:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #1f2933;
  --muted: #6b7785;
  --line: #e4e8ec;
  --accent: #10b981;
  --accent-d: #0c8f6a;
  --accent-soft: #e7f7f1;
  --t2: #6366f1;
  --t2-soft: #ecedff;
  --t3: #f59e0b;
  --t3-d: #b45309;
  --t3-soft: #fef3c7;
  --wrong: #ef4444;
  --wrong-soft: #fdeaea;
  --shadow: 0 1px 3px rgba(16,24,40,.08), 0 6px 20px rgba(16,24,40,.06);
  --radius: 16px;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

/* Boot error banner (shown only if data.js / init fails) */
.boot-error {
  margin: 12px 16px 0;
  padding: 12px 16px;
  border: 1px solid #f3c2c2;
  background: var(--wrong-soft);
  color: #a12626;
  border-radius: 12px;
  font-size: 13.5px;
  line-height: 1.6;
}
.boot-error b { color: #8a1f1f; }
.boot-error code {
  background: #fff;
  border: 1px solid #f0cfcf;
  border-radius: 6px;
  padding: 1px 6px;
  font-size: 12.5px;
}

/* Top bar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 22px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-text h1 { margin: 0; font-size: 18px; letter-spacing: .3px; }
.brand-text p { margin: 2px 0 0; font-size: 12px; color: var(--muted); }
.mode-switch { display: inline-flex; background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.mode-btn {
  border: 0; background: transparent; cursor: pointer;
  padding: 8px 16px; border-radius: 999px; font-size: 14px; color: var(--muted); font-weight: 600;
  transition: all .15s;
}
.mode-btn.active { background: var(--accent); color: #fff; box-shadow: var(--shadow); }
.mode-btn[data-mode="T2"].active { background: var(--t2); }
.mode-btn[data-mode="T3"].active { background: var(--t3); color: #fff; }

/* Layout — sidebar stays put; the article column grows to full length and the
   page scrolls naturally (no inner scroll container around the reading text). */
.layout { display: grid; grid-template-columns: 320px 1fr; align-items: start; }
.sidebar {
  border-right: 1px solid var(--line); background: var(--panel);
  display: flex; flex-direction: column;
  position: sticky; top: 60px; height: calc(100vh - 60px); min-height: 0;
}
.search-box { padding: 14px; border-bottom: 1px solid var(--line); }
.search-box input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  font-size: 13px; outline: none; background: var(--bg);
}
.search-box input:focus { border-color: var(--accent); background: #fff; }
.tree { flex: 1; overflow-y: auto; padding: 8px 6px 16px; }
.tree-foot { padding: 8px 14px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); }

/* Tree */
.node { user-select: none; }
.node.date {
  font-size: 12px; font-weight: 700; color: var(--muted);
  padding: 10px 10px 4px; letter-spacing: .4px; cursor: pointer;
  display: flex; align-items: center; gap: 6px;
}
.node.date:hover { color: var(--ink); }
/* Article title in the tree — same typeface and size as the topbar subtitle
   ('.brand-text p'): 12px, body font stack. Keeps a subtle indent under its date. */
.node.article {
  font-family: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 12px;
  line-height: 1.5;
  padding: 6px 10px 6px 22px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--ink);
}
.node.article:hover { background: var(--accent-soft); }
.node.article.active { background: var(--accent-soft); color: var(--accent-d); font-weight: 600; }
.caret { width: 12px; display: inline-block; transition: transform .15s; color: var(--muted); font-size: 10px; }
.collapsed > .children { display: none; }
.children { margin: 0; }

/* Stage — flows with the page; no inner scrollbar. */
.stage { padding: 22px 30px 48px; }
.breadcrumb { font-size: 13px; color: var(--muted); margin-bottom: 14px; }
.breadcrumb b { color: var(--ink); }

.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 22px 24px; max-width: 980px;
}
.scene-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.tag {
  font-size: 12px; font-weight: 800; padding: 4px 10px; border-radius: 8px; color: #fff; background: var(--accent);
}
.tag.T2 { background: var(--t2); }
.tag.T3 { background: var(--t3); }
.scenario { font-size: 13px; color: var(--muted); line-height: 1.5; }

/* Passage (T2 / T3) — shown in full, no inner scrollbar */
.passage {
  font-size: 15px; line-height: 1.75; color: var(--ink);
  background: #fbfcfd; border: 1px solid var(--line); border-radius: 12px;
  padding: 16px 18px; margin-bottom: 18px; white-space: pre-wrap; word-break: keep-all;
}
.passage h4 { margin: 0 0 8px; font-size: 16px; color: var(--ink); }
.passage .ins { color: var(--t2); font-weight: 800; padding: 0 2px; }
.passage .ins-pt { color: var(--t3-d); font-weight: 800; }

