:root {
  --paper: #f5f4ef;
  --paper-2: #ecebe4;
  --ink: #121211;
  --ink-2: #3b3a36;
  --muted: #6b6963; /* 4.6:1 on paper-2, 5:1 on paper (WCAG AA for small text) */
  --rule: #dedcd3;
  --accent: #ff4a1c;
  --accent-ink: #c2360d;    /* orange as text: 5:1 on paper (the bright one is 3:1) */
  --accent-strong: #cc3a10; /* fill behind white text */
  --accent-soft: rgba(255, 74, 28, 0.12);
  --hl: rgba(255, 196, 64, 0.42); /* shared idea: a study highlighter, not a red "wrong" underline */
  --card: #fbfaf7;
  --shadow: 0 1px 0 rgba(18, 18, 17, 0.04), 0 12px 32px -18px rgba(18, 18, 17, 0.25);

  --sans: "Inter Tight", ui-sans-serif, system-ui, -apple-system, sans-serif;
  --serif: "Newsreader", ui-serif, Georgia, serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}
/* Korean mode: Hangul falls back to a clean system Gothic instead of a mismatched serif. */
html:lang(ko) {
  --sans: "Inter Tight", "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", system-ui, sans-serif;
  --serif: "Newsreader", "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0f0f0e;
    --paper-2: #171716;
    --ink: #eeece6;
    --ink-2: #c4c2bb;
    --muted: #8e8c85;
    --rule: #2a2a27;
    --accent: #ff6a3d;
    --accent-ink: #ff6a3d;
    --accent-strong: #d9390c;
    --accent-soft: rgba(255, 106, 61, 0.14);
    --hl: rgba(255, 196, 64, 0.24);
    --card: #151514;
    --shadow: 0 1px 0 rgba(0, 0, 0, 0.3), 0 16px 40px -20px rgba(0, 0, 0, 0.8);
  }
}
:root[data-theme="dark"] {
  --paper: #0f0f0e;
  --paper-2: #171716;
  --ink: #eeece6;
  --ink-2: #c4c2bb;
  --muted: #8e8c85;
  --rule: #2a2a27;
  --accent: #ff6a3d;
  --accent-ink: #ff6a3d;
  --accent-strong: #d9390c;
  --accent-soft: rgba(255, 106, 61, 0.14);
  --hl: rgba(255, 196, 64, 0.24);
  --card: #151514;
  --shadow: 0 1px 0 rgba(0, 0, 0, 0.3), 0 16px 40px -20px rgba(0, 0, 0, 0.8);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; } /* components below set display; hidden must still win */
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
  display: grid;
  grid-template-rows: auto 1fr auto;
  grid-template-columns: minmax(0, 1fr); /* long one-line text in the header must not widen the page */
  overflow: hidden;
}
button, select { font: inherit; color: inherit; }
:where(button, select, a, [tabindex]):focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
kbd {
  font: 500 12px var(--mono);
  padding: 1px 6px;
  border: 1px solid var(--rule);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--card);
}

