:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --ring: rgba(11, 11, 11, 0.10);
  --wash: rgba(11, 11, 11, 0.05);
  --accent: #2a78d6;
  --flood-1: #6da7ec;
  --flood-2: #2a78d6;
  --flood-3: #184f95;
  --src-S1: #2a78d6;
  --src-HLS: #eb6834;
  --src-drone: #1baf7a;
  --report: #e34948;
  --precip: #6250d6;
  --condition: #e87ba4;
  --cat-none: #898781;
  --cat-action: #ffd400;
  --cat-minor: #ff9900;
  --cat-moderate: #ff0000;
  --cat-major: #cc33ff;
  --side-w: 380px;
  --drawer-h: 46vh;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --ink: #f0efec;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --ring: rgba(255, 255, 255, 0.10);
    --wash: rgba(255, 255, 255, 0.06);
    --accent: #3987e5;
    --flood-1: #5598e7;
    --flood-2: #86b6ef;
    --flood-3: #cde2fb;
    --src-S1: #3987e5;
    --src-HLS: #d95926;
    --src-drone: #199e70;
    --report: #e66767;
    --precip: #9085e9;
    --condition: #d55181;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --ink: #f0efec;
  --ink-2: #c3c2b7;
  --muted: #898781;
  --grid: #2c2c2a;
  --axis: #383835;
  --ring: rgba(255, 255, 255, 0.10);
  --wash: rgba(255, 255, 255, 0.06);
  --accent: #3987e5;
  --flood-1: #5598e7;
  --flood-2: #86b6ef;
  --flood-3: #cde2fb;
  --src-S1: #3987e5;
  --src-HLS: #d95926;
  --src-drone: #199e70;
  --report: #e66767;
  --precip: #9085e9;
  --condition: #d55181;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body { background: var(--page); color: var(--ink); font-size: 14px; line-height: 1.45; display: flex; flex-direction: column; }
a { color: var(--accent); }
button { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.num { font-variant-numeric: tabular-nums; }

.top { display: flex; align-items: baseline; gap: 16px; padding: 10px 16px; border-bottom: 1px solid var(--ring); background: var(--surface); flex: none; }
.brand { white-space: nowrap; font-weight: 700; color: var(--ink); text-decoration: none; letter-spacing: 0.01em; }
.crumbs { color: var(--ink-2); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crumbs a { color: var(--ink-2); }

.layout { flex: 1; min-height: 0; display: grid; grid-template-columns: var(--side-w) 1fr; grid-template-rows: 1fr auto; grid-template-areas: "side map" "side drawer"; }
.side { grid-area: side; overflow-y: auto; background: var(--surface); border-right: 1px solid var(--ring); padding: 16px; }
.mapwrap { grid-area: map; position: relative; min-height: 0; }
#map { position: absolute; inset: 0; }
.drawer { grid-area: drawer; background: var(--surface); border-top: 1px solid var(--ring); padding: 12px 16px 16px; max-height: var(--drawer-h); overflow-y: auto; }

/* sidebar */
.side h1 { font-size: 18px; line-height: 1.3; }
.side h3 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 20px 0 8px; font-weight: 600; }
.side section + section { margin-top: 4px; }
.back { display: inline-block; margin-bottom: 8px; font-size: 13px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.chip { font-size: 12px; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--ring); color: var(--ink-2); background: var(--page); }
.chip.on { border-color: var(--accent); color: var(--ink); }
.chip.off { text-decoration: line-through; color: var(--muted); }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0 4px; }
.stat { padding: 8px 10px; border: 1px solid var(--ring); border-radius: 8px; background: var(--page); }
.stat b { display: block; font-size: 18px; font-weight: 600; }
.stat span { font-size: 12px; color: var(--ink-2); }
.filters { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.filters label { font-size: 12px; color: var(--ink-2); display: flex; flex-direction: column; gap: 2px; }
select { font: inherit; padding: 4px 6px; border-radius: 6px; border: 1px solid var(--axis); background: var(--surface); color: var(--ink); }
.card { display: block; width: 100%; text-align: left; padding: 10px 12px; margin: 8px 0; border: 1px solid var(--ring); border-radius: 8px; background: var(--page); cursor: pointer; }
.card:hover, .card:focus-visible { border-color: var(--accent); outline: none; }
.card strong { display: block; }

.layers { list-style: none; padding: 0; margin: 0; }
.layers li { display: flex; align-items: center; gap: 8px; padding: 4px 0; }
.layers label { display: flex; align-items: center; gap: 8px; flex: 1; cursor: pointer; }
.layers li.credit { padding: 0 0 4px 30px; display: block; }
.layers .zoom { font-size: 12px; background: none; border: 0; color: var(--accent); cursor: pointer; padding: 0; }
.sw { width: 14px; height: 14px; border-radius: 3px; flex: none; display: inline-block; box-shadow: inset 0 0 0 1px var(--ring); }
.sw.tri { width: 0; height: 0; border-radius: 0; box-shadow: none; border-left: 7px solid transparent; border-right: 7px solid transparent; border-bottom: 12px solid var(--report); }
.sw.dot { border-radius: 50%; }
.sw.ring { background: transparent; box-shadow: inset 0 0 0 1.5px var(--ink-2); }
.sw.hatch { background: repeating-linear-gradient(135deg, var(--muted) 0 1px, transparent 1px 5px); }
.sw.fp { background: var(--wash); box-shadow: inset 0 0 0 1.5px var(--ink-2); }
.legend-row { display: flex; align-items: center; gap: 8px; font-size: 13px; padding: 2px 0; color: var(--ink-2); }

.gauges { width: 100%; border-collapse: collapse; font-size: 13px; }
.gauges th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12px; padding: 2px 4px 4px 0; }
.gauges td { padding: 5px 4px 5px 0; border-top: 1px solid var(--grid); vertical-align: top; }
.gauges button { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; text-align: left; }
.cat { display: inline-flex; align-items: center; gap: 4px; }
.cat i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; box-shadow: 0 0 0 1px var(--ring); }

