:root {
  color-scheme: light;
  --bg: #f4f4f1;
  --surface: #fcfcfb;
  --surface-2: #f0efec;
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #6b6a65;
  --grid: #e6e5e0;
  --axis: #b9b8b1;
  --border: #dcdbd5;
  --accent: #2a78d6;
  --accent-ink: #1c5cab;
  /* Fill behind white text: 4.9:1 (light) and 5.0:1 (dark), above WCAG AA's 4.5. */
  --accent-fill: #2470cc;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  /* Every series is at least 3:1 against the chart background (WCAG 1.4.11). */
  --series-3: #16956a;
  --series-4: #a87400;
  --series-5: #c8507f;
  --series-6: #008300;
  --series-7: #6250d6;
  --series-8: #e34948;
  --reference: #8a8984;
  --band: rgba(42, 120, 214, 0.14);
  --accent-fill-hover: #1f63b6;
  /* Status colors are toned to sit beside the warm neutrals; each is at least 3:1 on its surface. */
  --warning: #a87400;
  --good: #2e8f57;
  --critical: #d03b3b;
  /* Three radii: cards, boxes and controls, and the small parts nested inside controls. */
  --r-card: 12px;
  --r-box: 8px;
  --r-sm: 4px;
  /* One type scale. */
  --fs-xs: 0.75rem;
  --fs-sm: 0.8125rem;
  --fs-ctl: 0.875rem;
  --fs-body: 0.9375rem;
  --fs-h3: 1rem;
  --fs-h2: 1.125rem;
  --fs-fig: 1.375rem;
  --fs-h1: 1.75rem;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121211;
    --surface: #1a1a19;
    --surface-2: #232321;
    --text: #f0efec;
    --text-2: #c3c2b7;
    --muted: #94938b;
    --grid: #2c2c2a;
    --axis: #55544f;
    --border: #383835;
    --accent: #3987e5;
    --accent-ink: #86b6ef;
    --accent-fill: #2a6fc4;
    --accent-fill-hover: #2563b0;
    --warning: #d9a02b;
    --good: #4cc38a;
    --critical: #e66767;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --series-5: #d55181;
    --series-6: #008300;
    --series-7: #9085e9;
    --series-8: #e66767;
    --reference: #8f8e86;
    --band: rgba(57, 135, 229, 0.2);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121211;
  --surface: #1a1a19;
  --surface-2: #232321;
  --text: #f0efec;
  --text-2: #c3c2b7;
  --muted: #94938b;
  --grid: #2c2c2a;
  --axis: #55544f;
  --border: #383835;
  --accent: #3987e5;
  --accent-ink: #86b6ef;
  --accent-fill: #2a6fc4;
  --accent-fill-hover: #2563b0;
  --warning: #d9a02b;
  --good: #4cc38a;
  --critical: #e66767;
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #d55181;
  --series-6: #008300;
  --series-7: #9085e9;
  --series-8: #e66767;
  --reference: #8f8e86;
  --band: rgba(57, 135, 229, 0.2);
}

/* USF palette, chosen with the header toggle: USF Green #006747, USF Gold #CFC493, white.
   Pale gold is below 3:1 on a light chart, so light mode draws gold lines in a deeper gold;
   dark mode lightens the green instead. Series 3 becomes slate so groups don't read as two greens. */
:root[data-palette="usf"] {
  --accent: #006747;
  --accent-ink: #00543a;
  --accent-fill: #006747;
  --accent-fill-hover: #00543a;
  --series-1: #006747;
  --series-2: #9a8740;
  --series-3: #4d6a80;
  --band: rgba(0, 103, 71, 0.12);
}
@media (prefers-color-scheme: dark) {
  :root[data-palette="usf"]:not([data-theme="light"]) {
    --accent: #4cb88a;
    --accent-ink: #7fd1a8;
    --accent-fill: #006747;
    --accent-fill-hover: #00543a;
    --series-1: #4cb88a;
    --series-2: #cfc493;
    --series-3: #8fb0c8;
    --band: rgba(76, 184, 138, 0.18);
  }
}
:root[data-palette="usf"][data-theme="dark"] {
  --accent: #4cb88a;
  --accent-ink: #7fd1a8;
  --accent-fill: #006747;
  --accent-fill-hover: #00543a;
  --series-1: #4cb88a;
  --series-2: #cfc493;
  --series-3: #8fb0c8;
  --band: rgba(76, 184, 138, 0.18);
}

