/* WatSai AirCare v2.3
   แนวคิด: สีของระดับคุณภาพอากาศเป็นพระเอก ส่วนอื่นเรียบและนิ่ง ไม่มีภาพเคลื่อนไหว
   ตัวอักษร IBM Plex Sans Thai Looped (ตัวมีหัว อ่านง่ายสำหรับผู้สูงอายุ) · ไอคอน SVG ฝังในหน้า */
:root {
  --brand: #0f766e; --brand-2: #0d9488; --brand-soft: #dff3ef; --top-bg: #0f3b36;
  --bg: #eef3f1; --surface: #ffffff; --surface-2: #f5f8f7; --surface-3: #e8efed;
  --line: #dde6e3; --line-2: #c8d6d2;
  --ink: #14211f; --ink-2: #43544f; --ink-3: #7b8b87;
  --ok: #15803d; --warn: #b45309; --bad: #b91c1c; --sos-bg: #fdecec;
  --r-xl: 24px; --r-lg: 18px; --r-md: 14px; --r-sm: 10px;
  --shadow: 0 1px 2px rgba(20,33,31,.06), 0 10px 28px rgba(20,33,31,.10);
  --shadow-s: 0 1px 2px rgba(20,33,31,.07);
  --top: 64px; --panel: 420px;
  --font: 'IBM Plex Sans Thai Looped', 'IBM Plex Sans Thai', 'Loma', system-ui, sans-serif;
  color-scheme: light;
}
html.dark {
  --brand: #5eead4; --brand-2: #2dd4bf; --brand-soft: #173330; --top-bg: #0b2623;
  --bg: #0e1514; --surface: #151f1d; --surface-2: #1b2725; --surface-3: #22302d;
  --line: #263532; --line-2: #33453f;
  --ink: #e9f1ef; --ink-2: #b0c0bc; --ink-3: #7a8b87; --sos-bg: #3a1717;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 10px 28px rgba(0,0,0,.4);
  --shadow-s: 0 1px 2px rgba(0,0,0,.4);
  color-scheme: dark;
}
* { box-sizing: border-box; }
*, *::before, *::after { animation: none !important; transition: none !important; }
[v-cloak] { display: none; }
html, body { height: 100%; }
body { margin: 0; font-family: var(--font); background: var(--bg); color: var(--ink); -webkit-font-smoothing: antialiased; overflow: hidden; font-size: 15px; line-height: 1.5; }
button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
h1, h2, h3, p { margin: 0; }
.ic { width: 1.25em; height: 1em; fill: currentColor; flex-shrink: 0; vertical-align: -0.125em; }
.muted { color: var(--ink-3); }
.center { display: grid; place-items: center; height: 100%; font-weight: 500; }
:focus-visible { outline: 2px solid var(--brand-2); outline-offset: 2px; }

