/* water.css — หน้า /water (ทุกคลาสขึ้นต้น wt- กันชนของ global)
 * ⚠️ styles.css ตั้ง `button { background: var(--green); color:#fff; min-height:48px }` + hover เขียวทึบ
 *    ⇒ ปุ่มทุกแบบที่นี่ต้องประกาศ background/color/border/hover ของตัวเอง (frontend-conventions §39)
 * สี active = พิลเขียวอ่อน (#e4f1ec / ขอบ+ตัวหนังสือเขียว) ไม่ใช่พื้นทึบ (มติโอบ)
 */
.wt-shell { width: min(720px, 100%); padding: 12px 16px 40px; }
/* 🔴 `hidden` แพ้ display ของ author เสมอ (frontend-conventions §36) — .wt-stack/.wt-warn ตั้ง display:flex
   ⇒ ต้องบังคับให้ [hidden] ชนะทั้งหน้า ไม่งั้น 3 สถานะ (ขอตำแหน่ง/เลือกพื้นที่/ผล) โผล่ซ้อนกัน */
.wt-shell [hidden] { display: none !important; }
.wt-body .top-bar { justify-content: space-between; }

.wt-stack { display: flex; flex-direction: column; gap: 12px; }
.wt-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.wt-muted { color: var(--ink-secondary); font-size: .88rem; }
.wt-fine { color: var(--ink-secondary); font-size: .8rem; line-height: 1.55; margin: 4px 2px 0; }
.wt-note { color: var(--ink-secondary); font-size: .88rem; line-height: 1.55; margin: 0 2px; }
.wt-h2 { font-size: 1.15rem; font-weight: 700; margin: 0; line-height: 1.35; }
.wt-h3 { font-size: 1rem; font-weight: 700; margin: 18px 0 8px; }
.wt-h2row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.wt-section { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.wt-hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; width: 100%; }

