/* Layout: cool snow-grey ground, one centered column; overview = scannable resort rows,
   detail = model heatmap (rows = models, columns = days) + ensemble fan + links.
   Accent is ski-patrol red, used only for interaction; snow amounts use a blue→violet scale. */
:root {
  --bg: #eef2f4;
  --surface: #ffffff;
  --ink: #10202b;
  --muted: #5b6c77;
  --line: #d4dde3;
  --accent: #c2362b;
  --accent-ink: #ffffff;
  --sel: #10202b;
  --sel-ink: #ffffff;

  --s0: #f4f7f9;
  --s1: #e1edfa;
  --s2: #c0d8f5;
  --s3: #8db8ec;
  --s4: #578ddd;
  --s5: #3b5fc4;
  --s6: #5a3eb0;
  --s-ink-hi: #ffffff;

  --h1: #b7c4ce;
  --h2: #7d9cc0;
  --h3: #33568f;

  --ok: #1f7a4d;
  --ok-bg: #e2f2e9;
  --warn: #9a5b00;
  --warn-bg: #fbedd3;
  --bad: #a3271f;
  --bad-bg: #f9dfdc;

  --f-display: "Barlow Condensed", "Arial Narrow", "Noto Sans SC", sans-serif;
  --f-body: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

  --r: 10px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c151b; --surface: #131f27; --ink: #e4edf2; --muted: #93a5b0; --line: #24343f;
    --accent: #ff6b5c; --accent-ink: #1a0b09; --sel: #e4edf2; --sel-ink: #0c151b;
    --s0: #111c23; --s1: #16293a; --s2: #1b3a59; --s3: #224f86; --s4: #2f69bb; --s5: #4a6fdc; --s6: #7657dc; --s-ink-hi: #ffffff;
    --h1: #3a4a56; --h2: #5a7da6; --h3: #9cc0ee;
    --ok: #6fd3a0; --ok-bg: #12301f; --warn: #f2b45a; --warn-bg: #3a2810; --bad: #ff8a7d; --bad-bg: #3d1714;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0c151b; --surface: #131f27; --ink: #e4edf2; --muted: #93a5b0; --line: #24343f;
  --accent: #ff6b5c; --accent-ink: #1a0b09; --sel: #e4edf2; --sel-ink: #0c151b;
  --s0: #111c23; --s1: #16293a; --s2: #1b3a59; --s3: #224f86; --s4: #2f69bb; --s5: #4a6fdc; --s6: #7657dc; --s-ink-hi: #ffffff;
  --h1: #3a4a56; --h2: #5a7da6; --h3: #9cc0ee;
  --ok: #6fd3a0; --ok-bg: #12301f; --warn: #f2b45a; --warn-bg: #3a2810; --bad: #ff8a7d; --bad-bg: #3d1714;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.6 var(--f-body);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
a { color: inherit; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.wrap {
  max-width: 1120px;
  margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}

/* ── top bar ── */
body::before {
  content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px);
  background: var(--bg); z-index: 20;
}
.topbar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 10;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding-block: 10px;
}
.brand {
  display: flex; align-items: center; gap: 8px; text-decoration: none;
  font: 700 22px/1 var(--f-display); letter-spacing: .02em; text-transform: uppercase;
}
.brand-mark { width: 26px; height: 26px; fill: var(--ink); }
.brand-mark .cap { fill: var(--bg); }
.controls { display: flex; align-items: center; gap: 8px; }
.seg {
  display: inline-flex; border: 1px solid var(--line); border-radius: 999px; padding: 2px;
  background: var(--surface);
}
.seg button {
  border: 0; background: transparent; padding: 4px 12px; border-radius: 999px; cursor: pointer;
  font-size: 13px; color: var(--muted);
}
.seg button[aria-pressed="true"] { background: var(--sel); color: var(--sel-ink); }
.btn-ghost {
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px;
  padding: 5px 12px; font-size: 13px; cursor: pointer;
}
.btn-ghost:hover, .seg button:hover { color: var(--ink); }
.btn-ghost:disabled { opacity: .5; cursor: progress; }

main { padding-block: 20px 8px; min-height: 60vh; }
.loading, .muted { color: var(--muted); }
.loading { padding: 32px 0; }

