/* Bangkok flood watch — "chart paper + staff gauge". Light by default, monsoon-night in dark.
   The Ultrafast-TH view is styled separately in ufx.css (FusionCharge design language). */
:root {
  --paper: #e9eef0;        /* hydrographic chart paper, cool grey-blue */
  --paper-2: #f5f8f9;      /* raised surface */
  --ink: #1d2a31;          /* monsoon slate */
  --ink-2: #4a5b64;
  --rule: #c5d0d5;
  --canal: #2f6f62;        /* khlong green-teal: water, "dry/ok" never used as "safe" */
  --deep: #0e4a6b;         /* deep water / chart line */
  --gauge: #c8322b;        /* staff-gauge red: alert */
  --amber: #d9962c;        /* sodium street-lamp: watch */
  --band: rgba(14,74,107,.16);
  --dry: #8fa3ab; --wet1: #7fb8c9; --wet2: #3f8fb0; --wet3: #1f5f99; --wet4: #c8322b;
  --shadow: 0 1px 0 rgba(29,42,49,.06);
  --radius-s: 4px; --radius-m: 10px;
  --f-ui: "Anuphan", "Noto Sans Thai", system-ui, sans-serif;
  --f-num: "Chakra Petch", "Anuphan", system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0f1a20; --paper-2: #15232b; --ink: #dce6ea; --ink-2: #9db0b8; --rule: #27404b;
    --canal: #5fb3a1; --deep: #7cc2e6; --gauge: #ef5a4f; --amber: #f0b64f; --band: rgba(124,194,230,.18);
    --dry: #5b6f77; --wet1: #6fb3c8; --wet2: #3b92c0; --wet3: #5b7fe0; --wet4: #ef5a4f;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0f1a20; --paper-2: #15232b; --ink: #dce6ea; --ink-2: #9db0b8; --rule: #27404b;
  --canal: #5fb3a1; --deep: #7cc2e6; --gauge: #ef5a4f; --amber: #f0b64f; --band: rgba(124,194,230,.18);
  --dry: #5b6f77; --wet1: #6fb3c8; --wet2: #3b92c0; --wet3: #5b7fe0; --wet4: #ef5a4f;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 400 16px/1.55 var(--f-ui); font-feature-settings: "tnum" 1;
  /* faint chart grid: the paper the gauge readings are plotted on */
  background-image:
    linear-gradient(var(--rule) 1px, transparent 1px),
    linear-gradient(90deg, var(--rule) 1px, transparent 1px);
  background-size: 100% 48px, 48px 100%;
  background-position: 0 -1px, -1px 0;
  background-attachment: local;
}
body::before { /* wash the grid down so it stays a texture, not a pattern */
  content: ""; position: fixed; inset: 0; background: var(--paper); opacity: .86; pointer-events: none; z-index: -1;
}
body { position: relative; z-index: 0; }
a { color: var(--deep); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--amber); outline-offset: 2px; border-radius: 2px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--ink); color: var(--paper); padding: 8px 12px; z-index: 50; }
.skip:focus { left: 8px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--ink-2); }
.small { font-size: 13px; }
h1, h2, h3 { font-weight: 600; letter-spacing: -.01em; margin: 0; }
h2 { font-size: clamp(22px, 2.6vw, 30px); line-height: 1.15; }
h3 { font-size: 15px; margin: 18px 0 8px; }
p { margin: 0; }
.num { text-align: right; font-family: var(--f-num); }

main, .top-in, .fresh, .stale-banner, .foot { max-width: 1240px; margin: 0 auto; padding-left: 20px; padding-right: 20px; }
section { padding: 44px 0 8px; }
.sec-head { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; margin-bottom: 18px; max-width: 760px; }

