/* ตาปีวอทช์ — ระดับน้ำ จ.สุราษฎร์ธานี */

:root {
  color-scheme: light;
  --bg: #e9eff0;
  --surface: #f9fbfb;
  --surface-2: #eff4f4;
  --surface-3: #e3eaeb;
  --ink: #10292e;
  --ink-2: #3e5a5e;
  --muted: #6c8386;
  --line: #d4dfe0;
  --line-strong: #b9c8ca;
  --accent: #0c71a6;
  --accent-ink: #ffffff;
  --accent-wash: rgba(12, 113, 166, 0.1);
  --water: #0c71a6;
  --water-wash: rgba(12, 113, 166, 0.12);
  --bank: #8a5a36;
  --threshold: #b8591c;
  --grid: #e1e8e9;
  --focus: #0c71a6;

  --s5: #d03b3b;
  --s4: #e07a2e;
  --s3: #1e9a62;
  --s2: #c99a14;
  --s1: #8c5a2e;
  --s0: #97a3a4;

  --shadow-lg: 0 18px 50px -12px rgba(16, 41, 46, 0.35);
  --radius-sheet: 22px;
  --radius-tile: 14px;
  --radius-ctl: 10px;

  --font-body: "IBM Plex Sans Thai", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-num: "Bai Jamjuree", "IBM Plex Sans Thai", system-ui, sans-serif;

  --topbar-h: 60px;
  --bottomnav-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0a1719;
    --surface: #102227;
    --surface-2: #152b31;
    --surface-3: #1b353c;
    --ink: #e4eeee;
    --ink-2: #a9bec0;
    --muted: #7a9396;
    --line: #20383e;
    --line-strong: #2d4a51;
    --accent: #4aa8de;
    --accent-ink: #062030;
    --accent-wash: rgba(74, 168, 222, 0.14);
    --water: #4aa8de;
    --water-wash: rgba(74, 168, 222, 0.16);
    --bank: #c7956b;
    --threshold: #f0995a;
    --grid: #1a3036;
    --focus: #7cc4ec;

    --s5: #e5534b;
    --s4: #f08c45;
    --s3: #2db57f;
    --s2: #dcb030;
    --s1: #b98252;
    --s0: #5f7275;

    --shadow-lg: 0 18px 50px -12px rgba(0, 0, 0, 0.7);
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

a {
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: 6px;
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.icon {
  width: 20px;
  height: 20px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon.sm {
  width: 16px;
  height: 16px;
}
.icon.lg {
  width: 24px;
  height: 24px;
}

.num {
  font-family: var(--font-num);
  font-feature-settings: "tnum" 0;
}

/* ---------- top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: calc(var(--topbar-h) + env(safe-area-inset-top, 0px));
  padding: env(safe-area-inset-top, 0px) 16px 0;
  display: flex;
  align-items: center;
  gap: 16px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  min-width: 0;
}
.brand-mark {
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: 9px;
}
.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  min-width: 0;
}
.brand-name {
  font-family: var(--font-num);
  font-weight: 700;
  font-size: 19px;
  letter-spacing: 0.01em;
}
.brand-sub {
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tabs {
  display: none;
  margin-left: 12px;
  padding: 4px;
  gap: 2px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.tabs a {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 14px;
  border-radius: 9px;
  text-decoration: none;
  font-size: 14.5px;
  color: var(--ink-2);
}
.tabs a[aria-current="page"] {
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(16, 41, 46, 0.12);
}

.freshness {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--ink-2);
  white-space: nowrap;
}
.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--s3);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--s3) 25%, transparent);
}
.live-dot.stale {
  background: var(--s4);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--s4) 25%, transparent);
}
.live-dot.off {
  background: var(--s0);
  box-shadow: none;
}
.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
}
.icon-btn:hover {
  background: var(--surface-3);
  color: var(--ink);
}
.icon-btn.spinning .icon {
  animation: spin 0.9s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.install-btn {
  display: none;
}
@media (max-width: 599px) {
  .wide-only {
    display: none;
  }
  .install-btn {
    padding: 0 8px;
  }
  .topbar {
    gap: 8px;
  }
  .freshness {
    gap: 6px;
  }
}
.install-btn.show {
  display: inline-flex;
}

/* ---------- layout ---------- */

.layout {
  display: block;
}
.pane {
  min-width: 0;
}
.pane-list {
  padding-bottom: calc(var(--bottomnav-h) + var(--safe-b) + 24px);
}
.pane-main {
  padding-bottom: calc(var(--bottomnav-h) + var(--safe-b) + 24px);
}

.app[data-view="list"] .pane-main {
  display: none;
}
.app:not([data-view="list"]) .pane-list {
  display: none;
}

@media (min-width: 980px) {
  .tabs {
    display: flex;
  }
  .bottom-nav {
    display: none !important;
  }
  .layout {
    display: grid;
    grid-template-columns: minmax(380px, 440px) minmax(0, 1fr);
    height: calc(100dvh - var(--topbar-h));
  }
  .app .pane-list,
  .app .pane-main {
    display: block !important;
    overflow-y: auto;
    padding-bottom: 32px;
    scrollbar-gutter: stable;
  }
  .pane-list {
    border-right: 1px solid var(--line);
    background: var(--surface);
  }
  .pane-main .back-link {
    display: none;
  }
}

/* ---------- bottom nav (mobile) ---------- */

.bottom-nav {
  position: fixed;
  z-index: 30;
  left: 0;
  right: 0;
  bottom: 0;
  height: calc(var(--bottomnav-h) + var(--safe-b));
  padding: 6px 12px var(--safe-b);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-top: 1px solid var(--line);
}
.bottom-nav a {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  text-decoration: none;
  font-size: 12.5px;
  color: var(--muted);
  border-radius: 12px;
}
.bottom-nav a[aria-current="page"] {
  color: var(--accent);
  font-weight: 600;
}
.bottom-nav a[aria-current="page"] .icon {
  stroke-width: 2.2;
}
.nav-badge {
  position: absolute;
  top: 4px;
  left: calc(50% + 6px);
  min-width: 17px;
  height: 17px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--s5);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  line-height: 17px;
  text-align: center;
}

/* ---------- overview (hero) ---------- */

.overview {
  padding: 22px 16px 18px;
}
.overview-title {
  margin: 0;
  font-family: var(--font-num);
  font-weight: 600;
  font-size: 27px;
  line-height: 1.25;
  letter-spacing: -0.005em;
}
.overview-title .icon {
  width: 26px;
  height: 26px;
  vertical-align: -4px;
  margin-right: 6px;
}
.overview-lede {
  margin: 6px 0 0;
  color: var(--ink-2);
  font-size: 14.5px;
  max-width: 44ch;
}

.dist {
  margin-top: 18px;
}
.dist-bar {
  display: flex;
  gap: 2px;
  height: 12px;
}
.dist-bar span {
  display: block;
  min-width: 6px;
  height: 100%;
  background: var(--c);
}
.dist-bar span:first-child {
  border-radius: 4px 0 0 4px;
}
.dist-bar span:last-child {
  border-radius: 0 4px 4px 0;
}
.dist-bar span:only-child {
  border-radius: 4px;
}
.dist-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 6px;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
}
.dist-legend button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px 3px 8px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  font-size: 13.5px;
  color: var(--ink-2);
  cursor: pointer;
}
.dist-legend button:hover {
  background: var(--surface-3);
}
.dist-legend button[aria-pressed="true"] {
  border-color: var(--line-strong);
  background: var(--surface);
  color: var(--ink);
}
.dist-legend b {
  font-family: var(--font-num);
  font-weight: 600;
  color: var(--ink);
}
.swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: var(--c);
  flex: none;
}

