/* Toxin Alert Aggregator : map + feed page (v2 design, 2026-11-25)
 * All sizes are in rem so the text-size buttons (html[data-fs]) scale the whole page. */
:root {
  --bg: #f3f5f8;
  --panel: #ffffff;
  --text: #162030;
  --muted: #566274;
  --line: #e1e6ed;
  --accent: #0b6e69;
  --accent-soft: #e3f3f1;
  --accent-ink: #ffffff;
  --crit: #c62828;
  --crit-bg: #fdecec;
  --warn: #d95f00;
  --warn-bg: #fff1e3;
  --watch: #c9a100;
  --watch-bg: #fff8d6;
  --watch-ink: #6b5500;
  --note-bg: #fff8e6;
  --note-line: #f0d68a;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06);
  --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 4px 12px rgba(16, 24, 40, .05);
  --radius: 14px;
  --map-sea: #d6e6ee; --map-land: #f1f3ee; --map-border: #9aa7b0;
  font-family: "Noto Sans Thai", "Sarabun", "Leelawadee UI", "Tahoma", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1318; --panel: #161c23; --text: #e8ebf0; --muted: #9ca7b6; --line: #29323c;
    --accent: #43bdb4; --accent-soft: #12302e; --accent-ink: #052321;
    --crit-bg: #3a1616; --warn-bg: #3a2410; --watch-bg: #332b0a; --watch-ink: #f1d35a;
    --note-bg: #272210; --note-line: #5e501b;
    --map-sea: #0c1a22; --map-land: #1e252c; --map-border: #46525e;
    color-scheme: dark;
  }
}

/* text size levels (fs.js) */
html { font-size: 100%; }
html[data-fs="1"] { font-size: 112.5%; }
html[data-fs="2"] { font-size: 125%; }
html[data-fs="3"] { font-size: 140%; }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font-size: 1rem; line-height: 1.55; display: flex; flex-direction: column; }
a { color: var(--accent); }
button, select, input { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 0; background: var(--accent); color: var(--accent-ink); padding: .5rem 1rem; z-index: 2000; border-radius: 0 0 8px 0; }
.skip:focus { left: 0; }

