:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f2f1ed;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --gridline: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);

  --blue: #2a78d6;
  --orange: #eb6834;
  --aqua: #1baf7a;
  --yellow: #eda100;
  --magenta: #e87ba4;
  --green: #008300;
  --violet: #4a3aa7;
  --red: #e34948;

  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;

  --series-temp: var(--blue);
  --series-hum: var(--aqua);
  --series-press: var(--violet);
  --series-wind: var(--orange);
  --series-rain: #2a78d6;
  --series-dew: var(--yellow);
  --series-gust: var(--magenta);
  --series-rainrate: var(--red);

  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow-card: 0 1px 2px rgba(11,11,11,0.04), 0 8px 24px -12px rgba(11,11,11,0.12);
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #232322;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #898781;
    --gridline: #2c2c2a;
    --baseline: #383835;
    --border: rgba(255,255,255,0.10);

    --blue: #3987e5;
    --orange: #d95926;
    --aqua: #199e70;
    --yellow: #c98500;
    --magenta: #d55181;
    --green: #008300;
    --violet: #9085e9;
    --red: #e66767;

    --good: #0ca30c;
    --warning: #fab219;
    --serious: #ec835a;
    --critical: #e66767;

    --series-rain: #3987e5;
    --shadow-card: 0 1px 2px rgba(0,0,0,0.3), 0 8px 24px -12px rgba(0,0,0,0.5);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --surface-2: #232322;
  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted: #898781;
  --gridline: #2c2c2a;
  --baseline: #383835;
  --border: rgba(255,255,255,0.10);

  --blue: #3987e5;
  --orange: #d95926;
  --aqua: #199e70;
  --yellow: #c98500;
  --magenta: #d55181;
  --green: #008300;
  --violet: #9085e9;
  --red: #e66767;

  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #e66767;

  --series-rain: #3987e5;
  --shadow-card: 0 1px 2px rgba(0,0,0,0.3), 0 8px 24px -12px rgba(0,0,0,0.5);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--page);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--blue); }

.page {
  max-width: 1180px;
  margin: 0 auto;
  padding: 20px 20px 60px;
}

