: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;
  --src-SWOT: #7b4fd0;
  --src-ERI: #d1347f;                /* aerial flood (NOAA ERI); validated with S1/HLS/drone/SWOT */
  --rise-1: #cbbcf0;                 /* SWOT node rise above the days before: one hue, light -> dark */
  --rise-2: #a88ce4;
  --rise-3: #855fd3;
  --rise-4: #6339b8;
  --rise-5: #3f1f86;
  --depth-1: #9ec5f4;                /* FloodNet street depth: one hue, light -> dark */
  --depth-2: #4f8fe0;
  --depth-3: #1f5fb8;
  --depth-4: #0b3275;
  --report: #e34948;
  --impact: #b45309;
  --precip: #6250d6;
  --rain: #1f77d0;
  --condition: #e87ba4;
  --cat-none: #898781;
  --cat-action: #ffd400;
  --cat-minor: #ff9900;
  --cat-moderate: #ff0000;
  --cat-major: #cc33ff;
  --nws-advisory: #86c26f;           /* NWS flood products by class: one hue, advisory -> watch -> warning */
  --nws-watch: #3f9a44;
  --nws-warning: #1d6b2a;
  --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;
    --src-SWOT: #9d7cf0;
    --src-ERI: #e0559a;
    --rise-1: #4a3b7c;               /* dark: low rise dim, high rise bright */
    --rise-2: #6b55b4;
    --rise-3: #8f75e0;
    --rise-4: #ad92f5;
    --rise-5: #cdb9fb;
    --depth-1: #24466f;
    --depth-2: #3a73bf;
    --depth-3: #73a6ec;
    --depth-4: #c9defa;
    --report: #e66767;
    --impact: #e8913f;
    --precip: #9085e9;
    --rain: #4f9be8;
    --condition: #d55181;
    --nws-advisory: #2f7a36;         /* dark: advisory dim, warning bright */
    --nws-watch: #4fae55;
    --nws-warning: #8fd98a;
  }
}
: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;
    --src-SWOT: #9d7cf0;
    --src-ERI: #e0559a;
    --rise-1: #4a3b7c;               /* dark: low rise dim, high rise bright */
    --rise-2: #6b55b4;
    --rise-3: #8f75e0;
    --rise-4: #ad92f5;
    --rise-5: #cdb9fb;
    --depth-1: #24466f;
    --depth-2: #3a73bf;
    --depth-3: #73a6ec;
    --depth-4: #c9defa;
  --report: #e66767;
    --impact: #e8913f;
  --precip: #9085e9;
    --rain: #4f9be8;
  --condition: #d55181;
  --nws-advisory: #2f7a36;
  --nws-watch: #4fae55;
  --nws-warning: #8fd98a;
}

* { 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(2, 1fr); gap: 8px; }
.huc-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; margin-top: 10px; font-size: 12px; color: var(--ink-2); }
.huc-legend > span:first-child { flex-basis: 100%; }
.huc-legend i { display: inline-block; width: 16px; height: 10px; border-radius: 2px; background: var(--accent); }
.ws-chip { display: flex; align-items: center; gap: 8px; margin-top: 10px; padding: 6px 8px 6px 10px; border: 1px solid var(--ink-2);
  border-radius: 8px; font-size: 13px; }
.ws-chip[hidden] { display: none; }
.ws-chip button { margin-left: auto; border: 0; background: none; cursor: pointer; color: var(--ink-2); font-size: 14px; padding: 0 2px; }
.daterange { margin-top: 10px; }
.dr-head { display: flex; align-items: baseline; gap: 8px; font-size: 12px; color: var(--ink-2); }
.dr-head #dr-label { color: var(--ink); }
.dr-reset { margin-left: auto; font: inherit; font-size: 12px; color: var(--accent); background: none; border: 0; padding: 0; cursor: pointer; }
.dr-hist { display: block; width: calc(100% - 14px); height: 28px; margin: 6px 7px 0; }
.dr-hist rect.on { fill: var(--accent); }
.dr-hist rect.off { fill: var(--ring); }
.dr-track { position: relative; height: 22px; }
.dr-rail, .dr-fill { position: absolute; top: 9px; height: 4px; border-radius: 2px; }
.dr-rail { left: 7px; right: 7px; background: var(--ring); }
.dr-fill { background: var(--accent); }
.dr-track input[type=range] { position: absolute; inset: 0; width: 100%; height: 22px; margin: 0; background: none; pointer-events: none;
  -webkit-appearance: none; appearance: none; }
.dr-track input[type=range]::-webkit-slider-runnable-track { background: none; height: 22px; }
.dr-track input[type=range]::-moz-range-track { background: none; }
.dr-track input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; pointer-events: auto; width: 14px; height: 14px; margin-top: 4px;
  border-radius: 50%; background: var(--accent); border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--accent); cursor: pointer; }
.dr-track input[type=range]::-moz-range-thumb { pointer-events: auto; width: 10px; height: 10px; border-radius: 50%; background: var(--accent);
  border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--accent); cursor: pointer; }
.dr-track input[type=range]:focus-visible { outline: none; }
.dr-track input[type=range]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 3px var(--accent); }
.chip.review-verified { border-color: var(--accent); color: var(--ink); font-weight: 500; }
.chip.review-gate-checked { border-style: dashed; color: var(--ink-2); }
.review-note { margin: 6px 0 0; padding: 6px 10px; border: 1px dashed var(--ring); border-radius: 6px; color: var(--ink-2); }
.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-img { width: 16px; height: 16px; vertical-align: -3px; }
.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; }
}

.nws-sw { width: 10px; height: 10px; border-radius: 2px; display: inline-block; margin-right: 4px; box-shadow: 0 0 0 1px var(--ring); vertical-align: -1px; }
.alerts-list { font-size: 12px; margin: 6px 0 0; padding-left: 0; list-style: none; columns: 2; }
.alerts-list li { break-inside: avoid; margin: 2px 0; color: var(--ink-2); }
.panel-h { margin: 10px 0 0; font-size: 12px; font-weight: 600; color: var(--ink-2); }

/* lab credit, bottom of the all-events panel */
footer.lab { margin-top: 24px; padding-top: 14px; border-top: 1px solid var(--grid); display: flex; flex-direction: column; align-items: center; gap: 6px; }
footer.lab img { max-width: 200px; max-height: 72px; width: auto; height: auto; display: block; }