/* ---------- header ---------- */
.top { background: var(--panel); border-bottom: 1px solid var(--line); padding: .7rem 1.25rem; display: flex; gap: .75rem 1.25rem; align-items: center; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: .75rem; min-width: 0; flex: 1 1 22rem; }
.logo { width: 2.6rem; height: 2.6rem; flex: none; color: var(--accent); }
.brand h1 { font-size: 1.35rem; margin: 0; line-height: 1.3; font-weight: 700; letter-spacing: -.01em; }
.brand h1 .h1-sub { font-weight: 500; color: var(--muted); font-size: .8em; margin-left: .35rem; }
.brand p { margin: 0; color: var(--muted); font-size: .85rem; }
.top-actions { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.textsize { display: inline-flex; align-items: center; gap: .15rem; background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: .2rem; }
.ts-label { font-size: .8rem; color: var(--muted); padding: 0 .4rem 0 .6rem; }
.textsize button { border: 0; background: transparent; border-radius: 999px; min-width: 2.4rem; height: 2.4rem; cursor: pointer; font-weight: 700; font-size: 1.05rem; display: inline-flex; align-items: center; justify-content: center; }
.textsize button small { font-size: .8em; margin-left: 1px; }
.textsize button:hover:not(:disabled) { background: var(--panel); box-shadow: var(--shadow-sm); }
.textsize button:disabled { opacity: .35; cursor: default; }
.textsize .ts-level { font-size: .8rem; font-weight: 500; color: var(--muted); min-width: 4.2rem; }
.sos { display: inline-flex; align-items: center; gap: .3rem; height: 2.9rem; padding: 0 1rem; border-radius: 999px; background: var(--crit); color: #fff; text-decoration: none; font-size: .95rem; white-space: nowrap; }
.sos:hover { filter: brightness(1.08); }

.disclaimer { background: var(--note-bg); border-bottom: 1px solid var(--note-line); padding: .55rem 1.25rem; font-size: .88rem; }
.disclaimer summary { cursor: pointer; list-style: none; }
.disclaimer summary::-webkit-details-marker { display: none; }
.disclaimer summary strong { margin-right: .3rem; }
.disclaimer .more { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; margin-left: .3rem; white-space: nowrap; }
.disclaimer[open] .more { display: none; }
.disclaimer ul { margin: .4rem 0 .2rem; padding-left: 1.4rem; }

/* ---------- controls ---------- */
.controls { background: var(--panel); border-bottom: 1px solid var(--line); padding: .8rem 1.25rem; display: flex; flex-wrap: wrap; gap: .7rem 1rem; align-items: flex-end; }
.searchrow { display: flex; gap: .6rem; flex: 1 1 30rem; flex-wrap: wrap; }
.search { position: relative; flex: 1 1 16rem; }
.search-ico { position: absolute; left: .85rem; top: 50%; width: 1.2rem; height: 1.2rem; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search input { width: 100%; height: 2.9rem; border: 1.5px solid var(--line); border-radius: 999px; background: var(--bg); padding: 0 1rem 0 2.6rem; font-size: 1rem; }
.search input:focus { border-color: var(--accent); background: var(--panel); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.near { display: flex; gap: .4rem; }
.near select { height: 2.9rem; border: 1.5px solid var(--line); border-radius: 999px; background: var(--bg); padding: 0 .8rem; }
.btn { height: 2.9rem; border-radius: 999px; border: 1.5px solid var(--accent); background: transparent; color: var(--accent); padding: 0 1.15rem; cursor: pointer; white-space: nowrap; font-weight: 600; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .6; cursor: wait; }

.sevrow { display: flex; align-items: center; gap: .4rem .8rem; flex-wrap: wrap; }
.sev-toggles { display: flex; gap: .45rem; flex-wrap: wrap; }
.chip { height: 2.9rem; border-radius: 12px; border: 1.5px solid var(--line); background: var(--panel); padding: 0 .85rem; cursor: pointer; display: inline-flex; align-items: center; gap: .45rem; white-space: nowrap; font-weight: 600; transition: opacity .15s, background .15s; }
.chip[data-sev="CRITICAL"][aria-pressed="true"] { background: var(--crit-bg); border-color: var(--crit); }
.chip[data-sev="WARNING"][aria-pressed="true"] { background: var(--warn-bg); border-color: var(--warn); }
.chip[data-sev="WATCH"][aria-pressed="true"] { background: var(--watch-bg); border-color: var(--watch); }
.chip[aria-pressed="false"] { opacity: .5; text-decoration: line-through; }
.chip-n { min-width: 1.7rem; height: 1.5rem; padding: 0 .4rem; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); font-size: .85rem; display: inline-flex; align-items: center; justify-content: center; }
.dot { width: .72rem; height: .72rem; border-radius: 50%; display: inline-block; flex: none; }
.dot.CRITICAL { background: var(--crit); }
.dot.WARNING { background: var(--warn); }
.dot.WATCH { background: var(--watch); }
.info-btn { border: 0; background: transparent; color: var(--accent); cursor: pointer; font-size: .9rem; padding: .3rem .2rem; text-decoration: underline; text-underline-offset: 3px; white-space: nowrap; }

.filterrow { display: flex; gap: .6rem; flex-wrap: wrap; }
.field { display: flex; flex-direction: column; gap: .15rem; min-width: 0; }
.field label { font-size: .78rem; color: var(--muted); padding-left: .3rem; }
.field select { height: 2.9rem; border: 1.5px solid var(--line); border-radius: 999px; background: var(--bg); padding: 0 .9rem; max-width: 100%; min-width: 9rem; }

/* severity explanation */
.sev-help { background: var(--panel); border-bottom: 1px solid var(--line); padding: .8rem 1.25rem 1rem; font-size: .92rem; max-height: 50vh; overflow: auto; }
.sev-help p { margin: .25rem 0; }
.sev-help-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.sev-help h2 { font-size: 1.05rem; margin: 0; }
.sev-help-close { border: 1px solid var(--line); background: var(--bg); color: var(--text); border-radius: 10px; width: 2.4rem; height: 2.4rem; cursor: pointer; }
.sev-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); gap: .65rem; margin: .6rem 0; }
.sev-card { border-radius: var(--radius); padding: .6rem .85rem; border-left: 5px solid; }
.sev-card h3 { font-size: 1rem; margin: 0 0 .15rem; display: flex; align-items: center; gap: .4rem; }
.sev-card.CRITICAL { background: var(--crit-bg); border-color: var(--crit); }
.sev-card.WARNING { background: var(--warn-bg); border-color: var(--warn); }
.sev-card.WATCH { background: var(--watch-bg); border-color: var(--watch); }
.sev-card .eg { color: var(--muted); font-size: .85rem; }
.sev-help .muted { color: var(--muted); font-size: .85rem; }

/* ---------- status line ---------- */
.status { padding: .55rem 1rem; font-size: .92rem; display: flex; flex-wrap: wrap; gap: .3rem .9rem; align-items: center; background: var(--bg); position: sticky; top: 0; z-index: 5; border-bottom: 1px solid var(--line); }
.status .count { font-weight: 700; font-size: 1rem; }
.status .pill { display: none; }
.active-filter { display: inline-flex; align-items: center; gap: .35rem; background: var(--accent-soft); color: var(--text); border-radius: 999px; padding: .1rem .3rem .1rem .8rem; }
.active-filter button { border: 0; background: transparent; cursor: pointer; font-size: 1.1rem; line-height: 1; padding: .15rem .4rem; color: var(--muted); border-radius: 999px; }
.near-msg { color: var(--muted); }
.notice { margin: 0; padding: .55rem 1.25rem; background: var(--warn-bg); color: var(--text); font-size: .92rem; border-bottom: 1px solid var(--line); }

/* ---------- timeline ---------- */
.timeline { background: var(--panel); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: .5rem 1.25rem .55rem; display: flex; gap: .9rem; align-items: center; }
.tl-play { flex: none; width: 2.8rem; height: 2.8rem; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-ink); cursor: pointer; font-size: 1rem; box-shadow: var(--shadow-sm); }
.tl-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.tl-bars { height: 2.2rem; display: flex; align-items: flex-end; gap: 2px; padding: 0 .45rem; }
.tl-col { flex: 1; min-width: 0; height: 100%; display: flex; flex-direction: column-reverse; cursor: pointer; border-bottom: 1px solid var(--line); border-radius: 3px 3px 0 0; overflow: hidden; }
.tl-col:hover { background: var(--bg); }
.tl-col.out { opacity: .22; }
.tl-col.pick { outline: 2px solid var(--accent); outline-offset: 1px; }
.tl-seg { display: block; width: 100%; min-height: 3px; }
.tl-seg.CRITICAL { background: var(--crit); }
.tl-seg.WARNING { background: var(--warn); }
.tl-seg.WATCH { background: var(--watch); }
#tl-range { width: 100%; margin: .15rem 0 0; accent-color: var(--accent); height: 1.4rem; }
.tl-axis { display: flex; justify-content: space-between; font-size: .74rem; color: var(--muted); padding: 0 .25rem; }
.tl-side { flex: none; width: 19rem; display: flex; flex-direction: column; gap: .3rem; font-size: .84rem; }
.tl-label { color: var(--muted); line-height: 1.4; }
.tl-ctl { display: flex; gap: .4rem; }
.tl-ctl select { height: 2.2rem; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--text); padding: 0 .4rem; }
.tl-now { height: 2.2rem; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--text); padding: 0 .75rem; cursor: pointer; }
.tl-now:disabled { opacity: .45; cursor: default; }

