/* Tech+ Study Lab
   Layout: a left sidebar on laptops and wider, a top bar on tablets, bottom tabs on phones.
   At 1536px and up the extra width becomes more panes, never longer lines.
   Direction "Marked Textbook": Bitter for headings and question stems, Atkinson Hyperlegible Next for text,
   Atkinson Hyperlegible Mono for every technical token. Petrol blue does the work; marker yellow means
   "key term" or "flagged", never "you are here". */
:root {
  --bg: #F6F7F9;
  --surface: #FFFFFF;
  --surface2: #EEF1F5;
  --ink: #141A26;
  --mute: #4C5566;
  --rule: #BDC4CF;
  --rule-soft: #DCE1E8;
  --action: #0B4F6C;
  --action-hover: #083D54;
  --on-action: #FFFFFF;
  --tint: #E3EEF3;
  --mark: #FFE45C;
  --on-mark: #141A26;
  --ok: #116B3F;
  --ok-bg: #DCF1E4;
  --bad: #B3261E;
  --bad-bg: #FBE5E3;
  --warn-bg: #FFF4C2;
  --navbg: #0B4F6C;
  --navink: #FFFFFF;
  --navmute: #CFE3EC;
  --navact: #FFFFFF;
  --navonact: #141A26;
  --heat0: #FFFFFF;
  --heat1: #F9D9D5;
  --heat2: #EE9C92;
  --heat3: #C8473B;
  --heat4: #8C1D16;
  --on-heat-dark: #FFFFFF;
  --chart: #0B4F6C;
  --grid: #DCE1E8;
  --focus: #0B4F6C;

  --head: "Bitter", "Rockwell", "Georgia", serif;
  --body: "Atkinson Hyperlegible Next", "Atkinson Hyperlegible", "Verdana", "Segoe UI", sans-serif;
  --mono: "Atkinson Hyperlegible Mono", "Cascadia Mono", "Consolas", monospace;

  --r: 3px;
  --sidebar: clamp(216px, 11.5vw, 296px);
  --rail: clamp(280px, 17vw, 420px);
  --pad: clamp(16px, 1.7vw, 40px);
  --gap: clamp(14px, 1.3vw, 28px);
  --fs: clamp(16px, 14.5px + 0.2vw, 20px);
  --fs-stem: clamp(20px, 17px + 0.6vw, 32px);
  --measure: 68ch;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #11151C; --surface: #181D26; --surface2: #212733; --ink: #E8EBF0; --mute: #A5ADBB; --rule: #434B59; --rule-soft: #2B3240;
    --action: #7CC7E8; --action-hover: #A2D8F0; --on-action: #11151C; --tint: #1A2E38;
    --mark: #FFE45C; --on-mark: #141A26; --ok: #5FCF95; --ok-bg: #12331F; --bad: #FF8F85; --bad-bg: #3D1A16; --warn-bg: #3A3210;
    --navbg: #0D1117; --navink: #E8EBF0; --navmute: #A5ADBB; --navact: #7CC7E8; --navonact: #11151C;
    --heat0: #181D26; --heat1: #3B1E1C; --heat2: #6E2C25; --heat3: #B8483C; --heat4: #F08A7E; --on-heat-dark: #11151C;
    --chart: #7CC7E8; --grid: #2B3240; --focus: #7CC7E8;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #11151C; --surface: #181D26; --surface2: #212733; --ink: #E8EBF0; --mute: #A5ADBB; --rule: #434B59; --rule-soft: #2B3240;
  --action: #7CC7E8; --action-hover: #A2D8F0; --on-action: #11151C; --tint: #1A2E38;
  --mark: #FFE45C; --on-mark: #141A26; --ok: #5FCF95; --ok-bg: #12331F; --bad: #FF8F85; --bad-bg: #3D1A16; --warn-bg: #3A3210;
  --navbg: #0D1117; --navink: #E8EBF0; --navmute: #A5ADBB; --navact: #7CC7E8; --navonact: #11151C;
  --heat0: #181D26; --heat1: #3B1E1C; --heat2: #6E2C25; --heat3: #B8483C; --heat4: #F08A7E; --on-heat-dark: #11151C;
  --chart: #7CC7E8; --grid: #2B3240; --focus: #7CC7E8;
  color-scheme: dark;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--body); font-size: var(--fs); line-height: 1.55;
  text-rendering: optimizeLegibility;
}
img, svg { max-width: 100%; }
h1, h2, h3, h4 { font-family: var(--head); font-weight: 700; line-height: 1.2; margin: 0; text-wrap: balance; }
h1 { font-size: clamp(1.6em, 1.3em + 0.8vw, 2.3em); }
h2 { font-size: 1.4em; }
h3 { font-size: 1.15em; }
h4 { font-size: 1em; }
p { margin: 0; }
p + p { margin-top: 0.75em; }
a { color: var(--action); text-underline-offset: 0.18em; }
a:hover { color: var(--action-hover); }
code, .mono, kbd { font-family: var(--mono); font-size: 0.94em; }
code { background: var(--surface2); border: 1px solid var(--rule-soft); border-radius: var(--r); padding: 0 0.25em; overflow-wrap: anywhere; }
mark, .hl { background: var(--mark); color: var(--on-mark); padding: 0 0.15em; border-radius: 1px; }
kbd { border: 1px solid var(--rule); border-bottom-width: 2px; border-radius: var(--r); padding: 0 0.35em; background: var(--surface); font-size: 0.85em; }
strong, b { font-weight: 700; }
hr { border: 0; border-top: 1px solid var(--rule); margin: var(--gap) 0; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
.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; }
.skip { position: absolute; left: -9999px; top: 8px; z-index: 100; background: var(--surface); padding: 8px 12px; border: 2px solid var(--focus); }
.skip:focus { left: 8px; }
.muted { color: var(--mute); }
.small { font-size: 0.86em; }
.tnum { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }

