/* ==========================================================================
   น้ำท่วมกรุงเทพฯ — v2 "flood bulletin"
   Paper + ink, hairline rules, square corners, depth in a single blue ramp,
   hazard yellow only for places to avoid.
   ========================================================================== */

:root {
  --paper: #f2efe6;
  --paper-2: #e9e5d8;
  --card: #fbfaf5;
  --ink: #14161a;
  --ink-2: #4b4f56;
  --ink-3: #7c7a70;
  --rule: #c8c1ae;
  --hair: rgba(20, 22, 26, .13);
  --hazard: #f5c400;
  --accent: #0b3d91;
  --accent-soft: #dde6f2;
  /* depth ramp (read by the shared JS through these names) */
  --sev1: #7d9a80;
  --sev2: #5aa3cc;
  --sev3: #1f6fb2;
  --sev4: #0b2f6b;
  --off: #a39d8c;
  --report: #b4460f;
  --dds: #14161a;
  --serif: "Noto Serif Thai", Georgia, serif;
  --sans: "IBM Plex Sans Thai", system-ui, sans-serif;
  /* Plex Mono has no Thai glyphs: let Thai fall through to Plex Sans Thai */
  --mono: "IBM Plex Mono", "IBM Plex Sans Thai", ui-monospace, monospace;
  --mast: 64px;
  --tick: 30px;
  --top: calc(var(--mast) + var(--tick));
  --bottom: 0px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0f1215; --paper-2: #161b20; --card: #13181c; --ink: #ece7da; --ink-2: #b3ad9f; --ink-3: #8a8577;
    --rule: #2e353d; --hair: rgba(236, 231, 218, .12); --accent: #8fbfff; --accent-soft: #1a2838;
    --sev1: #6f8f73; --sev2: #3f8fbf; --sev3: #3a86d6; --sev4: #7fb2ff; --off: #5d5a52; --report: #e0763a; --dds: #ece7da;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0f1215; --paper-2: #161b20; --card: #13181c; --ink: #ece7da; --ink-2: #b3ad9f; --ink-3: #8a8577;
  --rule: #2e353d; --hair: rgba(236, 231, 218, .12); --accent: #8fbfff; --accent-soft: #1a2838;
  --sev1: #6f8f73; --sev2: #3f8fbf; --sev3: #3a86d6; --sev4: #7fb2ff; --off: #5d5a52; --report: #e0763a; --dds: #ece7da;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--paper); color: var(--ink); font: 15px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
a { color: var(--ink); text-decoration-color: var(--rule); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--ink); }
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }
.muted { color: var(--ink-3); }
.small { font-size: 12.5px; }
.ic { width: 1.05em; height: 1.05em; vertical-align: -.16em; display: inline-block; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- masthead ---------- */
.masthead {
  position: fixed; inset: 0 0 auto 0; height: var(--mast); z-index: 800;
  display: flex; align-items: center; gap: 22px; padding: 0 20px;
  background: var(--paper); border-bottom: 3px double var(--ink);
}
.wordmark { display: flex; align-items: baseline; gap: 6px; text-decoration: none; color: var(--ink); flex: none; }
.wm-1 { font: 800 26px/1 var(--serif); letter-spacing: -.01em; }
.wm-2 { font: 600 17px/1 var(--serif); color: var(--ink-2); }
.edition { display: flex; align-items: center; gap: 8px; font: 500 12px/1.3 var(--mono); color: var(--ink-2); min-width: 0; }
.edition #updated { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.edition .warn { color: var(--report); }
.ed-label { text-transform: uppercase; letter-spacing: .08em; color: var(--ink); font-weight: 600; }
.live-dot { width: 8px; height: 8px; background: #d62d20; border-radius: 50%; flex: none; animation: blink 2s steps(1) infinite; }
@keyframes blink { 50% { opacity: .25; } }
.nav { display: flex; margin-left: auto; }
.nav a {
  display: flex; align-items: baseline; gap: 7px; padding: 6px 14px; text-decoration: none; color: var(--ink-2);
  font-weight: 500; border-left: 1px solid var(--hair); white-space: nowrap;
}
.nav a:first-child { border-left: 0; }
.nav a i { font: 600 11px var(--mono); font-style: normal; color: var(--ink-3); }
.nav a:hover { color: var(--ink); }
.nav a.on { color: var(--ink); box-shadow: inset 0 -3px 0 var(--hazard); }
.nav a.on i { color: var(--ink); }
.vlink { flex: none; font: 600 12px var(--mono); color: var(--ink-2); text-decoration: none; white-space: nowrap; padding: 6px 4px; }
.vlink:hover { color: var(--ink); box-shadow: inset 0 -2px 0 var(--hazard); }
.icon-btn {
  width: 36px; height: 36px; display: grid; place-items: center; flex: none;
  background: transparent; border: 1px solid var(--ink); border-radius: 0;
}
.icon-btn:hover { background: var(--ink); color: var(--paper); }
.icon-btn.spin svg { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- ticker ---------- */
.ticker {
  position: fixed; top: var(--mast); left: 0; right: 0; height: var(--tick); z-index: 790;
  display: flex; align-items: center; background: var(--ink); color: var(--paper); overflow: hidden;
  font: 500 12.5px/1 var(--mono);
}
.tk-label { flex: none; height: 100%; display: flex; align-items: center; padding: 0 12px; background: var(--hazard); color: #14161a; font-weight: 600; letter-spacing: .04em; }
.tk-track { flex: 1; overflow: hidden; height: 100%; display: flex; align-items: center; mask-image: linear-gradient(90deg, transparent, #000 24px, #000 calc(100% - 24px), transparent); }
.tk-inner { display: inline-flex; gap: 34px; white-space: nowrap; padding-left: 24px; animation: tick var(--tk-dur, 60s) linear infinite; }
.tk-inner:hover { animation-play-state: paused; }
.tk-inner a { color: var(--paper); text-decoration: none; }
.tk-inner b { color: var(--hazard); font-weight: 600; margin-left: 6px; }
@keyframes tick { to { transform: translateX(-50%); } }
.tk-label small { font-weight: 500; opacity: .75; margin-left: 4px; }
.tk-inner.tk-rotate { animation: none; padding-left: 16px; overflow: hidden; text-overflow: ellipsis; max-width: 100%; animation: tkfade .5s ease; }
@keyframes tkfade { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .tk-inner { animation: none; } .live-dot { animation: none; } }
:root[data-theme] .ticker, .ticker { color-scheme: dark; }

.view { position: fixed; top: var(--top); left: 0; right: 0; bottom: var(--bottom); }
.page { overflow-y: auto; -webkit-overflow-scrolling: touch; }
.wrap { max-width: 1160px; margin: 0 auto; padding: 28px 24px 40px; }

/* ---------- 01 map ---------- */
#view-map { display: grid; grid-template-columns: 400px 1fr; grid-template-rows: minmax(0, 1fr) auto; }
#view-map > #panel { grid-column: 1; grid-row: 1; }
#view-map > .mapwrap { grid-column: 2; grid-row: 1; position: relative; min-height: 0; }
.mapwrap > #map { position: absolute; inset: 0; background: var(--paper-2); }
.sitefoot { grid-column: 1 / -1; grid-row: 2; }
#map .leaflet-gl-layer { filter: sepia(.14) saturate(.85) contrast(1.02); }
@media (prefers-color-scheme: dark) { #map .leaflet-gl-layer { filter: none; } }

#panel { display: flex; flex-direction: column; min-height: 0; background: var(--paper); border-right: 1px solid var(--ink); z-index: 500; }
#panel > .foot { display: none; }
.grab { display: none; }

.search { display: flex; align-items: center; margin: 16px 18px 12px; border-bottom: 2px solid var(--ink); }
.search input { flex: 1; min-width: 0; border: 0; background: transparent; color: var(--ink); font: 500 16px var(--sans); padding: 8px 0; outline: none; }
.search input::placeholder { color: var(--ink-3); }
.search button { border: 0; background: none; padding: 6px; color: var(--ink); }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); margin: 0 18px; border-top: 1px solid var(--ink); border-bottom: 1px solid var(--hair); }
.stat { background: none; border: 0; border-left: 1px solid var(--hair); border-radius: 0; padding: 10px 8px 9px 10px; text-align: left; position: relative; }
.stat:first-child { border-left: 0; padding-left: 0; }
.stat b { display: block; font: 800 26px/1 var(--serif); font-variant-numeric: tabular-nums; }
.stat span { display: block; margin-top: 5px; font: 500 11px/1.2 var(--mono); color: var(--ink-2); }
.stat .dot { display: inline-block; width: 8px; height: 8px; margin-right: 5px; vertical-align: 0; border-radius: 0; }
.stat.on::after { content: ""; position: absolute; left: 0; right: 8px; bottom: -1px; height: 3px; background: var(--hazard); }
.stat:first-child.on::after { left: 0; }

.layers { margin: 10px 18px 4px; }
.layers summary { cursor: pointer; font: 600 11.5px var(--mono); text-transform: uppercase; letter-spacing: .06em; color: var(--ink-2); list-style: none; padding: 4px 0; }
.layers summary::-webkit-details-marker { display: none; }
.layers summary::before { content: "+ "; }
.layers[open] summary::before { content: "− "; }
.toggles { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; padding: 6px 0 8px; }
.toggles label, .chk { display: inline-flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--ink-2); cursor: pointer; }
.toggles input, .chk input {
  appearance: none; width: 14px; height: 14px; margin: 0; border: 1.5px solid var(--ink); background: transparent; flex: none; display: grid; place-items: center;
}
.toggles input:checked, .chk input:checked { background: var(--ink); box-shadow: inset 0 0 0 2px var(--paper); }

.tabs { display: flex; gap: 18px; padding: 8px 18px 0; border-bottom: 1px solid var(--ink); }
.tab { border: 0; background: none; padding: 8px 0; color: var(--ink-3); font-weight: 600; border-bottom: 3px solid transparent; margin-bottom: -1px; }
.tab.on { color: var(--ink); border-bottom-color: var(--ink); }
.tab span { font: 500 12px var(--mono); color: var(--ink-3); }

.list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
.item { display: flex; gap: 12px; align-items: center; padding: 10px 18px; cursor: pointer; border-bottom: 1px solid var(--hair); }
.item:hover, .item:focus-visible { background: var(--paper-2); outline: none; }
.badge {
  flex: none; min-width: 58px; padding: 5px 6px 4px; border-radius: 0; text-align: center; color: #fff;
  font: 600 16px/1 var(--mono); font-variant-numeric: tabular-nums;
}
.badge small { font: 500 10px var(--mono); opacity: .85; }
.item .t { flex: 1; min-width: 0; }
.item .n { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .m { font-size: 12.5px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.empty { padding: 28px 18px; color: var(--ink-3); text-align: center; font-family: var(--serif); }
.more { display: block; width: calc(100% - 36px); margin: 12px 18px; padding: 8px; border: 1px solid var(--ink); background: none; font: 600 13px var(--mono); }
.more:hover { background: var(--ink); color: var(--paper); }

.map-ctl { position: absolute; right: 12px; top: 84px; z-index: 600; }
.fab { width: 40px; height: 40px; display: grid; place-items: center; background: var(--paper); border: 1px solid var(--ink); border-radius: 0; box-shadow: 3px 3px 0 var(--ink); }
.fab:hover { background: var(--hazard); color: #14161a; }
.fab:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }

.legend {
  position: absolute; right: 12px; bottom: 26px; z-index: 600; width: 212px;
  background: var(--paper); border: 1px solid var(--ink); box-shadow: 3px 3px 0 var(--ink); padding: 10px 12px; font-size: 12px;
}
.lg-title { font: 600 11px var(--mono); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 6px; }
.lg-ramp { display: grid; grid-template-columns: repeat(4, 1fr); height: 10px; }
.lg-scale { display: grid; grid-template-columns: repeat(4, 1fr); font: 500 10.5px var(--mono); color: var(--ink-2); margin: 3px 0 8px; }
.lg-row { display: flex; align-items: center; gap: 8px; line-height: 1.75; color: var(--ink-2); }
.lg-row i { width: 12px; height: 12px; flex: none; }
.lg-hz { background: repeating-linear-gradient(45deg, var(--hazard) 0 3px, #14161a 3px 6px); }
.lg-rp { background: var(--report); transform: rotate(45deg) scale(.8); }
.lg-dd { background: var(--dds); box-shadow: inset 0 0 0 2px var(--hazard); }

.toast {
  position: fixed; left: 50%; top: calc(var(--top) + 10px); transform: translate(-50%, -12px); opacity: 0; z-index: 900;
  background: var(--ink); color: var(--paper); padding: 8px 14px; font: 500 13.5px var(--sans);
  transition: opacity .2s, transform .2s; pointer-events: none; max-width: calc(100% - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- markers ---------- */
.pin {
  width: 32px; height: 22px; display: grid; place-items: center; color: #fff;
  font: 600 11.5px/1 var(--mono); border: 1.5px solid var(--paper); box-shadow: 0 1px 3px rgba(0,0,0,.4); margin: 4px 0 0 -1px;
}
.pin.small { width: 11px; height: 11px; margin: 1px 0 0 1px; border-width: 1.5px; font-size: 0; }
.pin.pulse { outline: 3px solid var(--hazard); outline-offset: 0; box-shadow: 0 0 0 5px #14161a; }
.rpt { width: 12px; height: 12px; margin: 1px; background: var(--report); border: 1.5px solid var(--paper); transform: rotate(45deg); }
.rpt.deep { background: #7a1d0c; }
.ddsm { min-width: 36px; height: 22px; padding: 0 5px; display: grid; place-items: center; background: #14161a; color: var(--hazard); font: 600 11.5px var(--mono); border: 1.5px solid var(--hazard); }
.ddsm.dry { color: #a39d8c; border-color: #a39d8c; }
.camm { width: 24px; height: 24px; display: grid; place-items: center; background: var(--ink); color: var(--paper); border: 1.5px solid var(--paper); font-size: 14px; }
.rainm { border-radius: 50%; display: grid; place-items: center; color: #fff; font: 600 10px var(--mono); border: 1.5px solid rgba(255,255,255,.9); }
.canalm { width: 14px; height: 14px; border: 2px solid var(--paper); box-shadow: 0 0 0 1px var(--ink); }
.me { width: 16px; height: 16px; border-radius: 50%; background: var(--accent); border: 3px solid var(--paper); box-shadow: 0 0 0 1.5px var(--ink); }
/* citizen-report clusters stay quieter than the sensor readings */
.marker-cluster-small, .marker-cluster-medium, .marker-cluster-large { background: transparent !important; }
.marker-cluster-small div, .marker-cluster-medium div, .marker-cluster-large div {
  background: var(--paper) !important; color: var(--report); border: 1.5px solid var(--report); font: 600 10.5px/27px var(--mono); border-radius: 50% !important;
}
.marker-cluster { text-align: center; }
.marker-cluster div { width: 30px; height: 30px; margin: 5px 0 0 5px; text-align: center; }
.marker-cluster span { line-height: 27px; }

/* ---------- popups ---------- */
.leaflet-popup-content-wrapper { background: var(--paper); color: var(--ink); border-radius: 0; border: 1px solid var(--ink); box-shadow: 4px 4px 0 var(--ink); }
.leaflet-popup-tip { background: var(--paper); border: 1px solid var(--ink); box-shadow: none; }
.leaflet-popup-content { margin: 14px 16px; font: 14px/1.5 var(--sans); min-width: 240px; }
.leaflet-container a.leaflet-popup-close-button { color: var(--ink); font: 600 18px var(--mono); }
.pp h3 { margin: 0 0 2px; font: 700 17px/1.3 var(--serif); }
.pp .road { color: var(--ink-3); font-size: 12.5px; }
.pp .big { display: flex; align-items: baseline; gap: 8px; margin: 10px 0 6px; font: 500 13px var(--mono); }
.pp .big b { font: 800 36px/1 var(--serif); font-variant-numeric: tabular-nums; }
.pp .chip, .chip-s { display: inline-block; padding: 2px 7px; color: #fff; font: 600 11px/1.4 var(--mono); border-radius: 0; }
.pp dl { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; margin: 8px 0; font-size: 12.5px; border-top: 1px solid var(--hair); padding-top: 8px; }
.pp dt { color: var(--ink-3); font: 500 11.5px/1.7 var(--mono); }
.pp dd { margin: 0; }
.pp .spark { margin: 6px 0 2px; }
.pp .spark svg { display: block; }
.pp .spark small { color: var(--ink-3); font: 500 10.5px var(--mono); }
.pp .links { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; margin-top: 8px; }
.pp img { width: 100%; max-height: 190px; object-fit: cover; margin: 8px 0 4px; background: var(--paper-2); display: block; }
.pp .txt { font-size: 13px; max-height: 120px; overflow: auto; white-space: pre-line; }
.pp .livebtn { border: 1px solid var(--ink); background: var(--hazard); color: #14161a; padding: 3px 10px; font: 600 12px var(--mono); }
.leaflet-control-attribution { font: 10px var(--sans); background: rgba(242, 239, 230, .85) !important; }
.leaflet-bar { border: 1px solid var(--ink) !important; border-radius: 0 !important; box-shadow: 3px 3px 0 var(--ink) !important; }
.leaflet-bar a { background: var(--paper); color: var(--ink); border-radius: 0 !important; border-bottom-color: var(--ink) !important; }

/* ---------- pages ---------- */
.page-head { border-bottom: 1px solid var(--ink); padding-bottom: 18px; margin-bottom: 18px; display: grid; gap: 8px; }
.kicker { margin: 0; font: 600 12px var(--mono); text-transform: uppercase; letter-spacing: .08em; color: var(--ink-2); }
.page-head h2 { margin: 0; font: 800 clamp(26px, 3.4vw, 40px)/1.2 var(--serif); letter-spacing: -.01em; max-width: 22em; }
.dek { margin: 0; color: var(--ink-2); font-size: 15px; max-width: 46em; }
.page input[type="search"] {
  font: 500 15px var(--sans); color: var(--ink); background: transparent; border: 0; border-bottom: 2px solid var(--ink);
  padding: 7px 0; min-width: 240px; max-width: 360px; outline: none; border-radius: 0;
}
.page-head input[type="search"] { margin-top: 6px; }

.figures { display: flex; flex-wrap: wrap; margin: 0 0 18px; border-top: 1px solid var(--hair); border-bottom: 1px solid var(--hair); }
.chipbox { padding: 12px 22px 12px 0; margin-right: 22px; border-right: 1px solid var(--hair); display: flex; flex-direction: column; }
.chipbox:last-child { border-right: 0; }
.chipbox b { font: 800 32px/1 var(--serif); font-variant-numeric: tabular-nums; }
.chipbox span { font: 500 11.5px/1.3 var(--mono); color: var(--ink-2); margin-top: 6px; max-width: 18em; }

.filters { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; margin-bottom: 18px; }
.seg { display: inline-flex; border: 1px solid var(--ink); }
.seg button { border: 0; background: none; padding: 6px 12px; font: 600 12.5px var(--mono); color: var(--ink-2); border-left: 1px solid var(--ink); }
.seg button:first-child { border-left: 0; }
.seg button.on { background: var(--ink); color: var(--paper); }
.sec { margin: 34px 0 12px; font: 700 20px/1.3 var(--serif); display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; border-top: 3px solid var(--ink); padding-top: 10px; }
.sec .muted { font: 500 12px var(--mono); }
#canalFilter { margin-bottom: 12px; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 24px 20px; }
.card { display: flex; flex-direction: column; border-top: 1px solid var(--ink); padding-top: 12px; }
.card .cam-img { position: relative; aspect-ratio: 16 / 10; background: var(--paper-2); cursor: pointer; overflow: hidden; }
.card .cam-img img, .camcard img { width: 100%; height: 100%; object-fit: cover; display: block; filter: contrast(1.03); }
.card .cam-img:hover img, .camcard:hover img { filter: contrast(1.08) brightness(1.03); }
.cam-img .tag, .camcard .tag {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 5px 60px 5px 8px; background: rgba(20, 22, 26, .78); color: #f2efe6;
  font: 500 11px/1.35 var(--mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cam-img .play, .camcard .play { position: absolute; right: 0; bottom: 0; padding: 5px 9px; background: var(--hazard); color: #14161a; font: 600 11px/1.35 var(--mono); }
.card .body { padding: 10px 0 0; display: flex; gap: 12px; align-items: flex-start; }
.card .body .t { flex: 1; min-width: 0; }
.card h4 { margin: 0; font: 700 18px/1.3 var(--serif); }
.card .m { color: var(--ink-3); font-size: 12.5px; margin-top: 3px; }
.card .acts { display: flex; gap: 14px; margin-top: 8px; font-size: 13px; }
.card .acts button { border: 0; background: none; padding: 0; text-decoration: underline; text-decoration-color: var(--rule); text-underline-offset: 3px; }
.src { display: inline-block; font: 600 10.5px/1.5 var(--mono); padding: 0 5px; border: 1px solid var(--ink-3); color: var(--ink-2); margin-right: 6px; text-transform: uppercase; }
.nocam { aspect-ratio: auto; padding: 14px; font: 500 12px var(--mono); color: var(--ink-3); background: var(--paper-2); }

.plist { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--ink); }
.plist:empty { display: none; }
.prow { display: flex; gap: 14px; align-items: center; padding: 11px 0; border-bottom: 1px solid var(--hair); cursor: pointer; }
.prow:hover, .prow:focus-visible { background: var(--paper-2); outline: none; }
.prow .t { flex: 1; min-width: 0; }
.prow .n { font-weight: 600; }
.prow .m { color: var(--ink-3); font-size: 12.5px; margin-top: 2px; }
.prow .go { font: 600 12px var(--mono); white-space: nowrap; padding-right: 6px; }

.cams { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.camcard { position: relative; aspect-ratio: 16 / 10; overflow: hidden; background: var(--paper-2); cursor: pointer; }
.camcard.off { display: flex; flex-direction: column; gap: 4px; justify-content: center; padding: 12px; cursor: default; font-size: 12px; color: var(--ink-3); border: 1px dashed var(--rule); background: transparent; }
.camcard.off b { color: var(--ink-2); font-weight: 600; }
#camNote { margin: 0 0 12px; }

.table-wrap { overflow-x: auto; border-top: 1px solid var(--ink); }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th, .tbl td { padding: 9px 12px 9px 0; text-align: left; border-bottom: 1px solid var(--hair); white-space: nowrap; }
.tbl th { font: 600 11px var(--mono); text-transform: uppercase; letter-spacing: .05em; color: var(--ink-2); position: sticky; top: 0; background: var(--paper); }
.tbl td.num, .tbl th.num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.tbl td.name { white-space: normal; min-width: 200px; font-weight: 500; }
.tbl td.name .muted { font-weight: 400; }
.tbl tr.click { cursor: pointer; }
.tbl tr.click:hover td { background: var(--paper-2); }

.radar-box { border: 1px solid var(--ink); box-shadow: 4px 4px 0 var(--ink); background: var(--paper); }
#radarMap { height: 460px; }
.radar-ctl { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-top: 1px solid var(--ink); }
.radar-ctl button { width: 38px; height: 32px; border: 1px solid var(--ink); background: var(--hazard); color: #14161a; display: grid; place-items: center; }
.radar-ctl input { flex: 1; accent-color: var(--ink); }
.radar-ctl span { font: 600 13px var(--mono); min-width: 120px; text-align: right; }

dialog#live { border: 1px solid var(--ink); border-radius: 0; padding: 0; width: min(940px, 96vw); background: var(--paper); color: var(--ink); box-shadow: 6px 6px 0 var(--ink); }
dialog#live::backdrop { background: rgba(15, 18, 21, .72); }
.live-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 12px 10px 16px; border-bottom: 1px solid var(--ink); font: 700 16px var(--serif); }
#liveVideo { width: 100%; max-height: 70vh; background: #000; display: block; }
#liveNote { margin: 0; padding: 10px 16px 12px; color: var(--ink-2); font-size: 12.5px; }

/* friendly failure notes */
.imgfail { display: block; padding: 10px 12px; font-size: 12.5px; line-height: 1.55; color: var(--ink-2); background: var(--paper-2); border-left: 3px solid var(--hazard); }
.cam-img .imgfail { position: absolute; inset: 0; display: grid; place-items: center; padding: 14px 16px; }
.pp .imgfail { margin: 8px 0; }
#liveNote.imgfail { background: var(--paper-2); }

/* credits */
.credits { color: var(--ink-2); font-size: 12px; line-height: 1.7; }
.credits b { font-family: var(--serif); color: var(--ink); }
.sitefoot { padding: 8px 20px; background: var(--paper); border-top: 1px solid var(--ink); z-index: 600; }
.page-foot { margin-top: 44px; padding-top: 14px; border-top: 3px double var(--ink); }

/* ---------- narrower screens ---------- */
@media (max-width: 1080px) {
  .edition .ed-label { display: none; }
  .nav a { padding: 6px 10px; }
}
@media (max-width: 900px) {
  .edition { display: none; }
}
@media (max-width: 760px) {
  :root { --mast: 54px; --tick: 28px; --bottom: 60px; }
  .masthead { gap: 10px; padding: 0 12px; }
  .wm-1 { font-size: 22px; }
  .wm-2 { font-size: 14px; }
  .edition { display: flex; margin-left: auto; font-size: 11px; max-width: 34vw; }
  .vlink { font-size: 11px; padding: 6px 2px; }
  .vlink[href="/"] { display: none; } /* phones: keep "ทั่วประเทศ", drop "แบบเดิม" to save room */
  .edition .ed-label, .edition .live-dot { display: none; }
  .nav {
    position: fixed; left: 0; right: 0; bottom: 0; height: var(--bottom); margin: 0;
    background: var(--paper); border-top: 3px double var(--ink); padding-bottom: env(safe-area-inset-bottom);
  }
  .nav a { flex: 1; flex-direction: column; align-items: center; justify-content: center; gap: 1px; padding: 4px 2px; border-left: 1px solid var(--hair); font-size: 12.5px; }
  .nav a.on { box-shadow: inset 0 3px 0 var(--hazard); background: var(--paper-2); }

  #view-map { display: block; }
  #view-map > .mapwrap { position: absolute; inset: 0; }
  .sitefoot { display: none; }
  #panel {
    position: absolute; left: 0; right: 0; bottom: 0; height: 46%; border-right: 0; border-top: 1px solid var(--ink);
    box-shadow: 0 -4px 0 var(--ink); transition: height .25s ease;
  }
  #panel.min { height: 158px; }
  #panel.max { height: 92%; }
  #panel.max > .foot { display: block; padding: 12px 18px 18px; border-top: 1px solid var(--hair); }
  .grab { display: block; width: 48px; height: 4px; background: var(--ink); margin: 8px auto 0; flex: none; cursor: grab; }
  .search { margin-top: 8px; }
  .stat b { font-size: 22px; }
  .legend { top: 12px; bottom: auto; left: 12px; right: auto; width: 168px; padding: 7px 9px; cursor: pointer; box-shadow: 2px 2px 0 var(--ink); }
  .legend.collapsed .lg-title { font-size: 10px; margin-bottom: 4px; }
  .legend.collapsed .lg-ramp { height: 7px; }
  .legend.collapsed > :not(.lg-title):not(.lg-ramp):not(.lg-scale) { display: none; }
  .legend.collapsed .lg-scale { margin-bottom: 0; }
  .leaflet-control-zoom { display: none; }
  .map-ctl { top: 12px; }
  .wrap { padding: 18px 14px 30px; }
  .chipbox { padding-right: 14px; margin-right: 14px; }
  .chipbox b { font-size: 26px; }
  .page input[type="search"] { min-width: 0; max-width: none; width: 100%; }
  .cards { grid-template-columns: 1fr; }
  .cams { grid-template-columns: 1fr 1fr; gap: 8px; }
  #radarMap { height: 340px; }
}

/* BMA pumping stations / floodgates / pump wells (tPumps, tWells) */
.pumpm { width: 20px; height: 20px; display: grid; place-items: center; font: 700 11px/1 var(--mono); border: 2px solid var(--sev3); background: var(--paper); color: var(--sev3); box-shadow: 0 0 0 1px var(--ink); }
.pumpm.work { background: var(--sev3); color: #fff; }
.pumpm.down { background: var(--paper-2); color: var(--off); border: 2px dashed var(--off); }
.pumpm.well { border-radius: 50%; width: 16px; height: 16px; font-size: 9px; }
.pumpchip.work { background: var(--sev3) !important; } .pumpchip.wait { background: var(--sev1) !important; } .pumpchip.down { background: var(--off) !important; }

/* header 761–960 px: the บ้านฉัน link needs the room of the "back to v1" link */
@media (min-width: 761px) and (max-width: 960px) { .vlink[href="/"] { display: none; } }
@media (min-width: 761px) and (max-width: 960px) { .masthead { gap: 10px; } .vlink { padding-left: 4px; padding-right: 4px; } }