/* ---------- main split ---------- */
.viewtabs { display: none; }
main { flex: 1; display: grid; grid-template-columns: minmax(0, 3fr) minmax(22rem, 2fr); min-height: 0; }
#map { min-height: 300px; height: 100%; background: #dfe7ea; }
.feed { overflow-y: auto; border-left: 1px solid var(--line); background: var(--bg); }
.feed ol { list-style: none; margin: 0; padding: .8rem .9rem 1.5rem; display: flex; flex-direction: column; gap: .7rem; }
.empty { padding: 1.5rem 1rem; color: var(--muted); text-align: center; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem 1rem .85rem; box-shadow: var(--shadow); cursor: pointer; position: relative; overflow: hidden; transition: transform .12s, box-shadow .12s; }
.card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: var(--line); }
.card.CRITICAL::before { background: var(--crit); }
.card.WARNING::before { background: var(--warn); }
.card.WATCH::before { background: var(--watch); }
.card:hover { transform: translateY(-1px); box-shadow: 0 2px 6px rgba(16, 24, 40, .1), 0 8px 20px rgba(16, 24, 40, .06); }
.card.selected { outline: 2.5px solid var(--accent); outline-offset: 0; }
.card-top { display: flex; gap: .8rem; align-items: flex-start; }
.card-head { flex: 1; min-width: 0; }
.thumb { flex: none; width: 7.5rem; aspect-ratio: 4 / 3; border-radius: 10px; overflow: hidden; position: relative; background: var(--bg); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; position: relative; z-index: 1; background: var(--bg); }
/* placeholder (shown when there is no picture): severity tint + shield mark */
.thumb::after { content: ""; position: absolute; inset: 0; margin: auto; width: 42%; height: 42%; opacity: .55;
  background: currentColor; -webkit-mask: url("logo-mask.svg?v=15") center / contain no-repeat; mask: url("logo-mask.svg?v=15") center / contain no-repeat; }