/* ---------- buttons and inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5em;
  min-height: 44px; padding: 0.45em 1em; border: 1px solid var(--ink); border-radius: var(--r);
  background: transparent; color: var(--ink); font: 700 0.95em/1.2 var(--body); cursor: pointer;
  text-decoration: none; white-space: nowrap; transition: background-color 0.12s, color 0.12s, border-color 0.12s;
}
.btn:hover { background: var(--surface2); color: var(--ink); }
.btn.primary { background: var(--action); border-color: var(--action); color: var(--on-action); }
.btn.primary:hover { background: var(--action-hover); border-color: var(--action-hover); color: var(--on-action); }
.btn.quiet { border-color: transparent; text-decoration: underline; text-underline-offset: 0.18em; font-weight: 700; color: var(--action); padding-inline: 0.4em; }
.btn.quiet:hover { background: var(--tint); }
.btn.flag[aria-pressed="true"] { background: var(--mark); border-color: var(--mark); color: var(--on-mark); }
.btn.small { min-height: 36px; padding: 0.3em 0.75em; font-size: 0.86em; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; }
.btn svg { width: 1.1em; height: 1.1em; flex: none; }
.btnrow { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
label { cursor: pointer; }
input[type="text"], input[type="search"], input[type="date"], input[type="number"], select, textarea {
  font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r);
  padding: 0.45em 0.6em; min-height: 44px; max-width: 100%;
}
textarea { min-height: 90px; width: 100%; }
input[type="checkbox"], input[type="radio"] { width: 1.15em; height: 1.15em; accent-color: var(--action); margin: 0; flex: none; }
.field { display: grid; gap: 6px; }
.field > span { font-weight: 700; font-size: 0.92em; }
.check { display: flex; gap: 0.6em; align-items: flex-start; padding: 6px 0; }
.check input { margin-top: 0.25em; }
.seg { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--rule); border-radius: var(--r); overflow: hidden; }
.seg button { font: 700 0.9em/1.2 var(--body); background: var(--surface); color: var(--ink); border: 0; border-right: 1px solid var(--rule); padding: 0.55em 0.9em; min-height: 40px; cursor: pointer; }
.seg button:last-child { border-right: 0; }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--surface); }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--navbg); color: var(--navink);
  display: flex; flex-direction: column; gap: 18px; padding-block: 20px 16px; border-right: 1px solid var(--rule);
}
.brand { display: block; padding: 0 20px; color: var(--navink); text-decoration: none; font-family: var(--head); font-weight: 700; font-size: 1.3em; line-height: 1.1; }
.brand:hover { color: var(--navink); }
.brand small { display: block; font-family: var(--body); font-weight: 400; font-size: 0.6em; color: var(--navmute); margin-top: 6px; line-height: 1.35; }
.navgroup h2 { padding: 0 20px; margin-bottom: 4px; font: 700 0.72em/1.2 var(--mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--navmute); }
.navgroup a { display: flex; justify-content: space-between; gap: 8px; padding: 7px 20px; color: var(--navink); text-decoration: none; font-size: 0.94em; }
.navgroup a:hover { background: color-mix(in srgb, var(--navink) 12%, transparent); color: var(--navink); }
.navgroup a[aria-current="page"] { background: var(--navact); color: var(--navonact); font-weight: 700; }
.navgroup a .count { font-family: var(--mono); font-size: 0.85em; opacity: 0.85; }
.side .foot { margin-top: auto; padding: 0 20px; display: grid; gap: 10px; font-size: 0.8em; color: var(--navmute); }
.side .foot a { color: var(--navink); }
.themesel { display: flex; gap: 6px; align-items: center; }
.themesel select { min-height: 36px; padding: 0.2em 0.4em; background: var(--navbg); color: var(--navink); border-color: var(--navmute); font-size: 0.95em; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar, .tabbar { display: none; }
#view { flex: 1; min-width: 0; }
#view:focus { outline: none; }

.page > * { min-width: 0; }
.field { min-width: 0; }
.field > select, .field > input { min-width: 0; max-width: 100%; }
.page { grid-template-columns: minmax(0, 1fr); padding-block: var(--pad) calc(var(--pad) * 1.5); padding-left: max(var(--pad), env(safe-area-inset-left, 0px)); padding-right: max(var(--pad), env(safe-area-inset-right, 0px)); display: grid; gap: var(--gap); align-content: start; }
.pagehead { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 24px; padding-bottom: 14px; border-bottom: 1px solid var(--rule); }
.pagehead .eyebrow { font: 700 0.78em/1.3 var(--mono); color: var(--mute); letter-spacing: 0.04em; margin-bottom: 6px; }
.pagehead p.lede { color: var(--mute); max-width: var(--measure); margin-top: 6px; }
.notice { font-size: 0.86em; color: var(--mute); }
.banner { border: 1px solid var(--rule); background: var(--warn-bg); padding: 10px 14px; border-radius: var(--r); }

/* panels: hairline sections, not floating cards */
.panel { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r); padding: var(--pad); min-width: 0; }
.panel > h2, .panel > h3 { margin-bottom: 10px; }
.panel.flat { background: transparent; border: 0; padding: 0; }
.cols { display: grid; gap: var(--gap); grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 900px) { .cols.c2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1024px) { .cols.c3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .cols.c4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1536px) { .cols.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .cols.c4 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 2100px) { .cols.c4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.cols.main-rail { grid-template-columns: minmax(0, 1fr); }
@media (min-width: 1280px) { .cols.main-rail { grid-template-columns: minmax(0, 1fr) var(--rail); } }
.span-all { grid-column: 1 / -1; }

.statline { display: flex; flex-wrap: wrap; gap: 8px 28px; }
.stat { display: grid; gap: 2px; }
.stat .v { font-size: 1.6em; font-weight: 700; line-height: 1.1; }
.stat .l { font-size: 0.84em; color: var(--mute); }

/* tables */
.tablewrap { overflow-x: auto; max-width: 100%; }
table { width: 100%; border-collapse: collapse; font-size: 0.94em; font-variant-numeric: tabular-nums; }
caption { text-align: left; font-weight: 700; padding-bottom: 8px; caption-side: top; }
th { font: 700 0.78em/1.25 var(--mono); color: var(--mute); text-align: left; padding: 6px 10px 8px; border-bottom: 1px solid var(--ink); vertical-align: bottom; }
td { padding: 9px 10px; border-bottom: 1px solid var(--rule-soft); vertical-align: top; }
td.n, th.n { text-align: right; white-space: nowrap; }
tr.link-row { cursor: pointer; }
tr.link-row:hover td { background: var(--surface2); }

/* meters and heatmap */
.meter { display: block; height: 10px; background: var(--surface2); border-radius: 2px; min-width: 70px; overflow: hidden; }
.meter > b { display: block; height: 100%; background: var(--heat3); border-radius: 0 2px 2px 0; }
.meter.good > b { background: var(--chart); }
.heat { display: grid; gap: 14px; }
.heat .dom { display: grid; gap: 6px; }
.heat .dom h3 { font: 700 0.8em/1.3 var(--mono); color: var(--mute); }
.heat .cells { display: flex; flex-wrap: wrap; gap: 4px; }
.heat a.cell { display: grid; place-items: center; min-width: 3.9em; min-height: 2.9em; padding: 4px 6px; text-decoration: none; border-radius: 2px; color: var(--ink); background: var(--heat0); border: 1px solid var(--rule); font-variant-numeric: tabular-nums; line-height: 1.15; }
.heat a.cell b { font-size: 0.92em; font-variant-numeric: tabular-nums; }
.heat a.cell span { font-size: 0.72em; }
.heat a.cell.h0 { color: var(--mute); border-style: dashed; }
.heat a.cell.h1 { background: var(--heat1); border-color: var(--heat1); }
.heat a.cell.h2 { background: var(--heat2); border-color: var(--heat2); color: var(--ink); }
.heat a.cell.h3 { background: var(--heat3); border-color: var(--heat3); color: #FFFFFF; }
.heat a.cell.h4 { background: var(--heat4); border-color: var(--heat4); color: var(--on-heat-dark); }
:root[data-theme="dark"] .heat a.cell.h2 { color: var(--ink); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 0.82em; color: var(--mute); align-items: center; }
.legend i { display: inline-block; width: 14px; height: 14px; vertical-align: -2px; margin-right: 6px; border-radius: 2px; }

/* lists of links (hubs, objective lists) */
.linklist { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule); }
.linklist li { border-bottom: 1px solid var(--rule-soft); }
.linklist a { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 4px 14px; align-items: baseline; padding: 10px 4px; color: var(--ink); text-decoration: none; }
.linklist a:hover { background: var(--surface2); }
.linklist .id { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--action); min-width: 2.2em; }
.linklist .sub { grid-column: 2 / -1; color: var(--mute); font-size: 0.86em; }
.linklist .meta { font-size: 0.84em; color: var(--mute); white-space: nowrap; }