/* Eastern Michigan palette (Swoop): EMU Green #046A38 and white. EMU has no second brand
   color, so series 2 is a cool gray and series 3 a slate blue, each at least 3:1 on the chart. */
:root[data-palette="emu"] {
  --accent: #046a38;
  --accent-ink: #035a2f;
  --accent-fill: #046a38;
  --accent-fill-hover: #03552d;
  --series-1: #046a38;
  --series-2: #6b6e72;
  --series-3: #3f6a8f;
  --band: rgba(4, 106, 56, 0.12);
}
@media (prefers-color-scheme: dark) {
  :root[data-palette="emu"]:not([data-theme="light"]) {
    --accent: #5cc08a;
    --accent-ink: #8bd6ad;
    --accent-fill: #046a38;
    --accent-fill-hover: #03552d;
    --series-1: #5cc08a;
    --series-2: #c9cbcd;
    --series-3: #8fb0c8;
    --band: rgba(92, 192, 138, 0.18);
  }
}
:root[data-palette="emu"][data-theme="dark"] {
  --accent: #5cc08a;
  --accent-ink: #8bd6ad;
  --accent-fill: #046a38;
  --accent-fill-hover: #03552d;
  --series-1: #5cc08a;
  --series-2: #c9cbcd;
  --series-3: #8fb0c8;
  --band: rgba(92, 192, 138, 0.18);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: var(--fs-body)/1.55 var(--font);
}
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }
a { color: var(--accent-ink); }
code { font-family: var(--mono); font-size: var(--fs-ctl); }
sub, sup { line-height: 0; }
/* Paragraphs and lists share one 12px rhythm instead of margins that follow each font size. */
p, ul, ol { margin-top: 12px; margin-bottom: 12px; }
/* Hierarchy comes from size; bold is one step, not two. */
h1, h2, h3, b, strong, legend, summary, thead th { font-weight: 600; }

.site-header { padding: 28px 0 8px; }
.site-header .wrap { position: relative; }

/* Color toggle, top right of the header. */
/* Liquid glass: a gray track with three equal options, and a glass lens over the chosen one.
   In Chromium browsers app.js gives the lens a refraction filter, so the track and its edge
   visibly bend through its rim (the labels sit above the glass and stay sharp); everywhere the lens frosts what is behind it, and a rim
   light (also drawn by app.js) catches the top left and bottom right. While pressed or sliding
   (.is-liquid) it swells past the track and clears. */