/* ---------- favourites ---------- */

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 0 16px;
  margin: 8px 0 10px;
}
.section-head h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
}
.section-head .hint {
  font-size: 12.5px;
  color: var(--muted);
}

/* ---------- pinned stations ---------- */

.pins {
  padding: 18px 16px 4px;
}
.pins .section-head {
  padding: 0;
  margin: 0 0 10px;
  align-items: center;
}
.section-head h2 .icon {
  vertical-align: -2px;
  margin-right: 6px;
  color: var(--accent);
}
.section-head .count {
  margin-left: 6px;
  font-family: var(--font-num);
  font-weight: 500;
  color: var(--muted);
}
.btn.sm {
  height: 32px;
  padding: 0 12px;
  font-size: 13.5px;
}
.btn[aria-pressed="true"] {
  color: var(--accent);
}
.pin-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.pin {
  display: flex;
  gap: 8px;
}
.pin-card {
  flex: 1;
  min-width: 0;
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  padding: 14px 16px 14px 14px;
  border-radius: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  text-decoration: none;
}
a.pin-card:hover {
  border-color: var(--line-strong);
}
.pin-card[aria-current="true"] {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}
.pin-gauge {
  width: 24px;
  height: 88px;
}
.pin-body {
  min-width: 0;
}
.pin-top {
  display: flex;
  align-items: center;
  gap: 8px;
}
.pin-name {
  min-width: 0;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pin-bell {
  flex: none;
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px 2px 6px;
  border-radius: 999px;
  background: var(--accent-wash);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
}
.pin-bell .icon {
  width: 13px;
  height: 13px;
}
.pin-bell.active {
  background: color-mix(in srgb, var(--s5) 14%, transparent);
  color: var(--s5);
}
.pin-sub {
  font-size: 12.5px;
  color: var(--muted);
}
.pin-mid {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-top: 6px;
}
.pin-level {
  font-family: var(--font-num);
  font-size: 36px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.pin-level small {
  margin-left: 5px;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0;
  color: var(--ink-2);
}
.pin-spark {
  flex: none;
  width: 112px;
  height: 40px;
  color: var(--water);
}
.pin-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 12px;
  margin-top: 10px;
  font-size: 13px;
  color: var(--ink-2);
}
.pin-foot .over {
  color: var(--s5);
  font-weight: 600;
}
.pin-foot .trend .icon {
  width: 13px;
  height: 13px;
}
.pin-ctl {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
}
.pin-ctl .icon-btn {
  width: 40px;
  height: 38px;
  border: 1px solid var(--line);
  background: var(--surface);
}
.pin-ctl .icon-btn[disabled] {
  opacity: 0.35;
  cursor: default;
}
.pin-ctl .unpin {
  color: var(--s5);
}

.pin-prompt {
  margin: 16px 16px 0;
  padding: 16px;
  border-radius: 18px;
  border: 1px dashed var(--line-strong);
  background: var(--surface);
}
.pin-prompt-head {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
}
.pin-prompt-icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--accent-wash);
  color: var(--accent);
}
.pin-prompt h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}
.pin-prompt p {
  margin: 2px 0 0;
  font-size: 13.5px;
  color: var(--ink-2);
}
.pin-prompt .icon-btn {
  margin: -6px -8px 0 0;
}
.pin-prompt .presets {
  margin-top: 12px;
}
.chip .icon {
  vertical-align: -3px;
  margin-right: 4px;
}