/* ---------- article (study notes) ---------- */
.article { max-width: var(--measure); min-width: 0; }
.article section { scroll-margin-top: 80px; padding-top: 18px; }
.article section + section { border-top: 1px solid var(--rule-soft); margin-top: 22px; }
.article h2 { font-size: 1.35em; margin-bottom: 10px; }
.article h3 { margin: 16px 0 8px; }
.article p, .article ul, .article ol { margin: 0 0 0.8em; }
.article ul, .article ol { padding-left: 1.3em; }
.article li + li { margin-top: 0.3em; }
.covers { font: 0.78em/1.4 var(--mono); color: var(--mute); margin-bottom: 10px; }
.callout { border: 1px solid var(--rule); border-radius: var(--r); padding: 10px 14px; margin: 0 0 0.9em; background: var(--surface); }
.callout .t { font: 700 0.76em/1.4 var(--mono); letter-spacing: 0.04em; text-transform: uppercase; display: block; margin-bottom: 4px; color: var(--mute); }
.callout.tip { background: var(--tint); border-color: color-mix(in srgb, var(--action) 35%, var(--rule)); }
.callout.tip .t { color: var(--action); }
.callout.trap { background: var(--bad-bg); border-color: color-mix(in srgb, var(--bad) 45%, var(--rule)); }
.callout.trap .t { color: var(--bad); }
.callout.remember { background: var(--warn-bg); }
.callout.remember .t { color: var(--ink); }
.callout.example { background: var(--surface2); }
.compare { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); margin: 0 0 1em; }
.compare > div { border: 1px solid var(--rule); border-radius: var(--r); padding: 10px 12px; background: var(--surface); }
.compare h4 { font-family: var(--body); font-size: 1em; margin-bottom: 6px; }
.compare ul { margin: 0; padding-left: 1.1em; font-size: 0.94em; }
.steps { counter-reset: s; list-style: none; padding: 0 !important; }
.steps li { counter-increment: s; display: grid; grid-template-columns: 2em minmax(0, 1fr); gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--rule-soft); }
.steps li::before { content: counter(s); font: 700 0.95em/1.6 var(--mono); color: var(--action); }
.datatable { margin: 0 0 1em; }
.datatable table { background: var(--surface); }
pre.code { margin: 0 0 1em; padding: 12px 14px; background: var(--surface2); border: 1px solid var(--rule); border-radius: var(--r); overflow-x: auto; font: 0.92em/1.5 var(--mono); white-space: pre; tab-size: 2; }
.mixups { display: grid; gap: 8px; }
.mixup { display: grid; grid-template-columns: minmax(0, 1fr); gap: 2px; padding: 10px 0; border-bottom: 1px solid var(--rule-soft); }
.mixup .pair { font-weight: 700; }
.mixup .pair span { color: var(--mute); font-weight: 400; padding: 0 0.35em; }
.terms { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0; }
.terms dt { font-weight: 700; padding-top: 10px; }
.terms dd { margin: 0; padding-bottom: 10px; border-bottom: 1px solid var(--rule-soft); }

/* study page layout */
.study { display: grid; gap: var(--gap); grid-template-columns: minmax(0, 1fr); align-items: start; }
.study .objnav, .study .rail { min-width: 0; }
.study .objnav { display: none; }
.rail { display: grid; gap: var(--gap); align-content: start; }
.rail .panel { padding: 16px 18px; }
.toc { list-style: none; padding: 0; margin: 0; font-size: 0.92em; }
.toc a { display: block; padding: 5px 0; color: var(--ink); text-decoration: none; border-bottom: 1px solid var(--rule-soft); }
.toc a:hover { color: var(--action); }
@media (min-width: 1280px) {
  .study { grid-template-columns: minmax(0, 1fr) var(--rail); }
  .rail { position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow-y: auto; }
}
@media (min-width: 1700px) {
  .study { grid-template-columns: clamp(220px, 12vw, 300px) minmax(0, 1fr) var(--rail); }
  .study .objnav { display: block; position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow-y: auto; }
}
.objnav ol { list-style: none; margin: 0; padding: 0; font-size: 0.88em; }
.objnav h3 { font: 700 0.75em/1.3 var(--mono); color: var(--mute); margin: 12px 0 4px; }
.objnav a { display: grid; grid-template-columns: 2.4em minmax(0, 1fr); gap: 4px; padding: 5px 6px; color: var(--ink); text-decoration: none; border-radius: 2px; }
.objnav a b { color: var(--action); font-variant-numeric: tabular-nums; }
.objnav a:hover { background: var(--surface2); }
.objnav a[aria-current="page"] { background: var(--ink); color: var(--surface); }
.objnav a[aria-current="page"] b { color: var(--surface); }
.studywide { display: grid; gap: var(--gap); grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 2000px) { .studywide { grid-template-columns: minmax(0, var(--measure)) minmax(0, 1fr); } }

