:root {
  --bg: #f5f8f7;
  --surface: #ffffff;
  --surface-2: #eef3f1;
  --text: #0f1f1c;
  --muted: #5a6a66;
  --line: #dbe4e1;
  --accent: #0d7a83;
  --accent-ink: #ffffff;
  --water: #2f7fd1;
  --warn: #c97a1f;
  --danger: #c4423a;
  --ok: #2f8f5b;

  /* model palette */
  --sky-top: #a9d8f0;
  --sky-bottom: #e6f4fa;
  --sun: #f6c445;
  --cloud: #ffffff;
  --cloud-rain: #8a99a6;
  --rain: rgba(60, 120, 190, 0.55);
  --sand: #e3cc98;
  --sand-dot: #c9ad72;
  --sat: rgba(47, 127, 209, 0.40);
  --clay: #9a6a4c;
  --clay-line: #86583d;
  --gravel: #b5a184;
  --gravel-dot: #8f7c61;
  --confined-water: rgba(47, 110, 190, 0.28);
  --bedrock: #5d6166;
  --bedrock-dot: #4c5055;
  --grass: #5c9e52;
  --river: #3a86d6;
  --particle: rgba(255, 255, 255, 0.9);
  --plume: #f08a24;
  --casing: #50585e;
  --model-ink: #13232a;
  --label-bg: rgba(255, 255, 255, 0.78);
  --focus: #ffb100;
  --hill-far: #bcdccd;
  --hill-near: #a3cc9c;
  --topsoil: #8a6a45;
  --sat-top: rgba(90, 165, 240, 0.32);
  --sat-deep: rgba(28, 88, 180, 0.58);
  --house: #f4eee3;
  --roof: #c2583f;
  --window: rgba(70, 115, 160, 0.6);
  --trunk: #7a5434;
  --star: #ffffff;

  --radius: 16px;
  --shadow: 0 1px 2px rgba(15, 31, 28, 0.06), 0 8px 24px rgba(15, 31, 28, 0.06);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c1413;
    --surface: #121e1c;
    --surface-2: #172624;
    --text: #e4eeeb;
    --muted: #9db0ab;
    --line: #233330;
    --accent: #3cbcbc;
    --accent-ink: #062120;
    --water: #5aa3ec;
    --warn: #e39a45;
    --danger: #e56a60;
    --ok: #4fbf82;

    --sky-top: #081626;
    --sky-bottom: #1b3350;
    --sun: #e9eef5;
    --cloud: #3b4a5c;
    --cloud-rain: #2a3442;
    --rain: rgba(130, 180, 240, 0.5);
    --sand: #5f4f35;
    --sand-dot: #4c3f2a;
    --sat: rgba(70, 150, 235, 0.42);
    --clay: #5a3a2a;
    --clay-line: #4a2f22;
    --gravel: #4b4336;
    --gravel-dot: #3b342a;
    --confined-water: rgba(70, 140, 230, 0.26);
    --bedrock: #262a2f;
    --bedrock-dot: #1d2125;
    --grass: #2f6b3c;
    --river: #3a7cc4;
    --particle: rgba(200, 230, 255, 0.85);
    --plume: #ff9a3c;
    --casing: #9aa5ad;
    --model-ink: #e4eeeb;
    --label-bg: rgba(10, 20, 28, 0.72);
    --focus: #ffc23d;
  --hill-far: #132838;
  --hill-near: #17352c;
  --topsoil: #3e2f1f;
  --sat-top: rgba(80, 160, 240, 0.30);
  --sat-deep: rgba(36, 105, 215, 0.58);
  --house: #3b424b;
  --roof: #7a3a2c;
  --window: #ffcf5a;
  --trunk: #4a3422;
  --star: #dfe8f5;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.25);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0c1413;
  --surface: #121e1c;
  --surface-2: #172624;
  --text: #e4eeeb;
  --muted: #9db0ab;
  --line: #233330;
  --accent: #3cbcbc;
  --accent-ink: #062120;
  --water: #5aa3ec;
  --warn: #e39a45;
  --danger: #e56a60;
  --ok: #4fbf82;
  --sky-top: #081626;
  --sky-bottom: #1b3350;
  --sun: #e9eef5;
  --cloud: #3b4a5c;
  --cloud-rain: #2a3442;
  --rain: rgba(130, 180, 240, 0.5);
  --sand: #5f4f35;
  --sand-dot: #4c3f2a;
  --sat: rgba(70, 150, 235, 0.42);
  --clay: #5a3a2a;
  --clay-line: #4a2f22;
  --gravel: #4b4336;
  --gravel-dot: #3b342a;
  --confined-water: rgba(70, 140, 230, 0.26);
  --bedrock: #262a2f;
  --bedrock-dot: #1d2125;
  --grass: #2f6b3c;
  --river: #3a7cc4;
  --particle: rgba(200, 230, 255, 0.85);
  --plume: #ff9a3c;
  --casing: #9aa5ad;
  --model-ink: #e4eeeb;
  --label-bg: rgba(10, 20, 28, 0.72);
  --focus: #ffc23d;
  --hill-far: #132838;
  --hill-near: #17352c;
  --topsoil: #3e2f1f;
  --sat-top: rgba(80, 160, 240, 0.30);
  --sat-deep: rgba(36, 105, 215, 0.58);
  --house: #3b424b;
  --roof: #7a3a2c;
  --window: #ffcf5a;
  --trunk: #4a3422;
  --star: #dfe8f5;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
h1, h2, h3 { line-height: 1.15; margin: 0; }
button { font: inherit; color: inherit; }

.container { width: 100%; max-width: 1240px; margin: 0 auto; padding: 0 16px; }
@media (min-width: 720px) { .container { padding: 0 28px; } }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.header-inner { display: flex; align-items: center; gap: 24px; height: 60px; }
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--water); font-weight: 500; }
.brand svg { flex: none; }
.brand span { color: var(--text); letter-spacing: -0.01em; }
.brand b { color: var(--accent); font-weight: 700; }
.nav { display: none; gap: 22px; margin-left: auto; font-size: 14.5px; }
.nav a { text-decoration: none; color: var(--muted); }
.nav a:hover { color: var(--text); }
.header-inner .btn { margin-left: auto; }
@media (min-width: 820px) {
  .nav { display: flex; }
  .header-inner .btn { margin-left: 0; }
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--accent); color: var(--accent-ink);
  border: 1px solid var(--accent); border-radius: 999px;
  padding: 10px 18px; font-weight: 600; font-size: 14.5px;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: transform .15s ease, opacity .15s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: .4; cursor: default; transform: none; }
