:root {
    --surface-0:    #ffffff;
    --surface-1:    #f2f3f5;
    --surface-2:    #e7e8eb;
    --line:         #d6d8db;
    --line-subtle:  #e4e6e9;
    --line-strong:  #9aa0a7;
    --ink-900:      #15181c;
    --ink-700:      #3a3e44;
    --ink-500:      #6b7077;
    --accent:       #1b5a96;
    --accent-tint:  #e9f1f9;
    --accent-100:   #d6e4f0;
    --accent-600:   #164a7d;
    --accent-700:   #0f3558;
    --chrome-900:   #15181c;
    --chrome-900-hover: #30353c;
    --shadow-card:  0 1px 2px rgba(21,24,28,.05), 0 1px 1px rgba(21,24,28,.03);
    --correct:      #1f7a42;
    --correct-tint: #e8f5ec;
    --wrong:        #b3261e;
    --wrong-tint:   #fbeae8;
    --flag:         #8a5a00;
    --flag-tint:    #fbf1de;
    --font-ui:      'Inter', -apple-system, 'Segoe UI', Roboto, sans-serif;
    --font-mono:    'IBM Plex Mono', 'SF Mono', ui-monospace, monospace;
    --fs-100: 11px;
    --fs-200: 12.5px;
    --fs-300: 14px;
    --fs-400: 15px;
    --fs-500: 17px;
    --fs-600: 20px;
    --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px;
    --sp-5: 20px; --sp-6: 24px; --sp-7: 32px; --sp-8: 48px;
    --radius-sm: 3px;
    --radius: 4px;
    --transition: 0.15s ease;
}

/* ── DARK MODE ─────────────────────────────────────
   Toggled via [data-theme="dark"] on <html>, set by the inline script
   in each page's <head> (reads localStorage, applied before paint to
   avoid a flash). --chrome-900/--chrome-900-hover are deliberately
   NOT overridden here - the sidebar and other dark-chrome surfaces are
   already as dark as the dark theme itself, so they stay fixed in both
   themes rather than trying to get darker still. */
:root[data-theme="dark"] {
    --surface-0:    #262b33;
    --surface-1:    #1c1f24;
    --surface-2:    #15181c;
    --line:         #363b44;
    --line-subtle:  #2a2e35;
    --line-strong:  #565d68;
    --ink-900:      #eef0f2;
    --ink-700:      #c3c8ce;
    --ink-500:      #8b9099;
    --accent:       #5b9bd8;
    --accent-tint:  #1c2e3f;
    --accent-100:   #28415a;
    --accent-600:   #7fb3e6;
    --accent-700:   #a8cdf0;
    --correct:      #4cc080;
    --correct-tint: #16301f;
    --wrong:        #ef6b61;
    --wrong-tint:   #3a1b18;
    --flag:         #e0ae55;
    --flag-tint:    #3a2c10;
    --shadow-card:  0 1px 2px rgba(0,0,0,.5), 0 1px 1px rgba(0,0,0,.35);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body { font-family: var(--font-ui); font-size: var(--fs-400); line-height: 1.55; color: var(--ink-700); background: var(--surface-1); display: flex; height: 100vh; height: 100dvh; overflow: hidden; }

/* ── SIDEBAR ─────────────────────────────────────── */
#sidebar { width: 240px; background: var(--chrome-900); overflow-y: auto; -webkit-overflow-scrolling: touch; flex-shrink: 0; z-index: 100; display: flex; flex-direction: column; }
.sidebar-brand { position: relative; padding: var(--sp-5) var(--sp-4) var(--sp-4); border-bottom: 1px solid rgba(255,255,255,0.1); }
#sidebar .sidebar-close-btn { display: none; }
.sidebar-brand-logo { display: flex; align-items: center; gap: var(--sp-2); margin-bottom: var(--sp-1); text-decoration: none; }
.brand-icon { width: 26px; height: 26px; background: var(--accent); border-radius: var(--radius); display: flex; align-items: center; justify-content: center; font-family: var(--font-mono); font-size: 14px; font-weight: 700; color: white; flex-shrink: 0; }
.sidebar-brand h1 { font-size: var(--fs-400); font-weight: 600; color: white; letter-spacing: 0.2px; }
.sidebar-brand p { font-size: var(--fs-100); color: rgba(255,255,255,0.45); padding-left: 34px; }
.sidebar-nav { padding: var(--sp-3) var(--sp-2) 0; }
.sidebar-nav-label { font-size: var(--fs-100); font-weight: 600; letter-spacing: 0.6px; text-transform: uppercase; color: rgba(255,255,255,0.35); padding: var(--sp-3) var(--sp-2) var(--sp-2); }
#sidebar a, #sidebar button { display: flex; align-items: center; gap: var(--sp-2); width: 100%; text-align: left; background: none; border: none; color: rgba(255,255,255,0.72); padding: 7px var(--sp-2); cursor: pointer; border-radius: var(--radius-sm); margin-bottom: 1px; transition: var(--transition); font-size: var(--fs-300); font-family: var(--font-ui); text-decoration: none; }
#sidebar a:hover, #sidebar button:hover { background: rgba(255,255,255,0.08); color: white; }
#sidebar a.active { background: var(--accent); color: white; font-weight: 500; }
.sidebar-divider { height: 1px; background: rgba(255,255,255,0.08); margin: var(--sp-2) var(--sp-2); }
.sidebar-subjects { padding: 0 var(--sp-2) var(--sp-4); }

/* ── MAIN SHELL ───────────────────────────────────── */
#main { flex: 1; display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
#topbar { background: var(--surface-0); box-shadow: 0 1px 0 var(--line); padding: 0 var(--sp-6); height: 48px; display: flex; justify-content: space-between; align-items: center; flex-shrink: 0; }
.topbar-left { display: flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-300); font-weight: 600; color: var(--ink-900); }
.topbar-left a { color: var(--accent); text-decoration: none; font-size: var(--fs-300); font-weight: 500; }
.topbar-left a:hover { text-decoration: underline; }
.topbar-sep { color: var(--line-strong); }
.topbar-right { display: flex; align-items: center; gap: var(--sp-2); }
.topbar-links { display: flex; gap: var(--sp-1); }
.topbar-link { color: var(--ink-500); text-decoration: none; font-size: var(--fs-300); font-weight: 500; padding: 5px var(--sp-3); border-radius: var(--radius-sm); transition: var(--transition); }
.topbar-link:hover { color: var(--ink-900); background: var(--surface-1); }
.theme-toggle { background: none; border: 1px solid var(--line); color: var(--ink-500); font-size: var(--fs-200); font-family: var(--font-ui); padding: 4px var(--sp-3); border-radius: var(--radius-sm); cursor: pointer; transition: var(--transition); }
.theme-toggle:hover { color: var(--ink-900); border-color: var(--line-strong); }
.theme-toggle::after { content: "Dark mode"; }
:root[data-theme="dark"] .theme-toggle::after { content: "Light mode"; }