.tabs { display: flex; flex-wrap: wrap; gap: 0; border-bottom: 1px solid var(--rule); }
.tabs button { font: 700 0.95em/1.2 var(--body); background: none; border: 0; border-bottom: 3px solid transparent; padding: 10px 14px; color: var(--mute); cursor: pointer; min-height: 44px; }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--ink); }
.tabs button:hover { color: var(--ink); }

/* ---------- figures (photos and diagrams) ---------- */
.figure { margin: 0; display: grid; gap: 8px; min-width: 0; }
.figure .frame { position: relative; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r); overflow: hidden; }
.figure .frame.photo { background: #FFFFFF; }
.figure .frame img { display: block; width: 100%; height: auto; }
.figure .frame.diagram { padding: 12px; color: var(--ink); }
.figure .frame.diagram svg { display: block; width: 100%; height: auto; }
.figure figcaption { font-size: 0.86em; color: var(--mute); display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; }
.figure .credit { font-size: 0.78em; color: var(--mute); }
.hs { position: absolute; transform: translate(-50%, -50%); width: 30px; height: 30px; border-radius: 50%; background: var(--mark); color: var(--on-mark); border: 2px solid #141A26; box-shadow: 0 0 0 2px #FFFFFF; font: 700 15px/1 var(--mono); display: grid; place-items: center; pointer-events: none; }
.gallery { display: grid; gap: var(--gap); grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); }
.gallery .figure .frame { aspect-ratio: 4 / 3; display: grid; place-items: center; }
.gallery .figure .frame img { width: 100%; height: 100%; object-fit: contain; }
.gallery .figure .frame.diagram svg { max-height: 100%; }
.gallery button.figbtn { all: unset; cursor: zoom-in; display: block; }
.gallery button.figbtn:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* diagram theme classes (inline SVGs) */
.dg-line{stroke:var(--ink);fill:none;stroke-width:2}
.dg-thin{stroke:var(--rule);fill:none;stroke-width:1.5}
.dg-dash{stroke:var(--mute);fill:none;stroke-width:2;stroke-dasharray:6 5}
.dg-box{fill:var(--surface);stroke:var(--ink);stroke-width:2}
.dg-box2{fill:var(--surface2);stroke:var(--rule);stroke-width:1.5}
.dg-tint{fill:var(--tint);stroke:var(--action);stroke-width:2}
.dg-accent{stroke:var(--action);fill:none;stroke-width:2.5}
.dg-accent-fill{fill:var(--action);stroke:none}
.dg-on-accent{fill:var(--on-action)}
.dg-mark{fill:var(--mark);stroke:none}
.dg-on-mark{fill:var(--on-mark)}
.dg-ok{fill:var(--ok-bg);stroke:var(--ok);stroke-width:2}
.dg-bad{fill:var(--bad-bg);stroke:var(--bad);stroke-width:2}
.dg-ok-text{fill:var(--ok)}
.dg-bad-text{fill:var(--bad)}
.dg-text{fill:var(--ink);font-family:var(--body)}
.dg-mute{fill:var(--mute);font-family:var(--body)}
.dg-mono{fill:var(--ink);font-family:var(--mono)}
.dg-bold{font-weight:700}
.dg-arrowhead{fill:var(--ink);stroke:none}
.dg-arrowhead-accent{fill:var(--action);stroke:none}

/* ---------- mock UI exhibits ---------- */
.ex { min-width: 0; }
.ex-code { margin: 0; }
.ex-window { border: 1px solid var(--rule); border-radius: 6px; background: var(--surface); overflow: hidden; font-size: 0.92em; max-width: 560px; }
.ex-window .tb { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 12px; background: var(--surface2); border-bottom: 1px solid var(--rule); font-weight: 700; }
.ex-window .tb .dots { display: flex; gap: 6px; } .ex-window .tb .dots i { width: 10px; height: 10px; border-radius: 50%; border: 1px solid var(--mute); display: block; }
.ex-window .wtabs { display: flex; gap: 2px; padding: 8px 12px 0; border-bottom: 1px solid var(--rule); }
.ex-window .wtabs span { padding: 5px 10px; border: 1px solid transparent; border-bottom: 0; font-size: 0.92em; color: var(--mute); }
.ex-window .wtabs span.on { border-color: var(--rule); background: var(--surface); color: var(--ink); border-radius: 4px 4px 0 0; margin-bottom: -1px; }
.ex-window dl { margin: 0; padding: 10px 12px; display: grid; grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.4fr); gap: 6px 14px; }
.ex-window dt { color: var(--mute); }
.ex-window dd { margin: 0; overflow-wrap: anywhere; }
.ex-window .wbtns { display: flex; justify-content: flex-end; gap: 8px; padding: 0 12px 12px; }
.ex-window .wbtns span { border: 1px solid var(--rule); border-radius: var(--r); padding: 3px 14px; background: var(--surface2); font-size: 0.9em; }
.ex-window .wnote { padding: 0 12px 10px; font-size: 0.86em; color: var(--mute); }
.ex-browser { border: 1px solid var(--rule); border-radius: 6px; overflow: hidden; background: var(--surface); max-width: 620px; font-size: 0.92em; }
.ex-browser .bar { display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: var(--surface2); border-bottom: 1px solid var(--rule); }
.ex-browser .url { flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; background: var(--surface); border: 1px solid var(--rule); border-radius: 16px; padding: 4px 12px; font-family: var(--mono); font-size: 0.9em; overflow-wrap: anywhere; }
.ex-browser .sec { font-family: var(--body); font-size: 0.86em; font-weight: 700; white-space: nowrap; }
.ex-browser .sec.bad { color: var(--bad); }
.ex-browser .sec.ok { color: var(--ok); }
.ex-browser .page { padding: 14px 16px; display: grid; gap: 6px; }
.ex-browser .page h4 { font-family: var(--body); }
.ex-browser .warnpage { padding: 18px 16px; background: var(--bad-bg); display: grid; gap: 6px; }
.ex-browser .warnpage b { color: var(--bad); font-size: 1.1em; }
.ex-email { border: 1px solid var(--rule); border-radius: 6px; background: var(--surface); max-width: 620px; font-size: 0.92em; overflow: hidden; }
.ex-email dl { margin: 0; padding: 10px 14px; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 3px 12px; background: var(--surface2); border-bottom: 1px solid var(--rule); }
.ex-email dt { color: var(--mute); }
.ex-email dd { margin: 0; overflow-wrap: anywhere; }
.ex-email .body { padding: 12px 14px; display: grid; gap: 8px; }
.ex-email .lnk { color: var(--action); text-decoration: underline; font-family: var(--mono); font-size: 0.92em; overflow-wrap: anywhere; }
.ex-email .att { display: inline-flex; gap: 6px; align-items: center; border: 1px solid var(--rule); border-radius: var(--r); padding: 4px 10px; font-family: var(--mono); font-size: 0.88em; width: fit-content; }
.ex-terminal { background: #10141B; color: #E3E8EF; border-radius: 6px; overflow: hidden; max-width: 680px; border: 1px solid var(--rule); }
.ex-terminal .tt { padding: 6px 12px; font-size: 0.8em; color: #A9B3C1; border-bottom: 1px solid #2B3240; }
.ex-terminal pre { margin: 0; padding: 12px 14px; font: 0.9em/1.5 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; }
.ex-table table { background: var(--surface); }
.ex-table th .key { display: inline-block; margin-left: 6px; padding: 0 4px; border: 1px solid var(--ink); border-radius: 2px; font-size: 0.85em; color: var(--ink); }
.ex-table th .key.fk { border-style: dashed; }
.ex-caption { font-size: 0.82em; color: var(--mute); margin-top: 6px; }

/* ---------- sessions (quiz, exam, challenge) ---------- */
body.in-session .side, body.in-session .topbar, body.in-session .tabbar { display: none !important; }
body.in-session .shell { grid-template-columns: minmax(0, 1fr); }
.sbar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; display: flex; flex-wrap: wrap; align-items: center; gap: 8px clamp(10px, 1.6vw, 32px); padding: 10px var(--pad); padding-left: max(var(--pad), env(safe-area-inset-left, 0px)); padding-right: max(var(--pad), env(safe-area-inset-right, 0px)); background: var(--surface); border-bottom: 1px solid var(--rule); }
.sbar .title { font-family: var(--head); font-weight: 700; font-size: 1.05em; }
.sbar .prog { font-family: var(--mono); font-size: 0.92em; color: var(--mute); }
.sbar .sp { flex: 1; }
.sbar .clock { font: 700 1.2em/1 var(--mono); font-variant-numeric: tabular-nums; }
.sbar .lives { font-family: var(--mono); font-weight: 700; }
.strip { display: flex; flex-wrap: wrap; gap: 3px; padding: 8px var(--pad); padding-left: max(var(--pad), env(safe-area-inset-left, 0px)); padding-right: max(var(--pad), env(safe-area-inset-right, 0px)); background: var(--surface); border-bottom: 1px solid var(--rule); }
.strip i { width: clamp(14px, 1.3vw, 22px); height: 8px; border-radius: 2px; background: var(--surface2); border: 1px solid var(--rule); }
.strip i.ok { background: var(--ok); border-color: var(--ok); }
.strip i.bad { background: var(--bad); border-color: var(--bad); }
.strip i.cur { background: var(--ink); border-color: var(--ink); height: 8px; }
.work { display: grid; grid-template-columns: minmax(0, 1fr); min-height: calc(100vh - 60px); }
.work .col { padding: var(--pad); padding-left: max(var(--pad), env(safe-area-inset-left, 0px)); padding-right: max(var(--pad), env(safe-area-inset-right, 0px)); min-width: 0; }
.work .qcol { background: var(--surface); }
.work .xcol { background: var(--surface2); display: none; }
.work .ncol { display: none; border-left: 1px solid var(--rule); background: var(--bg); }
@media (min-width: 1024px) {
  .work.has-nav { grid-template-columns: minmax(0, 1fr) clamp(300px, 24vw, 380px); }
  .work.has-nav .ncol { display: block; }
}
@media (min-width: 1536px) {
  .work.wide2 { grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); }
  .work.wide2.has-nav { grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr) clamp(360px, 17vw, 440px); }
  .work.wide2 .xcol { display: block; border-left: 1px solid var(--rule); }
}
.qcol .inner { max-width: 54em; }
.tagline { font: 700 0.8em/1.3 var(--mono); color: var(--mute); margin-bottom: 10px; display: flex; flex-wrap: wrap; gap: 4px 14px; }
.stem { font-family: var(--head); font-weight: 700; font-size: var(--fs-stem); line-height: 1.25; max-width: 34em; margin: 0 0 18px; text-wrap: pretty; }
.stem code { font-size: 0.82em; font-weight: 400; }
.pickhint { font-size: 0.9em; color: var(--mute); margin: -8px 0 12px; }
.qex { margin-bottom: 18px; }
.qex .figure .frame img { max-height: 46vh; width: auto; max-width: 100%; margin: 0 auto; }
.qex .figure .frame.diagram svg { max-height: 46vh; }
@media (min-width: 768px) and (max-width: 1535px) { .qex .figure .frame img, .qex .figure .frame.diagram svg { max-height: 34vh; } }
.xcol .qex .figure .frame img { max-height: 58vh; }
.xcol .qex .figure .frame.diagram svg { max-height: 58vh; }
.xcol h3 { font: 700 0.8em/1.3 var(--mono); color: var(--mute); margin-bottom: 12px; }
.opts { display: grid; gap: 0; list-style: none; padding: 0; margin: 0; }
.opt { position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 14px; align-items: center; width: 100%; text-align: left; padding: 12px 14px; min-height: 52px; margin-bottom: -1px; background: var(--surface); color: var(--ink); border: 1px solid var(--rule); border-radius: 0; font: inherit; cursor: pointer; }
.opts > :first-child .opt, .opts > .opt:first-child { border-top-left-radius: var(--r); border-top-right-radius: var(--r); }
.opts > :last-child .opt, .opts > .opt:last-child { border-bottom-left-radius: var(--r); border-bottom-right-radius: var(--r); }
.opt:hover { background: var(--surface2); }
.opt .L { font: 700 1em/1 var(--mono); min-width: 1.4em; height: 1.6em; display: grid; place-items: center; border: 1px solid var(--rule); border-radius: 2px; }
.opt .box { width: 1.15em; height: 1.15em; border: 2px solid var(--mute); border-radius: 2px; display: inline-block; margin-right: 6px; vertical-align: -0.15em; }
.opt.sel { border-color: var(--action); background: var(--tint); z-index: 1; }
.opt.sel .L { background: var(--action); color: var(--on-action); border-color: var(--action); }
.opt:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: -2px; z-index: 3; }
.opts[role="group"] .opt .L { border-radius: 4px; }
.opt.strike .txt { text-decoration: line-through; color: var(--mute); }
.opt.is-ok { background: var(--ok-bg); border-color: var(--ok); z-index: 2; }
.opt.is-ok .L { background: var(--ok); color: var(--surface); border-color: var(--ok); }
.opt.is-bad { background: var(--bad-bg); border-color: var(--bad); z-index: 2; }
.opt.is-bad .L { background: var(--bad); color: var(--surface); border-color: var(--bad); }
.opt .tag { font: 700 0.78em/1.2 var(--body); white-space: nowrap; }
.opt.is-ok .tag { color: var(--ok); }
.opt.is-bad .tag { color: var(--bad); }
.opt[disabled] { cursor: default; }
.opt .why { grid-column: 2 / -1; font-size: 0.88em; color: var(--ink); margin-top: -4px; }
.order-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; counter-reset: o; }
.order-list li { display: grid; grid-template-columns: 2em minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 8px 10px; border: 1px solid var(--rule); margin-bottom: -1px; background: var(--surface); }
.order-list li::before { counter-increment: o; content: counter(o); font: 700 1em/1 var(--mono); color: var(--action); }
.order-list li.is-ok { background: var(--ok-bg); border-color: var(--ok); }
.order-list li.is-bad { background: var(--bad-bg); border-color: var(--bad); }
.order-list .mv { display: flex; gap: 4px; }
.order-list .mv button { min-width: 40px; min-height: 40px; border: 1px solid var(--rule); background: var(--surface); color: var(--ink); border-radius: var(--r); cursor: pointer; font: 700 1em/1 var(--mono); }
.order-list .mv button:disabled { opacity: 0.35; cursor: default; }
.order-list .why { grid-column: 2 / -1; font-size: 0.88em; }
.match-grid { display: grid; gap: 0; border-top: 1px solid var(--rule); }
.match-row { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; padding: 10px 0; border-bottom: 1px solid var(--rule-soft); align-items: center; }
@media (min-width: 700px) { .match-row { grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.4fr); gap: 14px; } }
.match-row .left { font-weight: 700; }
.match-row select { width: 100%; }
.match-row.is-ok select { border-color: var(--ok); background: var(--ok-bg); }
.match-row.is-bad select { border-color: var(--bad); background: var(--bad-bg); }
.match-row .why { grid-column: 1 / -1; font-size: 0.88em; }