.btn.small { padding: 7px 14px; font-size: 13.5px; }
.btn.ghost { background: transparent; color: var(--text); border-color: var(--line); }
.btn.full { width: 100%; }

.eyebrow {
  margin: 0 0 10px; font-size: 12.5px; font-weight: 600;
  letter-spacing: .12em; text-transform: uppercase; color: var(--accent);
}
.section-title { font-family: Fraunces, Georgia, serif; font-size: clamp(26px, 3.4vw, 36px); margin-bottom: 28px; }

/* ---------- Hero ---------- */
.hero { padding: 40px 0 56px; }
.hero-copy { max-width: 760px; margin-bottom: 28px; }
.hero h1 {
  font-family: Fraunces, Georgia, serif; font-weight: 700;
  font-size: clamp(32px, 5vw, 54px); letter-spacing: -0.02em;
}
.hero h1 em { font-style: normal; color: var(--water); }
.hero h1 em + em, .hero h1 em:last-child { color: var(--accent); }
.hero-cta { margin: 20px 0 0; }
.lede { color: var(--muted); font-size: clamp(16px, 1.6vw, 18.5px); margin: 16px 0 0; max-width: 680px; }

.model-shell { display: grid; gap: 20px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 1040px) { .model-shell { grid-template-columns: minmax(0, 1fr) 320px; } }

.stage-col { display: grid; gap: 16px; min-width: 0; }
.stage {
  position: relative; border-radius: var(--radius); overflow: hidden;
  border: 1px solid var(--line); box-shadow: var(--shadow);
  background: var(--sky-bottom);
}
.stage canvas { display: block; width: 100%; touch-action: pan-y; cursor: pointer; }

