:root {
  color-scheme: light;
  --bg: #fcfcfb;
  --surface: #ffffff;
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #6d6c67;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --hover: rgba(11, 11, 11, 0.04);
  --accent: #2a78d6;
  --banner-bg: #fff6df;
  --banner-text: #5c4300;

  /* status (fixed, never themed) — always paired with a text label */
  --st-crit: #d03b3b;
  --st-warn: #fab219;
  --st-ok: #0ca30c;
  --st-off: #8a8983;
  --st-temp: #b8b7b0;

  /* 1h trend text: rising red, falling green (text-contrast safe) */
  --trend-up: #d03b3b;
  --trend-down: #006300;

  /* chart series (validated: light + dark, all pairs) */
  --s-in: #2a78d6;
  --s-out: #e87ba4;
  --s-river: #008300;

  --font: "IBM Plex Sans Thai", system-ui, -apple-system, "Segoe UI", "Leelawadee UI", Tahoma, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --bg: #111110;
    --surface: #1a1a19;
    --text: #ffffff;
    --text-2: #c3c2b7;
    --muted: #9b9a92;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --hover: rgba(255, 255, 255, 0.05);
    --accent: #3987e5;
    --banner-bg: #2b2413;
    --banner-text: #f3dfa6;
    --s-in: #3987e5;
    --s-out: #d55181;
    --s-river: #008300;
    --trend-up: #e66767;
    --trend-down: #0ca30c;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111110; --surface: #1a1a19; --text: #ffffff; --text-2: #c3c2b7; --muted: #9b9a92;
  --grid: #2c2c2a; --axis: #383835; --border: rgba(255,255,255,0.10); --hover: rgba(255,255,255,0.05);
  --accent: #3987e5; --banner-bg: #2b2413; --banner-text: #f3dfa6;
  --s-in: #3987e5; --s-out: #d55181; --s-river: #008300;
  --trend-up: #e66767; --trend-down: #0ca30c;
}

* { box-sizing: border-box; }
/* Components set display (grid/flex); make the hidden attribute always win. */
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; overflow-anchor: none; } /* filters keep position manually (Safari has no scroll anchoring) */
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
}
a { color: var(--accent); }
h1 { font-size: 1.5rem; font-weight: 600; margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 1.125rem; font-weight: 600; margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 0.8125rem; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.wrap { max-width: 1200px; margin: 0 auto; padding: 0 16px; }

.disclaimer {
  background: var(--banner-bg);
  color: var(--banner-text);
  font-size: 0.8125rem;
  padding: 8px 16px;
  text-align: center;
}
.disclaimer a { color: inherit; font-weight: 500; }

.mockbanner { background: var(--st-crit); color: #fff; font-weight: 600; font-size: 0.875rem; padding: 8px 16px; text-align: center; }
/* data not updating: light bar so the red blinking label stands out */
.mockbanner a { color: inherit; font-weight: 600; text-decoration: underline; }
.mockbanner.stale { background: color-mix(in srgb, var(--st-crit) 10%, var(--surface)); color: var(--text); border-bottom: 1px solid color-mix(in srgb, var(--st-crit) 35%, transparent); }

.top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding-top: 20px; padding-bottom: 12px; }
.top p { margin: 2px 0 0; font-size: 0.875rem; }
.top .byline { margin: 0 0 2px; font-size: 0.75rem; color: var(--muted); }
.top .byline a { color: inherit; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

.btn {
  font: inherit; font-size: 0.8125rem; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: 6px 12px; cursor: pointer; text-decoration: none; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 6px;
}
.btn:hover { background: var(--hover); }
.btn[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }
.btn[aria-disabled="true"] { opacity: 0.45; pointer-events: none; }

/* status tiles double as filters */
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 12px; }
.tile {
  font: inherit; text-align: left; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px; cursor: pointer;
}
.tile:hover { background: var(--hover); }
.tile[aria-pressed="true"] { outline: 2px solid var(--accent); outline-offset: -2px; }
.tile .n { font-size: 1.5rem; font-weight: 600; line-height: 1.2; font-variant-numeric: tabular-nums; }
.tile .l { font-size: 0.8125rem; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.tile.static { cursor: default; }
.tile.static:hover { background: var(--surface); }

.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; display: inline-block; }
.st-0 { background: var(--st-off); } .st-1 { background: var(--st-temp); }
.st-2 { background: var(--st-ok); } .st-3 { background: var(--st-warn); } .st-4 { background: var(--st-crit); }

.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 0.8125rem; white-space: nowrap; color: var(--text); }

