/* =============================================================================
   Specimen — a revision checklist that borrows the vernacular of the material
   it covers: a stained slide and a marked exam booklet.

   Colour carries two things and nothing else. Hue says which subject; depth of
   stain says how often the papers asked it. Green is reserved for done and rust
   for going cold, and neither is ever reused for weight. Colour is never the
   only signal — a tier always carries its word, a subject always its name.
   ========================================================================== */

:root {
  color-scheme: light dark;

  /* slide glass — deliberately cool, never cream */
  --glass:    #e7eaf0;
  --mount:    #f7f8fb;
  --sunk:     #dce0e9;
  --rule:     #ccd2df;
  --rule-2:   #b6bfd0;

  --ink:      #14171f;
  --ink-2:    #4b5364;
  --ink-3:    #7b8496;

  /* Subject sets the hue, frequency sets the depth. h3 = asked most.
     Four hues, validated all-pairs for CVD and normal-vision separation;
     every mark also carries its subject or tier in words. Defaults to
     the Pathology stain until a subject scope says otherwise. */
  --h3: #6d3bab;
  --h2: #9366cf;
  --h1: #c3a3e6;
  --wash: #efe8f9;
  --stain: #6d3bab;

  /* reserved status */
  --mark:     #118a5f;
  --mark-wash:#dbf0e7;
  --flag:     #b0442b;
  --flag-wash:#f7e3dd;
  /* A star is a pen mark, not a fifth hue: violet, teal, amber and rose are
     spoken for by the subjects, green by "done" and rust by "going cold", and
     every hue left over sits too close to one of them to be told apart (a blue
     measured ΔE 5.0 deutan against the Pathology violet). So starring is
     carried by shape and fill instead — filled glyph against hollow ones. */
  --star:     #14171f;

  --r:        3px;
  --shadow:   0 1px 0 rgb(20 23 31 / 0.04), 0 1px 3px rgb(20 23 31 / 0.05);

  --display: Archivo, "Helvetica Neue", Helvetica, Arial, sans-serif;
  --sans:    "IBM Plex Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono:    "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --glass:  #101219;
    --mount:  #171a23;
    --sunk:   #1d212c;
    --rule:   #282e3c;
    --rule-2: #3a4356;

    --ink:    #e9ecf4;
    --ink-2:  #a4adc0;
    --ink-3:  #707a8d;

    --h3: #9b70da;
    --h2: #7a55b0;
    --h1: #5d4186;
    --wash: #241d38;
    --stain: #9b70da;

    --mark:   #35b285;
    --mark-wash: #14302a;
    --flag:   #e0836a;
    --flag-wash: #331d17;
    --star:   #e9ecf4;

    --shadow: 0 1px 0 rgb(0 0 0 / 0.3), 0 1px 3px rgb(0 0 0 / 0.35);
  }
}

/* -------------------------------------------------------- subject stains
   Each subject borrows a colour from its own world: haematoxylin violet for
   Pathology, culture-plate teal for Microbiology, amber drug glass for
   Pharmacology, porcelain rose for Dental Materials. Set `data-hue` on any
   container to re-stain its subtree; body carries the current subject so the
   whole page follows what you are revising. */