/* ── Top bar ───────────────────────────────────────── */
.bar {
  position: relative;
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 18px 40px;
  border-bottom: 1px solid var(--rule);
  background: var(--paper);
  z-index: 5;
}
.brand { display: flex; align-items: center; gap: 10px; flex: none; }
.mark {
  width: 18px; height: 18px; border-radius: 50%;
  background: conic-gradient(from 200deg, var(--accent), var(--ink) 70%, var(--accent));
  -webkit-mask: radial-gradient(circle, transparent 4px, #000 4.5px);
          mask: radial-gradient(circle, transparent 4px, #000 4.5px);
}
.word { font: 500 22px/1 var(--serif); font-style: italic; letter-spacing: -0.01em; }
.course {
  min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font: 400 12px var(--mono);
  color: var(--muted);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.controls { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.actions { display: flex; align-items: center; gap: 12px; }

.seg { display: inline-flex; padding: 3px; border-radius: 999px; background: var(--paper-2); }
.seg button {
  border: 0; background: none; cursor: pointer; white-space: nowrap;
  padding: 6px 14px; border-radius: 999px;
  font-size: 13px; font-weight: 500; color: var(--muted);
  transition: background 0.25s var(--ease), color 0.25s var(--ease);
}
.seg button.on { background: var(--card); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,0.08); }
.seg button:disabled { opacity: 0.4; cursor: not-allowed; }

.play {
  width: 38px; height: 38px; border-radius: 50%;
  border: 0; cursor: pointer;
  background: var(--ink); color: var(--paper);
  display: grid; place-items: center;
  transition: transform 0.2s var(--ease), background 0.2s;
}
.play:hover { transform: scale(1.06); }
.play .icon {
  width: 0; height: 0;
  border-left: 10px solid currentColor;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  margin-left: 3px;
}
.play.playing .icon {
  width: 10px; height: 12px; margin: 0;
  border: 0;
  border-left: 3px solid currentColor;
  border-right: 3px solid currentColor;
}
.play.live { background: var(--accent); color: #fff; }

select {
  appearance: none;
  border: 1px solid var(--rule); border-radius: 8px;
  padding: 6px 24px 6px 10px;
  background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='5'%3E%3Cpath d='M.5.5 4 4 7.5.5' fill='none' stroke='%238c8a82' stroke-width='1.3'/%3E%3C/svg%3E") no-repeat right 9px center;
  font: 500 12px var(--mono); cursor: pointer;
  transition: border-color 0.2s;
}
select:hover { border-color: var(--muted); }
select:disabled { opacity: 0.35; cursor: not-allowed; }
.clock { font: 500 13px var(--mono); color: var(--ink-2); text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.clock .total { color: var(--muted); font-weight: 400; }

/* Replay progress on the header's bottom edge; click or drag to jump. */
.progress {
  position: absolute; left: 0; right: 0; bottom: -1px; height: 9px;
  transform: translateY(4px);
  cursor: pointer; touch-action: none;
}
.progress::before, .progress-fill {
  content: ""; position: absolute; left: 0; top: 3px; height: 3px;
  transition: height 0.2s var(--ease), top 0.2s var(--ease);
}
.progress::before { right: 0; background: transparent; }
.progress-fill { width: 0; background: var(--accent); border-radius: 0 3px 3px 0; }
.progress:hover::before, .progress:focus-visible::before { background: var(--rule); }
.progress:hover::before, .progress:hover .progress-fill,
.progress:focus-visible::before, .progress:focus-visible .progress-fill { top: 2px; height: 5px; }
.progress:focus-visible { outline: none; }
.progress-tip {
  position: absolute; top: 12px; transform: translateX(-50%);
  padding: 3px 7px; border-radius: 6px;
  background: var(--ink); color: var(--paper);
  font: 500 11px var(--mono); pointer-events: none; white-space: nowrap;
}
.progress.off { display: none; }

.gear {
  position: relative;
  width: 36px; height: 36px; border-radius: 50%;
  border: 1px solid var(--rule); background: transparent; cursor: pointer;
  display: grid; place-items: center; color: var(--ink-2);
  transition: transform 0.4s var(--ease), border-color 0.2s;
}
.gear:hover { transform: rotate(40deg); border-color: var(--muted); }
.gear-dot {
  position: absolute; top: 4px; right: 4px; width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 0 2px var(--paper);
}
.gear-dot.ok { background: #2fa36b; }

.settings { position: fixed; inset: 0; z-index: 20; }
.settings-panel {
  position: absolute; top: 72px; right: 40px;
  width: min(380px, calc(100% - 32px));
  background: var(--card); border: 1px solid var(--rule); border-radius: 16px;
  padding: 20px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 14px;
  animation: enter 0.35s var(--ease) both;
}
.settings-panel .label:first-child { justify-content: space-between; }
.x {
  border: 0; background: none; cursor: pointer; color: var(--muted);
  font: 400 20px/1 var(--sans); padding: 0 2px; margin: -4px -4px 0 0;
}
.x:hover { color: var(--ink); }
.fine a { color: var(--ink-2); text-underline-offset: 2px; text-decoration-color: var(--rule); }
.fine a:hover { color: var(--accent-ink); }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--ink-2); }
.field input {
  font: 400 13px var(--mono); color: var(--ink);
  border: 1px solid var(--rule); border-radius: 10px;
  background: var(--paper); padding: 10px 12px;
}
.field input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field .seg { align-self: flex-start; }
.settings-panel { max-height: calc(100dvh - 96px); overflow-y: auto; }
.field textarea {
  font: 400 12px/1.5 var(--mono); color: var(--ink); resize: vertical;
  border: 1px solid var(--rule); border-radius: 10px; background: var(--paper); padding: 8px 10px;
}
.field textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.glossary summary { cursor: pointer; color: var(--ink-2); }
.glossary summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.glossary[open] { gap: 8px; }
/* A <details> body doesn't take the flex column, so labels and textareas flowed inline around each other: stack them. */
.glossary::details-content { display: flex; flex-direction: column; gap: 8px; }
.glossary > span, .glossary > textarea { display: block; width: 100%; box-sizing: border-box; }
.glossary > summary + span { margin-top: 8px; }
.glossary .assist-row { margin-top: 0; }
.check { display: flex; gap: 8px; align-items: flex-start; font-size: 12px; color: var(--ink-2); }
/* Live mic second pass: dotted while Gemini checks a line, ✦ once it replaced it, ‹G› for speech only Gemini heard. */
.line.pending .text { text-decoration: underline dotted var(--rule); text-underline-offset: 6px; }
.line.refined time::after, .line.filled time::after { content: " ✦"; color: #4b6bfb; }
.line.filled time::after { content: " ‹G›"; }
.fine { margin: 0; font-size: 12px; color: var(--muted); }
.row { display: flex; justify-content: flex-end; gap: 8px; }
.solid, .ghost {
  border-radius: 999px; padding: 7px 16px; cursor: pointer; font-size: 13px; font-weight: 500;
}
.solid { border: 0; background: var(--ink); color: var(--paper); }
.ghost { border: 1px solid var(--rule); background: transparent; color: var(--muted); }

/* ── Stage ─────────────────────────────────────────── */
.stage {
  --mem: clamp(360px, 42.5vw, 680px);   /* Throughlines keeps this width whether or not Assist is open */
  --pane: clamp(300px, 27vw, 430px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--mem) 0px;
  min-height: 0;
  transition: grid-template-columns 0.5s var(--ease);
}
.stage.assist-open { grid-template-columns: minmax(0, 1fr) var(--mem) var(--pane); }
/* Wide screens keep Throughlines exactly as it was; between ~1180 and ~1400 px it gives way so the transcript keeps ~420 px. */
.stage.assist-open { --mem: max(330px, min(clamp(360px, 42.5vw, 680px), calc(100vw - var(--pane) - 420px))); }
.stage.assist-open .line { font-size: 19px; } /* the narrower transcript keeps ~7 words a line */
.stage.assist-open .lecture-title { font-size: 34px; }
.label {
  display: flex; align-items: center; gap: 10px;
  font: 500 11px var(--mono);
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted);
}
.label .hint { text-transform: none; letter-spacing: 0; font-family: var(--sans); font-size: 12px; opacity: 0.8; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--rule); transition: background 0.3s; }
.dot.on { background: var(--accent); animation: pulse 1.6s infinite; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 var(--accent-soft); }
  70% { box-shadow: 0 0 0 8px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

.now {
  padding: 40px 56px 0;
  display: flex; flex-direction: column;
  min-height: 0;
  border-right: 1px solid var(--rule);
}
.lecture-title {
  margin: 14px 0 28px;
  font: 400 40px/1.08 var(--serif);
  letter-spacing: -0.02em;
  max-width: 18ch;
}
.lecture-title small {
  display: block; margin-bottom: 6px;
  font: 400 13px var(--mono); letter-spacing: 0; color: var(--muted);
}

/* Older lines fade out at the top edge, but only once they have scrolled there —
   the first lines of a lecture are never under the fade. */
.transcript {
  position: relative; /* lines' offsetTop is measured from here */
  --fade-top: 0px;
  flex: 1;
  overflow-y: auto;
  padding: 4px 0 40vh;
  scrollbar-width: none;
  -webkit-mask: linear-gradient(to bottom, transparent 0, #000 var(--fade-top), #000 calc(100% - 96px), transparent);
          mask: linear-gradient(to bottom, transparent 0, #000 var(--fade-top), #000 calc(100% - 96px), transparent);
}
.transcript.scrolled { --fade-top: 56px; }
.transcript::-webkit-scrollbar { display: none; }
.empty { margin-top: 24px; color: var(--muted); font: 400 22px/1.5 var(--serif); }
.line.instant .w { animation: none; opacity: 1; transform: none; }
.mic-error { margin-top: 24px; padding: 14px 16px; border-radius: 12px; background: var(--accent-soft); color: var(--ink); font: 400 15px/1.5 var(--sans); }
.mic-error b { color: var(--accent-ink); font-weight: 600; }
.lecture-end {
  display: flex; align-items: center; flex-wrap: wrap; gap: 12px;
  margin: 28px 0 0 70px; padding-top: 18px; border-top: 1px dashed var(--rule);
  font: 400 12px var(--mono); color: var(--muted);
  animation: enter 0.5s var(--ease) both;
}
.lecture-end .quiz { font-size: 13px; }
.empty em { color: var(--ink); }
.keys { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 18px 0 0; font-size: 12px; color: var(--muted); }
.keys kbd + kbd { margin-left: -2px; }
.keys kbd:not(:first-child):not(kbd + kbd) { margin-left: 12px; }
.mic-error code { font: 13px var(--mono); }

.line {
  display: grid;
  grid-template-columns: 58px 1fr;
  gap: 12px;
  margin: 0 0 18px;
  font: 400 22px/1.5 var(--serif);
  color: var(--muted);
  transition: color 0.6s var(--ease);
}
.line.current { color: var(--ink); }
.line.asked { padding-bottom: 14px; margin-bottom: 14px; border-bottom: 1px dashed var(--rule); } /* Live Q&A: one question ends here */
.line.recent { color: var(--ink-2); }
.line time { font: 400 12px/2.8 var(--mono); color: var(--muted); font-variant-numeric: tabular-nums; }
.line .w { opacity: 0; display: inline-block; transform: translateY(4px); animation: rise 0.45s var(--ease) forwards; }
@keyframes rise { to { opacity: 1; transform: none; } }
.line.interim { color: var(--muted); font-style: italic; }
.hit, mark {
  /* a marker stroke over the lower half of the letters, hugging the baseline */
  background: linear-gradient(transparent 45%, var(--hl) 45%, var(--hl) 88%, transparent 88%);
  border-radius: 2px;
  transition: background 0.4s;
}
/* transcript words are inline-blocks as tall as the line, so the band sits higher to stay on the letters */
.line .w.hit { background: linear-gradient(transparent 38%, var(--hl) 38%, var(--hl) 76%, transparent 76%); }

/* ── Memory column ─────────────────────────────────── */
.memory {
  padding: 40px 40px 0;
  display: flex; flex-direction: column;
  min-height: 0;
  background: linear-gradient(to bottom, transparent, var(--paper-2) 140%);
}
.timeline {
  list-style: none; margin: 18px 0 26px; padding: 0;
  display: flex; gap: 6px;
}
.timeline li {
  flex: 1;
  min-width: 0;
  position: relative;
  padding-top: 14px;
  font: 500 11px var(--mono); color: var(--muted);
  transition: color 0.3s;
}
.timeline li::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 4px;
  border-radius: 4px; background: var(--rule);
  transition: background 0.4s var(--ease);
}
.timeline li span { display: block; font: 400 12px var(--sans); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.timeline li.lit { color: var(--ink); }
.timeline li.lit::before { background: color-mix(in srgb, var(--accent) 30%, var(--rule)); }
.ticks { position: absolute; left: 0; right: 0; top: 0; height: 4px; }
.ticks b {
  position: absolute; top: -2px; width: 2px; height: 8px; margin-left: -1px; border-radius: 1px;
  background: var(--ink-2); opacity: 0.28;
  transition: opacity 0.3s, background 0.3s;
}
.ticks b.on { background: var(--accent); opacity: 1; z-index: 1; }
.timeline li.today::before { background: var(--ink); }
.timeline li.today { color: var(--ink); }

.cards {
  flex: 1; overflow-y: auto; padding-bottom: 40px;
  display: flex; flex-direction: column; gap: 12px;
  scrollbar-width: thin;
}
.card {
  position: relative;
  border: 1px solid var(--rule);
  border-radius: 14px;
  background: var(--card);
  padding: 16px 18px 16px 20px;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.35s var(--ease), border-color 0.25s, opacity 0.35s;
  animation: enter 0.55s var(--ease) both;
  text-align: left; width: 100%;
}
.card::before {
  content: ""; position: absolute; left: -1px; top: 16px; bottom: 16px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--accent);
  transform: scaleY(0); transform-origin: top;
  animation: grow 0.6s 0.15s var(--ease) forwards;
}
.card:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--accent) 40%, var(--rule)); }
.card:has(.card-open:focus-visible) { border-color: var(--accent); }
.card-open {
  all: unset; cursor: pointer;
  font: inherit; color: inherit; letter-spacing: inherit;
}
.card-open:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 3px; }
.hold {
  margin-left: auto; padding: 2px 8px; border-radius: 999px;
  background: var(--paper-2); color: var(--ink-2);
  font: 500 10px var(--mono); letter-spacing: 0.04em; text-transform: none;
  animation: fade 0.25s both;
}
.card.seen, .card.seen::before { animation: none; }
.card.seen::before { transform: none; }
@keyframes enter { from { opacity: 0; transform: translateY(10px) scale(0.985); } }
@keyframes grow { to { transform: scaleY(1); } }

.card-meta {
  display: flex; align-items: center; gap: 8px;
  font: 500 11px var(--mono); color: var(--muted);
  letter-spacing: 0.02em;
}
.card-meta .tag {
  padding: 2px 7px; border-radius: 999px;
  background: var(--paper-2); color: var(--ink-2);
}
.card-meta .tag.slide { background: var(--accent-soft); color: var(--accent-ink); }
/* Claude graded every candidate 0: the local best is shown, but visibly unsure (no opacity, so text keeps its contrast). */
.card.weak { border-style: dashed; box-shadow: none; }
.card.weak::before { background: var(--rule); }
.card.weak p { color: var(--muted); }
.card-meta .tag.weak { background: transparent; border: 1px dashed var(--rule); color: var(--muted); }
.card-meta .score { margin-left: auto; display: flex; gap: 2px; }
.card-meta .score i { width: 4px; height: 10px; border-radius: 1px; background: var(--rule); }
.card-meta .score i.f { background: var(--ink-2); }
.card h2 { margin: 8px 0 6px; font: 500 15px/1.3 var(--sans); letter-spacing: -0.005em; }
.card p { margin: 0; font: 400 16px/1.5 var(--serif); color: var(--ink-2); }
mark { color: var(--ink); }
.card .why { margin-top: 10px; font: 400 11px var(--mono); color: var(--muted); }
.card .why b { font-weight: 500; color: var(--accent-ink); }

.card-actions { display: flex; gap: 6px; margin-top: 12px; }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--rule); background: transparent; cursor: pointer;
  border-radius: 999px; padding: 4px 11px;
  font: 500 12px var(--sans); color: var(--ink-2);
  transition: border-color 0.2s, color 0.2s, background 0.2s;
}
.pill:hover { border-color: var(--accent); color: var(--accent-ink); }
.pill.on { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.pill .spark { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }

.ai {
  margin-top: 12px; padding: 12px 14px;
  border-radius: 10px; background: var(--paper-2);
  cursor: auto;
  animation: enter 0.35s var(--ease) both;
}
.card.seen .ai { animation: none; }
.ai-head { display: flex; align-items: center; gap: 8px; font: 500 10px var(--mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.ai-head button { margin-left: auto; border: 0; background: none; cursor: pointer; color: var(--muted); font: 500 14px var(--sans); padding: 0 2px; }
.ai-text { margin-top: 6px; font: 400 15px/1.55 var(--sans); color: var(--ink); white-space: pre-wrap; }
.ai.streaming .ai-text::after {
  content: ""; display: inline-block; width: 7px; height: 15px; margin-left: 2px;
  vertical-align: -2px; background: var(--accent); animation: blink 0.9s steps(2) infinite;
}
@keyframes blink { 50% { opacity: 0; } }
.ai.error .ai-text { color: var(--accent-ink); }

.cards-empty {
  margin-top: 8px; padding: 28px 0;
  border-top: 1px dashed var(--rule);
  color: var(--muted); font: 400 16px/1.5 var(--serif);
}

/* ── Footer ────────────────────────────────────────── */
.status {
  display: flex; justify-content: space-between; gap: 24px;
  padding: 10px 40px;
  border-top: 1px solid var(--rule);
  font: 400 11px var(--mono); color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* ── Drawer ────────────────────────────────────────── */
.drawer { position: fixed; inset: 0; z-index: 30; }
.drawer-scrim { position: absolute; inset: 0; background: rgba(10, 10, 9, 0.28); backdrop-filter: blur(3px); animation: fade 0.3s both; }
.drawer-panel {
  position: absolute; right: 0; top: 0; bottom: 0;
  width: min(560px, 100%);
  background: var(--paper);
  border-left: 1px solid var(--rule);
  padding: 0 44px 40px;
  overflow-y: auto; /* .ctx offsetTop is measured from here */
  animation: slide 0.45s var(--ease) both;
}
@keyframes fade { from { opacity: 0; } }
@keyframes slide { from { transform: translateX(40px); opacity: 0; } }
/* Lecture · time and the close button stay at the top while the context scrolls. */
.drawer-head {
  position: sticky; top: 0; z-index: 1;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin: 0 -44px; padding: 26px 44px 12px;
  background: linear-gradient(var(--paper) 78%, transparent);
}
.drawer-close {
  flex: none;
  border: 1px solid var(--rule); background: var(--card);
  border-radius: 6px; padding: 3px 8px; cursor: pointer;
  font: 500 11px var(--mono); color: var(--muted);
}
.drawer-meta { font: 500 11px var(--mono); color: var(--muted); letter-spacing: 0.06em; text-transform: uppercase; }
.drawer h2 { margin: 2px 0 28px; font: 400 32px/1.1 var(--serif); letter-spacing: -0.02em; }
.ctx { display: grid; grid-template-columns: 52px 1fr; gap: 10px; margin-bottom: 14px; font: 400 18px/1.5 var(--serif); color: var(--muted); }
.ctx time { font: 400 12px/2.4 var(--mono); }
.ctx.focus { color: var(--ink); }
.ctx.focus time { color: var(--accent-ink); }
.slide-view {
  aspect-ratio: 16 / 10;
  border: 1px solid var(--rule); border-radius: 12px;
  background: var(--card);
  padding: 32px;
  display: flex; flex-direction: column; justify-content: center;
}
.slide-view h4 { margin: 0 0 14px; font: 500 26px/1.15 var(--sans); letter-spacing: -0.02em; }
.slide-view p { margin: 0; font: 400 17px/1.5 var(--serif); color: var(--ink-2); }

/* ── Small screens ─────────────────────────────────── */
/* Mid widths: tighten the header before anything wraps. */
@media (max-width: 1180px) {
  .bar { gap: 18px; padding: 16px 28px; }
  .controls { gap: 10px; }
  .now { padding: 32px 36px 0; }
  .memory { padding: 32px 28px 0; }
  .stage { --mem: clamp(330px, 45vw, 560px); --pane: 300px; }
  .stage.assist-open { --mem: clamp(300px, 34vw, 560px); } /* narrow laptops: the transcript must keep some room */
}
@media (max-width: 1020px) {
  .course { display: none; }
  #latency { display: none; }
}
@media (max-width: 1180px) { .fine-stat { display: none; } } /* the footer would ellipsize mid-word */

/* Phones and narrow windows: one column, the page scrolls, the header (with play) stays put. */
@media (max-width: 860px) {
  html, body { height: auto; }
  body { display: block; overflow: visible; }
  .bar {
    position: sticky; top: 0;
    display: grid; grid-template-columns: 1fr auto; grid-template-areas: "brand actions" "course course" "controls controls";
    gap: 8px 12px; padding: 12px 16px 14px;
  }
  .brand { grid-area: brand; }
  .actions { grid-area: actions; gap: 10px; }
  .course { display: block; grid-area: course; font-size: 11px; }
  .controls { grid-area: controls; margin: 4px 0 0; justify-content: space-between; gap: 8px; }
  .clock .total { display: none; }
  .quiz { padding: 7px 12px; }
  .stage { display: block; }
  .now { padding: 20px 16px 0; border-right: 0; height: 58vh; height: 58svh; border-bottom: 1px solid var(--rule); }
  .lecture-title { font-size: 28px; margin: 10px 0 18px; }
  .line { font-size: 19px; grid-template-columns: 44px 1fr; gap: 8px; margin-bottom: 14px; }
  .line time { line-height: 2.5; }
  .transcript { padding-bottom: 30vh; }
  .lecture-end { margin-left: 52px; }
  .memory { padding: 24px 16px 8px; background: var(--paper-2); }
  .timeline { margin: 14px 0 18px; }
  .timeline li span { display: none; }
  .cards { overflow: visible; padding-bottom: 16px; }
  .status { flex-direction: column; gap: 4px; padding: 14px 16px 24px; }
  body .status span { white-space: normal; } /* beats the one-line rule further down */
  #latency { display: none; }
  .settings-panel { top: 64px; right: 16px; }
  .drawer-panel { padding: 0 20px 32px; }
  .drawer-head { margin: 0 -20px; padding: 18px 20px 10px; }
  .drawer h2 { font-size: 26px; }
  .ctx { grid-template-columns: 46px 1fr; font-size: 17px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

.status span { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status #measured { flex-shrink: 0; } /* the evaluation line never loses its "how" link; the credit shrinks instead */
.status a { color: inherit; text-decoration: underline; text-decoration-color: var(--rule); text-underline-offset: 2px; }
.status a:hover { color: var(--ink); }

/* ── Quiz button ───────────────────────────────────── */
.quiz {
  border: 0; cursor: pointer; white-space: nowrap;
  border-radius: 999px; padding: 8px 14px 8px 16px;
  background: var(--accent-strong); color: #fff;
  font: 500 13px var(--sans);
  display: inline-flex; align-items: center; gap: 8px;
  animation: enter 0.4s var(--ease) both;
}
.quiz span { font: 500 11px var(--mono); background: rgba(255,255,255,0.22); border-radius: 999px; padding: 1px 7px; }
.quiz.nudge { animation: nudge 1.8s var(--ease) infinite; }
@keyframes nudge { 0%, 100% { box-shadow: 0 0 0 0 var(--accent-soft); } 50% { box-shadow: 0 0 0 10px transparent; } }

/* ── Oral exam ─────────────────────────────────────── */
.exam { position: fixed; inset: 0; z-index: 15; background: var(--paper); overflow-y: auto; animation: fade 0.3s both; }
.exam-panel { max-width: 760px; margin: 0 auto; padding: 28px 24px 80px; }
.exam-top {
  display: flex; align-items: center; gap: 18px;
  padding-bottom: 18px; border-bottom: 1px solid var(--rule);
}

.exam-top .model { font: 400 11px var(--mono); color: var(--muted); }
.dots { display: flex; gap: 6px; margin-right: auto; }
.dots i { width: 22px; height: 4px; border-radius: 4px; background: var(--rule); transition: background 0.3s; }
.dots i.cur { background: var(--ink); }
.dots i.correct { background: #2fa36b; }
.dots i.partial { background: #e0a43a; }
.dots i.incorrect { background: var(--accent); }
.speak { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); cursor: pointer; }
.speak input { accent-color: var(--accent); }

.exam-body { padding-top: 56px; }
.kicker { margin: 0 0 14px; font: 500 11px var(--mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.q { margin: 0 0 28px; font: 400 38px/1.15 var(--serif); letter-spacing: -0.02em; }
.sub { font: 400 18px/1.5 var(--serif); color: var(--ink-2); }
.warn { font-size: 13px; color: var(--accent-ink); }
.shimmer {
  background: linear-gradient(90deg, var(--ink) 30%, var(--muted) 50%, var(--ink) 70%);
  background-size: 200% 100%; -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: shimmer 1.8s linear infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }

.answer { display: flex; gap: 16px; align-items: flex-start; }
.answer.locked { opacity: 0.6; }
.mic {
  flex: none; width: 64px; height: 64px; border-radius: 50%;
  border: 1px solid var(--rule); background: var(--card); cursor: pointer;
  display: grid; place-items: center; box-shadow: var(--shadow);
  transition: transform 0.2s var(--ease), background 0.2s;
}
.mic span { width: 14px; height: 22px; border-radius: 8px; background: var(--ink); position: relative; }
.mic span::after { content: ""; position: absolute; left: -5px; right: -5px; bottom: -7px; height: 10px; border: 2px solid var(--ink); border-top: 0; border-radius: 0 0 12px 12px; }
.mic:hover { transform: scale(1.05); }
.mic.on { background: var(--accent); border-color: var(--accent); animation: nudge 1.4s infinite; }
.mic.on span { background: #fff; }
.mic.on span::after { border-color: #fff; }
.answer textarea {
  flex: 1; resize: vertical; min-height: 96px;
  font: 400 18px/1.5 var(--serif); color: var(--ink);
  background: var(--card); border: 1px solid var(--rule); border-radius: 14px; padding: 14px 16px;
}
.answer textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.exam-row { display: flex; justify-content: flex-end; gap: 8px; margin-top: 22px; }

.verdict {
  margin-top: 26px; padding: 16px 18px; border-radius: 14px;
  font: 400 16px/1.5 var(--sans); background: var(--paper-2);
  border-left: 3px solid var(--muted);
  animation: enter 0.4s var(--ease) both;
}
.verdict b { font-weight: 600; margin-right: 6px; }
.verdict.correct { border-color: #2fa36b; }
.verdict.partial { border-color: #e0a43a; }
.verdict.incorrect { border-color: var(--accent); }
.missing { display: block; margin-top: 6px; font: 400 12px var(--mono); color: var(--muted); }

.review {
  display: flex; flex-direction: column; gap: 4px; width: 100%; text-align: left;
  margin-top: 14px; padding: 16px 18px; cursor: pointer;
  border: 1px solid var(--rule); border-radius: 14px; background: var(--card); box-shadow: var(--shadow);
  transition: transform 0.25s var(--ease), border-color 0.2s;
  animation: enter 0.45s 0.1s var(--ease) both;
}
.review:hover { transform: translateY(-2px); border-color: var(--accent); }
.review-meta { font: 500 11px var(--mono); color: var(--accent-ink); }
.review-title { font: 500 15px var(--sans); }
.review-text { font: 400 15px/1.5 var(--serif); color: var(--ink-2); }
.review-list { margin-top: -6px; }

@media (max-width: 860px) {
  .exam-top { flex-wrap: wrap; gap: 10px; }
  .q { font-size: 28px; }
  .exam-body { padding-top: 32px; }
  .mic { width: 52px; height: 52px; }
}

.label.sep { margin-top: 6px; padding-top: 14px; border-top: 1px solid var(--rule); }
.card-meta .tag.sem { background: color-mix(in srgb, #4b6bfb 14%, transparent); color: #4b6bfb; }
.gear-dot.sem { background: #4b6bfb; }
.gear-dot.ok.sem { background: linear-gradient(90deg, #2fa36b 50%, #4b6bfb 50%); } /* both keys: green + blue */

.kplay {
  display: inline-block; width: 0; height: 0; margin: 0 3px 0 4px; vertical-align: 1px;
  border-left: 10px solid var(--ink); border-top: 6px solid transparent; border-bottom: 6px solid transparent;
}
.q:focus { outline: none; }

/* ── Assist: what to say back / what to ask ───────── */
.assist-pane {
  grid-column: 3; grid-row: 1; /* Assist and Lookup share the column; only the open one (.on) shows */
  min-width: 0; min-height: 0; overflow: hidden;
  border-left: 1px solid var(--rule); background: var(--paper-2);
}
.stage:not(.assist-open) .assist-pane { border-left-color: transparent; }
.assist-pane:not(.on) { pointer-events: none; background: transparent; border-left-color: transparent; }
/* The content keeps its full width while the column opens, then slides in; closing reverses it. */
.pane-inner {
  width: var(--pane); height: 100%; overflow-y: auto;
  padding: 40px 28px 24px; display: flex; flex-direction: column; gap: 12px;
  transform: translateX(32px); opacity: 0;
  transition: transform 0.5s var(--ease), opacity 0.3s;
}
.assist-pane.on .pane-inner { transform: none; opacity: 1; transition-delay: 0.08s; }
.assist-pane .label { justify-content: space-between; }
.assist-pane .label .hint { margin-right: auto; }
.assist-pane textarea {
  display: block; width: 100%; resize: vertical; min-height: 54px; max-height: 20vh;
  font: 400 16px/1.45 var(--serif); color: var(--ink);
  background: var(--card); border: 1px solid var(--rule); border-radius: 12px; padding: 10px 12px;
}
.assist-pane textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.assist-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.assist-pane .seg { margin-top: 2px; }
.assist-pane .seg button { font-size: 12px; }
.assist-pane .ai { margin-top: 0; background: var(--card); }
.pill.tab[aria-expanded="true"] { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.bar .pill.tab { padding: 7px 14px; font-size: 13px; white-space: nowrap; }
@media (max-width: 860px) { .bar .pill.tab { padding: 6px 10px; } }
.theme-icon::before { content: "◐"; font-size: 16px; line-height: 1; }
:root[data-theme="light"] .theme-icon::before { content: "☀"; }
:root[data-theme="dark"] .theme-icon::before { content: "☾"; }
@media (prefers-reduced-motion: reduce) { .stage, .pane-inner { transition: none; } }
/* Phones: Assist is a sheet that slides up over the page. */
@media (max-width: 860px) {
  .assist-pane {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 15; max-height: 72vh; max-height: 72svh;
    border-left: 0; border-top: 1px solid var(--rule); border-radius: 16px 16px 0 0; box-shadow: var(--shadow);
    transform: translateY(105%); transition: transform 0.45s var(--ease);
  }
  .assist-pane.on { transform: none; }
  .pane-inner { width: auto; max-height: 72svh; padding: 18px 16px 24px; transform: none; opacity: 1; }
}

.check a { color: inherit; }

.help-btn { font: 500 14px/1 var(--sans); color: var(--ink-2); }
.help-btn:hover { transform: none; }
.help {
  width: min(440px, calc(100% - 32px)); max-height: calc(100dvh - 64px); overflow-y: auto;
  background: var(--card); color: var(--ink); border: 1px solid var(--rule); border-radius: 16px;
  padding: 20px; box-shadow: var(--shadow);
}
.help::backdrop { background: rgba(0, 0, 0, 0.25); }
.help .label:first-child { justify-content: space-between; }
.help dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 10px 0 16px; font-size: 13px; }
.help dt { font-weight: 500; }
.help dd { margin: 0; color: var(--ink-2); }
.help dl:not(.keys) { grid-template-columns: 1fr; gap: 2px; }
.help dl:not(.keys) dd { margin-bottom: 8px; }
.help kbd { font: 12px var(--mono); border: 1px solid var(--rule); border-radius: 4px; padding: 0 4px; }
@media (max-width: 860px), (pointer: coarse) { .help-btn { display: none; } } /* phones: no keyboard, and the header row is full */
html, body { overflow-x: clip; } /* the closed Assist pane waits just past the right edge: no 1 px sideways scroll */
@media (max-width: 430px) { #themeBtn { display: none; } .actions { gap: 6px; } } /* phones: the action row would overflow; the theme follows the system there */
@media (max-width: 430px) { .word { font-size: 19px; } .brand { gap: 8px; } .bar .pill.tab { padding: 6px 8px; font-size: 12px; } .bar .quiz { padding: 6px 10px; font-size: 12px; } } /* room for Assist + Lookup */
.memory-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.file-pick { cursor: pointer; }
.file-pick input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.file-pick:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.lecture-end [data-save] { margin-left: 8px; }

/* ── Lookup: a word you heard, from the course memory ─ */
.lookup-form { display: flex; gap: 6px; }
.lookup-form input {
  flex: 1; min-width: 0; font: 400 16px var(--serif); color: var(--ink);
  background: var(--card); border: 1px solid var(--rule); border-radius: 12px; padding: 9px 12px;
}
.lookup-form input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.lookup-sub { margin-top: 6px; font: 500 10px var(--mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
#lookupLocal, #lookupHistory { display: flex; flex-direction: column; gap: 8px; }
#lookupLocal:empty, #lookupHistory:empty { display: none; }
.review.lookup-hit { margin-top: 0; padding: 10px 12px; font: inherit; color: inherit; animation: none; }
.review.lookup-hit .review-text { font-size: 14px; }
.line:not(.interim) .w { cursor: pointer; }
.line:not(.interim) .w:hover { text-decoration: underline dotted var(--muted); text-underline-offset: 3px; }
.line.flash { animation: flash 1.6s var(--ease); }
@keyframes flash { 0%, 40% { background: var(--accent-soft); } 100% { background: transparent; } }