h1, h2, h3 { text-wrap: balance; margin: 0; }
h1 { font: 700 clamp(30px, 5vw, 44px)/1.05 var(--f-display); letter-spacing: .01em; }
h2 { font: 600 24px/1.2 var(--f-display); letter-spacing: .02em; }
h3 { font: 600 16px/1.3 var(--f-body); }
.eyebrow {
  font: 600 13px/1 var(--f-display); text-transform: uppercase; letter-spacing: .12em; color: var(--muted);
}
.num { font-family: var(--f-mono); font-variant-numeric: tabular-nums; }

/* ── overview ── */
.lead {
  display: grid; gap: 6px; padding: 18px 20px; margin-bottom: 20px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
}
.lead p { margin: 0; }
.lead strong { font-weight: 700; }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin: 4px 0 10px; }
.notice {
  font-size: 13px; color: var(--warn); background: var(--warn-bg); border-radius: 8px; padding: 6px 10px; margin: 0 0 12px;
}

.region { margin: 22px 0 6px; }
.region h2 { margin-bottom: 6px; }
.rows { display: grid; gap: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.row-head, .row {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) repeat(3, minmax(64px, .55fr)) minmax(120px, 1fr) 92px;
  gap: 12px; align-items: center; padding: 10px 16px;
}
.row-head {
  font: 600 12px/1.2 var(--f-display); letter-spacing: .1em; text-transform: uppercase; color: var(--muted);
  border-bottom: 1px solid var(--line); background: var(--s0);
}
.row { text-decoration: none; border-top: 1px solid var(--line); }
.row:first-of-type { border-top: 0; }
.row-head + .row { border-top: 0; }
.row:hover { background: var(--s0); }
.row:hover .r-name { color: var(--accent); }
.r-name { font-weight: 700; min-width: 0; }
.r-meta { display: block; font-size: 12px; color: var(--muted); font-weight: 400; }
.r-pass {
  display: inline-block; font: 600 11px/1 var(--f-display); letter-spacing: .08em; text-transform: uppercase;
  border: 1px solid var(--line); border-radius: 4px; padding: 2px 5px; margin-left: 6px; vertical-align: 2px; color: var(--muted);
}
.amt { display: flex; flex-direction: column; align-items: flex-start; }
.amt .v { font: 700 22px/1 var(--f-display); font-variant-numeric: tabular-nums; }
.amt .v small { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 1px; }
.amt .rng { font: 11px/1.3 var(--f-mono); color: var(--muted); }
.amt .lbl { display: none; }
.spark { width: 100%; height: 30px; display: block; }
.spark rect { fill: var(--s4); }
.spark rect.zero { fill: var(--line); }
.spark line { stroke: var(--line); }

.chip {
  display: inline-block; font-size: 12px; line-height: 1; padding: 5px 8px; border-radius: 999px; white-space: nowrap;
}
.chip.ok { color: var(--ok); background: var(--ok-bg); }
.chip.warn { color: var(--warn); background: var(--warn-bg); }
.chip.bad { color: var(--bad); background: var(--bad-bg); }
.chip.none { color: var(--muted); background: var(--s0); border: 1px solid var(--line); }