[data-hue="pathology"]       { --h3:#6d3bab; --h2:#9366cf; --h1:#c3a3e6; --wash:#efe8f9; --stain:#6d3bab; }
[data-hue="microbiology"]    { --h3:#0c84a3; --h2:#3ba7c0; --h1:#94cfdd; --wash:#e3f2f6; --stain:#0c84a3; }
[data-hue="pharmacology"]    { --h3:#9a6a10; --h2:#c0912c; --h1:#e4c583; --wash:#f6edda; --stain:#9a6a10; }
[data-hue="dental-materials"]{ --h3:#c62f6d; --h2:#dd6d95; --h1:#f1aec5; --wash:#fae6ed; --stain:#c62f6d; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) [data-hue="pathology"],
  :root:not([data-theme="light"])[data-hue="pathology"]        { --h3:#9b70da; --h2:#7a55b0; --h1:#5d4186; --wash:#241d38; --stain:#9b70da; }
  :root:not([data-theme="light"]) [data-hue="microbiology"],
  :root:not([data-theme="light"])[data-hue="microbiology"]     { --h3:#2aa7ab; --h2:#218488; --h1:#1a6467; --wash:#15292c; --stain:#2aa7ab; }
  :root:not([data-theme="light"]) [data-hue="pharmacology"],
  :root:not([data-theme="light"])[data-hue="pharmacology"]     { --h3:#b3882b; --h2:#8e6b22; --h1:#6b511b; --wash:#2b2413; --stain:#b3882b; }
  :root:not([data-theme="light"]) [data-hue="dental-materials"],
  :root:not([data-theme="light"])[data-hue="dental-materials"] { --h3:#d96a8a; --h2:#ad5069; --h1:#83404f; --wash:#301a21; --stain:#d96a8a; }
}

/* ------------------------------------------------------------------- base */
*, *::before, *::after { box-sizing: border-box; }

/* Panels carry `display` of their own, which would otherwise beat the UA's
   [hidden] rule and leave two views stacked on top of each other. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--glass);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.shell { width: min(100% - 2.5rem, 74rem); margin-inline: auto; }

h1, h2, h3, h4 { font-family: var(--display); font-weight: 600; margin: 0; }

button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

:focus-visible { outline: 2px solid var(--stain); outline-offset: 2px; }

.vh {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip {
  position: absolute; left: -9999px; top: 0; z-index: 30;
  background: var(--stain); color: #fff; padding: 0.6rem 1rem;
}
.skip:focus { left: 0; }

.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* --------------------------------------------------------------- masthead */
.mast {
  background: var(--mount);
  border-bottom: 1px solid var(--rule);
}

.mast-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2rem 4rem;
  align-items: end;
  padding: 2.5rem 0 2rem;
}

.stamp {
  margin: 0 0 0.9rem;
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--ink-3);
  display: flex;
  align-items: center;
  gap: 0.7rem;
}
.stamp i { width: 1.4rem; height: 1px; background: var(--rule-2); }

.mast h1 {
  font-size: clamp(2rem, 1.1rem + 3.4vw, 3.4rem);
  font-weight: 700;
  line-height: 0.98;
  letter-spacing: -0.035em;
  font-stretch: 112%;
}

.lede {
  margin: 0.75rem 0 0;
  max-width: 34ch;
  color: var(--ink-2);
  font-size: 1.02rem;
}

.mast-figure { text-align: right; min-width: 13rem; }

.figure-label {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.figure {
  margin: 0.15rem 0 0;
  font-family: var(--display);
  font-weight: 700;
  font-size: 3.6rem;
  line-height: 1;
  letter-spacing: -0.045em;
  font-variant-numeric: tabular-nums;
  color: var(--ink); /* an all-subject figure, so it takes no subject's colour */
}
.figure-unit { font-size: 1.6rem; margin-left: 0.05em; color: var(--ink-3); }

/* One segment per subject, each as wide as that subject's share of every
   question ever asked, filled as far as it has been covered. The whole paper,
   at a glance, in the order you meet the subjects. */
.cov-track {
  display: flex;
  gap: 2px;
  height: 9px;
  width: 100%;
  margin-top: 0.6rem;
}
.cov-seg {
  background: var(--wash); /* faint tint, so the four subjects read at 0% too */
  border-radius: var(--r);
  overflow: hidden;
  min-width: 2px;
}
.cov-fill {
  display: block;
  height: 100%;
  width: 0;
  background: var(--h3);
  border-radius: var(--r);
  transition: width 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

.cov-key {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.85rem;
  justify-content: flex-end;
  margin: 0.55rem 0 0;
  padding: 0;
  list-style: none;
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--ink-3);
}
.cov-key li { display: flex; align-items: center; gap: 0.3rem; }
.cov-key i {
  width: 8px;
  height: 8px;
  border-radius: 1px;
  background: var(--h3);
  flex: 0 0 auto;
}

.figure-foot { margin: 0.5rem 0 0; font-size: 0.78rem; color: var(--ink-3); }

/* ------------------------------------------------------------------ views */
.views {
  display: flex;
  align-items: stretch;
  gap: 0.15rem;
  border-top: 1px solid var(--rule);
  margin-top: -1px;
}

.view-tab {
  padding: 0.75rem 0.95rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--ink-3);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.view-tab:hover { color: var(--ink); }
.view-tab[aria-current="true"] {
  color: var(--ink);
  border-bottom-color: var(--stain);
}

/* position:relative keeps the visually-hidden label inside the tab strip —
   without it the absolutely-positioned span resolves against the page and
   pushes it a few pixels wide once the strip starts scrolling on a phone. */
.find { margin-left: auto; display: flex; align-items: center; position: relative; }
.find input {
  font: inherit;
  font-size: 0.85rem;
  color: inherit;
  width: 15rem;
  max-width: 40vw;
  padding: 0.42rem 0.7rem;
  background: var(--glass);
  border: 1px solid var(--rule);
  border-radius: var(--r);
}
.find input::placeholder { color: var(--ink-3); }

/* ---------------------------------------------------------------- layout */
main { padding: 2rem 0 5rem; }

.layout {
  display: grid;
  grid-template-columns: 15rem minmax(0, 1fr);
  gap: 2.75rem;
  align-items: start;
}

.rail { position: sticky; top: 1rem; }

.rail-h {
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 0.55rem;
}

.rail-note { margin: 0 0 0.8rem; font-size: 0.8rem; color: var(--ink-3); }

.rail-block { margin-top: 1.75rem; }

.subject-list, .sitting-list { list-style: none; margin: 0; padding: 0; }

.subject-btn {
  width: 100%;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.5rem;
  padding: 0.42rem 0.6rem;
  border-left: 2px solid var(--rule);
  color: var(--ink-2);
  text-align: left;
  font-size: 0.9rem;
}
.subject-swatch {
  width: 9px;
  height: 9px;
  border-radius: 1px;
  background: var(--h3);
  flex: 0 0 auto;
}
.subject-btn:hover { background: var(--mount); color: var(--ink); }
.subject-btn[aria-current="true"] {
  border-left-color: var(--h3);
  background: var(--wash);
  color: var(--ink);
  font-weight: 600;
}
.subject-btn .tally { font-family: var(--mono); font-size: 0.72rem; color: var(--ink-3); }

.rail-stat { display: flex; justify-content: space-between; gap: 1rem; padding: 0.28rem 0; font-size: 0.82rem; color: var(--ink-2); }
.rail-stat b { font-family: var(--mono); font-weight: 500; color: var(--ink); }

.chips { display: flex; flex-wrap: wrap; gap: 0.25rem; margin-bottom: 0.45rem; }
.chips-stack { flex-direction: column; align-items: start; }

.chip {
  border: 1px solid var(--rule);
  border-radius: var(--r);
  padding: 0.16rem 0.5rem;
  font-size: 0.76rem;
  color: var(--ink-2);
}
.chip:hover { border-color: var(--rule-2); color: var(--ink); }
.chip[aria-pressed="true"] {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--mount);
}

.link-btn {
  padding: 0;
  font-size: 0.8rem;
  color: var(--ink-3);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--rule-2);
}
.link-btn:hover { color: var(--stain); }
.link-btn.warn:hover { color: var(--flag); }

.legend-note { margin: 0 0 0.6rem; font-size: 0.76rem; color: var(--ink-3); }
.legend-swatches { display: grid; gap: 0.3rem; }
.legend-row { display: flex; align-items: center; gap: 0.5rem; font-size: 0.76rem; color: var(--ink-2); }
.legend-cell { width: 10px; height: 14px; border-radius: 1px; flex: 0 0 auto; }

/* -------------------------------------------------------------- next up */
.nextup {
  background: var(--mount);
  border: 1px solid var(--rule);
  border-left: 2px solid var(--stain);
  border-radius: var(--r);
  padding: 1.05rem 1.25rem 1.15rem;
  margin-bottom: 1.75rem;
  box-shadow: var(--shadow);
}
.nextup h2 { font-size: 0.95rem; }
.nextup .sub { margin: 0.15rem 0 0.9rem; font-size: 0.82rem; color: var(--ink-3); }

.nextup-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.05rem; }
.nextup-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 0.85rem;
  padding: 0.3rem 0;
}
.nextup-row + .nextup-row { border-top: 1px dotted var(--rule); }
.nextup-name { text-align: left; font-size: 0.9rem; color: var(--ink); min-width: 0; }
.nextup-name:hover { color: var(--stain); }
.nextup-asked { font-family: var(--mono); font-size: 0.74rem; color: var(--ink-3); white-space: nowrap; }
.nextup-gain { font-family: var(--mono); font-size: 0.74rem; color: var(--mark); white-space: nowrap; min-width: 3.2rem; text-align: right; }

.nextup-done { margin: 0; font-size: 0.9rem; color: var(--ink-2); }

/* -------------------------------------------------------------- chapters */
.chapter { border-top: 1px solid var(--rule); }
.chapter:last-of-type { border-bottom: 1px solid var(--rule); }

.chapter-head {
  width: 100%;
  display: grid;
  grid-template-columns: 2.1rem minmax(0, 1fr) auto;
  gap: 0.9rem;
  align-items: baseline;
  padding: 0.95rem 0.25rem;
  text-align: left;
}
.chapter-head:hover { background: var(--mount); }

.chapter-idx {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--ink-3);
  letter-spacing: 0.04em;
}
.chapter[data-open="true"] .chapter-idx { color: var(--stain); }

.chapter-name { font-size: 1rem; }
.chapter-blurb { margin: 0.1rem 0 0; font-size: 0.8rem; color: var(--ink-3); }

.chapter-tally {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--ink-3);
  white-space: nowrap;
}