/* ── top */
.top { border-bottom: 1px solid var(--rule); background: var(--paper-2); position: sticky; top: 0; z-index: 20; }
.top-in { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; padding-top: 14px; padding-bottom: 8px; }
.place-th { font-size: 13px; color: var(--ink-2); }
h1 { font-family: var(--f-num); font-weight: 700; font-size: clamp(24px, 3.4vw, 36px); line-height: 1; letter-spacing: -.005em; }
.clock { display: grid; justify-items: end; line-height: 1.1; }
#clock-time { font-family: var(--f-num); font-size: 26px; font-weight: 600; }
#clock-date { font-size: 12px; }
.fresh { display: flex; flex-wrap: wrap; gap: 6px 14px; padding-bottom: 10px; font-size: 12.5px; }
.chip { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); white-space: nowrap; }
.chip i { width: 8px; height: 8px; border-radius: 50%; background: var(--canal); flex: none; }
.chip.aging i { background: var(--amber); }
.chip.stale i, .chip.down i { background: var(--gauge); }
.chip b { font-weight: 500; color: var(--ink); }
.stale-banner { background: var(--gauge); color: #fff; padding: 8px 20px; font-size: 14px; max-width: none; }

/* ── hero */
.hero { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 36px; align-items: start; padding-top: 34px; }
.gauge-wrap { margin: 0; display: grid; gap: 8px; justify-items: center; position: sticky; top: 120px; }
#gauge { width: 190px; height: auto; }
.gauge-wrap figcaption { text-align: center; display: grid; gap: 2px; font-size: 13px; }
.gauge-reading { font-family: var(--f-num); font-size: 30px; font-weight: 700; line-height: 1; }
.level { display: inline-flex; align-items: center; gap: 10px; font-family: var(--f-num); font-weight: 700; font-size: 15px;
  letter-spacing: .06em; padding: 6px 14px 6px 10px; border-radius: 999px; background: var(--paper-2); border: 1px solid var(--rule); }
.level-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--dry); }
[data-level="low"] .level-dot { background: var(--canal); }
[data-level="watch"] .level-dot { background: var(--amber); }
[data-level="alert"] .level-dot, [data-level="high"] .level-dot, [data-level="water"] .level-dot, [data-level="flooding"] .level-dot { background: var(--gauge); }
[data-level="alert"] .level, [data-level="high"] .level, [data-level="flooding"] .level { border-color: var(--gauge); }
.headline { font-size: clamp(22px, 2.9vw, 34px); line-height: 1.22; font-weight: 500; margin: 16px 0 26px; max-width: 30ch; text-wrap: balance; }
.today-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border-top: 2px solid var(--ink); }
.today-cell { display: grid; align-content: start; gap: 4px; padding: 14px 18px 16px 0; border-right: 1px solid var(--rule); }
.today-cell + .today-cell { padding-left: 18px; }
.today-cell:last-child { border-right: 0; }
.t-label { font-size: 13.5px; color: var(--ink-2); }
.big { font-family: var(--f-num); font-size: clamp(44px, 6vw, 68px); font-weight: 700; line-height: .95; color: var(--gauge); }
.big.quiet { color: var(--ink); font-size: clamp(34px, 4.4vw, 50px); }
.range { font-size: 14px; }
.t-src { font-size: 12px; color: var(--ink-2); }
.nearby { list-style: none; padding: 0; margin: 22px 0 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px 22px; }
.nearby li { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 10px; align-items: baseline; font-size: 14px; border-top: 1px solid var(--rule); padding-top: 7px; }
.nearby .d { font-family: var(--f-num); font-weight: 600; font-size: 17px; }
.nearby .d.wet { color: var(--wet3); }
.nearby .d .u { font-size: 12px; font-weight: 500; color: var(--ink-2); }
.nearby li { grid-template-columns: 58px minmax(0, 1fr); }
.nearby small { display: block; color: var(--ink-2); font-size: 12px; }

/* ── day row: a tide table turned into a gauge row */
.day-row { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); border: 1px solid var(--rule); background: var(--paper-2); border-radius: var(--radius-m); overflow: hidden; }
.day { display: grid; grid-template-rows: auto auto 118px auto auto; gap: 6px; padding: 12px 10px 14px; border-right: 1px solid var(--rule); min-width: 0; }
.day:last-child { border-right: 0; }
.day.past { background: repeating-linear-gradient(135deg, transparent 0 6px, rgba(143,163,171,.08) 6px 7px); }
.day.today { box-shadow: inset 0 3px 0 var(--ink); }
.d-name { font-weight: 600; font-size: 14px; }
.d-date { font-size: 12px; color: var(--ink-2); }
.tube { position: relative; border-left: 1px solid var(--rule); border-bottom: 1px solid var(--rule); margin: 4px 0 0; }
.tube .fill { position: absolute; left: 6px; right: 30%; bottom: 0; background: var(--wet2); border-radius: 2px 2px 0 0; }
.tube .fill.hi { background: var(--gauge); }
.tube .fill.mid { background: var(--amber); }
.tube .tick { position: absolute; left: 2px; right: 20%; height: 0; border-top: 2px dashed var(--ink); }
.tube .obs-bar { position: absolute; left: 6px; right: 30%; bottom: 0; background: var(--deep); opacity: .85; border-radius: 2px 2px 0 0; }
.tube .scale { position: absolute; right: 0; font-size: 10px; color: var(--ink-2); transform: translateY(50%); }
.d-p { font-family: var(--f-num); font-weight: 700; font-size: 26px; line-height: 1; }
.d-p small { font-size: 13px; font-weight: 500; }
.d-meta { font-size: 12px; color: var(--ink-2); line-height: 1.35; }
.day.past .d-p { font-size: 20px; color: var(--deep); }
.week-line { margin-top: 12px; font-size: 15px; }
.week-line b { font-family: var(--f-num); font-size: 19px; }