:root {
  --lg-track: rgba(120, 120, 128, 0.16);
  --lg-ink: var(--accent-ink);
  --lg-tint: rgba(255, 255, 255, 0.12);
  --lg-tint-clear: rgba(255, 255, 255, 0.06);
  --lg-edge: 0 0 0 0.5px rgba(0, 0, 0, 0.1), 0 4px 14px rgba(0, 0, 0, 0.12), 0 1px 3px rgba(0, 0, 0, 0.08);
  --lg-light-opacity: 1;
  --lg-knob: #fff;
  /* The body of the glass: a bright inner edge and a faint darker band inside it, as thick glass shows. */
  --lg-body: inset 0 0 0 1px rgba(255, 255, 255, 0.7), inset 0 -3px 6px -2px rgba(255, 255, 255, 0.9), inset 0 0 10px rgba(0, 0, 0, 0.06);
  --lg-gloss: 0.75;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --lg-track: rgba(120, 120, 128, 0.32);
    --lg-ink: #fff;
    --lg-tint: rgba(255, 255, 255, 0.1);
    --lg-tint-clear: rgba(255, 255, 255, 0.03);
    --lg-edge: 0 0 0 0.5px rgba(255, 255, 255, 0.12), 0 4px 14px rgba(0, 0, 0, 0.4);
    --lg-light-opacity: 0.6;
    --lg-knob: #636366;
    --lg-body: inset 0 0 0 1px rgba(255, 255, 255, 0.14), inset 0 -3px 6px -2px rgba(255, 255, 255, 0.18), inset 0 0 10px rgba(0, 0, 0, 0.25);
    --lg-gloss: 0.22;
  }
}
:root[data-theme="dark"] {
  --lg-track: rgba(120, 120, 128, 0.32);
  --lg-ink: #fff;
  --lg-tint: rgba(255, 255, 255, 0.1);
  --lg-tint-clear: rgba(255, 255, 255, 0.03);
  --lg-edge: 0 0 0 0.5px rgba(255, 255, 255, 0.12), 0 4px 14px rgba(0, 0, 0, 0.4);
  --lg-light-opacity: 0.6;
  --lg-knob: #636366;
  --lg-body: inset 0 0 0 1px rgba(255, 255, 255, 0.14), inset 0 -3px 6px -2px rgba(255, 255, 255, 0.18), inset 0 0 10px rgba(0, 0, 0, 0.25);
  --lg-gloss: 0.22;
}
.palette-toggle {
  position: absolute; top: -16px; right: 16px; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 2px; padding: 4px;
  background: var(--lg-track); border-radius: 999px;
}
.palette-toggle .glass-thumb {
  position: absolute; top: 4px; left: 0; z-index: 2; border-radius: 999px; pointer-events: none;
  background: var(--lg-tint); box-shadow: var(--lg-edge), var(--lg-body);
  -webkit-backdrop-filter: saturate(170%) brightness(1.05); backdrop-filter: saturate(170%) brightness(1.05);
  scale: 1.03 1.1;
  transition: scale 420ms cubic-bezier(0.3, 1.6, 0.45, 1), background-color 240ms var(--ease);
}
.palette-toggle .glass-thumb.refracts { -webkit-backdrop-filter: url(#glass-refract); backdrop-filter: url(#glass-refract); }
/* The gloss: a soft crescent of light across the top of the glass. */
.palette-toggle .glass-thumb::before {
  content: ""; position: absolute; top: 2px; left: 14%; right: 14%; height: 42%; border-radius: 999px;
  background: linear-gradient(to bottom, rgba(255, 255, 255, var(--lg-gloss)), rgba(255, 255, 255, 0));
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 30%, #000 70%, transparent); mask-image: linear-gradient(90deg, transparent, #000 30%, #000 70%, transparent);
}
.palette-toggle .glass-thumb::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit;
  background: var(--lg-light, none) center / 100% 100% no-repeat; opacity: var(--lg-light-opacity);
}
.palette-toggle .glass-thumb.is-liquid { scale: 1.16 1.42; background-color: var(--lg-tint-clear); }
.palette-toggle button {
  /* Above the lens (z-index 2): the refraction filter resamples whatever is under it, which blurs text. */
  position: relative; z-index: 3; display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 32px; padding: 4px 14px 4px 14px;
  border: 0; border-radius: 999px; background: transparent; color: var(--text-2); font: inherit; font-size: var(--fs-sm); font-weight: 500; cursor: pointer;
  transition: color 220ms var(--ease);
}
/* On a phone there is no room beside the "All USF.ac tools" link, so the toggle takes its own row. */
@media (max-width: 440px) { .palette-toggle { position: relative; top: auto; right: auto; margin: 4px 0 16px; } }
.palette-toggle button:hover { color: var(--text); }
.palette-toggle button[aria-pressed="true"] { color: var(--lg-ink); }
/* Before the script places the lens, the chosen option carries a plain knob. */
.palette-toggle:not(.has-thumb) button[aria-pressed="true"] { background: var(--lg-knob); box-shadow: var(--lg-edge); }
/* The lens keeps its small wobble with "reduce motion" on; see place() in app.js. */
@media (prefers-reduced-motion: reduce) { .palette-toggle button { transition: none; } }
.palette-toggle button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.palette-toggle .sw { width: 14px; height: 14px; flex: none; border-radius: 50%; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.18); }
.palette-toggle .sw-default { background: linear-gradient(90deg, #2a78d6 50%, #eb6834 50%); }
.palette-toggle .sw-usf { background: linear-gradient(90deg, #006747 50%, #cfc493 50%); }
.palette-toggle .sw-emu { background: linear-gradient(90deg, #046a38 50%, #fff 50%); }
.site-header h1 { display: flex; align-items: center; gap: 12px; margin: 0 0 8px; font-size: var(--fs-h1); line-height: 1.15; letter-spacing: -0.01em; }
/* The mark: the dashed line of perfect matching against the fitted line, as in every graph below. */
.mark { width: 28px; height: 28px; flex: none; fill: none; }
.mark-axis { stroke: var(--axis); stroke-width: 1.5; }
.mark-ref { stroke: var(--reference); stroke-width: 1.5; stroke-dasharray: 3 3; }
.mark-fit { stroke: var(--accent); stroke-width: 2.5; stroke-linecap: round; }
.lede { margin: 0; color: var(--text-2); max-width: 70ch; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  padding: 20px;
  margin: 16px 0;
}
.card h2 { margin: 0 0 12px; font-size: var(--fs-h2); display: flex; align-items: center; gap: 12px; }
.card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card-head h2 { margin: 0; }
.card-head .inline { margin-bottom: 0; }
/* Step numbers stay neutral so the accent is left for the selection, the primary action and links. */
.step {
  display: inline-grid; place-items: center;
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2);
  font-size: var(--fs-sm); font-weight: 600; font-variant-numeric: tabular-nums;
}
h3 { font-size: var(--fs-h3); margin: 20px 0 8px; }
.small-h { margin-top: 0; }
.hint { color: var(--text-2); font-size: var(--fs-sm); margin: 8px 0 12px; max-width: 65ch; }
.muted { color: var(--muted); }
.small { font-size: var(--fs-sm); }

/* Analysis mode */
.mode-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 16px 0 0; }
.mode-label { font-size: var(--fs-sm); font-weight: 600; color: var(--text-2); }
.mode-switch { display: flex; gap: 4px; background: var(--surface-2); border: 1px solid var(--border); padding: 4px; border-radius: var(--r-box); flex-wrap: wrap; }
.mode-switch button {
  border: 0; background: transparent; color: var(--text-2);
  padding: 8px 16px; border-radius: var(--r-sm); font: inherit; font-size: var(--fs-ctl); line-height: 20px; cursor: pointer; text-align: left;
}
.mode-switch button span { color: var(--muted); }
.mode-switch button:hover { color: var(--text); }
.mode-switch button[aria-checked="true"] { background: var(--accent-fill); color: #fff; }
.mode-switch button[aria-checked="true"] span { color: #fff; }
body.mode-hyperbola [data-mode="gml"],
body:not(.mode-hyperbola) [data-mode="hyperbola"] { display: none !important; }

/* Tabs */
.tabs { display: flex; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: var(--r-box); flex-wrap: wrap; }
.tab {
  border: 0; background: transparent; color: var(--text-2);
  min-height: 32px; padding: 4px 12px; border-radius: var(--r-sm); font: inherit; font-size: var(--fs-ctl); line-height: 20px; cursor: pointer;
}
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05); }

/* Form controls */
input[type="text"], input[type="number"], select, textarea {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--r-box); padding: 4px 8px; width: 100%;
}
input[type="text"], input[type="number"], select { height: 36px; }
textarea { font-family: var(--mono); font-size: var(--fs-sm); padding: 8px; resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, summary:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
label { font-size: var(--fs-sm); color: var(--text-2); }
label.block { display: block; margin-bottom: 12px; }
label.block > select, label.block > textarea { margin-top: 4px; }
label.file { display: block; margin-top: 4px; }
label.file input { display: block; margin-top: 4px; font-size: var(--fs-sm); color: var(--text-2); }
/* Groups of settings and questions are set apart by a hairline and space, not a box. */
fieldset { border: 0; border-top: 1px solid var(--border); padding: 16px 0 0; margin: 0; min-width: 0; }
/* Floated so the legend sits under the hairline instead of breaking it. */
legend { float: left; width: 100%; padding: 0; margin: 0 0 8px; font-size: var(--fs-body); color: var(--text); }
legend + * { clear: both; }

.btn {
  font: inherit; font-size: var(--fs-ctl); line-height: 20px; cursor: pointer;
  min-height: 36px; padding: 4px 16px; border-radius: var(--r-box);
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { color: var(--muted); cursor: default; background: var(--surface); }
.btn.primary { background: var(--accent-fill); border-color: var(--accent-fill); color: #fff; }
.btn.primary:hover { background: var(--accent-fill-hover); border-color: var(--accent-fill-hover); }
.btn.ghost { border-color: transparent; color: var(--text-2); }
.btn.small { min-height: 32px; padding: 4px 12px; font-size: var(--fs-sm); }
.btn, .tab, .mode-switch button, .del, .term {
  transition: background-color 140ms var(--ease), color 140ms var(--ease), border-color 140ms var(--ease);
}
@media (prefers-reduced-motion: reduce) {
  .btn, .tab, .mode-switch button, .del, .term { transition: none; }
}
.inline { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; margin-bottom: 8px; }
.inline label { flex: 1 1 120px; }

.names { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.names label { display: block; }
.names input { margin-top: 4px; }
.preset { margin: 12px 0 0; align-items: center; }

/* Data entry table */
.table-scroll { overflow-x: auto; max-height: 460px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--r-box); }
table { border-collapse: collapse; width: 100%; font-size: var(--fs-sm); }
th, td { padding: 4px 8px; text-align: left; border-bottom: 1px solid var(--grid); white-space: nowrap; }
thead th { position: sticky; top: 0; background: var(--surface-2); color: var(--text-2); z-index: 1; }
table.entry input { height: 32px; border-color: transparent; background: transparent; padding: 4px 8px; min-width: 72px; border-radius: var(--r-sm); }
table.entry input:hover { border-color: var(--border); }
table.entry input:focus { background: var(--surface); }
table.entry input.num { text-align: right; font-variant-numeric: tabular-nums; }
table.entry input[data-k="group"] { min-width: 212px; }
table.entry input.invalid { border-color: var(--critical); }
/* Invalid numbers are named in words, not only by the red border. */
.cell-err { display: block; padding: 0 8px 4px; font-size: var(--fs-xs); font-weight: 600; color: var(--critical); }
.cell-err[hidden] { display: none; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
/* A 32px button whose tap area reaches 44px wide and the full 40px row, so rows keep their height. */
.del { position: relative; display: inline-grid; place-items: center; min-width: 32px; min-height: 32px; border: 0; background: transparent; color: var(--muted); cursor: pointer; padding: 0; border-radius: var(--r-sm); }
.del::after { content: ""; position: absolute; inset: -4px -6px; }
.del:hover { color: var(--critical); background: var(--surface-2); }
.ico { width: 16px; height: 16px; flex: none; display: block; }
.row-actions { display: flex; gap: 8px; align-items: center; margin-top: 12px; flex-wrap: wrap; }
tr.excluded td { color: var(--muted); text-decoration: line-through; }
tr.flagged td { background: var(--surface-2); }

.paste-grid { display: grid; grid-template-columns: 1.3fr 1fr; gap: 24px; }
.mapping { display: grid; grid-template-columns: auto 1fr; gap: 8px 12px; align-items: center; margin-bottom: 12px; font-size: var(--fs-sm); }
.mapping span, .mapping label { color: var(--text-2); }
.msg { font-size: var(--fs-sm); color: var(--text-2); min-height: 1.55em; }
.msg.error { color: var(--critical); }
.sample { display: flex; gap: 24px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.sample > div { flex: 1 1 420px; }
.sample p { margin: 0 0 8px; max-width: 65ch; }

.settings { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px 32px; }

/* Results: the plain-language answer on the left, the verdict and key figures on the right. */
.results-top { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px 32px; align-items: start; margin-bottom: 24px; }
.results-top > :only-child { grid-column: 1 / -1; }
.plain h3 { margin: 0 0 8px; }
.plain p { margin: 8px 0; max-width: 65ch; }
.plain p:last-child { margin-bottom: 0; }
.verdict {
  background: var(--surface-2);
  border-radius: var(--r-box);
  padding: 16px;
  margin-bottom: 16px;
}
/* On its own (no fit yet) the box is only as wide as its text. */
#results > .verdict { width: fit-content; max-width: 100%; }
.verdict .headline { font-size: var(--fs-fig); font-weight: 600; line-height: 1.25; margin: 0 0 4px; }
.verdict .pooled { font-size: var(--fs-sm); color: var(--text-2); margin: 0 0 8px; }
.verdict p { margin: 4px 0; max-width: 65ch; }
.verdict .eq { margin-top: 8px; }
.empty { color: var(--text-2); padding: 12px 0; }

/* Key figures: a label, the number, and what it is measured against. No boxes. */
.tiles { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 16px 24px; }
.tile { grid-column: span 2; display: flex; flex-direction: column; border-top: 1px solid var(--border); padding-top: 12px; }
.tile:nth-child(n+4) { grid-column: span 3; }
.tile .k { font-size: var(--fs-sm); color: var(--text-2); margin-bottom: auto; }
.tile .v { font-size: var(--fs-fig); font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.25; margin-top: 4px; }
.tile .s { font-size: var(--fs-sm); color: var(--muted); font-variant-numeric: tabular-nums; }

.warnings { list-style: none; padding: 0; margin: 0 0 16px; }
.warnings li {
  display: flex; gap: 8px; align-items: flex-start;
  font-size: var(--fs-sm); padding: 8px 12px; border-radius: var(--r-box);
  background: var(--surface-2); margin-bottom: 8px;
}
/* 2px drops the 16px icon onto the first line of text. */
.warnings .icon { color: var(--warning); flex: none; margin-top: 2px; }

.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 24px; }
table.stats td:first-child { color: var(--text-2); white-space: normal; }
table.stats { border: 1px solid var(--border); border-radius: var(--r-box); overflow: hidden; }
.group-table { margin-top: 16px; }

.eq { font-family: var(--mono); font-size: var(--fs-ctl); background: var(--surface-2); padding: 8px 12px; border-radius: var(--r-sm); display: inline-block; }
.verdict .eq { background: var(--surface); }

/* Charts: the log-ratio plot leads, with strict matching beside it; the rest follow at full or half width. */
.charts { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 24px 32px; }
.chart { grid-column: span 6; margin: 0; min-width: 0; border-top: 1px solid var(--border); padding-top: 16px; }
.chart.lead { grid-column: span 7; }
.chart.side { grid-column: span 5; }
.chart.wide { grid-column: 1 / -1; }
.chart-head { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.chart h3 { margin: 0; font-size: var(--fs-h3); }
.chart .sub { font-size: var(--fs-sm); color: var(--text-2); margin: 4px 0 8px; max-width: 80ch; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart-tools { display: flex; gap: 4px; flex: none; }
/* Chart tools are quiet text buttons, so 18 of them do not outweigh the graphs. */
.chart-tools .btn { border-color: transparent; background: transparent; color: var(--text-2); padding: 4px 8px; }
.chart-tools .btn:hover, .chart-tools .btn[aria-expanded="true"] { background: var(--surface-2); color: var(--text); }
.legend { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: var(--fs-sm); color: var(--text-2); margin: 4px 0 0; }
.legend span { display: inline-flex; align-items: center; gap: 8px; }
.legend svg { width: 22px; height: 12px; display: inline; }
.chart-table { margin-top: 12px; max-height: 320px; }
svg text { font-family: var(--font); }

.tooltip {
  position: fixed; z-index: 10; pointer-events: none;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--r-box);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
  padding: 8px 12px; font-size: var(--fs-sm); line-height: 1.45; max-width: 280px;
}
.tooltip .t-row { display: flex; justify-content: space-between; gap: 16px; font-variant-numeric: tabular-nums; }
.tooltip .t-row span:first-child { color: var(--text-2); }

.sample + .sample { border-top: 1px solid var(--border); margin-top: 16px; padding-top: 16px; }
.pbp-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0 12px; }
.pbp-grid [hidden] { display: none; }

/* Footer */
.site-footer { border-top: 1px solid var(--border); margin-top: 24px; padding: 24px 0 40px; background: var(--surface); }
.site-footer h2 { font-size: var(--fs-h3); margin: 0 0 8px; }
.cite { margin-bottom: 16px; }
.apa { padding-left: 32px; text-indent: -32px; margin: 0 0 8px; max-width: 90ch; overflow-wrap: anywhere; }
.disclaimer { font-size: var(--fs-sm); color: var(--text-2); max-width: 100ch; }
.site-footer .small { overflow-wrap: anywhere; }

/* Method: one text flow in two balanced columns. */
.method-grid { columns: 2; column-gap: 32px; }
.method-grid > div:first-child > h3:first-child { margin-top: 0; }
.method-grid h3 { break-after: avoid; }
.method-grid li, .method-grid p { break-inside: avoid; }
.method ul { padding-left: 20px; }
.method li { margin-bottom: 8px; }
.refs { font-size: var(--fs-sm); padding-left: 20px; }
.refs li { margin-bottom: 8px; max-width: 100ch; }

/* Home link (matches the rest of usf.ac) */
/* Padding gives the link a 44px tap area; the margin keeps the space around it as before. */
.home-link { display: inline-block; padding: 12px 0; margin: -12px 0 0; color: var(--text-2); font-size: var(--fs-ctl); line-height: 20px; text-decoration: none; }
.home-link:hover { color: var(--accent-ink); text-decoration: underline; }

/* Start here: a card on the page, only as wide as its text. */
.start-here { display: flex; gap: 24px; align-items: flex-start; justify-content: space-between; width: fit-content; max-width: 100%; margin: 8px 0 0; padding: 16px 20px; border: 1px solid var(--border); border-radius: var(--r-card); background: var(--surface); }
.start-here[hidden] { display: none; }
.start-here h2 { font-size: var(--fs-h3); margin: 0 0 8px; }
.start-here ol { margin: 0; padding-left: 20px; }
.start-here li { margin-bottom: 4px; max-width: 65ch; }
.start-here li:last-child { margin-bottom: 0; }
.start-here .btn { white-space: nowrap; flex: none; }
.load-status { margin: 12px 0 0; padding: 8px 12px; border-radius: var(--r-box); background: var(--surface-2); font-size: var(--fs-ctl); }

/* Glossary terms */
.term { font: inherit; color: inherit; background: none; border: 0; padding: 0; margin: 0; cursor: help; text-decoration: underline dotted var(--text-2); text-underline-offset: 3px; text-align: inherit; }
.term:hover, .term:focus-visible, .term[aria-expanded="true"] { color: var(--accent-ink); text-decoration-color: var(--accent-ink); }
.term-pop { position: fixed; z-index: 20; max-width: 320px; padding: 12px; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--r-box); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1); font-size: var(--fs-sm); line-height: 1.5; }
.term-pop[hidden] { display: none; }

/* Plain-language extras */
.short-answer { padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.howto li, .warnings li, ul.small li { max-width: 65ch; }
.results-side .warnings li { max-width: none; }
.howto { margin: 24px 0 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 12px 0; }
.howto summary { cursor: pointer; }
.howto ol { padding-left: 20px; }
.howto li { margin-bottom: 8px; }
.comps li { margin-bottom: 8px; max-width: 65ch; }
.group-cautions summary { cursor: pointer; font-size: var(--fs-sm); font-weight: 400; color: var(--text-2); }

/* Explorer */
.explorer { margin: 24px 0; padding: 20px 0 0; border-top: 1px solid var(--border); }
.explorer h3 { margin-top: 0; }
.explorer-controls { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: center; }
.explorer-controls label { display: flex; flex-direction: column; gap: 4px; min-width: 200px; font-size: var(--fs-ctl); }
.explorer-controls input[type="range"] { width: 100%; accent-color: var(--accent); }
.ex-caption { min-height: 1.55em; }
.explorer-charts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 32px; }
.explorer-charts figure { margin: 0; }
.explorer-charts svg { width: 100%; height: auto; display: block; }
.explorer-charts figcaption { font-size: var(--fs-sm); color: var(--text-2); margin-top: 4px; }

/* Hyperbola extras */
.expo { margin-top: 16px; }
.expo h3 { margin-top: 0; }
.expo p { max-width: 65ch; }
label.check { display: flex; gap: 8px; align-items: flex-start; font-size: var(--fs-ctl); color: var(--text); margin-top: 8px; }
label.check input { margin-top: 4px; flex: none; }

/* Check your understanding */
.quiz { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px 32px; }
.quiz-q { margin: 0; }
.quiz-q legend { line-height: 1.45; }
.quiz-opt { display: flex; gap: 8px; align-items: flex-start; font-size: var(--fs-body); color: var(--text); padding: 4px 0; cursor: pointer; }
.quiz-opt input { margin-top: 4px; flex: none; }
.quiz-fb { font-size: var(--fs-sm); margin: 8px 0 0; padding: 0; }
.quiz-fb:not(:empty) { padding: 8px 12px; border-radius: var(--r-box); background: var(--surface-2); border: 1px solid var(--border); }
.quiz-fb.right { border-color: var(--good); }
.quiz-fb.wrong { border-color: var(--critical); }

/* Text for screen readers only */
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

@media (max-width: 700px) {
  .explorer-charts { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .settings, .paste-grid, .stats-grid, .quiz, .results-top { grid-template-columns: 1fr; }
  .method-grid { columns: 1; }
  /* One column: twelve columns' eleven 32px gaps alone are wider than a phone. */
  .charts { grid-template-columns: minmax(0, 1fr); }
  .chart, .chart.lead, .chart.side { grid-column: 1 / -1; }
  .pbp-grid { grid-template-columns: 1fr 1fr; }
  .names { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 480px) {
  .card { padding: 16px; }
  .names { grid-template-columns: 1fr; }
  .mode-switch, .mode-switch button { width: 100%; }
  .tile, .tile:nth-child(n+4) { grid-column: span 3; }
  .tile:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .start-here { flex-direction: column; padding: 16px; gap: 12px; }
}