/* confidence meter: three bars like a signal indicator */
.conf { display: inline-flex; align-items: flex-end; gap: 2px; font-size: 13px; line-height: 1; }
.conf i { display: block; width: 4px; border-radius: 1px; background: var(--line); }
.conf i:nth-child(1) { height: 6px; } .conf i:nth-child(2) { height: 10px; } .conf i:nth-child(3) { height: 14px; }
.conf b { margin-left: 6px; font-weight: 600; }
.conf.c3 i { background: var(--ok); } .conf.c3 b { color: var(--ok); }
.conf.c2 i:nth-child(-n+2) { background: var(--warn); } .conf.c2 b { color: var(--warn); }
.conf.c1 i:nth-child(1) { background: var(--bad); } .conf.c1 b { color: var(--bad); }
.conf.c0 b { color: var(--muted); font-weight: 400; }
.howto { margin: 6px 0 0; padding-left: 1.1em; font-size: 13px; color: var(--muted); }
.howto li { margin-bottom: 2px; }
.howto b { color: var(--ink); font-weight: 600; }
.ens-sum { margin: 0 0 16px; padding: 10px 14px; border-radius: 8px; background: var(--s0); border: 1px solid var(--line); max-width: 80ch; }
.ens-sum b { font-family: var(--f-mono); }
.ctl-lbl { font-size: 12.5px; color: var(--muted); min-width: 4.5em; }
.rec {
  display: inline-block; margin-left: 6px; padding: 1px 5px; border-radius: 4px; font-size: 10.5px; line-height: 1.4;
  background: var(--ok-bg); color: var(--ok); vertical-align: 1px;
}
.seg button[aria-pressed="true"] .rec { background: var(--sel-ink); color: var(--sel); }
.src-note { margin: -4px 0 14px; font-size: 13px; color: var(--muted); max-width: 80ch; }
.bars-h { font-size: 14px; margin: 14px 0 2px; }
.bars { width: 100%; height: auto; display: block; }
.bars text { fill: var(--muted); font: 11px var(--f-mono); }
.bars text.bv { fill: var(--ink); font-weight: 500; }
.bars text.bv.top { font-weight: 700; }
.bars .base { stroke: var(--line); }
.bars.b-pow rect { fill: var(--s3); }
.bars.b-pow rect.top { fill: var(--s6); }
.bars.b-amt rect { fill: var(--s2); }
.bars.b-amt rect.top { fill: var(--s4); }

@media (max-width: 760px) {
  .row-head { display: none; }
  .row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-template-areas: "name name chip" "a1 a2 a3" "spark spark spark";
    row-gap: 8px;
  }
  .r-name { grid-area: name; }
  .r-chip { grid-area: chip; justify-self: end; }
  .a1 { grid-area: a1; } .a2 { grid-area: a2; } .a3 { grid-area: a3; }
  .r-spark { grid-area: spark; }
  .amt .lbl { display: block; font-size: 11px; color: var(--muted); margin-bottom: 2px; }
}

/* ── detail ── */
.back { display: inline-block; margin-bottom: 10px; font-size: 14px; color: var(--muted); text-decoration: none; }
.back:hover { color: var(--accent); }
.d-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 12px 24px; margin-bottom: 18px; }
.d-head .facts { display: flex; gap: 20px; flex-wrap: wrap; }
.fact .k { display: block; font-size: 12px; color: var(--muted); }
.fact .v { font: 600 20px/1.1 var(--f-display); font-variant-numeric: tabular-nums; }

.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  padding: 18px 20px; margin-bottom: 18px;
}
.panel > h2 { margin-bottom: 4px; }
.panel > .sub { color: var(--muted); font-size: 13.5px; margin: 0 0 14px; max-width: 72ch; }

.scroller { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -20px; padding: 0 20px; }
table.grid { border-collapse: separate; border-spacing: 2px; font-size: 13px; min-width: 100%; }
table.grid th, table.grid td { text-align: center; white-space: nowrap; }
table.grid thead th { font-weight: 500; color: var(--muted); padding: 2px 0 6px; min-width: 44px; line-height: 1.25; }
table.grid thead th .dow { display: block; font: 600 14px/1.1 var(--f-display); color: var(--ink); letter-spacing: .04em; }
table.grid thead th.wk .dow { color: var(--accent); }
table.grid th.mname {
  position: sticky; left: 0; z-index: 1; background: var(--surface); text-align: left;
  padding: 0 10px 0 0; font-weight: 600; min-width: 108px;
}
table.grid th.mname small { display: block; font-weight: 400; color: var(--muted); font-size: 11px; }
table.grid td.c {
  font-family: var(--f-mono); font-variant-numeric: tabular-nums; height: 34px; min-width: 44px;
  border-radius: 5px; background: var(--s0); color: var(--ink);
}
/* level classes need the table prefix so they beat the base `table.grid td.c` background */
table.grid td.c.na { background: transparent; color: var(--muted); }
table.grid td.c.l1 { background: var(--s1); }
table.grid td.c.l2 { background: var(--s2); }
table.grid td.c.l3 { background: var(--s3); }
table.grid td.c.l4 { background: var(--s4); color: var(--s-ink-hi); }
table.grid td.c.l5 { background: var(--s5); color: var(--s-ink-hi); }
table.grid td.c.l6 { background: var(--s6); color: var(--s-ink-hi); }
tr.median th.mname, tr.median td.c { font-weight: 700; }
tr.median td.c { box-shadow: inset 0 0 0 1.5px var(--ink); }
tr.sep th, tr.sep td { padding-top: 10px; }
table.grid td.c.sl-snow { background: var(--s1); color: var(--ink); }
table.grid td.c.sl-mixed { background: var(--warn-bg); color: var(--warn); font-weight: 600; }
table.grid td.c.sl-rain { background: var(--bad-bg); color: var(--bad); font-weight: 600; }
table.grid td.c.dry { background: transparent; color: var(--muted); }
table.grid td.c.pr { background: transparent; color: var(--muted); }