.wt-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex; flex-direction: column; gap: 10px;
}
.wt-card.wt-soft { background: var(--green-soft); border-color: #c7e0d6; }
[data-theme="dark"] .wt-card.wt-soft { border-color: var(--line); }
.wt-small { gap: 8px; }

/* ── ปุ่ม/ชิป (กัน global button) ── */
.wt-btn, .wt-chip, .wt-tab, .wt-iconbtn, a.wt-btn {
  font: inherit; cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border-radius: 12px; transition: background .15s, border-color .15s;
}
.wt-btn, a.wt-btn {
  min-height: 48px; padding: 0 16px;
  background: var(--panel); color: var(--ink); border: 1px solid var(--line);
  font-weight: 600; font-size: 1rem;
}
.wt-btn-sm { min-height: 36px; padding: 0 12px; font-size: .88rem; border-radius: 10px; }
.wt-btn-primary { min-height: 52px; background: var(--panel); color: var(--green); border: 2px solid var(--green); font-weight: 700; font-size: 1.05rem; }
.wt-btn-soft { background: var(--green-soft); color: var(--green); border: 1px solid var(--green); }
.wt-btn-outline { background: var(--panel); color: var(--green); border: 1px solid var(--green); }
.wt-btn-danger { background: #FEE2E2; color: #991B1B; border: 1px solid #991B1B; font-weight: 700; }
.wt-btn[disabled] { opacity: .6; cursor: progress; }
@media (hover: hover) {
  .wt-btn:hover, a.wt-btn:hover { background: var(--paper); }
  .wt-btn-soft:hover { background: var(--green-soft); }
  .wt-btn-danger:hover { background: #FECACA; }
  .wt-chip:hover, .wt-tab:hover, .wt-iconbtn:hover { background: var(--paper); }
  .wt-chip[aria-pressed="true"]:hover, .wt-tab[aria-selected="true"]:hover { background: var(--green-soft); }
}
.wt-chip {
  min-height: 44px; padding: 0 14px; border-radius: 999px;
  background: var(--panel); color: var(--ink-secondary); border: 1px solid var(--line); font-weight: 600; font-size: .92rem;
}
.wt-chip[aria-pressed="true"] { background: var(--green-soft); color: var(--green); border-color: var(--green); }
.wt-iconbtn {
  min-height: 44px; min-width: 44px; padding: 0; border-radius: 12px;
  background: var(--panel); color: var(--green); border: 1px solid var(--line);
}

/* ── แท็บ ── */
.wt-tabs {
  display: flex; gap: 5px; overflow-x: auto; scrollbar-width: none;
  padding: 2px 0 10px; margin: -8px 0 6px;
}
.wt-tabs::-webkit-scrollbar { display: none; }
.wt-tab {
  flex: 1 0 auto; min-height: 44px; padding: 0 10px; border-radius: 999px; white-space: nowrap;
  background: var(--panel); color: var(--ink-secondary); border: 1px solid var(--line); font-weight: 500; font-size: .92rem;
}
.wt-tab[aria-selected="true"] { background: var(--green-soft); color: var(--green); border-color: var(--green); font-weight: 700; }
.wt-panel[hidden] { display: none !important; }

.wt-banner {
  display: flex; align-items: center; gap: 10px; justify-content: space-between;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; margin-bottom: 10px; font-size: .92rem;
}
.wt-banner[hidden] { display: none; }

/* ── ครั้งแรก ── */
.wt-hero { background: var(--green-soft); border-color: #c7e0d6; padding: 20px; gap: 12px; }
[data-theme="dark"] .wt-hero { border-color: var(--line); }
.wt-hero-icon { width: 56px; height: 56px; border-radius: 999px; background: var(--panel); color: var(--green); display: flex; align-items: center; justify-content: center; }
.wt-hero-title { font-size: 1.4rem; font-weight: 700; margin: 0; line-height: 1.3; }
.wt-hero-text { margin: 0; font-size: 1rem; line-height: 1.6; }
.wt-promises { list-style: none; margin: 0; padding: 0 4px; display: flex; flex-direction: column; gap: 8px; }
.wt-promises li { position: relative; padding-left: 28px; line-height: 1.5; color: var(--ink-secondary); font-size: .95rem; }
.wt-promises li::before { content: ""; position: absolute; left: 4px; top: 6px; width: 12px; height: 7px; border-left: 2.5px solid var(--green); border-bottom: 2.5px solid var(--green); transform: rotate(-45deg); }

.wt-warn { background: #FFFBEB; border: 1px solid #FCD34D; border-radius: 14px; padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; line-height: 1.5; color: #374151; }
.wt-help p, .wt-help ol { margin: 2px 0 0; }
.wt-help ol { padding-left: 1.25em; }
.wt-help li { margin: 4px 0; }
.wt-warn .wt-btn { margin-top: 8px; align-self: flex-start; }
.wt-warn strong { color: #92400E; }
[data-theme="dark"] .wt-warn { background: #2a2413; color: var(--ink); border-color: #6b5a1e; }
[data-theme="dark"] .wt-warn strong { color: #fcd34d; }
.wt-field { display: flex; flex-direction: column; gap: 6px; }
.wt-field span { color: var(--ink-secondary); font-size: .9rem; }
.wt-field input[type="search"] { min-height: 48px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); font-size: 1rem; }

/* ── ผลใกล้ฉัน ── */
.wt-place-row { display: flex; gap: 10px; align-items: flex-start; }
.wt-pin { width: 36px; height: 36px; flex: 0 0 auto; border-radius: 999px; background: #DBEAFE; color: #1D4ED8; display: flex; align-items: center; justify-content: center; }
.wt-place-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.wt-place-text strong { font-size: 1.05rem; line-height: 1.35; }
.wt-place .wt-row .wt-btn { flex: 1 1 140px; }
.wt-fetched { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--ink-secondary); font-size: .85rem; padding: 0 2px; }

.wt-verdict { gap: 8px; }
.wt-verdict[data-tone="red"] { background: #FEF2F2; border-color: #FCA5A5; }
.wt-verdict[data-tone="amber"] { background: #FFFBEB; border-color: #FCD34D; }
.wt-verdict[data-tone="ok"] { background: var(--panel); }
.wt-verdict[data-tone="unknown"] { background: #F3F4F6; border-color: #D1D5DB; }
[data-theme="dark"] .wt-verdict[data-tone="red"] { background: #2b1414; border-color: #7f1d1d; }
[data-theme="dark"] .wt-verdict[data-tone="amber"] { background: #2a2413; border-color: #6b5a1e; }
[data-theme="dark"] .wt-verdict[data-tone="unknown"] { background: var(--paper); border-color: var(--line); }
.wt-verdict-kicker { font-size: .82rem; font-weight: 600; color: var(--ink-secondary); }
.wt-verdict-head { font-size: 1.3rem; line-height: 1.35; }
.wt-verdict[data-tone="red"] .wt-verdict-head { color: #991B1B; }
.wt-verdict[data-tone="amber"] .wt-verdict-head { color: #92400E; }
[data-theme="dark"] .wt-verdict[data-tone="red"] .wt-verdict-head { color: #fca5a5; }
[data-theme="dark"] .wt-verdict[data-tone="amber"] .wt-verdict-head { color: #fcd34d; }
.wt-verdict-body { font-size: 1rem; line-height: 1.6; }
.wt-verdict-line { display: flex; flex-direction: column; gap: 2px; font-size: .95rem; line-height: 1.5; }
.wt-stamp { font-size: .82rem; font-weight: 600; color: var(--ink-secondary); }

.wt-map { width: 100%; height: 320px; border-radius: var(--radius); border: 1px solid var(--line); overflow: hidden; background: #EEF3EF; z-index: 0; }
.wt-map-tall { height: 420px; }
.wt-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .85rem; color: var(--ink-secondary); }
.wt-legend span { display: inline-flex; align-items: center; gap: 6px; }
.wt-dot { width: 11px; height: 11px; border-radius: 999px; display: inline-block; box-shadow: 0 0 0 1px rgba(17,24,39,.35); flex: 0 0 auto; }
.wt-dot.sq { border-radius: 3px; }

.wt-list { display: flex; flex-direction: column; gap: 8px; }
.wt-item {
  display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 10px 14px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px; color: var(--ink); text-align: left;
  font: inherit; width: 100%; box-sizing: border-box;
}
button.wt-item { cursor: pointer; font-weight: 400; }
a.wt-item { text-decoration: none; }
@media (hover: hover) { button.wt-item:hover, a.wt-item:hover { background: var(--paper); } }
.wt-item.is-stale { background: var(--paper); border-style: dashed; color: var(--ink-secondary); }
.wt-item-main { flex: 1 1 auto; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.wt-item-main strong { font-size: .98rem; line-height: 1.35; }
.wt-item-sub { font-size: .85rem; color: var(--ink-secondary); line-height: 1.45; }
.wt-item-time { font-size: .78rem; font-weight: 600; color: #166534; }
.wt-item.is-stale .wt-item-time { color: var(--ink-secondary); }
[data-theme="dark"] .wt-item-time { color: #6ee7b7; }
.wt-item-side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: 0 0 auto; text-align: right; }
.wt-dist { font-size: .88rem; font-weight: 600; color: var(--ink-secondary); }

.wt-badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .78rem; font-weight: 700; background: #E5E7EB; color: #374151; white-space: nowrap; }
.wt-badge[data-tone="red"], .wt-badge[data-tone="bad"] { background: #FEE2E2; color: #991B1B; }
.wt-badge[data-tone="blue"] { background: #E0E7FF; color: #1E3A8A; }
.wt-badge[data-tone="ok"], .wt-badge[data-tone="green"] { background: #DCFCE7; color: #166534; }
.wt-badge[data-tone="warn"], .wt-badge[data-tone="amber"] { background: #FEF3C7; color: #92400E; }
.wt-badges { display: flex; flex-wrap: wrap; gap: 6px; }
.wt-pill { font-size: .78rem; font-weight: 600; padding: 3px 10px; border-radius: 999px; background: var(--paper); color: var(--ink-secondary); white-space: nowrap; }
.wt-feedwarn { background: var(--paper); border: 1px dashed var(--ink-muted); border-radius: 14px; padding: 12px 14px; font-size: .92rem; line-height: 1.55; }
.wt-feedwarn[hidden] { display: none; }
.wt-soon p { margin: 0; line-height: 1.55; color: var(--ink-secondary); }

/* ── ภาพรวม ── */
.wt-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 10px 0; }
.wt-stat { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 12px; display: flex; flex-direction: column; gap: 2px; }
.wt-stat b { font-size: 1.5rem; line-height: 1.2; }
.wt-stat span { font-size: .85rem; color: var(--ink-secondary); line-height: 1.4; }
.wt-area { margin: 6px 0 10px; }

/* ── เขื่อน ── */
.wt-damtable { gap: 6px; padding: 12px; overflow-x: auto; }
.wt-damrow { display: grid; grid-template-columns: minmax(70px, 1fr) repeat(4, 56px); gap: 4px; align-items: center; min-height: 44px; }
.wt-damrow.head { min-height: 0; font-size: .75rem; font-weight: 600; color: var(--ink-secondary); padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.wt-damrow.head span { text-align: center; display: flex; flex-direction: column; align-items: center; line-height: 1.25; }
.wt-damrow.head b { font-size: .84rem; color: var(--ink); }
.wt-damrow.head small { font-size: .68rem; font-weight: 500; color: var(--ink-secondary); white-space: nowrap; }
.wt-damrow > strong { font-size: .92rem; line-height: 1.3; }
.wt-cell { height: 32px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: .82rem; font-weight: 700; }
.wt-bar { flex: 1 1 auto; height: 10px; border-radius: 999px; background: var(--paper); overflow: hidden; }
.wt-bar > i { display: block; height: 100%; border-radius: 999px; }
.wt-damitem { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 6px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; }
.wt-damitem .wt-rank { width: 22px; color: var(--ink-secondary); font-size: .82rem; flex: 0 0 auto; }
.wt-damitem .wt-dname { width: 128px; font-weight: 600; font-size: .9rem; flex: 0 0 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wt-damitem .wt-dpct { width: 52px; text-align: right; font-weight: 700; font-size: .9rem; flex: 0 0 auto; }

/* ── ลำน้ำ ── */
.wt-chain { display: flex; flex-direction: column; margin-top: 12px; }
.wt-node { display: flex; gap: 12px; }
.wt-rail { width: 20px; flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; }
.wt-rail i { width: 14px; height: 14px; margin-top: 18px; border-radius: 999px; border: 2px solid var(--panel); box-shadow: 0 0 0 1px rgba(17,24,39,.45); flex: 0 0 auto; }
.wt-rail b { width: 2px; flex: 1 1 auto; background: #C7D2E0; }
.wt-node:last-child .wt-rail b { background: transparent; }
.wt-node .wt-card { flex: 1 1 auto; margin-bottom: 10px; gap: 6px; padding: 12px 14px; min-width: 0; }
.wt-node button.wt-card { color: var(--ink); text-align: left; font-weight: 400; min-height: 0; width: 100%; cursor: pointer; }
@media (hover: hover) { .wt-node button.wt-card:hover { background: var(--paper); } }
.wt-node.hot .wt-card { background: #FFF5F5; border-color: #FCA5A5; }
[data-theme="dark"] .wt-node.hot .wt-card { background: #2b1414; border-color: #7f1d1d; }
.wt-node-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }

/* ── ช่วยเหลือ ── */
.wt-sos { background: #FFF5F5; border-color: #FCA5A5; }
[data-theme="dark"] .wt-sos { background: #2b1414; border-color: #7f1d1d; }
.wt-sos-row { display: flex; align-items: center; gap: 14px; line-height: 1.45; }
.wt-sos-num { font-size: 2.1rem; font-weight: 700; color: #991B1B; line-height: 1; }
[data-theme="dark"] .wt-sos-num { color: #fca5a5; }
.wt-tel, .wt-link {
  display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 10px 14px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px; color: var(--ink); text-decoration: none;
}
.wt-tel b { width: 58px; font-size: 1.3rem; flex: 0 0 auto; }
.wt-tel > span, .wt-link { flex-direction: row; }
.wt-tel > span { display: flex; flex-direction: column; gap: 2px; }
.wt-link { flex-direction: column; align-items: flex-start; justify-content: center; gap: 2px; }
@media (hover: hover) { .wt-tel:hover, .wt-link:hover { background: var(--paper); } }

/* ── แผ่นรายละเอียด ── */
.wt-sheet-back { position: fixed; inset: 0; background: rgba(17,24,39,.45); z-index: 900; }
.wt-sheet-back[hidden], .wt-sheet[hidden] { display: none; }
.wt-sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 901; max-height: 88vh; overflow-y: auto;
  width: min(720px, 100%); margin: 0 auto; box-sizing: border-box;
  background: var(--bg); border-radius: 20px 20px 0 0; padding: 16px 16px calc(24px + env(safe-area-inset-bottom));
  box-shadow: 0 -8px 32px rgba(17,24,39,.25);
}
.wt-sheet-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; margin-bottom: 12px; }
.wt-sheet-head > div { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.wt-gauge { position: relative; height: 34px; }
.wt-gauge-track { position: absolute; left: 0; right: 0; top: 11px; height: 12px; border-radius: 999px; overflow: hidden; display: flex; }
.wt-gauge-track i { display: block; height: 100%; }
.wt-gauge-mark { position: absolute; top: 0; width: 4px; height: 34px; margin-left: -2px; border-radius: 2px; background: var(--ink); }
.wt-kv { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.wt-kv b { font-size: 1.3rem; }
.wt-spark { width: 100%; height: 96px; }

.wt-footer { margin-top: 28px; padding-top: 16px; border-top: 1px solid var(--line); color: var(--ink-secondary); font-size: .82rem; line-height: 1.6; }
.wt-footer p { margin: 0 0 6px; }

/* marker ของ Leaflet */
.wt-mk { border-radius: 999px; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(17,24,39,.45); box-sizing: border-box; }
.wt-mk.sq { border-radius: 3px; }
.wt-me { width: 18px; height: 18px; border-radius: 999px; background: #2563EB; border: 3px solid #fff; box-shadow: 0 1px 4px rgba(17,24,39,.4); box-sizing: border-box; }
.wt-cam { width: 22px; height: 22px; border-radius: 6px; background: #3B6E9E; color: #fff; display: flex; align-items: center; justify-content: center; box-shadow: 0 0 0 1px rgba(17,24,39,.45); }
.leaflet-popup-content { font-family: inherit; font-size: .9rem; line-height: 1.5; margin: 10px 12px; }
.leaflet-popup-content b { display: block; }