.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 18px; }
.feedback { margin-top: 18px; border: 1px solid var(--rule); border-radius: var(--r); background: var(--surface); }
.feedback > header { padding: 10px 14px; font-weight: 700; border-bottom: 1px solid var(--rule); }
.feedback.ok > header { background: var(--ok-bg); border-bottom-color: var(--ok); }
.feedback.ok > header .v { color: var(--ok); }
.feedback.bad > header { background: var(--bad-bg); border-bottom-color: var(--bad); }
.feedback.bad > header .v { color: var(--bad); }
.feedback .fb { padding: 14px; display: grid; gap: 12px; }
.feedback .fb p { max-width: var(--measure); }
.feedback .hook { font-size: 0.92em; }
.feedback .hook b.hk { background: var(--mark); color: var(--on-mark); padding: 0 0.3em; border-radius: 2px; margin-right: 6px; font-size: 0.86em; }
.feedback ul.others { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule-soft); }
.feedback ul.others li { display: grid; grid-template-columns: 1.6em minmax(0, 1fr); gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--rule-soft); font-size: 0.94em; }
.feedback ul.others li b { font-family: var(--mono); }
.feedback details summary { cursor: pointer; font-weight: 700; color: var(--action); padding: 4px 0; }
.mobile-next { display: none; }
@media (max-width: 767px) {
  .mobile-next { display: block; position: sticky; bottom: 0; padding: 10px 0 calc(10px + env(safe-area-inset-bottom, 0px)); background: linear-gradient(to bottom, transparent, var(--surface) 30%); }
  .mobile-next .btn { width: 100%; }
  .feedback #next-btn { display: none; }
}
.cols.weakgrid { grid-template-columns: minmax(0, 1fr); }
@media (min-width: 1280px) { .cols.weakgrid { grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); } }
@media (min-width: 2200px) { .cols.weakgrid { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); } }