.chapter-head-static { cursor: default; }
.chapter-head-static:hover { background: none; }

.chapter-score { display: grid; justify-items: end; gap: 0.25rem; }
.chapter-bar {
  display: block;
  width: 3.4rem;
  height: 3px;
  border-radius: 2px;
  background: var(--sunk);
  overflow: hidden;
}
.chapter-bar i { display: block; height: 100%; background: var(--mark); }

.chapter-bulk {
  display: block;
  margin: 0 0.25rem 0.6rem auto;
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  color: var(--ink-3);
  border: 1px solid var(--rule);
  border-radius: var(--r);
  padding: 0.16rem 0.5rem;
}
.chapter-bulk:hover { color: var(--ink); border-color: var(--rule-2); }
.chapter-bulk[data-mode="clear"]:hover { color: var(--flag); border-color: var(--flag); }
.chapter[data-open="false"] .chapter-bulk { display: none; }
.chapter[data-open="false"] .chapter-body { display: none; }
.chapter-body { padding-bottom: 0.5rem; }

.chapter-void { margin: 0; padding: 0 0.25rem 1rem 3rem; font-size: 0.83rem; color: var(--ink-3); }

/* ----------------------------------------------------------------- topic */
.topic {
  display: grid;
  grid-template-columns: 2.1rem minmax(0, 1fr) 1.5rem auto;
  gap: 0.9rem;
  align-items: start;
  padding: 0.5rem 0.25rem;
  border-top: 1px dotted var(--rule);
}
.topic[data-status="done"] { background: var(--mark-wash); }
.topic[data-starred="true"] { box-shadow: inset 2px 0 0 var(--star); }