/* ── map */
.map-shell { position: relative; border-radius: var(--radius-m); overflow: hidden; border: 1px solid var(--rule); background: #c9d3d6; }
#map { height: min(72vh, 680px); min-height: 420px; }
.map-ui { position: absolute; top: 12px; left: 12px; display: grid; gap: 8px; max-width: 250px; z-index: 2; }
.map-ui > * { background: color-mix(in srgb, var(--paper-2) 92%, transparent); border: 1px solid var(--rule); border-radius: 8px; backdrop-filter: blur(6px); }
.seg { display: flex; padding: 3px; gap: 3px; }
.seg button, .presets button, .radar-ctl button { font: 500 13px var(--f-ui); color: var(--ink); background: transparent; border: 0; padding: 6px 10px; border-radius: 6px; cursor: pointer; }
.seg button[aria-pressed="true"], .presets button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.layers { margin: 0; padding: 8px 12px 10px; display: grid; gap: 4px; font-size: 13px; }
.layers legend { font-weight: 600; padding: 0 4px; font-size: 12px; }
.layers label { display: flex; gap: 8px; align-items: center; cursor: pointer; }
.radar-ctl { display: flex; align-items: center; gap: 8px; padding: 4px 10px 4px 4px; font-size: 12px; }
.radar-ctl input { flex: 1; min-width: 80px; accent-color: var(--deep); }
.maplibregl-popup-content { font: 14px/1.4 var(--f-ui); color: #1d2a31; border-radius: 8px; }
.maplibregl-popup-content b { font-family: var(--f-num); }

/* ── chart */
.chart-box { position: relative; background: var(--paper-2); border: 1px solid var(--rule); border-radius: var(--radius-m); padding: 10px 6px 4px; }
#chart { width: 100%; height: 380px; display: block; }
#chart text { font: 11px var(--f-ui); fill: var(--ink-2); }
#chart .day-lab { font-weight: 600; fill: var(--ink); font-size: 12px; }
.tip { position: absolute; pointer-events: none; background: var(--ink); color: var(--paper); font-size: 12.5px; line-height: 1.4; padding: 7px 10px; border-radius: 6px; white-space: nowrap; transform: translate(-50%, -110%); }

/* ── city */
.city-grid { display: grid; grid-template-columns: 1.1fr 1fr 1.1fr; gap: 30px; }
.city-col h3:first-child { margin-top: 0; }
.deep { list-style: none; padding: 0; margin: 0; display: grid; gap: 5px; }
.deep li { display: grid; grid-template-columns: minmax(0, 1fr) 46px; gap: 8px; align-items: center; font-size: 13.5px; }
.deep .bar { grid-column: 1 / -1; height: 5px; background: var(--rule); border-radius: 3px; overflow: hidden; }
.deep .bar span { display: block; height: 100%; background: var(--wet3); }
.deep .bar span.hi { background: var(--gauge); }
.deep .v { font-family: var(--f-num); font-weight: 600; text-align: right; }
.deep small { color: var(--ink-2); }
table.gauges { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.gauges th, table.gauges td { padding: 5px 4px; border-bottom: 1px solid var(--rule); text-align: left; vertical-align: top; }
table.gauges th { font-weight: 500; color: var(--ink-2); font-size: 12px; }
table.gauges .num { text-align: right; }
.notice { border-left: 3px solid var(--ink); padding: 2px 0 2px 12px; margin-bottom: 16px; font-size: 14px; }
.notice.red { border-color: var(--gauge); }
.notice.amber { border-color: var(--amber); }
.notice p + p { margin-top: 4px; }
.notice .when { font-size: 12px; color: var(--ink-2); }
.notice img { width: 100%; max-width: 180px; border-radius: 6px; margin-top: 6px; display: block; }
.shots { display: grid; grid-template-columns: repeat(2, minmax(0, 180px)); gap: 8px; }
.shots img { max-width: 100%; height: auto; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 12px; color: var(--ink-2); padding: 4px 30px 6px; }
.chart-legend i { display: inline-block; width: 12px; height: 9px; margin-right: 5px; vertical-align: -1px; border-radius: 1px; }

/* ── street 3D */
.street-shell { display: grid; grid-template-columns: minmax(0, 1fr) 270px; border: 1px solid var(--rule); border-radius: var(--radius-m); overflow: hidden; background: var(--paper-2); }
#street3d { width: 100%; height: 380px; display: block; background: linear-gradient(#b8c7cd, #dfe7ea); }
.street-ui { padding: 18px; display: grid; gap: 12px; align-content: start; border-left: 1px solid var(--rule); }
.street-ui label { font-weight: 600; display: flex; justify-content: space-between; }
.street-ui output { font-family: var(--f-num); font-size: 20px; }
#depth { width: 100%; accent-color: var(--deep); }
.presets { display: flex; flex-wrap: wrap; gap: 6px; }
.presets button { border: 1px solid var(--rule); }
.illus { margin: 22px 0 0; }
.illus img { width: 100%; height: auto; aspect-ratio: 16 / 6; object-fit: cover; border-radius: var(--radius-m); display: block; }
.illus figcaption { font-size: 12px; color: var(--ink-2); margin-top: 6px; }

/* ── verdict */
.vd-summary { display: grid; gap: 10px; max-width: 78ch; margin-bottom: 20px; }
.vd-summary p:first-child { font-size: 19px; font-weight: 500; }
.vd-table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.vd-table th, .vd-table td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--rule); vertical-align: top; }
.vd-table thead th { font-size: 12.5px; color: var(--ink-2); font-weight: 500; border-bottom: 2px solid var(--ink); }
.vd-table td.num, .vd-table th.num { text-align: right; white-space: nowrap; }
.vd-table .pv { font-size: 20px; font-weight: 700; color: var(--gauge); }
.vd-table td:last-child { max-width: 62ch; }
.vd-foot { display: grid; grid-template-columns: 1fr 1fr; gap: 30px; margin-top: 10px; }
.vd-foot ul, .method ul, .method ol { padding-left: 18px; margin: 0; display: grid; gap: 6px; font-size: 14.5px; }

/* ── method */
.method-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 30px; font-size: 14.5px; }
.method-grid h3:first-child { margin-top: 0; }
.method p { margin-bottom: 8px; }
table.thr { border-collapse: collapse; width: 100%; font-size: 13.5px; }
table.thr th, table.thr td { text-align: left; padding: 6px 4px; border-bottom: 1px solid var(--rule); vertical-align: top; }
table.thr th { font-weight: 500; color: var(--ink-2); width: 45%; }
.src li { font-size: 13px; }
.src .ok { color: var(--canal); } .src .bad { color: var(--gauge); }
.foot { padding-top: 36px; padding-bottom: 40px; font-size: 13px; color: var(--ink-2); border-top: 1px solid var(--rule); margin-top: 40px; }

