:root {
  color-scheme: dark;
  --bg: #0e1316;
  --panel: rgba(16, 22, 25, 0.9);
  --line: rgba(255, 255, 255, 0.1);
  --ink: #f0efec;
  --ink2: #c3c2b7;
  --muted: #898781;
  --water: #3987e5;
  --water-lt: #b7d3f6;
  --a: #d95926;
  --b: #199e70;
  --c: #6b6b66;
  --accent: #6da7ec;
  --band: rgba(237, 161, 0, 0.32);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; overflow: hidden; }
#map { position: absolute; inset: 0; }
a { color: var(--accent); }
button { font: inherit; color: inherit; }

#panel {
  position: absolute; top: 16px; left: 16px; bottom: 16px; width: 372px; z-index: 3;
  background: var(--panel); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px 12px; overflow: auto;
  display: flex; flex-direction: column; gap: 10px; scrollbar-width: thin;
}
.brand { display: flex; align-items: baseline; gap: 10px; }
.mark { font-weight: 800; font-size: 22px; letter-spacing: -0.04em; color: var(--ink); text-decoration: none; }
.mark span { color: var(--water); }
.tag { color: var(--muted); font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; flex: 1; }
.ghost { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 16px; display: none; }
h1 { font-size: 21px; line-height: 1.15; margin: 2px 0 0; letter-spacing: -0.02em; }
.lede { margin: 0; color: var(--ink2); }

.seg { display: grid; grid-template-columns: repeat(5, 1fr); gap: 2px; background: rgba(255,255,255,0.05); border-radius: 10px; padding: 3px; }
.seg button { background: none; border: 0; border-radius: 8px; padding: 6px 2px; color: var(--ink2); cursor: pointer; font-size: 12.5px; }
.seg button.on { background: rgba(255,255,255,0.12); color: var(--ink); font-weight: 600; }
.seg button:disabled { opacity: 0.35; cursor: default; }

