/* MoCHI web app. PapersClaw / Illinois palette (spec §5.1). Self-hosted Inter + Playfair Display (OFL, fonts/).
   Dark = PapersClaw dark tokens. Light = Notion-like white surfaces with the PapersClaw light-theme orange #b34200.
   Derived for WCAG AA (not in PapersClaw): --accent-ink, --line-strong, --bar, --link-light, banner tints. */
@font-face { font-family: "Inter"; src: url("../fonts/Inter-var-latin.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "Playfair Display"; src: url("../fonts/PlayfairDisplay-var-latin.woff2") format("woff2"); font-weight: 400 900; font-display: swap; }

:root, :root[data-theme="dark"] {
  --bg: #001830; --bg-mid: #003a5c; --panel: #13294B; --panel-2: #1D3B6B; --line: #2C4E8A; --line-strong: #7f95b0; --bar: #000f1f;
  --text: #eef6ff; --muted: #9fb3ce; --accent: #ff5f05; --accent-ink: #001830; --accent-text: #ff5f05; --link: #00a3e0; --gold: #FCB316;
  --warn-bg: #FCB316; --warn-ink: #001830; --focus: #FCB316; --danger: #ffa08a; --ok-text: #bfe9ff;
  --banner-bg: #2b2205; --banner-line: #FCB316; --shadow: 0 10px 30px rgba(0,0,0,.45); --scrim: rgba(0,8,18,.66);
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #ffffff; --bg-mid: #e6f4fb; --panel: #f7f8fa; --panel-2: #eceff4; --line: #dfe3ea; --line-strong: #6b7c93; --bar: #ffffff;
  --text: #13294B; --muted: #4a5b73; --accent: #b34200; --accent-ink: #ffffff; --accent-text: #b34200; --link: #00628f; --gold: #8a5a00;
  --warn-bg: #FCB316; --warn-ink: #13294B; --focus: #b34200; --danger: #a12a12; --ok-text: #00466b;
  --banner-bg: #fff6dc; --banner-line: #b38000; --shadow: 0 10px 30px rgba(19,41,75,.18); --scrim: rgba(19,41,75,.35);
  color-scheme: light;
}
@media (prefers-color-scheme: light) {
  :root[data-theme="system"] {
    --bg: #ffffff; --bg-mid: #e6f4fb; --panel: #f7f8fa; --panel-2: #eceff4; --line: #dfe3ea; --line-strong: #6b7c93; --bar: #ffffff;
    --text: #13294B; --muted: #4a5b73; --accent: #b34200; --accent-ink: #ffffff; --accent-text: #b34200; --link: #00628f; --gold: #8a5a00;
    --warn-bg: #FCB316; --warn-ink: #13294B; --focus: #b34200; --danger: #a12a12; --ok-text: #00466b;
    --banner-bg: #fff6dc; --banner-line: #b38000; --shadow: 0 10px 30px rgba(19,41,75,.18); --scrim: rgba(19,41,75,.35);
    color-scheme: light;
  }
}
/* High contrast: pure black/white surfaces, white borders, thicker focus. Keeps the orange accent. */
:root.high-contrast { --line: var(--line-strong); }
:root.high-contrast[data-theme="dark"], :root.high-contrast[data-theme="system"] {
  --bg: #000000; --panel: #000000; --panel-2: #0b1a33; --bar: #000000; --text: #ffffff; --muted: #e3ecf7; --line: #ffffff; --line-strong: #ffffff; --link: #6fd3ff;
}
:root.high-contrast[data-theme="light"] { --bg: #ffffff; --panel: #ffffff; --panel-2: #f0f0f0; --text: #000000; --muted: #1d2733; --line: #000000; --line-strong: #000000; --link: #003c5a; --accent: #8f3500; }
@media (prefers-color-scheme: light) {
  :root.high-contrast[data-theme="system"] { --bg: #ffffff; --panel: #ffffff; --panel-2: #f0f0f0; --bar: #ffffff; --text: #000000; --muted: #1d2733; --line: #000000; --line-strong: #000000; --link: #003c5a; --accent: #8f3500; }
}
:root.large-text { font-size: 125%; }
:root.reduce-motion *, :root.reduce-motion *::before { transition: none !important; animation: none !important; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); overflow: hidden; }
body { font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif; font-size: 1rem; line-height: 1.45; -webkit-text-size-adjust: 100%; }
a { color: var(--link); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: 8px; top: -60px; background: var(--accent); color: var(--accent-ink); padding: 8px 12px; border-radius: 8px; z-index: 50; }
.skip:focus { top: 8px; }

.app { display: flex; flex-direction: column; height: 100dvh; max-width: 640px; margin: 0 auto; background: var(--bg); position: relative; }
.appbar { flex: none; height: 56px; display: flex; align-items: center; gap: 8px; padding: 0 12px 0 14px; border-bottom: 1px solid var(--line); padding-top: env(safe-area-inset-top); }
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--text); min-width: 0; }
.brandmark { flex: none; width: 48px; height: 36px; border-radius: 9px; display: block; }
.authors-more summary { cursor: pointer; color: var(--link); font-size: .85rem; min-height: 32px; display: flex; align-items: center; }
.brand > span { display: flex; flex-direction: column; line-height: 1.1; }
.wordmark { font-family: "Playfair Display", Georgia, serif; font-size: 1.35rem; font-weight: 700; letter-spacing: .2px; }
.wordmark span { color: var(--accent-text); }
.ctx { color: var(--muted); font-size: .78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand > span { min-width: 0; overflow: hidden; }
.clockpill { flex: none; }
.large-text .ctx { font-size: .7rem; }
.large-text .cl-demo { display: none; }
.large-text .brandmark { width: 40px; height: 30px; }
.spacer { flex: 1; }
.iconbtn { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; border: 1px solid var(--line); background: var(--panel); color: var(--text); text-decoration: none; cursor: pointer; }
.clockpill { min-height: 32px; padding: 2px 10px; border-radius: 999px; border: 1px dashed var(--line-strong); background: transparent; color: var(--muted); font-size: .75rem; cursor: pointer; white-space: nowrap; }
.banner { margin: 8px 12px 0; padding: 8px 12px; border-radius: 12px; border: 1px solid var(--banner-line); background: var(--banner-bg); font-size: .85rem; }

main { flex: 1; overflow-y: auto; padding: 14px 14px 20px; display: flex; flex-direction: column; gap: 12px; scroll-padding-bottom: 24px; }
main:focus { outline: none; }
main > * { flex-shrink: 0; }
h1 { font-family: "Playfair Display", Georgia, serif; font-size: 1.6rem; line-height: 1.2; margin: 0; }
h2 { font-size: 1.05rem; line-height: 1.3; margin: 0; }
h3 { font-size: 1rem; margin: 0; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; }
.card.accent { border-color: var(--accent); }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 4px; scrollbar-width: none; }
.chip { flex: none; min-height: 36px; padding: 6px 14px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--panel); color: var(--text); font-size: .9rem; cursor: pointer; }
.chip[aria-pressed="true"], .chip.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 700; }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: .74rem; font-weight: 700; border: 1px solid transparent; }
.badge.warn { background: var(--warn-bg); color: var(--warn-ink); }
.badge.award { border-color: var(--gold); color: var(--text); }
.badge.info { background: var(--bg-mid); color: var(--ok-text); border-color: var(--link); }
.badge.bad { border-color: var(--danger); color: var(--danger); background: transparent; }
.badge.type { border-color: var(--line-strong); color: var(--muted); font-weight: 600; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 14px; border-radius: 12px; font-weight: 700; font-size: .92rem; border: 1px solid var(--line-strong); background: var(--panel-2); color: var(--text); cursor: pointer; text-decoration: none; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn.sm { min-height: 36px; padding: 0 10px; font-size: .84rem; }
.btn[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.seg { display: flex; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 3px; gap: 3px; }
.seg a, .seg button { flex: 1; text-align: center; padding: 8px 0; min-height: 40px; border-radius: 9px; font-size: .9rem; font-weight: 700; color: var(--muted); text-decoration: none; background: transparent; border: 0; cursor: pointer; }
.seg [aria-current="page"], .seg [aria-pressed="true"] { background: var(--panel-2); color: var(--text); box-shadow: inset 0 0 0 2px var(--accent); }
.field { display: flex; flex-direction: column; gap: 4px; }
.input, select.input, textarea.input { width: 100%; min-height: 44px; padding: 8px 12px; border-radius: 12px; border: 1px solid var(--line-strong); background: var(--panel); color: var(--text); }
textarea.input { min-height: 88px; resize: vertical; }
.search { position: relative; }
.search .input { padding-left: 36px; }
.search::before { content: "⌕"; position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 1.1rem; }

/* sessions */
.sess { display: flex; gap: 12px; align-items: flex-start; }
.sess .t { width: 52px; flex: none; font-weight: 700; font-size: .9rem; font-variant-numeric: tabular-nums; }
.sess .t small { display: block; color: var(--muted); font-weight: 400; }
.sess .body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.sess .title { font-weight: 700; color: var(--text); text-decoration: none; }
.sess .title:hover { text-decoration: underline; }
.sess .meta { color: var(--muted); font-size: .82rem; }
.sess .why { font-size: .8rem; color: var(--muted); border-left: 3px solid var(--line-strong); padding-left: 6px; }
.slot { font-size: .8rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-top: 4px; }
.talk { border-top: 1px solid var(--line); padding-top: 8px; display: flex; flex-direction: column; gap: 4px; }
.talk:first-child { border-top: 0; padding-top: 0; }
.authors { color: var(--muted); font-size: .84rem; }
.caption { background: var(--bar); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; font-size: .95rem; line-height: 1.5; }
.caption .now { background: rgba(252,179,22,.3); border-radius: 4px; padding: 0 2px; outline: 1px solid var(--gold); }
.empty { text-align: center; padding: 24px 8px; color: var(--muted); }

/* guide log */
.log { display: flex; flex-direction: column; gap: 10px; }
.turn { max-width: 88%; padding: 10px 12px; border-radius: 14px; border: 1px solid var(--line); background: var(--panel); }
.turn.me { align-self: flex-end; background: var(--panel-2); }
.turn .mode { font-size: .75rem; color: var(--muted); display: block; margin-bottom: 2px; }
.turn ul { margin: 6px 0 0; padding-left: 18px; }

/* command bar + tabs */
.cmdbar { flex: none; padding: 8px 10px; display: flex; gap: 8px; align-items: center; border-top: 1px solid var(--line); background: var(--bar); position: relative; margin: 0; }
.cmdwrap { flex: 1; position: relative; }
#cmd { width: 100%; height: 48px; border-radius: 24px; border: 1px solid var(--line-strong); background: var(--panel); padding: 0 16px; color: var(--text); font-size: 1rem; }
#cmd:focus { outline: 3px solid var(--focus); outline-offset: 1px; }
#suggest { position: absolute; left: 0; right: 0; bottom: 56px; margin: 0; padding: 4px; list-style: none; background: var(--panel); border: 1px solid var(--line-strong); border-radius: 14px; box-shadow: var(--shadow); max-height: 50vh; overflow: auto; z-index: 20; }
#suggest li { padding: 10px 12px; border-radius: 10px; cursor: pointer; display: flex; justify-content: space-between; gap: 8px; font-size: .92rem; }
#suggest li[aria-selected="true"], #suggest li:hover { background: var(--panel-2); outline: 2px solid var(--accent); }
#suggest li small { color: var(--muted); }
.send { width: 44px; height: 44px; border-radius: 50%; background: var(--panel-2); border: 1px solid var(--line-strong); display: grid; place-items: center; color: var(--text); flex: none; cursor: pointer; }
.mic { width: 56px; height: 56px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; flex: none; border: 0; cursor: pointer; box-shadow: 0 0 0 4px rgba(255,95,5,.22); }
.mic svg { width: 26px; height: 26px; }
.mic[aria-pressed="true"] { animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 10px rgba(255,95,5,.15); } }
.tabs { flex: none; height: 62px; display: flex; border-top: 1px solid var(--line); background: var(--bar); padding-bottom: env(safe-area-inset-bottom); }
.tabs a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--muted); font-size: .75rem; text-decoration: none; }
.tabs .ti { font-size: 1.15rem; line-height: 1; padding: 3px 14px; }
.tabs a[aria-current="page"] { color: var(--accent-text); font-weight: 700; }
.tabs a[aria-current="page"] .ti { background: rgba(255,95,5,.18); border-radius: 12px; }

