/* Shared by the question pages (chapter.html, topic.html). Apple-style, like the landing page. */
:root {
  color-scheme: light;
  --sys: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", Inter, "Helvetica Neue", Arial, sans-serif;
  --bg: #f5f5f7;
  --surface: #ffffff;
  --ink: #1d1d1f;
  --muted: #6e6e73;
  --line: #d2d2d7;
  --accent: #0071e3;
  --accent-soft: #e8f1fd;
  --good: #127a39;
  --good-soft: #e3f6e9;
  --bad: #c4291c;
  --bad-soft: #fdecea;
  --note: #8a5300;
  --note-soft: #fdf3dc;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #18171c;
    --surface: #242229;
    --ink: #f5f5f7;
    --muted: #a6a4ad;
    --line: #37343e;
    --accent: #5c9ded;
    --accent-soft: #1f2532;
    --good: #6cc28f;
    --good-soft: #1d2923;
    --bad: #e5877e;
    --bad-soft: #2d2124;
    --note: #d9bd7f;
    --note-soft: #2a251b;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #18171c;
  --surface: #242229;
  --ink: #f5f5f7;
  --muted: #a6a4ad;
  --line: #37343e;
  --accent: #5c9ded;
  --accent-soft: #1f2532;
  --good: #6cc28f;
  --good-soft: #1d2923;
  --bad: #e5877e;
  --bad-soft: #2d2124;
  --note: #d9bd7f;
  --note-soft: #2a251b;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 17px/1.47 var(--sys);
  letter-spacing: -0.01em;
}
.wrap { width: 100%; max-width: 800px; margin: 0 auto; padding: 0 16px; }
button, select, input { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* Global bar: same dark bar and white logo as the landing page. It scrolls away; the tabs stay. */
.gbar { background: #161617; }
.gbar-row { display: flex; align-items: center; gap: 6px; height: 48px; }
.gbar .brand { flex: none; display: block; line-height: 0; margin-right: auto; }
.gbar .brand img { height: 32px; width: auto; }
.gbar a.gl { padding: 8px 8px; color: rgba(255, 255, 255, .8); font-size: 12.5px; text-decoration: none; }
.gbar a.gl:hover { color: #fff; }
.gbar a.gl-cta { margin-left: 4px; padding: 4px 12px; border-radius: 980px; background: #0071e3; color: #fff; }

/* Page title */
.page-head { padding-top: 34px; padding-bottom: 6px; }
.crumb { margin: 0 0 10px; color: var(--muted); font-size: 13px; }
.crumb a { color: var(--accent); text-decoration: none; }
.crumb a:hover { text-decoration: underline; }
.crumb span { margin: 0 6px; }
.eyebrow { margin: 0 0 4px; color: var(--muted); font-size: 15px; font-weight: 600; letter-spacing: 0; }
.eyebrow a { color: inherit; }
h1 { margin: 0; font: 700 clamp(32px, 7vw, 48px)/1.08 var(--sys); letter-spacing: -0.03em; text-wrap: balance; }

.topic-link { margin: 18px 0 0; font-size: 16px; }
.topic-link a { display: inline-flex; align-items: center; min-height: 44px; color: var(--accent); text-decoration: none; }
.topic-link a::after { content: " ›"; white-space: pre; }
.topic-link a:hover { text-decoration: underline; }

/* Questions, papers and years at a glance */
.stats { display: flex; flex-wrap: wrap; gap: 10px; margin: 16px 0 0; }
.stats > div { flex: 1 1 90px; min-width: 0; padding: 12px 16px; background: var(--surface); border-radius: 14px; }
.stats dt { color: var(--muted); font-size: 13px; }
.stats dd { margin: 0; color: var(--ink); font: 700 clamp(18px, 4.6vw, 24px)/1.2 var(--sys); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.report { display: inline-flex; align-items: center; min-height: 40px; margin-top: 6px; color: var(--muted); font-size: 13px; text-underline-offset: 3px; }
.report:hover { color: var(--accent); }

/* Progress */
.progress { padding: 22px 0 16px; }
.progress-text { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 14px; font-size: 15px; }
.progress-text span { color: var(--muted); }
.bar { height: 6px; margin-top: 10px; background: var(--line); border-radius: 3px; overflow: hidden; }
.bar span { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 3px; transition: width .25s ease; }

/* Filters */
.filters { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; }
.filters label { display: block; min-width: 0; font-size: 13px; font-weight: 600; color: var(--muted); }
.filters label:first-child { grid-column: span 2; }
.filters select {
  display: block; width: 100%; min-height: 44px; margin-top: 6px; padding: 8px 10px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; font-weight: 400; color: var(--ink);
}

.list-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 16px 0 10px; }
.list-head p { margin: 0; font-size: 14px; color: var(--muted); }
.link-btn { min-height: 44px; padding: 0 2px; background: none; border: 0; color: var(--accent); font-size: 14px; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }

/* Question card */
.card { margin-bottom: 16px; padding: 22px; background: var(--surface); border-radius: 20px; }
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin-bottom: 10px; font-size: 13px; color: var(--muted); }
.qno { font: 700 15px/1.3 var(--sys); color: var(--ink); }
.level { padding: 2px 9px; border-radius: 980px; background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 600; }
.stem { margin: 0 0 14px; font-size: 17px; overflow-wrap: anywhere; }
.topic-line { margin: -8px 0 12px; font-size: 13px; color: var(--muted); }

.figure { margin: 0 0 14px; color: var(--ink); }
.figure svg { display: block; width: 100%; height: auto; max-width: 400px; }
.figure.wide svg { max-width: 620px; }

.opts { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.opt {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 50px; padding: 8px 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; text-align: left; cursor: pointer;
  transition: border-color .15s, background .15s;
}
.opt:hover:not(:disabled) { border-color: var(--accent); background: var(--accent-soft); }
.opt:disabled { cursor: default; color: var(--ink); }
.opt-letter { flex: none; font-weight: 600; color: var(--muted); }
.opt-body { min-width: 0; overflow-wrap: anywhere; }
.opt.correct { border-color: var(--good); background: var(--good-soft); }
.opt.correct .opt-letter { color: var(--good); }
.opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
.opt.wrong .opt-letter { color: var(--bad); }
.opt-mark { margin-left: auto; flex: none; padding-left: 8px; font-size: 13px; font-weight: 600; }
.opt.correct .opt-mark { color: var(--good); }
.opt.wrong .opt-mark { color: var(--bad); }

.actions { margin-top: 10px; }

.solution { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.verdict { margin: 0 0 8px; font-weight: 600; }
.verdict.good { color: var(--good); }
.verdict.bad { color: var(--bad); }
.steps { margin: 0; padding: 0; list-style: none; counter-reset: step; }
.steps li { position: relative; padding: 6px 0 6px 36px; counter-increment: step; overflow-wrap: anywhere; }
.steps li::before {
  content: counter(step); position: absolute; left: 0; top: 7px; width: 24px; height: 24px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent); font-size: 13px; font-weight: 600; line-height: 24px; text-align: center;
}
.answer-line { margin: 8px 0 0; font-weight: 600; }
.note { margin: 12px 0 0; padding: 12px 14px; background: var(--note-soft); color: var(--note); border-radius: 12px; font-size: 15px; }
.note b { font-weight: 600; }

.stem .katex, .steps .katex, .opt-body .katex, .note .katex { font-size: 1.05em; }

.empty { padding: 30px 0; text-align: center; color: var(--muted); }
.foot { padding-top: 20px; padding-bottom: 36px; font-size: 12.5px; color: var(--muted); }
.foot a { color: inherit; }

@media (max-width: 620px) {
  .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters label:first-child { grid-column: 1 / -1; }
  .card { padding: 16px; border-radius: 18px; }
  .page-head { padding-top: 24px; }
  .gbar a.gl { padding: 8px 6px; }
}
@media (max-width: 340px) { .gbar a.gl.hide-xs { display: none; } }
@media (prefers-reduced-motion: reduce) { .bar span { transition: none; } }

/* Same faint physics doodles as the home page, behind the question pages. Cards stay solid, so questions read cleanly. */
body { position: relative; isolation: isolate; }
body::before { content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none; background: url("assets/doodles.svg?v=3") 0 0 / 680px 680px repeat; opacity: .07; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) body::before { background-image: url("assets/doodles-white.svg?v=3"); opacity: .06; } }
:root[data-theme="dark"] body::before { background-image: url("assets/doodles-white.svg?v=3"); opacity: .06; }
:root[data-theme="light"] body:has(.hero)::before { display: none; } /* only the home page: it draws its own doodles per section */
/* Doodles fade out behind the page title and filters too */
.page-head, .progress, .filters, .list-head, .topic-link { position: relative; }
.page-head::before, .progress::before, .filters::before, .list-head::before, .topic-link::before {
  content: ""; position: absolute; inset: -24px -40px; z-index: -1; pointer-events: none;
  background: radial-gradient(closest-side, var(--bg) 65%, transparent 100%);
}

/* Bookmark star on each question */
.star { margin-left: auto; width: 36px; height: 36px; border: 0; border-radius: 50%; background: none; color: var(--muted); font-size: 20px; line-height: 1; cursor: pointer; }
.star:hover { background: var(--accent-soft); }
.star[aria-pressed="true"] { color: #f0a020; }

/* Question palette: numbered dots, coloured by status; tap to jump */
.palette-wrap { margin: 0 0 16px; padding: 14px; background: var(--surface); border-radius: 18px; }
.palette-key { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin: 0 0 10px; color: var(--muted); font-size: 12.5px; }
.palette-key .k { display: inline-block; width: 12px; height: 12px; margin-right: -6px; border-radius: 50%; background: var(--line); }
.palette-key .k.right { background: var(--good); }
.palette-key .k.wrong { background: var(--bad); }
.palette-key .k.viewed { background: var(--accent); }
.palette-key .k-star { margin-right: -8px; color: #f0a020; }
.palette { display: flex; flex-wrap: wrap; gap: 6px; }
.pdot { position: relative; width: 36px; height: 36px; border: 0; border-radius: 50%; background: var(--bg); color: var(--ink); font: 600 13px var(--sys); cursor: pointer; }
.pdot[hidden] { display: none; }
.pdot:hover { outline: 2px solid var(--accent); }
.pdot.right { background: var(--good); color: #fff; }
.pdot.wrong { background: var(--bad); color: #fff; }
.pdot.viewed { background: var(--accent); color: #fff; }
.pdot.saved::after { content: "★"; position: absolute; right: -3px; top: -6px; color: #f0a020; font-size: 13px; }
/* The text glow may reach past the screen edge; never let that create sideways scrolling */
html, body { overflow-x: clip; }
/* Star sits in the card's top-right corner, so it never takes its own line on phones */
.card { position: relative; }
.card .meta { padding-right: 40px; }
.card .star { position: absolute; right: 10px; top: 10px; margin: 0; }

/* Top bar matches the home page: deep indigo with a thin brand-gradient line */
.gbar { position: relative; background: #15122a; }
.gbar::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: linear-gradient(90deg, #6a5cff, #b03fd1 50%, #ff6a4d); opacity: .85; }
.gbar a.gl-cta { background: #fff; color: #15122a; font-weight: 600; }

/* In-page video window (video-popup.js) */
html.vp-open, html.vp-open body { overflow: hidden; }
.vp-wrap { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: 16px; background: rgba(10, 8, 20, .72); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.vp-wrap[hidden] { display: none; }
.vp-card { width: min(900px, 100%); border-radius: 18px; overflow: hidden; background: #000; box-shadow: 0 30px 80px rgba(0, 0, 0, .5); }
.vp-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 10px 8px 14px; background: #15122a; }
.vp-yt { color: #fff; opacity: .85; font-size: 13px; text-decoration: none; }
.vp-yt:hover { opacity: 1; text-decoration: underline; }
.vp-x { width: 34px; height: 34px; border: 0; border-radius: 50%; background: rgba(255, 255, 255, .12); color: #fff; font-size: 16px; cursor: pointer; }
.vp-x:hover { background: rgba(255, 255, 255, .22); }
.vp-frame { position: relative; aspect-ratio: 16 / 9; }
.vp-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
/* Tall pop-up for Shorts and Instagram reels */
.vp-card.vp-tall { width: min(380px, 100%); }
.vp-card.vp-tall .vp-frame { aspect-ratio: auto; height: min(78vh, 680px); }

/* ---------- PYQ chapter pages (pyq-*.html) ---------- */
html:not(.js) .js-only { display: none !important; }
.card .stem p { margin: 0 0 8px; }
.card .stem p:last-child { margin-bottom: 0; }
.qfig { display: block; max-width: 100%; height: auto; margin: 10px 0; }
.qfig.inl { display: inline-block; margin: 0 2px; vertical-align: middle; }
.opt-body .qfig { margin: 4px 0; max-height: 220px; }
/* diagrams are black ink on transparent: flip to light ink in dark mode */
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .qfig { filter: invert(1); } }
:root[data-theme="dark"] .qfig { filter: invert(1); }
.qtable-wrap { overflow-x: auto; margin: 10px 0; }
.qtable { border-collapse: collapse; font-size: 15px; }
.qtable td { padding: 6px 10px; border: 1px solid var(--line); vertical-align: top; }
.qtable tr:first-child td { font-weight: 600; background: var(--bg); }
.blank { display: inline-block; min-width: 3em; border-bottom: 1.5px solid currentColor; color: transparent; line-height: 1; }
.num-note { margin: 0 0 4px; color: var(--muted); font-size: 14px; }
.out-tag { padding: 1px 7px; border-radius: 980px; background: var(--bg); color: var(--muted); font-size: 11px; font-weight: 600; }
.sol-box { margin-top: 14px; }
.sol-box > summary { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 980px; background: var(--accent-soft); color: var(--accent); font-weight: 600; font-size: 14px; cursor: pointer; list-style: none; }
.sol-box > summary::-webkit-details-marker { display: none; }
.sol-box[open] > summary { display: none; }
.sol-box .solution { margin-top: 0; }
.sol-soon { color: var(--muted); font-size: 14px; }
.verdict.good { color: var(--good); font-weight: 600; }
.verdict.bad { color: var(--bad); font-weight: 600; }
.card .katex { color: inherit; }
.card .katex-display { margin: .4em 0; overflow-x: auto; overflow-y: hidden; }
.card .stem .katex, .opt-body .katex { max-width: 100%; }
/* diagrams drawn for solutions: inline SVG in the text colour, so they suit light and dark mode */
.sol-fig { display: block; max-width: min(100%, 360px); height: auto; margin: 4px 0 12px; color: var(--ink); }
.sol-fig text { font-family: inherit; }

/* Light / Dark switch in the top bar (theme.js). The bars are dark in both themes. */
.theme-sw { flex: none; display: inline-flex; gap: 2px; padding: 2px; border-radius: 980px; background: rgba(255, 255, 255, .12); margin: 0 4px; }
.theme-sw button { display: grid; place-items: center; width: 28px; height: 24px; border: 0; border-radius: 980px; background: none; color: rgba(255, 255, 255, .7); cursor: pointer; }
.theme-sw button[aria-pressed="true"] { background: #fff; color: #1d1d1f; }
.theme-sw svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.theme-sw button[data-t="dark"] svg { fill: currentColor; stroke: none; }
.gbar .brand { margin-right: auto; }

/* PYQ page filters as chips (pyq.js turns the dropdowns into these) */
.filters.chip-mode { display: flex; flex-direction: column; gap: 10px; padding: 14px 16px; border-radius: 18px; background: var(--surface); }
.chip-row { display: flex; align-items: flex-start; gap: 12px; min-width: 0; }
.chip-label { flex: none; width: 46px; padding-top: 8px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; }
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 12px; border: 1px solid var(--line); border-radius: 980px;
  background: var(--bg); color: var(--ink); font: 500 13.5px/1.2 var(--sys); cursor: pointer; transition: background .15s, border-color .15s; }
.chip small { font-size: 11.5px; font-weight: 600; color: var(--muted); }
.chip:hover { border-color: var(--accent); }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip[aria-pressed="true"] small { color: rgba(255, 255, 255, .8); }
@media (max-width: 700px) {
  .chip-row { flex-direction: column; gap: 6px; }
  .chip-label { width: auto; padding-top: 0; }
  .chips { flex-wrap: nowrap; width: 100%; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .chips::-webkit-scrollbar { display: none; }
  .chip { flex: none; }
}
.chips:not(.open) .chip-extra { display: none; }
.chip-more { border-style: dashed; color: var(--accent); }
.filters.chip-mode > label { display: none; }

/* Minimal filter bar: exam tabs + Filter button, the rest in a folding panel (pyq.js) */
.filters.chip-mode { gap: 10px; padding: 0; background: none; }
.fbar { display: flex; align-items: center; gap: 10px; }
.chips.seg { flex: 1 1 auto; flex-wrap: nowrap; gap: 2px; padding: 3px; border-radius: 12px; background: var(--line); background: color-mix(in srgb, var(--line) 55%, transparent); overflow-x: auto; scrollbar-width: none; }
.chips.seg::-webkit-scrollbar { display: none; }
.chips.seg .chip { flex: 1 0 auto; justify-content: center; min-height: 34px; border: 0; border-radius: 9px; background: none; color: var(--muted); font-weight: 600; }
.chips.seg .chip small { display: none; }
.chips.seg .chip[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.chips.seg .chip:hover { border-color: transparent; color: var(--ink); }
.fbtn { flex: none; display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink); font: 600 14px/1 var(--sys); cursor: pointer; }
.fbtn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.fbtn[aria-expanded="true"] { border-color: var(--accent); color: var(--accent); }
.fcount { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--accent); color: #fff; font-size: 11px; }
.fcount[hidden] { display: none; }
.ftags { display: flex; flex-wrap: wrap; gap: 6px; }
.ftags[hidden] { display: none; }
.ftag { display: inline-flex; align-items: center; gap: 6px; min-height: 28px; padding: 0 10px; border: 0; border-radius: 980px; background: var(--accent-soft); color: var(--accent); font: 600 12.5px/1 var(--sys); cursor: pointer; }
.ftag span { font-size: 11px; opacity: .7; }
.fpanel { display: flex; flex-direction: column; gap: 12px; padding: 16px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.fpanel[hidden] { display: none; }
.fpanel .chip { background: none; }
.fpanel .chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.fpanel .chip[aria-pressed="true"] small { color: inherit; opacity: .7; }
.ffoot { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-top: 12px; border-top: 1px solid var(--line); }
.fdone { min-height: 38px; padding: 0 18px; border: 0; border-radius: 980px; background: var(--accent); color: #fff; font: 600 14px/1 var(--sys); cursor: pointer; }
@media (max-width: 700px) { .fpanel .chips { flex-wrap: wrap; overflow: visible; } }
.fpanel .chip { max-width: 100%; white-space: normal; text-align: left; padding-top: 6px; padding-bottom: 6px; }
@media (max-width: 700px) {
  .chips.seg .chip { padding: 0 8px; font-size: 13px; }
  .fbtn { padding: 0 11px; }
}
@media (max-width: 380px) { .fbtn span { display: none; } }

/* Two views on PYQ pages: one question at a time, or the full list (pyq.js) */
.vsw { flex: none; display: inline-flex; gap: 2px; padding: 3px; border-radius: 12px; background: color-mix(in srgb, var(--line) 55%, transparent); }
.vsw button { display: grid; place-items: center; width: 34px; height: 34px; border: 0; border-radius: 9px; background: none; color: var(--muted); cursor: pointer; }
.vsw button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.vsw svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.one-mode #list .card:not(.cur) { display: none; }
.onenav { position: sticky; bottom: 12px; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 14px; padding: 8px;
  border: 1px solid var(--line); border-radius: 16px; background: var(--surface); box-shadow: 0 8px 24px rgba(0, 0, 0, .1); }
.onenav[hidden] { display: none; }
.onenav button { min-height: 44px; min-width: 104px; padding: 0 18px; border: 0; border-radius: 12px; background: var(--accent); color: #fff; font: 600 15px/1 var(--sys); cursor: pointer; }
.onenav .on-prev { background: var(--bg); color: var(--ink); }
.onenav button:disabled { opacity: .35; cursor: default; }
.on-pos { color: var(--muted); font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
@media (max-width: 420px) { .vsw button { width: 30px; } .onenav button { min-width: 88px; } }
.chips.seg .short { display: none; }
@media (max-width: 480px) { .chips.seg .full { display: none; } .chips.seg .short { display: inline; } }

/* Bookmarks: ★ Saved button, save message, header link */
.sbtn { flex: none; display: inline-flex; align-items: center; gap: 5px; min-height: 40px; padding: 0 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink); font: 600 14px/1 var(--sys); cursor: pointer; }
.sbtn .bmi { width: 17px; height: 17px; color: var(--accent); }
.sbtn[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
/* bookmark ribbon icon (outline +, filled ✓) */
.bmi { display: block; width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.bmi.on path:first-child { fill: currentColor; }
.bmi.on .tick { stroke: var(--surface); stroke-width: 2.1; }
.card .star { display: grid; place-items: center; width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); color: var(--muted); font-size: 18px; transition: color .15s, border-color .15s, background .15s; }
.card .star:hover { border-color: var(--accent); color: var(--accent); background: var(--surface); }
.card .star[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.pc-toast .bmi { flex: none; width: 18px; height: 18px; margin-right: -6px; color: #b9a3ff; }
.pc-toast .bmi.on .tick { stroke: #1d1d1f; }
:root[data-theme="dark"] .pc-toast .bmi { color: var(--accent); }
:root[data-theme="dark"] .pc-toast .bmi.on .tick { stroke: #f5f5f7; }
.bm-link .bmi { width: 19px; height: 19px; }
.sbtn:disabled { opacity: .45; cursor: default; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.pc-toast { position: fixed; left: 50%; bottom: 84px; z-index: 60; display: flex; align-items: center; gap: 14px; max-width: calc(100% - 32px); padding: 11px 16px;
  border-radius: 14px; background: #1d1d1f; color: #fff; font-size: 14px; box-shadow: 0 10px 30px rgba(0, 0, 0, .25);
  transform: translate(-50%, 16px); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; }
.pc-toast.show { transform: translate(-50%, 0); opacity: 1; pointer-events: auto; }
.pc-toast a { color: #6cb6ff; font-weight: 600; text-decoration: none; white-space: nowrap; }
:root[data-theme="dark"] .pc-toast { background: #f5f5f7; color: #1d1d1f; }
:root[data-theme="dark"] .pc-toast a { color: #0071e3; }
.bm-link { flex: none; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 980px; color: rgba(255, 255, 255, .8); font-size: 17px; text-decoration: none; }
.bm-link:hover { background: rgba(255, 255, 255, .12); color: #fff; }
@media (max-width: 700px) { .sbtn { padding: 0 10px; } }
/* phone: room for exam tabs + ★ + view switch + Filter in one row */
@media (max-width: 480px) {
  .fbar { gap: 6px; }
  .chips.seg .chip { padding: 0 6px; font-size: 12.5px; }
  .sbtn { padding: 0 8px; gap: 3px; }
  .vsw button { width: 28px; }
}

/* dark mode: calmer answer states (borders blend toward the card line, so they read without glowing) */
:root[data-theme="dark"] .opt:hover:not(:disabled) { border-color: color-mix(in srgb, var(--accent) 60%, var(--line)); }
:root[data-theme="dark"] .opt.correct { border-color: color-mix(in srgb, var(--good) 55%, var(--line)); }
:root[data-theme="dark"] .opt.wrong { border-color: color-mix(in srgb, var(--bad) 55%, var(--line)); }
/* Try again (one question) and Start over (whole chapter) */
.retry { display: inline-flex; align-items: center; gap: 6px; margin: 10px 0 0; min-height: 34px; padding: 0 12px; border: 1px solid var(--line); border-radius: 980px; background: var(--surface); color: var(--ink); font: 600 13.5px/1 var(--sys); cursor: pointer; }
.retry:hover { border-color: var(--accent); color: var(--accent); }
.retry svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.retry[hidden] { display: none; }
.progress-text #reset { min-height: 0; margin-left: auto; padding: 0; font-size: 14px; }
.progress-text #reset.armed { color: var(--bad); font-weight: 600; }
.progress-text:not(.has-answers) #reset { display: none; }
.list-head { justify-content: flex-start; }
/* Text size control (A− 100% A+): scales question, options and solution text via --qs on #list */
.list-head { justify-content: space-between; }
.fsz { flex: none; display: inline-flex; align-items: center; gap: 4px; }
.fsz-a { display: grid; place-items: center; width: 26px; height: 32px; padding: 0; border: 0; background: none; color: var(--muted); font-family: var(--sys); font-weight: 600; line-height: 1; cursor: pointer; }
.fsz-a.sm { font-size: 12px; } .fsz-a.lg { font-size: 18px; }
.fsz-a:hover:not(:disabled) { color: var(--ink); }
.fsz-a:disabled { opacity: .35; cursor: default; }
.fsz-track { position: relative; display: inline-flex; align-items: center; gap: 0; }
.fsz-track::before { content: ""; position: absolute; left: 8px; right: 8px; top: 50%; height: 1.5px; background: var(--line); transform: translateY(-50%); }
.fsz-dot { position: relative; display: grid; place-items: center; width: 16px; height: 28px; padding: 0; border: 0; background: none; cursor: pointer; }
.fsz-dot::after { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--surface); box-shadow: inset 0 0 0 1.5px var(--line); transition: transform .15s, background .15s, box-shadow .15s; }
.fsz-dot.past::after { background: var(--muted); box-shadow: none; opacity: .55; }
.fsz-dot.on::after { width: 10px; height: 10px; background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
#list .stem, #list .opt, #list .steps, #list .answer-line, #list .verdict { font-size: calc(17px * var(--qs, 1)); }
#list .note { font-size: calc(15px * var(--qs, 1)); }
#list .opt-mark { font-size: calc(13px * var(--qs, 1)); }
#list .qfig, #list .sol-fig { zoom: var(--qs, 1); }
@media (max-width: 420px) { .fsz-dot { width: 14px; } .fsz-a { width: 22px; } }

/* Left topic sidebar (wide screens only). Phones keep Topic inside the Filter panel. */
.tside { display: none; }
@media (min-width: 1080px) {
  main.wrap:has(> .tside) { max-width: 1140px; display: grid; grid-template-columns: 250px minmax(0, 1fr); column-gap: 36px; align-items: start; }
  main.wrap:has(> .tside) > *:not(.tside) { grid-column: 2; }
  html.js .tside { display: block; grid-column: 1; grid-row: 1 / span 40; position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow-y: auto; scrollbar-width: thin;
    margin-top: 22px; padding: 18px 12px 14px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
  body:has(.tside) .page-head, body:has(.tside) .foot { max-width: 1140px; padding-left: calc(16px + 250px + 36px); }
  .fpanel .chip-row[aria-label="Topic"] { display: none; }
}
.ts-k { margin: 0 8px 4px; color: var(--muted); font-size: 11.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.ts-ch { margin: 0 8px; font: 700 17px/1.3 var(--sys); color: var(--ink); }
.ts-sw { display: inline-block; margin: 4px 8px 18px; color: var(--accent); font-size: 13px; text-decoration: none; }
.ts-sw:hover { text-decoration: underline; }
.ts-list { display: flex; flex-direction: column; gap: 2px; margin: 6px 0 0 8px; padding-left: 10px; border-left: 1.5px solid var(--line); }
.ts-list button, .ts-list a { text-decoration: none; position: relative; display: flex; align-items: flex-start; gap: 8px; width: 100%; padding: 8px 10px; border: 0; border-radius: 10px; background: none;
  color: var(--muted); font: 500 14px/1.35 var(--sys); text-align: left; cursor: pointer; }
.ts-list button span, .ts-list a span { flex: 1; }
.ts-list button small, .ts-list a small { flex: none; padding-top: 1px; font-size: 12px; opacity: .8; }
.ts-list button:hover, .ts-list a:hover { color: var(--ink); background: color-mix(in srgb, var(--line) 35%, transparent); }
.ts-list button[aria-current], .ts-list a[aria-current] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.ts-list button.empty, .ts-list a.empty { opacity: .45; }
/* "you are here": a small dot on the rail beside the topic of the question on screen */
.ts-list button.here { color: var(--ink); }
.ts-list button[aria-current].here { color: var(--accent); }
.ts-list button.here::before { content: ""; position: absolute; left: -15px; top: 14px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px var(--surface); }

/* Saved button → small menu (Saved in this chapter · Go to My Bookmarks) */
.smenu-wrap { position: relative; flex: none; }
.sbtn[aria-expanded="true"] { border-color: var(--accent); }
.smenu { position: absolute; right: 0; top: calc(100% + 8px); z-index: 40; width: 280px; max-width: calc(100vw - 32px); padding: 6px; border: 1px solid var(--line); border-radius: 14px;
  background: var(--surface); box-shadow: 0 14px 34px rgba(0, 0, 0, .14), 0 2px 6px rgba(0, 0, 0, .06); }
:root[data-theme="dark"] .smenu { box-shadow: 0 14px 34px rgba(0, 0, 0, .45); }
.smenu > * { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px; border: 0; border-radius: 10px; background: none; color: var(--ink); font: inherit; text-align: left; text-decoration: none; cursor: pointer; }
.smenu > *:hover:not(:disabled) { background: color-mix(in srgb, var(--line) 40%, transparent); }
.smenu > * + * { margin-top: 2px; }
.smenu > :disabled { cursor: default; opacity: .55; }
.smenu span { flex: 1; min-width: 0; }
.smenu b { display: block; font-size: 14px; font-weight: 600; }
.smenu small { display: block; margin-top: 1px; color: var(--muted); font-size: 12px; line-height: 1.3; }
.smenu em { flex: none; min-width: 22px; padding: 2px 7px; border-radius: 980px; background: var(--accent-soft); color: var(--accent); font: 600 12px/1.3 var(--sys); text-align: center; font-style: normal; }
.smenu .bmi, .smenu .sm-ic { flex: none; width: 18px; height: 18px; color: var(--accent); }
.smenu .sm-ic { fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.smenu .sm-ic:last-child { width: 15px; height: 15px; color: var(--muted); margin-left: -4px; }
/* the ▾ tells it opens a menu; it flips up while open */
.sbtn .chev { width: 14px; height: 14px; margin: 0 -3px 0 1px; fill: none; stroke: var(--muted); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; transition: transform .18s; }
.sbtn[aria-expanded="true"] .chev { transform: rotate(180deg); stroke: var(--accent); }
@media (max-width: 480px) { .sbtn .chev { width: 12px; height: 12px; margin-left: 0; } }

/* ---------- chapter hub (pyq-<chapter>.html): one card per topic page ---------- */
.hub-ex { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 0; }
.hub-ex button { padding: 7px 15px; border: 1px solid var(--line); border-radius: 980px; background: var(--surface); color: var(--muted); font: 600 14px/1.2 var(--sys); cursor: pointer; }
.hub-ex button[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.hub-h { margin: 28px 0 12px; font: 700 20px/1.2 var(--sys); letter-spacing: -0.01em; }
.hub-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 12px; margin-bottom: 40px; }
.hub-card { display: flex; gap: 14px; align-items: flex-start; padding: 16px 18px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; color: var(--ink); text-decoration: none; transition: border-color .15s, transform .15s; }
.hub-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.hub-card.empty { opacity: .45; }
.hub-n { flex: none; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); font: 700 13px/1 var(--sys); font-variant-numeric: tabular-nums; }
.hub-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.hub-txt b { font: 600 16px/1.35 var(--sys); }
.hub-txt small { color: var(--muted); font-size: 13px; }
.hub-bar { display: block; height: 4px; margin-top: 6px; border-radius: 4px; background: var(--line); overflow: hidden; }
.hub-bar i { display: block; width: 0; height: 100%; background: var(--good); border-radius: 4px; }
.hub-prog:empty, .hub-bar:not(.on) { display: none; }
/* topic pages: other topics of the chapter at the bottom (and a next-topic link) */
.tp-more { margin: 36px 0 8px; padding-top: 22px; border-top: 1px solid var(--line); }
.tp-more h2 { margin: 0 0 10px; font: 700 17px/1.3 var(--sys); }
.tp-next { display: inline-flex; align-items: center; gap: 6px; margin: 0 0 16px; padding: 10px 18px; border-radius: 980px; background: var(--accent); color: #fff; font-weight: 600; text-decoration: none; }
.tp-links { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; list-style: none; }
.tp-links a { display: inline-block; padding: 7px 14px; border: 1px solid var(--line); border-radius: 980px; background: var(--surface); color: var(--ink); font-size: 14px; text-decoration: none; }
.tp-links a[aria-current] { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.tp-links a:hover { border-color: var(--accent); }