.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 12px; font-size: 12px; color: var(--muted); align-items: center; }
.legend .sw { display: inline-flex; align-items: center; gap: 5px; }
.legend i { display: inline-block; width: 14px; height: 14px; border-radius: 3px; }

.prob { border-collapse: separate; border-spacing: 3px; font-size: 14px; }
.prob th { font-weight: 500; color: var(--muted); padding: 4px 8px; text-align: center; white-space: nowrap; }
.prob th[scope="row"] { text-align: left; color: var(--ink); font-weight: 600; }
.prob td {
  text-align: center; padding: 8px 10px; min-width: 64px; border-radius: 6px;
  font: 600 16px/1 var(--f-mono); font-variant-numeric: tabular-nums;
}
.prob td small { display: block; font: 400 10.5px/1.3 var(--f-mono); color: inherit; opacity: .8; margin-top: 3px; }
.ens-wrap { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 24px; align-items: start; }
@media (max-width: 860px) { .ens-wrap { grid-template-columns: minmax(0, 1fr); } }
.fan { width: 100%; height: auto; display: block; }
.fan .grid-l { stroke: var(--line); stroke-width: 1; }
.fan text { fill: var(--muted); font: 11px var(--f-mono); }
.fan .b90 { fill: var(--s2); }
.fan .b50 { fill: var(--s3); }
.fan .med { stroke: var(--s6); stroke-width: 2.5; fill: none; }
.fan .mm { stroke: var(--ink); stroke-width: 1.2; fill: none; stroke-dasharray: 3 3; opacity: .55; }
details.more { margin-top: 12px; font-size: 13px; }
details.more summary { cursor: pointer; color: var(--muted); }
details.more table { margin-top: 8px; }