.map-card-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
.map-card-actions .btn.primary {
  flex: 1;
}

/* ---------- filters ---------- */

.filters {
  position: sticky;
  top: calc(var(--topbar-h) + env(safe-area-inset-top, 0px));
  z-index: 10;
  padding: 12px 16px 10px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
@media (min-width: 980px) {
  .filters {
    top: 0;
    background: var(--surface);
  }
}
.search {
  position: relative;
  display: flex;
  gap: 8px;
}
.search .icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}
.search input {
  flex: 1;
  min-width: 0;
  height: 42px;
  padding: 0 12px 0 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius-ctl);
  background: var(--surface);
  font-size: 15px;
}
.search input::placeholder {
  color: var(--muted);
}
.search select {
  height: 42px;
  padding: 0 30px 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-ctl);
  background: var(--surface)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236c8386' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E")
    no-repeat right 10px center;
  appearance: none;
  -webkit-appearance: none;
  font-size: 14px;
  color: var(--ink-2);
}
.chips {
  display: flex;
  gap: 6px;
  margin: 10px -16px 0;
  padding: 0 16px;
  overflow-x: auto;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar {
  display: none;
}
.chip {
  flex: none;
  padding: 5px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-size: 13.5px;
  color: var(--ink-2);
  cursor: pointer;
  white-space: nowrap;
}
.chip:hover {
  border-color: var(--line-strong);
}
.chip[aria-pressed="true"] {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--bg);
}