.box { border-top: 1px solid var(--line); padding-top: 9px; }
.lbl { color: var(--ink2); font-size: 12.5px; display: flex; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.lbl b { color: var(--ink); font-size: 14px; }
.hint { color: var(--muted); }
.chips { display: flex; gap: 4px; flex-wrap: wrap; }
.chips button { border: 1px solid var(--line); background: rgba(255,255,255,0.03); border-radius: 99px; padding: 3px 9px; cursor: pointer; color: var(--ink2); font-size: 12.5px; }
.chips button:disabled { opacity: 0.35; cursor: default; }
.chips button.on { border-color: var(--water); color: var(--ink); background: rgba(57,135,229,0.18); }
.dim { opacity: 0.4; pointer-events: none; }

.pipe { position: relative; height: 30px; }
.pipe .band { position: absolute; top: 7px; height: 16px; background: var(--band); border-radius: 4px; pointer-events: none; }
#cap { -webkit-appearance: none; appearance: none; position: absolute; inset: 0; width: 100%; height: 30px; background: none; margin: 0; cursor: pointer; }
#cap::-webkit-slider-runnable-track { height: 8px; border-radius: 99px; background: linear-gradient(90deg, #22303a, #3987e5); }
#cap::-moz-range-track { height: 8px; border-radius: 99px; background: linear-gradient(90deg, #22303a, #3987e5); }
#cap::-webkit-slider-thumb { -webkit-appearance: none; width: 22px; height: 22px; margin-top: -7px; border-radius: 50%; background: var(--ink); border: 4px solid #3987e5; box-shadow: 0 0 0 3px rgba(14,19,22,0.9); }
#cap::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: var(--ink); border: 4px solid #3987e5; }
.ticks { display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; padding: 0 4px; font-variant-numeric: tabular-nums; }
.note { color: var(--muted); font-size: 11.5px; margin-top: 4px; display: flex; align-items: center; gap: 6px; }
.sw { display: inline-block; width: 14px; height: 10px; border-radius: 3px; flex: none; }
.legend .row .sw { margin-top: 4px; }
.band-sw { background: var(--band); }
.sw.ring { border: 2px solid #f0efec; border-radius: 50%; width: 11px; height: 11px; }

.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.kpi { background: rgba(255,255,255,0.04); border-radius: 12px; padding: 8px 10px; }
.kpi .v { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; }
.kpi .k { color: var(--muted); font-size: 11.5px; }

#chart svg { display: block; width: 100%; height: auto; overflow: visible; }
#chart .axis text { fill: var(--muted); font-size: 10px; }
#chart .axis line, #chart .axis path { stroke: #383835; }
#chart .grid line { stroke: #2c2c2a; }
#chart .tip { fill: var(--ink); font-size: 10.5px; }

.legend .row { display: flex; align-items: flex-start; gap: 8px; color: var(--ink2); font-size: 12.5px; margin: 3px 0; }
.legend .ramp { display: flex; height: 10px; border-radius: 3px; overflow: hidden; margin: 4px 0 2px; }
.legend .ramp span { flex: 1; }
.legend .rampl { display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; }
.legend .ttl { color: var(--ink2); font-size: 12.5px; }
.legend .sub { color: var(--muted); font-size: 11.5px; margin-top: 4px; }

.toggle { display: flex; align-items: center; gap: 8px; color: var(--ink2); font-size: 12.5px; cursor: pointer; }
.toggle input { accent-color: #f0efec; }
.fine { color: var(--muted); font-size: 11px; margin: 0; }

#caption {
  position: absolute; z-index: 4; left: 50%; bottom: 46px; transform: translateX(-50%); max-width: min(760px, calc(100% - 32px));
  background: rgba(10, 14, 16, 0.86); border: 1px solid var(--line); border-radius: 14px; padding: 10px 18px; font-size: 19px; line-height: 1.3;
  text-align: center; opacity: 0; transition: opacity .35s; pointer-events: none;
}
#caption.show { opacity: 1; }
#caption small { display: block; color: var(--ink2); font-size: 13px; margin-top: 2px; }

.probe { position: absolute; z-index: 5; background: rgba(10,14,16,0.94); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; font-size: 12.5px; pointer-events: none; max-width: 260px; }
.probe b { color: var(--ink); }
.probe .m { color: var(--muted); }
#loading { position: absolute; z-index: 6; right: 16px; top: 16px; background: var(--panel); border: 1px solid var(--line); border-radius: 99px; padding: 6px 14px; color: var(--ink2); font-size: 12.5px; }
#loading.done { display: none; }

.maplibregl-ctrl-attrib { font-size: 10.5px; background: rgba(14,19,22,0.75) !important; color: var(--muted); }
.maplibregl-ctrl-attrib a { color: var(--ink2); }
.maplibregl-ctrl-group { background: rgba(16,22,25,0.9); }
.maplibregl-ctrl-group button span { filter: invert(1); }

/* demo mode: no interactive chrome */
body.demo #panel { pointer-events: none; }
body.demo .toggle, body.demo .fine a, body.demo .ghost, body.demo .maplibregl-ctrl-top-right, body.demo #loading { display: none; }

/* phone */
@media (max-width: 720px) {
  #panel { top: auto; left: 8px; right: 8px; bottom: 8px; width: auto; max-height: 56vh; border-radius: 16px; padding: 10px 12px; gap: 8px; }
  #panel.collapsed { max-height: 168px; overflow: hidden; }
  #panel > * { order: 5; }
  #panel .brand { order: 0; } #capBox { order: 1; } #modes { order: 2; } .kpis { order: 3; } #stormBox { order: 4; }
  #panel.collapsed h1 { display: none; }
  #capBox .note { display: none; }
  .ghost { display: block; }
  h1 { font-size: 17px; }
  .lede, .chartbox, .fine { display: none; }
  #panel.expanded .chartbox { display: block; }
  .kpi .v { font-size: 21px; }
  #caption { top: 12px; bottom: auto; font-size: 15px; }
  #loading { top: 8px; right: 8px; }
}

.play { margin-top: 7px; background: none; border: 1px solid var(--line); border-radius: 99px; padding: 3px 11px; color: var(--ink2); cursor: pointer; font-size: 12.5px; }
.play:hover { border-color: var(--water); color: var(--ink); }