#content { flex: 1; display: flex; min-height: 0; padding: var(--sp-5); gap: var(--sp-5); overflow: hidden; }
#mainArea { flex: 1; min-width: 0; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; display: flex; flex-direction: column; gap: var(--sp-4); }
#trackerArea { width: 260px; flex-shrink: 0; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; display: flex; flex-direction: column; gap: var(--sp-3); }

/* ── CARD / SURFACE ──────────────────────────────── */
.card, .intro-card { background: var(--surface-0); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-card); overflow: visible; }

/* ── SUBJECT HEADER (replaces hero) ──────────────── */
.subject-header { padding: var(--sp-6) var(--sp-6) var(--sp-5); }
.subject-title { font-family: var(--font-ui); font-weight: 700; font-size: var(--fs-600); color: var(--ink-900); margin-bottom: var(--sp-1); }
.subject-meta { font-variant-numeric: tabular-nums; margin-top: 2px; font-size: var(--fs-300); color: var(--ink-500); }

.intro-ref-search { padding: var(--sp-3) var(--sp-6); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; }
.intro-ref-search-label { font-size: var(--fs-200); color: var(--ink-500); }
.intro-ref-search form { display: flex; gap: var(--sp-2); }
.intro-ref-search .ref-search-input { width: 140px; }

/* Test setup: a plain form in the page's own colours (no dark widget, no
   monospace or uppercase labels). The Start button names exactly what it
   will start; see updateStartLabel() in quiz-engine.js. */
.test-setup { max-width: 460px; margin: 0 var(--sp-6) var(--sp-5); padding: 4px var(--sp-5); border: 1px solid var(--line); border-radius: 14px; background: var(--surface-1); box-shadow: 0 1px 2px rgba(15,23,42,.04), 0 8px 24px -12px rgba(15,23,42,.18); }
.ts-row { display: grid; grid-template-columns: 1fr; gap: 10px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.ts-controls.ts-pool { display: grid; grid-template-columns: 1fr 1fr; }
.ts-label { font-size: var(--fs-300); font-weight: 600; color: var(--ink-900); }
.ts-controls { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-3) var(--sp-5); }

.ts-seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-0); padding: 2px; gap: 2px; }
.ts-seg button { min-width: 48px; padding: 6px 12px; border: none; border-radius: 6px; background: transparent; color: var(--ink-700); font: 600 var(--fs-300)/1.2 var(--font-ui); font-variant-numeric: tabular-nums; cursor: pointer; }
.ts-seg button:hover { color: var(--ink-900); background: var(--surface-1); }
.ts-seg button.is-on { background: var(--ink-900); color: var(--surface-0); }
.ts-custom { display: inline-flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-300); color: var(--ink-500); }
.ts-custom .num-input { width: 76px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-0); color: var(--ink-900); font: 600 var(--fs-300)/1.2 var(--font-ui); font-variant-numeric: tabular-nums; }
.ts-custom .num-input::placeholder { color: var(--ink-500); font-weight: 400; }
.ts-custom .num-input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }

.ts-pool { gap: var(--sp-2) var(--sp-5); }
.ts-opt { display: inline-flex; align-items: center; gap: var(--sp-2); cursor: pointer; font-size: var(--fs-300); color: var(--ink-900); white-space: nowrap; }
.ts-opt input { width: 16px; height: 16px; margin: 0; accent-color: var(--ink-900); cursor: pointer; }
.ts-count { color: var(--ink-500); font-variant-numeric: tabular-nums; margin-left: 2px; }
.ts-opt.is-empty { color: var(--ink-500); cursor: default; }
.ts-opt.is-empty input { cursor: default; }