/* --------------------------------------------------- star: one last pass */
.star {
  width: 1.5rem;
  height: 1.5rem;
  margin-top: -0.05rem;
  padding: 0.2rem;
  color: var(--rule-2);
  border-radius: var(--r);
  line-height: 0;
}
.star svg { width: 100%; height: 100%; }
.star:hover { color: var(--star); background: var(--mount); }
.star[aria-pressed="true"] { color: var(--star); }
.star[aria-pressed="false"] svg path { fill: none; }

.tick {
  width: 1.15rem;
  height: 1.15rem;
  margin: 0.1rem 0 0 0.45rem;
  border: 1.5px solid var(--rule-2);
  border-radius: var(--r);
  display: grid;
  place-items: center;
  color: transparent;
  flex: 0 0 auto;
}
.tick:hover { border-color: var(--stain); }
.tick svg { width: 0.75rem; height: 0.75rem; }
.topic[data-status="revising"] .tick { border-color: var(--stain); color: var(--stain); }
.topic[data-status="done"] .tick { border-color: var(--mark); background: var(--mark); color: #fff; }

.topic-body { min-width: 0; }

.topic-name {
  text-align: left;
  font-size: 0.93rem;
  line-height: 1.35;
  color: var(--ink);
  padding: 0;
}
.topic-name:hover { color: var(--stain); }
.topic[data-status="done"] .topic-name { color: var(--ink-2); }

.topic-tags {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem 0.6rem;
  margin-top: 0.2rem;
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--ink-3);
}

.tier {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--ink-2);
}
.tier::before {
  content: "";
  width: 7px;
  height: 12px;
  border-radius: 1px;
  background: var(--h1);
}
.tier[data-tier="HIGH"]::before   { background: var(--h3); }
.tier[data-tier="MEDIUM"]::before { background: var(--h2); }

.stale-tag { color: var(--flag); }

/* ------------------------------------------------- the spine (signature) */
.spine {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 1px;
  width: 7.5rem;
  height: 1.35rem;
  margin-top: 0.15rem;
  background: var(--sunk);
  padding: 1px;
  border-radius: 2px;
}

.spine-cell { background: var(--mount); border-radius: 1px; }
.spine-cell[data-mark="5"] { background: var(--sunk); }   /* five-year footing */
.spine-cell[data-ink="1"] { background: var(--h1); }
.spine-cell[data-ink="2"] { background: var(--h2); }
.spine-cell[data-ink="3"] { background: var(--h3); }

.spine-wrap { display: grid; justify-items: end; gap: 0.15rem; }
.spine-axis {
  display: flex;
  justify-content: space-between;
  width: 7.5rem;
  font-family: var(--mono);
  font-size: 0.6rem;
  color: var(--ink-3);
}

/* ---------------------------------------------------------------- detail */
.detail {
  grid-column: 2 / -1;
  padding: 0.6rem 0 0.9rem;
  border-top: 1px dotted var(--rule);
  margin-top: 0.55rem;
}

.detail-h {
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 0.45rem;
}

.detail-h2 { margin-top: 1.1rem; }

/* --------------------------------- how it was asked (off the real papers) */
.asked {
  list-style: none;
  margin: 0 0 0.2rem;
  padding: 0;
  display: grid;
  gap: 0.5rem;
}

.ask {
  border-left: 2px solid var(--h2);
  background: var(--wash);
  border-radius: 0 3px 3px 0;
  padding: 0.45rem 0.7rem 0.5rem;
}

.ask-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.7rem;
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.04em;
}

.ask-src {
  border: 0;
  background: none;
  padding: 0;
  font: inherit;
  color: var(--stain);
  cursor: pointer;
  text-align: left;
  border-bottom: 1px solid transparent;
}
.ask-src:hover { border-bottom-color: var(--stain); }

.ask-marks { color: var(--ink-3); white-space: nowrap; }

