:root {
  --ink: #13222E; --muted: #51606C; --line: #E3E7EA; --ground: #F2F4F5; --card: #FFFFFF;
  --accent: #0B6E6E; --accent-dark: #084F50; --accent-soft: #DDEDED; --border: #D5DBDF;
  color-scheme: light;
  font-size: 15px;
}
:root[data-fs="1"] { font-size: 17px; }
:root[data-fs="2"] { font-size: 19px; }

* { box-sizing: border-box; }
/* class ที่ตั้ง display เองจะทับ [hidden] ของเบราว์เซอร์ — บังคับให้ซ่อนจริง */
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--ground); color: var(--ink); }
body { font-family: 'IBM Plex Sans Thai', system-ui, sans-serif; line-height: 1.5; }
h1, h2, .num { font-family: 'Anuphan', 'IBM Plex Sans Thai', sans-serif; }
a { color: var(--accent); }
a:hover { color: var(--accent-dark); }
button { font: inherit; color: inherit; cursor: pointer; }

.app { max-width: 480px; margin: 0 auto; min-height: 100vh; padding-bottom: calc(84px + env(safe-area-inset-bottom)); }

/* แถวแบรนด์ (mockup v2 แบบ A) */
.brand-row { padding: 14px 16px 0; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.brand { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; text-decoration: none; }
.brand img { display: block; border-radius: 7px; }
.brand span { font-family: 'Anuphan', sans-serif; font-size: 1.47rem; font-weight: 700; color: #084F50; letter-spacing: .2px; line-height: 1.35; }

.top { padding: 10px 16px 12px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.top-right { display: flex; align-items: center; gap: 8px; }
.pill { display: flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 12px; border: 1px solid var(--border); border-radius: 22px; background: var(--card); font-weight: 600; min-width: 0; }
.pill span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mode { text-decoration: none; display: flex; align-items: center; min-height: 44px; padding: 0 12px; border-radius: 22px; background: var(--accent-soft); color: var(--accent-dark); font-size: .87rem; font-weight: 600; white-space: nowrap; }
.icon-btn { width: 44px; height: 44px; border: 1px solid var(--border); border-radius: 22px; background: var(--card); font-weight: 700; flex-shrink: 0; }
.icon-btn small { font-size: .7em; }
.bell { position: relative; display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.bell-dot { position: absolute; top: 9px; right: 10px; width: 10px; height: 10px; border-radius: 5px; background: #D9480F; border: 2px solid #fff; }

main > * { margin: 14px 16px 0; }
main > .summary { margin-top: 4px; }

.banner { padding: 10px 14px; border-radius: 12px; background: #FFF4D6; border: 1px solid #F0D58A; color: #5C4300; font-size: .93rem; }

/* ระดับความรุนแรง: 0 ข้อมูล · 1 ปกติ · 2 ระวัง · 3 อันตราย */
.summary { padding: 18px; border-radius: 18px; border: 1px solid; }
.lv-0 { background: #EEF1F3; border-color: var(--border); --lv-text: #26343F; --lv-badge: #51606C; }
.lv-1 { background: #E5F4E8; border-color: #A9D9B4; --lv-text: #123F1E; --lv-badge: #1E6B32; }
.lv-2 { background: #FFE6CC; border-color: #F5C089; --lv-text: #4A2400; --lv-badge: #8A4300; }
.lv-3 { background: #FDE0DE; border-color: #F2A9A3; --lv-text: #5C120E; --lv-badge: #A3211A; }
.summary-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.badge { padding: 2px 10px; border-radius: 12px; background: var(--lv-badge); color: #fff; font-size: .87rem; font-weight: 600; }
.updated { font-size: .87rem; color: var(--lv-text); opacity: .85; }
.summary h1 { margin: 10px 0 0; font-size: 1.53rem; line-height: 1.35; font-weight: 700; color: var(--lv-text); }
.advice { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; color: var(--lv-text); }
.advice div { display: flex; gap: 8px; align-items: flex-start; }
.advice svg { flex-shrink: 0; margin-top: 2px; stroke: var(--lv-badge); }

.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.card, .box { padding: 14px; border-radius: 16px; background: var(--card); border: 1px solid var(--line); }
.card .t { display: flex; align-items: center; gap: 6px; font-size: .87rem; color: var(--muted); }
.card .t svg { flex-shrink: 0; }
.card .v { margin-top: 6px; display: flex; align-items: baseline; gap: 4px; flex-wrap: wrap; }
.card .num { font-size: 2.13rem; font-weight: 700; line-height: 1; }
.card .unit { font-size: .87rem; color: var(--muted); }
.card .lab { margin-top: 8px; display: flex; align-items: center; gap: 6px; font-weight: 600; font-size: .93rem; }
.dot { width: 10px; height: 10px; border-radius: 5px; flex-shrink: 0; box-shadow: inset 0 0 0 1px rgba(0,0,0,.12); }
.card .extra { margin-top: 6px; font-size: .87rem; font-weight: 600; color: var(--ink); }
.src { margin-top: 6px; font-size: .8rem; color: var(--muted); }
.far { color: #8A4300; font-weight: 600; }
.near-note { margin: -4px 16px 0; font-size: .8rem; color: var(--muted); }
.src.stale { color: #8A4300; font-weight: 600; }
.card.empty .num { color: #9AA5AD; }

.dam-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.dam-box .t { display: flex; align-items: center; gap: 6px; font-size: .87rem; color: var(--muted); }
.dam-row { margin-top: 6px; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.dam-row b { font-size: 1.07rem; }
.dam-row .num { font-family: 'Anuphan', sans-serif; font-size: 1.6rem; font-weight: 700; line-height: 1; }
.dam-box .lab { margin-top: 4px; display: flex; align-items: center; gap: 6px; font-weight: 600; font-size: .93rem; }
.dam-box .unit { font-weight: 400; font-size: .8rem; color: var(--muted); }
.st-badge { flex-shrink: 0; padding: 2px 10px; border-radius: 12px; font-size: .87rem; font-weight: 600; }
.st-badge.lv-0 { background: #EEF1F3; color: #51606C; }
.st-badge.lv-1 { background: #E5F4E8; color: #1E6B32; }
.st-badge.lv-2 { background: #FFE6CC; color: #8A4300; }
.st-badge.lv-3 { background: #FDE0DE; color: #A3211A; }

.quake-box { display: flex; align-items: flex-start; gap: 10px; font-size: .93rem; }
.quake-box svg { flex-shrink: 0; margin-top: 2px; }

.box h2 { margin: 0; font-size: 1.13rem; font-weight: 700; }
.hourly { margin-top: 12px; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 4px; text-align: center; font-size: .87rem; }
.hourly div { display: flex; flex-direction: column; gap: 4px; }
.hourly .h { color: var(--muted); }
.hourly .tp { font-weight: 600; font-size: 1.07rem; }
.hourly .rc { color: #1D4F9E; }
.hourly .rc.hi { font-weight: 600; }

.disclaimer { font-size: .8rem; color: var(--muted); }
.disclaimer b:first-child { color: var(--accent-dark); }

.nav { position: fixed; left: 0; right: 0; bottom: 0; background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.nav { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); max-width: 480px; margin: 0 auto; }
.nav a, .nav button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 68px; text-decoration: none; color: var(--muted); font-size: .8rem; background: none; border: 0; }
.nav svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.nav .active { color: var(--accent); font-weight: 600; }

.sheet { border: 0; border-radius: 18px; padding: 20px; width: min(420px, calc(100% - 32px)); color: var(--ink); }
.sheet::backdrop { background: rgba(19, 34, 46, .45); }
.sheet h2 { margin: 0 0 14px; font-size: 1.2rem; }
.sheet form { display: flex; flex-direction: column; gap: 10px; }
.primary { min-height: 48px; border: 0; border-radius: 12px; background: var(--accent); color: #fff; font-weight: 600; }
.ghost { min-height: 44px; border: 1px solid var(--border); border-radius: 12px; background: var(--card); }
.hint { margin: 0; font-size: .8rem; color: var(--muted); }
.presets { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.presets button { min-height: 44px; border: 1px solid var(--border); border-radius: 12px; background: var(--ground); }

/* ค้นหาอำเภอ/จังหวัด (ใช้ทั้งหน้าแรกและแผนที่) */
.place-results { display: flex; flex-direction: column; gap: 6px; }
.place-results button { min-height: 44px; padding: 0 12px; text-align: left; border: 1px solid var(--border); border-radius: 12px; background: var(--card); }
.place-results .hint { padding: 4px 6px; }
.place-results button small { color: var(--muted); font-size: .8em; margin-left: 4px; }
.place-results .more { border-style: dashed; color: var(--accent-dark); font-weight: 600; }
.osm-credit { font-size: .75rem; }
.search-input { min-height: 48px; padding: 0 14px; border: 1px solid var(--border); border-radius: 12px; font: inherit; }

/* หน้าข้อมูลฉุกเฉิน */
.page > * { margin: 14px 16px 0; }
.page-title { margin-top: 4px; font-size: 1.47rem; }
.hotlines { margin-top: 10px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.hotlines a { display: flex; flex-direction: column; min-height: 64px; padding: 10px 12px; border-radius: 12px; background: var(--ground); border: 1px solid var(--line); text-decoration: none; color: var(--ink); }
.hotlines b { font-family: 'Anuphan', sans-serif; font-size: 1.4rem; color: #A3211A; line-height: 1.2; }
.hotlines span { font-size: .8rem; color: var(--muted); }
.guide summary { cursor: pointer; list-style: none; display: flex; justify-content: space-between; align-items: center; min-height: 32px; }
.guide summary::after { content: '▾'; color: var(--muted); }
.guide[open] summary::after { content: '▴'; }
.guide summary::-webkit-details-marker { display: none; }
.guide ul { margin: 8px 0 0; padding-left: 1.2em; display: flex; flex-direction: column; gap: 6px; }
.guide .when { margin: 12px 0 0; font-weight: 600; color: var(--accent-dark); }
.links { margin: 8px 0 0; padding-left: 1.2em; display: flex; flex-direction: column; gap: 6px; }
.emergency-link { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; border-radius: 14px; background: #FDE0DE; color: #A3211A; font-weight: 600; text-decoration: none; border: 1px solid #F2A9A3; }

/* หน้า "ฉัน" */
.options { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.option { display: flex; align-items: flex-start; gap: 10px; padding: 12px; min-height: 44px; border: 1px solid var(--border); border-radius: 12px; cursor: pointer; }
.option.selected { border-color: var(--accent); background: var(--accent-soft); }
.option input { margin-top: 4px; accent-color: var(--accent); }
.option span { display: flex; flex-direction: column; }
.option small { color: var(--muted); }
.segmented { margin-top: 10px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.seg { display: flex; align-items: center; justify-content: center; min-height: 48px; border: 1px solid var(--border); border-radius: 12px; cursor: pointer; font-weight: 600; }
.seg.selected { border-color: var(--accent); background: var(--accent); color: #fff; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.places { margin: 10px 0 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; }
.places li { display: flex; gap: 6px; }
.place-use { flex: 1; min-height: 44px; padding: 0 12px; text-align: left; border: 1px solid var(--border); border-radius: 12px; background: var(--card); }
.place-use small { color: var(--accent); }
.place-del { width: 44px; min-height: 44px; border: 1px solid var(--border); border-radius: 12px; background: var(--card); color: var(--muted); font-size: 1.2rem; }
.add-place { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.ghost.danger { margin-top: 12px; width: 100%; color: #A3211A; border-color: #F2A9A3; }
button:disabled { opacity: .5; cursor: not-allowed; }

/* หน้าเกี่ยวกับ */
.about p { line-height: 1.6; }
.facts { margin: 10px 0 0; display: grid; grid-template-columns: max-content 1fr; gap: 6px 12px; font-size: .93rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.purpose { margin: 10px 0 0; padding-left: 1.3em; display: flex; flex-direction: column; gap: 8px; line-height: 1.55; }
.credits { width: 100%; margin-top: 10px; border-collapse: collapse; font-size: .87rem; }
.credits th, .credits td { padding: 8px 4px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.credits th { color: var(--muted); font-weight: 600; }

/* หน้าปลายทาง */
.dest-current { margin: 10px 0 0; }
.days { margin-top: 10px; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.day { display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 72px; padding: 6px 2px; border: 1px solid var(--border); border-radius: 12px; background: var(--card); font-size: .75rem; }
.day b { font-size: 1rem; }
.day small { color: #1D4F9E; }
.day.selected { border-color: var(--accent); background: var(--accent-soft); }
.day-facts { margin: 10px 0 0; display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; color: var(--lv-text); font-size: .93rem; }
.day-facts dt { opacity: .8; }
.day-facts dd { margin: 0; font-weight: 600; }
.now-list { margin-top: 10px; display: flex; flex-direction: column; gap: 10px; }
.now-head { margin: 0; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.now-item { display: flex; gap: 10px; align-items: flex-start; font-size: .93rem; }
.now-item .st-badge { min-width: 56px; text-align: center; }

/* หน้าแจ้งเตือน */
.alert-list { margin-top: 10px; display: flex; flex-direction: column; gap: 10px; }
.alert-item { display: flex; gap: 10px; align-items: flex-start; font-size: .93rem; color: var(--ink); text-decoration: none; }
.alert-item .st-badge { min-width: 56px; text-align: center; }
.ok-line { margin: 8px 0 0; color: #1E6B32; font-weight: 600; }
.warn-line { margin: 8px 0 0; color: #8A4300; font-weight: 600; }
.steps { margin: 8px 0 0; padding-left: 1.3em; line-height: 1.7; }
.push-actions { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 8px; }
.push-actions .primary { padding: 0 18px; }
.push-actions .ghost { padding: 0 14px; }
.push-actions .ghost.danger { width: auto; margin: 0; }
.topics { margin-top: 10px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.topic { display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 12px; border: 1px solid var(--border); border-radius: 12px; }
.topic input, #quiet { accent-color: var(--accent); width: 18px; height: 18px; }
#quietRow { margin-top: 10px; }

.toast { position: fixed; left: 50%; bottom: calc(92px + env(safe-area-inset-bottom)); transform: translateX(-50%); width: max-content; max-width: calc(100% - 32px); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: .93rem; z-index: 10; }

.skeleton .num, .skeleton .lab { color: transparent; background: #E8ECEE; border-radius: 6px; }

button:focus-visible, a:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
@media (max-width: 360px) { .mode { display: none; } }