.links { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.links a {
  display: block; padding: 12px 14px; border: 1px solid var(--line); border-radius: 8px; text-decoration: none;
  background: var(--surface);
}
.links a:hover { border-color: var(--accent); }
.links a b { display: block; font-weight: 600; }
.links a span { font-size: 12.5px; color: var(--muted); }

.horizon { width: 100%; border-collapse: collapse; font-size: 14px; }
.horizon th, .horizon td { text-align: left; padding: 8px 10px 8px 0; border-top: 1px solid var(--line); vertical-align: top; }
.horizon th { white-space: nowrap; font-weight: 600; }
.notes { margin: 12px 0 0; padding-left: 1.2em; font-size: 14px; max-width: 75ch; }
.notes li { margin-bottom: 6px; }

.err { color: var(--bad); font-size: 13px; }

/* ── nav ── */
.tabs { display: flex; gap: 2px; margin-right: auto; margin-left: 8px; }
.tabs a {
  text-decoration: none; padding: 5px 10px; border-radius: 6px; font-size: 14px; color: var(--muted);
}
.tabs a:hover { color: var(--ink); }
.tabs a[aria-current="true"] { color: var(--ink); font-weight: 700; box-shadow: inset 0 -2px 0 var(--accent); border-radius: 0; }
@media (max-width: 560px) {
  .tabs { order: 3; width: 100%; margin: 0; }
  .tabs a { flex: 1; text-align: center; }
}
.crosslinks { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: -6px 0 16px; font-size: 14px; }
.crosslinks a { color: var(--accent); text-decoration: none; }
.crosslinks a:hover { text-decoration: underline; }

/* ── history & backtest controls ── */
.hctl { display: flex; flex-wrap: wrap; gap: 8px 10px; align-items: center; margin-bottom: 12px; }
.hctl .seg { flex-wrap: wrap; border-radius: 14px; }
.pick {
  font: inherit; font-size: 14px; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); max-width: 100%;
}
.hchart-wrap { position: relative; margin: 6px 0 14px; }
.hchart, .skchart { width: 100%; height: auto; display: block; touch-action: pan-y; }
.hchart text, .skchart text { fill: var(--muted); font: 11px var(--f-mono); }
.hchart .unit { font-size: 10px; }
.hchart .g, .skchart .g { stroke: var(--line); stroke-width: 1; }
.hchart .g.v { stroke-dasharray: 2 3; }
.skchart .g.zero { stroke: var(--muted); }
.hchart .ln { fill: none; stroke-width: 1.8; stroke-linejoin: round; }
.hchart .ln.cur { stroke-width: 3; }
.hchart .hover { stroke: var(--muted); stroke-width: 1; }
.skchart .sk { fill: none; stroke-width: 1.6; opacity: .85; }
.skchart .sk.med { stroke-width: 3; opacity: 1; }
.skchart .lbl { font: 600 11px var(--f-body); }
.tip {
  position: absolute; top: 8px; z-index: 2; pointer-events: none; min-width: 150px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px;
  font-size: 12.5px; box-shadow: 0 4px 16px rgba(0,0,0,.12);
}
.tip b { display: block; margin-bottom: 4px; }
.tip div { display: flex; align-items: center; gap: 6px; }
.tip i, .htable i, .bttable i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: 0; }
.tip .num { margin-left: auto; padding-left: 10px; }
.htable, .bttable { border-collapse: collapse; font-size: 14px; }
.htable th, .htable td { padding: 7px 14px 7px 0; text-align: right; border-top: 1px solid var(--line); white-space: nowrap; }
.htable thead th { border-top: 0; color: var(--muted); font-weight: 500; font-size: 12.5px; }
.htable th[scope="row"] { text-align: left; font-weight: 600; }
.htable tr.cur th, .htable tr.cur td { font-weight: 700; }

.bt-wrap { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 24px; align-items: start; }
@media (max-width: 900px) { .bt-wrap { grid-template-columns: minmax(0, 1fr); } }
.bttable th, .bttable td { padding: 6px 8px; text-align: center; white-space: nowrap; }
.bttable thead th { color: var(--muted); font-weight: 500; font-size: 12.5px; }
.bttable th[scope="row"] { text-align: left; font-weight: 600; padding-left: 0; }
.bttable td.bt {
  font: 600 15px/1.1 var(--f-mono); font-variant-numeric: tabular-nums; border-radius: 6px; min-width: 70px;
  background: var(--s0);
}
.bttable td.bt small { font: 400 10.5px var(--f-mono); color: var(--muted); margin-left: 2px; }
.bttable td.bt small.n { display: block; margin: 3px 0 0; }
.bttable td.bt.best { background: var(--s4); color: var(--s-ink-hi); }
.bttable td.bt.best small { color: var(--s-ink-hi); opacity: .85; }
.bttable td.bt.weak { background: var(--bad-bg); color: var(--bad); }
.bttable td.bt.na { background: transparent; color: var(--muted); font: 400 11.5px var(--f-body); }
.bttable tr.median th { font-weight: 800; }
.bttable tr.median td.bt { box-shadow: inset 0 0 0 1.5px var(--ink); }
.bttable tbody tr + tr td, .bttable tbody tr + tr th { border-top: 2px solid var(--surface); }
.findings { margin: 4px 0 18px; padding-left: 1.2em; }
.findings li { margin-bottom: 8px; }
.bt-entry { margin-top: 18px; }
.bt-entry h3 { margin-bottom: 8px; }

.foot { padding-block: 24px 40px; font-size: 12.5px; color: var(--muted); }
.foot p { margin: 0 0 6px; max-width: 80ch; }

@media (prefers-reduced-motion: no-preference) {
  .row, .links a { transition: background-color .12s, border-color .12s; }
}
