/* น้ำแม่กลอง · ราชบุรี — tokens */
:root {
  --ground: #edf2f1;
  --surface: #ffffff;
  --surface-2: #f5f8f7;
  --ink: #13201e;
  --muted: #566a66;
  --line: #d3dedb;
  --accent: #0b6e78;          /* สีน้ำแม่กลอง */
  --accent-soft: #d6ecee;
  --river: #3d8fb8;
  --province: #7f948f;
  --land: #f3f1ea;
  --land-out: #e3e7e5;
  --water-fill: #b9dbe9;
  --road-major: #f3cf8e;
  --road-major-case: #d9ae66;
  --road: #ffffff;
  --road-case: #cfd6d3;
  --road-minor: #ffffff;
  --rail: #8d8a86;
  --map-label: #4b5654;

  /* ระดับสถานการณ์ (ThaiWater 1–5) */
  --lv5: #c0262d;  /* ล้นตลิ่ง */
  --lv4: #dc8300;  /* น้ำมาก */
  --lv3: #2f8f5b;  /* ปกติ */
  --lv2: #8aa39b;  /* น้ำน้อย */
  --lv1: #a07a2c;  /* น้ำน้อยวิกฤต */

  /* ประเภทจุด */
  --c-parking: #1f5fbf;
  --c-shelter: #2f8f5b;
  --c-flooded: #d32f2f;
  --c-supply: #b0701a;
  --c-medical: #c2185b;
  --c-road: #45504e;

  --tile-filter: none;
  --shadow: 0 1px 2px rgb(19 32 30 / .08), 0 4px 16px rgb(19 32 30 / .06);
  --f-display: "Chakra Petch", "Anuphan", "Noto Sans Thai", system-ui, sans-serif;
  --f-body: "Anuphan", "Noto Sans Thai", "Sukhumvit Set", system-ui, sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --ground: #0d1514; --surface: #141f1d; --surface-2: #1a2725; --ink: #e2ebe9; --muted: #93a6a2;
    --line: #273532; --accent: #46b6c0; --accent-soft: #163a3d; --river: #4aa3cf; --province: #6b7f7b; --land: #172321; --land-out: #0c1312; --water-fill: #1d3f52; --road-major: #8a6a3a; --road-major-case: #5d4827; --road: #3a4644; --road-case: #26302e; --road-minor: #2e3937; --rail: #5e6765; --map-label: #a8b5b2;
    --lv5: #ef5350; --lv4: #f0a02a; --lv3: #4cb97c; --lv2: #6f8a83; --lv1: #c49a45;
    --c-parking: #5b8fe6; --c-shelter: #4cb97c; --c-flooded: #f05252; --c-supply: #d99a3c; --c-medical: #e0529a; --c-road: #9aa7a4;
    --tile-filter: invert(1) hue-rotate(180deg) brightness(.82) contrast(.9) saturate(.6);
    --shadow: 0 1px 2px rgb(0 0 0 / .4), 0 6px 20px rgb(0 0 0 / .3);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --ground: #0d1514; --surface: #141f1d; --surface-2: #1a2725; --ink: #e2ebe9; --muted: #93a6a2;
  --line: #273532; --accent: #46b6c0; --accent-soft: #163a3d; --river: #4aa3cf; --province: #6b7f7b; --land: #172321; --land-out: #0c1312; --water-fill: #1d3f52; --road-major: #8a6a3a; --road-major-case: #5d4827; --road: #3a4644; --road-case: #26302e; --road-minor: #2e3937; --rail: #5e6765; --map-label: #a8b5b2;
  --lv5: #ef5350; --lv4: #f0a02a; --lv3: #4cb97c; --lv2: #6f8a83; --lv1: #c49a45;
  --c-parking: #5b8fe6; --c-shelter: #4cb97c; --c-flooded: #f05252; --c-supply: #d99a3c; --c-medical: #e0529a; --c-road: #9aa7a4;
  --tile-filter: invert(1) hue-rotate(180deg) brightness(.82) contrast(.9) saturate(.6);
  --shadow: 0 1px 2px rgb(0 0 0 / .4), 0 6px 20px rgb(0 0 0 / .3);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; } /* claude.ai ใส่ให้เอง แต่บนเว็บทั่วไปต้องใส่เอง */