#map {
  height: min(62vh, 560px); min-height: 360px;
  border-radius: 12px; border: 1px solid var(--border); background: var(--surface);
}
.leaflet-container { font: inherit; background: var(--surface); }
/* Chrome draws a focus rectangle around a tapped road/pin; map shapes aren't keyboard
   targets, so drop it (buttons and links keep their focus outlines). */
.leaflet-container .leaflet-interactive:focus, .leaflet-container svg:focus { outline: none; }
/* Road (traffic) popup: a bit narrower than the station popup; station link on its own line */
.pop-road .leaflet-popup-content { width: min(270px, calc(100vw - 132px)) !important; }
.near-st a { display: block; margin-top: 2px; }
.basemap { filter: grayscale(1) brightness(1.04) contrast(0.9); }
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) .basemap { filter: grayscale(1) invert(1) brightness(0.85) contrast(0.9); }
}
:root[data-theme="dark"] .basemap { filter: grayscale(1) invert(1) brightness(0.85) contrast(0.9); }
.leaflet-popup-content-wrapper { background: var(--surface); color: var(--text); border-radius: 10px; }
.leaflet-popup-tip { background: var(--surface); }
.leaflet-popup-content { margin: 12px 14px; width: 320px !important; max-width: calc(100vw - 80px); }
.leaflet-container a.leaflet-popup-close-button { color: var(--muted); }
.leaflet-interactive.mk { stroke: var(--surface); stroke-width: 2; stroke-opacity: 1; fill-opacity: 1; }
.mk-4 { fill: var(--st-crit); } .mk-3 { fill: var(--st-warn); } .mk-2 { fill: var(--st-ok); }
.mk-1 { fill: var(--st-temp); } .mk-0 { fill: var(--st-off); }
.leaflet-tooltip { font: inherit; font-size: 0.75rem; }
.locate-btn { display: flex !important; align-items: center; justify-content: center; color: #333; }
.locate-btn.busy { color: var(--accent); animation: loc-pulse 1s ease-in-out infinite; }
@keyframes loc-pulse { 50% { opacity: 0.4; } }
@media (prefers-reduced-motion: reduce) { .locate-btn.busy { animation: none; } }
.leaflet-interactive.loc-dot { fill: var(--accent); fill-opacity: 1; stroke: #fff; stroke-width: 3; stroke-opacity: 1; }
.loc-acc { fill: var(--accent); fill-opacity: 0.12; stroke: var(--accent); stroke-opacity: 0.4; stroke-width: 1; }
.map-legend {
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  border-radius: 6px; padding: 3px 7px; font-size: 0.6875rem; line-height: 1.45;
}
.map-legend .dot { width: 8px; height: 8px; }
.map-legend div { display: flex; align-items: center; gap: 5px; white-space: nowrap; }
.map-legend .lg-sep { border-top: 1px solid var(--border); margin: 3px 0; }

/* Traffic segments (conventional green/orange/red; the basemap is grayscale). The
   blue halo marks a road where the jam plus high water suggest flooding. */
:root { --tr-free: #2f9e44; --tr-slow: #f08c00; --tr-jam: #d9480f; --tr-flood: #2a78d6; }
.leaflet-interactive.tr { stroke-opacity: 0.95; }
.tr-free { stroke: var(--tr-free); } .tr-slow { stroke: var(--tr-slow); }
.tr-jam, .tr-closed { stroke: var(--tr-jam); }
.leaflet-interactive.tr-closed { stroke-dasharray: 2 8; stroke-width: 6; }
.leaflet-interactive.tr-halo { stroke: var(--tr-flood); stroke-opacity: 0.35; }
.leaflet-interactive.tr-halo-likely { stroke-opacity: 0.55; }
.lg-tr { stroke-width: 4; stroke-linecap: round; }
.lg-halo { stroke: var(--tr-flood); stroke-opacity: 0.5; stroke-width: 10; stroke-linecap: round; }
.traffic-btn { display: flex !important; align-items: center; justify-content: center; color: #999; }
.traffic-btn.on { color: var(--tr-jam); }
.leaflet-tooltip.tr-tip {
  width: 270px; white-space: normal; line-height: 1.4; padding: 10px 12px; border-radius: 10px;
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  box-shadow: 0 4px 14px rgb(0 0 0 / 0.18);
}
.leaflet-tooltip-top.tr-tip::before { border-top-color: var(--surface); }
.tr-tip .tt-road { font-weight: 700; font-size: 0.875rem; margin-bottom: 6px; }
.tr-tip .tt-verdict {
  font-size: 0.8125rem; font-weight: 500; padding: 6px 8px; border-radius: 6px;
  background: var(--hover); border-left: 3px solid var(--border);
}
.tr-tip .tt-verdict.vd-likely { color: var(--tr-flood); border-left-color: var(--tr-flood); background: color-mix(in srgb, var(--tr-flood) 14%, transparent); }
.tr-tip .tt-verdict.vd-possible { border-left-color: color-mix(in srgb, var(--tr-flood) 60%, transparent); background: color-mix(in srgb, var(--tr-flood) 8%, transparent); }
.tr-tip .tt-rows { display: grid; grid-template-columns: auto 1fr; gap: 3px 10px; margin-top: 8px; font-size: 0.8125rem; align-items: baseline; }
.tr-tip .tt-k { color: var(--text-2); }
.tr-tip .tt-sub { color: var(--text-2); font-size: 0.75rem; }
.tr-tip .tt-st { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tr-tip .dot { width: 8px; height: 8px; }
.tr-tip .tt-note { margin-top: 8px; padding-top: 6px; border-top: 1px solid var(--border); font-size: 0.6875rem; color: var(--text-2); }
.traffic-box { margin: 8px 0; padding: 8px 10px; border-radius: 8px; background: var(--hover); border-left: 3px solid var(--border); }
.traffic-box.vd-likely { border-left-color: var(--tr-flood); background: color-mix(in srgb, var(--tr-flood) 12%, transparent); }
.traffic-box.vd-possible { border-left-color: color-mix(in srgb, var(--tr-flood) 60%, transparent); }
.traffic-box .verdict { font-size: 0.875rem; font-weight: 500; margin: 2px 0; }
.traffic-box.vd-likely .verdict { color: var(--tr-flood); }
.jam-free { color: var(--trend-down); } .jam-slow { color: #b35f00; } .jam-jam, .jam-closed { color: var(--trend-up); }

.pop h3 { font-size: 0.9375rem; font-weight: 600; margin: 0 0 2px; line-height: 1.35; }
.pop .meta { font-size: 0.75rem; color: var(--muted); margin-bottom: 8px; }
.levels { display: grid; grid-template-columns: repeat(3, auto); gap: 2px 14px; font-size: 0.8125rem; margin: 8px 0; }
.levels .k { color: var(--text-2); }
.levels .v { font-variant-numeric: tabular-nums; font-weight: 500; }
.links { display: flex; gap: 12px; font-size: 0.8125rem; margin-top: 8px; flex-wrap: wrap; }

/* chart */
.chart-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; margin: 6px 0 4px; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg button { font: inherit; font-size: 0.75rem; border: 0; background: transparent; color: var(--text-2); padding: 3px 10px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--hover); color: var(--text); font-weight: 600; }
.legend { display: flex; gap: 12px; font-size: 0.75rem; color: var(--text-2); flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { width: 12px; height: 2px; border-radius: 1px; display: inline-block; }
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .empty { font-size: 0.8125rem; color: var(--muted); padding: 24px 0; text-align: center; }
.note { font-size: 0.75rem; color: var(--st-crit); }

.tip {
  position: fixed; z-index: 2000; pointer-events: none;
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  box-shadow: 0 4px 16px rgba(0,0,0,0.12); border-radius: 8px;
  padding: 6px 9px; font-size: 0.75rem; line-height: 1.5; white-space: nowrap;
}
.tip b { font-weight: 600; }
.tip .row { display: flex; align-items: center; gap: 6px; }
.tip .row i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.tip .row .val { margin-left: auto; padding-left: 12px; font-variant-numeric: tabular-nums; }

/* city overview: summary cards; danger cards pulse */
.overview .section-head { margin-bottom: 8px; align-items: center; }
.map-section { margin-top: 24px; }
.map-section h2 { margin-bottom: 10px; }
.ov-lead {
  margin: 0; font-weight: 600; display: inline-flex; align-items: center; gap: 8px;
  padding: 4px 12px; border-radius: 999px; font-size: 0.9375rem;
  background: var(--hover); color: var(--text);
}
.ov-lead i { width: 8px; height: 8px; border-radius: 50%; background: var(--st-off); }
.ov-up { background: color-mix(in srgb, var(--st-crit) 14%, transparent); color: var(--trend-up); }
.ov-up i { background: var(--st-crit); animation: ov-blink 1.2s ease-in-out infinite; }
.ov-down { background: color-mix(in srgb, var(--st-ok) 14%, transparent); color: var(--trend-down); }
.ov-down i { background: var(--st-ok); }
.ov-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; }
.ovc {
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--st-off);
  border-radius: 10px; padding: 10px 12px; min-width: 0;
}
.ovc-n { font-size: 1.625rem; font-weight: 600; line-height: 1.15; font-variant-numeric: tabular-nums; display: flex; align-items: baseline; gap: 6px; }
.ovc-i { font-size: 0.875rem; }
.ovc-l { font-size: 0.8125rem; font-weight: 500; color: var(--text); line-height: 1.3; }
.ovc-s { font-size: 0.75rem; color: var(--muted); line-height: 1.3; }
.ovc-down .ovc-n { color: var(--st-crit); font-size: 1.125rem; animation: ov-blink 1.2s ease-in-out infinite; }
.sysdown { color: var(--st-crit); font-weight: 700; animation: ov-blink 1.2s ease-in-out infinite; }
.ovc-good, .ovc-danger { border-color: color-mix(in srgb, var(--ovc) 45%, transparent); border-left-color: var(--ovc); }
.ovc-blink { background: color-mix(in srgb, var(--ovc) 10%, var(--surface)); }
.ovc-good { --ovc: var(--st-ok); }
.ovc-good .ovc-n { color: var(--trend-down); }
.ovc-danger { --ovc: var(--st-crit); }
.ovc-danger .ovc-n { color: var(--trend-up); }
/* blinking: pulsing border glow plus a flashing dot beside the number */
.ovc-blink { animation: ov-pulse 1.6s ease-in-out infinite; }
.ovc-blink .ovc-n::after {
  content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--ovc);
  margin-left: auto; align-self: center; animation: ov-blink 1.2s ease-in-out infinite;
}
@keyframes ov-pulse {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ovc) 45%, transparent); }
  50% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--ovc) 18%, transparent); }
}
@keyframes ov-blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.2; } }
@media (prefers-reduced-motion: reduce) { .ovc-blink, .ovc-blink .ovc-n::after, .ov-up i, .sysdown, .ovc-down .ovc-n { animation: none; } }
@media (max-width: 900px) { .ov-grid { grid-template-columns: repeat(3, 1fr); } }
/* Phones: keep the overview about as tall as the status tiles so the map still peeks in. */
@media (max-width: 760px) {
  .ov-lead { font-size: 0.8125rem; padding: 3px 10px; }
  /* 2×2: rising + falling, then districts + roads; "steady" is left out */
  .ov-grid { gap: 6px; grid-template-columns: repeat(2, 1fr); }
  .ovc-flat { display: none; }
  .ovc { padding: 7px 8px; border-left-width: 3px; }
  .ovc-n { font-size: 1.25rem; }
  .ovc-i { font-size: 0.75rem; }
  .ovc-l { font-size: 0.75rem; }
  .ovc-s { font-size: 0.6875rem; }
  .ovc-1h { display: none; }
  .ov-note { font-size: 0.6875rem; line-height: 1.4; }
}
.ov-note { margin: 8px 0 0; }