/* ---------- แถบบน ---------- */
.topbar { position: fixed; inset: 0 0 auto 0; height: var(--top); z-index: 1000; display: flex; align-items: center; gap: 16px; padding: 0 20px; background: var(--top-bg); color: #fff; }
.brand { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; flex-shrink: 0; }
.brand img { border-radius: 10px; }
/* โลโก้ตัวอักษร: Fredoka ตัวกลมมน เข้ากับหน้ายิ้ม · WatSai ขาว + AirCare เขียวมิ้นต์ */
.wordmark { display: block; font-family: 'Fredoka', var(--font); font-size: 22px; font-weight: 600; line-height: 1.1; letter-spacing: .2px; }
.wordmark em { font-style: normal; font-weight: 500; color: #5eead4; margin-left: .22em; }
.brand small { display: block; font-size: 12px; color: #a9c7c1; }
.tabs { display: flex; gap: 4px; margin: 0 auto; }
.tabs button { display: flex; align-items: center; gap: 8px; padding: 9px 16px; border-radius: 99px; font-size: 14.5px; font-weight: 500; color: #cfe3df; }
.tabs button:hover { color: #fff; background: rgba(255,255,255,.08); }
.tabs button.on, .tabs button.on:hover { background: #fff; color: var(--top-bg); font-weight: 600; }
html.dark .tabs button.on { color: #0b2623; }
.tabs .ic { font-size: 16px; }
.tools { display: flex; gap: 6px; }
.icon-btn { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: rgba(255,255,255,.09); color: #fff; border: 1px solid rgba(255,255,255,.16); font-size: 15px; }
.icon-btn:hover { background: rgba(255,255,255,.18); }
.icon-btn.txt { font-size: 13px; font-weight: 600; }

/* ---------- หน้าแผนที่ ---------- */
.map-page { position: fixed; inset: var(--top) 0 0 0; }
#map { position: absolute; inset: 0 0 0 var(--panel); background: #e3e8e5; z-index: 1; }
html.dark #map { background: #171d1b; }
.tiles-street { filter: saturate(.6) contrast(.97); }
html.dark .tiles-street { filter: invert(100%) hue-rotate(180deg) brightness(92%) contrast(85%) saturate(.5); }
.leaflet-container { font-family: inherit; }
.leaflet-control-zoom, .leaflet-control-layers { border: 1px solid var(--line) !important; border-radius: var(--r-md) !important; box-shadow: var(--shadow-s) !important; overflow: hidden; }
.leaflet-control-layers { background: var(--surface) !important; padding: 6px 10px !important; color: var(--ink); font-size: 13px; }
.leaflet-control-layers label { margin: 3px 0; font-weight: 500; }
.leaflet-control-zoom a { background: var(--surface) !important; color: var(--ink) !important; border-color: var(--line) !important; }
.leaflet-control-attribution { font-size: 10px; background: rgba(255,255,255,.8) !important; }
html.dark .leaflet-control-attribution { background: rgba(21,31,29,.85) !important; color: var(--ink-3); }

.mode-switch { position: absolute; top: 14px; left: calc(var(--panel) + (100% - var(--panel)) / 2); transform: translateX(-50%); z-index: 500; display: flex; align-items: center; gap: 2px; padding: 4px; background: var(--surface); border-radius: 99px; box-shadow: var(--shadow); border: 1px solid var(--line); max-width: calc(100vw - 24px); }
.seg { display: flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 99px; font-size: 13.5px; font-weight: 500; color: var(--ink-2); white-space: nowrap; }
.seg:hover { background: var(--surface-2); color: var(--ink); }
.seg .ic { font-size: 14px; }
.seg.on { background: var(--brand); color: #fff; font-weight: 600; }
html.dark .seg.on { color: #06211d; }
.seg.fire { color: #b45309; }
.seg.fire.on { background: #c2410c; color: #fff; }
.seg .count { font-style: normal; font-size: 11.5px; font-weight: 600; background: #fde8d8; color: #9a3412; border-radius: 99px; padding: 0 7px; }
.seg.fire.on .count { background: rgba(255,255,255,.22); color: #fff; }
.divider { width: 1px; height: 20px; background: var(--line); margin: 0 4px; }

/* แผงซ้าย */
.panel { position: absolute; z-index: 600; top: 0; left: 0; bottom: 0; width: var(--panel); display: flex; flex-direction: column; background: var(--bg); border-right: 1px solid var(--line); }
.sheet-handle { display: none; }
.panel-scroll { overflow-y: auto; padding: 18px; flex: 1; overscroll-behavior: contain; }
.panel-scroll::-webkit-scrollbar { width: 6px; } .panel-scroll::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 9px; }

/* ค่าฝุ่นตอนนี้ — พื้นสีตามระดับ */
.hero { border-radius: var(--r-xl); overflow: hidden; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-s); }
.hero-top { background: var(--lv); color: var(--lvink); padding: 20px 20px 18px; display: flex; align-items: center; gap: 12px; }
.hero-main { min-width: 0; }
.hero-label { font-size: 13.5px; font-weight: 500; opacity: .82; }
.hero-num { display: flex; align-items: baseline; gap: 8px; margin-top: 4px; }
.hero-num b { font-size: 68px; font-weight: 700; line-height: .95; letter-spacing: -2px; font-variant-numeric: tabular-nums; }
.hero-num small { font-size: 14px; font-weight: 500; opacity: .82; }
.hero-lv { font-size: 22px; font-weight: 700; margin-top: 6px; line-height: 1.25; }
.hero-face { margin-left: auto; width: 92px; height: 92px; border-radius: 50%; background: rgba(255,255,255,.38); display: grid; place-items: center; flex-shrink: 0; }
.hero-face svg { width: 72%; height: 72%; }
.hero-body { padding: 18px 20px; display: grid; gap: 14px; }
.ruler-bar { position: relative; display: grid; grid-template-columns: repeat(5, 1fr); gap: 3px; height: 10px; }
.ruler-bar i { border-radius: 5px; }
.ruler-pin { position: absolute; top: -5px; width: 6px; height: 20px; margin-left: -3px; border-radius: 3px; background: var(--ink); box-shadow: 0 0 0 2.5px var(--surface); }
.ruler-ticks { display: grid; grid-template-columns: repeat(5, 1fr); margin-top: 7px; font-size: 11.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.ruler-ticks span { width: fit-content; transform: translateX(-50%); }
.ruler-ticks span:first-child { transform: none; }
.ruler-ticks .std { color: var(--ink); font-weight: 700; }
.hero-tip { font-size: 15px; line-height: 1.6; }
.hero-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.hero-meta { font-size: 12.5px; color: var(--ink-3); display: inline-flex; align-items: center; gap: 5px; font-variant-numeric: tabular-nums; }
.hero-foot .share-btn { margin-left: auto; }
.hero-empty { border-radius: var(--r-xl); background: var(--surface); border: 1px dashed var(--line-2); padding: 28px 20px; text-align: center; color: var(--ink-2); display: grid; gap: 10px; justify-items: center; }
.hero-empty .ic { font-size: 28px; color: var(--ink-3); }

.face { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0; }
.face svg { width: 68%; height: 68%; }
.face.sm { width: 34px; height: 34px; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.pill.soft { background: var(--surface-2); border: 1px solid var(--line); }

.btn { display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px; border-radius: 99px; background: var(--surface); border: 1px solid var(--line-2); font-weight: 500; font-size: 13.5px; text-decoration: none; color: var(--ink); }
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .4; cursor: default; }
.btn .ic { font-size: 14px; color: var(--brand); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; padding: 11px 18px; font-size: 14.5px; }
html.dark .btn.primary { color: #06211d; }
.btn.primary .ic { color: inherit; }

/* พยากรณ์ */
.fc { margin-top: 12px; padding: 16px 18px 14px; border-radius: var(--r-xl); background: var(--surface); border: 1px solid var(--line); }
.fc-head { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 600; margin-bottom: 12px; }
.fc-head .ic { color: var(--brand); font-size: 15px; }
.fc-head small { font-weight: 400; color: var(--ink-3); font-size: 12px; margin-left: auto; }
.fc-days { display: grid; grid-template-columns: repeat(3, 1fr); }
.fc-day { display: grid; justify-items: center; gap: 4px; padding: 4px 6px 2px; text-align: center; }
.fc-day + .fc-day { border-left: 1px solid var(--line); }
.fc-name { font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 2px; }
.fc-day b { font-size: 26px; font-weight: 700; line-height: 1.15; font-variant-numeric: tabular-nums; }
.fc-lv { font-size: 12.5px; font-weight: 500; line-height: 1.3; }
.fc-day small { font-size: 11.5px; color: var(--ink-3); }
.fc-note { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); font-size: 11.5px; color: var(--ink-3); line-height: 1.5; }

.seg-tabs { display: flex; gap: 4px; margin: 20px 0 12px; }
.seg-tabs button { display: flex; align-items: center; gap: 7px; padding: 8px 14px; border-radius: 99px; font-size: 14px; font-weight: 500; color: var(--ink-2); }
.seg-tabs button:hover { background: var(--surface-3); }
.seg-tabs button.on { background: var(--ink); color: var(--bg); font-weight: 600; }
.seg-tabs .ic { font-size: 13px; }
.seg-tabs.compact { margin: 0; border: 1px solid var(--line); border-radius: 99px; background: var(--surface); padding: 3px; gap: 2px; }
.seg-tabs.compact button { padding: 6px 14px; }

.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.card { width: 100%; display: flex; gap: 12px; align-items: center; text-align: left; padding: 14px; border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line); }
.card:hover { border-color: var(--brand-2); }
.card.stale { opacity: .65; }
.card-body { min-width: 0; flex: 1; display: grid; gap: 2px; }
.card-title { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-sub { font-size: 12.5px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-val { text-align: right; flex-shrink: 0; display: grid; gap: 1px; }
.card-val b { font-size: 26px; font-weight: 700; line-height: 1.05; font-variant-numeric: tabular-nums; }
.card-val small { font-size: 11px; color: var(--ink-3); }
.src { font-size: 11px; font-weight: 600; padding: 0 6px; border-radius: 5px; margin-right: 4px; background: var(--surface-3); color: var(--ink-2); }
.src.sensor { background: var(--brand-soft); color: var(--brand); }
.chips { display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 3px; }
.chip { font-size: 12px; color: var(--ink-3); display: inline-flex; align-items: center; gap: 4px; }
.chip b { font-weight: 600; color: var(--ink-2); }
.chip.warn { color: var(--warn); }
.chip .ic { font-size: 11px; }
.rank { width: 22px; text-align: center; font-weight: 700; font-size: 16px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.ranked li:nth-child(-n+3) .rank { color: var(--bad); }
.card.skel { pointer-events: none; }
.card.skel i { width: 44px; height: 44px; border-radius: 50%; background: var(--surface-3); }
.card.skel div { flex: 1; display: grid; gap: 7px; }
.card.skel b { height: 10px; border-radius: 5px; background: var(--surface-3); }
.card.skel b:nth-child(2) { width: 60%; } .card.skel b:nth-child(3) { width: 40%; }

.legend { position: absolute; z-index: 500; left: calc(var(--panel) + 14px); bottom: 14px; display: flex; gap: 14px; align-items: center; flex-wrap: wrap; padding: 8px 16px; border-radius: 99px; background: var(--surface); box-shadow: var(--shadow-s); border: 1px solid var(--line); font-size: 12.5px; font-weight: 500; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 50%; }
.legend small { color: var(--ink-3); font-weight: 400; }
.legend-title { color: var(--ink-3); }

.fab { position: absolute; z-index: 500; display: flex; align-items: center; gap: 8px; box-shadow: var(--shadow); }
.fab.gps { right: 14px; bottom: 30px; width: 46px; height: 46px; border-radius: 50%; justify-content: center; background: var(--surface); color: var(--brand); border: 1px solid var(--line); font-size: 17px; }
.fab.gps:hover { background: var(--surface-2); }
.fab.report { right: 14px; bottom: 88px; padding: 11px 18px; border-radius: 99px; background: #c2410c; color: #fff; font-weight: 600; font-size: 14px; }

/* หมุดบนแผนที่ */
.mk { background: transparent; border: 0; }
.mk-dot { width: 46px; height: 46px; border-radius: 50%; border: 3px solid #fff; display: grid; place-items: center; font-weight: 700; font-size: 15px; line-height: 1; text-align: center; position: relative; box-shadow: 0 2px 6px rgba(0,0,0,.28); font-variant-numeric: tabular-nums; }
.mk-dot small { display: block; font-size: 9px; font-weight: 500; margin-top: 1px; }
.mk-dot.own { border-color: #0f3b36; }
/* ข้อมูลเก่า: ยังคงสีตามระดับฝุ่น แต่ขอบเป็นเส้นประและจางลงเล็กน้อย */
.mk-dot.stale { border-style: dashed; border-color: #e5e7eb; opacity: .85; }
.fire-dot { width: 26px; height: 26px; border-radius: 50%; border: 2px solid #fff; display: grid; place-items: center; color: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.35); font-size: 12px; }
.zone-dot { width: 26px; height: 26px; border-radius: 8px; background: #1e40af; border: 2px solid #fff; display: grid; place-items: center; color: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.3); font-size: 11px; }
.me-dot { width: 16px; height: 16px; border-radius: 50%; background: #2563eb; border: 3px solid #fff; box-shadow: 0 0 0 4px rgba(37,99,235,.22); }

/* Popup */
.leaflet-popup-content-wrapper { padding: 0; border-radius: var(--r-xl); overflow: hidden; box-shadow: var(--shadow); background: var(--surface); color: var(--ink); }
.leaflet-popup-tip { background: var(--surface); }
.leaflet-popup-content { margin: 0; width: min(310px, calc(100vw - 36px)) !important; font-size: 13.5px; line-height: 1.5; }
.leaflet-container a.leaflet-popup-close-button { top: 10px; right: 10px; width: 28px; height: 28px; font-size: 18px; line-height: 26px; border-radius: 50%; color: rgba(0,0,0,.6); background: rgba(255,255,255,.45); z-index: 5; }
.leaflet-container a.leaflet-popup-close-button:hover { background: rgba(255,255,255,.8); color: #000; }
.pop { max-height: min(66vh, 600px); overflow-y: auto; }
.pop-hero { padding: 16px 18px 18px; }
.pop-name { display: flex; gap: 8px; align-items: flex-start; font-weight: 600; font-size: 15.5px; line-height: 1.35; padding-right: 34px; }
.pop-name .ic { margin-top: 4px; font-size: 14px; }
.pop-name small { display: block; font-weight: 400; font-size: 12px; opacity: .8; }
.pop-val { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.pop-val .big { font-size: 52px; font-weight: 700; line-height: 1; letter-spacing: -1.5px; font-variant-numeric: tabular-nums; }
.pop-val .unit { font-size: 12px; margin-left: 6px; opacity: .82; }
.pop-val b { display: block; font-size: 17px; font-weight: 700; margin-top: 4px; }
.pop-face { margin-left: auto; width: 64px; height: 64px; border-radius: 50%; background: rgba(255,255,255,.38); display: grid; place-items: center; flex-shrink: 0; }
.pop-face svg { width: 72%; height: 72%; }
.pop-grid { display: grid; grid-template-columns: repeat(3, 1fr); margin: 14px 18px 0; }
.pop-grid div { padding: 2px 6px; text-align: center; }
.pop-grid div + div { border-left: 1px solid var(--line); }
.pop-grid span { display: block; font-size: 11.5px; font-weight: 500; color: var(--ink-3); }
.pop-grid b { display: block; font-size: 21px; font-weight: 700; line-height: 1.25; font-variant-numeric: tabular-nums; }
.pop-grid small { font-size: 10.5px; color: var(--ink-3); }
.pop-meta { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 14px 18px 0; padding-top: 12px; border-top: 1px solid var(--line); font-size: 12px; color: var(--ink-2); }
.pop-meta span { display: inline-flex; align-items: center; gap: 4px; }
.pop-meta .ic { color: var(--ink-3); font-size: 11px; }
.pop-meta .warn, .pop-meta .warn .ic { color: var(--warn); font-weight: 600; }
.pop-sec { padding: 14px 18px 0; font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.pop-chart { height: 110px; margin: 6px 18px 0; position: relative; }
.pop-health { margin: 14px 18px 0; padding: 14px; border-radius: var(--r-md); background: var(--surface-2); }
.pop-ico { display: flex; align-items: center; gap: 6px; margin-bottom: 10px; }
.pop-ico span { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-size: 15px; }
.pop-ico b { margin-left: 4px; font-size: 13px; font-weight: 600; }
.pop-health p { font-size: 13px; color: var(--ink); margin-bottom: 8px; line-height: 1.55; }
.pop-health p:last-child { margin: 0; }
.pop-health p b { display: block; font-size: 11.5px; font-weight: 600; color: var(--ink-3); }
.pop-actions { display: flex; gap: 8px; padding: 14px 18px 18px; }
.pop-actions a, .pop-actions button { flex: 1; display: flex; justify-content: center; align-items: center; gap: 6px; padding: 9px; border-radius: 99px; border: 1px solid var(--line-2); font-size: 13px; font-weight: 500; color: var(--ink); text-decoration: none; background: var(--surface); }
.pop-actions a:hover, .pop-actions button:hover { background: var(--surface-2); }
.pop-actions .ic { color: var(--brand); font-size: 13px; }
.pop-mini { display: flex; gap: 10px; align-items: center; padding: 14px 44px 14px 16px; }
.pop-mini .ic { color: var(--brand); font-size: 16px; }
.pop-mini small { color: var(--ink-3); }
.pop-fire { padding: 16px 18px 18px; }
.pop-fire h4 { margin: 0 34px 10px 0; color: #c2410c; display: flex; align-items: center; gap: 6px; font-size: 15px; font-weight: 700; }
html.dark .pop-fire h4 { color: #fdba74; }
.pop-fire div { margin-bottom: 4px; }
.pop-fire a { display: flex; justify-content: center; align-items: center; gap: 6px; margin-top: 12px; padding: 9px; border-radius: 99px; border: 1px solid var(--line-2); color: var(--ink); font-weight: 500; text-decoration: none; }

/* แผ่นรายละเอียดสถานีบนมือถือ: เต็มจอ เลื่อนได้จนสุด */
.detail { display: none; }
@media (max-width: 860px) {
  .detail { display: block; position: fixed; z-index: 1050; left: 0; right: 0; top: var(--top); bottom: calc(64px + env(safe-area-inset-bottom)); background: var(--surface); overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; font-size: 14.5px; }
  .detail .pop { max-height: none; overflow: visible; padding-bottom: 8px; }
  .detail .pop-hero { padding: 18px 20px 20px; }
  .detail .pop-name { padding-right: 48px; font-size: 17px; }
  .detail .pop-val .big { font-size: 64px; }
  .detail .pop-chart { height: 150px; }
  .detail .pop-health p { font-size: 14.5px; }
  .detail-close { position: sticky; top: 10px; float: right; margin: 10px 12px -50px 0; z-index: 2; width: 40px; height: 40px; border-radius: 50%; background: rgba(255,255,255,.6); color: rgba(0,0,0,.7); display: grid; place-items: center; font-size: 17px; box-shadow: var(--shadow-s); }
}

/* ---------- หน้าทั่วไป ---------- */
.page { position: fixed; inset: var(--top) 0 0 0; overflow-y: auto; padding: 36px 20px 64px; }
.wrap { max-width: 1120px; margin: 0 auto; display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; }
.wrap.narrow { max-width: 860px; }
.page-head { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-end; justify-content: space-between; padding-bottom: 6px; }
.page-head > * { min-width: 0; max-width: 100%; }
.page-head h1 { font-size: 30px; font-weight: 700; letter-spacing: -.4px; line-height: 1.3; }
.page-head p { margin-top: 6px; color: var(--ink-2); font-size: 15px; max-width: 640px; line-height: 1.6; }
.controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
select { padding: 8px 14px; border-radius: 99px; border: 1px solid var(--line-2); background: var(--surface); font-weight: 500; max-width: 100%; }
.box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-xl); padding: 22px; }
.box.flush { padding: 0; overflow: hidden; }
.box h2 { font-size: 16px; font-weight: 600; display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.box h2 .ic { color: var(--brand); font-size: 15px; }
.box h2 small { color: var(--ink-3); font-weight: 400; }
.box-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 22px; border-bottom: 1px solid var(--line); }
.box-head h2 { margin: 0; }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-xl); }
.kpi { padding: 20px 22px; display: grid; gap: 4px; min-width: 0; }
.kpi + .kpi { border-left: 1px solid var(--line); }
.kpi span { font-size: 13px; font-weight: 500; color: var(--ink-2); display: flex; align-items: center; gap: 6px; }
.kpi span .ic { color: var(--ink-3); font-size: 13px; }
.kpi b { font-size: 36px; font-weight: 700; line-height: 1.15; font-variant-numeric: tabular-nums; letter-spacing: -.5px; }
.kpi small { font-size: 12px; color: var(--ink-3); }
.chart-wrap { height: 320px; position: relative; }
.chart-wrap canvas, .pop-chart canvas { max-width: 100%; }
.table-scroll { overflow: auto; max-height: 460px; }
.table-scroll.flat { max-height: none; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
table.data th { position: sticky; top: 0; background: var(--surface-2); color: var(--ink-2); text-align: left; padding: 10px 16px; font-weight: 600; font-size: 12.5px; white-space: nowrap; border-bottom: 1px solid var(--line); }
table.data tr.sub th { top: 39px; font-weight: 500; }
.flat table.data th { position: static; }
table.data td { padding: 10px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover td { background: var(--surface-2); }
table.data.mid th, table.data.mid td { text-align: center; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 8px; }

/* ---------- หน้าความรู้ ---------- */
.info { display: block; }
.info-head h1 { font-size: 36px; font-weight: 700; letter-spacing: -.6px; line-height: 1.3; }
.info-head p { margin-top: 10px; font-size: 17px; line-height: 1.7; color: var(--ink-2); max-width: 34em; }
.toc { position: sticky; top: -36px; z-index: 5; display: flex; flex-wrap: wrap; gap: 6px; margin: 22px -20px 0; padding: 12px 20px; background: var(--bg); border-bottom: 1px solid var(--line); }
.toc button { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 99px; font-size: 13.5px; font-weight: 500; color: var(--ink-2); background: var(--surface); border: 1px solid var(--line); white-space: nowrap; }
.toc button:hover { border-color: var(--brand-2); color: var(--ink); }
.toc .ic { font-size: 12px; color: var(--brand); }
.sec { padding: 40px 0 8px; }
.sec h2 { display: flex; align-items: center; gap: 12px; font-size: 25px; font-weight: 700; letter-spacing: -.3px; line-height: 1.35; margin-bottom: 18px; scroll-margin-top: 120px; }
.sec-ic { width: 42px; height: 42px; border-radius: 13px; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; font-size: 18px; flex-shrink: 0; }
.sec h3 { font-size: 16.5px; font-weight: 600; margin: 26px 0 12px; }
.prose p, .sec-lead { font-size: 16px; line-height: 1.8; max-width: 36em; }
.prose p + p { margin-top: 12px; }
.sec-lead { margin-bottom: 18px; color: var(--ink-2); }
.split { display: grid; grid-template-columns: 1.15fr 1fr; gap: 32px; align-items: center; }
.size-fig { margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-xl); padding: 12px 12px 10px; }
.size-fig svg { width: 100%; height: auto; display: block; }
.fig-hair { fill: #4a3b33; } html.dark .fig-hair { fill: #6b574c; }
.fig-pm10 { fill: #ffb74d; } .fig-pm25 { fill: #dc2626; }
.fig-t { font: 600 15px var(--font); fill: var(--ink); } .fig-s { font: 400 12.5px var(--font); fill: var(--ink-3); }
.fig-on.fig-t { fill: #fff; } .fig-on.fig-s { fill: #e5d9d2; }
.size-fig figcaption { text-align: center; font-size: 12px; color: var(--ink-3); }
.facts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0 24px; margin: 28px 0 0; padding-top: 18px; border-top: 2px solid var(--ink); }
.facts dt { font-size: 13px; color: var(--ink-3); }
.facts dt b { font-size: 38px; font-weight: 700; color: var(--ink); letter-spacing: -1px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.facts dd { margin: 6px 0 0; font-size: 13.5px; line-height: 1.55; color: var(--ink-2); }
.icon-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 20px 32px; }
.icon-list li { display: flex; gap: 14px; }
.il-ic { width: 46px; height: 46px; border-radius: 50%; background: var(--surface); border: 1px solid var(--line); color: var(--brand); display: grid; place-items: center; font-size: 18px; flex-shrink: 0; }
.icon-list b { font-size: 16px; font-weight: 600; }
.icon-list p { margin-top: 2px; font-size: 14.5px; line-height: 1.65; color: var(--ink-2); }
.note { display: flex; gap: 14px; margin-top: 26px; padding: 18px 20px; border-radius: var(--r-lg); background: var(--brand-soft); }
.note > .ic { font-size: 20px; color: var(--brand); margin-top: 3px; }
.note b { font-weight: 600; font-size: 15.5px; }
.note p { margin-top: 3px; font-size: 14.5px; line-height: 1.7; }
.note.sos { background: var(--sos-bg); }
.note.sos > .ic { color: var(--bad); } html.dark .note.sos > .ic { color: #fca5a5; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 0 32px; }
.two h3 { margin-top: 0; }
.ticks { list-style: none; margin: 0; padding: 0; display: grid; gap: 9px; font-size: 15px; line-height: 1.6; }
.ticks li { display: flex; gap: 10px; }
.ticks .ic { font-size: 13px; margin-top: 6px; }
.ticks li > i { width: 6px; height: 6px; border-radius: 50%; background: var(--line-2); margin: 10px 4px 0 6px; flex-shrink: 0; }
.ticks.ok .ic { color: var(--ok); } html.dark .ticks.ok .ic { color: #4ade80; }
.risk { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.risk li { display: inline-flex; align-items: center; gap: 8px; padding: 8px 16px 8px 12px; border-radius: 99px; background: var(--surface); border: 1px solid var(--line); font-size: 14.5px; font-weight: 500; }
.risk .ic { color: var(--brand); font-size: 15px; }
.lv-rows { border-radius: var(--r-xl); overflow: hidden; border: 1px solid var(--line); background: var(--surface); }
.lv-row { display: grid; grid-template-columns: 230px 1fr; gap: 20px; padding: 18px 22px 18px 16px; border-left: 10px solid var(--lv); }
.lv-row + .lv-row { border-top: 1px solid var(--line); }
.lv-main { display: flex; gap: 12px; align-items: center; }
.lv-main b { display: block; font-size: 17px; font-weight: 700; line-height: 1.35; }
.lv-main small { display: block; font-size: 12.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.lv-adv { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.lv-adv p { font-size: 14px; line-height: 1.65; }
.lv-adv b { display: block; font-size: 12px; font-weight: 600; color: var(--ink-3); margin-bottom: 2px; }
.masks { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.mask { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 18px; }
.mask.m3 { border: 2px solid var(--ok); }
.mask-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.mask-top b { font-size: 17px; font-weight: 700; }
.bars { display: inline-flex; gap: 3px; align-items: flex-end; }
.bars i { width: 7px; border-radius: 2px; background: var(--line-2); }
.bars i:nth-child(1) { height: 8px; } .bars i:nth-child(2) { height: 13px; } .bars i:nth-child(3) { height: 18px; }
.m3 .bars i { background: var(--ok); } .m2 .bars i:nth-child(-n+2) { background: var(--warn); } .m1 .bars i:first-child { background: var(--bad); }
.mask-tag { display: inline-block; margin-top: 4px; font-size: 12.5px; font-weight: 600; }
.m3 .mask-tag { color: var(--ok); } .m2 .mask-tag { color: var(--warn); } .m1 .mask-tag { color: var(--bad); }
html.dark .m3 .mask-tag { color: #4ade80; } html.dark .m2 .mask-tag { color: #fbbf24; } html.dark .m1 .mask-tag { color: #fca5a5; }
.mask p { margin-top: 8px; font-size: 14px; line-height: 1.65; color: var(--ink-2); }
.faq details { border-top: 1px solid var(--line); }
.faq details:last-child { border-bottom: 1px solid var(--line); }
.faq summary { cursor: pointer; list-style: none; display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 16px 0; font-size: 16px; font-weight: 600; line-height: 1.5; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary .ic { color: var(--ink-3); font-size: 12px; }
.faq details[open] summary .ic { transform: rotate(180deg); }
.faq p { padding-bottom: 18px; font-size: 15px; line-height: 1.8; color: var(--ink-2); max-width: 38em; }
.calls { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.calls a { display: grid; gap: 2px; align-content: start; padding: 16px 18px; border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line); color: inherit; text-decoration: none; }
.calls a:hover { border-color: var(--brand-2); }
.call-n { display: flex; align-items: center; gap: 8px; font-size: 32px; font-weight: 700; letter-spacing: -.5px; color: var(--brand); line-height: 1.2; font-variant-numeric: tabular-nums; }
.call-n .ic { font-size: 15px; }
.calls b { font-size: 14.5px; font-weight: 600; margin-top: 2px; }
.calls small { font-size: 12.5px; color: var(--ink-3); line-height: 1.5; }
.report-link { margin-top: 14px; }
.pollutants { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 32px; }
.pol { font-size: 14.5px; color: var(--ink-2); line-height: 1.65; padding-left: 14px; border-left: 3px solid var(--line-2); }
.pol b { display: block; color: var(--ink); font-size: 16px; font-weight: 700; }
.src-note { margin-top: 10px; font-size: 12.5px; color: var(--ink-3); }
.info-foot { margin-top: 44px; padding-top: 20px; border-top: 1px solid var(--line); font-size: 13px; line-height: 1.7; color: var(--ink-3); max-width: 46em; }

/* ---------- หน้าสถานะเครื่อง ---------- */
.diag-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(330px, 100%), 1fr)); gap: 12px; }
.diag { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-xl); padding: 18px 20px; }
.diag-top { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; }
.diag-top .grow { flex: 1; min-width: 0; }
.diag-top b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.diag-top small { color: var(--ink-3); font-size: 12px; }
.diag dl { margin: 0; display: grid; }
.diag dl div { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 8px; font-size: 13.5px; padding: 8px 0; border-top: 1px solid var(--line); }
.diag dt { color: var(--ink-2); display: flex; align-items: center; gap: 7px; }
.diag dt .ic { color: var(--ink-3); font-size: 12px; }
.diag dd { margin: 0; font-weight: 500; display: flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; }
.diag dd small { color: var(--ink-3); font-weight: 400; }
.status-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; background: #9ca3af; }
.status-dot.live { background: var(--ok); }
.status-dot.lost { background: var(--warn); } .status-dot.off { background: var(--bad); }
.pill.live { color: var(--ok); } .pill.lost { color: var(--warn); } .pill.off { color: var(--bad); }
.batt { width: 32px; height: 14px; border: 1.5px solid var(--ink-3); border-radius: 3px; padding: 1.5px; position: relative; }
.batt::after { content: ''; position: absolute; right: -4px; top: 3.5px; width: 2.5px; height: 5px; background: var(--ink-3); border-radius: 0 2px 2px 0; }
.batt i { display: block; height: 100%; border-radius: 1px; background: var(--ok); }
.batt.mid i { background: var(--warn); } .batt.low i { background: var(--bad); }

.toast { position: fixed; z-index: 2000; left: 50%; bottom: 40px; transform: translateX(-50%); background: var(--ink); color: var(--surface); padding: 10px 20px; border-radius: 99px; font-size: 13.5px; font-weight: 500; box-shadow: var(--shadow); }

/* ---------- จอเล็ก / มือถือ ---------- */
@media (max-width: 1280px) { .legend { display: none; } }
@media (max-width: 1100px) { .tabs .lbl { display: none; } .tabs button { padding: 10px 14px; } .tabs button.on .lbl { display: inline; } }
@media (max-width: 860px) {
  :root { --top: 56px; --panel: 0px; }
  .topbar { padding: 0 14px; }
  .tabs { position: fixed; left: 0; right: 0; bottom: 0; margin: 0; background: var(--surface); padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); justify-content: space-around; border-top: 1px solid var(--line); z-index: 1100; gap: 2px; }
  .tabs button, .tabs button:hover { flex-direction: column; gap: 3px; padding: 7px 4px 5px; font-size: 11.5px; color: var(--ink-3); background: none; flex: 1; border-radius: 12px; }
  .tabs .lbl, .tabs button.on .lbl { display: inline; }
  .tabs button.on, .tabs button.on:hover, html.dark .tabs button.on { background: var(--brand-soft); color: var(--brand); }
  .tabs .ic { font-size: 18px; }
  .tools { margin-left: auto; }
  .brand small { display: none; }
  .map-page, .page { bottom: calc(64px + env(safe-area-inset-bottom)); }
  .page { padding: 22px 16px 36px; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .kpi:nth-child(3) { border-left: 0; }
  .kpi:nth-child(n+3) { border-top: 1px solid var(--line); }
  .kpi b { font-size: 28px; }
  .page-head h1 { font-size: 24px; }

  .mode-switch { top: 10px; }
  .panel { top: auto; width: auto; right: 0; max-height: 68%; border-right: 0; border-top: 1px solid var(--line); border-radius: 22px 22px 0 0; box-shadow: 0 -6px 24px rgba(0,0,0,.10); }
  .panel.open { height: 68%; }
  .sheet-handle { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 8px 0; width: 100%; font-size: 13px; font-weight: 600; color: var(--ink-2); flex-shrink: 0; }
  .sheet-handle i { width: 38px; height: 4px; border-radius: 9px; background: var(--line-2); }
  .panel-scroll { padding: 4px 14px 18px; }
  /* ย่ออยู่: เหลือแค่ค่าฝุ่นตอนนี้ แตะเพื่อเปิดดูทั้งหมด */
  .panel:not(.open) .panel-scroll { overflow: hidden; padding-bottom: 0; flex: none; }
  .panel:not(.open) .panel-scroll > :not(.hero):not(.hero-empty), .panel:not(.open) .hero-body { display: none; }
  .panel:not(.open) .hero { border-radius: var(--r-xl) var(--r-xl) 0 0; border-bottom: 0; cursor: pointer; }
  .panel:not(.open) .hero-empty { margin-bottom: 14px; }
  .hero-num b { font-size: 60px; }
  .hero-lv { font-size: 20px; }
  .hero-face { width: 80px; height: 80px; }
  .fab.gps { bottom: 236px; }
  .fab.report { bottom: 294px; }
  .leaflet-bottom { bottom: 206px; }
  .toast { top: calc(var(--top) + 64px); bottom: auto; max-width: calc(100vw - 32px); text-align: center; }
  table.data th, table.data td { padding: 9px 11px; }
  .seg { padding: 8px 12px; }
  .seg .lbl, .seg:not(.fire) .ic { display: none; }

  .info-head h1 { font-size: 28px; }
  .info-head p { font-size: 16px; }
  .toc { flex-wrap: nowrap; overflow-x: auto; top: -22px; margin: 16px -16px 0; padding: 10px 16px; scrollbar-width: none; }
  .toc::-webkit-scrollbar { display: none; }
  .sec { padding-top: 32px; }
  .sec h2 { font-size: 22px; scroll-margin-top: 70px; }
  .split, .two, .icon-list, .pollutants, .lv-adv { grid-template-columns: 1fr; }
  .two { gap: 22px; }
  .facts { grid-template-columns: 1fr 1fr; gap: 18px 20px; }
  .lv-row { grid-template-columns: 1fr; gap: 12px; }
  .masks { grid-template-columns: 1fr; }
  .calls { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 420px) {
  .seg { padding: 8px 10px; font-size: 13px; }
  .wordmark { font-size: 19px; }
  .tabs button, .tabs button:hover { font-size: 11px; }
}
@media (max-width: 350px) {
  .hero-top { padding: 16px 16px 14px; }
  .hero-num b { font-size: 52px; }
  .hero-lv { font-size: 18px; }
  .hero-face { width: 64px; height: 64px; }
  .calls { grid-template-columns: 1fr; }
  .facts dt b { font-size: 32px; }
}
/* มือถือแนวนอน: จอเตี้ย ย่อแผงเหลือแค่แถบจับ ให้เห็นแผนที่ */
@media (max-width: 860px) and (max-height: 520px) {
  .panel:not(.open) .panel-scroll { display: none; }
  .panel.open { height: 86%; max-height: 86%; }
  .fab.gps { bottom: 64px; }
  .fab.report { bottom: 122px; }
  .leaflet-bottom { bottom: 50px; }
}