html, body { height: 100%; }
body {
  margin: 0; background: var(--ground); color: var(--ink);
  font: 15px/1.55 var(--f-body);
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1, h2 { font-family: var(--f-display); text-wrap: balance; margin: 0; }

.app { display: flex; flex-direction: column; height: 100%; }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark { width: 36px; height: 36px; border-radius: 9px; background: var(--accent); display: grid; place-items: center; flex: none; }
.brand-mark svg { width: 24px; height: 24px; fill: none; stroke: var(--surface); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.brand-mark svg path:last-child { fill: var(--surface); stroke: none; }
.brand h1 { font-size: 19px; font-weight: 700; letter-spacing: .01em; line-height: 1.2; }
.h1-sub { font-family: var(--f-body); font-size: 13px; font-weight: 500; color: var(--accent); margin-left: 6px; letter-spacing: 0; }
.brand-sub { margin: 0; font-size: 12.5px; color: var(--muted); }
.topbar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.live { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--lv3); box-shadow: 0 0 0 0 var(--lv3); animation: pulse 2.4s infinite; }
.live.stale .live-dot { background: var(--lv4); animation: none; }
.hotline {
  text-decoration: none; background: var(--lv5); color: #fff; border-radius: 999px;
  padding: 6px 14px; font-size: 13.5px; white-space: nowrap;
}
.hotline b { font-family: var(--f-display); font-size: 16px; margin-left: 2px; }

.alert {
  display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap;
  padding: 9px 16px; background: var(--lv5); color: #fff; font-size: 14px;
}
.alert strong { font-family: var(--f-display); font-weight: 600; letter-spacing: .02em; }
.alert.warn { background: var(--lv4); color: #1c1300; }

/* ---------- layout ---------- */
.layout { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(340px, 420px) 1fr; }
.panel { background: var(--surface); border-right: 1px solid var(--line); overflow-y: auto; display: flex; flex-direction: column; min-height: 0; }
.mapbox { position: relative; min-height: 0; }
#map { position: absolute; inset: 0; background: var(--land-out); }

@media (max-width: 820px) {
  .app { height: auto; }
  .layout { grid-template-columns: 1fr; }
  .mapbox { order: -1; height: 58vh; min-height: 360px; }
  .panel { border-right: 0; overflow: visible; }
  .brand-sub { display: none; }
}

/* ---------- tabs ---------- */
.tabs { position: sticky; top: 0; z-index: 2; display: flex; background: var(--surface); border-bottom: 1px solid var(--line); padding: 0 8px; }
.tabs button {
  flex: 1; background: none; border: 0; padding: 12px 6px 10px; cursor: pointer; font-weight: 500; font-size: 14.5px;
  color: var(--muted); border-bottom: 2.5px solid transparent;
}
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.count { font-family: var(--f-mono); font-size: 11.5px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 0 6px; margin-left: 2px; }
.tabpane { padding: 14px 16px 24px; display: flex; flex-direction: column; gap: 18px; }

/* ---------- stats ---------- */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 11px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.stat .v { font-family: var(--f-display); font-size: 28px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat .v small { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 2px; }
.stat .k { font-size: 12.5px; color: var(--muted); line-height: 1.3; }
.stat.lv5 { background: color-mix(in srgb, var(--lv5) 10%, var(--surface)); border-color: color-mix(in srgb, var(--lv5) 35%, var(--line)); }
.stat.lv5 .v { color: var(--lv5); }
.stat.lv4 .v { color: var(--lv4); }

.block { display: flex; flex-direction: column; gap: 8px; }
.block-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.block-head h2 { font-size: 15.5px; font-weight: 600; }
.hint { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- river profile ---------- */
.profile-wrap { overflow-x: auto; }
#profile { width: 100%; min-width: 340px; height: 210px; display: block; }
#profile text { fill: var(--muted); font-family: var(--f-body); font-size: 11px; }
#profile .val { font-family: var(--f-mono); font-size: 11px; fill: var(--ink); font-weight: 500; }
#profile .code { font-family: var(--f-mono); font-size: 10.5px; fill: var(--ink); }
#profile .bankline { stroke: var(--ink); stroke-dasharray: 4 3; stroke-width: 1; opacity: .55; }
#profile .grid { stroke: var(--line); stroke-width: 1; }
#profile .riverbed { fill: var(--accent-soft); }
#profile .prov { fill: var(--surface-2); }
#profile .prov-label { font-size: 10.5px; fill: var(--muted); letter-spacing: .02em; }
#profile .bar { cursor: pointer; }

/* ---------- dams ---------- */
.dams { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.dam { border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; display: flex; flex-direction: column; gap: 6px; }
.dam-name { font-size: 13.5px; font-weight: 600; }
.meter { height: 8px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--accent); }
.meter.hot i { background: var(--lv4); }
.dam-row { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.dam-row b { color: var(--ink); font-family: var(--f-mono); font-weight: 500; }

/* ---------- stations table ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; }
table.stations { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.stations th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12px; padding: 7px 9px; background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap; }
.stations td { padding: 7px 9px; border-bottom: 1px solid var(--line); vertical-align: top; }
.stations tr:last-child td { border-bottom: 0; }
.stations tbody tr { cursor: pointer; }
.stations tbody tr:hover { background: var(--surface-2); }
.stations .num { text-align: right; font-family: var(--f-mono); white-space: nowrap; }
.stations .sub { display: block; font-size: 11.5px; color: var(--muted); }
.stations .code { font-family: var(--f-mono); font-size: 11px; color: var(--muted); }
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; padding: 1px 8px 1px 6px; border-radius: 999px; white-space: nowrap; border: 1px solid; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.lv5 { color: var(--lv5); background: color-mix(in srgb, var(--lv5) 10%, transparent); }
.pill.lv4 { color: var(--lv4); background: color-mix(in srgb, var(--lv4) 10%, transparent); }
.pill.lv3 { color: var(--lv3); background: color-mix(in srgb, var(--lv3) 10%, transparent); }
.pill.lv2, .pill.lv1, .pill.lv0 { color: var(--muted); }
.up { color: var(--lv5); } .down { color: var(--lv3); }

/* ---------- rain ---------- */
.rainlist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 5px; }
.rainlist li { display: grid; grid-template-columns: 1fr 110px 44px; gap: 8px; align-items: center; font-size: 13px; }
.rainlist .rn { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rainlist .rn span { color: var(--muted); font-size: 12px; }
.rainlist .rb { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.rainlist .rb i { display: block; height: 100%; background: var(--river); border-radius: 3px; }
.rainlist .rv { font-family: var(--f-mono); text-align: right; }

.hotlines { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.hotlines a { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; text-decoration: none; color: var(--ink); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; font-size: 12.5px; }
.hotlines a b { font-family: var(--f-display); font-size: 17px; color: var(--lv5); }
.sources { font-size: 12px; color: var(--muted); margin: 0; line-height: 1.6; }
.sources .bad { color: var(--lv5); }

/* ---------- points ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-size: 13px;
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 4px 11px 4px 6px;
}
.chip[aria-pressed="true"] { background: var(--ink); color: var(--surface); border-color: var(--ink); }
#news-chips .chip { padding-left: 11px; }
.chip .glyph { width: 20px; height: 20px; }
.chip .n { font-family: var(--f-mono); font-size: 11.5px; opacity: .75; }

.points, .news { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.point { display: grid; grid-template-columns: 30px 1fr; gap: 10px; padding: 11px 2px; border-bottom: 1px solid var(--line); cursor: pointer; }
.point:hover { background: var(--surface-2); }
.point .glyph { width: 30px; height: 30px; }
.point h3 { margin: 0; font-size: 14.5px; font-weight: 600; line-height: 1.35; }
.point p { margin: 2px 0 0; font-size: 13px; color: var(--muted); }
.meta { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 12px; color: var(--muted); margin-top: 4px; }
.meta a { color: var(--accent); }
.tag { font-size: 11px; border: 1px dashed var(--muted); border-radius: 4px; padding: 0 5px; color: var(--muted); }
.point.nogeo { cursor: default; }
.report { border: 1px dashed var(--line); border-radius: 10px; padding: 12px; font-size: 13px; color: var(--muted); display: flex; flex-direction: column; gap: 8px; }
.report strong { color: var(--ink); font-size: 14px; }
.btn { align-self: flex-start; text-decoration: none; background: var(--accent); color: var(--surface); border-radius: 8px; padding: 7px 14px; font-weight: 500; }

.news li { padding: 11px 2px; border-bottom: 1px solid var(--line); }
.news a { color: var(--ink); text-decoration: none; font-size: 14.5px; line-height: 1.45; }
.news a:hover { color: var(--accent); text-decoration: underline; }
.src { font-weight: 500; }
.fb { color: #fff; background: #1877f2; border-radius: 4px; padding: 0 5px; font-size: 11px; }
.empty { color: var(--muted); font-size: 13.5px; padding: 12px 0; }

/* ---------- map ---------- */
.leaflet-container { font: 13px/1.45 var(--f-body); background: var(--land-out); }
.leaflet-tile-pane { filter: var(--tile-filter); }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.leaflet-popup-content { margin: 11px 13px; min-width: 200px; }
.leaflet-popup-content h4 { margin: 0 0 2px; font-family: var(--f-display); font-size: 15px; font-weight: 600; }
.leaflet-popup-content .pp { color: var(--muted); font-size: 12.5px; }
.leaflet-popup-content .kv { display: grid; grid-template-columns: auto 1fr; gap: 1px 10px; margin-top: 6px; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.leaflet-popup-content .kv b { font-family: var(--f-mono); font-weight: 500; text-align: right; }
.leaflet-bar a, .leaflet-control-attribution { background: var(--surface) !important; color: var(--ink) !important; }
.leaflet-control-attribution a { color: var(--accent) !important; }

.st-marker { border-radius: 50%; border: 2.5px solid var(--surface); box-shadow: 0 0 0 1px rgb(0 0 0 / .25); }
.st-marker.lv5 { animation: ring 1.8s infinite; }
.pin { filter: drop-shadow(0 1px 2px rgb(0 0 0 / .35)); }
.pin.focus { transform-origin: 50% 100%; }
.district-label { font-family: var(--f-display); font-size: 12px; font-weight: 600; color: var(--muted); white-space: nowrap; text-shadow: 0 0 3px var(--land), 0 0 3px var(--land); letter-spacing: .03em; pointer-events: none; }
.road-label { font-size: 11px; font-weight: 500; color: var(--map-label); white-space: nowrap; text-shadow: 0 0 3px var(--land), 0 0 3px var(--land), 0 0 2px var(--land); pointer-events: none; }
.river-label { font-size: 11px; color: var(--river); font-style: italic; white-space: nowrap; text-shadow: 0 0 3px var(--land); pointer-events: none; }

.legend, .layers {
  position: absolute; z-index: 500; background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(6px);
  border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); font-size: 12px; padding: 8px 10px;
}
.legend { left: 10px; bottom: 22px; max-width: calc(100% - 20px); }
.legend > div { display: flex; flex-direction: column; gap: 3px; margin-top: 5px; }
.legend summary, .layers summary { cursor: pointer; font-weight: 600; font-size: 12px; color: var(--ink); list-style: none; display: flex; align-items: center; gap: 5px; }
.legend summary::-webkit-details-marker, .layers summary::-webkit-details-marker { display: none; }
.legend summary::after, .layers summary::after { content: "▾"; color: var(--muted); font-size: 10px; }
details[open] > summary::after { content: "▴"; }
.legend:not([open]), .layers:not([open]) { padding: 6px 10px; }
.legend .row { display: flex; flex-wrap: wrap; gap: 3px 10px; align-items: center; }
.legend .ttl { font-weight: 600; color: var(--muted); font-size: 11px; letter-spacing: .04em; }
.legend .sw { display: inline-flex; align-items: center; gap: 4px; }
.legend .sw i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.legend .sw svg { width: 16px; height: 16px; }
.layers { right: 10px; top: 10px; }
#layers-body { display: flex; flex-direction: column; gap: 3px; margin-top: 5px; }
.layers label { display: flex; align-items: center; gap: 6px; cursor: pointer; white-space: nowrap; }

@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--lv3) 60%, transparent); } 70% { box-shadow: 0 0 0 7px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
@keyframes ring { 0% { box-shadow: 0 0 0 1px rgb(0 0 0 / .25), 0 0 0 0 color-mix(in srgb, var(--lv5) 70%, transparent); } 70% { box-shadow: 0 0 0 1px rgb(0 0 0 / .25), 0 0 0 12px transparent; } 100% { box-shadow: 0 0 0 1px rgb(0 0 0 / .25), 0 0 0 0 transparent; } }
@media (prefers-reduced-motion: reduce) { .live-dot, .st-marker.lv5 { animation: none; } }

/* ---------- districts ---------- */
.districts { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.district { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 8px 11px; border-bottom: 1px solid var(--line); cursor: pointer; }
.district:last-child { border-bottom: 0; }
.district:hover { background: var(--surface-2); }
.district .dn { font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 6px; }
.district .ds { grid-column: 1 / -1; font-size: 12px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 2px 10px; }
.district .ds .none { color: var(--lv4); }
.warn-chip { font-size: 11px; font-weight: 500; color: #fff; background: var(--lv5); border-radius: 4px; padding: 0 6px; }
.district-label.warned { color: var(--lv5); }
.district-label.warned::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--lv5); margin-right: 4px; vertical-align: 1px; }

/* ---------- dam extras / channels ---------- */
.dam-room { font-size: 12px; line-height: 1.4; border-radius: 6px; padding: 5px 7px; background: var(--surface-2); }
.dam-room b { font-family: var(--f-mono); font-weight: 500; }
.dam-room.crit { background: color-mix(in srgb, var(--lv5) 12%, var(--surface)); color: var(--ink); }
.dam-room.crit b { color: var(--lv5); }
.dam-note { font-size: 11.5px; color: var(--muted); margin: 0; }
.tag-dam { font-size: 11px; border-radius: 4px; padding: 0 5px; background: var(--accent-soft); color: var(--accent); }
.tag-official { font-size: 11px; border-radius: 4px; padding: 0 5px; border: 1px solid var(--lv3); color: var(--lv3); }
.tag-fact { font-size: 11px; border-radius: 4px; padding: 0 5px; background: var(--lv4); color: #1c1300; }
.channels { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.channels li { display: flex; gap: 8px; align-items: baseline; font-size: 13px; }
.channels .g { font-size: 11px; color: var(--muted); min-width: 82px; }

@media (max-width: 820px) { .legend { bottom: 18px; } .road-label { font-size: 10.5px; } }
/* กันหน้ากว้างเกินจอบนมือถือ: grid item ต้องหดได้ */
.layout > *, .tabpane > *, .block { min-width: 0; }
@media (max-width: 820px) {
  .topbar { padding-block: 8px; }
  .topbar-right { width: 100%; justify-content: space-between; }
  .live { font-size: 12px; min-width: 0; }
  .brand h1 { font-size: 17px; }
  .alert { font-size: 13px; padding-block: 7px; }
}

/* ---------- ค้นหา/กรองจุด ---------- */
.finder { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.finder input, .finder select {
  font: inherit; font-size: 14px; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; min-width: 0;
}
.finder input:focus, .finder select:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
.point mark { background: color-mix(in srgb, var(--lv4) 35%, transparent); color: inherit; border-radius: 2px; padding: 0 1px; }
#points-count { margin: -6px 0 -8px; }
.province-label { font-family: var(--f-display); font-size: 12.5px; font-weight: 600; letter-spacing: .08em; color: var(--muted); opacity: .75; white-space: nowrap; pointer-events: none; }

/* ---------- ประกาศสำคัญ (แถบบนสุด) ---------- */
.bulletin { background: var(--surface); border-bottom: 1px solid var(--line); padding: 8px 16px; display: flex; flex-direction: column; gap: 3px; border-left: 4px solid var(--lv4); }
.bulletin.critical { border-left-color: var(--lv5); background: color-mix(in srgb, var(--lv5) 7%, var(--surface)); }
.b-row { display: flex; align-items: center; gap: 10px; min-width: 0; }
.b-badge { flex: none; font-family: var(--f-display); font-weight: 700; font-size: 12px; letter-spacing: .03em; color: #fff; background: var(--lv4); border-radius: 4px; padding: 2px 7px; }
.bulletin.critical .b-badge { background: var(--lv5); }
.b-title { flex: 1; min-width: 0; color: var(--ink); text-decoration: none; font-weight: 600; font-size: 15px; line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.b-title:hover { text-decoration: underline; }
.b-nav { flex: none; display: flex; align-items: center; gap: 2px; font-family: var(--f-mono); font-size: 12px; color: var(--muted); }
.b-nav button { background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; width: 26px; height: 26px; cursor: pointer; font-size: 15px; line-height: 1; color: var(--ink); }
.b-meta { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; font-size: 12px; color: var(--muted); padding-left: 2px; }
.b-meta .gov { color: var(--lv3); font-weight: 600; }
.b-all { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font-size: 12px; text-decoration: underline; }
.alert { padding-block: 5px; font-size: 13px; }

/* ---------- ลดการเลื่อน: ปุ่มลอย + รายการพับได้ ---------- */
.fab { position: fixed; right: 16px; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); z-index: 1000; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.fab button { font: inherit; font-weight: 600; font-size: 13.5px; border: 0; border-radius: 999px; padding: 10px 16px; cursor: pointer;
  background: var(--ink); color: var(--surface); box-shadow: var(--shadow); }
.fab .fab-map { background: var(--accent); }
@media (min-width: 821px) { .fab { left: 16px; right: auto; } .fab .fab-map { display: none; } }
.more { align-self: flex-start; font: inherit; font-size: 13px; font-weight: 500; color: var(--accent); background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px; cursor: pointer; }
.stations tr.extra, .district.extra, .news li.extra, .point.extra { display: none; }
.expanded tr.extra, .expanded .district.extra, .expanded li.extra { display: revert; }
.expanded .point.extra, .expanded .district.extra { display: grid; }
@media (max-width: 820px) { .tabs { top: env(safe-area-inset-top, 0px); } .b-title { font-size: 14px; } }

/* หมุดตำแหน่งโดยประมาณ (ระดับตัวเมือง/ตำบล) */
.pin-approx { opacity: .72; }
.pin-approx svg circle, .pin-approx svg rect { stroke-dasharray: 3 2.2; stroke-width: 2.2; }
.approx-note { margin-top: 6px; font-size: 12px; color: var(--lv4); background: color-mix(in srgb, var(--lv4) 10%, transparent); border-radius: 6px; padding: 4px 7px; }

/* รายงานจากประชาชน (ยังไม่ยืนยัน) */
.pin-community svg { filter: drop-shadow(0 0 0 transparent); }
.pin-community svg circle, .pin-community svg rect { stroke: #fff; stroke-width: 2.5; stroke-dasharray: 2 2; }
.community-note { margin-top: 6px; font-size: 12px; color: var(--c-flooded); background: color-mix(in srgb, var(--c-flooded) 10%, transparent); border-radius: 6px; padding: 4px 7px; }

/* ---------- แจ้งจุดน้ำท่วม ---------- */
.report-btn { position: absolute; z-index: 600; right: 10px; bottom: 28px; font: inherit; font-weight: 600; font-size: 13px;
  background: var(--c-flooded); color: #fff; border: 0; border-radius: 999px; padding: 7px 12px; box-shadow: var(--shadow); cursor: pointer; }
.report-hint { position: absolute; z-index: 600; left: 50%; transform: translateX(-50%); top: 12px; background: var(--ink); color: var(--surface);
  border-radius: 999px; padding: 8px 8px 8px 16px; font-size: 14px; display: flex; gap: 10px; align-items: center; box-shadow: var(--shadow); }
.report-hint button { font: inherit; font-size: 13px; background: var(--surface); color: var(--ink); border: 0; border-radius: 999px; padding: 4px 12px; cursor: pointer; }
.mapbox.picking #map { cursor: crosshair; }
.report-dlg { border: 0; border-radius: 14px; padding: 0; width: min(460px, calc(100% - 24px)); max-height: calc(100% - 24px); background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.report-dlg::backdrop { background: rgb(0 0 0 / .45); }
.report-dlg form { padding: 16px 18px; display: flex; flex-direction: column; gap: 6px; }
.report-dlg h2 { font-size: 17px; margin-bottom: 2px; }
.report-dlg fieldset { border: 0; padding: 0; margin: 4px 0 0; }
.report-dlg legend, .report-dlg label { font-size: 12.5px; font-weight: 600; color: var(--muted); margin-top: 6px; }
.report-dlg small { font-weight: 400; }
.report-dlg input, .report-dlg select, .report-dlg textarea { font: inherit; font-size: 15px; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%; }
.report-hint { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: center; max-width: calc(100% - 24px); }
.report-hint .rh-gps { background: #1a73e8; color: #fff; font-weight: 600; }
.rd-where-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rd-gps { font: inherit; font-size: 13px; font-weight: 600; border: 1px solid #1a73e8; color: #1a73e8; background: var(--surface); border-radius: 999px; padding: 5px 11px; cursor: pointer; }
.rd-gps[aria-busy="true"], .rh-gps[aria-busy="true"] { opacity: .6; }
.rd-where { flex: 1 1 200px; margin: 0; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.rd-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.rd-chips button { font: inherit; font-size: 13.5px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 999px; padding: 6px 12px; cursor: pointer; }
.rd-chips button[aria-pressed="true"] { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.rd-note { font-size: 12px; color: var(--muted); margin: 6px 0 0; }
.rd-msg { font-size: 13.5px; margin: 4px 0 0; min-height: 1.2em; }
.rd-msg.ok { color: var(--lv3); font-weight: 600; } .rd-msg.err { color: var(--lv5); font-weight: 600; }
.rd-acts { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.rd-acts button { font: inherit; font-weight: 600; border: 0; border-radius: 8px; padding: 9px 16px; cursor: pointer; background: var(--c-flooded); color: #fff; }
.rd-acts button.ghost { background: var(--surface-2); color: var(--ink); }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
@media (max-width: 820px) { .report-btn { bottom: 26px; font-size: 12.5px; padding: 6px 11px; } }
.moved { display: block; padding: 10px 16px; background: var(--accent); color: #fff; text-decoration: none; font-size: 14.5px; }
.moved b { font-family: var(--f-display); }

/* ---------- ตำแหน่งฉัน / รอบตัวคุณ ---------- */
.locate-btn { position: absolute; z-index: 600; left: 10px; top: 86px; display: inline-flex; align-items: center; gap: 6px; font: inherit; font-weight: 600; font-size: 13px;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; box-shadow: var(--shadow); cursor: pointer; }
.locate-btn svg { width: 18px; height: 18px; fill: #1a73e8; stroke: #1a73e8; stroke-width: 2; }
.locate-btn[aria-busy="true"] { opacity: .6; cursor: wait; }
.me-dot { width: 16px; height: 16px; border-radius: 50%; background: #1a73e8; border: 3px solid #fff; box-shadow: 0 0 0 2px rgb(26 115 232 / .35), 0 1px 4px rgb(0 0 0 / .4); }
.nearme { position: absolute; z-index: 650; left: 10px; bottom: 22px; width: min(360px, calc(100% - 20px)); max-height: 62%; overflow: auto;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; }
.nm-head { display: flex; justify-content: space-between; align-items: center; }
.nm-head h2 { font-size: 16px; }
.nm-head button { background: none; border: 0; font-size: 20px; color: var(--muted); cursor: pointer; line-height: 1; }
.nm-sec { display: flex; flex-direction: column; gap: 4px; }
.nm-sec h3 { margin: 4px 0 0; font-size: 12.5px; color: var(--muted); font-weight: 600; letter-spacing: .02em; }
.nm-row { display: grid; grid-template-columns: 24px 1fr auto; gap: 8px; align-items: center; font-size: 13.5px; }
.nm-row .glyph { width: 22px; height: 22px; }
.nm-row .d { font-family: var(--f-mono); font-size: 12px; color: var(--muted); white-space: nowrap; }
.nm-row a { color: var(--accent); font-size: 12px; }
.nm-row .nm-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.nm-alert { border-radius: 8px; padding: 8px 10px; font-size: 13.5px; background: color-mix(in srgb, var(--lv5) 10%, var(--surface)); border: 1px solid color-mix(in srgb, var(--lv5) 35%, var(--line)); }
.nm-alert.calm { background: var(--surface-2); border-color: var(--line); }
.nm-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.nm-actions button { font: inherit; font-weight: 600; font-size: 13px; border: 0; border-radius: 8px; padding: 8px 12px; cursor: pointer; background: var(--c-flooded); color: #fff; }
.nm-privacy { font-size: 11.5px; color: var(--muted); margin: 0; }
@media (max-width: 820px) { .locate-btn { top: 86px; } .nearme { bottom: 12px; max-height: 70%; } }

/* ตัวกรองที่ใช้อยู่ — แสดงบนแผนที่ให้รู้ว่าทำไมหมุดบางส่วนหายไป */
.filter-chip { position: absolute; z-index: 600; left: 50%; transform: translateX(-50%); top: 10px; display: flex; align-items: center; gap: 8px;
  background: var(--lv4); color: #1c1300; border-radius: 999px; padding: 5px 5px 5px 12px; font-size: 13px; font-weight: 600; box-shadow: var(--shadow); max-width: calc(100% - 140px); }
.filter-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filter-chip button { font: inherit; font-size: 12.5px; border: 0; border-radius: 999px; padding: 4px 10px; background: #fff; color: #1c1300; cursor: pointer; white-space: nowrap; }

.district-note { margin: 0 0 8px; padding: 8px 10px; border-left: 3px solid var(--c-flooded); background: var(--surface-2); border-radius: 6px; font-size: 13px; line-height: 1.55; }
.district-note small { color: var(--muted); }

.alert-src { display: block; font-size: 12px; opacity: .92; }
.alert-src a { color: inherit; text-decoration: underline; }

/* มือถือ: ย่อแถบเตือน/ประกาศให้เห็นแผนที่มากขึ้น */
.alert-more { display: none; }
@media (max-width: 820px) {
  .alert { flex-wrap: nowrap; align-items: flex-start; gap: 8px; padding: 6px 12px; font-size: 12.5px; line-height: 1.4; }
  .alert-main { flex: 1; min-width: 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .alert-src { display: none; }
  .alert.open .alert-main { display: block; -webkit-line-clamp: unset; }
  .alert.open .alert-src { display: block; }
  .alert-more { display: inline-block; flex: none; font: inherit; font-size: 11.5px; color: inherit; background: rgb(255 255 255 / .18); border: 1px solid rgb(255 255 255 / .45); border-radius: 999px; padding: 1px 8px; cursor: pointer; }
  .alert.warn .alert-more { background: rgb(0 0 0 / .08); border-color: rgb(0 0 0 / .25); }
  .bulletin { padding: 6px 12px; gap: 2px; }
  .b-title { font-size: 13.5px; -webkit-line-clamp: 2; }
  .b-meta { font-size: 11.5px; gap: 8px; }
  .topbar { padding: 6px 12px; }
  /* ปุ่มตำแหน่งฉันเหลือแต่ไอคอน ขนาดเท่าปุ่มซูม */
  .locate-btn { top: 84px; width: 34px; height: 34px; padding: 0; justify-content: center; }
  .locate-btn span { display: none; }
  .leaflet-popup-content { margin: 10px 12px; font-size: 13px; }
}
