/* Layout: one calm column on phones; on wide screens the forecast on the left and the radar map
   pinned on the right. System fonts so it feels native on every device. */
:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #eef1f5;
  --ink: #111827;
  --muted: #5f6b7a;
  --line: #e1e6ec;
  --accent: #2563eb;
  --accent-ink: #ffffff;
  --ok: #15803d;
  --warn: #b45309;
  --alert: #c2410c;
  --rain-0: #c9e6fb;
  --rain-1: #5fb2f0;
  --rain-2: #2563eb;
  --rain-3: #6d3fd6;
  --rain-4: #d02670;
  --ring: rgba(55, 65, 81, 0.55);
  --pin: #2563eb;
  --pin-stroke: #ffffff;
  --pin-dot: #ffffff;
  --track: #2563eb;
  --shadow: 0 1px 2px rgba(17, 24, 39, 0.05), 0 2px 10px rgba(17, 24, 39, 0.05);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", Arial, sans-serif;
  --radius: 14px;
  --top-h: 60px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1220;
    --surface: #121b2b;
    --surface-2: #1a2536;
    --ink: #e8edf4;
    --muted: #9aa6b6;
    --line: #233046;
    --accent: #60a5fa;
    --accent-ink: #0b1220;
    --ok: #4ade80;
    --warn: #fbbf24;
    --alert: #fb923c;
    --rain-0: #22425c;
    --rain-1: #5fb7f5;
    --rain-2: #3b82f6;
    --rain-3: #8b5cf6;
    --rain-4: #f0569b;
    --ring: rgba(226, 232, 240, 0.5);
    --pin: #60a5fa;
    --pin-stroke: #0b1220;
    --pin-dot: #0b1220;
    --track: #93c5fd;
    --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b1220;
  --surface: #121b2b;
  --surface-2: #1a2536;
  --ink: #e8edf4;
  --muted: #9aa6b6;
  --line: #233046;
  --accent: #60a5fa;
  --accent-ink: #0b1220;
  --ok: #4ade80;
  --warn: #fbbf24;
  --alert: #fb923c;
  --rain-0: #22425c;
  --rain-1: #5fb7f5;
  --rain-2: #3b82f6;
  --rain-3: #8b5cf6;
  --rain-4: #f0569b;
  --ring: rgba(226, 232, 240, 0.5);
  --pin: #60a5fa;
  --pin-stroke: #0b1220;
  --pin-dot: #0b1220;
  --track: #93c5fd;
  --shadow: none;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 16px/1.5 var(--font);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
body::before {
  content: "";
  position: fixed;
  inset: 0 0 auto;
  height: env(safe-area-inset-top, 0px);
  z-index: 1001;
  background: var(--surface);
}
[hidden] { display: none !important; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--muted); }