/* ---------- station list (ledger) ---------- */

.list {
  margin: 0;
  padding: 0;
  list-style: none;
}
.row-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  border-bottom: 1px solid var(--line);
}
.row-item:hover {
  background: color-mix(in srgb, var(--surface-3) 60%, transparent);
}
.row-item:has(> .row[aria-current="true"]) {
  background: var(--accent-wash);
}
.row {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr) 56px auto;
  align-items: center;
  gap: 10px;
  padding: 12px 2px 12px 16px;
  text-decoration: none;
  position: relative;
  min-width: 0;
}
.row-pin {
  display: grid;
  place-items: center;
  padding: 0 8px 0 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.row-pin:hover {
  color: var(--ink);
}
.row-pin[aria-pressed="true"] {
  color: var(--accent);
}
[aria-pressed="true"] > .icon.pin {
  fill: currentColor;
}
.row[aria-current="true"]::before {
  content: "";
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
}
.row.stale {
  opacity: 0.62;
}
.row-name {
  font-size: 15px;
  font-weight: 500;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.row-meta {
  margin-top: 2px;
  font-size: 12.5px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.row-meta .over {
  color: var(--s5);
  font-weight: 600;
}
.row-spark {
  width: 56px;
  height: 28px;
  color: var(--water);
}
.row-value {
  text-align: right;
  min-width: 60px;
}
.row-level {
  font-family: var(--font-num);
  font-size: 19px;
  font-weight: 600;
  line-height: 1.15;
  white-space: nowrap;
}
.row-trend {
  margin-top: 1px;
  font-size: 12px;
  color: var(--ink-2);
  white-space: nowrap;
}
.empty {
  padding: 40px 24px;
  text-align: center;
  color: var(--ink-2);
}
.empty .icon {
  width: 32px;
  height: 32px;
  color: var(--muted);
  margin-bottom: 8px;
}

/* ---------- trend + status ---------- */

.trend {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.trend .icon {
  width: 13px;
  height: 13px;
  stroke-width: 2.4;
}
.trend.up .icon {
  color: var(--s5);
}
.trend.down .icon {
  color: var(--s3);
}
.trend.flat .icon {
  color: var(--muted);
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px 3px 7px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--c) 15%, transparent);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
}
.status .icon {
  width: 15px;
  height: 15px;
  color: var(--c);
  stroke-width: 2.3;
}

/* mini gauge in rows */
.mini-gauge {
  width: 12px;
  height: 44px;
}

/* ---------- detail ---------- */

.detail {
  max-width: 980px;
  margin: 0 auto;
  padding: 12px 16px 24px;
}
@media (min-width: 980px) {
  .detail {
    padding: 20px 36px 40px;
  }
}
.detail-top {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
}
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: -8px;
  padding: 8px 10px 8px 6px;
  border-radius: 10px;
  text-decoration: none;
  color: var(--ink-2);
  font-size: 14.5px;
}
.back-link:hover {
  background: var(--surface-3);
}
.detail-actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  border-radius: var(--radius-ctl);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  font-size: 14.5px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover {
  background: var(--surface-2);
}
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.btn.primary:hover {
  filter: brightness(1.07);
}
.btn.ghost {
  border-color: transparent;
  background: transparent;
}
.btn.ghost:hover {
  background: var(--surface-3);
}
.btn.danger {
  color: var(--s5);
}
.btn.block {
  width: 100%;
  height: 48px;
  font-size: 16px;
}
.btn[disabled] {
  opacity: 0.55;
  cursor: default;
}
.btn .icon.on {
  fill: var(--s2);
  stroke: var(--s2);
}
.btn-label-sm {
  display: none;
}
@media (max-width: 420px) {
  .btn.compact .btn-label {
    display: none;
  }
  .btn.compact {
    width: 40px;
    padding: 0;
  }
}

.station-title {
  margin: 8px 0 2px;
  font-family: var(--font-num);
  font-size: 28px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.005em;
}
.station-sub {
  margin: 0;
  color: var(--ink-2);
  font-size: 14px;
}

.hero {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 20px;
  align-items: stretch;
  margin: 20px 0 8px;
}
.hero-gauge {
  width: 112px;
  height: 256px;
}
.hero-read {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 10px;
  min-width: 0;
}
.hero-level {
  font-family: var(--font-num);
  font-size: 60px;
  font-weight: 600;
  line-height: 0.95;
  letter-spacing: -0.02em;
}
.hero-level small {
  font-size: 17px;
  font-weight: 500;
  letter-spacing: 0;
  color: var(--ink-2);
  margin-left: 6px;
}
.hero-bank {
  font-size: 17px;
  font-weight: 500;
}
.hero-bank.over {
  color: var(--s5);
  font-weight: 600;
}
.facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 20px;
  margin: 6px 0 0;
  max-width: 420px;
}
.facts div {
  min-width: 0;
}
.facts dt {
  font-size: 12.5px;
  color: var(--muted);
}
.facts dd {
  margin: 0;
  font-size: 15px;
  font-weight: 500;
}
.facts dd .num {
  font-size: 17px;
  font-weight: 600;
}