.ask-text {
  margin: 0.28rem 0 0;
  font-size: 0.86rem;
  line-height: 1.5;
  color: var(--ink);
}

.ask-more {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--ink-3);
  padding-left: 0.15rem;
}

.ask-void { margin: 0; font-size: 0.84rem; color: var(--ink-3); }

/* ------------------------------------------------------ your own notes */
.note-box {
  width: 100%;
  resize: vertical;
  font: inherit;
  font-size: 0.84rem;
  line-height: 1.5;
  color: var(--ink);
  background: var(--glass);
  border: 1px solid var(--rule);
  border-radius: var(--r);
  padding: 0.4rem 0.55rem;
}
.note-box:focus-visible { border-color: var(--stain); outline: none; }
.note-box::placeholder { color: var(--ink-3); }

.note-tag { color: var(--ink-2); }

/* why a search result surfaced when its own name never says the word */
.result-why {
  grid-column: 2 / -1;
  margin: 0.3rem 0 0;
  padding-left: 0.6rem;
  border-left: 2px solid var(--h2);
  font-size: 0.8rem;
  line-height: 1.45;
  color: var(--ink-2);
}
.result-why-src {
  display: block;
  font-family: var(--mono);
  font-size: 0.66rem;
  color: var(--ink-3);
  margin-bottom: 0.1rem;
}

.asked-tag { color: var(--stain); }

.angles { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.15rem; }
.angle {
  display: grid;
  grid-template-columns: 3.2rem 6rem minmax(0, 1fr);
  gap: 0.7rem;
  font-size: 0.82rem;
  color: var(--ink-2);
  padding: 0.14rem 0;
  border-bottom: 1px dotted var(--rule);
}
.angle-y { font-family: var(--mono); color: var(--ink); }
.angle-s { font-family: var(--mono); font-size: 0.76rem; color: var(--ink-3); }
.angle-n { color: var(--ink-2); }

/* ---------------------------------------------------------------- papers */
.sitting-btn {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.5rem;
  align-items: baseline;
  padding: 0.34rem 0.6rem;
  border-left: 2px solid var(--rule);
  text-align: left;
  font-size: 0.85rem;
  color: var(--ink-2);
}
.sitting-btn:hover { background: var(--mount); color: var(--ink); }
.sitting-btn[aria-current="true"] {
  border-left-color: var(--stain);
  background: var(--mount);
  color: var(--ink);
  font-weight: 600;
}
.sitting-btn .tally { font-family: var(--mono); font-size: 0.72rem; color: var(--ink-3); }

.paper-head { border-bottom: 1px solid var(--rule); padding-bottom: 1rem; margin-bottom: 1.25rem; }
.paper-head h2 { font-size: 1.6rem; letter-spacing: -0.02em; }
.paper-head p { margin: 0.35rem 0 0; color: var(--ink-2); font-size: 0.88rem; }

.paper-subject { margin-bottom: 1.5rem; }
.paper-subject h3 {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--h3);
  padding-bottom: 0.4rem;
  border-bottom: 2px solid var(--h3);
  margin-bottom: 0.3rem;
}

.paper-q {
  display: grid;
  grid-template-columns: 1.6rem minmax(0, 1fr) auto;
  gap: 0.8rem;
  align-items: baseline;
  padding: 0.36rem 0;
  border-bottom: 1px dotted var(--rule);
  font-size: 0.9rem;
}
.paper-q .qn { font-family: var(--mono); font-size: 0.75rem; color: var(--ink-3); }
.paper-q .qmeta { font-family: var(--mono); font-size: 0.72rem; color: var(--ink-3); white-space: nowrap; }
.paper-q .qnote { font-style: italic; color: var(--ink-3); }
.paper-q[data-status="done"] .qname { color: var(--ink-3); }

/* ------------------------------------------------ a real transcribed paper */
.rail-group {
  font-family: var(--mono);
  font-size: 0.64rem;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin: 0.9rem 0 0.3rem;
  padding-left: 0.6rem;
}
.rail-group:first-child { margin-top: 0; }

.paper-kicker {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--h3);
  margin: 0 0 0.35rem;
}

.paper-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 1.1rem;
  font-family: var(--mono);
  font-size: 0.74rem;
  color: var(--ink-3);
  margin: 0.45rem 0 0;
}

.paper-note { font-size: 0.8rem; color: var(--ink-3); font-style: italic; }
.paper-warn {
  font-size: 0.82rem;
  color: var(--flag);
  background: var(--flag-wash);
  border-radius: var(--r);
  padding: 0.5rem 0.7rem;
  margin-top: 0.6rem;
}

.paper-subject h3 .part-marks {
  margin-left: auto;
  font-family: var(--mono);
  color: var(--ink-3);
  letter-spacing: 0;
  text-transform: none;
}