/* ── responsive */
@media (max-width: 1080px) {
  .day-row { grid-template-columns: repeat(9, 140px); overflow-x: auto; scroll-snap-type: x mandatory; }
  .day { scroll-snap-align: start; }
  .city-grid, .method-grid { grid-template-columns: 1fr 1fr; }
  .notices { grid-column: 1 / -1; }
}
@media (max-width: 760px), (hover: none) and (pointer: coarse) and (max-width: 1180px) {
  main, .top-in, .fresh, .foot { padding-left: 16px; padding-right: 16px; }
  .top { position: static; }
  .hero { grid-template-columns: 1fr; gap: 18px; padding-top: 22px; }
  .gauge-wrap { position: static; grid-template-columns: 92px minmax(0, 1fr); justify-items: start; align-items: end; gap: 14px; }
  #gauge { width: 92px; }
  .gauge-wrap figcaption { text-align: left; }
  .gauge-reading { font-size: 34px; }
  .today-grid { grid-template-columns: 1fr; }
  .today-cell, .today-cell + .today-cell { padding: 12px 0; border-right: 0; border-bottom: 1px solid var(--rule); }
  .headline { font-size: 19px; margin: 12px 0 18px; }
  .city-grid, .method-grid, .vd-foot { grid-template-columns: 1fr; }
  .street-shell { grid-template-columns: 1fr; }
  .street-ui { border-left: 0; border-top: 1px solid var(--rule); }
  #street3d { height: 280px; }
  .map-ui { max-width: 190px; }
    .vd-table thead { display: none; }
  .vd-table tr { display: grid; grid-template-columns: 1fr auto auto; gap: 2px 12px; padding: 10px 0; border-bottom: 1px solid var(--rule); }
  .vd-table td { border: 0; padding: 0; }
  .vd-table td:last-child { grid-column: 1 / -1; max-width: none; font-size: 14px; color: var(--ink-2); }
  .vd-table td.rng { display: none; }
  .clock #clock-date { display: none; }
  .fresh { font-size: 12px; gap: 4px 10px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* traffic proxy: magenta ring-dot, deliberately outside the red/blue depth ramp */
.sw-traffic { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: #b0309a; box-shadow: 0 0 0 2px #3a0f33 inset; margin: 0 4px 0 2px; vertical-align: -1px; }
#traffic-leg[hidden] { display: none; }

/* ═════════ round 3: bilingual, two views, timelapse ═════════ */
html[lang="th"] [data-l="en"], html[lang="en"] [data-l="th"] { display: none !important; }
body[data-view="city"] [data-for="ufx"], body[data-view="ufx"] [data-for="city"] { display: none !important; }
html[lang="th"] body { line-height: 1.62; }
html[lang="th"] h1 { font-family: var(--f-ui); font-weight: 700; letter-spacing: 0; line-height: 1.15; }

.top-right { display: flex; align-items: flex-end; gap: 16px; }
.lang-seg { border: 1px solid var(--rule); border-radius: 8px; background: var(--paper); }
.lang-seg button { padding: 4px 10px; font-weight: 600; }
.top-in { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: end; }
.viewbar { padding-bottom: 2px; }
.view-seg { display: inline-flex; border: 1px solid var(--ink); border-radius: 10px; background: var(--paper); padding: 3px; }
.view-seg button { font-size: 15px; font-weight: 600; padding: 8px 18px; border-radius: 7px; }

/* city hero */
.city-hero { padding-top: 30px; }
.city-hero .headline { max-width: 34ch; }
.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-top: 2px solid var(--ink); }
.stat { display: grid; align-content: start; gap: 4px; padding: 14px 18px 16px 0; border-right: 1px solid var(--rule); min-width: 0; }
.stat + .stat { padding-left: 18px; }
.stat:last-child { border-right: 0; }
.stat .range { font-size: 13.5px; overflow-wrap: anywhere; }
.out-note { margin-top: 10px; max-width: 90ch; }
.c-analyst { margin-top: 18px; padding: 14px 18px; background: var(--paper-2); border: 1px solid var(--rule); border-radius: var(--radius-m); max-width: 90ch; }
.c-analyst ul { margin: 8px 0 10px; padding-left: 18px; display: grid; gap: 6px; font-size: 15px; }
.link-btn { font: 600 14px var(--f-ui); color: var(--deep); background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.nearby .d.out { color: var(--ink-2); text-decoration: line-through; }
.warn { color: var(--gauge); font-weight: 600; }

/* map controls */
.layers-btn { font: 600 13px var(--f-ui); color: var(--ink); padding: 7px 12px; cursor: pointer; display: none; }
.map-ui .layers { display: grid; }

/* timelapse bar */
.tl { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "play track now" "read read read"; gap: 8px 12px; align-items: center;
  margin-top: 12px; padding: 12px 14px; background: var(--paper-2); border: 1px solid var(--rule); border-radius: var(--radius-m); }
.tl-play { grid-area: play; width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--ink); color: var(--paper); font-size: 16px; cursor: pointer; }
.tl-now { grid-area: now; font: 600 13px var(--f-ui); border: 1px solid var(--gauge); color: var(--gauge); background: transparent; border-radius: 999px; padding: 7px 14px; cursor: pointer; }
.tl-track { grid-area: track; position: relative; padding-bottom: 16px; min-width: 0; }
#tl-spark { display: block; width: 100%; height: 44px; }
#tl-slider { width: 100%; margin: 2px 0 0; accent-color: var(--gauge); display: block; }
.tl-ticks { position: absolute; left: 0; right: 0; bottom: 0; height: 14px; font-size: 11px; color: var(--ink-2); }
.tl-ticks span { position: absolute; white-space: nowrap; transform: translateX(2px); }
.tl-ticks span::before { content: ""; position: absolute; left: -2px; top: -4px; height: 5px; border-left: 1px solid var(--ink-2); }
.tl-read { grid-area: read; display: grid; gap: 2px; }
.tl-read b { font-family: var(--f-num); font-size: 16px; }
.tl-kind { white-space: nowrap; font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--rule); vertical-align: 1px; }
.tl-kind[data-k="now"] { border-color: var(--gauge); color: var(--gauge); }
.tl-kind[data-k="fc"] { border-color: var(--deep); color: var(--deep); background: var(--band); }
.tl-note { margin-top: 4px; }

/* legend under the map */
.legend-row { display: flex; flex-wrap: wrap; gap: 8px 22px; margin-top: 10px; font-size: 12.5px; color: var(--ink-2); }
.lg-group { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.lg-group b { color: var(--ink); font-weight: 600; }
.legend-row i { display: inline-block; width: 11px; height: 11px; border-radius: 50%; background: var(--c); margin-right: 4px; vertical-align: -1px; }
.legend-row i.ring-out { background: #d3d9dc; box-shadow: 0 0 0 1.5px #8fa3ab inset; }
.legend-row i.ring-event { background: transparent; box-shadow: 0 0 0 2.4px #1f5f99 inset; }
.rain-ramp { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.rain-ramp i { border-radius: 2px !important; }
.radar-ctl { display: flex; align-items: center; gap: 10px; margin-top: 10px; font-size: 13px; color: var(--ink-2); }
.radar-ctl button { width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--rule); background: var(--paper-2); color: var(--ink); cursor: pointer; }

/* method folded */
.method details > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 10px; }
.method details > summary::-webkit-details-marker { display: none; }
.method details > summary::before { content: "+"; font: 700 22px var(--f-num); width: 28px; height: 28px; border: 1px solid var(--rule); border-radius: 50%; display: grid; place-items: center; flex: none; }
.method details[open] > summary::before { content: "–"; }
.method details[open] > summary { margin-bottom: 18px; }

@media (max-width: 1080px) {
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .stat:nth-child(2) { border-right: 0; }
  .stat:nth-child(3) { padding-left: 0; }
  .stat:nth-child(n+3) { border-top: 1px solid var(--rule); }
}
@media (max-width: 760px), (hover: none) and (pointer: coarse) and (max-width: 1180px) {
  .top-in { flex-wrap: wrap; align-items: center; }
  .top-right { gap: 10px; }
  .top-in { grid-template-columns: minmax(0, 1fr) auto; }
  .viewbar { grid-column: 1 / -1; order: 3; padding: 4px 0 2px; }
  .view-seg { display: flex; width: 100%; }
  .view-seg button { flex: 1; padding: 9px 8px; }
  .layers-btn { display: block; }
  .map-ui .layers { display: none; }
  .map-ui.open .layers { display: grid; }
  #map { height: 62vh; min-height: 380px; }
  .tl { grid-template-columns: auto minmax(0, 1fr); grid-template-areas: "play track" "now read"; }
  .tl-now { align-self: start; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .stat { padding: 12px 10px 12px 0; }
  .stat + .stat { padding-left: 10px; }
  .big { font-size: 40px; }
  .big.quiet { font-size: 32px; }
}

html[lang="th"] .headline { max-width: 40ch; }

/* ═════════ round 4: phone-first — map + timelapse on the first screen ═════════ */
.fresh-sum { display: none; }
.t-short, .strip-note { display: none; }
.map-sec .sec-head { margin-bottom: 12px; }
.map-help { margin-top: 8px; max-width: 90ch; }
.city-more, .site-more { padding-top: 22px; }
.site-more h3 { margin-top: 0; }
.site-more .nearby { margin-top: 0; }

/* timelapse bar lives inside the map frame; the time stamp floats on the map */
.map-shell .tl { margin: 0; border: 0; border-top: 1px solid var(--rule); border-radius: 0; grid-template-areas: "play track now"; }
.map-top { position: absolute; top: 10px; left: 10px; z-index: 2; display: grid; gap: 8px; justify-items: start; max-width: min(420px, calc(100% - 64px)); pointer-events: none; }
.map-top > * { pointer-events: auto; }
.map-top .map-ui { position: static; max-width: 250px; }
.stamp { background: color-mix(in srgb, var(--paper-2) 90%, transparent); border: 1px solid var(--rule); border-radius: 8px; padding: 6px 10px 7px; backdrop-filter: blur(6px); box-shadow: 0 2px 10px rgba(0,0,0,.12); }
.stamp p { margin: 0; }
.st-line { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 8px; }
.stamp #tl-time { font-family: var(--f-num); font-size: 16px; line-height: 1.2; transition: font-size .2s; }
.st-sub { font-size: 12.5px; color: var(--ink-2); line-height: 1.35; margin-top: 2px !important; }
.map-shell.playing .stamp #tl-time { font-size: 21px; }
.tl-read { display: grid; gap: 2px; margin-top: 8px; }
.tl-play.hint { animation: hint 1.4s ease-in-out 3; }
@keyframes hint { 0%, 100% { box-shadow: 0 0 0 0 rgba(200,50,43,.55); } 50% { box-shadow: 0 0 0 10px rgba(200,50,43,0); } }
.fresh-sum.pulse, .fresh.pulse .chip b { animation: pulse 2.4s ease-out 1; }
@keyframes pulse { 0% { background: var(--amber); color: #1d2a31; } 100% { background: transparent; } }

@media (max-width: 760px), (hover: none) and (pointer: coarse) and (max-width: 1180px) {
  /* header: title row scrolls away, the view toggle stays pinned */
  .top { position: sticky; top: var(--stick, 0px); }
  .top-in { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "place right" "sum sum" "view view"; gap: 6px 10px; padding-top: 10px; padding-bottom: 8px; align-items: center; }
  .place { grid-area: place; min-width: 0; }
  .place-th { display: none; }
  h1, html[lang="th"] h1 { font-size: 19px; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .top-right { grid-area: right; gap: 10px; align-items: center; }
  #clock-time { font-size: 19px; }
  .lang-seg button { padding: 5px 10px; min-height: 32px; }
  .fresh-sum { grid-area: sum; display: flex; align-items: center; gap: 8px; justify-self: start; font: 500 12.5px var(--f-ui); color: var(--ink-2); background: none; border: 0; padding: 2px 6px 2px 0; border-radius: 6px; cursor: pointer; text-align: left; }
  .fresh-sum i { width: 8px; height: 8px; border-radius: 50%; background: var(--canal); flex: none; }
  .fresh-sum.aging i { background: var(--amber); } .fresh-sum.stale i, .fresh-sum.down i { background: var(--gauge); }
  .fresh-sum::after { content: "▾"; font-size: 11px; }
  .fresh-sum[aria-expanded="true"]::after { content: "▴"; }
  .viewbar { grid-area: view; padding: 0; order: 0; }
  .view-seg button { padding: 8px 8px; font-size: 15px; min-height: 40px; }
  .fresh { display: none; }
  .top.fresh-open .fresh { display: flex; }

  /* city hero: a four-number strip */
  .city-hero { padding-top: 12px; padding-bottom: 0; }
  .level { font-size: 12.5px; padding: 4px 11px 4px 8px; gap: 7px; }
  .level-dot { width: 10px; height: 10px; }
  .city-hero .headline, .headline { font-size: 17px; line-height: 1.35; margin: 8px 0 10px; }
  .stat-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); border-top-width: 1.5px; }
  .stat, .stat + .stat { padding: 7px 6px 6px 0; border-right: 1px solid var(--rule); border-top: 0 !important; }
  .stat + .stat { padding-left: 7px; }
  .stat:last-child { border-right: 0; }
  .stat .t-label, .stat .range { display: none; }
  .t-short { display: block; font-size: 11.5px; line-height: 1.25; color: var(--ink-2); min-height: 2.5em; }
  .stat .big { font-size: 27px; } .stat .big.quiet { font-size: 22px; white-space: nowrap; }
  .strip-note { display: block; font-size: 12px; line-height: 1.4; margin-top: 4px; }

  /* site hero: small staff gauge beside the reading */
  .hero { grid-template-columns: 54px minmax(0, 1fr); gap: 4px 12px; padding-top: 12px; padding-bottom: 0; }
  .gauge-wrap, .verdict-now { display: contents; }
  #gauge { width: 54px; grid-column: 1; grid-row: 1 / 4; align-self: start; }
  .gauge-wrap figcaption { grid-column: 2; grid-row: 1; text-align: left; font-size: 12px; line-height: 1.35; }
  .gauge-reading { font-size: 30px; }
  .hero .level { grid-column: 2; grid-row: 2; justify-self: start; }
  .hero .headline { grid-column: 2; grid-row: 3; margin: 4px 0 6px; font-size: 15.5px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; cursor: pointer; }
  .hero .headline.open { -webkit-line-clamp: unset; display: block; }
  .today-grid { grid-column: 1 / -1; grid-row: 4; grid-template-columns: repeat(3, minmax(0, 1fr)); border-top-width: 1.5px; }
  .today-cell, .today-cell + .today-cell { padding: 7px 6px 6px 0; border-right: 1px solid var(--rule); border-bottom: 0; }
  .today-cell + .today-cell { padding-left: 7px; }
  .today-cell:last-child { border-right: 0; }
  .today-cell .t-label { display: none; }
  .today-cell .t-short { min-height: 0; }
  .today-cell .range, .today-cell .t-src { display: none; }
  .today-cell .big { font-size: 27px; } .today-cell .big.quiet { font-size: 22px; }

  /* the map fills the rest of the first screen; timelapse controls sit on it */
  .map-sec { padding-top: 10px; }
  .map-sec .sec-head { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .map-shell { border-radius: 12px; margin: 0 -6px; }
  #map { height: var(--map-h, 58svh); min-height: 220px; }
  .map-top { top: 8px; left: 8px; gap: 6px; max-width: calc(100% - 58px); }
  .stamp { padding: 5px 9px 6px; }
  .stamp #tl-time { font-size: 14.5px; }
  .map-shell.playing .stamp #tl-time { font-size: 19px; }
  .st-sub { font-size: 11.5px; }
  .layers-btn { padding: 5px 10px; font-size: 12.5px; }
  .map-shell .tl { position: absolute; left: 8px; right: 8px; bottom: 8px; z-index: 3; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "play track now";
    gap: 6px 8px; padding: 6px 8px 4px; background: color-mix(in srgb, var(--paper-2) 90%, transparent); border: 1px solid var(--rule); border-radius: 12px; backdrop-filter: blur(6px); box-shadow: 0 2px 12px rgba(0,0,0,.18); }
  .tl-play { width: 42px; height: 42px; }
  .tl-now { padding: 6px 10px; font-size: 12.5px; align-self: center; }
  #tl-spark { height: 22px; }
  .tl-track { padding-bottom: 13px; }
  .tl-ticks { font-size: 10px; height: 12px; }
  .maplibregl-ctrl-bottom-right, .maplibregl-ctrl-bottom-left { bottom: 74px; }
  .tl-read { margin-top: 8px; }
  .legend-row { font-size: 12px; gap: 6px 16px; }
  .city-more, .site-more { padding-top: 18px; }
}
/* short phones (SE, LINE's in-app browser with its bars): trim the hero so ▶ still lands on the first screen */
@media (max-width: 760px) and (max-height: 620px), (hover: none) and (pointer: coarse) and (max-width: 1180px) and (max-height: 620px) {
  .top-in { padding-top: 6px; padding-bottom: 6px; gap: 4px 10px; }
  .view-seg button { min-height: 36px; padding: 6px 8px; }
  .strip-note { display: none; }
  .city-hero .headline { font-size: 15.5px; margin: 6px 0 6px; }
  .hero .headline { -webkit-line-clamp: 1; margin: 2px 0 4px; }
  .today-cell, .today-cell + .today-cell { padding-top: 5px; padding-bottom: 4px; }
  .gauge-reading { font-size: 26px; }
  #gauge { width: 44px; }
  .hero { grid-template-columns: 44px minmax(0, 1fr); }
}
@media (prefers-reduced-motion: reduce) { .map-shell.playing .stamp #tl-time { font-size: inherit; } }

.map-wait { padding: 28px 20px; color: #4a5b64; font-size: 15px; }

/* ───── roads to avoid (BMA flood-alert re-published) ───── */
.routes { margin-top: 34px; }
.routes h2 b { font-family: var(--f-num); color: var(--gauge); }
.rt-stale { color: var(--gauge); font-size: 13px; margin: 4px 0 0; }
.rt-tally { display: flex; flex-wrap: wrap; gap: 8px 18px; margin: 0 0 12px; font-size: 13.5px; }
.rt-k { display: inline-flex; align-items: center; gap: 6px; }
.rt-k i { width: 22px; height: 6px; border-radius: 3px; background: var(--c); }
.rt-k b { font-family: var(--f-num); font-size: 17px; }
.k-R, .lv-R { --c: #7a0019; } .k-r, .lv-r { --c: #e0233f; } .k-a, .lv-a { --c: #f2a900; }
:root[data-theme="dark"] .k-R, :root[data-theme="dark"] .lv-R { --c: #d0284a; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .k-R, :root:not([data-theme="light"]) .lv-R { --c: #d0284a; } }
.rt-tools { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 12px; }
.rt-zones { display: inline-flex; flex-wrap: wrap; gap: 2px; border: 1px solid var(--rule); border-radius: 8px; padding: 2px; }
.rt-zones small { color: inherit; opacity: .7; font-family: var(--f-num); }
.rt-q { flex: 1 1 220px; min-width: 0; font: 14px var(--f-ui); color: var(--ink); background: var(--paper-2); border: 1px solid var(--rule); border-radius: 8px; padding: 8px 10px; }
.rt-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 8px; }
.rt-road { background: var(--paper-2); border-radius: var(--radius-m); border-left: 6px solid var(--c); min-width: 0; }
.rt-go { all: unset; box-sizing: border-box; display: grid; grid-template-columns: 54px minmax(0, 1fr); gap: 10px; width: 100%; padding: 10px 12px 4px; cursor: pointer; }
.rt-go:focus-visible { outline: 2px solid var(--deep); outline-offset: 2px; border-radius: 6px; }
.rt-cm { display: grid; justify-items: center; align-content: start; color: var(--c); }
.lv-a .rt-cm { color: #9a6a00; }
.rt-cm b { font: 700 26px/1 var(--f-num); }
.rt-cm small { font-size: 11px; color: var(--ink-2); }
.rt-body { display: grid; gap: 1px; min-width: 0; font-size: 13.5px; }
.rt-n { font-size: 15.5px; }
.rt-lv { display: inline-block; width: max-content; font-size: 11px; font-weight: 600; color: #fff; background: var(--c); border-radius: 4px; padding: 0 6px; }
.lv-a .rt-lv { color: #3a2600; }
.rt-s, .rt-d { color: var(--ink-2); overflow-wrap: anywhere; }
.rt-d { font-size: 12px; }
.rt-sens { padding: 0 12px 8px 76px; font-size: 12px; color: var(--ink-2); }
.rt-sens summary { cursor: pointer; overflow-wrap: anywhere; }
.rt-sens ul { margin: 4px 0 0; padding-left: 16px; }
.rt-note { margin-top: 12px; }
.rp-box { margin-top: 18px; border-top: 1px solid var(--rule); padding-top: 10px; }
.rp-box > summary { cursor: pointer; list-style-position: outside; }
.rp-box > summary h3 { display: inline; font-size: 16px; margin: 0 8px 0 0; }
.rp-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 6px 18px; margin-top: 8px; }
.rp-d { font-size: 13.5px; border-bottom: 1px solid var(--rule); padding: 4px 0; min-width: 0; }
.rp-d summary { cursor: pointer; }
.rp-d ul { margin: 4px 0 6px; padding-left: 4px; list-style: none; display: grid; gap: 3px; }
.rp-d li { overflow-wrap: anywhere; }
.rp-b { display: inline-block; font-size: 11px; font-weight: 600; border-radius: 4px; padding: 0 6px; color: #fff; }
.rp-H { background: #6b2a8f; } .rp-M { background: #9a5cc0; } .rp-L { background: #c7a3dd; color: #2a1238; }
.sw-road { display: inline-block; width: 16px; height: 5px; border-radius: 3px; background: linear-gradient(90deg, #7a0019 0 33%, #e0233f 33% 66%, #f2a900 66%); vertical-align: middle; }
.sw-rp { display: inline-block; width: 16px; height: 0; border-top: 4px dashed #6b2a8f; vertical-align: middle; }
@media (max-width: 760px), (hover: none) and (pointer: coarse) and (max-width: 1180px) {
  .rt-list, .rp-list { grid-template-columns: minmax(0, 1fr); }
  .rt-tools { flex-direction: column; align-items: stretch; }
}
.rt-more { margin-top: 10px; }
@media (max-width: 760px), (hover: none) and (pointer: coarse) and (max-width: 1180px) { .rt-q { flex: none; width: 100%; } }
.rt-topnote { margin: -4px 0 12px; }
.rt-road.receded { opacity: .62; }
.rt-rec { display: inline-block; font-size: 11px; font-weight: 600; border-radius: 4px; padding: 0 6px; background: var(--canal); color: #fff; }