.thumb.CRITICAL { background: var(--crit-bg); color: var(--crit); }
.thumb.WARNING { background: var(--warn-bg); color: var(--warn); }
.thumb.WATCH { background: var(--watch-bg); color: var(--watch); }
.card h2 { font-size: 1.04rem; margin: .35rem 0 .25rem; line-height: 1.45; font-weight: 600; }
.card h2 a { color: inherit; text-decoration: none; }
.card h2 a:hover { text-decoration: underline; }
.meta { font-size: .8rem; color: var(--muted); display: flex; flex-wrap: wrap; align-items: center; gap: .15rem .6rem; }
.summary { font-size: .9rem; color: var(--muted); margin: .25rem 0; }
.tags { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .5rem; }
.tag { font-size: .78rem; border-radius: 999px; padding: .1rem .6rem; background: var(--bg); border: 1px solid var(--line); }
.tag.place { background: var(--accent-soft); border-color: transparent; }
.tag.place::before { content: "📍"; margin-right: .15rem; }
.tag.nopin { color: var(--muted); font-style: italic; }
.card .source-link { font-size: .85rem; display: inline-flex; align-items: center; gap: .2rem; margin-top: .55rem; font-weight: 600; text-decoration: none; }
.card .source-link:hover { text-decoration: underline; }