/* navigator grid */
.ncol h3 { font: 700 0.8em/1.3 var(--mono); color: var(--mute); margin-bottom: 10px; }
.navfilter { margin-bottom: 10px; display: grid; grid-template-columns: repeat(3, minmax(0, auto)); width: 100%; }
.navfilter button { padding: 0.5em 0.55em; white-space: nowrap; font-size: 0.84em; }
@media (min-width: 1024px) { .only-narrow { display: none !important; } }
.navlist { display: none; list-style: none; margin: 16px 0 0; padding: 0; border-top: 1px solid var(--rule); font-size: 0.86em; max-height: 46vh; overflow-y: auto; }
.navlist li button { all: unset; box-sizing: border-box; cursor: pointer; display: grid; grid-template-columns: 2.4em 6.5em minmax(0, 1fr); gap: 8px; width: 100%; padding: 6px 4px; border-bottom: 1px solid var(--rule-soft); }
.navlist li button:hover { background: var(--surface2); }
.navlist li button:focus-visible { outline: 3px solid var(--focus); outline-offset: -3px; }
.navlist li button[aria-current="true"] { background: var(--tint); }
.navlist .n { font-family: var(--mono); font-weight: 700; }
.navlist .st { color: var(--mute); }
.navlist .st.fl { color: var(--ink); font-weight: 700; }
.navlist .tx { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (min-width: 1900px) {
  .work.has-nav { grid-template-columns: minmax(0, 1fr) clamp(520px, 27vw, 720px); }
  .work.wide2.has-nav { grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr) clamp(520px, 24vw, 700px); }
  .navlist { display: block; }
}
.navgrid { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 3px; }
.navgrid button { aspect-ratio: 1; min-height: 28px; display: grid; place-items: center; font: 700 clamp(10px, 0.45vw + 5px, 13px)/1 var(--mono); border: 1px solid var(--rule); border-radius: 2px; background: var(--surface); color: var(--ink); cursor: pointer; padding: 0; position: relative; }
.navgrid button.ans { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.navgrid button.flag { background: var(--mark); color: var(--on-mark); border-color: var(--on-mark); }
.navgrid button.flag.ans::after { content: ""; position: absolute; right: 2px; bottom: 2px; width: 5px; height: 5px; background: var(--on-mark); border-radius: 50%; }
.navgrid button.cur { outline: 3px solid var(--action); outline-offset: 1px; z-index: 1; }
.navgrid button.ok { background: var(--ok-bg); color: var(--ok); border-color: var(--ok); }
.navgrid button.bad { background: var(--bad-bg); color: var(--bad); border-color: var(--bad); }
.navgrid button.dim { opacity: 0.3; }
.navkey { display: grid; gap: 4px; font-size: 0.84em; color: var(--mute); margin-top: 10px; }
.navkey i { display: inline-block; width: 12px; height: 12px; margin-right: 6px; vertical-align: -1px; border: 1px solid var(--rule); border-radius: 2px; }

/* results */
.scoreline { font-size: 1.15em; }
.scoreline .big { font-size: 2.6em; font-weight: 700; line-height: 1; display: block; margin-bottom: 4px; }
.bars { display: grid; gap: 10px; }
.bars .row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; align-items: center; }
.bars .row .track { grid-column: 1 / -1; height: 14px; background: var(--surface2); border-radius: 0 4px 4px 0; overflow: hidden; }
.bars .row .track b { display: block; height: 100%; background: var(--chart); border-radius: 0 4px 4px 0; }
.review-item { border: 1px solid var(--rule); border-radius: var(--r); background: var(--surface); }
.review-item > summary { list-style: none; cursor: pointer; display: grid; grid-template-columns: auto auto minmax(0, 1fr); gap: 10px; padding: 10px 14px; align-items: baseline; }
.review-item > summary::-webkit-details-marker { display: none; }
.review-item .mk { font: 700 0.9em/1 var(--mono); }
.review-item .mk.ok { color: var(--ok); }
.review-item .mk.bad { color: var(--bad); }
.review-item .mk.skip { color: var(--mute); }
.review-item .body { padding: 0 14px 14px; display: grid; gap: 12px; }
.review-list { display: grid; gap: 8px; }

