:root {
  --bg: #f3f6f5;
  --surface: #ffffff;
  --text: #13201e;
  --muted: #5b6b68;
  --line: #dbe3e1;
  --brand: #0f5c57;
  --brand-ink: #ffffff;
  --accent: #1b8a7e;
  --star: #e0a100;
  --warn-bg: #fff4d6;
  --warn-ink: #7a5600;
  --err-bg: #fde8e6;
  --err-ink: #9b1c12;
  --radius: 14px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1514;
    --surface: #17211f;
    --text: #e6eeec;
    --muted: #9aaba7;
    --line: #2a3734;
    --brand: #13312e;
    --brand-ink: #e6eeec;
    --accent: #5cc3b4;
    --star: #f2c14e;
    --warn-bg: #3a2f10;
    --warn-ink: #f2d58a;
    --err-bg: #3d1714;
    --err-ink: #ffb4ab;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
[hidden] { display: none !important; }
a { color: var(--accent); }
.muted { color: var(--muted); }

.top {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--brand);
  color: var(--brand-ink);
  padding: env(safe-area-inset-top) 16px 0;
}
.top-row { display: flex; align-items: center; justify-content: space-between; min-height: 52px; }
.top h1 { margin: 0; font-size: 1.2rem; font-weight: 650; }
.icon-btn {
  width: 44px; height: 44px; margin-right: -10px;
  display: grid; place-items: center;
  background: none; border: 0; color: inherit; border-radius: 50%;
}
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn.spinning svg { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.tabs { display: flex; gap: 4px; }
.tabs a {
  flex: 1; text-align: center; padding: 10px 0 12px;
  color: inherit; text-decoration: none; opacity: 0.75; font-weight: 550;
  border-bottom: 3px solid transparent;
}
.tabs a.active { opacity: 1; border-bottom-color: currentColor; }

main { max-width: 640px; margin: 0 auto; padding: 16px; }
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.card h2 { margin: 0 0 6px; font-size: 1.15rem; }
form.card { display: grid; gap: 6px; margin-bottom: 16px; }
label { font-weight: 600; font-size: 0.9rem; margin-top: 8px; }
input, select {
  width: 100%;
  font: inherit; font-size: 16px; /* 16px stops iPhone zooming in */
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
}
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
.hint { margin: 2px 0 0; font-size: 0.85rem; min-height: 1em; }
button.primary, a.button.primary {
  margin-top: 12px;
  display: block; text-align: center; text-decoration: none;
  font: inherit; font-weight: 650;
  padding: 12px; border: 0; border-radius: 10px;
  background: var(--accent); color: #fff;
}
button.primary:disabled { opacity: 0.6; }
@media (prefers-color-scheme: dark) { button.primary, a.button.primary { color: #0e1514; } }

.banner { border-radius: 10px; padding: 10px 12px; margin: 0 0 12px; }
.banner.error { background: var(--err-bg); color: var(--err-ink); }
.updated { font-size: 0.85rem; margin: 0 0 10px; }
.list { display: grid; gap: 12px; }
.river-head { margin: 10px 2px -2px; font-size: 0.95rem; color: var(--muted); font-weight: 650; }

.gauge { padding: 14px 14px 12px; }
.gauge-top { display: flex; gap: 8px; align-items: flex-start; }
.gauge-name { flex: 1; min-width: 0; }
.gauge-name h3 { margin: 0; font-size: 1rem; line-height: 1.3; }
.gauge-name .sub { font-size: 0.82rem; }
.star {
  flex: none; width: 44px; height: 44px; margin: -10px -8px 0 0;
  display: grid; place-items: center;
  background: none; border: 0; color: var(--muted); font-size: 1.6rem; line-height: 1;
}
.star[aria-pressed="true"] { color: var(--star); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.stat { background: var(--bg); border-radius: 10px; padding: 8px 10px; min-width: 0; }
.stat .label { font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }
.stat .value { font-size: 1.35rem; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.stat .unit { font-size: 0.8rem; font-weight: 500; color: var(--muted); margin-left: 2px; }
.stat .alt { font-size: 0.78rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.stat.none .value { color: var(--muted); font-weight: 500; font-size: 1rem; padding-top: 4px; }
.gauge-foot { display: flex; justify-content: space-between; gap: 8px; margin-top: 8px; font-size: 0.8rem; }
.gauge-foot .stale { color: var(--warn-ink); background: var(--warn-bg); border-radius: 6px; padding: 0 6px; }

.empty { text-align: center; }
.foot { text-align: center; font-size: 0.8rem; padding: 8px 16px 24px; }