/* overlays */
.scrim { position: fixed; inset: 0; background: var(--scrim); z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 640px; background: var(--panel); border-top-left-radius: 22px; border-top-right-radius: 22px; border: 1px solid var(--line); padding: 14px 18px calc(22px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 12px; max-height: 88dvh; overflow: auto; box-shadow: var(--shadow); }
.grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line-strong); margin: 0 auto 2px; }
.bigmic { width: 96px; height: 96px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; margin: 4px auto; border: 0; cursor: pointer; box-shadow: 0 0 0 12px rgba(255,95,5,.18); }
.bigmic svg { width: 40px; height: 40px; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: 150px; z-index: 35; background: var(--panel-2); color: var(--text); border: 1px solid var(--line-strong); border-radius: 14px; padding: 10px 12px 10px 16px; display: flex; gap: 12px; align-items: center; box-shadow: var(--shadow); width: min(92vw, 520px); }
.toast[hidden] { display: none; }
.toast p { flex: 1; font-size: .92rem; }
.confirm .warnbox { border: 2px solid var(--warn-bg); border-radius: 12px; padding: 8px 10px; display: flex; flex-direction: column; gap: 4px; }
.setrow { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.setrow:last-child { border-bottom: 0; }
.setrow label, .setrow .lbl { flex: 1; }
.switch { appearance: none; width: 50px; height: 30px; border-radius: 15px; background: var(--panel-2); border: 1px solid var(--line-strong); position: relative; cursor: pointer; flex: none; margin: 0; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: var(--muted); transition: left .15s; }
.switch:checked { background: var(--accent); border-color: var(--accent); }
.switch:checked::after { left: 23px; background: var(--accent-ink); }
.thumb { width: 100%; max-height: 220px; object-fit: contain; border-radius: 12px; border: 1px solid var(--line); background: var(--bar); }
.progress { height: 6px; border-radius: 3px; background: var(--panel-2); overflow: hidden; }
.progress > i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.scanbtns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.scanbtn { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; text-align: left; padding: 14px; border-radius: 14px; border: 1px solid var(--line-strong); background: var(--panel); color: var(--text); cursor: pointer; min-height: 120px; }
.scanbtn b { font-size: 1rem; }
.scanbtn .ic { font-size: 1.6rem; }
ul.plain { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.kbd { font-family: ui-monospace, monospace; font-size: .8rem; border: 1px solid var(--line-strong); border-radius: 4px; padding: 0 4px; }
.noscript { padding: 20px; }