.hero-row {
  display: grid;
  gap: 0;
}
@media (min-width: 1240px) {
  .hero-row {
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: 28px;
    align-items: center;
  }
  .hero-row .stats {
    grid-template-columns: 1fr;
    margin-top: 0;
  }
}

.stale-note {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin: 16px 0 0;
  padding: 12px 14px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--s4) 12%, transparent);
  font-size: 14px;
  color: var(--ink);
}
.stale-note .icon {
  color: var(--s4);
  margin-top: 2px;
}

/* chart block */
.block {
  margin-top: 28px;
}
.block-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 12px;
  margin-bottom: 12px;
}
.block-head h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  margin-right: auto;
}
.seg {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border-radius: 11px;
  background: var(--surface-3);
}
.seg button {
  padding: 5px 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  font-size: 13.5px;
  color: var(--ink-2);
  cursor: pointer;
  white-space: nowrap;
}
.seg button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(16, 41, 46, 0.14);
}

.chart-card {
  position: relative;
  padding: 16px 8px 8px 4px;
  border-radius: var(--radius-tile);
  background: var(--surface);
  border: 1px solid var(--line);
}
.chart {
  position: relative;
  width: 100%;
  touch-action: pan-y;
}
.chart svg {
  display: block;
  width: 100%;
  overflow: visible;
}
.chart.loading svg {
  opacity: 0.45;
  transition: opacity 0.2s;
}
.chart-msg {
  display: grid;
  place-items: center;
  height: 260px;
  color: var(--ink-2);
  font-size: 14px;
  text-align: center;
  padding: 0 24px;
}
.chart .tick text {
  font-family: var(--font-body);
  font-size: 11.5px;
  fill: var(--muted);
  font-variant-numeric: tabular-nums;
}
.chart .grid line {
  stroke: var(--grid);
  stroke-width: 1;
}
.chart .baseline {
  stroke: var(--line-strong);
}
.chart .area {
  fill: var(--water-wash);
}
.chart .line {
  fill: none;
  stroke: var(--water);
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}
.chart .ref-bank {
  stroke: var(--bank);
  stroke-width: 1.5;
}
.chart .ref-crit {
  stroke: var(--s5);
  stroke-width: 1.25;
  stroke-dasharray: 6 4;
}
.chart .ref-user {
  stroke: var(--threshold);
  stroke-width: 1.25;
  stroke-dasharray: 3 4;
}
.chart .ref-label {
  font-family: var(--font-body);
  font-size: 11.5px;
  font-weight: 600;
  paint-order: stroke;
  stroke: var(--surface);
  stroke-width: 4px;
  stroke-linejoin: round;
}
.chart .ref-label.bank {
  fill: var(--bank);
}
.chart .ref-label.crit {
  fill: var(--s5);
}
.chart .ref-label.user {
  fill: var(--threshold);
}
.chart .end-dot {
  fill: var(--water);
  stroke: var(--surface);
  stroke-width: 2;
}
.chart .end-label {
  font-family: var(--font-num);
  font-size: 13px;
  font-weight: 600;
  fill: var(--ink);
  paint-order: stroke;
  stroke: var(--surface);
  stroke-width: 4px;
}
.chart .cross {
  stroke: var(--ink-2);
  stroke-width: 1;
}
.chart .cross-dot {
  fill: var(--water);
  stroke: var(--surface);
  stroke-width: 2;
}
.chart .offscale {
  font-family: var(--font-body);
  font-size: 11.5px;
  font-weight: 600;
}
.chart-tip {
  position: absolute;
  top: 0;
  z-index: 2;
  pointer-events: none;
  padding: 8px 11px;
  border-radius: 10px;
  background: var(--ink);
  color: var(--bg);
  font-size: 12.5px;
  line-height: 1.35;
  white-space: nowrap;
  box-shadow: var(--shadow-lg);
  transform: translateX(-50%);
}
.chart-tip b {
  display: block;
  font-family: var(--font-num);
  font-size: 17px;
  font-weight: 600;
}
.chart-tip span {
  opacity: 0.78;
}
.chart-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 16px;
  padding: 10px 12px 4px;
  font-size: 12.5px;
  color: var(--ink-2);
}
.key {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.key i {
  display: inline-block;
  width: 18px;
  height: 0;
  border-top: 2px solid var(--c);
}
.key i.dash {
  border-top-style: dashed;
}
.chart-foot .src {
  margin-left: auto;
  color: var(--muted);
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  margin-top: 12px;
  border-radius: var(--radius-tile);
  overflow: hidden;
  background: var(--line);
  border: 1px solid var(--line);
}
.stat {
  padding: 10px 12px;
  background: var(--surface);
}
.stat dt {
  font-size: 12.5px;
  color: var(--muted);
}
.stat dd {
  margin: 0;
  font-family: var(--font-num);
  font-size: 19px;
  font-weight: 600;
}
.stat dd .trend {
  gap: 4px;
  white-space: nowrap;
}
.stat dd .trend .icon {
  width: 16px;
  height: 16px;
}
.stat dd small {
  display: block;
  font-family: var(--font-body);
  font-size: 11.5px;
  font-weight: 400;
  color: var(--muted);
}

.table-wrap {
  max-height: 340px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-tile);
  background: var(--surface);
}
.table-wrap table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.table-wrap th,
.table-wrap td {
  padding: 7px 14px;
  text-align: left;
  border-bottom: 1px solid var(--line);
}
.table-wrap th {
  position: sticky;
  top: 0;
  background: var(--surface-2);
  font-weight: 600;
  font-size: 13px;
  color: var(--ink-2);
}
.table-wrap td.n {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* rule cards */
.rules {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.rule {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px 12px 12px 14px;
  border-radius: var(--radius-tile);
  background: var(--surface);
  border: 1px solid var(--line);
}
.rule.off {
  opacity: 0.6;
}
.rule-icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--accent-wash);
  color: var(--accent);
}
.rule-icon.active {
  background: color-mix(in srgb, var(--s5) 15%, transparent);
  color: var(--s5);
}
.rule-title {
  font-weight: 600;
  font-size: 15px;
  line-height: 1.35;
}
.rule-station {
  font-size: 13px;
  color: var(--ink-2);
  text-decoration: none;
}
a.rule-station:hover {
  text-decoration: underline;
}
.rule-note {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 2px;
}
.rule-ctl {
  display: flex;
  align-items: center;
  gap: 2px;
}

