:root {
  --bg: #f6f7f4; --card: #ffffff; --ink: #18211f; --muted: #5d6965; --line: #dde2dd;
  --accent: #0f7c6b; --warn: #a3470d; --danger-bg: #fde8e4; --danger: #9b1c0c;
  --env: #cfd8d4; --band: #5fb3a3; --p50: #0b4f45; --rep: #d9541e;
  --radius: 12px; color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1513; --card: #16201d; --ink: #e5ece9; --muted: #95a39e; --line: #2a3632;
    --accent: #4fc2ad; --danger-bg: #3b1712; --danger: #ffb4a4; --env: #33433e; --band: #3f9c8b; --p50: #b8f0e3;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; }
.wrap { max-width: 1040px; margin: 0 auto; padding: 0 16px; }
h1 { font-size: 1.6rem; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 1.15rem; margin: 0 0 .6rem; display: flex; align-items: center; gap: .4rem; }
section { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin: 16px 0; }
.sub, .muted { color: var(--muted); margin: 0; }
.small { font-size: .85rem; }
header { border-bottom: 1px solid var(--line); background: var(--card); }
.head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding-top: 14px; padding-bottom: 14px; }
.controls { display: flex; gap: 8px; align-items: center; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.seg button { border: 0; background: none; color: var(--ink); padding: 6px 14px; cursor: pointer; font: inherit; }
.seg button[aria-pressed="true"] { background: var(--accent); color: #fff; }
.btn { border: 1px solid var(--accent); color: var(--accent); padding: 6px 14px; border-radius: 999px; text-decoration: none; }
.banner { border-radius: var(--radius); padding: 10px 14px; margin: 16px 0 0; border: 1px solid var(--line); background: var(--card); font-size: .95rem; }
.banner.danger { background: var(--danger-bg); color: var(--danger); border-color: currentColor; }
body:not(.detailed) .detail { display: none; }

.scene-card { padding: 0; overflow: hidden; display: grid; grid-template-columns: 1.7fr 1fr; }
#scene { width: 100%; height: auto; display: block; }
.hill { fill: #2f5d4a; opacity: .85; }
.readout { padding: 18px; display: flex; flex-direction: column; justify-content: center; gap: 4px; }
.now { font-size: 2.6rem; font-weight: 700; margin: 0; display: flex; align-items: baseline; gap: .3rem; font-variant-numeric: tabular-nums; }
.now .unit { font-size: 1.1rem; color: var(--muted); font-weight: 500; }
.scrub { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 10px; font-size: .85rem; }
.scrub select, .scrub input { font: inherit; }
.link { background: none; border: 0; color: var(--accent); cursor: pointer; text-decoration: underline; font: inherit; }
.panel { transition: fill .6s; }
.bob { animation: bob 4s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(1.5px); } }
.ripple { stroke: #fff; stroke-opacity: .25; stroke-width: 1; animation: drift 7s linear infinite; }
@keyframes drift { to { transform: translateX(-40px); } }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; }
.stat { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.stat h3 { font-size: .85rem; font-weight: 500; color: var(--muted); margin: 0; display: flex; gap: .35rem; align-items: center; }
.stat .v { font-size: 1.55rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .r { font-size: .82rem; color: var(--muted); }
.tag { font-size: .7rem; border-radius: 999px; padding: 1px 7px; border: 1px solid currentColor; white-space: nowrap; }
.tag.assumed { color: var(--warn); } .tag.reported { color: var(--accent); } .tag.modelled { color: var(--muted); }

.info { width: 18px; height: 18px; border-radius: 50%; border: 1px solid var(--muted); background: none; color: var(--muted);
  font: italic 600 11px/1 Georgia, serif; cursor: pointer; padding: 0; flex: none; }
#pop { position: fixed; z-index: 20; max-width: 320px; background: var(--card); color: var(--ink); border: 1px solid var(--line);
  border-radius: 10px; padding: 12px 14px; box-shadow: 0 8px 30px rgba(0,0,0,.18); font-size: .9rem; }
#pop p { margin: 0 0 8px; } #pop button { font: inherit; font-size: .8rem; }

.heat { overflow: hidden; border-radius: 8px; }
#heat { width: 100%; height: 200px; display: block; image-rendering: pixelated; }
.legend { display: flex; align-items: center; gap: 8px; font-size: .8rem; color: var(--muted); margin-top: 6px; }
.legend i { flex: 0 1 200px; height: 8px; border-radius: 4px; }

.row { display: grid; grid-template-columns: 220px 1fr; gap: 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.row:first-child { border-top: 0; }
.row .lab b { display: block; }
.bar { position: relative; height: 26px; }
.bar > * { position: absolute; top: 50%; transform: translateY(-50%); }
.bar .env { height: 10px; background: var(--env); border-radius: 5px; }
.bar .band { height: 10px; background: var(--band); border-radius: 5px; }
.bar .p50 { width: 2px; height: 18px; background: var(--p50); }
.bar .rep { width: 12px; height: 12px; background: var(--rep); transform: translate(-50%, -50%) rotate(45deg); }
.bar .claim { height: 4px; background: var(--rep); opacity: .55; }
.verdict { grid-column: 2; font-size: .85rem; color: var(--muted); margin-top: -4px; }
.key { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 8px; }
.k { display: inline-block; width: 14px; height: 8px; border-radius: 4px; margin-right: 5px; vertical-align: middle; }
.k.env { background: var(--env); } .k.band { background: var(--band); } .k.p50 { background: var(--p50); width: 3px; } .k.rep { background: var(--rep); width: 8px; height: 8px; transform: rotate(45deg); }

#monthly { width: 100%; height: auto; }
#monthly text { fill: var(--muted); font-size: 11px; }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: .85rem; }
th, td { text-align: left; padding: 6px 8px; border-top: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 500; }
.sources { padding-left: 1.1rem; font-size: .9rem; }
footer { padding-bottom: 32px; }

#loader { position: fixed; inset: 0; z-index: 30; background: #071311; transition: opacity .7s; }
#loader.done { opacity: 0; pointer-events: none; }
#map { width: 100%; height: 100%; display: block; }
#loader-label { position: absolute; left: 50%; bottom: 14%; transform: translateX(-50%); color: #bfeee4; letter-spacing: .2em;
  text-transform: uppercase; font-size: .8rem; opacity: 0; transition: opacity .6s; }
#skip { position: absolute; right: 16px; bottom: 16px; background: none; border: 1px solid #3b6b62; color: #bfeee4; border-radius: 999px; padding: 4px 12px; cursor: pointer; }

@media (max-width: 760px) {
  .scene-card { grid-template-columns: 1fr; }
  .row { grid-template-columns: 1fr; }
  .verdict { grid-column: 1; }
  #heat { height: 160px; }
}
@media (prefers-reduced-motion: reduce) { .bob, .ripple { animation: none; } }

/* v0.2 additions */
.tag.inference { color: #7a4fb0; }
@media (prefers-color-scheme: dark) { .tag.inference { color: #c3a2ef; } }
.fn { font-size: .62em; margin-left: 1px; line-height: 0; }
.fn a { color: var(--accent); text-decoration: none; padding: 0 1px; }
.fn a:hover { text-decoration: underline; }
summary { cursor: pointer; list-style: none; }
summary::-webkit-details-marker { display: none; }
summary h2 { display: inline-flex; margin: 0; }
summary h2::before { content: "▸"; color: var(--muted); font-size: .8em; margin-right: .2rem; transition: transform .2s; }
details[open] > summary h2::before { transform: rotate(90deg); }
details[open] > summary { margin-bottom: .6rem; }
section > details > summary { margin: -4px 0; }
h3 { font-size: .95rem; margin: 1rem 0 .4rem; }
.note { border-left: 3px solid var(--rep); padding: 6px 10px; margin: 10px 0 0; }
.seg.mini { margin-top: 8px; font-size: .75rem; }
.seg.mini button { padding: 3px 8px; }
.arith { font-size: .78rem; margin-top: 6px; }
.arith summary { color: var(--accent); }
.arith ol { margin: 4px 0 0; padding-left: 1.1rem; color: var(--muted); }
.bar .rep.hollow { background: none; border: 2px solid var(--rep); }
body.synthetic #score .band, body.synthetic #score .p50 { background: var(--env); opacity: .5; }
body.synthetic #score .verdict { opacity: .7; }
.wf { display: grid; grid-template-columns: 220px 1fr 60px 56px; gap: 10px; align-items: center; font-size: .85rem; padding: 3px 0; }
.wfbar { height: 12px; background: var(--line); border-radius: 6px; overflow: hidden; }
.wfbar i { display: block; height: 100%; background: var(--band); }
.wf b { text-align: right; font-variant-numeric: tabular-nums; }
.wf em { font-style: normal; font-size: .78rem; text-align: right; }
.wf em.neg { color: var(--warn); } .wf em.pos { color: var(--accent); }
.tor { display: grid; grid-template-columns: 220px 1fr; gap: 4px 10px; align-items: center; font-size: .85rem; padding: 4px 0; }
.tor small { grid-column: 2; color: var(--muted); }
.torbar { position: relative; height: 14px; background: linear-gradient(var(--line), var(--line)) 50% 0 / 1px 100% no-repeat; }
.torbar i { position: absolute; top: 0; height: 100%; border-radius: 3px; }
.torbar i.neg { background: var(--rep); opacity: .75; } .torbar i.pos { background: var(--band); }
#monthly text, #hydro text { fill: var(--muted); font-size: 11px; }
#monthly .wet { fill: #4a90c2; opacity: .12; } #monthly .dry { fill: #d9a441; opacity: .14; }
#monthly .period { stroke: var(--rep); stroke-width: 2; }
#hydro { width: 100%; height: auto; }
#hydro .peak { fill: #4a90c2; opacity: .15; } #hydro .pv { fill: var(--band); opacity: .8; }
.lab { border-top: 1px solid var(--line); margin-top: 12px; }
.lab-row { display: grid; grid-template-columns: 120px 1fr 90px; gap: 10px; align-items: center; font-size: .85rem; margin: 6px 0; }
.lab-row output { font-variant-numeric: tabular-nums; }
.reservoir { margin-top: 12px; }
#res-scene svg { width: 100%; max-width: 520px; display: block; border-radius: 8px; }
#res-scene .lake { transition: transform .3s; }
.sources li { margin: 6px 0; scroll-margin-top: 80px; border-radius: 6px; }
.sources li.flash { animation: flash 1.6s; }
@keyframes flash { 0%, 40% { background: color-mix(in srgb, var(--accent) 22%, transparent); } }
#hardware th, #hydro-facts th { width: 160px; }
@media (max-width: 760px) {
  .wf { grid-template-columns: 1fr 52px 48px; } .wf span { grid-column: 1 / -1; }
  .tor { grid-template-columns: 1fr; } .tor small { grid-column: 1; }
  .lab-row { grid-template-columns: 90px 1fr 70px; }
}
summary:not(:has(h2))::before { content: "▸ "; color: var(--muted); }
details[open] > summary:not(:has(h2))::before { content: "▾ "; }