.ts-foot { display: flex; flex-direction: column; align-items: stretch; gap: 14px; padding: 16px 0 18px; }
.ts-foot .btn-start { width: 100%; padding: 13px 20px; }
.ts-progress { flex: 1; min-width: 0; }
.seen-progress-bar { height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; width: 100%; }
.seen-progress-fill { height: 100%; background: var(--accent); transition: width 0.4s ease; }
.seen-progress-text { font-size: var(--fs-200); color: var(--ink-500); margin-top: 8px; }
.reset-seen-btn { background: none; border: none; padding: 0; margin-left: 4px; color: var(--ink-700); font: inherit; text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
.reset-seen-btn:hover { color: var(--ink-900); }

.btn-start { flex-shrink: 0; background: var(--ink-900); color: var(--surface-0); border: none; padding: 11px 20px; border-radius: 8px; font: 600 var(--fs-300)/1.2 var(--font-ui); cursor: pointer; white-space: nowrap; font-variant-numeric: tabular-nums; }
.btn-start:hover { opacity: .88; }
.btn-start:disabled { background: var(--line); color: var(--ink-500); cursor: default; opacity: 1; }
.ts-seg button:focus-visible, .btn-start:focus-visible, .reset-seen-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Free-sample note: one plain line under the title, not a banner. */
.guest-sample-line { margin-top: var(--sp-2); font-size: var(--fs-200); color: var(--ink-700); }
.link-btn { background: none; border: none; padding: 0; font: inherit; font-weight: 600; color: var(--ink-900); text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
.link-btn:hover { color: var(--accent); }

/* Unfinished tests sit at the top of the test box, one line each. */
.ts-saved { border-bottom: 1px solid var(--line); }
.ts-saved-row { display: flex; align-items: center; gap: var(--sp-3); padding: 14px 0; }
.ts-saved-row + .ts-saved-row { border-top: 1px solid var(--line); }
.ts-saved-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; font-size: var(--fs-200); color: var(--ink-500); }
.ts-saved-text strong { font-size: var(--fs-300); font-weight: 600; color: var(--ink-900); }
.ts-resume { padding: 7px 14px; border: 1px solid var(--ink-900); border-radius: 8px; background: var(--surface-0); color: var(--ink-900); font: 600 var(--fs-200)/1.2 var(--font-ui); cursor: pointer; }
.ts-resume:hover { background: var(--ink-900); color: var(--surface-0); }
.ts-discard { background: none; border: none; padding: 0; color: var(--ink-500); font: inherit; font-size: var(--fs-200); text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
.ts-discard:hover { color: #b42318; }
.ts-resume:focus-visible, .ts-discard:focus-visible, .link-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Setup screen has no sidebar content: let the main column take the width. */
#trackerArea:empty { display: none; }

/* ── DEMOTED "ABOUT THIS SUBJECT" DISCLOSURE ─────── */
.intro-body { padding: var(--sp-5) 0 0; border-top: 1px solid var(--line-subtle); }
.intro-body .intro-section + .intro-section { padding-top: var(--sp-4); }
.intro-body .intro-section { max-width: 820px; }
.intro-body > summary { list-style: none; cursor: pointer; padding: var(--sp-4) var(--sp-6); font-size: var(--fs-300); font-weight: 600; color: var(--ink-500); border-top: 1px solid var(--line-subtle); user-select: none; }
.intro-body > summary::-webkit-details-marker { display: none; }
.intro-body > summary::before { content: '▸'; display: inline-block; margin-right: var(--sp-2); transition: transform var(--transition); }
.intro-body[open] > summary::before { transform: rotate(90deg); }
.intro-body > summary:hover { color: var(--ink-900); background: var(--surface-1); }
.intro-section { padding: 0 var(--sp-6) var(--sp-6); }
.intro-section:last-child { padding-bottom: var(--sp-6); }
.i-label { font-size: var(--fs-100); font-weight: 700; text-transform: uppercase; letter-spacing: 0.6px; color: var(--accent); margin-bottom: var(--sp-1); }
.i-title { font-family: var(--font-ui); font-weight: 600; font-size: var(--fs-500); color: var(--ink-900); margin-bottom: var(--sp-3); }
.intro-section p { font-size: var(--fs-300); color: var(--ink-700); line-height: 1.7; margin-bottom: var(--sp-3); }
.intro-section p:last-child { margin-bottom: 0; }

.data-table { width: 100%; border-collapse: collapse; margin-top: var(--sp-3); font-size: var(--fs-300); }
.data-table th { background: var(--surface-1); color: var(--ink-900); padding: var(--sp-2) var(--sp-3); text-align: left; font-weight: 600; font-size: var(--fs-200); border-bottom: 1px solid var(--line-subtle); }
.data-table td { padding: var(--sp-2) var(--sp-3); border-bottom: 1px solid var(--line-subtle); color: var(--ink-700); vertical-align: top; }
.data-table tr:last-child td { border-bottom: none; }

.formula-block { background: var(--surface-1); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--sp-4) var(--sp-4); margin: var(--sp-3) 0; }
.formula-block h4 { font-size: var(--fs-200); font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--accent); margin-bottom: var(--sp-2); }
.formula { font-family: var(--font-mono); font-size: var(--fs-300); color: var(--ink-900); margin-bottom: var(--sp-1); display: block; }
.formula-note { font-size: var(--fs-200); color: var(--ink-500); }
.ref-formula { font-family: var(--font-mono); font-size: var(--fs-300); color: var(--ink-900); background: var(--surface-1); border-radius: var(--radius-sm); padding: 3px var(--sp-2); margin: var(--sp-1) 0; display: block; }
.tuc-warn { color: var(--wrong); font-weight: 700; }

.topics-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px,1fr)); gap: var(--sp-2); margin-top: var(--sp-3); }
.topic-pill { background: var(--surface-1); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: var(--sp-2) var(--sp-3); font-size: var(--fs-300); color: var(--ink-700); }

/* ── QUIZ SCREEN LAYOUT ──────────────────────────── */
.hidden { display: none !important; }
.progress-wrap { background: var(--surface-0); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--sp-4) var(--sp-5); }
.progress-track { height: 4px; background: var(--surface-2); border-radius: var(--radius-sm); overflow: hidden; margin-bottom: var(--sp-3); }
.progress-fill { height: 100%; background: var(--accent); transition: width 0.4s ease; }
.progress-meta { display: flex; justify-content: space-between; align-items: center; font-size: var(--fs-300); color: var(--ink-500); font-weight: 500; flex-wrap: wrap; gap: var(--sp-2); }
.progress-meta strong { color: var(--ink-900); font-family: var(--font-mono); font-weight: 600; }
.meta-timer { display: inline-flex; align-items: center; gap: var(--sp-2); font-family: var(--font-mono); }
.timer-toggle { background: none; border: 1px solid var(--line); color: var(--ink-500); font-size: var(--fs-100); font-family: var(--font-ui); padding: 1px 6px; border-radius: var(--radius-sm); cursor: pointer; }
.timer-toggle:hover { border-color: var(--line-strong); color: var(--ink-900); }
.meta-timer.timer-hidden #examTimer, .meta-timer.timer-hidden .timer-sep { display: none; }

.exam-nav { background: var(--surface-0); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--sp-3) var(--sp-4); display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4); }
.nav-arrow { width: 32px; height: 32px; border-radius: var(--radius-sm); background: var(--surface-1); color: var(--ink-900); border: 1px solid var(--line); font-size: var(--fs-400); cursor: pointer; display: flex; align-items: center; justify-content: center; transition: var(--transition); flex-shrink: 0; }
.nav-arrow:hover { border-color: var(--line-strong); background: var(--surface-2); }
.nav-arrow:disabled { color: var(--line-strong); cursor: not-allowed; }
.btn-finish { background: var(--chrome-900); color: white; border: none; padding: 7px var(--sp-4); border-radius: var(--radius-sm); font-size: var(--fs-300); font-weight: 600; font-family: var(--font-ui); cursor: pointer; transition: var(--transition); }
.btn-finish:hover { background: var(--chrome-900-hover); }

.question-card { background: var(--surface-0); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-card); padding: var(--sp-5) var(--sp-5); }
.q-head-row { display: flex; align-items: center; flex-wrap: wrap; gap: var(--sp-3); margin-bottom: var(--sp-4); font-family: var(--font-mono); font-size: var(--fs-200); color: var(--ink-500); }
.q-ref-tag { background: var(--surface-1); border: 1px solid var(--line); color: var(--ink-700); padding: 2px var(--sp-2); border-radius: var(--radius-sm); }
.q-number { font-family: var(--font-mono); font-size: var(--fs-200); color: var(--ink-500); margin-bottom: var(--sp-4); }
.q-text { font-size: var(--fs-500); font-weight: 500; color: var(--ink-900); line-height: 1.6; }