.switch {
  position: relative;
  width: 44px;
  height: 26px;
  flex: none;
}
.switch input {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}
.switch span {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: var(--line-strong);
  transition: background 0.15s;
  pointer-events: none;
}
.switch span::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform 0.15s;
}
.switch input:checked + span {
  background: var(--accent);
}
.switch input:checked + span::after {
  transform: translateX(18px);
}
.switch input:focus-visible + span {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.info-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px 24px;
  margin: 0;
}
.info-list dt {
  font-size: 12.5px;
  color: var(--muted);
}
.info-list dd {
  margin: 0;
  font-size: 15px;
}

.source-note {
  margin-top: 28px;
  font-size: 12.5px;
  color: var(--muted);
  max-width: 70ch;
}
.source-note a {
  color: var(--ink-2);
}

/* ---------- alerts page ---------- */

.page {
  max-width: 760px;
  margin: 0 auto;
  padding: 20px 16px 24px;
}
@media (min-width: 980px) {
  .page {
    padding: 28px 36px 40px;
  }
}
.page-title {
  margin: 0 0 4px;
  font-family: var(--font-num);
  font-size: 28px;
  font-weight: 600;
}
.page-lede {
  margin: 0 0 20px;
  color: var(--ink-2);
  font-size: 15px;
  max-width: 60ch;
}