.paper-q.real {
  grid-template-columns: 2.2rem minmax(0, 1fr) 2.2rem;
  align-items: start;
  padding: 0.55rem 0;
}
.paper-q.real .qtext { display: block; line-height: 1.45; }
.paper-q.real .qmeta {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--ink-2);
  text-align: right;
}
.paper-q.real[data-status="done"] { background: var(--mark-wash); }

.qtopics { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-top: 0.35rem; }
.qtopic {
  font-family: var(--mono);
  font-size: 0.68rem;
  border: 1px solid var(--rule-2);
  border-radius: 99px;
  padding: 0.08rem 0.5rem;
  color: var(--ink-3);
  text-align: left;
}
.qtopic:hover { border-color: var(--h3); color: var(--h3); }
.qtopic[data-status="revising"] { border-color: var(--h3); color: var(--h3); }
.qtopic[data-status="done"] {
  background: var(--mark);
  border-color: var(--mark);
  color: #fff;
}

/* ----------------------------------------------------------------- drill */
.drill { max-width: 44rem; margin: 0 auto; }

.drill-bar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--ink-3);
  margin-bottom: 0.6rem;
}

.card {
  background: var(--mount);
  border: 1px solid var(--rule);
  border-radius: var(--r);
  padding: 2.25rem 2rem;
  box-shadow: var(--shadow);
  min-height: 19rem;
  display: flex;
  flex-direction: column;
}

.card-eyebrow {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin: 0 0 0.7rem;
}

.card-q {
  font-family: var(--display);
  font-size: clamp(1.3rem, 1rem + 1.4vw, 1.85rem);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin: 0;
}

.card-tags { display: flex; flex-wrap: wrap; gap: 0.5rem 0.9rem; align-items: center; margin-top: 0.85rem; font-family: var(--mono); font-size: 0.74rem; color: var(--ink-3); }

.card-prompt { margin: 1.4rem 0 0; color: var(--ink-2); font-size: 0.92rem; }

.card-reveal { margin-top: 1.3rem; border-top: 1px solid var(--rule); padding-top: 1rem; }

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: auto;
  padding-top: 1.5rem;
}

.btn {
  border: 1px solid var(--rule-2);
  border-radius: var(--r);
  padding: 0.5rem 0.95rem;
  font-size: 0.87rem;
  font-weight: 500;
  color: var(--ink);
  background: var(--glass);
}
.btn:hover { border-color: var(--ink-3); }
.btn kbd {
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--ink-3);
  margin-left: 0.4rem;
}
.btn-solid { background: var(--stain); border-color: var(--stain); color: #fff; }
.btn-solid:hover { filter: brightness(1.08); }
.btn-solid kbd { color: rgb(255 255 255 / 0.65); }
.btn-mark { border-color: var(--mark); color: var(--mark); }
.btn-mark:hover { background: var(--mark-wash); }

/* ------------------------------------------------------------------ plan */
.plan { max-width: 52rem; }

.plan-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  background: var(--rule);
  border: 1px solid var(--rule);
  border-radius: var(--r);
  overflow: hidden;
  margin-bottom: 2rem;
}

.plan-cell { background: var(--mount); padding: 1.1rem 1.15rem; }
.plan-cell .k {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin: 0 0 0.35rem;
}
.plan-cell .v {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.9rem;
  line-height: 1;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  margin: 0;
}
.plan-cell .n { margin: 0.3rem 0 0; font-size: 0.78rem; color: var(--ink-3); }

.date-row { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; margin-bottom: 1.75rem; }
.date-row label { font-size: 0.88rem; color: var(--ink-2); }
.date-row input {
  font: inherit;
  font-family: var(--mono);
  font-size: 0.85rem;
  color: inherit;
  padding: 0.4rem 0.6rem;
  background: var(--mount);
  border: 1px solid var(--rule-2);
  border-radius: var(--r);
}

.plan-h { font-size: 1.05rem; margin-bottom: 0.3rem; }
.plan-sub { margin: 0 0 0.9rem; font-size: 0.85rem; color: var(--ink-3); }

.bars { display: grid; gap: 0.55rem; margin-bottom: 2rem; }
.bar-row { display: grid; grid-template-columns: 8.5rem minmax(0, 1fr) 3.4rem; gap: 0.75rem; align-items: center; font-size: 0.85rem; }
.bar-track { height: 8px; background: var(--wash); border-radius: var(--r); overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--h3); border-radius: var(--r); }
.bar-val { font-family: var(--mono); font-size: 0.76rem; color: var(--ink-2); text-align: right; }

.stale-list { list-style: none; margin: 0; padding: 0; }
.stale-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 0.8rem;
  align-items: baseline;
  padding: 0.4rem 0;
  border-bottom: 1px dotted var(--rule);
  font-size: 0.88rem;
}
.stale-when { font-family: var(--mono); font-size: 0.74rem; color: var(--flag); white-space: nowrap; }

.plan-none { margin: 0; font-size: 0.88rem; color: var(--ink-3); }