/* flashcards */
.fcwrap { display: grid; gap: var(--gap); grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 1280px) { .fcwrap { grid-template-columns: clamp(240px, 15vw, 320px) minmax(0, 1fr); } }
@media (min-width: 1900px) { .fcwrap { grid-template-columns: clamp(240px, 13vw, 320px) minmax(0, 1fr) clamp(280px, 16vw, 400px); } }
.fcwrap .decklist, .fcwrap .cardlist { min-width: 0; }
.fcwrap .cardlist { display: none; }
@media (min-width: 1900px) { .fcwrap .cardlist { display: block; } }
.card { display: grid; grid-template-columns: minmax(0, 1fr); border: 1px solid var(--rule); border-radius: var(--r); background: var(--surface); min-height: 280px; }
@media (min-width: 1024px) { .card.two { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } .card.two .back { border-left: 1px solid var(--rule); border-top: 0; } }
.card .front, .card .back { padding: clamp(20px, 2vw, 40px); display: grid; align-content: center; gap: 10px; }
.card .back { border-top: 1px solid var(--rule); background: var(--surface2); }
.card .side-l { font: 700 0.75em/1 var(--mono); color: var(--mute); letter-spacing: 0.05em; text-transform: uppercase; }
.card .front .txt { font-family: var(--head); font-weight: 700; font-size: clamp(1.25em, 1em + 0.6vw, 1.9em); line-height: 1.25; }
.card .back .txt { font-size: 1.1em; }
.card .back.hiddenback .txt { color: var(--mute); }
.decks { list-style: none; padding: 0; margin: 0; border-top: 1px solid var(--rule); font-size: 0.92em; }
.decks button { all: unset; box-sizing: border-box; cursor: pointer; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; width: 100%; padding: 8px 6px; border-bottom: 1px solid var(--rule-soft); }
.decks button:hover { background: var(--surface2); }
.decks button[aria-current="true"] { background: var(--ink); color: var(--surface); }
.decks button:focus-visible { outline: 3px solid var(--focus); outline-offset: -3px; }
.decks .c { font-family: var(--mono); font-size: 0.9em; }