/* districts */
.districts { margin-top: 28px; }
.districts .section-head { justify-content: space-between; flex-wrap: wrap; margin-bottom: 4px; }
.districts > p { margin: 0 0 12px; max-width: 760px; }
.dist-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
#distPick {
  font: inherit; font-size: 0.875rem; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; max-width: 260px;
}
.dgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; margin-bottom: 10px; }
.dcard {
  font: inherit; color: var(--text); text-align: left; cursor: pointer;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px;
  display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; align-items: end;
}
.dcard:hover { background: var(--hover); }
.dcard[aria-pressed="true"] { outline: 2px solid var(--accent); outline-offset: -2px; }
.dcard .dn { grid-column: 1 / -1; font-weight: 500; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dcard .dv { font-size: 1.25rem; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.2; }
.dcard .dv small { font-size: 0.75rem; font-weight: 400; color: var(--muted); }
.dcard .dvw { display: flex; flex-direction: column; gap: 1px; }
.dcard .dtr { font-size: 0.75rem; color: var(--text-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.dcard .dtr small, .dlegend small { color: var(--muted); }
.dlegend { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 0.75rem; color: var(--text-2); margin: 0 0 12px; }
.dlegend > span { display: inline-flex; align-items: center; gap: 6px; }
.dlegend .dot { width: 8px; height: 8px; }
.dlegend b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.dcard .dc { grid-column: 1 / -1; display: flex; gap: 10px; font-size: 0.75rem; color: var(--text-2); }
.dcard .dc span { display: inline-flex; align-items: center; gap: 4px; }
.dcard .dc .dot { width: 8px; height: 8px; }
.dpanel { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; margin-bottom: 12px; }
.dpanel h3 { margin: 0; font-size: 1rem; font-weight: 600; }
.dpanel .dsum { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 0.8125rem; color: var(--text-2); margin: 4px 0 6px; }
.dpanel .dsum b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.dpanel .dsum b.above { color: var(--st-crit); }
.dpanel .dsum b.safe { color: var(--trend-down); }

/* table */
.table-section { margin-top: 28px; }
.section-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 10px; }
.controls { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; }
.controls input[type="search"], .controls select {
  font: inherit; font-size: 0.875rem; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px;
}
.controls input[type="search"] { flex: 1 1 240px; min-width: 0; }
.controls select { max-width: 220px; }

#tblMore { margin-top: 10px; }
.table-scroll { overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
th, td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--grid); vertical-align: middle; }
th { font-weight: 500; color: var(--text-2); font-size: 0.8125rem; white-space: nowrap; position: sticky; top: 0; background: var(--surface); }
th[data-sort] { cursor: pointer; user-select: none; }
th[data-sort]:hover { color: var(--text); }
th[aria-sort="ascending"]::after { content: " ↑"; }
th[aria-sort="descending"]::after { content: " ↓"; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tbody tr.row { cursor: pointer; }
tbody tr.row:hover { background: var(--hover); }
tbody tr.row.open { background: var(--hover); }
tbody tr:last-child td { border-bottom: 0; }
.c-spark { width: 132px; }
.c-time { white-space: nowrap; color: var(--text-2); }
.name { font-weight: 500; line-height: 1.35; }
.m-dot, .lbl-short { display: none; }
.sub { font-size: 0.75rem; color: var(--muted); }
.above { color: var(--st-crit); font-weight: 600; }
.safe { color: var(--trend-down); font-weight: 600; }
.trend-up { color: var(--trend-up); }
.trend-down { color: var(--trend-down); }
.dlegend b.trend-up { color: var(--trend-up); }
.dlegend b.trend-down { color: var(--trend-down); }
.dpanel .dsum b .trend-up { color: var(--trend-up); }
.dpanel .dsum b .trend-down { color: var(--trend-down); }
.detail td { padding: 4px 16px 16px; background: var(--hover); }
.detail .inner { max-width: 900px; }
.detail-meta { margin-top: 8px; color: var(--text-2); }
#tbl .detail-meta .bl { position: static; width: auto; height: auto; clip: auto; }
.spark { display: block; }

.about { margin: 40px 0 24px; max-width: 760px; }
.about { scroll-margin-top: 16px; }
.about p, .about li { color: var(--text-2); }
.about p { margin: 8px 0; }
.about ul { margin: 8px 0; padding-left: 1.25em; }
.about li { margin: 4px 0; }
footer { padding-top: 16px; padding-bottom: 32px; border-top: 1px solid var(--grid); }
footer p { margin: 4px 0; }
footer .credit { color: var(--text-2); font-size: 0.875rem; }
footer .credit a { font-weight: 500; }

@media (max-width: 760px) {
  h1 { font-size: 1.25rem; }
  .top { flex-wrap: wrap; }
  .btn-label { display: none; }
  /* Map credits run under the legend on narrow maps: lift the legend above them. */
  .leaflet-control-attribution { font-size: 10px; }
  .leaflet-bottom.leaflet-left { bottom: 18px; }
  /* Station popup on phones: compact, and the legend steps aside while it's open */
  .has-popup .map-legend { display: none; }
  /* map is the page width minus 32px gutters; leave ~76px for the zoom column + edge */
  .pop-mobile .leaflet-popup-content { margin: 10px 12px; width: min(300px, calc(100vw - 132px)) !important; max-width: none; }
  .pop-mobile .pop h3 { font-size: 0.875rem; padding-right: 14px; }
  .pop-mobile .levels, .pop-mobile .traffic-box { font-size: 0.75rem; }
  /* Two columns so the legend covers less of a small map */
  .map-legend { display: grid; grid-template-columns: auto auto; column-gap: 10px; font-size: 0.625rem; }
  .map-legend .lg-sep { grid-column: 1 / -1; }
  .tiles { grid-template-columns: repeat(4, 1fr); }
  .tile .n { font-size: 1.25rem; }
  /* Station table on phones: status dot moves into the name cell; 4 columns fit */
  .c-time, .c-d1h, .c-status { display: none; }
  table { font-size: 0.8125rem; }
  th { font-size: 0.75rem; white-space: normal; }
  .lbl-full { display: none; }
  .lbl-short { display: inline; }
  .m-dot { display: inline-block; margin-right: 6px; vertical-align: 0.05em; }
  #tbl .name { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  #tbl .sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 42vw; }
  .c-spark { width: 64px; }
  .c-spark svg { width: 60px; height: 24px; }
  .dgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dcard { grid-template-columns: 1fr; }
  th, td { padding: 8px 6px; }
  .controls select { max-width: none; flex: 1 1 140px; }
}
@media (max-width: 420px) {
  .tiles { grid-template-columns: repeat(2, 1fr); }
}

/* service notice shown on entry while the data is frozen */
.notice {
  width: min(560px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); overflow: auto;
  padding: 20px 22px; border: 1px solid var(--border); border-radius: 12px;
  background: var(--surface); color: var(--text); box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
}
.notice::backdrop { background: rgba(0, 0, 0, 0.55); }
.notice h2 { margin: 0 0 10px; font-size: 1.25rem; color: var(--st-crit); }
.notice p { margin: 0 0 12px; line-height: 1.65; font-size: 0.9375rem; }
.notice .btn.primary { display: block; margin: 16px auto 0; min-width: 120px; justify-content: center; background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.notice .btn.primary:hover { filter: brightness(1.08); }
