:root {
  --canvas: #f3f4f7;
  --card: #fff;
  --ink: #262a35;
  --muted: #686d7c;
  --line: #eceef3;
  --surface: #f7f8fa;
  --dark: #1f2433;
  --purple: #6a4cf5;
  --purple-dark: #5537e6;
  --purple-soft: #efebff;
  --purple-text: #6a4cf5; /* purple used as text; lighter in dark mode for contrast */
  --teal: #13a89e;
  --gradient: linear-gradient(135deg, #5fb784 0%, #6f97a6 45%, #8a4fe5 100%);
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 6px 24px rgba(16, 24, 40, .05);
  --radius: 24px;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "Fraunces", Georgia, serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --lift: 0 1px 2px rgba(16,24,40,.06), 0 4px 14px rgba(16,24,40,.07);
  --field-line: #dcdee6; --track: #e3e5ec; --tick: #d5d7e0; --axis-mid: #b2b6c4;
  --badge-bg: #fbf2c0; --badge-ink: #6b5600; --teal-bg: #d8f5f1; --teal-ink: #0b6b63; --purple-ink: #4a2fc9; --soft-hover: #e3dcff;
  /* chart canvas colours, read by app.js */
  --chart-grid: #e4e6ec; --chart-text: #686d7c; --chart-ghost: #c9ccd6; --chart-split: #d5d8e2; --chart-split-text: #686d7c;
  --chart-cursor: rgba(31,36,51,.25); --chart-dot: #fff; --chart-tag: #1f2433;
  color-scheme: light;
}
/* Dark mode follows the system setting, unless the rail's theme switch has picked light or dark. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --canvas: #12151c; --card: #1c202b; --ink: #e6e8ee; --muted: #9aa0ad; --line: #2a2f3c; --surface: #242936;
    --dark: #323a4f; --purple-soft: #2c2650; --purple-text: #a693ff;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 24px rgba(0, 0, 0, .25);
    --lift: 0 1px 2px rgba(0, 0, 0, .35), 0 4px 14px rgba(0, 0, 0, .3);
    --field-line: #3a4050; --track: #343a4a; --tick: #4a5164; --axis-mid: #5a6175;
    --badge-bg: #3d3514; --badge-ink: #f3d86b; --teal-bg: #12352f; --teal-ink: #7fdcd0; --purple-ink: #c2b4ff; --soft-hover: #383063;
    --chart-grid: #2f3442; --chart-text: #9aa0ad; --chart-ghost: #4a5164; --chart-split: #3a4050; --chart-split-text: #8f95a8;
    --chart-cursor: rgba(230,232,238,.25); --chart-dot: #1c202b; --chart-tag: #3a4258;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --canvas: #12151c; --card: #1c202b; --ink: #e6e8ee; --muted: #9aa0ad; --line: #2a2f3c; --surface: #242936;
  --dark: #323a4f; --purple-soft: #2c2650; --purple-text: #a693ff;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 24px rgba(0, 0, 0, .25);
  --lift: 0 1px 2px rgba(0, 0, 0, .35), 0 4px 14px rgba(0, 0, 0, .3);
  --field-line: #3a4050; --track: #343a4a; --tick: #4a5164; --axis-mid: #5a6175;
  --badge-bg: #3d3514; --badge-ink: #f3d86b; --teal-bg: #12352f; --teal-ink: #7fdcd0; --purple-ink: #c2b4ff; --soft-hover: #383063;
  --chart-grid: #2f3442; --chart-text: #9aa0ad; --chart-ghost: #4a5164; --chart-split: #3a4050; --chart-split-text: #8f95a8;
  --chart-cursor: rgba(230,232,238,.25); --chart-dot: #1c202b; --chart-tag: #3a4258;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 24px; }
body { margin: 0; background: var(--canvas); color: var(--ink); font: 15px/1.6 var(--sans); -webkit-font-smoothing: antialiased; }
h1, h2, h3 { margin: 0; font-family: var(--display); font-weight: 500; line-height: 1.3; }
a { color: inherit; }
b { font-weight: 600; }
code { font-family: var(--mono); font-size: .84em; background: var(--surface); border: 1px solid var(--line); padding: .1em .4em; border-radius: 6px; }

/* ---------- rail ---------- */
.rail {
  position: fixed; left: 0; top: 0; bottom: 0; width: 84px; z-index: 20;
  background: var(--card); border-radius: 0 20px 20px 0; box-shadow: var(--shadow);
  display: flex; flex-direction: column; align-items: center; padding: 20px 0;
}
.rail-logo { width: 42px; height: 42px; display: block; }
.rail-logo svg { width: 100%; height: 100%; }
.rail-logo rect { fill: var(--dark); }
.rail-logo path { fill: none; stroke: #53d6c2; stroke-width: 2.6; stroke-linecap: round; }
.rail-nav { margin: auto 0; display: flex; flex-direction: column; gap: 10px; }
.rail-nav a, .rail-gh { width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; color: var(--ink); transition: background .15s, color .15s; }
.rail-nav a:hover { background: var(--surface); }
.rail-nav a.active { background: var(--dark); color: #fff; }
.rail-nav svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.rail-gh { background: var(--purple); color: #fff; }
.rail-gh:hover { background: var(--purple-dark); }
.rail-gh svg { width: 22px; height: 22px; fill: currentColor; }
.rail-theme { width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; margin-bottom: 10px; border: 0; background: none; color: var(--ink); cursor: pointer; transition: background .15s; }
.rail-theme:hover { background: var(--surface); }
.rail-theme svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

/* Skip link: first thing keyboard users reach, hidden until focused */
.skip { position: absolute; left: 12px; top: -60px; z-index: 30; background: var(--dark); color: #fff; padding: 10px 16px; border-radius: 10px; font-weight: 500; text-decoration: none; }
.skip:focus { top: 12px; }

main { margin-left: 84px; padding: 40px clamp(16px, 4vw, 56px) 32px; max-width: 1340px; }
main > section + section { margin-top: 28px; }

@media (max-width: 860px) {
  .rail { position: sticky; top: 0; bottom: auto; width: 100%; height: 64px; flex-direction: row; border-radius: 0 0 18px 18px; padding: 0 12px; gap: 8px; }
  .rail-logo { width: 36px; height: 36px; flex: none; }
  /* The page links scroll sideways when they don't all fit, so the bar never pushes the page wider. */
  .rail-nav { margin: 0 auto; flex-direction: row; gap: 2px; min-width: 0; overflow-x: auto; scrollbar-width: none; }
  .rail-nav::-webkit-scrollbar { display: none; }
  .rail-nav a, .rail-gh, .rail-theme { width: 40px; height: 40px; border-radius: 11px; flex: none; }
  .rail-theme { margin: 0; }
  .rail-nav svg, .rail-gh svg, .rail-theme svg { width: 19px; height: 19px; }
  main { margin-left: 0; padding-top: 24px; }
}
@media (max-width: 380px) { .rail-nav a, .rail-gh, .rail-theme { width: 32px; } .rail { padding: 0 8px; gap: 4px; } }

/* ---------- page head ---------- */
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 28px; }
h1 { font-size: clamp(1.5rem, 3vw, 1.9rem); }
.sub { margin: 2px 0 0; color: var(--muted); }

/* ---------- cards ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 28px 32px; }
.card + .card, .card + .grid3, .grid3 + .card { margin-top: 28px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 4px; }
.card-head h2 { font-size: 1.2rem; }
.card-sub { color: var(--muted); margin: 6px 0 14px; max-width: 760px; }
.card-sub.flush { margin: 2px 0 0; font-size: .9rem; }
.note { font-size: .8rem; color: var(--muted); margin: 10px 0 0; }
kbd { font: 500 .74rem var(--sans); color: var(--ink); background: var(--card); border: 1px solid var(--field-line); border-bottom-width: 2px; border-radius: 6px; padding: 1px 6px; }
.body { margin: 12px 0 0; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 28px; }
.grid3 .card { margin-top: 0; }
#overview .grid3, #chemistry .grid3 { margin-top: 28px; }
@media (max-width: 1080px) { .grid3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 720px) { .grid3 { grid-template-columns: 1fr; } .card { padding: 22px 20px; border-radius: 20px; } }

/* ---------- buttons & badges ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font: 500 .95rem var(--sans); padding: 11px 20px; border-radius: 12px; border: 0; cursor: pointer; text-decoration: none; white-space: nowrap; transition: background .15s, box-shadow .15s; color: var(--ink); background: var(--card); }
.btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; }
.btn.primary { background: var(--purple); color: #fff; }
.btn.primary:hover { background: var(--purple-dark); }
.btn.soft { background: var(--purple-soft); color: var(--purple-text); }
.btn.soft:hover { background: var(--soft-hover); }
.btn.wide { width: 100%; margin-top: 18px; color: var(--purple-text); box-shadow: var(--lift); }
.btn.wide:hover { box-shadow: 0 2px 4px rgba(16,24,40,.08), 0 8px 20px rgba(16,24,40,.09); }
.btn.small { padding: 7px 14px; font-size: .86rem; border-radius: 10px; }
.icon-btn { width: 44px; height: 44px; border-radius: 12px; background: var(--card); display: grid; place-items: center; color: var(--ink); box-shadow: var(--lift); }
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.btn:focus-visible, .icon-btn:focus-visible, .seg button:focus-visible, select:focus-visible, .rail a:focus-visible, summary:focus-visible, .skip:focus-visible { outline: 3px solid rgba(106,76,245,.35); outline-offset: 2px; }
.badge { display: inline-block; background: var(--badge-bg); color: var(--badge-ink); font-size: .72rem; font-weight: 500; letter-spacing: .05em; text-transform: uppercase; padding: 3px 9px; border-radius: 6px; white-space: nowrap; }
.badge.teal { background: var(--teal-bg); color: var(--teal-ink); }
.badge.purple { background: var(--purple-soft); color: var(--purple-ink); }

/* ---------- stepper ---------- */
.stepper { display: flex; align-items: center; padding: 8px 14px; border-radius: 14px; background: var(--card); box-shadow: var(--lift); }
.stepper-label { color: var(--muted); font-size: .86rem; margin-right: 12px; }
.step { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--tick); display: grid; place-items: center; flex: none; }
.step.done { background: var(--purple); border-color: var(--purple); }
.step.done svg { width: 14px; height: 14px; fill: none; stroke: #fff; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.step.current { border-color: var(--purple); }
.step.current::after { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--purple); }
.stepper i { width: 18px; height: 2px; background: var(--purple); }
.stepper i.todo { background: var(--tick); }

/* ---------- rows ---------- */
.row { display: grid; grid-template-columns: 2fr 1fr 1fr auto; align-items: center; gap: 16px; padding: 16px 0; }
.row + .row { border-top: 1px solid var(--line); }
.row-name { font-weight: 500; font-size: 1.02rem; }
.row-name span { display: block; font-weight: 400; font-size: .86rem; color: var(--muted); }
.row-val { color: var(--muted); font-variant-numeric: tabular-nums; }
.row-val b { color: var(--ink); font-size: 1.15rem; }
.row-act { justify-self: end; }
.mono { font-family: var(--mono); font-size: .92rem; }
.mono span { font-family: var(--sans); }
.files .row { grid-template-columns: 3fr 1fr auto; }
.scn-row { grid-template-columns: 1.4fr 1.6fr 1fr .8fr auto; }
.drop { height: 8px; border-radius: 4px; background: var(--surface); overflow: hidden; }
.drop i { display: block; height: 100%; border-radius: 4px; background: var(--purple); }
@media (max-width: 720px) {
  .row, .files .row, .scn-row { grid-template-columns: 1fr auto; gap: 8px 12px; }
  .row-name, .drop { grid-column: 1 / -1; }
  .row-act { grid-column: 2; grid-row: 2; }
  .scn-row .row-act { grid-row: 3; }
}

/* ---------- overview cards ---------- */
.highlight { background: linear-gradient(160deg, rgba(14,40,62,.25) 0%, rgba(20,34,60,.78) 100%), url(assets/ocean.webp) center 30% / cover, var(--dark); color: #fff; }
.highlight h2 { font-size: 1.2rem; }
.highlight .big { font-family: var(--display); font-weight: 600; font-size: 3.2rem; line-height: 1.1; margin: 18px 0 8px; font-variant-numeric: tabular-nums; }
.highlight p { margin: 0; color: rgba(255,255,255,.92); }
.q { display: block; margin: 12px 0 12px; }
.select-wrap { position: relative; }
.select-wrap::after { content: ""; position: absolute; right: 18px; top: 50%; width: 7px; height: 7px; border-right: 2px solid var(--ink); border-bottom: 2px solid var(--ink); transform: translateY(-70%) rotate(45deg); pointer-events: none; }
select { width: 100%; appearance: none; font: 400 .95rem var(--sans); color: var(--ink); background: var(--card); border: 1px solid var(--field-line); border-radius: 12px; padding: 12px 40px 12px 16px; cursor: pointer; }
.answer { margin: 14px 0 0; padding: 12px 14px; background: var(--surface); border-radius: 12px; font-size: .9rem; }
.answer .btn { margin-top: 10px; }
.mini { display: grid; gap: 10px; margin-top: 14px; }
.mini-row { display: grid; grid-template-columns: 104px 1fr 40px; align-items: center; gap: 10px; font-size: .86rem; }
.mini-row .drop { height: 10px; border-radius: 5px; }
.mini-row b { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- explorer ---------- */
.seg { display: flex; flex-wrap: wrap; gap: 4px; padding: 4px; border-radius: 14px; background: var(--card); box-shadow: var(--lift); }
.seg button { font: 500 .88rem var(--sans); padding: 8px 14px; border-radius: 10px; border: 0; background: transparent; color: var(--ink); cursor: pointer; }
.seg button:hover { background: var(--surface); }
.seg button.on { background: var(--dark); color: #fff; }
.seg.small { padding: 3px; border-radius: 11px; }
.seg.small button { padding: 4px 11px; font-size: .8rem; border-radius: 8px; }
.stage { display: grid; grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr); gap: 32px; align-items: start; margin-top: 22px; }
@media (max-width: 980px) { .stage { grid-template-columns: 1fr; } }
.tank-wrap { position: relative; border-radius: 18px; overflow: hidden; aspect-ratio: 4 / 5; max-height: 640px; width: 100%; background: #0b2a3d; }
#tank { width: 100%; height: 100%; display: block; }
.tank-hud { position: absolute; top: 16px; left: 18px; right: 18px; display: flex; justify-content: space-between; color: #fff; pointer-events: none; text-shadow: 0 1px 8px rgba(0,0,0,.35); }
.hud-year { font: 500 1.5rem var(--display); font-variant-numeric: tabular-nums; }
.hud-ph { text-align: right; font: 600 2rem/1 var(--display); font-variant-numeric: tabular-nums; }
.hud-ph small { display: block; font: 500 .7rem var(--sans); opacity: .85; margin-top: 3px; }
.tank-status { position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%); background: rgba(255,255,255,.95); color: #262a35; font-size: .8rem; font-weight: 500; padding: 5px 13px; border-radius: 999px; white-space: nowrap; }
.scrub { display: flex; align-items: center; gap: 14px; margin-top: 16px; }
.scrub label { font-weight: 500; font-size: .9rem; }
.scrub input { flex: 1; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 22px; }
@media (max-width: 620px) { .stats { grid-template-columns: repeat(2, 1fr); } }
.stat { background: var(--surface); border-radius: 14px; padding: 12px 14px; display: flex; flex-direction: column; }
.stat .k { font-size: .74rem; color: var(--muted); line-height: 1.3; min-height: 2.6em; }
.stat .v { font: 600 1.45rem var(--display); font-variant-numeric: tabular-nums; }
.stat .u { font-size: .72rem; color: var(--muted); }
.changed { margin: -10px 0 22px; font-size: .9rem; min-height: 3.2em; }

.chart-block + .chart-block { margin-top: 18px; }
.chart-title { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.chart-title h3 { font-size: .98rem; }
.legend { font-size: .76rem; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.sw { display: inline-block; width: 16px; height: 8px; border-radius: 2px; }
.sw.band { background: rgba(106,76,245,.2); }
.sw.ghost { background: var(--chart-ghost); height: 2px; margin-left: 8px; }
.sw.ref { height: 0; border-top: 2px dashed #e5484d; }
.btn.png-btn { margin-left: 6px; padding: 4px 10px; font-size: .76rem; border-radius: 8px; }
.chart { width: 100%; height: 250px; display: block; touch-action: pan-y; cursor: ew-resize; border-radius: 14px; background: var(--surface); }
.chart.short { height: 180px; }
.chart.tall { height: 340px; }
.pick-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 20px; margin: 14px 0 22px; }
@media (max-width: 860px) { .pick-row { grid-template-columns: 1fr; } }
.pick-label { display: flex; align-items: center; gap: 8px; font-weight: 500; font-size: .9rem; margin-bottom: 8px; }
.sw.line-a { height: 0; border-top: 3px solid #6a4cf5; }
.sw.line-b { height: 0; border-top: 3px dashed #f2734f; }

/* Data-table fallback for the two canvas charts */
.data-table { margin-top: 14px; }
.data-table summary { cursor: pointer; font-weight: 500; font-size: .9rem; color: var(--purple-text); border-radius: 8px; width: fit-content; }
.table-wrap { max-height: 320px; overflow: auto; margin-top: 10px; border-radius: 14px; background: var(--surface); }
.data-table table { width: 100%; border-collapse: collapse; font-size: .84rem; font-variant-numeric: tabular-nums; }
.data-table caption { text-align: left; padding: 10px 14px 4px; color: var(--muted); font-size: .8rem; }
.data-table th, .data-table td { padding: 7px 14px; text-align: right; border-top: 1px solid var(--line); white-space: nowrap; }
.data-table th:first-child, .data-table td:first-child { text-align: left; }
.data-table thead th { position: sticky; top: 0; background: var(--surface); font-weight: 600; border-top: 0; }
.data-table tr.now td { background: var(--purple-soft); font-weight: 600; }

input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 6px; border-radius: 3px; background: var(--track); cursor: pointer; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%; background: var(--purple); border: 3px solid var(--card); box-shadow: 0 0 0 1px var(--purple); }
input[type=range]::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: var(--purple); border: 3px solid var(--card); box-shadow: 0 0 0 1px var(--purple); }
input[type=range]:focus-visible { outline: 3px solid rgba(106,76,245,.35); outline-offset: 4px; }

.region-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; margin: 14px 0 22px; }
.region-note { flex: 1 1 260px; margin: 0; font-size: .88rem; color: var(--muted); }
.dials { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 20px 32px; margin-top: 8px; }
.dial label { display: flex; justify-content: space-between; font-size: .9rem; font-weight: 500; margin-bottom: 8px; }
.dial output { color: var(--purple-text); font-variant-numeric: tabular-nums; }

/* ---------- chemistry ---------- */
.pump-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin: 16px 0 20px; }
.pump-scrub { flex: 1 1 240px; margin-top: 0; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.react-steps { list-style: none; counter-reset: react; margin: 0 0 22px; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 860px) { .react-steps { grid-template-columns: 1fr; } }
.react-steps li { counter-increment: react; background: var(--surface); border-radius: 14px; padding: 12px 14px; border: 2px solid transparent; transition: border-color .2s; }
.react-steps b { display: block; font-weight: 600; font-size: .92rem; margin-bottom: 2px; }
.react-steps b::before { content: counter(react) ". "; color: var(--muted); }
.react-steps span { display: block; font-size: .84rem; color: var(--muted); min-height: 1.3em; }
.react-steps li.now { border-color: var(--purple); }
.react-steps li.done b::before { color: var(--purple-text); }
.species-title { margin-bottom: 10px; }
.steps-head { margin: 28px 0 0; }
.species { display: grid; gap: 14px; margin-top: 6px; }
.sp { display: grid; grid-template-columns: 170px 1fr 80px; gap: 16px; align-items: center; }
.sp .nm { font-weight: 500; line-height: 1.3; }
.sp .nm small { display: block; font-weight: 400; font-size: .76rem; color: var(--muted); }
.axis { position: relative; height: 24px; border-radius: 8px; background: var(--surface); }
.axis::before { content: ""; position: absolute; left: 50%; top: -3px; bottom: -3px; width: 1px; background: var(--axis-mid); }
.axis i { position: absolute; top: 5px; bottom: 5px; border-radius: 4px; transition: left .2s, width .2s; }
.sp .val { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
@media (max-width: 620px) { .sp { grid-template-columns: 1fr 70px; gap: 6px 12px; } .axis { grid-column: 1 / -1; grid-row: 2; } }
.step-card .num { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--dark); color: #fff; font-weight: 600; margin-bottom: 14px; }
.step-card h3 { font-size: 1.05rem; margin-bottom: 6px; }
.step-card p { margin: 0; color: var(--muted); font-size: .92rem; }

/* ---------- timeline ---------- */
.tl-stage { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 28px; align-items: start; }
.tl-readout { position: sticky; top: 24px; }
.tl-year-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.tl-year { font: 600 2.6rem/1.1 var(--display); font-variant-numeric: tabular-nums; }
.tl-track { height: 8px; border-radius: 4px; background: var(--surface); overflow: hidden; margin: 14px 0 20px; }
.tl-track i { display: block; height: 100%; border-radius: 4px; background: var(--purple); transition: width .3s; }
.tl-readout .stats { grid-template-columns: repeat(2, 1fr); margin-bottom: 0; }
.tl-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 28px; }
.tl-item { min-height: 46vh; border: 2px solid transparent; transition: border-color .2s; cursor: pointer; }
.tl-item.now { border-color: var(--purple); }
.tl-item .card-head h2 { font-size: 1.6rem; }
@media (max-width: 860px) {
  .tl-stage { grid-template-columns: 1fr; gap: 20px; }
  .tl-readout { top: 72px; z-index: 5; padding: 16px 18px; }
  .tl-year { font-size: 1.8rem; }
  .tl-track { margin: 10px 0 12px; }
  .tl-readout .stats { grid-template-columns: repeat(4, 1fr); gap: 6px; }
  .tl-readout .stat { padding: 8px 10px; }
  .tl-readout .stat .k { min-height: 0; font-size: .68rem; }
  .tl-readout .stat .u, .tl-readout .note { display: none; }
  .tl-item { min-height: 36vh; }
}

/* ---------- limits ---------- */
#limits .card-head h2 { font-size: 1.08rem; }
/* sensor-detection calculator */
.detect { display: grid; gap: 14px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.detect select { padding: 9px 40px 9px 14px; font-size: .9rem; }
.detect-out { margin: 0; font-size: .86rem; color: var(--muted); }
.detect-out .big-sm { display: block; font: 600 1.6rem/1.2 var(--display); color: var(--ink); font-variant-numeric: tabular-nums; }
.list { margin: 14px 0 0; padding-left: 18px; display: grid; gap: 10px; font-size: .92rem; }

/* ---------- code & footer ---------- */
.code { margin: 20px 0 0; padding: 18px 20px; background: var(--dark); color: #e3e6f2; border-radius: 16px; overflow-x: auto; font: .82rem/1.7 var(--mono); }
.code code { background: none; border: 0; padding: 0; color: inherit; }
footer { margin-top: 36px; padding-top: 18px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; color: var(--muted); font-size: .8rem; }

@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } * { transition: none !important; } }
/* ---------- quiz ---------- */
.qz-stage { margin-top: 0; }
.qz-steps { grid-template-columns: 1fr; }
.qz-stats { margin: 0 0 18px; }

/* glossary */
a.term { text-decoration: underline dotted; text-underline-offset: 3px; }
a.term:hover { text-decoration-style: solid; }
dd a.term { color: var(--purple-text); white-space: nowrap; }
.gloss-find { display: grid; gap: 6px; max-width: 320px; margin-top: 14px; font-size: .86rem; font-weight: 500; }
.gloss-find input { font: inherit; font-weight: 400; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 9px 12px; }
.gloss { margin: 14px 0 0; }
.gloss-item { padding: 16px 12px; margin: 0 -12px; border-radius: 12px; scroll-margin-top: 24px; }
.gloss-item + .gloss-item { border-top: 1px solid var(--line); }
.gloss-item.target { background: var(--purple-soft); border-top-color: transparent; }
.gloss dt { font-weight: 600; font-size: 1.02rem; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.gloss dd { margin: 6px 0 0; max-width: 760px; font-size: .94rem; }

/* ---------- print ---------- */
/* Paper is always light: restate the light palette so a dark-mode screen still prints dark ink on white. */
@media print {
  :root {
    --canvas: #fff; --card: #fff; --ink: #262a35; --muted: #686d7c; --line: #eceef3; --surface: #f7f8fa;
    --dark: #1f2433; --purple-soft: #efebff; --purple-text: #6a4cf5; --shadow: none; --lift: none;
    --field-line: #dcdee6; --track: #e3e5ec; --tick: #d5d7e0; --axis-mid: #b2b6c4;
    --badge-bg: #fbf2c0; --badge-ink: #6b5600; --teal-bg: #d8f5f1; --teal-ink: #0b6b63; --purple-ink: #4a2fc9;
    --chart-grid: #e4e6ec; --chart-text: #686d7c; --chart-ghost: #c9ccd6; --chart-split: #d5d8e2; --chart-split-text: #686d7c;
    --chart-cursor: rgba(31,36,51,.25); --chart-dot: #fff; --chart-tag: #1f2433;
    color-scheme: light;
  }
  @page { margin: 14mm; }
  /* Keep bars, badges and chart backgrounds, which browsers drop from print by default. */
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  body { font-size: 11pt; }

  /* Navigation and controls do nothing on paper. */
  .rail, .skip, .btn, .icon-btn, .scrub, .gloss-find, .no-print, input[type=range] { display: none !important; }
  /* Segmented pickers shrink to a label for the option that is switched on. */
  .seg { padding: 0; background: none; }
  .seg button:not(.on) { display: none; }
  .seg button.on { padding: 4px 12px; }
  .select-wrap::after { display: none; }

  main { margin: 0; padding: 0; max-width: none; }
  .page-head { margin-bottom: 16px; }
  .card { border: 1px solid var(--field-line); padding: 18px 20px; border-radius: 14px; }
  .card + .card, .card + .grid3, .grid3 + .card, main > section + section { margin-top: 16px; }
  .grid3, .tl-list { gap: 16px; }
  .card, .stat, .row, .chart-block, .tank-wrap, .sp, .react-steps li, .gloss-item, .data-table tr { break-inside: avoid; }
  h1, h2, h3, .card-head, .chart-title { break-after: avoid; }

  /* Charts keep the shape they were drawn at instead of stretching to the page. */
  .chart, .chart.short, .chart.tall { height: auto; }
  .tank-wrap { max-width: 300px; margin: 0 auto; }
  #tank { object-fit: cover; }

  /* An open data table prints in full with its header repeated on each page; a closed one is left out. */
  .data-table:not([open]), .data-table summary { display: none; }
  .table-wrap { max-height: none; overflow: visible; background: none; }
  .data-table thead { display: table-header-group; }
  .data-table thead th { position: static; }
  .data-table th, .data-table td { padding: 4px 10px; }

  .tl-readout { position: static; }
  .tl-item { min-height: 0; }
  .code { white-space: pre-wrap; overflow: visible; }
  a.term { text-decoration: none; }
  footer { margin-top: 20px; }
}

/* ---------- marine life ---------- */
.life-scale { position: relative; margin: 8px 0 44px; }
.life-bar { height: 12px; border-radius: 6px; background: var(--surface); overflow: hidden; }
.life-bar i { display: block; height: 100%; border-radius: 6px; background: var(--purple); transition: width .3s; }
.life-tick { position: absolute; top: -4px; height: 20px; border-left: 2px dashed var(--muted); }
.life-tick span { position: absolute; top: 24px; left: 0; transform: translateX(-50%); font-size: .72rem; color: var(--muted); white-space: nowrap; }
#lifeCards { margin-top: 28px; }
.life-card .card-sub { margin-bottom: 10px; }
.life-card .life-when { font-weight: 500; margin: 0; }
