:root {
  --bg: #f2f6f8;
  --card: #ffffff;
  --ink: #14242e;
  --muted: #61788a;
  --brand: #0e2a3a;
  --accent: #1273b5;
  --rising: #d9650b;
  --falling: #1e8a4c;
  --steady: #1273b5;
  --stale: #9aa7af;
  --danger: #c0392b;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%; }

.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 0.85rem; }

.view { max-width: 720px; margin: 0 auto; padding-bottom: 40px; }

.app-header {
  background: var(--brand); color: #fff;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) 16px 12px;
  display: flex; align-items: center; gap: 10px;
  position: sticky; top: 0; z-index: 1000;
}
.app-header h1 { font-size: 1.15rem; margin: 0; flex: 1; font-weight: 600; }
.updated { font-size: 0.75rem; opacity: 0.75; }

.icon-btn {
  background: none; border: none; color: inherit; font-size: 1.6rem;
  line-height: 1; padding: 4px 10px; cursor: pointer;
}

#map { height: 46vh; min-height: 280px; z-index: 1; }

.banner { margin: 10px 12px 0; padding: 10px 14px; border-radius: 10px;
  background: #fff6e8; border: 1px solid #eccb96; font-size: 0.9rem; }

#station-list { padding: 10px 12px; }
.river-group h3 { margin: 14px 4px 6px; font-size: 0.85rem; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.05em; }
.station-row {
  background: var(--card); border-radius: 12px; padding: 12px 14px; margin-bottom: 8px;
  display: flex; align-items: center; gap: 12px; cursor: pointer;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}
.station-row .dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.station-row .s-name { flex: 1; font-size: 0.95rem; }
.station-row .s-height { font-weight: 700; font-variant-numeric: tabular-nums; }
.station-row .s-trend { font-size: 0.8rem; width: 56px; text-align: right; }
.trend-rising { color: var(--rising); }
.trend-falling { color: var(--falling); }
.trend-steady { color: var(--steady); }
.trend-stale { color: var(--stale); }

.credits { padding: 16px 16px calc(env(safe-area-inset-bottom, 0px) + 16px);
  font-size: 0.72rem; color: var(--muted); }

.card {
  background: var(--card); border-radius: 14px; margin: 12px;
  padding: 14px 16px; box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}
.card h2 { font-size: 1rem; margin: 0 0 8px; }

.current .big-height { font-size: 2.6rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.current .unit { font-size: 1.1rem; font-weight: 400; color: var(--muted); }
.current .sub { color: var(--muted); font-size: 0.9rem; }
.record { margin-top: 10px; font-size: 0.88rem; }
.pct-bar { height: 8px; border-radius: 4px; background: #e3ebf0; overflow: hidden; margin-bottom: 6px; }
.pct-fill { height: 100%; border-radius: 4px; min-width: 2px; }

.s-nums { display: flex; flex-direction: column; align-items: flex-end; }
.s-pct { font-size: 0.72rem; font-weight: 600; }

.floodclass { margin-top: 8px; font-size: 0.85rem; }
.floodclass span { display: inline-block; margin-right: 10px; }

.range-btns { display: flex; gap: 6px; margin-bottom: 10px; flex-wrap: wrap; }
.range-btns button {
  border: 1px solid #d4dee5; background: #fff; border-radius: 8px;
  padding: 6px 12px; font-size: 0.85rem; cursor: pointer; color: var(--ink);
}
.range-btns button.active { background: var(--accent); border-color: var(--accent); color: #fff; }

#chart { width: 100%; }

button.primary, label.primary {
  background: var(--accent); color: #fff; border: none; border-radius: 10px;
  padding: 10px 16px; font-size: 0.95rem; cursor: pointer; display: inline-block;
}
button.danger { background: var(--danger); color: #fff; border: none;
  border-radius: 10px; padding: 10px 16px; font-size: 0.9rem; cursor: pointer; }
button:disabled, label.disabled { opacity: 0.5; pointer-events: none; }

.alert-add, .lookup-row { display: flex; gap: 8px; margin-top: 10px; }
.alert-add input, .lookup-row input {
  flex: 1; min-width: 0; border: 1px solid #d4dee5; border-radius: 10px;
  padding: 10px 12px; font-size: 1rem;
}

.alert-row { display: flex; align-items: center; gap: 10px; padding: 8px 0;
  border-bottom: 1px solid #eef2f5; }
.alert-row .a-desc { flex: 1; font-size: 0.92rem; }
.alert-row .a-state { font-size: 0.75rem; color: var(--muted); }
.alert-row button { background: none; border: none; color: var(--danger);
  font-size: 1.2rem; cursor: pointer; padding: 4px 8px; }

.event-row { padding: 8px 0; border-bottom: 1px solid #eef2f5; font-size: 0.92rem; }
.event-row .e-peak { font-weight: 700; }
.event-row .e-ago { color: var(--muted); font-size: 0.8rem; }

#photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 8px; margin-top: 12px; }
.photo-cell { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden;
  cursor: pointer; background: #e6edf1; }
.photo-cell img { width: 100%; height: 100%; object-fit: cover; }
.photo-cell .ph-height {
  position: absolute; left: 6px; bottom: 6px; background: rgba(14,42,58,0.85);
  color: #fff; font-size: 0.78rem; font-weight: 700; padding: 2px 7px; border-radius: 6px;
}

.modal { position: fixed; inset: 0; background: rgba(8,16,22,0.96); z-index: 2000;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 20px; gap: 12px; }
.modal img { max-width: 100%; max-height: 65vh; border-radius: 8px; }
.modal .close { position: absolute; top: calc(env(safe-area-inset-top, 0px) + 8px);
  right: 12px; color: #fff; font-size: 2rem; }
#photo-meta { color: #fff; text-align: center; font-size: 0.9rem; }

.toast { position: fixed; bottom: calc(env(safe-area-inset-bottom, 0px) + 24px);
  left: 50%; transform: translateX(-50%); background: var(--brand); color: #fff;
  padding: 10px 18px; border-radius: 10px; font-size: 0.9rem; z-index: 3000;
  max-width: 90vw; text-align: center; }

.marker-label {
  background: rgba(255,255,255,0.92); border: 1px solid rgba(0,0,0,0.15);
  border-radius: 6px; padding: 1px 5px; font-size: 11px; font-weight: 700;
  color: var(--ink); white-space: nowrap; box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