.options-list { display: flex; flex-direction: column; gap: var(--sp-2); margin-top: var(--sp-2); }
.option-btn { display: flex; align-items: flex-start; gap: var(--sp-3); width: 100%; padding: var(--sp-3) var(--sp-4); background: var(--surface-0); border: 1px solid var(--line); border-radius: var(--radius); cursor: pointer; font-size: var(--fs-400); font-family: var(--font-ui); color: var(--ink-700); text-align: left; transition: var(--transition); line-height: 1.5; }
.option-btn:hover:not(:disabled) { border-color: var(--accent); background: var(--accent-tint); }
.option-btn:disabled { cursor: default; }
.option-btn.correct { background: var(--correct-tint); border-color: var(--correct); color: var(--ink-900); }
.option-btn.wrong   { background: var(--wrong-tint); border-color: var(--wrong); color: var(--ink-900); }
.opt-letter { width: 22px; height: 22px; border-radius: var(--radius-sm); background: var(--surface-1); border: 1px solid var(--line); display: flex; align-items: center; justify-content: center; font-family: var(--font-mono); font-size: var(--fs-200); font-weight: 600; color: var(--ink-500); flex-shrink: 0; }
.option-btn.correct .opt-letter { background: var(--correct); border-color: var(--correct); color: white; }
.option-btn.wrong   .opt-letter { background: var(--wrong);  border-color: var(--wrong);  color: white; }

.btn-expl, .flag-btn { background: transparent; border: 1px solid var(--line); color: var(--ink-700); padding: 6px var(--sp-3); border-radius: var(--radius-sm); font-size: var(--fs-300); font-weight: 500; font-family: var(--font-ui); cursor: pointer; transition: var(--transition); display: inline-flex; align-items: center; gap: var(--sp-2); }
.nav-toggle-btn { display: none; }
.btn-expl:hover, .flag-btn:hover { border-color: var(--accent); color: var(--accent); }
.flag-btn.active { background: var(--flag-tint); border-color: var(--flag); color: var(--flag); }
.note-btn.active { background: var(--accent-100); border-color: var(--accent); color: var(--accent-700); }
.note-box { margin-top: var(--sp-2); }
.note-textarea { width: 100%; min-height: 72px; padding: var(--sp-3); border: 1px solid var(--line); border-radius: var(--radius); font-family: var(--font-ui); font-size: var(--fs-300); color: var(--ink-900); background: var(--surface-0); resize: vertical; }
.note-textarea:focus { outline: none; border-color: var(--accent); }
.note-textarea::placeholder { color: var(--ink-500); }
.expl-box { background: var(--accent-tint); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--sp-4) var(--sp-4); margin-top: var(--sp-2); }
.expl-box h4 { font-size: var(--fs-200); font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--accent); margin-bottom: var(--sp-2); }
.expl-box p  { font-size: var(--fs-300); color: var(--ink-700); line-height: 1.65; }
.expl-box figure { margin: var(--sp-3) 0; }
.expl-box figure a { display: inline-block; }
.expl-box img { display: block; max-width: 220px; width: 100%; height: auto; border-radius: var(--radius-sm); border: 1px solid var(--line); cursor: zoom-in; transition: opacity 0.15s ease, box-shadow 0.15s ease; }
.expl-box figure a:hover img { opacity: 0.88; box-shadow: var(--shadow-card); }
.expl-box figcaption { font-size: var(--fs-100); color: var(--ink-500); text-align: center; margin-top: var(--sp-1); max-width: 220px; }

/* ── RESULT SCREEN (built by renderResultScreen in quiz-engine.js) ── */
/* Results take the full content width, centred; the right rail is empty here. */
#content:has(#result:not(.hidden)) #trackerArea { display: none; }
#result { width: 100%; max-width: 860px; margin: 0 auto; }
.rs { display: flex; flex-direction: column; gap: var(--sp-5); padding-bottom: var(--sp-7); }
.rs-summary, .rs-review { background: var(--surface-0); border: 1px solid var(--line); border-radius: 14px; }

/* Summary: the score and plain sentences, no badges, bars or stat tiles. */
.rs-summary { padding: var(--sp-7); }
.rs-subject { font-size: var(--fs-300); color: var(--ink-500); margin: 0 0 var(--sp-2); }
.rs-pct { font-family: var(--font-ui); font-weight: 700; font-size: 64px; line-height: 1; letter-spacing: -2px; color: var(--ink-900); font-variant-numeric: tabular-nums; }
.rs-verdict { font-size: var(--fs-400); color: var(--ink-900); margin: var(--sp-4) 0 var(--sp-1); line-height: 1.5; }
.rs-pass { color: var(--correct); font-weight: 600; }
.rs-fail { color: var(--wrong); font-weight: 600; }
.rs-detail { font-size: var(--fs-300); color: var(--ink-500); margin: 0; }
.rs-actions { display: flex; align-items: center; gap: var(--sp-3) var(--sp-4); flex-wrap: wrap; margin-top: var(--sp-6); }
.rs-guest { margin: var(--sp-5) 0 0; padding-top: var(--sp-4); border-top: 1px solid var(--line); font-size: var(--fs-300); color: var(--ink-700); }

/* Buttons: same family as the test setup box. */
.rs-btn { font: 600 var(--fs-300)/1.2 var(--font-ui); padding: 11px 18px; border-radius: 8px; cursor: pointer; border: 1px solid transparent; }
.rs-btn-primary { background: var(--ink-900); color: var(--surface-0); }
.rs-btn-primary:hover { opacity: .88; }
.rs-btn-secondary { background: var(--surface-0); color: var(--ink-900); border-color: var(--line); }
.rs-btn-secondary:hover:not(:disabled) { border-color: var(--ink-900); }
.rs-btn:disabled { opacity: .35; cursor: default; }
.rs-link { background: none; border: none; padding: 0; font: 500 var(--fs-300)/1.2 var(--font-ui); color: var(--ink-700); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.rs-link:hover { color: var(--ink-900); }
.rs-btn:focus-visible, .rs-link:focus-visible, .rs-tabs button:focus-visible, .rs-nav-n:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Review: one question at a time. */
.rs-review { padding: var(--sp-6) var(--sp-7) var(--sp-7); }
.rs-review-head { display: flex; justify-content: space-between; align-items: center; gap: var(--sp-3); flex-wrap: wrap; margin-bottom: var(--sp-4); }
.rs-review-head h3 { font-family: var(--font-ui); font-size: var(--fs-500); font-weight: 600; color: var(--ink-900); margin: 0; }
.rs-tabs { display: inline-flex; max-width: 100%; overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-0); padding: 2px; gap: 2px; }
.rs-tabs button { white-space: nowrap; font: 600 var(--fs-200)/1.2 var(--font-ui); color: var(--ink-700); background: none; border: 0; border-radius: 6px; padding: 6px 12px; cursor: pointer; }
.rs-tabs button span { font-weight: 400; margin-left: 3px; opacity: .75; font-variant-numeric: tabular-nums; }
.rs-tabs button:hover:not(:disabled):not(.active) { background: var(--surface-1); }
.rs-tabs button.active { background: var(--ink-900); color: var(--surface-0); }
.rs-tabs button:disabled { opacity: .35; cursor: default; }

