/* ==========================================================================
   น้ำท่วมประเทศไทย — /thailand (national). Own copy of the v2 "flood bulletin" styles; not shared with v1/v2.
   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-overview { display: grid; grid-template-columns: 400px 1fr; grid-template-rows: minmax(0, 1fr) auto; }
#view-overview > #panel { grid-column: 1; grid-row: 1; }
#view-overview > .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; }
  .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-overview { display: block; }
  #view-overview > .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; }
}

/* ==========================================================================
   /thailand additions
   ========================================================================== */
:root {
  /* province situation levels */
  --lv4: #0b2f6b; --lv3: #3a86c8; --lv2: #a9cbe3;
  /* station % of bank capacity */
  --st5: #0b2f6b; --st4: #2f7fc0; --st3: #9cc3dd;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --lv4: #7fb2ff; --lv3: #3a86d6; --lv2: #24476b; --st5: #9dcbff; --st4: #3f8fd6; --st3: #2a4a66; }
}

/* province picker in the masthead */
.picker { position: relative; flex: none; }
.pick-btn {
  display: flex; align-items: baseline; gap: 8px; height: 38px; padding: 0 12px;
  background: var(--card); border: 1px solid var(--ink); box-shadow: 2px 2px 0 var(--ink);
}
.pick-btn:hover { background: var(--hazard); color: #14161a; }
.pick-label { font: 600 10.5px var(--mono); text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); }
.pick-btn b { font: 700 16px var(--serif); max-width: 12em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick-btn svg { align-self: center; }
.pick-pop {
  position: absolute; top: calc(100% + 8px); left: 0; z-index: 900; width: 300px; max-height: min(70vh, 560px);
  display: flex; flex-direction: column; background: var(--paper); border: 1px solid var(--ink); box-shadow: 4px 4px 0 var(--ink);
}
.pick-pop input { margin: 10px; padding: 7px 0; border: 0; border-bottom: 2px solid var(--ink); background: transparent; color: var(--ink); font: 500 15px var(--sans); outline: none; }
.pick-pop ul { list-style: none; margin: 0; padding: 0 0 6px; overflow-y: auto; }
.pick-pop li { display: flex; align-items: center; gap: 10px; padding: 7px 12px; cursor: pointer; }
.pick-pop li:hover, .pick-pop li.on, .pick-pop li:focus-visible { background: var(--paper-2); outline: none; }
.pick-pop li .lvl { width: 10px; height: 10px; flex: none; }
.pick-pop li span:last-child { margin-left: auto; font: 500 11px var(--mono); color: var(--ink-3); }
.versions { display: flex; gap: 10px; flex: none; }
.versions a { font: 600 12px var(--mono); color: var(--ink-2); text-decoration: none; white-space: nowrap; }
.versions a:hover { color: var(--ink); box-shadow: inset 0 -2px 0 var(--hazard); }

/* panel content */
#view-overview { grid-template-columns: 420px 1fr; }
.panel-body { flex: 1; overflow-y: auto; padding: 16px 18px 24px; }
.p-kicker { margin: 0 0 4px; font: 600 11.5px var(--mono); text-transform: uppercase; letter-spacing: .08em; color: var(--ink-2); }
.p-title { margin: 0; font: 800 30px/1.15 var(--serif); }
.p-back { border: 0; background: none; padding: 0; margin-bottom: 8px; font: 600 12px var(--mono); color: var(--ink-2); text-decoration: underline; text-underline-offset: 3px; }
.p-level { display: inline-block; margin-top: 8px; padding: 3px 9px; font: 600 12px var(--mono); color: #fff; }
.p-level.l1 { background: transparent; color: var(--ink-2); border: 1px solid var(--rule); }
.p-level.l2 { background: var(--lv2); color: #14161a; }
.p-level.l3 { background: var(--lv3); }
.p-level.l4 { background: var(--lv4); box-shadow: 0 0 0 3px var(--hazard); }
.p-figs { display: grid; grid-template-columns: repeat(3, 1fr); margin: 14px 0 6px; border-top: 1px solid var(--ink); }
.p-figs div { padding: 9px 8px 9px 0; border-bottom: 1px solid var(--hair); }
.p-figs b { display: block; font: 800 24px/1 var(--serif); font-variant-numeric: tabular-nums; }
.p-figs span { display: block; margin-top: 4px; font: 500 11px/1.3 var(--mono); color: var(--ink-2); }
.p-sec { margin: 18px 0 6px; padding-top: 8px; border-top: 3px solid var(--ink); font: 700 16px var(--serif); display: flex; justify-content: space-between; align-items: baseline; }
.p-sec small { font: 500 11px var(--mono); color: var(--ink-3); }
.p-note { font-size: 12.5px; color: var(--ink-2); margin: 6px 0; }
.bkk-box { margin: 14px 0; padding: 10px 12px; border: 1px solid var(--ink); background: var(--card); font-size: 13.5px; }
.bkk-box a { font-weight: 600; }

.prov-list, .mini-list { list-style: none; margin: 0; padding: 0; }
.prov-row { display: grid; grid-template-columns: 12px 1fr auto; gap: 10px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--hair); cursor: pointer; }
.prov-row:hover, .prov-row:focus-visible { background: var(--paper-2); outline: none; }
.prov-row .lvl { width: 12px; height: 34px; }
.prov-row .n { font: 700 16px var(--serif); }
.prov-row .m { font-size: 12px; color: var(--ink-3); }
.prov-row .v { font: 600 13px var(--mono); text-align: right; }
.prov-row .v small { display: block; font: 500 10.5px var(--mono); color: var(--ink-3); }
.lvl.l1 { background: transparent; border: 1px solid var(--rule); }
.lvl.l2 { background: var(--lv2); }
.lvl.l3 { background: var(--lv3); }
.lvl.l4 { background: var(--lv4); }
.mini-list li { display: flex; gap: 10px; align-items: baseline; padding: 7px 0; border-bottom: 1px solid var(--hair); cursor: pointer; font-size: 13.5px; }
.mini-list li:hover { background: var(--paper-2); }
.mini-list .pct { flex: none; min-width: 58px; padding: 2px 5px; font: 600 12.5px var(--mono); color: #fff; text-align: center; }
.mini-list .t { flex: 1; min-width: 0; }
.mini-list .t small { display: block; color: var(--ink-3); font-size: 11.5px; }
.mini-more { border: 0; background: none; padding: 6px 0; font: 600 12px var(--mono); text-decoration: underline; }

/* map furniture */
.mapwrap .layers {
  position: absolute; left: 12px; top: 12px; z-index: 600; margin: 0; padding: 8px 12px; min-width: 190px;
  background: var(--paper); border: 1px solid var(--ink); box-shadow: 3px 3px 0 var(--ink);
}
.mapwrap .layers label { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); padding: 2px 0; cursor: pointer; }
.mapwrap .layers input { appearance: none; width: 14px; height: 14px; margin: 0; border: 1.5px solid var(--ink); flex: none; }
.mapwrap .layers input:checked { background: var(--ink); box-shadow: inset 0 0 0 2px var(--paper); }
.mapwrap .layers[open] summary { margin-bottom: 4px; }
.legend .lg-row i { border-radius: 0; }
.lg-gap { margin-top: 8px; }
.lg-none { border: 1px solid var(--rule); }
.lg-dot { border-radius: 50% !important; width: 11px !important; height: 11px !important; }
.lg-over { background: var(--st5); box-shadow: 0 0 0 2px var(--hazard); }
.prov-label { font: 600 11px var(--sans); color: var(--ink); text-shadow: 0 0 3px var(--paper), 0 0 3px var(--paper); white-space: nowrap; pointer-events: none; }
.damm { min-width: 34px; height: 20px; padding: 0 4px; display: grid; place-items: center; background: var(--paper); border: 1.5px solid var(--ink); font: 600 10.5px var(--mono); color: var(--ink); }
.damm.hi { background: var(--hazard); color: #14161a; }
.evm { width: 11px; height: 11px; background: var(--report); border: 1.5px solid var(--paper); transform: rotate(45deg); }
.ewsm { width: 20px; height: 20px; display: grid; place-items: center; background: var(--hazard); color: #14161a; border: 1.5px solid #14161a; font: 700 12px var(--mono); }
.ewsm.crit { background: #14161a; color: var(--hazard); border-color: var(--hazard); }

/* cameras page */
.cam-group { margin-bottom: 26px; }
.cam-group h3 .lvl { width: 10px; height: 20px; flex: none; display: inline-block; }
.camcard.nosnap { display: flex; flex-direction: column; justify-content: space-between; padding: 12px; background: var(--card); border: 1px solid var(--hair); }
.camcard.nosnap b { font: 600 13.5px/1.35 var(--sans); }
.camcard.nosnap .play { position: static; align-self: flex-start; }

/* alerts page */
.sub-sec { margin: 22px 0 8px; font: 700 16px var(--serif); }
.sub-sec .muted { font: 500 11.5px var(--mono); }
.official { border: 1px solid var(--ink); background: var(--card); padding: 14px 16px; margin-bottom: 12px; box-shadow: 4px 4px 0 var(--ink); }
.official .src-tag { display: inline-block; font: 600 11px var(--mono); padding: 2px 7px; background: #14161a; color: var(--hazard); margin-bottom: 8px; }
.official h4 { margin: 0 0 6px; font: 700 18px/1.35 var(--serif); }
.official .when { font: 500 12px var(--mono); color: var(--ink-2); margin-bottom: 8px; }
.official p { margin: 0 0 8px; white-space: pre-line; font-size: 14px; }
.official details summary { cursor: pointer; font: 600 12px var(--mono); }
.warnlist { list-style: none; margin: 0 0 10px; padding: 0; border-top: 1px solid var(--ink); }
.warnlist li { padding: 8px 0; border-bottom: 1px solid var(--hair); font-size: 14px; }
.warnlist li small { font: 500 11px var(--mono); color: var(--ink-3); margin-right: 8px; }
.ews-lv { display: inline-block; padding: 1px 7px; font: 600 11px var(--mono); background: var(--hazard); color: #14161a; }
.ews-lv.crit { background: #14161a; color: var(--hazard); }
.ews-lv.prep { background: transparent; border: 1px solid var(--ink); color: var(--ink); }
.fcbar { display: inline-block; height: 8px; background: var(--lv3); vertical-align: middle; margin-right: 6px; min-width: 1px; }
.tbl td.fc { white-space: nowrap; font-family: var(--mono); font-size: 13px; }
.tbl td.fc small { color: var(--ink-3); }

.ai-box { border: 1px dashed var(--ink); padding: 16px 18px; background: var(--card); }
.ai-flag { padding: 10px 12px; margin-bottom: 14px; background: var(--paper-2); border-left: 4px solid var(--hazard); font-size: 13px; color: var(--ink-2); }
.ai-flag b { color: var(--ink); }
.ai-box h4 { margin: 0 0 8px; font: 800 22px/1.3 var(--serif); }
.ai-box p { margin: 0 0 10px; font-size: 15px; }
.ai-risks { list-style: none; margin: 10px 0; padding: 0; border-top: 1px solid var(--ink); }
.ai-risks li { display: grid; grid-template-columns: 76px 1fr; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--hair); }
.ai-risks .rk { font: 600 12px var(--mono); padding: 3px 6px; text-align: center; align-self: start; color: #fff; background: var(--lv3); }
.ai-risks .rk.r3 { background: var(--lv4); box-shadow: 0 0 0 2px var(--hazard); }
.ai-risks .rk.r1 { background: var(--lv2); color: #14161a; }
.ai-risks b { font: 700 16px var(--serif); cursor: pointer; }
.ai-risks .hz { font: 500 11.5px var(--mono); color: var(--ink-2); margin-left: 6px; }
.ref { font: 600 10.5px var(--mono); vertical-align: super; margin-left: 2px; color: var(--accent); text-decoration: none; }
.ai-refs { margin: 12px 0 0; padding: 10px 0 0; border-top: 1px solid var(--hair); font-size: 12.5px; color: var(--ink-2); }
.ai-refs ol { margin: 4px 0 0; padding-left: 0; list-style: none; }
.ai-refs li { margin: 2px 0; }
.ai-refs li b { font: 600 11px var(--mono); margin-right: 6px; color: var(--ink); }

@media (max-width: 1440px) {
  .versions { display: none; }
  .nav a { padding: 6px 9px; }
}
@media (max-width: 760px) {
  .picker { margin-left: auto; }
  .pick-btn { height: 34px; padding: 0 8px; }
  .pick-label { display: none; }
  .pick-btn b { font-size: 14px; max-width: 8.5em; }
  .pick-pop { position: fixed; left: 8px; right: 8px; top: calc(var(--mast) + 4px); width: auto; }
  .masthead .edition { display: none; }
  .wm-2 { display: none; }
  .nav a span { font-size: 10px; text-align: center; line-height: 1.2; }
  .nav a i { font-size: 10px; }
  #view-overview { display: block; }
  .mapwrap .layers { top: 12px; left: auto; right: 64px; min-width: 0; padding: 6px 10px; }
  .legend { display: none; }
  .p-title { font-size: 26px; }
  .ai-risks li { grid-template-columns: 64px 1fr; }
}

.tg-btn { display: block; margin: 14px 0 4px; padding: 10px 12px; text-align: center; background: #229ed9; color: #fff !important; text-decoration: none; font-weight: 600; border: 1px solid var(--ink); box-shadow: 3px 3px 0 var(--ink); }
.tg-btn:hover { filter: brightness(1.05); }

.push-box { margin: 12px 0 4px; padding: 10px 12px; border: 1px solid var(--ink); background: var(--card); font-size: 13.5px; }
.push-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.push-row select, .push-row button { font: 600 12.5px var(--mono); padding: 6px 8px; border: 1px solid var(--ink); background: var(--paper); color: var(--ink); }
.push-row button:hover { background: var(--hazard); color: #14161a; }
.linkbtn { border: 0; background: none; padding: 0; margin-left: 6px; color: var(--accent); text-decoration: underline; font: inherit; cursor: pointer; }

/* hazard switch น้ำ | ฝุ่น (also used by /air, which loads this file first) */
.hz { display: inline-flex; flex: none; border: 1px solid var(--ink); }
.hz a { padding: 5px 11px; font: 600 14px/1.2 var(--sans); color: var(--ink-2); text-decoration: none; border-left: 1px solid var(--ink); }
.hz a:first-child { border-left: 0; }
.hz a:hover { background: var(--hazard); color: #14161a; }
.hz a.on { background: var(--ink); color: var(--paper); }
@media (max-width: 760px) { .hz a { padding: 4px 7px; font-size: 13px; } }
.push-topics label { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; margin-right: 10px; }

/* glossary term links inside TMD announcements (terms from /glossary/terms.js) */
a.gl-term { text-decoration: underline dotted var(--accent); text-underline-offset: 3px; color: inherit; }
a.gl-term:hover { background: var(--accent-soft); }

/* masthead between phone and wide desktop: the hazard switch made it ~1,280 px wide, so shed parts
   step by step instead of overflowing (all pages that use this masthead) */
@media (min-width: 761px) and (max-width: 1320px) {
  .masthead { gap: 14px; padding: 0 14px; }
  .wm-2 { display: none; }
  .nav a { padding: 6px 8px; }
  .nav a i { display: none; }
}
@media (min-width: 761px) and (max-width: 1060px) {
  .masthead { gap: 10px; }
  .pick-label { display: none; }
  .pick-btn b { max-width: 7em; }
  .hz a { padding: 4px 7px; font-size: 13px; }
  .nav a { padding: 6px 6px; font-size: 13.5px; }
}
@media (min-width: 761px) and (max-width: 900px) {
  .hz a[href="/glossary/"] { display: none; } /* still linked from the alerts view */
  .wordmark .wm-1 { font-size: 22px; }
}

/* BMA pumping stations / floodgates in the Bangkok focus (lPumps) */
.pumpm { width: 20px; height: 20px; display: grid; place-items: center; font: 700 11px/1 var(--mono); border: 2px solid var(--st4); background: var(--paper); color: var(--st4); box-shadow: 0 0 0 1px var(--ink); }
.pumpm.work { background: var(--st4); color: #fff; }
.pumpm.down { background: var(--paper-2); color: var(--off); border: 2px dashed var(--off); }
.pumpchip.work { background: var(--st4) !important; } .pumpchip.wait { background: #7d9a80 !important; } .pumpchip.down { background: var(--off) !important; }

/* link to /home from the overview panel */
.home-cta { display: block; margin: 10px 0 2px; padding: 8px 10px; border: 1px solid var(--ink); background: var(--card); font-weight: 600; text-decoration: none; box-shadow: 3px 3px 0 var(--hazard); }
.home-cta:hover { background: var(--hazard); color: #14161a; }
.ask { margin: 10px 0 4px; padding: 12px 14px; border: 1px solid var(--ink); background: var(--card); box-shadow: 3px 3px 0 var(--hazard); }
.ask-q { margin: 0; font: 800 21px/1.3 var(--serif); }
.ask-sub { margin: 3px 0 10px; font-size: 13.5px; color: var(--ink-2); }
.ask-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.ask-btns a { flex: 1 1 150px; display: flex; align-items: center; justify-content: center; min-height: 46px; padding: 6px 10px; border: 1px solid var(--ink); font-weight: 600; text-decoration: none; text-align: center; }
.ask-go { background: var(--ink); color: var(--paper); }
.ask-go:hover, .ask-alt:hover { background: var(--hazard); color: #14161a; }
.help-cta { display: block; margin: 6px 0 2px; padding: 6px 10px; border: 1px dashed var(--ink); font-size: 13.5px; text-decoration: none; }
.help-cta:hover { background: var(--paper-2); }

/* "บ้านฉัน" shortcut in the hazard switch */
.hz a.hz-home { background: var(--hazard); color: #14161a; }
.hz a.hz-home:hover { background: var(--ink); color: var(--paper); }
@media (min-width: 761px) and (max-width: 1060px) { .hz a[href="/glossary/"] { display: none; } }
@media (max-width: 760px) { .hz a[href="/glossary/"] { display: none; } }

@media (max-width: 420px) { .hz a { padding: 4px 5px; font-size: 12.5px; } .masthead { gap: 8px; padding: 0 10px; } }
@media (min-width: 761px) and (max-width: 900px) { .hz a { padding: 4px 6px; } }
@media (max-width: 400px) { .wordmark .wm-1 { font-size: 19px; } .pick-btn b { max-width: 6em; } .hz a { padding: 4px 4px; font-size: 12px; } }
@media (min-width: 761px) and (max-width: 900px) { .masthead { gap: 8px; padding: 0 10px; } }
@media (max-width: 400px) { .masthead { gap: 6px; padding: 0 8px; } .pick-btn { padding: 0 6px; } }

/* river cameras (Department of Water Resources) */
.rcm { width: 24px; height: 24px; display: grid; place-items: center; background: #1d6fa5; color: #fff; border: 1.5px solid #fff; border-radius: 50%; font-size: 13px; box-shadow: 0 1px 3px rgba(0,0,0,.35); }
.rcm.old { opacity: .55; }
a.camcard { display: block; color: inherit; }
.camcard .play.old, .chip.old { background: var(--paper-2); color: var(--ink-2); }

.p-share { display: inline-block; margin: 6px 0 2px; font-size: 13.5px; }