/* ---------- top bar ---------- */
.top {
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 1000;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.top-inner {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 1280px;
  margin: 0 auto;
  min-height: var(--top-h);
  padding-block: 8px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.place {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  text-align: left;
}
.place:hover { background: var(--surface-2); }
.place .pin { width: 22px; height: 22px; color: var(--accent); flex: none; }
.place .chev { width: 18px; height: 18px; color: var(--muted); flex: none; }
.place-text { display: flex; flex-direction: column; min-width: 0; }
#loc-name { font-weight: 600; font-size: 17px; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.place .sub { font-size: 13px; color: var(--muted); line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 10px;
  border: 0;
  background: transparent;
  color: var(--ink);
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn.spin svg { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .icon-btn.spin svg { animation: none; } }
@media (max-width: 400px) { .top-inner { gap: 2px; } .icon-btn { width: 38px; } }

/* ---------- sheets (search, settings) ---------- */
.sheet {
  position: sticky;
  top: calc(var(--top-h) + env(safe-area-inset-top, 0px));
  z-index: 999;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.12);
}
.sheet-inner {
  max-width: 640px;
  margin: 0 auto;
  display: grid;
  gap: 12px;
  padding-block: 14px 16px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.search-row { display: flex; gap: 8px; }
.search-row input {
  flex: 1;
  min-width: 0;
  padding: 11px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface-2);
}
.btn {
  padding: 10px 16px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-weight: 600;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.results { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.results button { width: 100%; text-align: left; padding: 10px; border: 0; border-radius: 8px; background: transparent; }
.results button:hover, .results button:focus-visible { background: var(--surface-2); }
.results small { color: var(--muted); }
.setting { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.setting > span { font-weight: 600; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 8px; font-size: 15px; font-weight: 500; }
.seg button[aria-pressed="true"] { background: var(--surface); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15); font-weight: 600; }
.hint { margin: 0; font-size: 14px; color: var(--muted); }

/* ---------- page grid ---------- */
.page {
  max-width: 1280px;
  margin: 0 auto;
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(0, 1fr);
  padding-block: 16px 24px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.col-main, .col-side { display: grid; gap: 16px; align-content: start; min-width: 0; }
@media (min-width: 1000px) {
  .page { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
  .col-side { position: sticky; top: calc(var(--top-h) + 16px + env(safe-area-inset-top, 0px)); }
  .map { height: min(560px, calc(100vh - var(--top-h) - 200px)); }
}
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
  padding: 16px;
  min-width: 0;
}
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
h2 { margin: 0; font-size: 17px; font-weight: 600; }
.aside { font-size: 14px; color: var(--muted); }

/* ---------- summary ---------- */
.summary { padding: 18px 18px 16px; }
.status { display: inline-flex; align-items: center; gap: 8px; margin: 0; font-size: 14px; font-weight: 600; color: var(--muted); }
.status .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.status[data-state="dry"] .dot { background: var(--ok); }
.status[data-state="chance"] .dot { background: var(--warn); }
.status[data-state="incoming"] .dot { background: var(--rain-2); }
.status[data-state="raining"] .dot { background: var(--rain-2); }
.status[data-state="thunder"] .dot { background: var(--alert); }
.summary h1 {
  margin: 6px 0 6px;
  font-size: clamp(30px, 7vw, 40px);
  line-height: 1.12;
  font-weight: 700;
  letter-spacing: -0.01em;
  text-wrap: balance;
}
.detail { margin: 0; font-size: 17px; max-width: 60ch; text-wrap: pretty; }
.approach { margin: 8px 0 0; font-size: 15px; color: var(--muted); max-width: 60ch; }
.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}
.stat { background: var(--surface-2); border-radius: 12px; padding: 10px 12px; min-width: 0; display: flex; flex-direction: column; }
.stat .label { font-size: 13px; color: var(--muted); line-height: 1.3; }
.stat .value { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 2px; }
.stat .small { font-size: 13px; color: var(--muted); }
@media (max-width: 420px) {
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
  .stat { padding: 8px 9px; }
  .stat .label { font-size: 12px; }
  .stat .value { font-size: 19px; }
}
.notice {
  margin: 12px 0 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--surface-2);
  font-size: 14px;
}
.notice .btn { margin: 6px 6px 0 0; padding: 6px 12px; }
.meta { margin: 12px 0 0; font-size: 13px; color: var(--muted); display: flex; gap: 6px 14px; flex-wrap: wrap; }

/* ---------- charts & keys ---------- */
canvas { display: block; width: 100%; }
#nexthour-canvas { height: 120px; touch-action: pan-y; }
.key { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 10px; font-size: 13px; color: var(--muted); }
.key i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -2px; }

/* ---------- 5-hour strip ---------- */
.strip-wrap { overflow-x: auto; margin: 0 -16px; padding: 0 16px; scrollbar-width: thin; }
.strip { list-style: none; margin: 0; padding: 0 0 4px; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(64px, 1fr); gap: 6px; }
.slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 4px;
  border-radius: 12px;
  background: var(--surface-2);
  font-variant-numeric: tabular-nums;
  min-width: 64px;
}
.slot .t { font-size: 13px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.slot .t.now { color: var(--ink); }
.slot svg { width: 26px; height: 26px; }
.slot .p { font-size: 16px; font-weight: 700; }
.slot .p.low { color: var(--muted); font-weight: 500; }
.slot .i { font-size: 12px; color: var(--muted); white-space: nowrap; min-height: 1.5em; }
.slot .temp { font-size: 15px; font-weight: 600; }
.slot .w { font-size: 12px; color: var(--muted); white-space: nowrap; display: flex; align-items: center; gap: 2px; }
.slot .w svg { width: 11px; height: 11px; }
.slot .ts { font-size: 11px; font-weight: 700; color: var(--alert); text-align: center; line-height: 1.2; max-width: 56px; }

/* ---------- track record ---------- */
.sc-summary { margin: 0; font-size: 16px; max-width: 60ch; }
.track .stats { margin-top: 12px; }
.track .hint { margin-top: 10px; }
.sc-leads { display: grid; gap: 6px; margin-top: 12px; }
.sc-row { display: grid; grid-template-columns: 84px minmax(0, 1fr) 44px; align-items: center; gap: 10px; font-size: 14px; font-variant-numeric: tabular-nums; }
.sc-row span:last-child { text-align: right; font-weight: 600; }
.sc-bar { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.sc-bar i { display: block; height: 100%; background: var(--ok); }
.linkbtn { border: 0; background: none; padding: 0; color: var(--accent); font: inherit; text-decoration: underline; text-underline-offset: 2px; }

/* ---------- map ---------- */
.map {
  height: 380px;
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface-2);
}
@media (max-width: 520px) { .map { height: 340px; } }
.map-controls { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.map-controls input[type="range"] { flex: 1 1 auto; min-width: 0; accent-color: var(--accent); }
.leaflet-container { font-family: var(--font); background: var(--surface-2); }
.leaflet-control-attribution { font-size: 10px; }
.pw-pin { filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.35)); }
.pw-ring { stroke: var(--ring); }
.pw-track { stroke: var(--track); }
.pw-track-dot { stroke: var(--track); fill: var(--track); }
.pw-base-light { filter: grayscale(0.85) brightness(1.03) contrast(0.9); }
.pw-base-dark { filter: invert(1) hue-rotate(180deg) grayscale(0.7) brightness(0.78) contrast(1.15); }

