/* ==========================================================================
   BPSC PYQ — shared question-bank UI (all pyq-*.html pages)
   Tokens → layout → components. Subject accents are set by body.s-<subject>.
   ========================================================================== */

:root {
  --font-ui: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-read: "Newsreader", Georgia, "Times New Roman", serif;
  --radius: 14px;
  --radius-sm: 10px;
  --radius-pill: 999px;
  --header-h: 60px;
  --bar-h: 68px;
  --col: 780px;
  --side: 280px;
  --ease: cubic-bezier(.2, .8, .2, 1);
}

/* ---------- theme: light ---------- */
/* light mode for reading (the owner, 2026-10-03, plan doc "Light mode, buttons and
   challenges"): borders that show, third-level grey at 5:1 or more, a page a shade darker */
html[data-theme="light"] {
  color-scheme: light;
  --bg: #f3f4f6;
  --surface: #ffffff;
  --surface-2: #eef1f5;
  --surface-3: #e3e8ef;
  --border: rgba(15, 23, 42, .14);
  --border-strong: rgba(15, 23, 42, .24);
  --text: #0f172a;
  --text-2: #3f4b5e;
  --text-3: #586477;
  --good: #047857;
  --good-bg: #ecfdf5;
  --good-border: #6ee7b7;
  --bad: #b91c1c;
  --bad-bg: #fef2f2;
  --bad-border: #fca5a5;
  --warn: #92400e;
  --warn-bg: #fffbeb;
  --flame: #ea580c;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 6px 20px -6px rgba(15, 23, 42, .10);
  --scrim: rgba(15, 23, 42, .45);
}

/* ---------- theme: dark ---------- */
html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0f17;
  --surface: #131a26;
  --surface-2: #1a2333;
  --surface-3: #222d40;
  --border: rgba(255, 255, 255, .09);
  --border-strong: rgba(255, 255, 255, .17);
  --text: #e8edf4;
  --text-2: #b3bfcf;
  --text-3: #8592a6;
  --good: #34d399;
  --good-bg: rgba(52, 211, 153, .12);
  --good-border: rgba(52, 211, 153, .55);
  --bad: #f87171;
  --bad-bg: rgba(248, 113, 113, .12);
  --bad-border: rgba(248, 113, 113, .55);
  --warn: #fbbf24;
  --warn-bg: rgba(251, 191, 36, .12);
  --flame: #fb923c;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px -8px rgba(0, 0, 0, .5);
  --scrim: rgba(0, 0, 0, .6);
}

/* ---------- subject accents (match the homepage cards) ---------- */
/* --acc: fills (selected chips, primary button)  --acc-ink: text on a fill
   --acc-text: accent-coloured text/links          --acc-soft: tinted backgrounds */
