/* Layout: video + dark "stage" for the subtitle line on the left, tabbed side panel on the right.
   Page follows the system theme; the subtitle stage is always dark, like a cinema screen. */
:root {
  --bg: #eef1f4;
  --surface: #ffffff;
  --surface-2: #f5f7f9;
  --ink: #18212b;
  --ink-2: #56616e;
  --ink-3: #8a94a0;
  --line: #dde3e9;
  --accent: #0f766e;
  --accent-ink: #ffffff;
  --accent-soft: #e0f2ef;
  --good: #15803d;
  --warn: #b45309;
  --bad: #b91c1c;
  --good-soft: #dcfce7;
  --warn-soft: #fef3c7;
  --bad-soft: #fee2e2;

  --stage: #0d1117;
  --stage-2: #161c25;
  --stage-ink: #f3f5f8;
  --stage-ink-2: #9aa5b4;
  --gloss: #ffc65c;
  --gloss-soft: rgba(255, 198, 92, 0.14);
  --forced: #7cc8ff;
  --forced-soft: rgba(124, 200, 255, 0.16);
  --inbook: #6ee7b7;

  --font: "Figtree", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
  --font-zh: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 8px 24px rgba(16, 24, 40, 0.06);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0f14; --surface: #131a22; --surface-2: #19212b; --ink: #e7ecf1; --ink-2: #a3aebb;
    --ink-3: #6f7b88; --line: #26313d; --accent: #2dd4bf; --accent-ink: #062b27; --accent-soft: #0f2f2c;
    --good: #4ade80; --warn: #fbbf24; --bad: #f87171;
    --good-soft: #10291a; --warn-soft: #2e2510; --bad-soft: #321616;
    --stage: #070a0e; --stage-2: #10161e;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b0f14; --surface: #131a22; --surface-2: #19212b; --ink: #e7ecf1; --ink-2: #a3aebb;
  --ink-3: #6f7b88; --line: #26313d; --accent: #2dd4bf; --accent-ink: #062b27; --accent-soft: #0f2f2c;
  --good: #4ade80; --warn: #fbbf24; --bad: #f87171;
  --good-soft: #10291a; --warn-soft: #2e2510; --bad-soft: #321616;
  --stage: #070a0e; --stage-2: #10161e;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 15px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
svg { display: block; }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 20px; padding-block: 12px;
  padding-left: max(20px, env(safe-area-inset-left, 0px)); padding-right: max(20px, env(safe-area-inset-right, 0px));
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.brand-mark { width: 32px; height: 32px; }
.bm-bg { fill: var(--stage); }
.bm-line { fill: var(--stage-ink); opacity: 0.85; }
.bm-gloss { fill: var(--gloss); }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-weight: 700; font-size: 16px; letter-spacing: -0.01em; }
.brand-sub { font-size: 12px; color: var(--ink-2); }
.video-bar { flex: 1; min-width: 0; display: flex; gap: 8px; align-items: center; }
.video-bar select {
  min-width: 0; max-width: 340px; flex: 0 1 auto; height: 36px; padding: 0 30px 0 10px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); color: var(--ink);
  font: inherit; font-size: 14px; text-overflow: ellipsis;
}
.url-form { display: flex; gap: 6px; flex: 1 1 260px; min-width: 0; max-width: 460px; }
.url-form input {
  flex: 1; min-width: 0; height: 36px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); color: var(--ink); font: inherit; font-size: 14px;
}
.live-hint {
  flex: 1 1 260px; min-width: 0; font-size: 12.5px; line-height: 1.4; color: var(--warn);
  background: var(--warn-soft); border-radius: 8px; padding: 6px 10px;
}
.url-form input:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }

