/* ===== น้ำไทย FLOOD WATCH — control-room dark theme ===== */
:root {
  --ink-0: #070d18;
  --ink-1: #0b1220;
  --ink-2: #111b2e;
  --ink-3: #1a2740;
  --line: rgba(146, 180, 230, .16);
  --line-strong: rgba(146, 180, 230, .32);
  --text: #e8eef9;
  --text-2: #c7d4ea;
  --text-3: #93a4c2;
  --accent: #4fd1ff;
  --accent-2: #7cf2ff;
  --glass: rgba(11, 18, 32, .9);
  --glass-2: rgba(17, 27, 46, .94);
  --shadow: 0 18px 50px rgba(0, 0, 0, .45), 0 1px 0 rgba(255,255,255,.04) inset;

  /* water-level status palette (validated on #0b1220) */
  --l0: #4b5568;   /* ไม่มีข้อมูล */
  --l1: #9c5a17;   /* น้ำน้อยวิกฤต */
  --l2: #c4983f;   /* น้ำน้อย */
  --l3: #1fa39b;   /* ปกติ */
  --l4: #e07b2a;   /* น้ำมาก */
  --l5: #e03a5e;   /* ล้นตลิ่ง */

  --font-display: "Chakra Petch", "Bai Jamjuree", sans-serif;
  --font-body: "Bai Jamjuree", "Chakra Petch", sans-serif;
  --r: 14px;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
/* lock the page to the viewport so swiping/panning the map can't scroll or rubber-band the page
   (which was making the top/bottom bars drift off-screen on phones) */
html { overflow: hidden; overscroll-behavior: none; }
body {
  font-family: var(--font-body);
  color: var(--text);
  background: var(--ink-0);
  position: fixed; inset: 0; width: 100%; height: 100%;
  overflow: hidden; overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
}
#map { position: absolute; inset: 0; background: var(--ink-0); touch-action: none; }
/* let panels scroll internally without chaining the gesture back to the (locked) page */
.legend-body, .drawer, .search-results, .header-right { overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
/* bars/panels allow pan + tap but NOT pinch-zoom, so pinching on them never zooms the page (only the map zooms) */
.hud, .hud-top, .dock, .legend, .legend-tab, .header-right, .status { touch-action: manipulation; }
.grain {
  pointer-events: none; position: absolute; inset: 0; z-index: 2; opacity: .35; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 .18 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

/* ===== shared HUD panel ===== */
.hud {
  position: absolute; z-index: 10;
  background: var(--glass);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
}
.hud::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: linear-gradient(180deg, rgba(255,255,255,.05), transparent 40%);
}

/* ===== header ===== */
.hud-top {
  top: 14px; left: 14px; right: 14px;
  display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 18px;
  padding: 0;
  background: transparent; border: 0; box-shadow: none; backdrop-filter: none; -webkit-backdrop-filter: none;
  animation: drop .6s cubic-bezier(.2,.8,.2,1) both;
}
.hud-top::before { display: none; }
/* make free-standing text on the map legible without a bar behind it */
.brand h1, .brand-sub { text-shadow: 0 1px 3px rgba(0,0,0,.85), 0 0 2px rgba(0,0,0,.7); }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px; flex: none;
  background:
    radial-gradient(circle at 30% 30%, var(--accent-2), transparent 55%),
    linear-gradient(160deg, #0d5c8f, #062c4a);
  box-shadow: 0 0 0 1px rgba(124,242,255,.35), 0 0 24px rgba(79,209,255,.35);
  position: relative; overflow: hidden;
}
.brand-mark::after {
  content: ""; position: absolute; left: -10%; right: -10%; height: 40%; bottom: -8%;
  background: rgba(124,242,255,.45); border-radius: 50% 50% 0 0 / 100% 100% 0 0;
  animation: wave 3s ease-in-out infinite;
}
.brand h1 {
  margin: 0; font-family: var(--font-display); font-weight: 700; font-size: 19px; letter-spacing: .01em; line-height: 1.05;
}
.brand h1 span { color: var(--accent); font-size: 12px; letter-spacing: .22em; margin-left: 6px; }
.brand-sub { margin: 2px 0 0; font-size: 11.5px; color: var(--text-2); }

.tiles { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.tile {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  min-width: 92px; padding: 6px 12px; border-radius: 10px;
  background: rgba(11,18,32,.82); border: 1px solid var(--line-strong);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 4px 14px rgba(0,0,0,.35);
  transition: transform .25s;
}
.tile-n { font-family: var(--font-display); font-weight: 700; font-size: 22px; line-height: 1; font-variant-numeric: tabular-nums; }
.tile-l { font-size: 11.5px; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.tile.bump { transform: translateY(-2px); }

.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; box-shadow: 0 0 0 2px rgba(255,255,255,.08); }
.dot.l1 { background: var(--l1); } .dot.l2 { background: var(--l2); } .dot.l3 { background: var(--l3); }
.dot.l4 { background: var(--l4); } .dot.l5 { background: var(--l5); } .dot.l0 { background: var(--l0); }

.header-right { display: flex; align-items: center; gap: 10px; justify-content: flex-end; }
.visits { display: flex; align-items: center; gap: 9px; padding: 5px 11px; border: 1px solid var(--line-2); border-radius: 10px; background: var(--glass); backdrop-filter: blur(10px) saturate(140%); -webkit-backdrop-filter: blur(10px) saturate(140%); white-space: nowrap; box-shadow: var(--shadow); }
.visits .visits-ico { width: 17px; height: 17px; color: var(--accent); flex: none; }
.visits .visits-col { display: flex; flex-direction: column; line-height: 1.05; }
.visits .visits-col b { font-family: var(--font-display); font-weight: 700; font-size: 14px; color: var(--text); font-variant-numeric: tabular-nums; }
.visits .visits-col small { font-size: 9px; color: var(--text-3); letter-spacing: .02em; margin-top: 1px; }
.visits .visits-sep { width: 1px; height: 22px; background: var(--line-2); flex: none; }
@media (max-width: 1100px) { .visits .visits-col small { display: none; } }
.search { position: relative; }
.search input {
  width: 260px; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--line-strong);
  background: rgba(11,18,32,.82); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  color: var(--text); font: inherit; font-size: 13px; outline: none; box-shadow: 0 4px 14px rgba(0,0,0,.35);
}
.search input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(79,209,255,.18); }
.search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; margin: 0; padding: 6px; list-style: none;
  background: var(--glass-2); border: 1px solid var(--line-strong); border-radius: 10px; box-shadow: var(--shadow);
  max-height: 320px; overflow: auto; z-index: 20;
}
.search-results { overflow-x: hidden; }
.search-results li { padding: 8px 10px; border-radius: 7px; cursor: pointer; font-size: 13px; display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; gap: 8px; align-items: center; }
.search-results li .nm { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-results li:hover { background: var(--ink-3); }
.search-results li small { color: var(--text-3); white-space: nowrap; max-width: 120px; overflow: hidden; text-overflow: ellipsis; font-size: 11px; }

.seg {
  font: inherit; font-size: 12.5px; font-weight: 600; color: var(--text);
  background: rgba(11,18,32,.82); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--line-strong); padding: 8px 12px; cursor: pointer; box-shadow: 0 4px 14px rgba(0,0,0,.35);
  transition: background .2s, color .2s;
}
.seg:first-child { border-radius: 10px 0 0 10px; } .seg:last-child { border-radius: 0 10px 10px 0; margin-left: -1px; }
.seg.on { background: linear-gradient(180deg, #0f4f78, #0b3a5a); color: #dff7ff; border-color: rgba(79,209,255,.6); }
.basemap, .mode { display: flex; }

/* ===== status ===== */
.status {
  position: absolute; z-index: 30; top: 86px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px; padding: 8px 14px; border-radius: 999px;
  background: var(--glass-2); border: 1px solid var(--line-strong); font-size: 13px; color: var(--text-2);
  transition: opacity .4s;
}
.status[hidden] { display: none; }
.spinner { width: 14px; height: 14px; border-radius: 50%; border: 2px solid rgba(79,209,255,.25); border-top-color: var(--accent); animation: spin .9s linear infinite; }

/* ===== legend ===== */
.legend { left: 14px; bottom: calc(var(--dock-h, 130px) + 26px); padding: 0; width: 320px; max-height: calc(100vh - var(--dock-h, 130px) - var(--head-h, 70px) - 56px); display: flex; flex-direction: column; transition: transform .32s cubic-bezier(.2,.8,.2,1), opacity .25s; }
/* auto-tuck to the left; a small tab stays at the screen edge and reveals the panel on hover */
.legend.tucked { transform: translateX(calc(-100% - 18px)); opacity: 0; pointer-events: none; }
.legend-tab {
  position: absolute; left: 0; bottom: calc(var(--dock-h, 130px) + 26px); z-index: 9;
  writing-mode: vertical-rl; text-orientation: mixed;
  display: inline-flex; align-items: center; gap: 8px; padding: 14px 8px; cursor: pointer;
  background: var(--glass); backdrop-filter: blur(14px) saturate(140%); -webkit-backdrop-filter: blur(14px) saturate(140%);
  border: 1px solid var(--line); border-left: 0; border-radius: 0 12px 12px 0; box-shadow: var(--shadow);
  color: var(--text); font-family: var(--font-display); font-weight: 600; font-size: 12px; letter-spacing: .12em;
  opacity: 0; transform: translateX(-100%); pointer-events: none;
  transition: opacity .25s, transform .25s, color .2s, border-color .2s;
}
.legend-tab.show { opacity: 1; transform: translateX(0); pointer-events: auto; }
.legend-tab:hover { color: var(--accent); border-color: var(--line-strong); }
.legend-tab .chev { font-size: 14px; color: var(--accent); }
.legend-title { font-family: var(--font-display); font-weight: 600; font-size: 12px; letter-spacing: .12em; color: var(--text-3); text-transform: uppercase; margin-bottom: 8px; }
.legend-head { display: flex; justify-content: space-between; align-items: center; width: 100%; padding: 10px 14px; border: 0; background: transparent; color: var(--text); font: inherit; font-family: var(--font-display); font-weight: 600; font-size: 13px; letter-spacing: .08em; cursor: pointer; border-bottom: 1px solid var(--line); position: relative; }
.legend-head .chev { transition: transform .25s; color: var(--text-3); }
.legend.collapsed .legend-head .chev { transform: rotate(180deg); }
.legend.collapsed .legend-body { display: none; }
.legend-body { padding: 10px 14px 12px; overflow: auto; }
.legend ul.lv { list-style: none; margin: 0; padding: 0; display: grid; gap: 5px; }
.legend ul.lv li { font-size: 13px; }
.legend ul.lv li label { display: flex; align-items: center; gap: 7px; width: 100%; cursor: pointer; }
.legend ul.lv li label > input { flex: none; margin: 0; }
.legend ul.lv li label .dot { flex: none; }
.legend ul.lv li label b { flex: none; white-space: nowrap; font-weight: 600; }
.legend ul.lv li label .lv-sub { flex: 1 1 auto; min-width: 0; color: var(--text-3); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.legend ul.lv li label .lv-n { flex: none; margin-left: auto; padding-left: 6px; color: var(--text-2); font-weight: 600; font-variant-numeric: tabular-nums; font-size: 12px; }
.legend .sub { margin: 6px 0 4px 22px; display: grid; gap: 6px; }
.legend select { width: 100%; font: inherit; font-size: 12px; color: var(--text); background: var(--ink-2); border: 1px solid var(--line-strong); border-radius: 7px; padding: 5px 8px; }
.legend .hint { font-size: 10.5px; color: var(--text-3); line-height: 1.35; }
.legend .hint.warn { color: #f2b23a; }
.legend .hint.ok { color: var(--accent); }
.legend .hint code { font-family: ui-monospace, monospace; font-size: 10px; }
.gistda-legend { display: grid; gap: 3px; }
.gistda-legend div { display: flex; align-items: center; gap: 6px; font-size: 10.5px; color: var(--text-2); }
.gistda-legend img { width: 18px; height: 12px; border-radius: 3px; object-fit: cover; background: #fff; }
.opacity { display: flex; align-items: center; gap: 8px; margin: 8px 0 0; font-size: 11.5px; color: var(--text-2); }
.opacity input { flex: 1; accent-color: var(--accent); }
.legend-toggle { display: flex; gap: 8px; align-items: center; margin-top: 10px; font-size: 12.5px; color: var(--text-2); cursor: pointer; }
.legend-toggle input { accent-color: var(--accent); }
.legend-title-2 { margin-top: 12px; }
.legend-toggle + .legend-toggle { margin-top: 6px; }
.depth { list-style: none; margin: 6px 0 0 22px; padding: 0; display: flex; gap: 8px; flex-wrap: wrap; }
.depth li { display: flex; align-items: center; gap: 4px; font-size: 10.5px; color: var(--text-3); }
.depth li i { width: 14px; height: 10px; border-radius: 3px; display: inline-block; }
.dem-status { display: block; margin: 4px 0 0 22px; font-size: 10.5px; color: var(--accent-2); min-height: 12px; }
.legend-note { margin: 8px 0 0; font-size: 11px; color: var(--text-2); line-height: 1.4; }

/* ===== timeline dock ===== */
.dock {
  left: 14px; right: 14px; bottom: 14px; padding: 8px 14px 6px; overflow: hidden;
  animation: rise .6s .25s cubic-bezier(.2,.8,.2,1) both;
}
.dock-head { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; }
.readout { display: flex; align-items: baseline; gap: 10px; justify-content: center; min-width: 0; }
.readout-tag {
  font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-0);
  background: var(--accent); padding: 2px 7px; border-radius: 5px; font-weight: 600; white-space: nowrap;
}
.readout-tag.future { background: #f2b23a; }
.readout-time { font-family: var(--font-display); font-weight: 600; font-size: 17px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.readout-sub { font-size: 11px; color: var(--text-3); white-space: nowrap; display: none; }
.dock-actions { display: flex; align-items: center; gap: 6px; }
.play {
  width: 32px; height: 32px; border-radius: 50%; border: 1px solid rgba(79,209,255,.6); cursor: pointer;
  background: linear-gradient(180deg, #0f4f78, #0b3a5a); color: #dff7ff; display: grid; place-items: center;
  transition: transform .15s;
}
.play:hover { transform: scale(1.06); }
.play .ico-pause { display: none; } .play.playing .ico-pause { display: block; } .play.playing .ico-play { display: none; }
.dock-toggle {
  width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--line-strong); background: var(--ink-2);
  color: var(--text-2); cursor: pointer; display: grid; place-items: center; font-size: 16px; line-height: 1;
}
.dock-toggle .chev { display: inline-block; transition: transform .25s; transform: translateY(-2px); }
.dock.collapsed .dock-toggle .chev { transform: rotate(180deg) translateY(-1px); }
.mode .seg { padding: 6px 10px; font-size: 12px; }

.slider-wrap { position: relative; margin: 4px 2px 0; }
#slider { width: 100%; margin: 0; appearance: none; -webkit-appearance: none; height: 22px; background: transparent; cursor: pointer; }
#slider::-webkit-slider-runnable-track {
  height: 5px; border-radius: 3px;
  background: linear-gradient(90deg, var(--accent) 0, var(--accent) var(--fill, 0%), var(--ink-3) var(--fill, 0%));
}
#slider::-webkit-slider-thumb {
  appearance: none; -webkit-appearance: none; width: 18px; height: 18px; margin-top: -6.5px; border-radius: 50%;
  background: #fff; border: 3px solid var(--accent); box-shadow: 0 0 0 5px rgba(79,209,255,.16), 0 3px 10px rgba(0,0,0,.5);
}
#slider::-moz-range-track { height: 5px; border-radius: 3px; background: var(--ink-3); }
#slider::-moz-range-progress { height: 5px; border-radius: 3px; background: var(--accent); }
#slider::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: #fff; border: 3px solid var(--accent); }
.ticks { display: flex; justify-content: space-between; margin-top: -2px; padding: 0 7px; }
.ticks span { font-size: 10px; line-height: 1.25; color: var(--text-3); font-variant-numeric: tabular-nums; position: relative; }
.ticks span::before { content: ""; position: absolute; left: 50%; top: -6px; width: 1px; height: 4px; background: var(--line-strong); }

/* collapsed: only tag + time (+ play / expand) and a hairline progress */
.dock-progress { display: none; height: 2px; margin: 6px -14px -6px; background: var(--ink-3); }
.dock-progress i { display: block; height: 100%; width: var(--fill, 0%); background: var(--accent); transition: width .15s; }
.dock.collapsed { padding: 6px 14px 6px; }
.dock.collapsed .slider-wrap, .dock.collapsed .mode { display: none; }
.dock.collapsed .dock-head { grid-template-columns: 1fr auto; }
.dock.collapsed .readout { justify-content: flex-start; }
.dock.collapsed .readout-sub { display: inline; }
.dock.collapsed .dock-progress { display: block; }

/* ===== drawer ===== */
.drawer {
  top: calc(var(--head-h, 70px) + 24px); right: 14px; bottom: calc(var(--dock-h, 130px) + 26px); width: 360px; padding: 18px 18px 14px; overflow: auto;
  animation: slide .35s cubic-bezier(.2,.8,.2,1) both;
}
.drawer[hidden] { display: none; }
.drawer-close { position: absolute; top: 10px; right: 10px; width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--line); background: var(--ink-2); color: var(--text-2); font-size: 18px; cursor: pointer; }
.drawer-kicker { font-family: var(--font-display); font-size: 11px; letter-spacing: .18em; text-transform: uppercase; color: var(--accent); }
.drawer h2 { margin: 4px 36px 2px 0; font-family: var(--font-display); font-weight: 700; font-size: 22px; line-height: 1.15; }
.drawer-where { margin: 0 0 14px; color: var(--text-2); font-size: 13px; }
.drawer-now { background: var(--ink-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.now-grid { display: grid; grid-template-columns: 72px 1fr; gap: 12px; align-items: center; }
.gauge-wrap { width: 72px; height: 84px; }
.gauge { width: 100%; height: 100%; display: block; }
.bank-label { font-size: 12px; color: var(--text-2); margin-bottom: 2px; }
.big { display: flex; align-items: baseline; gap: 4px; flex-wrap: wrap; }
.big-n.over { color: var(--l5); }
.kv dd small { color: var(--text-3); font-size: 10px; }
.big-n { font-family: var(--font-display); font-weight: 700; font-size: 44px; line-height: 1; font-variant-numeric: tabular-nums; }
.big-u { font-size: 16px; color: var(--text-3); margin-right: 10px; }
.badge { font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px; color: #fff; background: var(--l0); align-self: center; }
.badge.l1 { background: var(--l1); } .badge.l2 { background: var(--l2); color: #1a1200; } .badge.l3 { background: var(--l3); }
.badge.l4 { background: var(--l4); } .badge.l5 { background: var(--l5); }
.kv { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; margin: 12px 0 0; }
.kv div { display: flex; flex-direction: column; }
.kv dt { font-size: 11px; color: var(--text-3); }
.kv dd { margin: 0; font-size: 14px; font-variant-numeric: tabular-nums; }
.drawer-time { margin: 10px 0 0; font-size: 11.5px; color: var(--text-3); }
.impact { margin-top: 10px; background: linear-gradient(180deg, rgba(224,58,94,.10), rgba(224,58,94,.03)); border: 1px solid rgba(224,58,94,.3); border-radius: 12px; padding: 10px 14px; }
.impact[hidden] { display: none; }
.impact-head { font-size: 12.5px; font-weight: 600; color: var(--text); }
.impact-head small { color: var(--text-3); font-weight: 400; }
.kv-3 { grid-template-columns: 1fr 1fr 1fr; margin-top: 8px; }
.impact-note { margin: 8px 0 0; font-size: 11px; color: var(--text-3); line-height: 1.4; }
.impact-note b { color: var(--text); font-family: var(--font-display); }
.pop-impact { margin-top: 4px; padding-top: 4px; border-top: 1px solid var(--line); }
.ramp { margin: 6px 0 2px 22px; }
.ramp i { display: block; height: 8px; border-radius: 4px; background: linear-gradient(90deg, #f2c14e, #ee8a2e 35%, #e03a5e 70%, #8e0f3f); }
.ramp-l { display: flex; justify-content: space-between; font-size: 10px; color: var(--text-3); margin-top: 3px; }
.ramp .legend-note { margin-top: 4px; }

.chart-head { margin-top: 16px; display: flex; flex-direction: column; gap: 4px; }
.drawer h3 { margin: 0; font-size: 13px; font-weight: 600; color: var(--text-2); }
.chart-legend { list-style: none; margin: 0; padding: 0; display: flex; gap: 12px; font-size: 11px; color: var(--text-3); }
.chart-legend li { display: flex; align-items: center; gap: 5px; }
.sw { display: inline-block; width: 18px; height: 0; border-top: 2px solid var(--accent); }
.sw.dash { border-top-style: dashed; }
.sw.bank { border-top: 2px solid var(--l5); opacity: .8; }
.chart { position: relative; height: 200px; margin-top: 6px; }
.chart svg { width: 100%; height: 100%; display: block; overflow: visible; }
.chart .grid line { stroke: var(--line); stroke-width: 1; }
.chart .axis text { fill: var(--text-3); font-size: 10px; font-family: var(--font-body); }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .line.fc { stroke-dasharray: 4 4; }
.chart .area { fill: url(#areaGrad); }
.chart .bank { stroke: var(--l5); stroke-width: 1.5; stroke-dasharray: 2 3; opacity: .85; }
.chart .ground { stroke: var(--text-3); stroke-width: 1; stroke-dasharray: 1 3; }
.chart .cursor { stroke: #f2b23a; stroke-width: 1.5; }
.chart .cursor-dot { fill: #fff; stroke: #f2b23a; stroke-width: 2; }
.chart .x-hover { stroke: var(--text-2); stroke-width: 1; stroke-dasharray: 2 2; }
.chart .tip {
  position: absolute; pointer-events: none; transform: translate(-50%, -110%);
  background: var(--glass-2); border: 1px solid var(--line-strong); border-radius: 8px; padding: 6px 9px;
  font-size: 11.5px; white-space: nowrap; box-shadow: var(--shadow);
}
.chart .tip b { font-family: var(--font-display); font-size: 13px; }
.chart .chart-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--text-3); font-size: 12px; }

.rain-title { margin-top: 16px !important; }
.rain-title small { color: var(--text-3); font-weight: 400; }
.rain { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-top: 8px; }
.rain .day { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 10.5px; color: var(--text-3); }
.rain .bar { width: 100%; height: 54px; border-radius: 6px; background: var(--ink-3); position: relative; overflow: hidden; }
.rain .bar i { position: absolute; left: 0; right: 0; bottom: 0; background: linear-gradient(180deg, var(--accent-2), #1f7fc2); border-radius: 6px 6px 0 0; }
.rain .day b { color: var(--text); font-family: var(--font-display); font-weight: 600; font-size: 12px; }
.drawer-src { margin: 16px 0 0; font-size: 11px; color: var(--text-3); line-height: 1.4; }

/* ===== dwell probe ===== */
.probe {
  position: absolute; z-index: 12; --px: 14px; transform: translate(var(--px), -50%); pointer-events: none; min-width: 230px; max-width: 300px;
  background: var(--glass-2); border: 1px solid rgba(79,209,255,.5); border-radius: 10px; padding: 9px 12px; box-shadow: var(--shadow);
  font-size: 12px; animation: probe-in .18s ease-out both;
}
.probe[hidden] { display: none; }
.probe.flip { --px: calc(-100% - 14px); }
.probe-title { color: var(--text-2); font-size: 12px; }
.probe-depth { font-family: var(--font-display); font-size: 13px; color: var(--text-2); }
.probe-depth b { font-size: 26px; color: #7cf2ff; line-height: 1; }
.probe-depth.probe-dry b { font-size: 18px; color: #4ade80; }
.probe-sub { font-size: 11px; color: var(--text-3); margin: 2px 0 6px; }
.probe-row { display: flex; justify-content: space-between; gap: 10px; font-size: 11.5px; padding: 2px 0; border-top: 1px solid var(--line); }
.probe-row span:first-child { color: var(--text-3); }
.probe-row span:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.probe-note { margin-top: 6px; font-size: 10.5px; color: #f2b23a; }
@keyframes probe-in { from { opacity: 0; } to { opacity: 1; } }

/* ===== map popups ===== */
.maplibregl-popup-content {
  background: var(--glass-2); color: var(--text); border: 1px solid var(--line-strong); border-radius: 10px;
  box-shadow: var(--shadow); padding: 10px 12px; font-family: var(--font-body); font-size: 12.5px; min-width: 190px;
}
.maplibregl-popup-tip { display: none; }
.pop-name { font-family: var(--font-display); font-weight: 600; font-size: 14px; margin-bottom: 2px; }
.pop-where { color: var(--text-3); font-size: 11.5px; margin-bottom: 6px; }
.pop-row { display: flex; justify-content: space-between; gap: 10px; font-variant-numeric: tabular-nums; }
.pop-row .badge { font-size: 11px; padding: 2px 8px; }
.pop-main { display: grid; grid-template-columns: 44px 1fr; gap: 8px; align-items: center; margin: 4px 0 6px; }
.pop-bank { font-family: var(--font-display); font-weight: 600; font-size: 14px; color: var(--accent-2); }
.pop-bank.over { color: var(--l5); }
.pop-dim { color: var(--text-3); font-size: 11px; }
.pop-dim b { font-weight: 500; }
.maplibregl-ctrl-group { background: var(--glass-2) !important; border: 1px solid var(--line-strong); }
.maplibregl-ctrl-group button { filter: invert(.9); }
.maplibregl-ctrl-attrib { background: rgba(11,18,32,.7) !important; color: var(--text-3); font-size: 10px; }
.maplibregl-ctrl-attrib a { color: var(--text-2); }

/* ===== motion ===== */
@keyframes drop { from { opacity: 0; transform: translateY(-14px); } to { opacity: 1; transform: none; } }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes slide { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes wave { 0%,100% { transform: translateY(0) scaleX(1); } 50% { transform: translateY(-3px) scaleX(1.08); } }

/* ===== responsive ===== */
@media (max-width: 1100px) {
  .hud-top { grid-template-columns: 1fr; gap: 10px; }
  .legend { width: 260px; }
  /* let the top controls scroll horizontally when they don't all fit */
  .header-right { justify-content: flex-start; flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch; padding-bottom: 3px; }
  .header-right > * { flex: 0 0 auto; }
  .header-right::-webkit-scrollbar { height: 4px; }
  .header-right::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 3px; }
  .search input { width: 180px; }
  .drawer { width: min(360px, calc(100vw - 28px)); top: auto; bottom: calc(var(--dock-h, 130px) + 26px); max-height: 50vh; }
}
@media (max-width: 640px) {
  .tiles { display: none; }
  /* keep the layers panel usable on phones: narrower, starts tucked, tap the edge tab to open */
  .legend { width: min(88vw, 320px); max-height: 56vh; }
  .search input { width: 150px; }
  .dock-head { grid-template-columns: auto 1fr auto; }
  .readout { justify-content: flex-start; }
  .mode .seg { font-size: 11px; padding: 6px 8px; }
}

/* ===== field layer: feed drawer + popups ===== */
.feed-btn { font: inherit; font-size: 12.5px; font-weight: 600; color: #dff7ff; background: linear-gradient(180deg, #4c1d95, #2e1065); border: 1px solid rgba(192,132,252,.6); border-radius: 10px; padding: 8px 12px; cursor: pointer; white-space: nowrap; }
.feed-btn[aria-expanded="true"] { box-shadow: 0 0 0 3px rgba(192,132,252,.25); }
.drawer.feed { width: 380px; }
.feed-status { margin: 0 0 8px; font-size: 11.5px; color: var(--text-3); line-height: 1.45; }
.feed-tools { display: flex; gap: 8px; margin-bottom: 10px; }
.feed-tools input { flex: 1; padding: 7px 10px; border-radius: 8px; border: 1px solid var(--line-strong); background: var(--ink-2); color: var(--text); font: inherit; font-size: 12.5px; }
.feed-tools .seg { border-radius: 8px; }
.feed-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.feed-list li { display: grid; grid-template-columns: 10px 1fr auto; gap: 8px; align-items: start; padding: 8px 10px; border-radius: 10px; background: var(--ink-2); border: 1px solid var(--line); cursor: pointer; }
.feed-list li[data-lat]:hover { border-color: var(--accent); }
.feed-list li:not([data-lat]) { cursor: default; opacity: .8; }
.feed-dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 4px; }
.feed-title { font-size: 12.5px; line-height: 1.35; }
.feed-meta { font-size: 10.5px; color: var(--text-3); margin-top: 2px; }
.feed-thumb { width: 54px; height: 54px; object-fit: cover; border-radius: 6px; }
.feed-empty { color: var(--text-3); font-size: 12px; }

.field-popup .maplibregl-popup-content { padding: 10px 12px; min-width: 240px; }
.fp-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 6px; }
.fp-tag { font-size: 10.5px; font-weight: 600; padding: 2px 7px; border-radius: 5px; color: #1a0b2e; }
.fp-time { font-size: 11px; color: var(--text-3); }
.fp-title { font-family: var(--font-display); font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.fp-img { display: block; width: 100%; max-height: 200px; object-fit: cover; border-radius: 8px; margin: 4px 0 6px; background: var(--ink-3); }
.fp-video { display: block; width: 100%; aspect-ratio: 16 / 9; border: 0; border-radius: 8px; background: #000; margin: 4px 0 6px; }
.fp-text { font-size: 12.5px; line-height: 1.4; }
.fp-text a { color: var(--accent-2); text-decoration: none; }
.fp-meta { font-size: 11px; color: var(--text-3); margin-top: 6px; line-height: 1.4; }
.fp-link { display: inline-block; margin-top: 8px; font-size: 11.5px; color: var(--accent); text-decoration: none; }
@media (max-width: 1100px) { .drawer.feed { width: min(380px, calc(100vw - 28px)); } }

/* ===== ECMWF risk + alerts ===== */
.alert-btn { font: inherit; font-size: 12.5px; font-weight: 600; color: var(--text); background: var(--ink-2); border: 1px solid var(--line-strong); border-radius: 10px; padding: 8px 12px; cursor: pointer; white-space: nowrap; }
.alert-btn.hot { color: #fff; background: linear-gradient(180deg, #b91c1c, #7f1d1d); border-color: rgba(224,58,94,.7); animation: pulse 2s ease-in-out infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(224,58,94,.45); } 50% { box-shadow: 0 0 0 6px rgba(224,58,94,0); } }
.drawer.alerts { width: 380px; }
.rk { font-size: 10.5px; font-weight: 600; padding: 2px 7px; border-radius: 5px; color: #1a0b00; background: var(--ink-3); }
.rk1 { background: #f2c14e; } .rk2 { background: #ee8a2e; } .rk3 { background: #e03a5e; color: #fff; } .rk0 { color: var(--text-3); }
.al { display: block !important; }
.al-head { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.al-head b { flex: 1; }
.al-when { font-size: 11px; color: var(--text-3); white-space: nowrap; }
.al-body { font-size: 11.5px; color: var(--text-2); margin-top: 4px; line-height: 1.45; }
.al-body b { color: var(--text); }
.al3 { border-color: rgba(224,58,94,.5) !important; } .al2 { border-color: rgba(238,138,46,.5) !important; }
.rk-table { width: 100%; border-collapse: collapse; font-size: 11px; margin: 4px 0; }
.rk-table th { color: var(--text-3); font-weight: 500; text-align: left; padding: 2px 4px; border-bottom: 1px solid var(--line); }
.rk-table td { padding: 2px 4px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.rk-table tr.cur td { background: rgba(124,242,255,.08); }
@media (max-width: 1100px) { .drawer.alerts { width: min(380px, calc(100vw - 28px)); } }

/* header: keep the stat tiles on one row; drop them to a second row on mid-size screens */
@media (max-width: 1500px) and (min-width: 1101px) {
  .hud-top { grid-template-columns: auto 1fr; }
  .header-right { justify-content: flex-end; }
  .tiles { grid-column: 1 / -1; justify-content: flex-start; }
  .search input { width: 200px; }
}
.tiles { flex-wrap: nowrap; }

/* ===== info panel (replaces map popups for clicked items) ===== */
.drawer.info { width: 380px; padding: 16px 16px 14px; }
.drawer.info .fp-img { max-height: 260px; object-fit: cover; cursor: zoom-in; }   /* report / post photos: capped so the text stays in view; click opens full size */
.drawer.info .cam-big { width: 100%; aspect-ratio: 4 / 3; object-fit: contain; background: #000; cursor: zoom-in; }
/* camera card zoom: click the ⛶ button to enlarge card + image, click the image to shrink back */
.drawer.info { transition: width .28s cubic-bezier(.2,.8,.2,1); }
.drawer.info.zoomed { width: min(760px, calc(100vw - 28px)); }
.drawer.info.zoomed .fp-img, .drawer.info.zoomed .cam-big { max-height: 74vh; aspect-ratio: auto; object-fit: contain; background: #000; cursor: zoom-out; }
.fp-mediawrap { position: relative; }
.cam-cap { margin: 2px 0 6px; font-size: 11.5px; color: var(--accent); display: flex; align-items: center; gap: 4px; }
.cam-cap.stale { color: #f2b23a; }
.fp-zoom { position: absolute; top: 8px; right: 8px; z-index: 4; width: 32px; height: 32px; display: grid; place-items: center; border: 1px solid var(--line-strong); border-radius: 8px; background: rgba(11,18,32,.72); color: var(--text); font-size: 15px; line-height: 1; cursor: pointer; transition: background .15s, color .15s; }
.fp-zoom:hover { background: rgba(11,18,32,.95); color: var(--accent); }
.drawer.info .fp-title { font-size: 17px; margin: 4px 36px 8px 0; }
.drawer.info .fp-text { font-size: 13.5px; }
.drawer.info .rk-table { font-size: 12px; }
.drawer.info .rk-table td, .drawer.info .rk-table th { padding: 4px 5px; }
@media (max-width: 1100px) { .drawer.info { width: min(380px, calc(100vw - 28px)); } }

/* ===== category chips (news/youtube filter) ===== */
.cat-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 2px 0 8px; }
.cat-chips .chip { font: inherit; font-size: 11.5px; color: var(--text-2); background: var(--ink-2); border: 1px solid var(--line-strong); border-radius: 999px; padding: 4px 10px; cursor: pointer; white-space: nowrap; }
.cat-chips .chip.on { background: linear-gradient(180deg, #0f4f78, #0b3a5a); color: #dff7ff; border-color: rgba(79,209,255,.6); }

/* ===== layer-type icons in the legend ===== */
.lyr-ico { width: 16px; height: 16px; flex: none; }
.legend-toggle { gap: 7px; }

/* ===== water-level status toggles (moved from header) ===== */
.legend-title small { color: var(--text-3); font-weight: 400; font-size: 10.5px; }
.lv-toggle li { display: block; }
.lv-toggle label { display: grid; grid-template-columns: 16px 14px 1fr auto auto; align-items: center; gap: 7px; cursor: pointer; padding: 3px 0; }
.lv-toggle input { accent-color: var(--accent); margin: 0; }
.lv-toggle b { font-weight: 600; }
.lv-sub { color: var(--text-3); font-size: 11px; }
.lv-n { font-family: var(--font-display); font-weight: 700; font-variant-numeric: tabular-nums; min-width: 34px; text-align: right; }