.rs-empty { color: var(--ink-500); font-size: var(--fs-300); padding: var(--sp-4) 0; }
.rs-nav { display: flex; flex-wrap: wrap; gap: 4px; padding-bottom: var(--sp-4); margin-bottom: var(--sp-5); border-bottom: 1px solid var(--line); }
.rs-nav-n { position: relative; min-width: 34px; height: 34px; padding: 0 6px; border-radius: 6px; font: 600 var(--fs-200)/1 var(--font-ui); font-variant-numeric: tabular-nums; cursor: pointer; border: 1px solid transparent; background: none; color: var(--ink-700); }
.rs-nav-n:hover { background: var(--surface-1); }
.rs-nav-n.correct { color: var(--correct); }
.rs-nav-n.wrong   { color: var(--wrong); }
.rs-nav-n.skipped { color: var(--ink-500); }
.rs-nav-n.flagged::after { content: ""; position: absolute; top: 4px; right: 4px; width: 5px; height: 5px; border-radius: 50%; background: var(--flag); }
.rs-nav-n.current { border-color: currentColor; }

.rs-card { padding: 0; }
.rs-card-top { display: flex; align-items: baseline; gap: var(--sp-3); flex-wrap: wrap; margin-bottom: var(--sp-3); }
.rs-card-n { font-size: var(--fs-200); color: var(--ink-500); }
.rs-state { margin-left: auto; font-size: var(--fs-200); font-weight: 600; }
.rs-state.correct { color: var(--correct); } .rs-state.wrong { color: var(--wrong); } .rs-state.skipped { color: var(--ink-500); }
.rs-q { font-size: var(--fs-500); font-weight: 500; color: var(--ink-900); line-height: 1.55; margin-bottom: var(--sp-4); }
.rs-opts { list-style: none; margin: 0 0 var(--sp-5); padding: 0; display: flex; flex-direction: column; gap: 2px; }
.rs-opt { display: grid; grid-template-columns: 22px 1fr auto; gap: var(--sp-2); align-items: baseline; padding: 9px 12px; border-radius: 8px; font-size: var(--fs-300); color: var(--ink-700); }
.rs-opt-l { font-weight: 600; color: var(--ink-500); }
.rs-opt-tag { font-size: var(--fs-200); font-weight: 600; white-space: nowrap; }
.rs-opt.is-answer { background: var(--correct-tint); color: var(--ink-900); }
.rs-opt.is-answer .rs-opt-l, .rs-opt.is-answer .rs-opt-tag { color: var(--correct); }
.rs-opt.is-pick { background: var(--wrong-tint); color: var(--ink-900); }
.rs-opt.is-pick .rs-opt-l, .rs-opt.is-pick .rs-opt-tag { color: var(--wrong); }
.rs-expl { font-size: var(--fs-300); color: var(--ink-700); line-height: 1.65; max-width: 68ch; }
.rs-expl-h { font-size: var(--fs-300); font-weight: 600; color: var(--ink-900); margin-bottom: 4px; }
.rs-expl p { margin: 0; }
.rs-expl img { max-width: 100%; height: auto; }
.rs-pager { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); margin-top: var(--sp-6); padding-top: var(--sp-4); border-top: 1px solid var(--line); }
.rs-pager-pos { font-size: var(--fs-200); color: var(--ink-500); font-variant-numeric: tabular-nums; }

@media (max-width: 720px) {
    .rs-summary { padding: var(--sp-5); }
    .rs-review { padding: var(--sp-5) var(--sp-4); }
    .rs-pct { font-size: 52px; }
    .rs-actions .rs-btn { flex: 1 1 auto; }
    .rs-q { font-size: var(--fs-400); }
    .rs-opt { grid-template-columns: 22px 1fr; }
    .rs-opt-tag { grid-column: 2; }
}

/* ── RIGHT RAIL: TRACKER + REFERENCE ─────────────── */
.tracker-panel, .ref-panel { background: var(--surface-0); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--sp-4); }
.tp-hdr, .ref-hdr { margin-bottom: var(--sp-3); padding-bottom: var(--sp-3); border-bottom: 1px solid var(--line-subtle); }
.tp-hdr h3, .ref-hdr h3 { font-size: var(--fs-300); font-weight: 600; color: var(--ink-900); margin-bottom: 1px; }
.tp-hdr p, .ref-hdr p  { font-size: var(--fs-200); color: var(--ink-500); }
.ref-search { display: flex; gap: var(--sp-2); margin-bottom: var(--sp-2); }
.ref-search-input { flex: 1; min-width: 0; padding: 7px var(--sp-2); border: 1px solid var(--line); border-radius: var(--radius-sm); font-size: var(--fs-300); font-family: var(--font-ui); color: var(--ink-900); background: var(--surface-0); transition: var(--transition); }
.ref-search-input:focus { outline: none; border-color: var(--accent); }
.ref-search-input[readonly] { cursor: pointer; background: var(--surface-1); color: var(--ink-500); }
.ref-search-msg { font-size: var(--fs-200); color: var(--wrong); margin-bottom: var(--sp-2); min-height: 14px; }
.ref-search-msg:empty { margin-bottom: 0; min-height: 0; }
.tracker-grid { display: flex; flex-wrap: wrap; gap: var(--sp-1); }
.qbox { width: 30px; height: 30px; display: flex; align-items: center; justify-content: center; border: 1px solid var(--line); border-radius: var(--radius-sm); cursor: pointer; background: var(--surface-0); font-family: var(--font-mono); font-size: var(--fs-200); font-weight: 600; color: var(--ink-500); transition: var(--transition); position: relative; }
.qbox:hover { border-color: var(--line-strong); color: var(--ink-900); }
.qbox.current { border-color: var(--accent); border-width: 2px; color: var(--accent); }
.qbox.correct { background: var(--correct-tint); border-color: var(--correct); color: var(--correct); }
.qbox.wrong   { background: var(--wrong-tint);  border-color: var(--wrong);  color: var(--wrong); }
.qbox.flagged::after { content: ''; position: absolute; top: -1px; right: -1px; width: 0; height: 0; border-style: solid; border-width: 0 7px 7px 0; border-color: transparent var(--flag) transparent transparent; }
.tracker-legend { display: flex; flex-wrap: wrap; gap: var(--sp-3); margin-top: var(--sp-3); padding-top: var(--sp-3); border-top: 1px solid var(--line-subtle); }
.leg-item { display: flex; align-items: center; gap: var(--sp-1); font-size: var(--fs-100); color: var(--ink-500); }
.leg-dot { width: 9px; height: 9px; border-radius: var(--radius-sm); border: 1px solid var(--line); }
.leg-dot.current { border-color: var(--accent); border-width: 2px; } .leg-dot.correct { background: var(--correct-tint); border-color: var(--correct); } .leg-dot.wrong { background: var(--wrong-tint); border-color: var(--wrong); } .leg-dot.unseen { background: var(--surface-0); }
.score-sum { background: var(--surface-0); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--sp-3) var(--sp-4); margin-top: var(--sp-3); }
.score-row { display: flex; justify-content: space-between; font-size: var(--fs-300); padding: 4px 0; border-bottom: 1px solid var(--surface-1); }
.score-row:last-child { border-bottom: none; }
.score-row span:first-child { color: var(--ink-500); }
.score-row span:last-child { font-weight: 600; color: var(--ink-900); font-family: var(--font-mono); }
.sg { color: var(--correct) !important; } .sb { color: var(--wrong) !important; }