/* T1 cloze passage */
.cloze {
  font-size: 16px; line-height: 2; color: var(--ink);
  background: #fbfcfd; border: 1px solid var(--line); border-radius: 12px;
  padding: 18px 20px; margin-bottom: 18px; word-break: keep-all;
}
.gap-wrap { display: inline-flex; align-items: baseline; }
.gap-prefix { font-weight: 600; }
.gap-field { position: relative; display: inline-block; margin: 0 3px; vertical-align: baseline; }
.gap-field:focus-within { background: var(--accent-soft); border-radius: 4px; }
.gap-track {
  font-family: "SF Mono", "Menlo", "Consolas", ui-monospace, monospace;
  font-size: 16px; font-weight: 700; letter-spacing: .12em;
  color: var(--accent); opacity: .35; white-space: pre;
}
.gap {
  position: absolute; left: 0; top: 0; width: 100%; height: 100%;
  border: 0; background: transparent; outline: none; margin: 0; padding: 0;
  font-family: "SF Mono", "Menlo", "Consolas", ui-monospace, monospace;
  font-size: 16px; font-weight: 700; letter-spacing: .12em;
  color: var(--accent-d); text-align: left;
}
.gap.correct { color: var(--accent); }
.gap.wrong { color: var(--wrong); }
.gap:disabled { opacity: .92; cursor: default; }

/* Questions */
.question { padding: 16px 0 14px; border-top: 1px dashed var(--line); }
.question:first-of-type { border-top: 0; padding-top: 4px; }
.q-text { font-size: 15px; font-weight: 700; line-height: 1.6; margin-bottom: 10px; }
.options { display: flex; flex-direction: column; gap: 8px; }
.opt {
  display: flex; gap: 10px; align-items: flex-start; padding: 9px 12px;
  border: 1px solid var(--line); border-radius: 10px; cursor: pointer; font-size: 14px;
  transition: all .12s; line-height: 1.5;
}
.opt:hover { border-color: var(--accent); background: #fbfdfc; }
.opt input { margin-top: 3px; accent-color: var(--accent); flex: none; }
.opt.correct { border-color: var(--accent); background: var(--accent-soft); }
.opt.wrong { border-color: var(--wrong); background: var(--wrong-soft); }
.opt.dim { opacity: .5; }

/* Countdown */
.countdown-wrap { position: relative; width: 120px; height: 120px; margin: 8px 0 4px; }
.ring { transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: var(--bg); stroke-width: 9; }
.ring-fg { fill: none; stroke: var(--accent); stroke-width: 9; stroke-linecap: round;
  stroke-dasharray: 326.7; stroke-dashoffset: 326.7; transition: stroke-dashoffset .25s linear, stroke .2s; }
.ring-fg.t2 { stroke: var(--t2); }
.ring-fg.t3 { stroke: var(--t3); }
.ring-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.cd-num { font-size: 34px; font-weight: 800; font-variant-numeric: tabular-nums; }
.cd-status { font-size: 11px; color: var(--muted); margin-top: 2px; text-align: center; padding: 0 6px; }

/* Buttons */
.actions { display: flex; gap: 10px; margin: 16px 0 6px; flex-wrap: wrap; }
.btn {
  border: 1px solid var(--line); background: #fff; cursor: pointer; border-radius: 10px;
  padding: 9px 14px; font-size: 13px; font-weight: 600; color: var(--ink); transition: all .15s;
}
.btn:hover { border-color: var(--accent); color: var(--accent-d); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary {
  background: var(--accent); color: #fff; border-color: var(--accent);
  padding: 11px 22px; font-size: 15px;
}
.btn-primary:hover { background: var(--accent-d); color: #fff; }
.btn-primary:disabled { background: #c7ced4; border-color: #c7ced4; }
.nav { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.nav-pos { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.hint { font-size: 12px; color: var(--muted); margin-top: 14px; }

/* Result */
.result { margin-top: 18px; border-top: 2px solid var(--line); padding-top: 16px; }
.result h3 { margin: 0 0 12px; font-size: 15px; }
.verdict { font-weight: 800; margin-left: 8px; }
.verdict.ok { color: var(--accent); }
.verdict.no { color: var(--wrong); }
.answer-reveal { font-size: 13px; color: var(--muted); margin-top: 6px; }
.answer-reveal b { color: var(--ink); }

.rrow {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px;
  font-size: 14px; line-height: 1.4;
}
.rrow:nth-child(even) { background: #fbfcfd; }
.rbadge { font-weight: 800; color: var(--ink); flex: none; }
.rval { color: var(--accent-d); font-weight: 700; font-family: "SF Mono", "Menlo", monospace; }
.result .answer-reveal { margin-top: 0; }

@media (max-width: 880px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { display: none; }
}