@media (min-width: 58rem) {
  .plan-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* ---------------------------------------------------------------- scored */
/* A paper already sat, read back against the checklist. Green says the list
   had it, rust says it did not — the same two colours the rest of the app
   reserves for done and going cold, used here for the same kind of fact. */
.scored { max-width: 52rem; }

.scored-head { margin-bottom: 2rem; }
.scored-figure {
  font-family: var(--display);
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  text-wrap: balance;
  margin: 0 0 0.4rem;
}
.scored-lede { margin: 0 0 1.1rem; color: var(--ink-2); max-width: 46ch; }

.ledger { display: grid; gap: 0.55rem; }
.ledger-strip {
  display: flex;
  gap: 1px;
  height: 13px;
  background: var(--rule);
  padding: 1px;
  border-radius: 2px;
  overflow: hidden;
}
.ledger-seg { min-width: 2px; }
.ledger-seg[data-verdict="on"] { background: var(--mark); }
.ledger-seg[data-verdict="off"] { background: var(--flag); }
.ledger-seg[data-verdict="partly"] { background: var(--rule-2); }

.ledger-key {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.2rem;
  margin: 0;
  padding: 0;
  list-style: none;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--ink-2);
}
.ledger-key li { display: flex; align-items: center; gap: 0.4rem; }
.ledger-sw { width: 9px; height: 13px; border-radius: 1px; flex: none; }
.ledger-sw[data-verdict="on"] { background: var(--mark); }
.ledger-sw[data-verdict="off"] { background: var(--flag); }
.ledger-sw[data-verdict="partly"] { background: var(--rule-2); }

.scored-parts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  gap: 1px;
  background: var(--rule);
  border: 1px solid var(--rule);
  border-radius: var(--r);
  overflow: hidden;
  margin-bottom: 2rem;
}
.scored-part { background: var(--mount); padding: 1.1rem 1.15rem; }
.scored-part .rail-h { color: var(--h3); margin-bottom: 0.35rem; }
.scored-part-figure {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.9rem;
  line-height: 1;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  margin: 0;
}
.scored-part-note { margin: 0.3rem 0 0; font-size: 0.78rem; color: var(--ink-3); }

.scored-block { margin-bottom: 2.25rem; }
.scored-h {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  font-size: 1.05rem;
  margin: 0 0 0.5rem;
}
.scored-h .part-marks {
  font-family: var(--mono);
  font-size: 0.74rem;
  font-weight: 400;
  color: var(--ink-3);
}
.scored-sub { margin: 0 0 0.9rem; font-size: 0.85rem; color: var(--ink-3); max-width: 60ch; }

/* where the marks came from — depth of stain is the tier, as everywhere else */
.tier-strip {
  display: flex;
  gap: 1px;
  height: 22px;
  background: var(--rule);
  padding: 1px;
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 0.7rem;
}
.tier-strip span { min-width: 2px; }
.tier-sw { width: 9px; height: 12px; border-radius: 1px; flex: none; }
.tier-strip [data-band="HIGH"],   .tier-sw[data-band="HIGH"]   { background: var(--h3); }
.tier-strip [data-band="MEDIUM"], .tier-sw[data-band="MEDIUM"] { background: var(--h2); }
.tier-strip [data-band="LOW"],    .tier-sw[data-band="LOW"]    { background: var(--h1); }
.tier-strip [data-band="PARTLY"], .tier-sw[data-band="PARTLY"] { background: var(--rule-2); }
.tier-strip [data-band="OFF"],    .tier-sw[data-band="OFF"]    { background: var(--flag); }

.tier-key {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
  gap: 0.4rem 1.2rem;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.82rem;
  color: var(--ink-2);
}
.tier-key li { display: flex; align-items: baseline; gap: 0.45rem; }
.tier-key b { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* question by question */
.scored-qs { border-top: 1px solid var(--rule); margin-bottom: 0.75rem; }
.scored-q {
  display: grid;
  grid-template-columns: 3.1rem minmax(0, 1fr) auto;
  gap: 0.3rem 0.85rem;
  padding: 0.8rem 0;
  border-bottom: 1px solid var(--rule);
  align-items: baseline;
}
.scored-q[data-verdict="off"] {
  background: linear-gradient(to right, var(--flag-wash), transparent 60%);
}

.scored-n {
  font-family: var(--mono);
  font-size: 0.74rem;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}
.scored-n b { display: block; color: var(--ink); font-size: 0.92rem; }

.scored-body { display: grid; gap: 0.4rem; min-width: 0; }
.scored-text { margin: 0; line-height: 1.45; }
.scored-skip { color: var(--ink-3); }
.scored-meta {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--ink-3);
}
.scored-note {
  margin: 0;
  font-size: 0.8rem;
  color: var(--ink-3);
  border-left: 2px solid var(--rule-2);
  padding-left: 0.6rem;
}