/* ---------- about ---------- */
.about summary { cursor: pointer; list-style: none; display: flex; align-items: center; justify-content: space-between; font-size: 17px; font-weight: 600; }
.about summary::-webkit-details-marker { display: none; }
.about summary::after { content: "Show"; font-size: 14px; font-weight: 500; color: var(--accent); }
.about[open] summary::after { content: "Hide"; }
.facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 16px; margin: 14px 0 0; font-size: 15px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; min-width: 0; }
@media (max-width: 520px) { .facts { grid-template-columns: minmax(0, 1fr); gap: 2px; } .facts dd { margin-bottom: 10px; } }
.models { margin-top: 14px; display: grid; gap: 8px; }
.models h3 { margin: 0 0 2px; font-size: 15px; }
.model-row { display: grid; grid-template-columns: minmax(0, 150px) minmax(0, 1fr) auto; align-items: center; gap: 10px; font-size: 14px; }
.model-row .w { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.model-row .w i { display: block; height: 100%; background: var(--accent); }
.model-row .check { font-size: 13px; color: var(--muted); white-space: nowrap; }
.model-row .check.good { color: var(--ok); }
.model-row .check.poor { color: var(--alert); }
.method { font-size: 14px; color: var(--muted); max-width: 70ch; margin: 14px 0 0; }

.foot {
  max-width: 1280px;
  margin: 0 auto;
  padding-block: 0 28px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  font-size: 13px;
  color: var(--muted);
}
.foot p { margin: 4px 0; max-width: 90ch; }
.foot a { color: inherit; }
