/* แมพน้ำท่วมกรุงเทพ
   ฉากใช้งาน: มือถือ กลางฝน ตอนกลางคืน คนรีบ อ่านสีหมุดให้รู้เรื่องใน 2 วินาที
   ทิศทาง: หน้าจอของหน่วยบรรเทาภัยที่เงียบและชัด สีมีไว้บอกระดับน้ำเท่านั้น ไม่ใช้ตกแต่ง */

:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --fg: #16202b;
  --muted: #56616f;
  --line: #dfe4ea;
  --primary: #0f5bd8;
  --primary-ink: #ffffff;
  --focus: #0f5bd8;
  --link: #0f5bd8;
  /* สเกลระดับน้ำ: เขียว → เหลือง → ส้ม → แดง → แดงเลือดหมู (อันตรายสุดต้องเข้มสุด) */
  --l0: #1f9d63;
  --l1: #e8b400;
  --l2: #f0850f;
  --l3: #dc3a2f;
  --l4: #8e1537;
  --lx: #7d8794;
  --cam: #1c2530;
  --route: #0f5bd8;
  --route-alt: #7d8794;
  --warn-bg: #fff4e2;
  --warn-fg: #6e3b00;
  --warn-line: #f5c98a;
  --shadow-1: 0 1px 2px rgba(16, 24, 32, .12), 0 4px 12px rgba(16, 24, 32, .10);
  --shadow-2: 0 -2px 6px rgba(16, 24, 32, .06), 0 -12px 32px rgba(16, 24, 32, .16);
  --radius: 14px;
  --ease: cubic-bezier(.16, 1, .3, 1);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #101418; --surface: #182029; --fg: #eef2f6; --muted: #a3adb9; --line: #2b3541;
    --primary: #2563eb; --focus: #8ab4ff; --link: #8ab4ff; --cam: #0b1015; --route: #5b9bff; --route-alt: #9aa4b1;
    --warn-bg: #33250f; --warn-fg: #ffd9a3; --warn-line: #6b4a1c;
    --shadow-1: 0 1px 2px rgba(0,0,0,.5), 0 4px 14px rgba(0,0,0,.45);
    --shadow-2: 0 -12px 32px rgba(0,0,0,.55);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overscroll-behavior: none; }
body {
  font-family: "IBM Plex Sans Thai Looped", system-ui, sans-serif;
  color: var(--fg); background: var(--bg); overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}
::selection { background: color-mix(in srgb, var(--primary) 28%, transparent); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 8px; }
a { color: var(--link); text-underline-offset: 3px; }
[tabindex="-1"]:focus { outline: none; }
#map { position: fixed; inset: 0; z-index: 0; background: #e9edf1; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) #map { background: #1a1f25; } }

.ic { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.ic.sm { width: 17px; height: 17px; }
.ic.xs { width: 13px; height: 13px; stroke-width: 2.2; }

/* ---------- ส่วนบน ---------- */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 900;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
  background: var(--bg);
  box-shadow: 0 1px 0 var(--line);
}
.brand { min-width: 0; flex: 1; }
/* line-height ต้องพอให้สระบน/วรรณยุกต์ไทย (้ ่ ็) ไม่ถูก overflow:hidden ตัดหัว (Santa เห็นบน iPhone 2026-09-27) */
.brand-title { margin: 0; font-size: 18px; font-weight: 700; line-height: 1.6; letter-spacing: -.005em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-top: 1px; }
/* หัวต้องสูงคงที่ ไม่งั้นแถบเตือนที่วางตำแหน่งตายตัวจะถูกบัง */
.brand-sub { margin: 0; font-size: 12.5px; color: var(--muted); line-height: 1.6; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.top-stack {
  position: fixed; z-index: 890; left: 12px; right: 12px;
  top: calc(env(safe-area-inset-top) + 72px);
  max-width: 560px; margin: 0 auto;
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px;
  pointer-events: none; /* ช่องว่างระหว่างแถบต้องแตะแมพทะลุได้ */
}
.top-stack > * { pointer-events: auto; }
body.navigating .top-stack { display: none !important; }
.notice {
  width: 100%;
  display: flex; align-items: center; gap: 8px;
  padding: 7px 8px 7px 11px; border-radius: 12px;
  background: var(--warn-bg); color: var(--warn-fg); border: 1px solid var(--warn-line);
  font-size: 12.5px; line-height: 1.45; box-shadow: var(--shadow-1);
}
.notice > span { flex: 1; }
.hotline {
  display: inline-flex; align-items: center; gap: 4px; flex: none;
  padding: 6px 10px; border-radius: 999px; min-height: 34px;
  background: var(--warn-fg); color: var(--warn-bg); font-weight: 700; font-size: 13.5px; text-decoration: none;
}

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--surface); color: var(--fg); cursor: pointer; box-shadow: var(--shadow-1);
  transition: transform .18s var(--ease);
}
.icon-btn:active { transform: scale(.94); }
.icon-btn.close { position: absolute; top: 12px; right: 12px; box-shadow: none; width: 40px; height: 40px; }
.icon-btn.busy .ic { animation: spin 1s linear infinite; }