.ref-item { padding: var(--sp-2) 0; border-bottom: 1px solid var(--surface-1); }
.ref-item:last-child { border-bottom: none; padding-bottom: 0; }
.ref-lbl { font-size: var(--fs-100); font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--accent); margin-bottom: var(--sp-1); }
.ref-content { font-size: var(--fs-200); color: var(--ink-700); line-height: 1.6; }
.ref-content strong { color: var(--ink-900); }
.ref-tip-panel { background: var(--chrome-900); border-radius: var(--radius); padding: var(--sp-4); }
.ref-tip-panel h4 { font-size: var(--fs-300); font-weight: 600; color: white; margin-bottom: var(--sp-3); }
.ref-tip { display: flex; gap: var(--sp-2); align-items: flex-start; margin-bottom: var(--sp-2); font-size: var(--fs-200); color: rgba(255,255,255,0.65); line-height: 1.55; }
.ref-tip:last-child { margin-bottom: 0; }
.ref-tip-dot { width: 4px; height: 4px; border-radius: 50%; background: var(--accent); flex-shrink: 0; margin-top: 6px; }

/* ── MOBILE NAV (hamburger-triggered sidebar overlay) ── */
.mobile-nav-toggle { display: none; position: relative; z-index: 201; background: none; border: 1px solid var(--line); border-radius: var(--radius-sm); width: 34px; height: 34px; align-items: center; justify-content: center; cursor: pointer; color: var(--ink-700); flex-shrink: 0; }
body.mobile-nav-active .mobile-nav-toggle { visibility: hidden; }
.mobile-nav-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 150; }

/* ── RESPONSIVE ───────────────────────────────────── */
/* Below 1100px there's no room for a side-by-side right rail. Rather than
   hiding the Question Navigator or overlaying it (both tried and rejected -
   see git history), #trackerArea itself gets physically moved by JS to
   become the last child of #mainArea, where it just renders as a normal
   block below the question/options/flag row, in #mainArea's own existing
   scrollable column - no change to #content's or #mainArea's own layout
   model at all, just where one element lives in the DOM. .tracker-inline
   is the marker class added alongside that move (see quiz-engine.js). */
@media (max-width: 1100px) {
    #trackerArea { display: none; }
    .nav-toggle-btn { display: inline-flex; }
    #trackerArea.tracker-inline {
        display: flex; width: 100%; flex-shrink: 0;
    }
    #trackerArea.tracker-inline.nav-collapsed { display: none; }
}
@media (max-width: 900px) {
    .mobile-nav-toggle { display: flex; }
    #sidebar .sidebar-close-btn { display: flex; align-items: center; justify-content: center; position: absolute; top: var(--sp-5); right: var(--sp-4); width: 28px; height: 28px; flex: none; background: none; border: 1px solid rgba(255,255,255,0.25); border-radius: var(--radius-sm); color: rgba(255,255,255,0.7); cursor: pointer; padding: 0; margin: 0; }
    #sidebar .sidebar-close-btn:hover { color: white; border-color: rgba(255,255,255,0.5); }
    #sidebar {
        position: fixed; top: 0; left: 0; bottom: 0; width: 280px; max-width: 85vw;
        height: 100vh; height: 100dvh; transform: translateX(-100%); transition: transform 0.25s ease;
        z-index: 200; box-shadow: 4px 0 24px rgba(0,0,0,0.3);
    }
    #sidebar.mobile-open { transform: translateX(0); }
    body.mobile-nav-active .mobile-nav-backdrop { display: block; }
    #main { width: 100%; }
    #content { flex-direction: column; padding: var(--sp-4); }
    .subject-header { padding: var(--sp-5) var(--sp-4) var(--sp-3); }
    .test-setup { padding: 0 var(--sp-4); }
    .intro-section { padding: 0 var(--sp-4) var(--sp-4); }
    .intro-body > summary { padding: var(--sp-3) var(--sp-4); }
    .topics-grid { grid-template-columns: 1fr 1fr; }
    .topbar-links { display: none; }
}
@media (max-width: 560px) {
    .subject-title { font-size: var(--fs-500); }
    .topics-grid { grid-template-columns: 1fr; }

    /* Start-test panel: full width of the card, controls stacked so nothing squeezes. */
    #content { padding: var(--sp-3); }
    .test-setup { margin: 0 var(--sp-3) var(--sp-4); padding: 0 var(--sp-4); }
    .ts-row { grid-template-columns: 1fr; gap: var(--sp-2); }
    .ts-foot { flex-direction: column; align-items: stretch; gap: var(--sp-3); }
    .btn-start { width: 100%; }
    .reset-seen-btn { order: 2; }
    .btn-start { order: 3; flex: 1 1 100%; padding: 14px 22px; font-size: var(--fs-400); border-radius: 10px; }
    .subject-header { padding: var(--sp-4) var(--sp-3) var(--sp-3); }
    .subject-switch { width: 100%; }
    .intro-ref-search form { display: flex; gap: var(--sp-2); }
    .intro-ref-search .ref-search-input { flex: 1; min-width: 0; }

    /* Question screen: slightly smaller question text, roomier tap targets. */
    .q-text { font-size: 17px; line-height: 1.5; }
    .option-btn { padding: 14px var(--sp-3); }
    .tp-hdr p { display: none; }  /* keyboard-shortcut hint is irrelevant on touch screens */
}