.push-card {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 14px;
  padding: 18px;
  border-radius: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
}
.push-card .badge {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--accent-wash);
  color: var(--accent);
}
.push-card.on .badge {
  background: color-mix(in srgb, var(--s3) 16%, transparent);
  color: var(--s3);
}
.push-card.warn .badge {
  background: color-mix(in srgb, var(--s4) 16%, transparent);
  color: var(--s4);
}
.push-card h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
}
.push-card p {
  margin: 4px 0 0;
  font-size: 14.5px;
  color: var(--ink-2);
}
.push-card .actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}
.steps {
  margin: 10px 0 0;
  padding-left: 20px;
  font-size: 14.5px;
  color: var(--ink-2);
}
.steps li {
  margin: 4px 0;
}

.events {
  margin: 0;
  padding: 0;
  list-style: none;
}
.event {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr);
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.event:last-child {
  border-bottom: 0;
}
.event-dot {
  width: 10px;
  height: 10px;
  margin-top: 7px;
  border-radius: 50%;
  background: var(--c, var(--accent));
}
.event-title {
  font-weight: 600;
  font-size: 14.5px;
}
.event-body {
  font-size: 13.5px;
  color: var(--ink-2);
  white-space: pre-line;
}
.event-time {
  font-size: 12.5px;
  color: var(--muted);
}

/* ---------- map ---------- */

.map-wrap {
  position: relative;
  height: calc(100dvh - var(--topbar-h) - var(--bottomnav-h) - var(--safe-b) - env(safe-area-inset-top, 0px));
}
@media (min-width: 980px) {
  .map-wrap {
    height: calc(100dvh - var(--topbar-h));
  }
  .pane-main:has(.map-wrap) {
    padding-bottom: 0 !important;
    overflow: hidden !important;
  }
}
.pane-main:has(.map-wrap) {
  padding-bottom: 0;
}
#map {
  position: absolute;
  inset: 0;
  background: var(--surface-2);
}
.map-legend {
  position: absolute;
  z-index: 500;
  top: 12px;
  right: 12px;
  padding: 8px 12px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  border: 1px solid var(--line);
  box-shadow: 0 4px 16px -6px rgba(16, 41, 46, 0.3);
  font-size: 12.5px;
}
.map-legend ul {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 2px;
}
.map-legend li {
  display: flex;
  align-items: center;
  gap: 8px;
}
.map-legend .swatch {
  border-radius: 50%;
}
.map-card {
  position: absolute;
  z-index: 500;
  left: 12px;
  right: 12px;
  bottom: 12px;
  max-width: 420px;
  padding: 14px 16px;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 12px;
  align-items: center;
}
.map-card[hidden] {
  display: none;
}
.map-card .row-name {
  white-space: normal;
}
.leaflet-container {
  font-family: var(--font-body) !important;
  background: var(--surface-2) !important;
}
.leaflet-tooltip.tw-tip {
  padding: 6px 10px;
  border-radius: 8px;
  border: 0;
  background: var(--ink);
  color: var(--bg);
  font-size: 12.5px;
  box-shadow: var(--shadow-lg);
}
.leaflet-tooltip.tw-tip::before {
  display: none;
}
@media (prefers-color-scheme: dark) {
  .leaflet-tile-pane {
    filter: invert(1) hue-rotate(180deg) brightness(0.85) contrast(0.9) saturate(0.6);
  }
  .leaflet-control-attribution {
    background: rgba(16, 34, 39, 0.8) !important;
    color: var(--muted) !important;
  }
  .leaflet-control-attribution a {
    color: var(--ink-2) !important;
  }
  .leaflet-bar a {
    background: var(--surface) !important;
    color: var(--ink) !important;
    border-color: var(--line) !important;
  }
}