/* live generation progress */
.gen { display: flex; align-items: center; gap: 8px; flex-basis: 100%; font-size: 12.5px; color: var(--ink-2); }
.gen-bar { flex: 0 0 120px; height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.gen-bar > span { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width 0.3s; }
.gen.done .gen-bar > span { background: var(--good); }
.tr-row.pending { opacity: 0.5; }
.top-actions { display: flex; gap: 8px; align-items: center; }

.btn {
  border: 1px solid transparent; border-radius: 10px; padding: 8px 14px; font-weight: 600; font-size: 14px;
  cursor: pointer; background: var(--surface-2); color: var(--ink); white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(1.06); }
.btn-ghost { background: transparent; border-color: var(--line); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-sm { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.icon-btn { width: 36px; height: 36px; padding: 0; display: grid; place-items: center; }
.link-btn {
  border: 0; background: none; padding: 0; color: var(--accent); font-size: 13px; font-weight: 600; cursor: pointer;
}
.link-btn:hover { text-decoration: underline; }

/* ---------- layout ---------- */
.layout {
  display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 20px; align-items: start;
  max-width: 1440px; margin: 0 auto; padding-block: 20px;
  padding-left: max(20px, env(safe-area-inset-left, 0px)); padding-right: max(20px, env(safe-area-inset-right, 0px));
}
.main-col { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }

.player-frame {
  position: relative; width: 100%; max-width: 100%; aspect-ratio: 16 / 9; background: #000;
  border-radius: var(--radius) var(--radius) 0 0; overflow: hidden;
}
.player-frame iframe, #yt { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.player-frame { container-type: inline-size; }

/* subtitles inside the video: sized from the video width, so they scale up in fullscreen */
.overlay-subs {
  position: absolute; left: 0; right: 0; bottom: max(64px, 13%); z-index: 3;   /* clear of YouTube's control bar */
  display: flex; justify-content: center; padding: 0 4%; pointer-events: none;
}
.overlay-subs .stage-text {
  min-height: 0; gap: 0; pointer-events: auto; max-width: 100%;
  font-size: clamp(15px, 2.5cqw, 46px); color: var(--stage-ink);
  background: rgba(6, 8, 12, 0.74); border-radius: 0.45em; padding: 0.1em 0.75em 0.15em;
}
.overlay-subs .line { font-size: 1em; line-height: 2.05; }
.overlay-subs .line.paren { line-height: 1.5; padding: 0.2em 0; }
.overlay-subs .line-zh { font-size: 0.72em; color: #d5dbe3; padding-bottom: 0.3em; }

/* fullscreen: our own (video + subtitles together) */
.player-frame:fullscreen { aspect-ratio: auto; width: 100%; height: 100%; max-width: none; border-radius: 0; background: #000; }
.player-frame.pseudo-fs { position: fixed; inset: 0; z-index: 40; aspect-ratio: auto; width: auto; height: auto; max-width: none; border-radius: 0; background: #000; }
.player-frame:fullscreen .overlay-subs, .player-frame.pseudo-fs .overlay-subs { bottom: max(90px, 11%); }
.fs-bar {
  /* top centre: YouTube puts its own title on the left and buttons on the right */
  display: none; position: absolute; z-index: 4; gap: 6px; opacity: 0.5; transition: opacity 0.2s;
  top: max(14px, env(safe-area-inset-top, 0px)); left: 50%; transform: translateX(-50%);
}
.player-frame:fullscreen .fs-bar, .player-frame.pseudo-fs .fs-bar { display: flex; }
.fs-bar:hover, .fs-bar:focus-within { opacity: 1; }
.fs-bar .sbtn { background: rgba(16, 22, 30, 0.85); }

/* ---------- stage (always dark) ---------- */
.stage {
  margin-top: -14px; background: var(--stage); color: var(--stage-ink);
  border-radius: 0 0 var(--radius) var(--radius); padding: 22px 24px 14px;
}
.stage-text { min-height: 128px; display: flex; flex-direction: column; justify-content: center; gap: 6px; }
.line {
  margin: 0; text-align: center; font-size: clamp(19px, 2.1vw, 27px); line-height: 2.05; font-weight: 500;
  letter-spacing: 0.005em; text-wrap: balance;
}
.line.paren { line-height: 1.6; }
.line-zh { margin: 0; text-align: center; font-family: var(--font-zh); font-size: clamp(16px, 1.6vw, 20px); color: var(--stage-ink-2); }
.line .placeholder { color: var(--stage-ink-2); font-size: 0.75em; }
.line .retry-btn { font-size: 0.6em; padding: 0.35em 1.1em; margin-left: 0.5em; vertical-align: middle; line-height: 1.4; }

.tok { cursor: pointer; border-radius: 4px; transition: background 0.12s; }
.tok:hover { background: rgba(255, 255, 255, 0.1); }
.tok.inbook { text-decoration: underline 2px var(--inbook); text-underline-offset: 5px; }
.tok.active-tok { background: rgba(255, 255, 255, 0.16); }

/* gloss above the word */
.g { position: relative; display: inline-block; }
.g .w { background: var(--gloss-soft); border-radius: 5px; padding: 0 3px; }
.g .zh {
  position: absolute; left: 50%; bottom: 84%; transform: translateX(-50%);
  font-family: var(--font-zh); font-size: 0.56em; line-height: 1; color: var(--gloss);
  white-space: nowrap; font-weight: 500; pointer-events: none;
}
.g.forced .w { background: var(--forced-soft); }
.g.forced .zh { color: var(--forced); }
/* gloss in brackets */
.pz { font-family: var(--font-zh); color: var(--gloss); font-size: 0.72em; margin-left: 1px; }
.p .w { background: var(--gloss-soft); border-radius: 5px; padding: 0 3px; }
.p.forced .w { background: var(--forced-soft); }
.p.forced .pz { color: var(--forced); }

.stage-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--stage-2);
}
.stage-btns { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.sbtn {
  display: inline-flex; align-items: center; gap: 6px; height: 34px; min-width: 34px; padding: 0 8px;
  border: 1px solid #263040; border-radius: 9px; background: var(--stage-2); color: var(--stage-ink); cursor: pointer;
  font-size: 13px; font-weight: 600;
}
.sbtn:hover { border-color: #3a4658; }
.sbtn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.sbtn-wide { padding: 0 12px 0 10px; }
.stage-meta { font-size: 12.5px; color: var(--stage-ink-2); font-variant-numeric: tabular-nums; }
.stage-right { display: flex; align-items: center; gap: 10px; }
/* when subtitles are inside the video, the stage is just the control bar */
.stage.bar-only { padding-top: 12px; }
.stage.bar-only .stage-bar { margin-top: 0; padding-top: 0; border-top: 0; }

.switch { display: inline-flex; align-items: center; gap: 8px; margin-left: 8px; font-size: 13px; font-weight: 600; cursor: pointer; color: var(--stage-ink); }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track { width: 34px; height: 20px; border-radius: 99px; background: #2a3442; position: relative; transition: background 0.15s; }
.switch-thumb { position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform 0.15s; }
.switch input:checked + .switch-track { background: var(--gloss); }
.switch input:checked + .switch-track .switch-thumb { transform: translateX(14px); background: #1d1606; }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--gloss); outline-offset: 2px; }

/* ---------- controls ---------- */
.controls { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 24px; padding: 18px 20px; }
.ctl-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.ctl-label { font-size: 12px; font-weight: 600; color: var(--ink-2); letter-spacing: 0.04em; }
.level-value { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.ctl-head .link-btn { margin-left: auto; }
input[type="range"] { width: 100%; accent-color: var(--accent); margin: 0; height: 24px; cursor: pointer; }
.level-scale { display: flex; justify-content: space-between; font-size: 11px; color: var(--ink-3); font-variant-numeric: tabular-nums; padding: 0 2px; }
.density { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 10px; font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.pill { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; }
.pill-good { background: var(--good-soft); color: var(--good); }
.pill-warn { background: var(--warn-soft); color: var(--warn); }
.pill-bad { background: var(--bad-soft); color: var(--bad); }
.ctl-options { display: flex; flex-direction: column; gap: 14px; }
.ctl-group { display: flex; flex-direction: column; gap: 6px; }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 3px; width: fit-content; max-width: 100%; flex-wrap: wrap; }
.seg button { border: 0; background: none; padding: 6px 12px; border-radius: 7px; font-size: 13.5px; font-weight: 600; color: var(--ink-2); cursor: pointer; }
.seg button[aria-checked="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(16, 24, 40, 0.12); }
.hint { margin: 0; font-size: 12.5px; color: var(--ink-3); }

/* ---------- side panel ---------- */
.side { position: sticky; top: 16px; display: flex; flex-direction: column; height: calc(100vh - 100px); min-height: 520px; overflow: hidden; }
.tabs { display: flex; border-bottom: 1px solid var(--line); padding: 6px 6px 0; gap: 2px; }
.tabs button {
  flex: 1; border: 0; background: none; padding: 10px 6px 11px; font-size: 14px; font-weight: 600; color: var(--ink-2);
  cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
}
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.count { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 99px; background: var(--surface-2); color: var(--ink-2); font-size: 12px; font-variant-numeric: tabular-nums; }
.tab-panel { position: relative; flex: 1; overflow-y: auto; overscroll-behavior: contain; min-height: 0; }
.panel-intro { padding: 14px 16px 6px; font-size: 13px; color: var(--ink-2); }
.panel-intro b { color: var(--ink); }
.empty { padding: 40px 24px; text-align: center; color: var(--ink-2); font-size: 14px; }
.empty .empty-title { font-weight: 700; color: var(--ink); margin-bottom: 6px; font-size: 15px; }

/* transcript */
.tr-row { display: grid; grid-template-columns: 44px 1fr; gap: 8px; padding: 9px 14px; cursor: pointer; border-left: 3px solid transparent; }
.tr-row:hover { background: var(--surface-2); }
.tr-row.active { background: var(--accent-soft); border-left-color: var(--accent); }
.tr-time { font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; padding-top: 2px; }
.tr-text { font-size: 14px; line-height: 1.55; }
.tr-text .tz { font-family: var(--font-zh); color: var(--warn); font-size: 12.5px; }
.tr-text .tz.forced { color: #0369a1; }
.tr-zh { font-family: var(--font-zh); font-size: 13px; color: var(--ink-2); margin-top: 2px; }

/* word rows (preview + book) */
.wrow { padding: 12px 16px; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: start; }
.wrow:last-child { border-bottom: 0; }
.w-term { font-weight: 700; font-size: 15.5px; }
.w-zh { font-family: var(--font-zh); color: var(--ink); font-size: 14px; }
.w-meta { grid-column: 1 / -1; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.w-sent { grid-column: 1 / -1; font-size: 13px; color: var(--ink-2); line-height: 1.5; }
.w-sent mark { background: var(--warn-soft); color: var(--ink); border-radius: 3px; padding: 0 2px; }
.w-actions { display: flex; gap: 6px; align-items: center; }
.time-link { border: 0; background: var(--surface-2); color: var(--accent); font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 6px; cursor: pointer; font-variant-numeric: tabular-nums; }
.time-link:hover { background: var(--accent-soft); }
.tag { font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 99px; background: var(--surface-2); color: var(--ink-2); }
.tag-phrase { background: var(--accent-soft); color: var(--accent); }
.tag-sense { background: var(--warn-soft); color: var(--warn); }
.x-btn { border: 0; background: none; color: var(--ink-3); cursor: pointer; font-size: 18px; line-height: 1; padding: 2px 4px; border-radius: 6px; }
.x-btn:hover { color: var(--bad); background: var(--bad-soft); }
.panel-foot { padding: 12px 16px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: space-between; align-items: center; font-size: 12.5px; color: var(--ink-3); }

/* ---------- word card ---------- */
.word-card {
  position: fixed; z-index: 50; width: 300px; max-width: calc(100vw - 24px);
  background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.22); padding: 14px 16px 14px;
}
.wc-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; padding-right: 22px; }
.wc-term { font-size: 19px; font-weight: 700; }
.wc-zh { font-family: var(--font-zh); font-size: 18px; margin: 6px 0 2px; }
.wc-none { font-size: 13px; color: var(--ink-2); margin: 6px 0 2px; }
.wc-note { font-size: 12.5px; color: var(--ink-3); margin-bottom: 10px; }
.wc-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.wc-actions a.btn { text-decoration: none; }
.wc-close { position: absolute; top: 8px; right: 8px; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 60;
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 14px;
  display: flex; gap: 14px; align-items: center; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25); max-width: calc(100vw - 32px);
}
.toast button { border: 0; background: none; color: var(--gloss); font-weight: 700; cursor: pointer; padding: 0; }

/* ---------- modals ---------- */
.modal {
  border: 0; padding: 0; border-radius: 18px; background: var(--surface); color: var(--ink);
  width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 48px); box-shadow: 0 24px 64px rgba(0, 0, 0, 0.3);
  overflow-x: hidden; overflow-y: auto;
}
.modal-wide { width: min(760px, calc(100vw - 32px)); }
.modal::backdrop { background: rgba(8, 12, 18, 0.55); backdrop-filter: blur(2px); }
.modal-body { padding: 28px 30px 26px; }
.eyebrow { margin: 0 0 8px; font-size: 12px; font-weight: 700; letter-spacing: 0.06em; color: var(--accent); }
.modal h2 { margin: 0 0 14px; font-size: 24px; line-height: 1.3; letter-spacing: -0.01em; text-wrap: balance; }
.modal h3 { margin: 0 0 6px; font-size: 18px; }
.intro-list { margin: 0 0 18px; padding-left: 20px; display: grid; gap: 8px; color: var(--ink-2); }
.intro-list b { color: var(--ink); }
.demo-line {
  background: var(--stage); color: var(--stage-ink); border-radius: 12px; padding: 28px 18px 16px; text-align: center;
  font-size: 18px; line-height: 2; margin-bottom: 20px;
}
.modal-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; align-items: center; }
.modal-actions .spacer { flex: 1; }
.muted { color: var(--ink-2); font-size: 14px; margin: 0 0 16px; }

/* vocabulary test */
.progress { height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin: 6px 0 18px; }
.progress > span { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width 0.25s; }
.test-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.test-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 18px; }
.titem { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 8px 8px 14px; border: 1px solid var(--line); border-radius: 12px; }
.titem.answered { background: var(--surface-2); }
.titem.missing, .mcq.missing { border-color: var(--bad); box-shadow: 0 0 0 1px var(--bad) inset; }
.missing-msg { font-size: 13px; font-weight: 600; color: var(--bad); }
.modal code { font-size: 0.9em; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
.titem-word { font-weight: 700; font-size: 16px; min-width: 0; overflow-wrap: anywhere; }
.tchoices { display: flex; gap: 4px; flex-shrink: 0; }
.tchoices button { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 5px 9px; font-size: 13px; font-weight: 600; cursor: pointer; color: var(--ink-2); }
.tchoices button[aria-pressed="true"][data-v="2"] { background: var(--good-soft); border-color: var(--good); color: var(--good); }
.tchoices button[aria-pressed="true"][data-v="1"] { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); }
.tchoices button[aria-pressed="true"][data-v="0"] { background: var(--surface-2); border-color: var(--ink-3); color: var(--ink); }
.mcq { border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; margin-bottom: 10px; }
.mcq-word { font-weight: 700; font-size: 17px; }
.mcq-ex { font-size: 14px; color: var(--ink-2); margin: 4px 0 10px; font-style: italic; }
.mcq-opts { display: flex; flex-wrap: wrap; gap: 6px; }
.mcq-opts button { border: 1px solid var(--line); background: var(--surface); border-radius: 9px; padding: 6px 12px; font-family: var(--font-zh); font-size: 14px; cursor: pointer; }
.mcq-opts button[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--ink); font-weight: 600; }
.result-num { font-size: 44px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.result-num small { font-size: 18px; font-weight: 600; color: var(--ink-2); margin-left: 4px; }
.bands { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 6px; align-items: end; height: 120px; margin: 18px 0 6px; }
.band { display: flex; flex-direction: column; justify-content: flex-end; height: 100%; }
.band-bar { background: var(--accent); border-radius: 6px 6px 2px 2px; min-height: 3px; opacity: 0.85; }
.band-labels { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 6px; font-size: 11px; color: var(--ink-3); text-align: center; font-variant-numeric: tabular-nums; margin-bottom: 16px; }
.note-box { background: var(--surface-2); border-radius: 10px; padding: 10px 14px; font-size: 13px; color: var(--ink-2); margin-bottom: 18px; }

/* ---------- responsive ---------- */
@media (max-width: 1080px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; height: 70vh; min-height: 420px; }
}
@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; gap: 10px 14px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
  .video-bar { order: 3; flex-basis: 100%; flex-wrap: wrap; }
  .video-bar select { max-width: 100%; flex: 1 1 100%; }
  .url-form { max-width: none; flex-basis: 100%; }
  .top-actions { margin-left: auto; }
  .brand-sub { display: none; }
  .layout { padding-left: max(12px, env(safe-area-inset-left, 0px)); padding-right: max(12px, env(safe-area-inset-right, 0px)); padding-block: 12px; gap: 14px; }
  .controls { grid-template-columns: minmax(0, 1fr); gap: 16px; padding: 16px; }
  .stage { padding: 18px 14px 12px; }
  .stage-text { min-height: 110px; }
  .switch { margin-left: 2px; }
  .test-grid { grid-template-columns: minmax(0, 1fr); }
  .modal-body { padding: 22px 18px 20px; }
  .hint { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