@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.fade-up { animation: fadeUp 0.2s ease forwards; }
.skip-link { position: absolute; left: -9999px; background: var(--chrome-900); color: white; padding: var(--sp-2); text-decoration: none; z-index: 1000; }

.guest-sample-banner { display: flex; align-items: center; gap: var(--sp-4); background: var(--surface-1); border: 1px solid var(--line); color: var(--ink-700); border-radius: var(--radius-sm); padding: var(--sp-3) var(--sp-3) var(--sp-3) var(--sp-4); font-size: var(--fs-300); line-height: 1.5; margin-bottom: var(--sp-4); }
.guest-sample-text { flex: 1; min-width: 0; }
.guest-sample-text strong { color: var(--ink-900); }
.guest-sample-btn { flex-shrink: 0; background: var(--accent); color: #fff; border: 0; border-radius: var(--radius-sm); padding: 8px 16px; font: inherit; font-weight: 600; cursor: pointer; }
.guest-sample-btn:hover { background: var(--accent-600); }
@media (max-width: 560px) { .guest-sample-banner { flex-direction: column; align-items: stretch; } }

/* One-off sign-in prompt after a guest's 10th answer (quiz-engine.js maybeShowGuestNudge).
   Floats bottom-centre so it never covers or shifts the question being answered. */
.guest-nudge { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 900; width: min(560px, calc(100vw - 24px)); display: flex; align-items: center; gap: var(--sp-3); background: var(--surface-0, #fff); color: var(--ink-700); border: 1px solid var(--accent-100); border-radius: var(--radius); box-shadow: 0 12px 32px -8px rgba(13,27,42,.28); padding: var(--sp-3) var(--sp-3) var(--sp-3) var(--sp-4); font-size: var(--fs-300); line-height: 1.45; animation: guest-nudge-in .25s ease-out; }
.guest-nudge strong { color: var(--ink-900); }
.guest-nudge-text { flex: 1; min-width: 0; }
.guest-nudge-actions { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.guest-nudge-btn { background: var(--accent); color: #fff; border: 0; border-radius: var(--radius-sm); padding: 8px 14px; font: inherit; font-weight: 600; cursor: pointer; }
.guest-nudge-btn:hover { background: var(--accent-600); }
.guest-nudge-close { background: none; border: 0; color: var(--ink-500); font-size: 22px; line-height: 1; padding: 4px 8px; cursor: pointer; }
.guest-nudge-close:hover { color: var(--ink-900); }
@keyframes guest-nudge-in { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }
@media (prefers-reduced-motion: reduce) { .guest-nudge { animation: none; } }

.skip-link:focus { left: 0; }

.saved-sessions-panel { background: var(--surface-1); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--sp-4); margin-bottom: var(--sp-4); }
.saved-sessions-hdr h3 { font-size: var(--fs-400); margin-bottom: 2px; }
.saved-sessions-hdr p { color: var(--ink-500); font-size: var(--fs-300); margin-bottom: var(--sp-3); }
.saved-sessions-list { display: flex; flex-direction: column; gap: var(--sp-2); }
.saved-session-row { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap; background: var(--surface-0); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: var(--sp-3); }
.ssr-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ssr-progress { font-weight: 600; font-size: var(--fs-300); }
.ssr-time { color: var(--ink-500); font-size: var(--fs-200); }
.ssr-actions { display: flex; gap: var(--sp-2); flex-shrink: 0; }
.ssr-discard:hover { border-color: #d64545; color: #d64545; }

.exam-finish-group { display: flex; align-items: center; gap: var(--sp-2); }

/* Compound selector, not just .review-modal-box - .modal-box's own max-width/
   max-height (below) is an equal-specificity single-class rule, so whichever of
   the two comes later in this file would otherwise win regardless of which one is
   "meant" to override the other. .modal-box.review-modal-box outranks .modal-box
   alone and is immune to reordering. */
.modal-box.review-modal-box { max-width: 92vw; width: 92vw; max-height: 90vh; height: 90vh; display: flex; flex-direction: column; }
.review-hdr { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--sp-3); flex-wrap: wrap; margin-bottom: var(--sp-4); flex-shrink: 0; }
.review-body { display: flex; gap: var(--sp-5); align-items: stretch; flex: 1; min-height: 0; }
.review-main { flex: 1; min-width: 0; overflow-y: auto; }
.review-main .q-text { font-size: var(--fs-600); }
.review-tracker { width: 280px; flex-shrink: 0; overflow-y: auto; }
@media (max-width: 900px) {
    .review-body { flex-direction: column; }
    .review-tracker { width: 100%; }
}

/* Shared lightweight modal (report-an-issue, admin issue detail, account messages) -
   plain DOM overlay, no modal library, matching this codebase's existing pattern of
   simple injected panels (tracker panel, note box) rather than a dependency. */
.modal-overlay { position: fixed; inset: 0; background: rgba(21,24,28,.55); display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 20px; }
.modal-box { background: var(--surface-0); border-radius: var(--radius); padding: var(--sp-5); max-width: 460px; width: 100%; max-height: 85vh; overflow-y: auto; overflow-wrap: break-word; word-break: break-word; box-shadow: 0 20px 60px rgba(0,0,0,.35); box-sizing: border-box; }
.modal-box h3 { margin-bottom: 6px; }
.modal-sub { color: var(--ink-500); font-size: 13px; margin-bottom: 14px; }
.modal-textarea { width: 100%; min-height: 80px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); font-family: inherit; font-size: 14px; resize: vertical; margin-top: var(--sp-3); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; flex-wrap: wrap; }

.msg-thread { max-height: 240px; overflow-y: auto; margin: var(--sp-3) 0; display: flex; flex-direction: column; gap: 8px; }
.msg-bubble { padding: 8px 12px; border-radius: var(--radius-sm); font-size: 13.5px; max-width: 85%; overflow-wrap: break-word; word-break: break-word; }
.msg-bubble.from-admin { background: var(--accent-tint); align-self: flex-start; }
.msg-bubble.from-user { background: var(--surface-1); align-self: flex-end; }
.msg-meta { font-size: 11px; color: var(--ink-500); margin-bottom: 3px; font-weight: 600; }

.status-pill { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; }
.status-open { background: #fef3e0; color: #b45309; }
.status-resolved { background: #e6f7f0; color: #0f9d6e; }
.status-dismissed { background: var(--surface-1); color: var(--ink-500); }

.unread-dot { position: absolute; top: -3px; right: -3px; width: 9px; height: 9px; border-radius: 50%; background: #f59e0b; border: 2px solid #fff; }
.unread-dot-inline:not([hidden]) { display: inline-block; }
.unread-dot-inline { width: 8px; height: 8px; border-radius: 50%; background: #f59e0b; margin-left: 7px; vertical-align: middle; }

/* Generic collapsible-section title, for a <details> wrapping a report list/table
   that could grow long (mirrors the existing .intro-body > summary chevron pattern). */
.collapsible-title { cursor: pointer; list-style: none; user-select: none; }
.collapsible-title::-webkit-details-marker { display: none; }
.collapsible-title::before { content: '▸'; display: inline-block; margin-right: 8px; transition: transform .15s; }
details[open] > .collapsible-title::before { transform: rotate(90deg); }

/* Question comments panel */
.comment-item { padding: 10px 0; border-bottom: 1px solid var(--line-subtle); }
.comment-item:last-child { border-bottom: none; }
.comment-meta { display: flex; justify-content: space-between; align-items: center; font-size: 11.5px; color: var(--ink-500); font-weight: 600; margin-bottom: 4px; }
.comment-text { font-size: 13.5px; color: var(--ink-900); white-space: pre-wrap; word-break: break-word; }
.comment-actions { display: flex; align-items: center; gap: 12px; margin-top: 6px; }
.comment-like-btn { display: inline-flex; align-items: center; gap: 5px; border: none; background: none; cursor: pointer; font-size: 12px; color: var(--ink-500); padding: 2px 4px; }
.comment-like-btn.liked { color: #e0245e; font-weight: 600; }
.comment-delete-btn { border: none; background: none; cursor: pointer; font-size: 12px; color: var(--ink-500); }
.comment-delete-btn:hover { color: #b3261e; }
.comment-post-area { display: flex; flex-direction: column; gap: 8px; margin-top: var(--sp-3); }

.pagination { display: flex; gap: 6px; flex-wrap: wrap; padding: var(--sp-3) var(--sp-4); }
.page-btn { min-width: 32px; padding: 6px 10px; border-radius: 999px; border: 1px solid var(--line); background: #fff; cursor: pointer; font-size: 13px; }
.page-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.page-btn:disabled { opacity: .4; cursor: not-allowed; }

.action-menu { position: relative; display: inline-block; }
.action-menu-btn { background: #fff; border: 1px solid var(--line); border-radius: 999px; width: 28px; height: 28px; cursor: pointer; font-size: 16px; line-height: 1; }
.action-menu-dropdown { position: absolute; right: 0; top: 100%; margin-top: 4px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius-sm); box-shadow: 0 8px 24px -8px rgba(0,0,0,.25); min-width: 140px; z-index: 50; flex-direction: column; overflow: hidden; }
.action-menu-dropdown:not([hidden]) { display: flex; }
.action-menu-dropdown button { text-align: left; padding: 8px 12px; border: none; background: none; cursor: pointer; font-size: 13px; white-space: nowrap; }
.action-menu-dropdown button:hover { background: var(--surface-1); }
.action-menu-dropdown button.danger { color: #b3261e; }

/* Static sample questions on subject pages (scripts/build_sample_questions.py) */
.sample-qs .sq { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: var(--sp-4); margin-top: var(--sp-3); background: var(--surface-0); }
.sample-qs .sq-q { font-weight: 600; color: var(--ink-900); margin: 0 0 var(--sp-2); }
.sample-qs .sq-ref { font-family: var(--font-mono, 'IBM Plex Mono', monospace); font-size: 12px; font-weight: 500; color: var(--ink-500); margin-right: 6px; }
.sample-qs .sq-opts { margin: 0 0 var(--sp-2); padding-left: 1.6em; color: var(--ink-700); }
.sample-qs .sq-opts li { margin: 3px 0; }
.sample-qs .sq-ans > summary { cursor: pointer; color: var(--accent); font-weight: 600; font-size: 14px; }
.sample-qs .sq-ans p { margin: var(--sp-2) 0 0; color: var(--ink-700); }
.sample-qs .sq-cta { margin-top: var(--sp-4); }
.sample-qs .sq-cta a { color: var(--accent); font-weight: 600; text-decoration: none; }

/* Static FAQ + related reading on subject pages (scripts/build_sample_questions.py) */
.sq-faq .sq-faq-item { border-top: 1px solid var(--line); padding-top: var(--sp-3); margin-top: var(--sp-3); }
.sq-faq .sq-faq-item h3 { font-family: var(--font-ui); font-size: var(--fs-300); font-weight: 600; color: var(--ink-900); margin: 0 0 var(--sp-2); }
.sq-related .sq-related-list { list-style: none; padding: 0; margin: 0; border-top: 1px solid var(--line); max-width: 640px; }
.sq-related .sq-related-list li { border-bottom: 1px solid var(--line); }
.sq-related .sq-related-list a { display: block; padding: 12px 0; text-decoration: none; }
.sq-rel-title { display: block; font-weight: 600; color: var(--ink-900); font-size: var(--fs-300); }
.sq-rel-desc { display: block; margin-top: 2px; color: var(--ink-500); font-size: var(--fs-200); line-height: 1.5; }
.sq-related .sq-related-list a:hover .sq-rel-title { text-decoration: underline; text-underline-offset: 3px; }
.sq-others .sq-others-list { list-style: none; padding: 0; margin: 0; columns: 2; column-gap: var(--sp-5); max-width: 640px; }
.sq-others .sq-others-list li { padding: 5px 0; break-inside: avoid; }
.sq-others .sq-others-list a, .sq-others .sq-cta a { color: var(--accent); font-weight: 500; text-decoration: none; }
.sq-others .sq-others-list a:hover, .sq-others .sq-cta a:hover { text-decoration: underline; text-underline-offset: 3px; }
.sq-others .sq-cta { margin-top: var(--sp-3); }
@media (max-width: 560px) { .sq-others .sq-others-list { columns: 1; } }
@media (max-width: 560px) {
    .ts-saved-row { flex-wrap: wrap; }
    .ts-saved-text { flex-basis: 100%; }
}