/* ---------- rule sheet ---------- */

dialog.sheet {
  width: min(560px, 100%);
  max-height: min(92dvh, 820px);
  margin: auto auto 0;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sheet) var(--radius-sheet) 0 0;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
@media (min-width: 640px) {
  dialog.sheet {
    margin: auto;
    border-radius: var(--radius-sheet);
  }
}
dialog.sheet::backdrop {
  background: rgba(6, 20, 24, 0.5);
  backdrop-filter: blur(2px);
}
dialog.sheet[open] {
  animation: sheet-in 0.26s cubic-bezier(0.2, 0.9, 0.3, 1);
}
@keyframes sheet-in {
  from {
    transform: translateY(24px);
    opacity: 0;
  }
}
.sheet-form {
  display: flex;
  flex-direction: column;
  max-height: inherit;
}
.sheet-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 18px 18px 12px;
  border-bottom: 1px solid var(--line);
}
.sheet-head h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  line-height: 1.3;
}
.sheet-head p {
  margin: 2px 0 0;
  font-size: 13.5px;
  color: var(--ink-2);
}
.sheet-head .icon-btn {
  margin: -4px -6px 0 auto;
}
.sheet-body {
  padding: 16px 18px;
  overflow-y: auto;
  display: grid;
  gap: 18px;
}
.sheet-foot {
  display: flex;
  gap: 10px;
  padding: 12px 18px calc(12px + var(--safe-b));
  border-top: 1px solid var(--line);
  background: var(--surface);
}
.sheet-foot .btn.primary {
  flex: 1;
}
.field-label {
  display: block;
  margin-bottom: 8px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink-2);
}
.seg.full {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  width: 100%;
}
.seg.full button {
  padding: 8px 6px;
  font-size: 14px;
}
.stepper {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) 48px;
  gap: 8px;
  align-items: stretch;
}
.stepper button {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-ctl);
  background: var(--surface-2);
  font-size: 22px;
  cursor: pointer;
}
.stepper button:hover {
  background: var(--surface-3);
}
.stepper .input {
  position: relative;
}
.stepper input {
  width: 100%;
  height: 56px;
  padding: 0 64px 0 16px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-ctl);
  background: var(--surface);
  font-family: var(--font-num);
  font-size: 26px;
  font-weight: 600;
  text-align: center;
}
.stepper .unit {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 13px;
  color: var(--muted);
  pointer-events: none;
}
.presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.presets .chip b {
  font-family: var(--font-num);
  font-weight: 600;
  margin-left: 4px;
}
.rule-preview {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  padding: 14px;
  border-radius: 14px;
  background: var(--surface-2);
}
.rule-preview svg {
  width: 56px;
  height: 120px;
}
.rule-preview p {
  margin: 0;
  font-size: 14.5px;
}
.rule-preview .distance {
  margin-top: 6px;
  font-size: 13px;
  color: var(--ink-2);
}
.form-error {
  color: var(--s5);
  font-size: 13.5px;
  margin: 0;
}

/* ---------- toast ---------- */

.toast {
  position: fixed;
  z-index: 100;
  left: 50%;
  bottom: calc(var(--bottomnav-h) + var(--safe-b) + 16px);
  transform: translate(-50%, 20px);
  max-width: calc(100% - 32px);
  padding: 11px 16px;
  border-radius: 12px;
  background: var(--ink);
  color: var(--bg);
  font-size: 14.5px;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.2s,
    transform 0.2s;
}
.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}
@media (min-width: 980px) {
  .toast {
    bottom: 24px;
  }
}

/* gauge water surface */
.gauge-wave {
  animation: wave 5s ease-in-out infinite alternate;
}
@keyframes wave {
  from {
    transform: translateX(-10px);
  }
  to {
    transform: translateX(10px);
  }
}
.gauge-fill {
  transform-box: fill-box;
  transform-origin: bottom;
  animation: rise 0.9s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes rise {
  from {
    transform: scaleY(0.2);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}

.skeleton-line {
  height: 14px;
  border-radius: 6px;
  background: var(--surface-3);
  margin: 8px 0;
}

.leaflet-interactive:focus:not(:focus-visible) {
  outline: none;
}