.hud { position: absolute; top: 10px; left: 10px; display: flex; flex-wrap: wrap; gap: 6px; pointer-events: none; max-width: calc(100% - 64px); }
.hud-chip {
  display: flex; align-items: baseline; gap: 6px;
  background: var(--label-bg); color: var(--model-ink);
  backdrop-filter: blur(6px);
  border-radius: 999px; padding: 4px 10px; font-size: 12px;
}
.hud-chip span { opacity: .75; }
.hud-chip strong { font-variant-numeric: tabular-nums; font-size: 13px; }
.trend { font-style: normal; font-size: 12px; font-weight: 600; }
.trend.up { color: var(--ok); }
.trend.down { color: var(--danger); }

.stage-btn {
  position: absolute; top: 10px; right: 10px;
  width: 36px; height: 36px; border-radius: 50%;
  border: none; background: var(--label-bg); color: var(--model-ink);
  display: grid; place-items: center; cursor: pointer; backdrop-filter: blur(6px);
}
.stage-btn .i-play { display: none; }
.stage-btn.paused .i-play { display: block; }
.stage-btn.paused .i-pause { display: none; }
.stage-hint {
  position: absolute; bottom: 8px; right: 10px; margin: 0;
  font-size: 11.5px; color: var(--model-ink); opacity: .7;
  background: var(--label-bg); padding: 2px 8px; border-radius: 999px; pointer-events: none;
}

.tip {
  position: absolute; z-index: 3; max-width: 260px; pointer-events: none;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
  padding: 10px 12px; font-size: 13px; line-height: 1.45;
}
.tip strong { display: block; font-size: 13.5px; margin-bottom: 2px; }

/* ---------- Lesson ---------- */
.lesson {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow);
}
.lesson-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; margin-bottom: 8px; }
.lesson-kicker { white-space: nowrap; font-size: 12.5px; font-weight: 600; color: var(--accent); text-transform: uppercase; letter-spacing: .08em; }
.lesson-dots { display: flex; gap: 6px; }
.lesson-dots button {
  width: 9px; height: 9px; border-radius: 50%; padding: 0; border: none;
  background: var(--line); cursor: pointer;
}
.lesson-dots button[aria-current="step"] { background: var(--accent); width: 22px; border-radius: 999px; }
.lesson h2 { font-family: Fraunces, Georgia, serif; font-size: 22px; margin-bottom: 6px; }
.lesson p { margin: 0 0 14px; color: var(--muted); }
.lesson p b { color: var(--text); font-weight: 600; }
.lesson-nav { display: flex; gap: 10px; justify-content: space-between; }

/* ---------- Panel ---------- */
.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 20px; align-self: start;
}
.panel h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 10px; }
.panel h3 small { text-transform: none; letter-spacing: 0; font-weight: 400; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button {
  border: 1px solid var(--line); background: var(--surface-2);
  border-radius: 999px; padding: 6px 12px; font-size: 13px; cursor: pointer;
}
.chips button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

.range { display: block; margin-bottom: 14px; }
.range-top { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 4px; }
.range output { font-variant-numeric: tabular-nums; color: var(--muted); }
.range input { width: 100%; accent-color: var(--accent); }

.toggle { display: flex; align-items: center; gap: 10px; font-size: 14px; margin-bottom: 12px; cursor: pointer; }
.toggle small { color: var(--muted); }
.toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch {
  flex: none; width: 36px; height: 20px; border-radius: 999px; background: var(--line);
  position: relative; transition: background .2s;
}
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px;
  border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 2px rgba(0,0,0,.25);
}
.toggle input:checked + .switch { background: var(--accent); }
.toggle input:checked + .switch::after { transform: translateX(16px); }
.toggle input:focus-visible + .switch { outline: 2px solid var(--focus); outline-offset: 2px; }

.budget { display: grid; gap: 8px; }
.budget-row { display: grid; grid-template-columns: 34px 1fr; align-items: center; font-size: 13px; color: var(--muted); }
.bar { height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--water); border-radius: 999px; transition: width .4s ease; }
.bar.out i { background: var(--warn); }
.river-status { margin: 10px 0 0; font-size: 13.5px; }
.river-status b.gain { color: var(--ok); }
.river-status b.lose { color: var(--danger); }