.info { border: 1px solid var(--ring); border-radius: 8px; padding: 10px 12px; background: var(--page); }
.info dl { display: grid; grid-template-columns: auto 1fr; gap: 3px 10px; margin: 8px 0 0; font-size: 13px; }
.info dt { color: var(--muted); }
.info dd { margin: 0; overflow-wrap: anywhere; }
details summary { cursor: pointer; color: var(--ink-2); font-size: 13px; }
details p { font-size: 13px; color: var(--ink-2); white-space: pre-wrap; }
.notes li { font-size: 13px; color: var(--ink-2); margin: 4px 0; }
.notes { padding-left: 18px; margin: 0; }

/* map overlays */
.basemap { position: absolute; top: 10px; left: 10px; display: flex; background: var(--surface); border-radius: 8px; box-shadow: 0 0 0 1px var(--ring), 0 1px 4px rgba(0,0,0,.12); overflow: hidden; }
.basemap button { border: 0; background: none; padding: 5px 12px; cursor: pointer; font-size: 13px; color: var(--ink-2); }
.basemap button[aria-pressed="true"] { background: var(--wash); color: var(--ink); font-weight: 600; }
.timeline { position: absolute; left: 10px; right: 56px; top: 48px; display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; gap: 2px 10px; align-items: center; background: var(--surface); padding: 8px 12px; border-radius: 10px; box-shadow: 0 0 0 1px var(--ring), 0 2px 8px rgba(0,0,0,.15); }
.timeline .play { grid-row: 1; width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--axis); background: var(--page); cursor: pointer; font-size: 12px; }
.track { position: relative; grid-row: 1; }
.ticks { display: block; width: 100%; height: 16px; }
#slider { width: 100%; margin: 0; accent-color: var(--accent); }
.tlabel { grid-column: 2; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 13px; }
#tnow { font-variant-numeric: tabular-nums; font-weight: 600; }
.mode { color: var(--ink-2); display: flex; gap: 6px; align-items: center; }
.tip { position: absolute; pointer-events: none; background: var(--surface); color: var(--ink); border-radius: 6px; padding: 6px 8px; font-size: 12px; max-width: 280px; box-shadow: 0 0 0 1px var(--ring), 0 2px 8px rgba(0,0,0,.18); z-index: 5; }
.tip b { font-weight: 600; }

/* chart drawer */
.drawer-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.drawer-head h2 { font-size: 15px; }
.drawer-head p { margin: 2px 0 0; font-size: 12px; }
.drawer-actions { display: flex; gap: 12px; align-items: center; }
.link { font-size: 13px; }
.close { border: 0; background: none; font-size: 22px; line-height: 1; cursor: pointer; color: var(--ink-2); }
.panels { margin-top: 6px; }
.panel h4 { margin: 8px 0 0; font-size: 12px; font-weight: 600; color: var(--ink-2); display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: baseline; }
.thrs { font-weight: 400; display: inline-flex; flex-wrap: wrap; gap: 4px 12px; }
.thr { display: inline-flex; align-items: center; gap: 5px; }
.thr i { width: 16px; border-top: 2px dashed; display: inline-block; }
.uplot { font-family: inherit; }
.u-legend { font-size: 12px; color: var(--ink-2); text-align: left; }
.u-legend .u-marker { border-radius: 2px; }
.ts-table { border-collapse: collapse; font-size: 12px; margin-top: 10px; }
.ts-table th, .ts-table td { padding: 3px 14px 3px 0; text-align: left; border-top: 1px solid var(--grid); font-variant-numeric: tabular-nums; }
.ts-table th { color: var(--muted); font-weight: 500; }

.maplibregl-ctrl-attrib { font-size: 11px; }

@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; grid-template-rows: 58vh auto auto; grid-template-areas: "map" "drawer" "side"; }
  .side { border-right: 0; border-top: 1px solid var(--ring); overflow: visible; }
  body { display: block; height: auto; }
  .mapwrap { height: 58vh; }
  .drawer { max-height: none; }
}