/* share */
.share-btn { display: inline-flex; align-items: center; gap: .35rem; height: 2.9rem; padding: 0 1rem; border-radius: 999px; border: 1.5px solid var(--accent); background: var(--panel); color: var(--accent); cursor: pointer; font-weight: 600; white-space: nowrap; }
.share-btn svg { width: 1.1rem; height: 1.1rem; }
.share-btn:hover { background: var(--accent-soft); }
.card-share { margin-top: .55rem; margin-right: .8rem; border: 1px solid var(--line); background: var(--bg); color: var(--text); border-radius: 999px; padding: .2rem .8rem; cursor: pointer; font-size: .85rem; }
.card-share:hover { border-color: var(--accent); color: var(--accent); }
.share-dlg { border: 0; border-radius: 18px; padding: 1rem 1.1rem 1.1rem; width: min(26rem, calc(100vw - 2rem)); background: var(--panel); color: var(--text); box-shadow: 0 20px 60px rgba(0, 0, 0, .25); }
.share-dlg::backdrop { background: rgba(10, 20, 30, .45); }
.share-head { display: flex; justify-content: space-between; align-items: center; }
.share-head h2 { margin: 0; font-size: 1.15rem; }
.share-close { border: 1px solid var(--line); background: var(--bg); color: var(--text); border-radius: 10px; width: 2.4rem; height: 2.4rem; cursor: pointer; }
.share-what { color: var(--muted); font-size: .9rem; margin: .4rem 0 .8rem; }
.share-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(5.6rem, 1fr)); gap: .5rem; }
.share-opt { display: flex; flex-direction: column; align-items: center; gap: .3rem; padding: .7rem .3rem; border-radius: 14px; border: 1px solid var(--line); background: var(--bg); color: var(--text); text-decoration: none; font-size: .85rem; cursor: pointer; }
.share-opt:hover { border-color: var(--accent); }
.share-ico { width: 2.6rem; height: 2.6rem; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: 1.1rem; background: #6b7280; }
.share-opt.line .share-ico { background: #06c755; }
.share-opt.fb .share-ico { background: #1877f2; font-family: Arial, sans-serif; }
.share-opt.x .share-ico { background: #111; }
.share-opt.copy .share-ico { background: var(--accent); }
.share-url { width: 100%; margin-top: .8rem; height: 2.5rem; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--muted); padding: 0 .7rem; font-size: .85rem; }
.share-msg { margin: .4rem 0 0; color: var(--accent); font-size: .85rem; min-height: 1.2em; }
/* publisher icon (favicon) with a letter badge underneath as the fallback */
.src { display: inline-flex; align-items: center; gap: .3rem; }
.src-ico { position: relative; width: 1rem; height: 1rem; flex: none; border-radius: 4px; overflow: hidden; }
.src-ico img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #fff; }
.src-letter { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: var(--accent-soft); color: var(--accent); font-size: .62rem; font-weight: 700; line-height: 1; }
/* brief (สรุปประเด็น) shown inside the clicked card */
.brief-toggle { margin-top: .55rem; margin-right: .8rem; border: 1px solid var(--line); background: var(--bg); color: var(--text); border-radius: 999px; padding: .2rem .8rem; cursor: pointer; font-size: .85rem; }
.brief-toggle:hover { border-color: var(--accent); color: var(--accent); }
.brief { margin-top: .7rem; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: .7rem .85rem; cursor: default; }
.brief-title { font-weight: 700; display: flex; justify-content: space-between; align-items: center; margin-bottom: .3rem; }
.brief-close { border: 0; background: transparent; color: var(--accent); cursor: pointer; font-size: .85rem; }
.brief dl { margin: 0; display: grid; grid-template-columns: max-content 1fr; gap: .35rem .8rem; font-size: .92rem; }
.brief dt { color: var(--muted); font-weight: 600; }
.brief dd { margin: 0; min-width: 0; }
.brief-note { color: var(--muted); font-size: .8rem; margin: .15rem 0 0; }
.brief-actions { display: flex; gap: .5rem; flex-wrap: wrap; margin: .7rem 0 .2rem; }
.brief-actions .btn { height: 2.6rem; display: inline-flex; align-items: center; text-decoration: none; }
.card.selected .source-link { display: none; }
@media (max-width: 480px) { .brief dl { grid-template-columns: 1fr; gap: .1rem; } .brief dd { margin-bottom: .35rem; } }
.badge { font-size: .78rem; font-weight: 700; border-radius: 999px; padding: .1rem .65rem; display: inline-block; }
.badge.CRITICAL { background: var(--crit); color: #fff; }
.badge.WARNING { background: var(--warn-bg); color: var(--warn); }
.badge.WATCH { background: var(--watch-bg); color: var(--watch-ink); }

/* ---------- map extras ---------- */
.legend { background: var(--panel); color: var(--text); padding: .55rem .7rem; border-radius: 12px; box-shadow: var(--shadow); font-size: .8rem; line-height: 1.7; }
.legend div { display: flex; align-items: center; gap: .4rem; }
.legend .hint { color: var(--muted); max-width: 12rem; line-height: 1.4; margin-top: .25rem; display: block; }
.leaflet-container { font: inherit; }
.leaflet-control-attribution { font-size: .68rem; }
.leaflet-popup-content-wrapper { border-radius: 12px; }
.leaflet-popup-content { font-family: inherit; font-size: .88rem; margin: .7rem .8rem; }
.pop h3 { font-size: .95rem; margin: 0 0 .15rem; }
.pop .where { color: #5b6676; font-size: .78rem; margin-bottom: .4rem; }
.pop ul { margin: 0; padding: 0; list-style: none; max-height: 14rem; overflow-y: auto; }
.pop li { padding: .35rem 0; border-top: 1px solid #e2e6ec; }
.pop li a { font-weight: 600; }
.pop .small { font-size: .78rem; color: #5b6676; }
.pop .only { margin-top: .5rem; border: 1px solid #0b6e69; color: #0b6e69; background: #fff; border-radius: 999px; padding: .25rem .8rem; cursor: pointer; font: inherit; font-size: .82rem; }

footer { font-size: .78rem; color: var(--muted); padding: .55rem 1.25rem; border-top: 1px solid var(--line); background: var(--panel); display: flex; flex-direction: column; gap: .15rem; }
footer .hotlines { color: var(--text); font-size: .85rem; }

.more-filters { display: none; }
@media (max-width: 600px) {
  /* province / toxin / period sit behind one button on phones (opened automatically when one is in use) */
  .more-filters { display: inline-block; border: 1px solid var(--line); background: var(--bg); color: var(--text); border-radius: 999px; padding: .3rem .9rem; cursor: pointer; font-size: .88rem; }
  .controls:not(.filters-open) .filterrow { display: none !important; }
  .controls { gap: .55rem; padding-top: .6rem; padding-bottom: .6rem; }
  .sev-toggles { flex-wrap: nowrap !important; }
  .chip { font-size: .85rem; padding: 0 .3rem !important; gap: .25rem !important; height: 2.6rem; min-width: 0; }
  .chip-n { border: 0; background: transparent; min-width: 0 !important; padding: 0 !important; font-size: .85rem; }
  .chip-n::before { content: "("; } .chip-n::after { content: ")"; }
  .tl-side { flex-wrap: wrap; }
  .tl-label { width: 100%; }
}
/* ---------- tablet / phone ---------- */
@media (max-width: 860px) {
  body { display: block; height: auto; }
  .top { padding: .6rem .9rem; }
  .brand { flex-basis: 100%; }
  .brand h1 { font-size: 1.2rem; }
  .logo { width: 2.2rem; height: 2.2rem; }
  .top-actions { width: 100%; justify-content: space-between; }
  .ts-label { display: none; }
  .controls, .disclaimer, .status, .timeline, .sev-help { padding-left: .9rem; padding-right: .9rem; }
  .searchrow { flex-basis: 100%; }
  .near { flex: 1 1 100%; }
  .near .btn { flex: 1; }
  .sevrow { width: 100%; }
  .sev-toggles { width: 100%; gap: .35rem; }
  .chip { flex: 1 1 auto; justify-content: center; padding: 0 .45rem; gap: .3rem; font-size: .92rem; }
  .chip-n { min-width: 1.4rem; padding: 0 .3rem; }
  .filterrow { width: 100%; gap: .35rem; }
  .field { flex: 1 1 6.5rem; min-width: 0; }
  .field select { min-width: 0; width: 100%; padding: 0 .5rem; font-size: .9rem; }
  .timeline { flex-wrap: wrap; gap: .4rem .7rem; }
  .tl-main { flex-basis: calc(100% - 3.6rem); }
  .tl-side { width: 100%; flex-direction: row; align-items: center; justify-content: space-between; gap: .5rem; }
  .tl-label { font-size: .8rem; }
  .viewtabs { display: flex; position: sticky; top: 0; z-index: 1000; background: var(--panel); border-bottom: 1px solid var(--line); padding: .45rem .9rem; gap: .4rem; }
  .viewtabs button { flex: 1; height: 2.7rem; border-radius: 999px; border: 1.5px solid var(--line); background: var(--bg); cursor: pointer; font-weight: 600; }
  .viewtabs button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
  .vt-n { font-weight: 500; opacity: .85; }
  main { display: block; }
  #map { height: 68vh; }
  .feed { border-left: 0; overflow: visible; }
  body.view-map .feed { display: none; }
  body.view-list #map { display: none; }
}

/* ---------- phone header: one compact row (logo + name | text size, share, 1669) ---------- */
.fs-toggle, .upd-short { display: none; }
@media (max-width: 600px) {
  .top { flex-wrap: nowrap; padding: .45rem .7rem; gap: .5rem; position: relative; }
  .brand { flex: 1 1 auto; min-width: 0; gap: .45rem; }
  .logo { width: 2rem; height: 2rem; }
  .brand h1 { font-size: 1.1rem; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .brand h1 .h1-sub { display: none; }
  .brand p { font-size: .74rem; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .brand p .tagline, .upd-long { display: none; }
  .upd-short { display: inline; }
  .top-actions { width: auto !important; flex: none; flex-wrap: nowrap; gap: .35rem; justify-content: flex-end; }
  /* three round buttons of the same size, 44px touch target */
  .icon-btn, .share-btn, .sos { width: 2.75rem; height: 2.75rem; min-width: 2.75rem; padding: 0; border-radius: 50%; justify-content: center; display: inline-flex; align-items: center; }
  .fs-toggle { display: inline-flex; border: 1.5px solid var(--line); background: var(--panel); color: var(--text); cursor: pointer; font-weight: 700; font-size: 1.05rem; line-height: 1; }
  .fs-toggle small { font-size: .7em; margin-left: 1px; }
  .share-btn .share-t, .sos .sos-t, .sos b { display: none; }
  .sos::after { content: "1669"; font-size: .7rem; font-weight: 700; position: absolute; bottom: -.1rem; left: 50%; transform: translateX(-50%); background: #fff; color: var(--crit); border-radius: 6px; padding: 0 .2rem; line-height: 1.2; }
  .sos { position: relative; font-size: 1.15rem; }
  /* text-size buttons become a small pop-up under the กก button */
  .textsize { display: none; position: absolute; right: .7rem; top: calc(100% + .3rem); z-index: 1500; background: var(--panel); box-shadow: var(--shadow); padding: .3rem; }
  .top.fs-open .textsize { display: inline-flex; }
  .textsize button { min-width: 2.75rem; height: 2.75rem; }
  .ts-label { display: inline; }
  .disclaimer summary { font-size: .8rem; }
}@media (max-width: 600px) { .brand > div { min-width: 0; } }
@media (max-width: 360px) {
  .brand p::before { content: none; }
  .viewtabs button { font-size: .9rem; white-space: nowrap; }
  .top-actions { gap: .25rem; }
}
/* collapsible colour key on the map */
.legend { padding: .35rem .55rem; }
.legend-toggle { display: flex; align-items: center; gap: .45rem; width: 100%; min-height: 2.2rem; border: 0; background: transparent; color: var(--text); cursor: pointer; font: inherit; font-size: .82rem; font-weight: 600; padding: 0 .15rem; }
.legend-dots { display: inline-flex; gap: .2rem; }
.legend-arrow::after { content: "▾"; color: var(--muted); }
.legend.closed .legend-arrow::after { content: "▴"; }
.legend .legend-body { display: block; padding: .15rem .15rem .2rem; max-width: 13rem; }
.legend.closed .legend-body { display: none; }
.legend .legend-toggle { max-width: 13rem; }
.legend.closed { border-radius: 999px; }
/* "updates automatically" badge in the header */
.live { display: inline-flex; align-items: center; gap: .4rem; }
.live-dot { width: .7rem; height: .7rem; border-radius: 50%; background: #9aa5b4; flex: none; position: relative; margin: 0 .15rem; }
.live-dot i { position: absolute; inset: 0; border-radius: 50%; border: 2px solid currentColor; opacity: 0; }
.live.ok .live-dot { background: #1faa59; color: #1faa59; box-shadow: 0 0 0 3px rgba(31, 170, 89, .18); }
.live.ok .live-dot i { animation: live-ring 2.4s cubic-bezier(.2, .6, .4, 1) infinite; }
.live.ok .live-dot i + i { animation-delay: 1.2s; }
.live.ok .live-dot { animation: live-blink 2.4s ease-in-out infinite; }
.live.warn .live-dot { background: #e6a700; }
.live.warn { color: #9a6a00; }
.live.bad .live-dot { background: var(--crit); }
.live.bad { color: var(--crit); }
.live.wait .live-dot { background: var(--accent); }
@keyframes live-ring { 0% { transform: scale(1); opacity: .85; } 100% { transform: scale(3.2); opacity: 0; } }
@keyframes live-blink { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }
/* spinning arrows while the page fetches new data (about one second every 2 minutes) */
.live-sync { width: .95rem; height: .95rem; flex: none; color: var(--accent); display: none; }
.live.checking .live-sync { display: inline-block; animation: live-spin .9s linear infinite; }
@keyframes live-spin { to { transform: rotate(360deg); } }
/* countdown to the next scraper run */
.live-bar { display: inline-block; width: 3.2rem; height: .32rem; border-radius: 999px; background: rgba(31, 170, 89, .18); overflow: hidden; flex: none; }
.live-bar b { display: block; height: 100%; width: 0; background: #1faa59; border-radius: inherit; transition: width 4.8s linear; }
@media (prefers-reduced-motion: reduce) {
  .live.ok .live-dot, .live.ok .live-dot i, .live.checking .live-sync { animation: none; }
  .live-bar b { transition: none; }
}/* new news */
.news-toast { position: fixed; left: 50%; bottom: 1.2rem; transform: translateX(-50%); z-index: 3000; border: 0; border-radius: 999px; background: var(--accent); color: var(--accent-ink); padding: .7rem 1.2rem; font: inherit; font-weight: 600; box-shadow: 0 8px 24px rgba(0,0,0,.2); cursor: pointer; max-width: calc(100vw - 2rem); }
.new-tag { background: #1faa59; color: #fff; border-radius: 999px; padding: 0 .5rem; font-size: .72rem; font-weight: 700; }
.card.is-new { box-shadow: 0 0 0 2px #1faa59, var(--shadow); }