.verdict {
  justify-self: end;
  font-family: var(--mono);
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.18rem 0.45rem;
  border-radius: 2px;
  white-space: nowrap;
}
.verdict[data-verdict="on"] { color: var(--mark); background: var(--mark-wash); }
.verdict[data-verdict="off"] { color: var(--flag); background: var(--flag-wash); }
.verdict[data-verdict="partly"] { color: var(--ink-2); background: var(--sunk); }

/* what it exposed */
.gap-list { border-top: 1px solid var(--rule); }
.gap {
  display: grid;
  grid-template-columns: 5rem minmax(0, 1fr);
  gap: 0.2rem 0.85rem;
  padding: 0.8rem 0;
  border-bottom: 1px solid var(--rule);
}
.gap-cost {
  font-family: var(--mono);
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--flag);
}
.gap h4 { margin: 0; font-size: 0.95rem; }
.gap p { margin: 0.25rem 0 0; font-size: 0.85rem; color: var(--ink-2); }

/* the other side of the ledger */
.noshow {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
.noshow li {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: var(--ink-2);
  background: var(--mount);
  border: 1px solid var(--rule-2);
  border-left: 3px solid var(--h3);
  border-radius: 2px;
  padding: 0.22rem 0.55rem;
}
.noshow b {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--h3);
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------- search */
.result-group { margin-bottom: 1.75rem; }
.result-group h3 {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--ink-3);
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 0.2rem;
}

.void { color: var(--ink-3); padding: 3rem 0; text-align: center; font-size: 0.92rem; }

/* ---------------------------------------------------------------- footer */
.foot {
  border-top: 1px solid var(--rule);
  background: var(--mount);
  padding: 2rem 0 4rem;
  font-size: 0.82rem;
  color: var(--ink-3);
}
.foot p { margin: 0 0 0.35rem; }
.foot-rule { font-family: var(--mono); font-size: 0.75rem; }

.foot-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr));
  gap: 1.5rem 3rem;
  margin-top: 1.5rem;
}
.foot summary { cursor: pointer; color: var(--ink-2); }
.foot ul { margin: 0.6rem 0 0; padding-left: 1.05rem; }
.foot li { margin-bottom: 0.35rem; }
.foot .muted { margin-top: 0.6rem; }

.foot textarea {
  width: 100%;
  margin-top: 0.5rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  padding: 0.55rem;
  border: 1px solid var(--rule);
  border-radius: var(--r);
  background: var(--glass);
  color: var(--ink-2);
  resize: vertical;
}

.foot-actions { display: flex; flex-wrap: wrap; gap: 0.9rem; align-items: center; margin-top: 0.55rem; }
.say { color: var(--mark); font-size: 0.78rem; }

/* ----------------------------------------------------------- responsive */
@media (max-width: 60rem) {
  .layout { grid-template-columns: 1fr; gap: 1.5rem; }
  .rail { position: static; }
  .subject-list { display: flex; flex-wrap: wrap; gap: 0.25rem; }
  .subject-btn { width: auto; border-left: 0; border-bottom: 2px solid var(--rule); }
  .subject-btn[aria-current="true"] { border-left: 0; border-bottom-color: var(--stain); }
  .sitting-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr)); gap: 0.15rem; }
}

@media (max-width: 46rem) {
  .mast-grid { grid-template-columns: 1fr; gap: 1.5rem; padding: 1.75rem 0 1.5rem; }
  .mast-figure { text-align: left; }
  .figure-label { margin-left: 0; }
  .views { overflow-x: auto; }
  .find { margin-left: 0; }
  .find input { width: 9rem; }
  .topic { grid-template-columns: 1.9rem minmax(0, 1fr) 1.4rem; gap: 0.5rem; }
  .chapter-head { grid-template-columns: 1.9rem minmax(0, 1fr); }
  .spine-wrap { grid-column: 2 / -1; justify-items: start; margin-top: 0.35rem; }
  .spine, .spine-axis { width: 100%; max-width: 14rem; }
  .chapter-score { grid-column: 2; justify-items: start; }
  .scored-q { grid-template-columns: 3.1rem minmax(0, 1fr); }
  .scored-q .verdict { grid-column: 2; justify-self: start; }
  .gap { grid-template-columns: minmax(0, 1fr); }
  .angle { grid-template-columns: 3rem minmax(0, 1fr); }
  .angle-n { grid-column: 2; }
  .card { padding: 1.5rem 1.25rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* -------------------------------------------------------------- printing */
@media print {
  .views, .rail, .foot, .skip, .nextup, .mast-figure { display: none; }
  body { background: #fff; color: #000; font-size: 10pt; }
  .layout { grid-template-columns: 1fr; }
  .chapter[data-open="false"] .chapter-body { display: block; }
  .topic { break-inside: avoid; }
  .tick { border-color: #000; }
  .ask { background: none; border-left-color: #000; break-inside: avoid; }
  .ask-src { color: #000; }
}