/* number lab */
.lab-q { font-family: var(--head); font-weight: 700; font-size: var(--fs-stem); line-height: 1.25; }
.lab-answer { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.lab-answer input { font-family: var(--mono); font-size: 1.2em; min-width: 0; width: min(100%, 16em); }
.placevals { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(2.8em, 1fr); border: 1px solid var(--rule); border-radius: var(--r); overflow-x: auto; max-width: 100%; width: fit-content; }
.placevals div { display: grid; text-align: center; border-right: 1px solid var(--rule-soft); }
.placevals div:last-child { border-right: 0; }
.placevals span { padding: 4px 8px; font: 0.82em/1.3 var(--mono); color: var(--mute); background: var(--surface2); }
.placevals b { padding: 6px 8px; font: 700 1.1em/1.3 var(--mono); }
.placevals b.on { background: var(--mark); color: var(--on-mark); }

/* charts */
.chart { width: 100%; min-width: 0; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid line { stroke: var(--grid); stroke-width: 1; }
.chart .axis text { fill: var(--mute); font: 12px var(--mono); }
.chart .line { fill: none; stroke: var(--chart); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: var(--chart); opacity: 0.1; }
.chart .dot { fill: var(--chart); stroke: var(--surface); stroke-width: 2; }
.chart .ref { stroke: var(--mute); stroke-width: 1; }
.chart .reflabel { fill: var(--mute); font: 12px var(--body); }
.chart .endlabel { fill: var(--ink); font: 700 13px var(--body); }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit:focus { outline: none; }
.chart .hit:focus + .dot, .chart .hit:hover + .dot { stroke: var(--ink); }
.tooltip { position: absolute; pointer-events: none; z-index: 50; background: var(--ink); color: var(--surface); padding: 6px 10px; border-radius: var(--r); font-size: 0.82em; white-space: nowrap; transform: translate(-50%, calc(-100% - 10px)); }
.chartbox { position: relative; }

/* week row */
.week { display: flex; gap: 6px; flex-wrap: wrap; }
.week .d { display: grid; gap: 2px; text-align: center; min-width: 2.6em; }
.week .d i { display: block; height: 28px; border-radius: 2px; border: 1px solid var(--rule); background: var(--surface); }
.week .d.on i { background: var(--chart); border-color: var(--chart); }
.week .d span { font: 0.75em/1.2 var(--mono); color: var(--mute); }

/* dialogs and toasts */
dialog { border: 1px solid var(--rule); border-radius: var(--r); background: var(--surface); color: var(--ink); padding: 0; max-width: min(92vw, 1400px); max-height: 92vh; }
dialog::backdrop { background: rgba(10, 14, 20, 0.6); }
dialog .dhead { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--rule); }
dialog .dbody { padding: 14px; overflow: auto; max-height: calc(92vh - 60px); }
dialog .dbody img { display: block; max-height: 78vh; width: auto; margin: 0 auto; }
dialog .dbody svg { display: block; width: min(1200px, 86vw); height: auto; color: var(--ink); }
dialog.confirm { max-width: 520px; }
dialog.confirm .dbody { display: grid; gap: 14px; }
#toast { position: fixed; left: 50%; bottom: calc(80px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 90; display: grid; gap: 8px; pointer-events: none; }
#toast div { background: var(--ink); color: var(--surface); padding: 10px 16px; border-radius: var(--r); font-size: 0.92em; max-width: 90vw; }

/* empty states */
.empty { border: 1px dashed var(--rule); border-radius: var(--r); padding: var(--pad); display: grid; gap: 10px; justify-items: start; background: var(--surface); }
.empty p { max-width: var(--measure); }

/* filters bar */
.filters { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: end; }
.filters .field { min-width: 0; }
.filters input[type="search"] { width: min(100%, 26em); }

/* acronym grid */
.acrgrid { display: grid; gap: 0 var(--gap); grid-template-columns: minmax(0, 1fr); }
@media (min-width: 1100px) { .acrgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1800px) { .acrgrid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.acr { display: grid; grid-template-columns: minmax(5.5em, auto) minmax(0, 1fr); gap: 2px 14px; padding: 10px 0; border-bottom: 1px solid var(--rule-soft); }
.acr .a { font: 700 1.05em/1.3 var(--mono); color: var(--action); }
.acr .s { font-weight: 700; }
.acr .m { grid-column: 2; font-size: 0.92em; }
.acr .c { grid-column: 2; font-size: 0.8em; color: var(--mute); }

/* sheet grid (cheat sheets) */
.sheetgrid { columns: 1; column-gap: var(--gap); }
@media (min-width: 1200px) { .sheetgrid { columns: 2; } }
@media (min-width: 1900px) { .sheetgrid { columns: 3; } }
.sheetgrid > .panel { break-inside: avoid; margin-bottom: var(--gap); display: block; }
.sheetgrid .panel table { font-size: 0.9em; }

/* guide */
.facts { display: grid; grid-template-columns: minmax(0, 1fr); border-top: 1px solid var(--rule); }
.fact { display: grid; grid-template-columns: minmax(0, 1fr); gap: 2px 18px; padding: 10px 0; border-bottom: 1px solid var(--rule-soft); }
@media (min-width: 800px) { .fact { grid-template-columns: minmax(10em, 0.7fr) minmax(0, 1.3fr) auto; } }
.fact .lab { font-weight: 700; }
.fact .st { font: 700 0.75em/1.6 var(--mono); white-space: nowrap; }
.fact .st.official { color: var(--ok); }
.fact .st.community { color: var(--mute); }
.fact .st.unverified { color: var(--bad); }
.fact .src { grid-column: 1 / -1; font-size: 0.8em; color: var(--mute); overflow-wrap: anywhere; }

/* ---------- tablet: top bar ---------- */
@media (max-width: 1023px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; inset: 0 auto 0 0; width: min(320px, 86vw); z-index: 60; transform: translateX(-102%); transition: transform 0.15s; padding-top: calc(20px + env(safe-area-inset-top, 0px)); }
  body.nav-open .side { transform: none; box-shadow: 0 0 0 100vmax rgba(10, 14, 20, 0.55); }
  .topbar { display: flex; position: sticky; top: env(safe-area-inset-top, 0px); z-index: 30; align-items: center; gap: 12px; padding: 8px max(16px, env(safe-area-inset-right, 0px)) 8px max(16px, env(safe-area-inset-left, 0px)); background: var(--navbg); color: var(--navink); border-bottom: 1px solid var(--rule); }
  body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 31; background: var(--navbg); }
  .topbar .brand { padding: 0; font-size: 1.1em; }
  .topbar .sections { display: flex; gap: 2px; margin-left: auto; }
  .topbar .sections a { color: var(--navink); text-decoration: none; padding: 8px 10px; font-weight: 700; font-size: 0.92em; border-radius: 2px; }
  .topbar .sections a[aria-current="page"] { background: var(--navact); color: var(--navonact); }
  .menubtn { background: none; border: 1px solid var(--navmute); color: var(--navink); border-radius: var(--r); min-height: 40px; padding: 0 12px; font: 700 0.9em var(--body); cursor: pointer; }
}
/* ---------- phone: bottom tabs ---------- */
@media (max-width: 767px) {
  .topbar .sections { display: none; }
  .topbar .menubtn { margin-left: auto; }
  .tabbar { display: grid; grid-template-columns: repeat(4, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; background: var(--navbg); border-top: 1px solid var(--rule); padding-bottom: env(safe-area-inset-bottom, 0px); padding-left: env(safe-area-inset-left, 0px); padding-right: env(safe-area-inset-right, 0px); }
  .tabbar a { color: var(--navink); text-decoration: none; text-align: center; padding: 12px 4px; font-weight: 700; font-size: 0.82em; min-height: 48px; }
  .tabbar a[aria-current="page"] { background: var(--navact); color: var(--navonact); }
  body:not(.in-session) #view { padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px)); }
  .page { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
  .sbar .hide-phone { display: none; }
  .hide-phone { display: none; }
  table { font-size: 0.88em; }
  th, td { padding: 7px 6px; }
  .opt { padding: 12px 10px; gap: 10px; }
  .card { min-height: 220px; }
}
@media (min-width: 768px) { .only-phone { display: none !important; } }

/* objective numbers read better in the text face than in mono */
.oid, a.mono[href^="#/study/"], b.mono { font-family: var(--body); font-weight: 700; font-variant-numeric: tabular-nums; }
.studyside { display: none; min-width: 0; align-content: start; gap: var(--gap); }
@media (min-width: 2000px) { .studyside { display: grid; position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow-y: auto; } }
.fact .st.derived { color: var(--action); }