html[data-theme="light"] body.s-history   { --acc: #1e40af; --acc-ink: #fff; --acc-text: #1e40af; --acc-soft: #eef2ff; }
html[data-theme="dark"]  body.s-history   { --acc: #60a5fa; --acc-ink: #06101f; --acc-text: #93c5fd; --acc-soft: rgba(96, 165, 250, .14); }
html[data-theme="light"] body.s-polity    { --acc: #4f46e5; --acc-ink: #fff; --acc-text: #4338ca; --acc-soft: #eef2ff; }
html[data-theme="dark"]  body.s-polity    { --acc: #818cf8; --acc-ink: #0b0d1f; --acc-text: #a5b4fc; --acc-soft: rgba(129, 140, 248, .15); }
html[data-theme="light"] body.s-bihar     { --acc: #a16207; --acc-ink: #fff; --acc-text: #92400e; --acc-soft: #fefce8; }
html[data-theme="dark"]  body.s-bihar     { --acc: #f59e0b; --acc-ink: #1a1204; --acc-text: #fbbf24; --acc-soft: rgba(245, 158, 11, .14); }
html[data-theme="light"] body.s-geography { --acc: #0369a1; --acc-ink: #fff; --acc-text: #0369a1; --acc-soft: #f0f9ff; }
html[data-theme="dark"]  body.s-geography { --acc: #38bdf8; --acc-ink: #03131d; --acc-text: #7dd3fc; --acc-soft: rgba(56, 189, 248, .14); }
html[data-theme="light"] body.s-biology   { --acc: #0f766e; --acc-ink: #fff; --acc-text: #0f766e; --acc-soft: #f0fdfa; }
html[data-theme="dark"]  body.s-biology   { --acc: #34d399; --acc-ink: #03140d; --acc-text: #6ee7b7; --acc-soft: rgba(52, 211, 153, .14); }
html[data-theme="light"] body.s-chemistry { --acc: #b45309; --acc-ink: #fff; --acc-text: #b45309; --acc-soft: #fffbeb; }
html[data-theme="dark"]  body.s-chemistry { --acc: #fbbf24; --acc-ink: #1a1204; --acc-text: #fcd34d; --acc-soft: rgba(251, 191, 36, .14); }
html[data-theme="light"] body.s-physics   { --acc: #2563eb; --acc-ink: #fff; --acc-text: #1d4ed8; --acc-soft: #eff6ff; }
html[data-theme="dark"]  body.s-physics   { --acc: #60a5fa; --acc-ink: #06101f; --acc-text: #93c5fd; --acc-soft: rgba(96, 165, 250, .14); }
/* pages that aren't about one subject (league, settings, profiles, daily, revise, admin): deep navy */
html[data-theme="light"] body.s-site      { --acc: #1e3a8a; --acc-ink: #fff; --acc-text: #1e3a8a; --acc-soft: #eef2fb; }
html[data-theme="dark"]  body.s-site      { --acc: #60a5fa; --acc-ink: #06101f; --acc-text: #93c5fd; --acc-soft: rgba(96, 165, 250, .14); }

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.5 var(--font-ui);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--acc-text); }
:focus-visible { outline: 2px solid var(--acc); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
[hidden] { display: none !important; }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; scroll-behavior: auto !important; } }

/* ---------- background art (layer filled by assets/art/<slug>.js) ----------
   Sits behind all page content (z-index -1 under the body's own content); each
   chapter's art is a .bg-l layer that cross-fades in. Subject files style their own art. */
.bg { position: fixed; inset: 0; z-index: -1; pointer-events: none; overflow: hidden; contain: strict; }
.bg-l { position: absolute; inset: 0; opacity: 0; transition: opacity .6s var(--ease); }
.bg-l.in { opacity: 1; }
.bg svg { display: block; }

/* ---------- header ---------- */
/* scrolls away with the page (the owner, 2026-10-02: nothing pinned to the top) */
.hdr {
  position: relative; z-index: 30;
  height: var(--header-h);
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  border-bottom: 1px solid var(--border);
}
.hdr-in {
  height: 100%;
  max-width: calc(var(--side) + var(--col) + 72px);
  margin: 0 auto;
  padding: 0 16px;
  display: flex; align-items: center; gap: 10px;
}
.brand { min-width: 0; flex: 1; display: flex; flex-direction: column; justify-content: center; }
.brand h1 {
  margin: 0;
  font: 600 1.125rem/1.2 var(--font-read);
  letter-spacing: -.005em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.brand p { margin: 1px 0 0; font-size: .75rem; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hdr-actions { display: flex; align-items: center; gap: 6px; flex: none; }
/* every control in the header is 40 px tall, like the Home button (the account button is 36 elsewhere) */
.hdr .acct-btn { min-height: 40px; }
.hdr .acct-btn.in { width: 40px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 0 14px;
  border: 1px solid var(--border-strong); border-radius: 8px;
  background: var(--surface); color: var(--text);
  font-size: .9375rem; font-weight: 600; text-decoration: none; white-space: nowrap;
  transition: background .15s var(--ease), border-color .15s var(--ease), transform .1s var(--ease);
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: default; transform: none; }
.btn.primary { background: var(--acc); border-color: var(--acc); border-bottom-color: color-mix(in srgb, var(--acc) 72%, #000); color: var(--acc-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.primary:disabled { border-bottom-color: var(--acc); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { color: var(--bad); }
.icon-btn { width: 40px; padding: 0; flex: none; }
.btn .lbl-wide { display: none; }
@media (min-width: 560px) { .btn .lbl-wide { display: inline; } }

.streak-btn {
  display: inline-flex; align-items: center; gap: 4px; min-height: 40px; padding: 0 11px 0 8px;
  border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface); color: var(--text-3);
  font-size: .875rem; font-weight: 800; font-variant-numeric: tabular-nums;
}
.streak-btn:hover { background: var(--surface-2); }
.streak-btn.on { color: var(--text); }
.timer {
  font-variant-numeric: tabular-nums; font-weight: 700; font-size: .9375rem;
  padding: 0 12px; min-height: 36px; display: inline-flex; align-items: center; gap: 6px;
  border-radius: var(--radius-pill); background: var(--surface-2); color: var(--text);
}
.timer.low { background: var(--bad-bg); color: var(--bad); }

/* ---------- page shell ---------- */
.shell {
  max-width: calc(var(--side) + var(--col) + 72px);
  margin: 0 auto;
  padding: 16px 16px calc(var(--bar-h) + 28px + env(safe-area-inset-bottom));
}
.main { min-width: 0; max-width: var(--col); margin: 0 auto; }
.side { display: none; }
@media (min-width: 1100px) {
  .shell { display: grid; grid-template-columns: var(--side) minmax(0, var(--col)); gap: 32px; justify-content: center; padding-bottom: 40px; }
  .main { margin: 0; }
  .side {
    display: block; position: sticky; top: 16px;
    align-self: start; max-height: calc(100vh - 32px); overflow-y: auto; overflow-x: hidden;
    scrollbar-width: thin;
  }
  .only-narrow { display: none !important; }
}
@media (max-width: 1099px) { .only-wide { display: none !important; } }
/* light mode: the background art is faded behind the side panel's text (the owner, 2026-10-03) */
@media (min-width: 1100px) {
  html[data-theme="light"] .side { background: color-mix(in srgb, var(--bg) 84%, transparent); box-shadow: 0 0 18px 14px color-mix(in srgb, var(--bg) 84%, transparent); border-radius: 12px; }
}

/* ---------- controls ---------- */
.controls { display: grid; gap: 10px; margin-bottom: 14px; }
.seg {
  display: inline-grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  padding: 3px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border);
  justify-self: start;
}
.seg button {
  min-height: 34px; padding: 0 16px; border: 0; border-radius: 7px; background: transparent;
  font-size: .875rem; font-weight: 600; color: var(--text-2);
}
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
/* English | हिन्दी, on a subject with a Hindi version (src/scripts/pyq/lang.ts, DECISIONS D52) */
.lang-seg { justify-self: end; flex: none; grid-auto-columns: auto; }
.lang-seg button { padding: 0 12px; }
/* Practice | Mock test, the switch and Shuffle share one row; on a phone the switch takes a row
   of its own under them */
.topline.with-lang { flex-wrap: wrap; row-gap: 8px; }
.topline.with-lang .lang-seg { margin-left: auto; }
@media (max-width: 479px) { .topline.with-lang .lang-seg { order: 3; flex: 1 0 100%; grid-auto-columns: 1fr; } }
.lang-seg button:lang(hi) { font-family: "Noto Sans Devanagari", "Kohinoor Devanagari", "Nirmala UI", "Mangal", var(--font-ui); font-size: .9375rem; }
.exam-lang { margin: -4px 2px 10px; justify-content: flex-end; }
/* Hindi text: Noto Sans Devanagari, self-hosted for Devanagari only (src/data/fonts.ts), first, so
   Latin letters and numbers still come from the reading font; the phone's own Devanagari faces
   only while it loads or offline (before the generic family, which would otherwise win); more line
   height for the matras */
:lang(hi) .stem, :lang(hi) .opt .t, :lang(hi) .expl-body, .card:lang(hi) .q-ch, .chlist li:lang(hi) {
  font-family: "Noto Sans Devanagari Variable", "Newsreader", Georgia, "Times New Roman",
    "Noto Sans Devanagari", "Kohinoor Devanagari", "Nirmala UI", "Mangal", serif;
}
:lang(hi) .stem .rt, :lang(hi) .opt .t, :lang(hi) .expl-body { line-height: 1.75; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; min-width: 0; }
.field {
  min-height: 42px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); padding: 0 12px; font-size: .9375rem; min-width: 0;
}
select.field {
  appearance: none; -webkit-appearance: none; padding-right: 34px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%23889' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
.field.grow { flex: 1 1 200px; }
.search { position: relative; flex: 1 1 150px; min-width: 0; }
.topline { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.search input { width: 100%; padding-left: 38px; }
.search input::-webkit-search-cancel-button { cursor: pointer; }
#chapterSel { flex: 1 1 100%; }
@media (min-width: 640px) { #chapterSel { flex: 1 1 260px; } }

.chips {
  display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch;
  margin: 0 -16px; padding: 2px 16px; scroll-padding: 16px;
}
.chips::-webkit-scrollbar { display: none; }
@media (min-width: 1100px) { .chips { margin: 0; padding: 2px 0; flex-wrap: wrap; } }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 6px;
  min-height: 36px; padding: 0 14px; border-radius: var(--radius-pill);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-2);
  font-size: .875rem; font-weight: 600;
}
.chip .n { font-weight: 700; color: var(--text-3); font-variant-numeric: tabular-nums; }
.chip[aria-pressed="true"] { background: var(--acc); border-color: var(--acc); color: var(--acc-ink); }
.chip[aria-pressed="true"] .n { color: inherit; opacity: .8; }

.statline { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: .8125rem; color: var(--text-3); }
.statline b { color: var(--text-2); font-variant-numeric: tabular-nums; }

/* ---------- question card ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
}
.q-meta {
  display: flex; align-items: flex-start; gap: 10px; padding: 14px 16px 0;
}
.q-meta .where { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.q-no { font-weight: 800; font-size: .8125rem; color: var(--acc-text); font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.q-ch { font-size: .8125rem; color: var(--text-3); min-width: 0; }
.tag {
  display: inline-flex; align-items: center; min-height: 22px; padding: 0 8px; border-radius: 6px;
  background: var(--surface-2); color: var(--text-2); font-size: .75rem; font-weight: 600; line-height: 1.3;
}
.tag.src { background: var(--acc-soft); color: var(--acc-text); }
.tag.warn { background: var(--warn-bg); color: var(--warn); }
/* time on this question: live while attempting, frozen after; amber once past the BPSC pace */
.qtime {
  flex: none; display: inline-flex; align-items: center; gap: 5px; margin-top: 7px;
  min-height: 26px; padding: 0 9px 0 7px; border-radius: var(--radius-pill);
  background: var(--surface-2); color: var(--text-2);
  font-size: .75rem; font-weight: 700; font-variant-numeric: tabular-nums;
}
.qtime svg { width: 14px; height: 14px; }
.qtime.quick { background: var(--good-bg); color: var(--good); }
.qtime.slow { background: var(--warn-bg); color: var(--warn); }
.star { color: var(--text-3); }
.star[aria-pressed="true"] { color: #f59e0b; }
.star[aria-pressed="true"] svg { fill: currentColor; }

.q-body { padding: 12px 16px 16px; }
.q-tools { display: flex; flex-wrap: wrap; gap: 4px; margin: 10px -8px 0; }
.btn.sm { min-height: 32px; padding: 0 10px; gap: 6px; font-size: .8125rem; color: var(--text-3); }
.btn.sm svg { width: 16px; height: 16px; }
.btn.sm:hover { color: var(--text); }
.report-kinds { display: grid; gap: 8px; margin: 12px 0; }
.report-kinds .chip { justify-content: flex-start; min-height: 42px; }
.report-kinds .chip[aria-checked="true"] { background: var(--acc); border-color: var(--acc); color: var(--acc-ink); }
.report-note { width: 100%; min-height: 84px; padding: 10px 12px; resize: vertical; font: inherit; line-height: 1.45; }
.stem { font: 400 clamp(1.125rem, 1.06rem + .3vw, 1.28rem)/1.55 var(--font-read); color: var(--text); overflow-wrap: anywhere; }
.stem > * { margin: 0 0 .6em; }
.stem > *:last-child { margin-bottom: 0; }
.rt { white-space: pre-line; }
.rt strong { font-weight: 700; }
.stem ul, .expl ul { padding-left: 1.2em; }
.stem ul { list-style: none; padding-left: 0; }
.stem li { margin: .15em 0; }
.tbl-wrap { overflow-x: auto; margin: .2em 0 .7em; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.tbl { border-collapse: collapse; width: 100%; font: 400 .9375rem/1.45 var(--font-ui); }
.tbl td, .tbl th { padding: 8px 10px; border-top: 1px solid var(--border); vertical-align: top; text-align: left; }
.tbl tr:first-child td, .tbl tr:first-child th { border-top: 0; }
.tbl th { background: var(--surface-2); font-weight: 700; font-size: .8125rem; color: var(--text-2); }

.opts { display: grid; gap: 10px; margin-top: 16px; }
.opt {
  display: flex; align-items: flex-start; gap: 12px; width: 100%;
  min-height: 52px; padding: 12px 14px; text-align: left;
  border: 1.5px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  font-size: 1rem; line-height: 1.45;
  transition: border-color .15s var(--ease), background .15s var(--ease);
}
.opt:hover:not(:disabled) { border-color: var(--acc); background: var(--acc-soft); }
.opt:disabled { cursor: default; }
.opt .k {
  flex: none; display: grid; place-items: center; width: 28px; height: 28px; margin-top: -2px;
  border-radius: 8px; border: 1.5px solid color-mix(in srgb, var(--text) 30%, transparent);
  font-size: .8125rem; font-weight: 800; text-transform: uppercase; color: var(--text-2);
}
.opt .t { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.opt .mark { flex: none; margin-top: 1px; }
.opt.sel { border-color: var(--acc); background: var(--acc-soft); }
.opt.sel .k { background: var(--acc); border-color: var(--acc); color: var(--acc-ink); }
.opt.right { border-color: var(--good-border); background: var(--good-bg); }
.opt.right .k { background: var(--good); border-color: var(--good); color: var(--surface); }
.opt.right .mark { color: var(--good); }
.opt.wrong { border-color: var(--bad-border); background: var(--bad-bg); }
.opt.wrong .k { background: var(--bad); border-color: var(--bad); color: var(--surface); }
.opt.wrong .mark { color: var(--bad); }
.opt.dim { opacity: .62; }

.verdict {
  display: flex; align-items: center; gap: 10px; margin-top: 16px; padding: 12px 14px;
  border-radius: var(--radius-sm); font-weight: 700; font-size: .9375rem; flex-wrap: wrap; row-gap: 4px;
}
.verdict.ok { background: var(--good-bg); color: var(--good); }
.verdict.no { background: var(--bad-bg); color: var(--bad); }
.verdict.info { background: var(--surface-2); color: var(--text-2); }
.verdict.warn { background: var(--warn-bg); color: var(--warn); }
.verdict .sub { margin-left: auto; font-weight: 600; font-size: .8125rem; opacity: .85; }
.verdict .run { margin-left: auto; display: inline-flex; align-items: center; gap: 5px; font-size: .8125rem; font-weight: 800; }
.verdict .run svg, .streak-btn.on svg, .today-sub.on svg, .ptile.on > svg.i { color: var(--flame); fill: currentColor; fill-opacity: .3; }
.verdict .run svg { width: 16px; height: 16px; }

.expl { border-top: 1px solid var(--border); padding: 16px; background: var(--surface-2); }
.expl h2 { margin: 0 0 8px; font: 700 .8125rem/1.3 var(--font-ui); color: var(--text-3); }
.expl-body { font: 400 1.0625rem/1.65 var(--font-read); color: var(--text); max-width: 68ch; overflow-wrap: anywhere; }
.expl-body > * { margin: 0 0 .7em; }
.expl-body > *:last-child { margin-bottom: 0; }
.expl-body li { margin: .25em 0; }
.note { margin-top: 12px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--warn-bg); color: var(--warn); font-size: .875rem; line-height: 1.5; }
.note.plain { background: var(--surface-3); color: var(--text-2); }

.empty { text-align: center; padding: 48px 20px; color: var(--text-2); }
.empty h2 { font: 600 1.25rem/1.3 var(--font-read); color: var(--text); margin: 0 0 6px; }
.empty .btn { margin-top: 16px; }
/* a guest past the 20-question / 20-card limit (src/scripts/gate.ts) */
.wall p { max-width: 46ch; margin: 0 auto; line-height: 1.55; }
.wall .wall-note { margin-top: 14px; font-size: .8125rem; color: var(--text-3); }

.hint { margin: 14px 2px 0; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; font-size: .75rem; color: var(--text-3); line-height: 1.4; }
.hint .kh { display: inline-flex; align-items: center; gap: 5px; }
.hint kbd {
  font: 700 .6875rem/1 var(--font-ui); padding: 3px 6px; border-radius: 5px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-2);
}
@media (hover: none), (max-width: 719px) { .hint { display: none; } }

/* ---------- bottom bar ---------- */
.bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
  background: var(--surface);
  border-top: 1px solid var(--border);
  box-shadow: 0 -6px 18px -12px rgba(0, 0, 0, .35);
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
}
.bar-in { max-width: var(--col); margin: 0 auto; display: flex; align-items: center; gap: 8px; }
.bar .count {
  flex: 1; min-width: 0; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; border: 0; background: transparent; border-radius: var(--radius-sm);
  font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text-2); font-size: .9375rem; white-space: nowrap;
}
@media (max-width: 379px) {
  .bar .lbl-mid { display: none; } .bar .count svg { display: none; }
  .streak-btn { padding: 0 4px; border-color: transparent; background: transparent; }
}
.bar .count:hover { background: var(--surface-2); }
.bar .btn { min-height: 48px; }
.bar .nav-prev, .bar .nav-next { min-width: 56px; }
@media (min-width: 1100px) {
  .bar { position: sticky; bottom: 16px; margin-top: 16px; padding: 10px; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); background: var(--surface); }
  body[data-view="exam"] .shell, body[data-view="result"] .shell { grid-template-columns: minmax(0, var(--col)); }
  body[data-view="exam"] .side, body[data-view="result"] .side { display: none; }
  .bar-in { max-width: none; }
}

/* ---------- side panel / drawer ---------- */
.panel h2 { margin: 0 0 10px; font: 700 .8125rem/1.3 var(--font-ui); color: var(--text-3); }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 18px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px; text-align: center; }
.stat b { display: block; font-size: 1.125rem; font-variant-numeric: tabular-nums; }
.stat span { font-size: .75rem; color: var(--text-3); font-weight: 700; }
.stat.good b { color: var(--good); }
.stat.bad b { color: var(--bad); }
.chlist { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.chgroup { margin: 12px 0 4px; font-size: .75rem; font-weight: 800; color: var(--text-3); padding: 0 10px; }
.chbtn {
  width: 100%; display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; align-items: center;
  padding: 9px 10px; border: 0; border-radius: 9px; background: transparent; text-align: left; color: var(--text-2);
  font-size: .875rem; line-height: 1.35;
}
.chbtn:hover { background: var(--surface-2); color: var(--text); }
.chbtn[aria-current="true"] { background: var(--acc-soft); color: var(--acc-text); font-weight: 700; box-shadow: inset 2px 0 0 var(--acc); }
.chbtn .cnt { display: inline-flex; align-items: center; gap: 4px; font-size: .75rem; color: var(--text-3); font-variant-numeric: tabular-nums; }
.chbtn .cnt svg { width: 14px; height: 14px; }
.chbtn.full .cnt, .chbtn.master .cnt { color: var(--good); }
.chbtn.master .cnt svg { color: #f59e0b; }
.chbtn.full .prog i, .chbtn.master .prog i { background: var(--good); }
.chbtn .prog { grid-column: 1 / -1; height: 3px; border-radius: 3px; overflow: hidden; }
.chbtn .prog i { display: block; height: 100%; background: var(--acc); border-radius: 3px; }
.side-actions { display: grid; gap: 8px; margin-top: 18px; }
/* today card: daily-goal ring + streak; opens the progress sheet */
.today {
  width: 100%; display: flex; align-items: center; gap: 12px; margin-bottom: 10px; padding: 12px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); text-align: left;
  transition: border-color .15s var(--ease);
}
.today:hover { border-color: var(--acc); }
.today > svg.i { color: var(--text-3); }
.today-tx { flex: 1; min-width: 0; display: grid; gap: 2px; }
.today-tx b { font-size: .9375rem; }
.today-sub { display: inline-flex; align-items: center; gap: 5px; font-size: .8125rem; font-weight: 600; color: var(--text-3); }
.today-sub svg { width: 15px; height: 15px; }
.ring { position: relative; flex: none; display: inline-grid; place-items: center; width: 44px; height: 44px; }
.ring.lg { width: 58px; height: 58px; }
.ring svg:first-child { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 3.6; }
.ring .track { stroke: var(--surface-3); }
.ring .fill { stroke: var(--acc); stroke-linecap: round; }
.ring.done .fill { stroke: var(--good); }
.ring b { font-size: .8125rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.ring.lg b { font-size: 1.125rem; }
.ring > .i { color: var(--good); }
/* "N more chapters" pill: sticks to the bottom of the scrolling list. While chapters are
   hidden below, the list itself fades out (a mask, so the background art shows through);
   the first mask layer keeps the pill's own spot fully opaque. */
.more-hint {
  position: sticky; bottom: 0; z-index: 2;
  display: flex; justify-content: center;
  margin-top: 8px; padding: 26px 0 8px;
  pointer-events: none; opacity: 0; visibility: hidden; transition: opacity .2s var(--ease), visibility .2s;
}
.fade-end {   /* --pill = "x y / w h" of the pill inside the scroller, set by pyq.js */
  -webkit-mask: linear-gradient(#000 0 0) var(--pill, 0 0 / 0 0) no-repeat,
                linear-gradient(to bottom, #000 calc(100% - 84px), transparent calc(100% - 10px));
          mask: linear-gradient(#000 0 0) var(--pill, 0 0 / 0 0) no-repeat,
                linear-gradient(to bottom, #000 calc(100% - 84px), transparent calc(100% - 10px));
}
.more-hint.on { opacity: 1; visibility: visible; }
.more-hint button {
  pointer-events: auto; display: inline-flex; align-items: center; gap: 6px;
  min-height: 34px; padding: 0 12px 0 14px; border-radius: var(--radius-pill);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-2);
  font-size: .8125rem; font-weight: 700; box-shadow: var(--shadow);
}
.more-hint button:hover { color: var(--acc-text); border-color: var(--acc); }
.more-hint svg { width: 16px; height: 16px; animation: nudge 1.6s var(--ease) infinite; }
@keyframes nudge { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(3px); } }

/* ---------- dialogs & drawers ---------- */
.scrim { position: fixed; inset: 0; z-index: 40; background: var(--scrim); opacity: 0; pointer-events: none; transition: opacity .2s var(--ease); }
.scrim.on { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; z-index: 50; top: 0; bottom: 0; left: 0; width: min(88vw, 340px);
  background: var(--bg); border-right: 1px solid var(--border);
  transform: translateX(-102%); transition: transform .25s var(--ease);
  display: flex; flex-direction: column; visibility: hidden;
}
.drawer.on { transform: none; visibility: visible; }
.sheet {
  position: fixed; z-index: 50; left: 0; right: 0; bottom: 0; max-height: 86vh;
  background: var(--bg); border-top: 1px solid var(--border); border-radius: 18px 18px 0 0;
  transform: translateY(102%); transition: transform .25s var(--ease);
  display: flex; flex-direction: column; visibility: hidden;
}
.sheet.on { transform: none; visibility: visible; }
@media (min-width: 720px) {
  .sheet {
    left: 50%; right: auto; bottom: auto; top: 50%; width: min(92vw, 560px); max-height: 84vh;
    border: 1px solid var(--border); border-radius: 18px;
    transform: translate(-50%, -46%) scale(.98); opacity: 0; transition: transform .2s var(--ease), opacity .2s var(--ease);
  }
  .sheet.on { transform: translate(-50%, -50%); opacity: 1; }
}
.dlg-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.dlg-head h2 { flex: 1; margin: 0; font: 600 1.125rem/1.3 var(--font-read); }
.dlg-body { padding: 16px; overflow: auto; overscroll-behavior: contain; }
.dlg-foot { padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }

.palette { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 6px; }
.pal {
  min-height: 42px; border-radius: 9px; border: 1px solid var(--border-strong); background: var(--surface);
  font-size: .8125rem; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text-2); position: relative;
}
.pal.ok { background: var(--good-bg); border-color: var(--good-border); color: var(--good); }
.pal.no { background: var(--bad-bg); border-color: var(--bad-border); color: var(--bad); }
.pal.done { background: var(--acc-soft); border-color: var(--acc); color: var(--acc-text); }
.pal.flag::after { content: ""; position: absolute; top: 4px; right: 4px; width: 7px; height: 7px; border-radius: 50%; background: #f59e0b; }
.pal.cur { outline: 2px solid var(--acc); outline-offset: 1px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-bottom: 12px; font-size: .75rem; color: var(--text-3); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; border: 1px solid var(--border-strong); }
.legend .l-ok { background: var(--good-bg); border-color: var(--good-border); }
.legend .l-no { background: var(--bad-bg); border-color: var(--bad-border); }
.legend .l-done { background: var(--acc-soft); border-color: var(--acc); }
.legend .l-flag { background: #f59e0b; border-radius: 50%; border: 0; }

.form { display: grid; gap: 18px; }
.form fieldset { border: 0; margin: 0; padding: 0; display: grid; gap: 8px; }
.form legend { padding: 0; margin-bottom: 8px; font-weight: 700; font-size: .875rem; }
.form .choices { display: flex; flex-wrap: wrap; gap: 8px; }
.form .help { font-size: .8125rem; color: var(--text-3); margin: 0; }
.check { display: flex; align-items: center; gap: 10px; font-size: .9375rem; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--acc); }

/* ---------- exam result ---------- */
.result-hero { padding: 22px 18px; text-align: center; }
.result-hero .big { font: 600 clamp(2.25rem, 1.8rem + 2vw, 3rem)/1 var(--font-read); color: var(--text); font-variant-numeric: tabular-nums; }
.result-hero .big small { font-size: .45em; color: var(--text-3); }
.result-hero p { margin: 8px 0 0; color: var(--text-2); }
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; padding: 0 16px 18px; }
@media (min-width: 560px) { .tiles { grid-template-columns: repeat(3, 1fr); } }
.tile { background: var(--surface-2); border-radius: var(--radius-sm); padding: 12px; text-align: center; }
.tile b { display: block; font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.tile span { font-size: .75rem; color: var(--text-3); font-weight: 600; }
.tile.good b { color: var(--good); }
.tile.bad b { color: var(--bad); }
.tile.warn b { color: var(--warn); }
.result-hero .pb {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 12px; padding: 5px 12px;
  border-radius: var(--radius-pill); background: var(--acc-soft); color: var(--acc-text); font-size: .8125rem; font-weight: 800;
}
.result-hero .pb svg { width: 16px; height: 16px; }
.result-hero .help { margin-top: 6px; font-size: .8125rem; color: var(--text-3); }
.rsec { padding: 0 16px 18px; }
.review { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--border); }
.review li { border-bottom: 1px solid var(--border); }
.review button {
  width: 100%; display: grid; grid-template-columns: auto 1fr auto auto; gap: 12px; align-items: center;
  padding: 12px 16px; border: 0; background: transparent; text-align: left; font-size: .9375rem; color: var(--text);
}
.review button:hover { background: var(--surface-2); }
.review .num { font-weight: 800; color: var(--text-3); font-variant-numeric: tabular-nums; font-size: .8125rem; }
.review .snip { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.review .tm { font-size: .75rem; font-weight: 600; color: var(--text-3); font-variant-numeric: tabular-nums; }
.review .tm.slow { color: var(--warn); }
.review .res { font-size: .75rem; font-weight: 800; padding: 3px 8px; border-radius: 6px; }
.review .res.ok { background: var(--good-bg); color: var(--good); }
.review .res.no { background: var(--bad-bg); color: var(--bad); }
.review .res.skip { background: var(--surface-3); color: var(--text-2); }
.result-actions { display: flex; flex-wrap: wrap; gap: 8px; padding: 16px; }

/* ---------- progress sheet ---------- */
.progress { display: grid; gap: 22px; }
.progress h3, .rsec h3 {
  display: flex; justify-content: space-between; gap: 8px; margin: 0 0 10px;
  font: 700 .8125rem/1.3 var(--font-ui); color: var(--text-3);
}
.progress h3 span { letter-spacing: 0; text-transform: none; font-weight: 600; }
.progress .choices { display: flex; flex-wrap: wrap; gap: 8px; }
.progress .choices .chip { min-width: 52px; justify-content: center; }
.progress .help { margin: -4px 0 12px; font-size: .8125rem; color: var(--text-3); }
.progress .msg { margin: -10px 0 0; text-align: center; font-size: .875rem; color: var(--text-2); }
.ptiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.ptile {
  min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 14px 6px 12px; text-align: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.ptile > svg.i { width: 26px; height: 26px; margin-bottom: 4px; color: var(--text-3); }
.ptile > .ring { margin-bottom: 4px; }
.ptile b { font-size: 1.375rem; line-height: 1.15; font-variant-numeric: tabular-nums; }
.ptile span { font-size: .8125rem; font-weight: 600; color: var(--text-2); }
.ptile small { font-size: .6875rem; color: var(--text-3); }
.ptile > .ring + span { margin-top: auto; }

/* activity heatmap: columns are weeks (Mon→Sun), newest on the right */
.heat { display: grid; grid-template-columns: repeat(15, 1fr); grid-template-rows: repeat(7, auto); grid-auto-flow: column; gap: 3px; max-width: 340px; }
.heat i { aspect-ratio: 1; border-radius: 3px; }
.heat i, .heat-legend i { background: var(--surface-3); }
.heat .h1, .heat-legend .h1 { background: var(--acc); opacity: .3; }
.heat .h2, .heat-legend .h2 { background: var(--acc); opacity: .55; }
.heat .h3, .heat-legend .h3 { background: var(--acc); opacity: .8; }
.heat .h4, .heat-legend .h4 { background: var(--acc); }
.heat .x { background: transparent; }
.heat-legend { display: flex; align-items: center; gap: 3px; margin-top: 8px; font-size: .6875rem; color: var(--text-3); }
.heat-legend i { width: 10px; height: 10px; border-radius: 2px; }
.heat-legend i:first-of-type { margin-left: 4px; }
.heat-legend i:last-of-type { margin-right: 4px; }

/* mock test score history */
.hist { display: flex; gap: 6px; height: 124px; }
.hcol { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.hbar { flex: 1; width: 100%; max-width: 30px; display: flex; align-items: flex-end; border-radius: 6px; background: var(--surface-3); overflow: hidden; }
.hbar i { display: block; width: 100%; background: var(--acc); opacity: .5; }
.hcol.cur .hbar i { opacity: 1; }
.hv { font-size: .6875rem; font-weight: 800; color: var(--text-2); font-variant-numeric: tabular-nums; }
.hx { font-size: .625rem; color: var(--text-3); font-variant-numeric: tabular-nums; }

.badges { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.badge { display: flex; align-items: flex-start; gap: 10px; padding: 10px; border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); }
.badge .bi { flex: none; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--surface-3); color: var(--text-3); }
.badge .bt { min-width: 0; display: grid; gap: 1px; }
.badge .bt b { font-size: .8125rem; color: var(--text-2); }
.badge .bt span { font-size: .75rem; line-height: 1.35; color: var(--text-3); }
.badge.got { border-style: solid; border-color: var(--border); background: var(--surface); }
.badge.got .bi { background: var(--acc); color: var(--acc-ink); }
.badge.got .bt b { color: var(--text); }
/* earned harder badges in amber, the hardest in ruby (src/scripts/pyq/badges.ts tiers 3 and 4; no tier names shown) */
.badge.got.t3 .bi { background: #b45309; color: #fff; }
.badge.got.t4 .bi { background: #9f1239; color: #fff; }

/* ---------- award pop + confetti ---------- */
.award {
  position: fixed; z-index: 65; left: 50%; top: calc(var(--header-h) + 12px);
  display: flex; align-items: center; gap: 12px; width: max-content; max-width: calc(100vw - 32px);
  padding: 10px 18px 10px 10px; border-radius: 16px;
  background: var(--surface); border: 1px solid var(--border-strong); box-shadow: 0 14px 34px -12px rgba(0, 0, 0, .4);
  transform: translate(-50%, -14px); opacity: 0; pointer-events: none;
  transition: transform .25s var(--ease), opacity .25s var(--ease);
}
.award.on { transform: translate(-50%, 0); opacity: 1; }
.award-ic { flex: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: var(--acc); color: var(--acc-ink); }
.award-tx { min-width: 0; display: grid; }
.award-tx b { font-size: .6875rem; letter-spacing: .08em; text-transform: uppercase; color: var(--acc-text); }
.award-tx span { font-size: .9375rem; font-weight: 700; color: var(--text); line-height: 1.35; }
.confetti { position: fixed; inset: 0; z-index: 70; pointer-events: none; overflow: hidden; }
.confetti i { position: absolute; top: -16px; width: 8px; height: 13px; border-radius: 2px; animation: fall 1.6s cubic-bezier(.25, .6, .4, 1) forwards; }
@keyframes fall { to { transform: translate(var(--dx), 105vh) rotate(var(--r)); opacity: .85; } }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--bar-h) + 20px + env(safe-area-inset-bottom)); z-index: 60;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: var(--radius-pill);
  font-size: .875rem; font-weight: 600; transition: transform .2s var(--ease), opacity .2s var(--ease);
  max-width: calc(100vw - 32px);
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Phase 3: XP hint, question stats, revision, streak freezes ---------- */
a.btn { text-decoration: none; }
.verdict .xp-hint { margin-left: auto; padding: 2px 8px; border-radius: var(--radius-pill); background: var(--acc-soft); color: var(--acc-text); font-size: .75rem; font-weight: 800; }
.verdict .run + .xp-hint, .verdict .sub + .xp-hint { margin-left: 8px; }
.verdict .xp-hint.neg { background: var(--bad-bg); color: var(--bad); }
.qstats { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 12px 0 0; font-size: .8125rem; color: var(--text-2); }
.qstats .diff { padding: 2px 8px; border-radius: var(--radius-pill); font-size: .75rem; font-weight: 800; }
.qstats .diff.easy { background: var(--good-bg); color: var(--good); }
.qstats .diff.medium { background: var(--warn-bg); color: var(--warn); }
.qstats .diff.hard { background: var(--bad-bg); color: var(--bad); }
.chip.rev svg { width: 14px; height: 14px; margin-right: 2px; vertical-align: -2px; }
.chip.rev:not([aria-pressed="true"]) { border-color: var(--acc); color: var(--acc-text); }
.heat i.fz { background: #7dd3fc; outline: 1px dashed #0284c7; outline-offset: -1px; }

/* ---------- a question on its way from /api/q (src/scripts/pyq/content.ts) ---------- */
/* about a real card's height, so nothing below jumps when the text lands */
.card.wait .q-body { min-height: 360px; }
.card.wait .sk { border-radius: var(--radius-sm); background: var(--surface-2); }
.card.wait .sk-stem { height: 22px; width: 92%; margin: 4px 0 12px; }
.card.wait .sk-stem.short { width: 60%; margin-bottom: 26px; }
.card.wait .sk-opt { height: 52px; margin-top: 10px; background: none; border: 1.5px solid var(--border); }
.card.wait .help { margin: 4px 0 14px; }
@media (prefers-reduced-motion: no-preference) { .card.wait[aria-busy="true"] .sk-stem { animation: sk-pulse 1.2s ease-in-out infinite alternate; } }
@keyframes sk-pulse { from { opacity: 1; } to { opacity: .5; } }

/* ---------- chapter list at the foot: plain HTML for search engines and no-JS readers ---------- */
.toc { box-sizing: border-box; max-width: calc(var(--side) + var(--col) + 72px); margin: 0 auto; padding: 0 16px 20px; font: 400 .875rem/1.6 var(--font-ui); color: var(--text-2); }
.toc summary { cursor: pointer; padding: 8px 0; font-weight: 700; color: var(--text); }
.toc ol { margin: 4px 0 0; padding-left: 1.4em; columns: 2 280px; column-gap: 32px; }
.toc li { break-inside: avoid; margin: 0 0 4px; }
.toc a { color: var(--text); text-decoration: underline; text-decoration-color: var(--border-strong); text-underline-offset: 2px; }
.toc a:hover { color: var(--acc-text); }
.toc span { color: var(--text-3); white-space: nowrap; }

/* ---------- noscript / static fallback ---------- */
.noscript { max-width: var(--col); margin: 24px auto; padding: 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }

/* ---------- related-modules footer (bp-more) ---------- */
.bp-more {
  box-sizing: border-box; max-width: calc(var(--side) + var(--col) + 72px); margin: 8px auto 0;
  padding: 20px 16px calc(var(--bar-h) + 36px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border); color: var(--text-3); font: 400 .8125rem/1.8 var(--font-ui);
}
.bp-more p { margin: 0 0 6px; }
.bp-more b { font-weight: 700; color: var(--text-2); }
.bp-more a { color: var(--text-2); text-decoration: underline; text-decoration-color: var(--border-strong); text-underline-offset: 2px; }
.bp-more a:hover { color: var(--acc-text); }
.bp-more [aria-current] { font-weight: 700; color: var(--text); }
@media (min-width: 1100px) { .bp-more { padding-bottom: 32px; } }

@media print {
  .hdr, .bar, .controls, .side, .scrim, .drawer, .sheet, .bp-more, .toc, .hint, .award, .confetti, .bg { display: none !important; }
  .shell { padding: 0; display: block; }
  .card { box-shadow: none; }
}
