:root {
  color-scheme: light;
  --bg: #f6f7f9; --fg: #1d2433; --muted: #5b6475; --line: #d8dce3; --card: #fff;
  --accent: #2f5fd0; --truth: #1b8fc9; --dgmr: #1f9d5c; --pysteps: #c77a00; --unet: #d23c3c; --axial: #7a52d1;
  --fig: #070b14;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 56px; }
html, body { margin: 0; background: var(--bg); color: var(--fg);
  font: 17px/1.65 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-text-size-adjust: 100%; }
a { color: var(--accent); }

header.bar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 12px;
  padding: calc(8px + env(safe-area-inset-top)) 16px 8px; background: rgba(255,255,255,.92);
  border-bottom: 1px solid var(--line); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
header.bar .brand { font-weight: 700; white-space: nowrap; }
header.bar .brand span { color: var(--accent); }
header.bar nav { margin-left: auto; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
header.bar nav::-webkit-scrollbar { display: none; }
header.bar nav a { font-size: 13px; text-decoration: none; color: var(--fg); border: 1px solid var(--line);
  padding: 3px 10px; border-radius: 999px; white-space: nowrap; background: #fff; }
header.bar nav a.on { background: var(--accent); color: #fff; border-color: var(--accent); }
#progress { position: fixed; top: 0; left: 0; height: 3px; width: 0; z-index: 11; background: var(--accent); }

main { max-width: 760px; margin: 0 auto; padding: 8px 20px 40px; }
section { padding: 28px 0 12px; border-bottom: 1px solid var(--line); }
section:last-of-type { border-bottom: 0; }
h1 { font-size: 36px; line-height: 1.15; margin: 8px 0 12px; }
h2 { font-size: 26px; line-height: 1.25; margin: 0 0 10px; }
.kicker { font-size: 12px; text-transform: uppercase; letter-spacing: .14em; color: var(--accent); font-weight: 700; }
.lede { font-size: 19px; color: var(--muted); }
.muted { color: var(--muted); font-size: 15px; }
.tldr { background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 10px; padding: 12px 16px; margin: 16px 0; }
.analogy { background: #eef3ff; border-radius: 10px; padding: 10px 14px; margin: 14px 0; font-size: 16px; }
.analogy b:first-child { color: var(--accent); }
.cite { font-size: 15px; color: var(--muted); border-left: 3px solid var(--line); padding-left: 12px; margin: 12px 0; font-style: italic; }
ul.clean { padding-left: 20px; } ul.clean li { margin-bottom: 6px; }
.tag { font-weight: 600; }
.t-truth { color: var(--truth); } .t-dgmr { color: var(--dgmr); } .t-pysteps { color: var(--pysteps); } .t-unet { color: var(--unet); } .t-axial { color: var(--axial); }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 16px 0; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.stat b { display: block; font-size: 20px; color: var(--accent); line-height: 1.25; }
.stat span { font-size: 12px; color: var(--muted); line-height: 1.3; display: block; }

/* three.js illustrations */
figure.illus { margin: 18px 0; background: var(--fig); border-radius: 14px; overflow: hidden; box-shadow: 0 6px 24px rgba(16,24,40,.12); }
figure.illus .view { position: relative; width: 100%; aspect-ratio: 16 / 9; touch-action: pan-y; cursor: grab; }
figure.illus .view:active { cursor: grabbing; }
figure.illus.tall .view { aspect-ratio: 4 / 3; }
figure.illus canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
figure.illus figcaption { color: #b9c3d6; font-size: 13.5px; line-height: 1.45; padding: 10px 14px 12px; border-top: 1px solid rgba(255,255,255,.08); }
figure.illus figcaption b { color: #fff; }
figure.illus .hint { position: absolute; right: 10px; bottom: 8px; font-size: 11px; color: rgba(255,255,255,.45); pointer-events: none; }
.no-webgl figure.illus .view::after { content: "3D illustration needs WebGL"; position: absolute; inset: 0; display: grid; place-items: center; color: #9aa6bd; font-size: 14px; }

/* bar chart */
.bars { margin: 14px 0; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.bars .row { display: grid; grid-template-columns: 96px 1fr 44px; align-items: center; gap: 10px; font-size: 15px; margin: 4px 0; }
.bars .track { height: 12px; background: #eceff4; border-radius: 6px; overflow: hidden; }
.bars .fill { height: 100%; width: var(--w); border-radius: 6px; }

/* playground controls */
.controls { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-top: -6px; }
.seg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.seg button, .btn { font: inherit; font-size: 15px; padding: 6px; border-radius: 8px; border: 1px solid var(--line);
  background: #fff; color: var(--fg); cursor: pointer; min-height: 40px; }
.seg button.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.lead { display: flex; justify-content: space-between; align-items: baseline; margin: 12px 0 0; }
.lead b { font-size: 20px; font-variant-numeric: tabular-nums; }
input[type=range] { width: 100%; accent-color: var(--accent); height: 30px; }
.row2 { display: flex; gap: 8px; }
.row2 .btn { flex: 1; }
.legend { height: 8px; border-radius: 4px; margin-top: 12px;
  background: linear-gradient(90deg, #0a2a6b, #1e7fd8, #35d6c4, #b6f03c, #ffd23c, #ff7a2f, #e8306b); }
.legend-lbl { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }
#explain { font-size: 15px; margin: 10px 0 0; min-height: 4.5em; }

footer { max-width: 760px; margin: 0 auto; padding: 20px 20px calc(30px + env(safe-area-inset-bottom)); color: var(--muted); font-size: 13px; }

@media (max-width: 760px) {
  html, body { font-size: 16px; }
  main { padding: 4px 14px 30px; }
  h1 { font-size: 28px; } h2 { font-size: 22px; } .lede { font-size: 17px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  figure.illus { margin: 14px -14px; border-radius: 0; }      /* full-bleed on phones */
  figure.illus .view, figure.illus.tall .view { aspect-ratio: 1 / 1; }
  figure.illus.wide .view { aspect-ratio: 4 / 3; }
  .controls { border-radius: 0; margin: -14px -14px 0; border-left: 0; border-right: 0; }
  .bars .row { grid-template-columns: 82px 1fr 40px; }
}