/* ---------- Topbar ---------- */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  font-size: 26px;
  line-height: 1;
}
.brand-text h1 {
  font-size: 18px;
  margin: 0;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.station-line {
  margin: 2px 0 0;
  font-size: 12.5px;
  color: var(--text-muted);
}
.topbar-actions { display: flex; align-items: center; gap: 14px; }
.clock {
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  color: var(--text-secondary);
  min-width: 6ch;
  text-align: right;
}
.theme-toggle {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-secondary);
  width: 34px; height: 34px;
  border-radius: 999px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.theme-toggle:hover { color: var(--text-primary); }

/* ---------- Alert banner ---------- */
.alert-banner {
  background: var(--critical);
  color: #fff;
  padding: 10px 20px;
  font-size: 14px;
}
.alert-banner.warning { background: var(--warning); color: #1a1200; }
.alert-banner-inner {
  max-width: 1180px;
  margin: 0 auto;
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}
.alert-banner strong { font-weight: 700; }

/* ---------- Hero ---------- */
.hero {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 16px;
  margin-top: 20px;
}
@media (max-width: 860px) {
  .hero { grid-template-columns: 1fr; }
}

.cam-panel {
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border);
}
.cam-frame {
  position: relative;
  background: #000;
  aspect-ratio: 16 / 9;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cam-frame img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.cam-badge {
  position: absolute;
  top: 12px; left: 12px;
  background: rgba(0,0,0,0.55);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 5px 10px 5px 8px;
  border-radius: 999px;
  display: flex; align-items: center; gap: 6px;
  backdrop-filter: blur(4px);
}
.live-dot {
  width: 8px; height: 8px;
  border-radius: 999px;
  background: var(--red);
  display: inline-block;
  box-shadow: 0 0 0 rgba(227,73,72,0.6);
  animation: pulse 2s infinite;
}
.live-dot.small { width: 7px; height: 7px; }
.live-dot.ok { background: var(--good); }
.live-dot.stale { background: var(--warning); animation: none; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(227,73,72,0.55); }
  70% { box-shadow: 0 0 0 8px rgba(227,73,72,0); }
  100% { box-shadow: 0 0 0 0 rgba(227,73,72,0); }
}

.now-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.now-top {
  display: flex;
  align-items: flex-start;
  gap: 16px;
}
.now-temp {
  font-size: 64px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.02em;
  white-space: nowrap;
}
.now-temp .deg { font-size: 30px; font-weight: 500; color: var(--text-secondary); }
.now-meta { padding-top: 6px; }
.now-cond { font-size: 19px; font-weight: 600; }
.now-feels { font-size: 16px; color: var(--text-secondary); margin-top: 4px; }
.now-updated {
  font-size: 15px; color: var(--text-muted);
  margin-top: 9px;
  display: flex; align-items: center; gap: 6px;
}

.now-body {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 20px;
  border-top: 1px solid var(--gridline);
  padding-top: 16px;
}

.now-grid {
  flex: 1;
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.now-tile {
  background: var(--surface-2);
  border-radius: var(--radius-md);
  padding: 12px 14px;
}
.now-tile-label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.03em; white-space: nowrap; }
.now-tile-value { font-size: 22px; font-weight: 700; margin-top: 3px; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Stays side-by-side at phone widths too (per request) — the gauge and tiles
   both shrink instead of stacking, since the SVG scales cleanly via its
   viewBox and only the HTML text sizes need explicit overrides here. */
@media (max-width: 600px) {
  .now-body { gap: 10px; }
  .gauge-ring-wrap { width: 128px; height: 128px; }
  .gauge-speed-value { font-size: 30px; }
  .gauge-speed-unit { font-size: 11px; }
  .gauge-gust-line { font-size: 10.5px; margin-top: 6px; }
  .gauge-below { margin-top: -4px; }
  .gauge-dir-readout { font-size: 15px; }
  .gauge-dir-deg { font-size: 11px; margin-left: 4px; }
  .gauge-peak-today { font-size: 10.5px; margin-top: 3px; }

  .now-tile-desktop-only { display: none; }
  .now-grid { grid-template-columns: 1fr; gap: 8px; }
  .now-tile { padding: 9px 12px; }
  .now-tile-label { font-size: 10.5px; white-space: normal; }
  .now-tile-value { font-size: 18px; }
}

/* ---------- Wind gauge ---------- */
.wind-gauge {
  flex: 0 0 auto;
  align-self: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.gauge-ring-wrap {
  position: relative;
  width: 190px;
  height: 190px;
}
.gauge-svg { width: 100%; height: 100%; }
.gauge-ring { fill: none; stroke: var(--series-wind); stroke-width: 2.5; }
.gauge-ticks line { stroke: var(--baseline); stroke-width: 2; }
.gauge-dir-label { fill: var(--text-muted); font-size: 14px; font-weight: 700; text-anchor: middle; dominant-baseline: middle; }
.gauge-marker { fill: var(--series-wind); }
#windMarker {
  transform-box: view-box;
  transform-origin: 100px 100px;
  transition: transform 0.6s ease;
}
.gauge-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.gauge-speed-value { font-size: 48px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.gauge-speed-unit { font-size: 18px; color: var(--text-muted); margin-top: 3px; }
.gauge-gust-line { font-size: 15px; color: var(--text-secondary); margin-top: 14px; }
.gauge-gust-line strong { font-variant-numeric: tabular-nums; }
.gauge-below { text-align: center; }
.gauge-dir-readout { font-size: 26px; font-weight: 700; }
.gauge-dir-deg { font-size: 18px; font-weight: 500; color: var(--text-muted); margin-left: 6px; }
.gauge-peak-today { font-size: 18px; color: var(--text-secondary); margin-top: 5px; }
.gauge-peak-today strong { font-variant-numeric: tabular-nums; }

/* ---------- Section titles ---------- */
.section-title {
  font-size: 15px;
  font-weight: 700;
  margin: 0 0 12px;
  letter-spacing: -0.01em;
}
.strip-section, .history-section { margin-top: 34px; }
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

/* ---------- Forecast strip ---------- */
.forecast-strip, .hourly-strip {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 6px;
  scrollbar-width: thin;
}
.skeleton-row { color: var(--text-muted); font-size: 13px; padding: 20px 0; }
.fc-card {
  flex: 0 0 auto;
  width: 156px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 12px;
  text-align: center;
  box-shadow: var(--shadow-card);
}
.fc-card .fc-name { font-size: 14px; font-weight: 700; color: var(--text-secondary); }
.fc-card img { width: 60px; height: 60px; margin: 8px 0; }
.fc-card .fc-temp { font-size: 23px; font-weight: 700; }
.fc-card .fc-pop { font-size: 13px; color: var(--blue); margin-top: 3px; min-height: 16px; }
.fc-card .fc-short { font-size: 13px; color: var(--text-muted); margin-top: 5px; line-height: 1.35; }

.hr-card {
  flex: 0 0 auto;
  width: 96px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 8px;
  text-align: center;
  box-shadow: var(--shadow-card);
}
.hr-card .hr-time { font-size: 13px; color: var(--text-muted); }
.hr-card img { width: 40px; height: 40px; margin: 6px 0; }
.hr-card .hr-temp { font-size: 19px; font-weight: 700; }
.hr-card .hr-pop { font-size: 12.5px; color: var(--blue); min-height: 15px; }

/* ---------- Range picker ---------- */
.range-picker {
  display: inline-flex;
  background: var(--surface-2);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}
.range-picker button {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 12.5px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
}
.range-picker button.active {
  background: var(--surface);
  color: var(--text-primary);
  box-shadow: 0 1px 2px rgba(11,11,11,0.12);
}

/* ---------- Charts ---------- */
.chart-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 14px;
}
@media (max-width: 760px) {
  .chart-grid { grid-template-columns: 1fr; }
}
.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 14px 16px 8px;
}
.chart-card.wide { grid-column: 1 / -1; }
.chart-card-head {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.swatch {
  width: 10px; height: 10px;
  border-radius: 3px;
  background: var(--sw);
  display: inline-block;
}
.chart-wrap { height: 220px; position: relative; }

/* ---------- Wind rose ---------- */
.windrose-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding-bottom: 6px;
}
.windrose-svg { width: 200px; height: 200px; max-width: 100%; }
.windrose-ring { fill: none; stroke: var(--gridline); stroke-width: 1; }
.windrose-tick-label { fill: var(--text-muted); font-size: 8px; text-anchor: middle; }
.windrose-dir-label { fill: var(--text-secondary); font-size: 10px; font-weight: 700; text-anchor: middle; dominant-baseline: middle; }
.windrose-calm-label { fill: var(--text-primary); font-size: 11px; font-weight: 700; text-anchor: middle; dominant-baseline: middle; }
.windrose-calm-sub { fill: var(--text-muted); font-size: 7.5px; text-anchor: middle; dominant-baseline: middle; }
.windrose-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 12px;
}
.windrose-legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--text-secondary);
}
.windrose-legend-swatch {
  width: 10px; height: 10px;
  border-radius: 3px;
  display: inline-block;
}
.windrose-caption {
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
}

/* ---------- Radar ---------- */
.radar-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 10px;
  display: flex;
  justify-content: center;
}
.radar-panel img { max-width: 100%; border-radius: var(--radius-md); display: block; }

/* ---------- Footer ---------- */
.site-footer {
  text-align: center;
  padding: 30px 20px 50px;
  font-size: 12.5px;
  color: var(--text-muted);
}
.site-footer p { margin: 4px 0; }