.plume-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0; }
.plume-stats div { background: var(--surface-2); border-radius: 10px; padding: 8px 10px; }
.plume-stats dt { font-size: 12px; color: var(--muted); }
.plume-stats dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- Facts ---------- */
.facts { background: var(--surface); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 36px 0; }
.facts-grid { display: grid; gap: 20px; grid-template-columns: 1fr; }
@media (min-width: 760px) { .facts-grid { grid-template-columns: repeat(3, 1fr); } }
.fact strong { display: block; font-family: Fraunces, Georgia, serif; font-size: 40px; color: var(--water); }
.fact span { color: var(--muted); }
.fact-src { grid-column: 1 / -1; margin: 0; font-size: 12.5px; color: var(--muted); }

/* ---------- Paths ---------- */
.paths { padding: 64px 0; }
.path-grid { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .path-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1040px) { .path-grid { grid-template-columns: repeat(4, 1fr); } }
.path-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow); display: flex; flex-direction: column;
}
.path-icon {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  font-weight: 700; font-size: 14px; color: var(--c);
  background: color-mix(in srgb, var(--c) 14%, transparent); margin-bottom: 14px;
}
.path-card h3 { font-size: 18px; margin-bottom: 6px; }
.path-card p { color: var(--muted); margin: 0 0 16px; font-size: 14.5px; flex: 1; }
.meta { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.meta li { font-size: 12px; background: var(--surface-2); border-radius: 999px; padding: 3px 10px; color: var(--muted); }

/* ---------- Quiz ---------- */
.quiz { padding: 56px 0; background: var(--surface); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.quiz-inner { display: grid; gap: 24px; align-items: center; }
@media (min-width: 860px) { .quiz-inner { grid-template-columns: 1fr 1fr; } }
.quiz .section-title { margin-bottom: 12px; }
.quiz-q { font-size: 18px; margin: 0; }
.quiz-options { display: grid; gap: 10px; }
.quiz-options button {
  text-align: left; padding: 14px 16px; border-radius: 12px; cursor: pointer;
  background: var(--bg); border: 1px solid var(--line); font-size: 15px;
}
.quiz-options button.right { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 14%, transparent); }
.quiz-options button.wrong { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, transparent); }
.quiz-feedback { margin: 4px 0 0; min-height: 1.5em; color: var(--muted); font-size: 14.5px; }

/* ---------- Glossary ---------- */
.glossary { padding: 64px 0; }
.gloss-grid { display: grid; gap: 16px; margin: 0; grid-template-columns: 1fr; }
@media (min-width: 720px) { .gloss-grid { grid-template-columns: repeat(3, 1fr); } }
.gloss-grid div { border-left: 3px solid var(--accent); padding: 4px 0 4px 14px; }
.gloss-grid dt { font-weight: 600; }
.gloss-grid dd { margin: 4px 0 0; color: var(--muted); font-size: 14.5px; }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--line); padding: 24px 0; font-size: 13px; color: var(--muted); }
.footer-inner { display: flex; flex-wrap: wrap; gap: 8px 24px; justify-content: space-between; }

@media (max-width: 560px) {
  .header-inner { gap: 12px; }
  .brand { font-size: 15px; min-width: 0; }
  .stage-hint { display: none; }
  /* On phones the readouts sit in a strip under the model instead of covering it */
  .hud {
    position: static; max-width: none; display: grid; grid-template-columns: repeat(3, 1fr);
    padding: 8px; gap: 6px; background: var(--surface); border-top: 1px solid var(--line);
  }
  .hud-chip {
    display: grid; grid-template-columns: auto auto; justify-content: center; align-items: baseline;
    column-gap: 4px; text-align: center;
    font-size: 11px; padding: 4px 6px; border-radius: 10px;
    background: var(--surface-2); color: var(--text); backdrop-filter: none;
  }
  .hud-chip span { grid-column: 1 / -1; white-space: nowrap; }
  .hud-chip strong { font-size: 12px; }
}
@media (max-width: 400px) {
  .brand { font-size: 14px; gap: 6px; }
  .header-inner .btn { padding: 6px 11px; font-size: 12.5px; }
}