.map-tools { position: fixed; right: 16px; bottom: calc(env(safe-area-inset-bottom) + 90px); z-index: 880; display: flex; flex-direction: column; gap: 10px; }
.top-actions { display: flex; align-items: center; gap: 8px; flex: none; }
/* จอแคบกว่า 430px (iPhone ทุกรุ่นแนวตั้ง): หัวแอปมีของ 4 ชิ้น ต้องย่อทุกชิ้นให้ชื่อแอปกับเวลาอัปเดตแสดงครบ
   ชื่อ 16px · ซ่อนคำ "เจ้าพระยา" เหลือ ~ 99% · ปุ่มกลม 40px · จำนวนรูป/กล้องซ่อน (ยังมีในหน้าชั้นข้อมูล) */
@media (max-width: 430px) {
  .topbar { gap: 8px; padding-left: 12px; padding-right: 12px; }
  .brand-title { font-size: 16px; }
  .brand-sub { font-size: 12px; }
  .sub-counts { display: none; }
  .top-actions { gap: 6px; }
  .topbar .icon-btn { width: 40px; height: 40px; }
  .river-chip { padding: 0 9px; height: 34px; }
  .river-chip .chip-word { display: none; }
}
.river-chip {
  display: inline-flex; align-items: center; gap: 5px; height: 36px; padding: 0 11px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--fg); font: inherit; font-size: 13px; font-weight: 600;
  font-variant-numeric: tabular-nums; cursor: pointer; white-space: nowrap;
}
.river-chip.hi { background: color-mix(in srgb, var(--l2) 16%, var(--surface)); border-color: color-mix(in srgb, var(--l2) 55%, var(--line)); }
.river-chip.over { background: color-mix(in srgb, var(--l3) 16%, var(--surface)); border-color: color-mix(in srgb, var(--l3) 60%, var(--line)); color: var(--l3); }
.toggles { display: grid; gap: 4px; margin: 0 0 8px; }
.toggle { display: flex; gap: 12px; align-items: flex-start; padding: 10px 2px; border-bottom: 1px solid var(--line); font-size: 14.5px; line-height: 1.5; cursor: pointer; }
.toggle:last-child { border-bottom: 0; }
.toggle input { width: 22px; height: 22px; margin: 1px 0 0; flex: none; accent-color: var(--primary); }
.toggle b { font-weight: 600; margin-right: 6px; }
.river-list { list-style: none; margin: 4px 0 8px; padding: 0; }
.river-list li { padding: 11px 0; border-bottom: 1px solid var(--line); }
.river-list li:last-child { border-bottom: 0; }
.river-row { display: flex; align-items: baseline; gap: 10px; }
.river-row b { flex: 1; font-size: 15px; font-weight: 600; }
.river-pct { font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; }
.river-bar { height: 6px; border-radius: 3px; background: color-mix(in srgb, var(--line) 70%, transparent); margin: 7px 0 5px; overflow: hidden; }
.river-bar > i { display: block; height: 100%; border-radius: 3px; }
.river-meta { font-size: 13px; color: var(--muted); line-height: 1.5; }
/* ป้ายระดับน้ำคลอง/แม่น้ำ: สีน้ำเงิน → เหลือง → ส้ม → แดง ตามความใกล้ล้นตลิ่ง */
.wl-pill, .rain-pill {
  display: inline-flex; align-items: center; justify-content: center; min-width: 38px; height: 22px; padding: 0 6px;
  border-radius: 7px; border: 2px solid #fff; color: #fff; font-size: 11.5px; font-weight: 700; font-style: normal;
  font-variant-numeric: tabular-nums; box-shadow: 0 1px 2px rgba(0,0,0,.25), 0 2px 6px rgba(0,0,0,.2); white-space: nowrap;
}
.wl-pill.w0 { background: #1a73e8; } .wl-pill.w1 { background: #d9a400; } .wl-pill.w2 { background: var(--l2); } .wl-pill.w3 { background: var(--l3); }
.wl-pill.stale { background: var(--lx); }
.rain-pill { background: #e8f1fe; color: #0b4db8; border-color: #9cc3fb; border-radius: 999px; min-width: 30px; }
.rain-pill.r1 { background: #b9d5fc; } .rain-pill.r2 { background: #5f9df7; color: #fff; border-color: #fff; } .rain-pill.r3 { background: #1c5fd6; color: #fff; border-color: #fff; }
.mini { transform: scale(.92); flex: none; }
.pin.road { border-radius: 9px; font-size: 13px; width: auto; min-width: 44px; height: 30px; padding: 0 6px; gap: 1px; }
.pin.road small { font-size: 9.5px; font-weight: 600; opacity: .9; }
.legend-road { flex: none; transform: scale(.85); }
.sensor-dot { width: 12px; height: 12px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); flex: none; display: inline-block; }
.sensor-dot.dry { background: var(--l0); }
.sensor-dot.wet1 { background: var(--l1); }
.sensor-dot.stale { background: #b0b6be; }
/* คลอง: สีคนละชุดกับระดับน้ำบนถนน เพื่อไม่ให้สับสนว่าเป็นน้ำท่วมถนน */
:root { --c-ok: #4a90e2; --c-warn: #e8b400; --c-crit: #f0850f; --c-over: #dc3a2f; --c-na: #b0b6be; }
.canal-dot { width: 12px; height: 12px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); display: inline-block; flex: none; }
.canal-dot.c-ok { background: var(--c-ok); } .canal-dot.c-warn { background: var(--c-warn); }
.canal-dot.c-crit { background: var(--c-crit); } .canal-dot.c-over { background: var(--c-over); } .canal-dot.c-na { background: var(--c-na); }
.dots { display: inline-flex; gap: 5px; flex: none; }

.actions {
  position: fixed; left: 12px; right: 12px; bottom: calc(env(safe-area-inset-bottom) + 18px); z-index: 900;
  display: flex; gap: 10px; justify-content: center;
}
.fab {
  flex: 1 1 0; max-width: 240px; min-width: 0;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; white-space: nowrap;
  padding: 0 14px; height: 56px; border: 0; border-radius: 999px;
  background: var(--primary); color: var(--primary-ink); font: inherit; font-weight: 600; font-size: 16.5px;
  box-shadow: 0 2px 4px rgba(15, 91, 216, .25), 0 10px 26px rgba(15, 91, 216, .35); cursor: pointer;
  outline-offset: 3px;
  transition: transform .2s var(--ease), box-shadow .2s var(--ease);
}
.fab:active { transform: scale(.97); }
.fab.secondary { background: var(--surface); color: var(--fg); border: 1px solid var(--line); box-shadow: var(--shadow-1); }

/* โหมดเลือกจุดบนแมพ: หมุดค้างกลางจอ + แถบยืนยันด้านล่าง */
.center-pin {
  position: fixed; left: 50%; top: 50%; z-index: 955; width: 44px; height: 44px;
  transform: translate(-50%, -100%); pointer-events: none;
  filter: drop-shadow(0 3px 4px rgba(0,0,0,.35));
}
.center-pin svg { width: 100%; height: 100%; fill: #ea4335; stroke: #ffffff; stroke-width: 1.4; }
.center-pin circle { fill: #ffffff; stroke: none; }
.center-pin::after { /* จุดเล็กตรงปลายหมุด บอกตำแหน่งที่จะถูกเลือกจริง */
  content: ''; position: absolute; left: 50%; bottom: -3px; width: 6px; height: 6px; margin-left: -3px;
  border-radius: 50%; background: rgba(0,0,0,.35);
}
.pickbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 960; max-width: 560px; margin: 0 auto;
  padding: 14px 16px calc(env(safe-area-inset-bottom) + 16px); border-radius: 18px 18px 0 0;
  background: var(--surface); box-shadow: var(--shadow-2);
}
.pickbar p { margin: 0 0 12px; font-size: 16px; font-weight: 600; line-height: 1.5; text-align: center; }
.pickbar .row .btn.ghost { margin-top: 0; }
.link-row { display: flex; flex-wrap: wrap; gap: 4px 18px; margin-top: 4px; }
.btn-link {
  display: inline-flex; align-items: center; gap: 6px; background: none; border: 0; padding: 8px 2px; min-height: 40px;
  color: var(--link); font: inherit; font-size: 14.5px; font-weight: 600; cursor: pointer; text-decoration: underline; text-underline-offset: 3px;
}

/* ฟอร์มเส้นทาง */
.field { margin: 0 0 14px; }
.field-label { display: block; font-size: 14px; font-weight: 600; color: var(--muted); margin: 0 0 6px; }
.field-note { margin: 6px 0 0; font-size: 13.5px; color: var(--muted); line-height: 1.5; }
.field-note.ok { color: var(--l0); }
.field-note.bad { color: var(--l3); }
.seg { display: flex; gap: 6px; padding: 4px; border-radius: 14px; background: color-mix(in srgb, var(--line) 55%, transparent); }
.seg-btn {
  flex: 1; min-height: 42px; border: 0; border-radius: 10px; background: transparent; color: var(--fg);
  font: inherit; font-size: 14.5px; font-weight: 500; cursor: pointer;
}
.seg-btn.on { background: var(--surface); font-weight: 700; box-shadow: 0 1px 2px rgba(0,0,0,.12), 0 2px 6px rgba(0,0,0,.08); }
.search { display: flex; align-items: center; gap: 8px; padding: 0 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); min-height: 48px; }
.search:focus-within { border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 25%, transparent); }
.search .ic { color: var(--muted); }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--fg); font: inherit; font-size: 16px; padding: 12px 0; }
.results { list-style: none; margin: 6px 0 0; padding: 4px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); max-height: 240px; overflow-y: auto; }
.results button { display: block; width: 100%; text-align: left; border: 0; background: none; color: var(--fg); font: inherit; padding: 10px; border-radius: 8px; cursor: pointer; line-height: 1.45; }
.results button:hover, .results button:focus-visible { background: color-mix(in srgb, var(--line) 50%, transparent); }
.results small { display: block; color: var(--muted); font-size: 12.5px; }
.route-card { border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; margin: 0 0 10px; }
.route-card.best { border-color: color-mix(in srgb, var(--primary) 45%, var(--line)); background: color-mix(in srgb, var(--primary) 6%, var(--surface)); }
.route-card p { margin: 6px 0 0; font-size: 14.5px; line-height: 1.55; }
.route-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 15.5px; }
.route-line span { color: var(--muted); font-size: 14px; margin-left: auto; font-variant-numeric: tabular-nums; }
.swatch { display: inline-block; width: 26px; height: 6px; border-radius: 3px; flex: none; }
.swatch.best { background: var(--route); }
.toll-row { margin: 12px 0 0; }
.toll-tag { display: inline-block; margin: 8px 0 0 !important; padding: 3px 10px; border-radius: 999px; background: #fff3cd; color: #6e4b00; font-size: 13px !important; font-weight: 600; }
.route-card.suggest { border-color: var(--warn-line); background: var(--warn-bg); color: var(--warn-fg); }
.route-card.suggest .btn { margin-top: 10px; min-height: 46px; }
#btnUseNormal { margin-top: 10px; min-height: 44px; }
/* สรุปโซน: ประโยคเดียวตัวใหญ่บอกคำตอบก่อน แล้วค่อยรายการหลักฐาน แตะได้ทุกข้อ */
.zone-head { font-size: 18px; font-weight: 700; line-height: 1.45; margin: 12px 0 4px; }
/* ข้อความต้อนรับ: รายการสั้น ตัวหนาคือใจความ อ่านจบใน 30 วิ */
.welcome-list { list-style: none; margin: 0 0 14px; padding: 0; }
.welcome-list li { padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 15px; line-height: 1.55; }
.welcome-list li:last-child { border-bottom: 0; }
.welcome-list b { display: block; }
.help-box { margin: 14px 0 6px; padding: 12px 14px; border-radius: 12px; background: color-mix(in srgb, var(--line) 35%, transparent); }
.help-box b { display: block; margin-bottom: 4px; }
.help-box p { margin: 0 0 6px; }
/* ป้ายโซนลอยใต้แถบเตือน: บอกว่ากำลังดูโซนไหน และล้างได้โดยไม่ต้องเปิดแผ่น */
.zone-chip { display: inline-flex; align-items: stretch; border-radius: 999px; background: var(--surface); box-shadow: var(--shadow-1); overflow: hidden; }
.zone-chip button { border: 0; background: none; font: inherit; color: var(--fg); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.zone-chip-name { padding: 8px 6px 8px 12px; font-weight: 600; font-size: 14px; max-width: 60vw; }
.zone-chip-name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.zone-chip-x { padding: 8px 12px 8px 8px; border-left: 1px solid var(--line) !important; color: var(--muted); }
.zone-chip-x:hover, .zone-chip-x:focus-visible { color: var(--fg); }
#btnZoneClear { margin-top: 8px; }
.zone-head.wet { color: var(--l3); }
.zone-head.dry { color: var(--l0); }
.zone-list { list-style: none; margin: 8px 0 14px; padding: 0; }
.zone-list li { border-bottom: 1px solid var(--line); }
.zone-list button { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; border: 0; background: none; color: var(--fg); font: inherit; padding: 11px 4px; cursor: pointer; line-height: 1.45; }
.zone-list button:hover, .zone-list button:focus-visible { background: color-mix(in srgb, var(--line) 50%, transparent); border-radius: 8px; }
.zone-list .dot { width: 14px; height: 14px; }
.zone-list small { display: block; color: var(--muted); font-size: 13px; }
/* ขั้นตอนทางเลี้ยว: ตัวเลขลำดับใหญ่ อ่านทีละบรรทัดได้ขณะจอดข้างทาง */
.steps { list-style: none; margin: 4px 0 12px; padding: 0; counter-reset: step; }
.steps li { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 15.5px; line-height: 1.5; }
.steps li::before { counter-increment: step; content: counter(step); flex: none; width: 28px; height: 28px; border-radius: 50%; background: var(--primary); color: var(--primary-ink); font-weight: 700; font-size: 14px; display: flex; align-items: center; justify-content: center; }
.steps li b { display: block; }
.steps li small { color: var(--muted); font-size: 13.5px; }
.steps li.warn b { color: var(--l3); }

/* ---------- หน้าจอนำทางในแอป ---------- */
.nav-top {
  position: fixed; z-index: 970; left: 10px; right: 10px; top: calc(env(safe-area-inset-top) + 8px);
  max-width: 560px; margin: 0 auto; display: flex; align-items: center; gap: 14px;
  padding: 14px 16px; border-radius: 16px; background: #0b5a3a; color: #fff; box-shadow: var(--shadow-1);
}
.nav-arrow { width: 52px; height: 52px; flex: none; display: flex; align-items: center; justify-content: center; }
.nav-arrow .ic { width: 46px; height: 46px; stroke-width: 2.6; transition: transform .25s var(--ease); }
.nav-dist { font-size: 24px; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.nav-instr { font-size: 16.5px; font-weight: 500; line-height: 1.4; }
.nav-warn {
  position: fixed; z-index: 969; left: 10px; right: 10px; top: calc(env(safe-area-inset-top) + 104px);
  max-width: 560px; margin: 0 auto; padding: 10px 14px; border-radius: 12px;
  background: var(--l3); color: #fff; font-weight: 600; font-size: 15px; line-height: 1.45; box-shadow: var(--shadow-1);
}
.nav-bottom {
  position: fixed; z-index: 970; left: 0; right: 0; bottom: 0; max-width: 560px; margin: 0 auto;
  display: flex; align-items: center; gap: 10px; padding: 12px 16px calc(env(safe-area-inset-bottom) + 14px);
  background: var(--surface); border-radius: 18px 18px 0 0; box-shadow: var(--shadow-2);
}
.nav-remain { flex: 1; display: flex; flex-direction: column; }
.nav-remain b { font-size: 20px; font-variant-numeric: tabular-nums; }
.nav-remain span { font-size: 14px; color: var(--muted); }
.nav-bottom .icon-btn { box-shadow: none; }
.btn.nav-end { width: auto; min-width: 72px; background: #d93025; border-color: #d93025; color: #fff; }
body.navigating .topbar, body.navigating .actions, body.navigating .map-tools,
body.navigating .empty, body.navigating .maplibregl-ctrl-bottom-left { display: none !important; }
.swatch.flood { height: 7px; background: linear-gradient(90deg, var(--l1) 0 25%, var(--l2) 25% 50%, var(--l3) 50% 75%, var(--l4) 75%); }
.legend-lead { margin: -4px 0 10px; font-size: 15px; line-height: 1.55; }
.stepbox { margin: 0 0 12px; }
/* ขอความร่วมมือ + วิธีถ่าย: ถูกสีเขียว ไม่ควรสีแดง อ่านจบในไม่กี่วินาที */
.ask { font-size: 15px; line-height: 1.6; margin: 0 0 10px; }
.tips { margin: 0 0 14px; padding: 12px 14px; border-radius: 12px; background: color-mix(in srgb, var(--line) 35%, transparent); }
.tips-title { font-weight: 700; font-size: 14.5px; margin-bottom: 6px; }
.tips-list { list-style: none; margin: 0; padding: 0; }
.tips-list li { display: flex; gap: 8px; align-items: flex-start; padding: 5px 0; font-size: 14px; line-height: 1.55; }
.tips-list li .ic { flex: none; margin-top: 3px; stroke-width: 2.6; }
.tips-list li.do .ic { color: var(--l0); }
.tips-list li.dont .ic { color: var(--l3); }
.step-title { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15.5px; margin: 14px 0 8px; }
.step-no { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 50%; background: var(--primary); color: #fff; font-size: 13px; flex: none; }
.stepbox .gps { margin: 0 0 8px; }
.stepbox .btn { margin-bottom: 4px; }
.loc-help { margin: 8px 0 4px; padding: 10px 12px; border-radius: 10px; background: var(--warn-bg); color: var(--warn-fg); border: 1px solid var(--warn-line); font-size: 14px; line-height: 1.65; }
.center-note { text-align: center; margin: 8px 0 0 !important; font-size: 13px !important; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.swatch.normal { background: repeating-linear-gradient(90deg, var(--route-alt) 0 6px, transparent 6px 10px); }
a.btn { text-decoration: none; margin-bottom: 8px; }
.route-end { width: 22px; height: 22px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); background: var(--fg); border: 3px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.35); }
.route-start { width: 18px; height: 18px; border-radius: 50%; background: #fff; border: 5px solid var(--fg); box-shadow: 0 2px 6px rgba(0,0,0,.3); }
.dot.ring { background: transparent !important; box-shadow: inset 0 0 0 4px var(--l3); }
.pin.event { width: 22px; height: 22px; border-width: 2px; background: var(--surface) !important; box-shadow: inset 0 0 0 5px var(--ev), 0 2px 6px rgba(0,0,0,.25); }

.empty {
  cursor: pointer;
  /* ใต้แถบเตือน ไม่ทับปุ่มซูมและปุ่มตำแหน่งที่อยู่ด้านล่าง */
  position: fixed; left: 12px; right: 12px; top: calc(env(safe-area-inset-top) + 132px); z-index: 860;
  max-width: 560px; margin: 0 auto; padding: 9px 12px; border-radius: 12px;
  background: var(--surface); color: var(--fg); box-shadow: var(--shadow-1); font-size: 13px; line-height: 1.5; text-align: center;
}
@media (min-width: 900px) { .empty { left: 16px; right: auto; margin: 0; top: calc(env(safe-area-inset-top) + 124px); } }

/* ---------- หมุด ---------- */
.pin {
  width: 34px; height: 34px; border-radius: 50%; border: 3px solid #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,.25), 0 3px 8px rgba(0,0,0,.25);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 13px; font-variant-numeric: tabular-nums;
}
.pin.cluster { font-size: 14px; }
.pin.l1 { color: #2b2100; }
.pin.cam { position: relative; border-radius: 10px; background: var(--cam); color: #fff; }
.cam-dot { position: absolute; top: -5px; right: -5px; width: 13px; height: 13px; border-radius: 50%; border: 2px solid #fff; }
.me { width: 20px; height: 20px; border-radius: 50%; background: #1a73e8; border: 3px solid #fff; box-shadow: 0 0 0 7px rgba(26,115,232,.22), 0 2px 6px rgba(0,0,0,.3); }
.l0 { background: var(--l0); } .l1 { background: var(--l1); } .l2 { background: var(--l2); }
.l3 { background: var(--l3); } .l4 { background: var(--l4); } .lx { background: var(--lx); }
.cam { background: var(--cam); }

/* ---------- bottom sheet ---------- */
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 950;
  max-width: 560px; margin: 0 auto;
  background: var(--surface); border-radius: 20px 20px 0 0; box-shadow: var(--shadow-2);
  padding: 6px 18px calc(env(safe-area-inset-bottom) + 16px);
  max-height: 78vh; overflow-y: auto; overscroll-behavior: contain;
  animation: rise .32s var(--ease);
}
.sheet.compact { max-height: 42vh; }
.sheet.compact h2 { font-size: 16px; margin-bottom: 8px; }
@keyframes rise { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .sheet, .modal-card { animation: none !important; } }
.sheet-handle { width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: 6px auto 14px; }
/* ปุ่มปิดติดหัวแผ่นตลอด ไม่ต้องเลื่อนลงไปหาปุ่มล่างสุด (margin ติดลบ = ไม่ดันเนื้อหาลง หัวข้อเว้นขวาไว้แล้ว) */
.sheet > .icon-btn.close { position: sticky; top: 4px; right: auto; display: flex; margin: -24px 0 -40px auto; z-index: 2; background: var(--surface); box-shadow: 0 0 0 4px var(--surface); }
/* ระหว่างปัดลง: ตามนิ้วทันที ไม่หน่วงด้วย transition */
/* ห้ามแตะ animation ตอนลาก: ถ้าปิดแล้วเปิดกลับ ท่าเปิด (rise) จะเล่นซ้ำตอนปล่อยนิ้ว = อาการกระตุกที่ Santa เจอ */
.sheet.dragging, .modal-card.dragging { transition: none !important; }
.sheet.settling, .modal-card.settling { transition: transform .22s var(--ease); }
/* ปิดทุกแบบ (X, แตะข้างนอก, ปุ่มปิด) ให้เลื่อนลงนุ่ม ๆ เหมือนตอนปัด ไม่หายวับ */
.sheet.closing, .modal.closing .modal-card { transform: translateY(105%) !important; transition: transform .2s var(--ease); pointer-events: none; }
.modal.closing { opacity: 0; transition: opacity .2s var(--ease); pointer-events: none; }
@media (prefers-reduced-motion: reduce) { .sheet.closing, .modal.closing, .modal.closing .modal-card { transition: none; } }
.sheet h2, .modal h2 { font-size: 18px; line-height: 1.45; margin: 0 0 12px; padding-right: 44px; }
.legend-list { list-style: none; padding: 0; margin: 0 0 10px; }
.legend-list li { display: flex; align-items: center; gap: 12px; padding: 7px 0; font-size: 15px; line-height: 1.5; }
.legend-list b { font-weight: 600; margin-right: 6px; }
.dot { width: 20px; height: 20px; border-radius: 50%; flex: none; display: inline-flex; align-items: center; justify-content: center; color: #fff; box-shadow: inset 0 0 0 2px rgba(255,255,255,.55); }
.dot.cam { border-radius: 6px; }
.dot.old { width: 14px; height: 14px; opacity: .45; }
.muted { color: var(--muted); font-size: 13.5px; line-height: 1.6; }

.detail-head { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; margin: 2px 0 6px; }
.badge { display: inline-flex; align-items: center; padding: 5px 12px; border-radius: 999px; color: #fff; font-weight: 700; font-size: 14px; line-height: 1.3; }
.badge.l1 { color: #2b2100; }
.badge.big { font-size: 17px; padding: 8px 16px; margin-bottom: 10px; }
.detail-advice { margin: 4px 0 2px; font-size: 17px; font-weight: 600; line-height: 1.5; }
.detail-summary { margin: 0 0 4px; color: var(--muted); font-size: 14.5px; line-height: 1.6; }
.strip { display: flex; gap: 10px; overflow-x: auto; padding: 10px 0 12px; scroll-snap-type: x mandatory; scrollbar-width: thin; }
.strip figure { flex: none; width: min(78vw, 300px); margin: 0; scroll-snap-align: start; }
.strip img { display: block; width: 100%; height: auto; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 12px; background: var(--line); }
.strip figcaption { font-size: 12.5px; color: var(--muted); margin-top: 6px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.strip .flag { color: var(--muted); background: none; border: 1px solid var(--line); border-radius: 999px; font: inherit; font-size: 12px; padding: 4px 10px; min-height: 32px; cursor: pointer; }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; z-index: 1000; background: rgba(8, 12, 16, .52); display: flex; align-items: flex-end; justify-content: center; }
#privacy { z-index: 1010; }
.modal-card {
  position: relative; width: 100%; max-width: 520px; max-height: 94vh; overflow-y: auto; overscroll-behavior: contain;
  /* iOS ที่แถบเบราว์เซอร์ค้าง: 94vh สูงกว่าจอจริง การ์ดล้นขึ้นบนจนปุ่ม X หาย ใช้ dvh เมื่อรองรับ */
  max-height: min(94vh, calc(100dvh - env(safe-area-inset-top) - 12px));
  background: var(--surface); border-radius: 20px 20px 0 0; padding: 20px 18px calc(env(safe-area-inset-bottom) + 20px);
  animation: rise .32s var(--ease);
}
@media (min-width: 640px) { .modal { align-items: center; } .modal-card { border-radius: 20px; } }
.modal-card p { font-size: 15px; line-height: 1.65; margin: 0 0 12px; }
/* ปุ่มปิดของโมดัลติดหัวการ์ดตอนเลื่อนอ่าน เหมือนแผ่นล่าง */
.modal-card > .icon-btn.close { position: sticky; top: 0; right: auto; display: flex; margin: -8px 0 -32px auto; z-index: 2; background: var(--surface); box-shadow: 0 0 0 4px var(--surface); }
/* แถบข้อมูลเก่า */
.stale-bar { width: 100%; padding: 9px 12px; border-radius: 12px; background: #d93025; color: #fff; font-weight: 600; font-size: 14px; line-height: 1.45; box-shadow: var(--shadow-1); }
/* ตัวอักษรบนสีส้ม/เหลืองต้องเป็นสีเข้ม (ขาวบน #f0850f ได้แค่ ~2.6:1 อ่านยากกลางแดด) */
.badge.l2, .pill-l2, .wl-pill.w1, .wl-pill.w2 { color: #2b1500; }
.warn { background: var(--warn-bg); color: var(--warn-fg); border: 1px solid var(--warn-line); padding: 10px 12px; border-radius: 12px; margin: 0 0 12px; font-size: 14.5px; line-height: 1.6; }
.gps { font-size: 14px; color: var(--muted); padding: 8px 12px; border-radius: 10px; background: color-mix(in srgb, var(--line) 45%, transparent); }
.gps.ok { color: var(--l0); background: color-mix(in srgb, var(--l0) 12%, transparent); }
.gps.bad { color: var(--l3); background: color-mix(in srgb, var(--l3) 10%, transparent); }
.check { display: flex; gap: 12px; align-items: flex-start; font-size: 14.5px; line-height: 1.6; margin: 14px 0 16px; cursor: pointer; }
.check input { width: 24px; height: 24px; flex: none; margin: 1px 0 0; accent-color: var(--primary); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: 52px; padding: 12px 16px; border-radius: 14px; border: 1px solid var(--line);
  background: var(--surface); color: var(--fg); font: inherit; font-size: 16px; font-weight: 600; cursor: pointer;
  transition: transform .18s var(--ease), opacity .18s;
}
.btn:active { transform: scale(.985); }
.btn.primary { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.btn.primary:disabled { opacity: .4; cursor: not-allowed; }
.btn.ghost { margin-top: 8px; }
.row { display: flex; gap: 10px; }
.row .btn.ghost { margin-top: 0; }
.when { border: 0; padding: 0; margin: 4px 0 12px; }
.when legend { font-weight: 600; padding: 0; margin-bottom: 8px; }
.when-opts { display: flex; gap: 8px; }
.when-opts .btn { min-height: 44px; padding: 8px 6px; font-size: 15px; }
.when-opts .btn[aria-pressed="true"] { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.credits { margin: 10px 0 14px; }
.credits summary { cursor: pointer; font-weight: 600; padding: 6px 0; }
.credits ul { padding-left: 18px; margin: 6px 0 0; }
.credits li { margin-bottom: 6px; font-size: 14px; line-height: 1.6; }
.warn-note { background: var(--warn-bg); color: var(--warn-fg); border: 1px solid var(--warn-line); border-radius: 12px; padding: 10px 12px; font-size: 15px; }
.preview img { display: block; width: 100%; max-height: 52vh; object-fit: contain; border-radius: 12px; background: var(--line); }
.center { text-align: center; padding: 18px 0 8px; }
.spinner { width: 40px; height: 40px; border: 4px solid var(--line); border-top-color: var(--primary); border-radius: 50%; margin: 8px auto 14px; animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.prose p { font-size: 14.5px; line-height: 1.7; margin: 0 0 10px; }
.prose a { word-break: break-all; }

.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 94px); transform: translateX(-50%);
  z-index: 1100; background: var(--fg); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px;
  max-width: calc(100vw - 32px); text-align: center; box-shadow: var(--shadow-1);
}
[hidden] { display: none !important; }

/* เดสก์ท็อป: ปุ่มหลักไปมุมขวา แถบเตือนไม่ยืดเต็มจอ */
/* จอมือถือแคบ: ชื่อเว็บต้องเห็นเต็ม ตัดไอคอนคลื่นในป้ายเจ้าพระยาออกแทน */
@media (max-width: 420px) { .river-chip { padding: 0 10px; } .river-chip .ic { display: none; } .brand-title { font-size: 17px; } }
@media (max-width: 350px) { .river-chip { display: none !important; } }
@media (min-width: 900px) {
  .actions { left: auto; right: 24px; width: 460px; }
  .notice { left: 16px; right: auto; margin: 0; }
  .map-tools { bottom: calc(env(safe-area-inset-bottom) + 96px); right: 24px; }
}

/* ---------- ควบคุมของ MapLibre ให้เข้าชุดกับหน้า ---------- */
.maplibregl-ctrl-bottom-left { bottom: calc(env(safe-area-inset-bottom) + 86px); left: 6px; }
.maplibregl-ctrl-group { border-radius: 12px !important; box-shadow: var(--shadow-1) !important; overflow: hidden; }
.maplibregl-ctrl-group button { width: 40px !important; height: 40px !important; }
.maplibregl-ctrl-bottom-right { bottom: calc(env(safe-area-inset-bottom) + 84px); right: 4px; }
.maplibregl-ctrl-attrib { font-size: 10px; }
.maplibregl-ctrl-attrib.maplibregl-compact { margin: 0 6px 4px 0; }
/* มือถือจอสัมผัส: ซูมด้วยนิ้วอยู่แล้ว ไม่ต้องมีปุ่ม +/- เกะกะ (แบบแอป Google Maps) */
@media (hover: none) and (pointer: coarse) { .maplibregl-ctrl-bottom-left { display: none; } }
/* ปุ่มและแผ่นทั้งหมด: แตะแล้วตอบทันที ไม่รอเช็คดับเบิลแตะ */
button, a, input, label, .sheet, .modal-card { touch-action: manipulation; }

/* แมพเปิดไม่ได้ (ไม่มี WebGL / CDN ล่ม) */
.map-fail { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center; padding: 24px; font-size: 17px; line-height: 1.6; color: var(--fg); }
.map-fail a { font-weight: 700; }
