:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --ink: #12161c;
  --muted: #5d6675;
  --line: #e2e6ec;
  --accent: #0d7ea8;
  --gust: #e0662e;
  --avg: #0d7ea8;
  --lull: #5aa469;
  --warn-bg: #fdf3d8;
  --warn-ink: #7a5b10;
  --warn-line: #e8cf8a;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --surface: #171b22;
    --ink: #f3f5fa;
    --muted: #8d95ac;
    --line: #262b35;
    --accent: #5bb8ef;
    --gust: #f0894f;
    --avg: #5bb8ef;
    --lull: #6fc98a;
    --warn-bg: #2e2612;
    --warn-ink: #f0d79a;
    --warn-line: #5a4a1e;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
.bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 18px 20px;
  border-bottom: 1px solid var(--line); background: var(--surface);
}
h1 { margin: 0; font-size: 1.25rem; letter-spacing: -0.01em; }
.sub { margin: 2px 0 0; color: var(--muted); font-size: 0.85rem; }
.unit {
  font: inherit; font-weight: 600; cursor: pointer;
  padding: 8px 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--bg); color: var(--ink);
  min-width: 64px;
}
.unit:hover { border-color: var(--accent); color: var(--accent); }
main { max-width: 1000px; margin: 0 auto; padding: 20px; }

.banner {
  margin-bottom: 16px; padding: 10px 14px; border-radius: 8px;
  background: var(--warn-bg); color: var(--warn-ink);
  border: 1px solid var(--warn-line); font-size: 0.9rem;
}

.cards {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; padding: 14px 16px;
  display: flex; flex-direction: column; gap: 2px;
}
.card.primary { outline: 2px solid var(--accent); outline-offset: -2px; }
.label {
  font-size: 0.72rem; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--muted);
}
.value {
  font-size: 2rem; font-weight: 650; line-height: 1.15;
  font-variant-numeric: tabular-nums;
}
.value.small { font-size: 1.25rem; }
.unit-label { font-size: 0.78rem; color: var(--muted); }
.dir-wrap { display: flex; align-items: center; gap: 10px; }
.compass { width: 42px; height: 42px; flex: none; }
.compass-ring { fill: none; stroke: var(--line); stroke-width: 2.5; }
.compass-arrow { fill: var(--accent); transform-origin: 24px 24px; transition: transform .4s ease; }

.updated { color: var(--muted); font-size: 0.82rem; margin: 14px 2px 22px; }

.chart-section {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; padding: 16px;
}
.chart-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-bottom: 12px;
}
.chart-head h2 { margin: 0; font-size: 1rem; }
.ranges { display: flex; gap: 4px; flex-wrap: wrap; }
.ranges button {
  font: inherit; font-size: 0.85rem; cursor: pointer;
  padding: 5px 11px; border-radius: 7px;
  border: 1px solid var(--line); background: transparent; color: var(--muted);
}
.ranges button:hover { color: var(--ink); }
.ranges button.active {
  background: var(--accent); border-color: var(--accent); color: #fff;
}
.chart-wrap { position: relative; width: 100%; overflow-x: auto; }
#chart { width: 100%; height: 300px; display: block; }
.empty { text-align: center; color: var(--muted); padding: 40px 0; margin: 0; }
.grid-line { stroke: var(--line); stroke-width: 1; }
.axis-text { fill: var(--muted); font-size: 11px; }
.series-gust { fill: none; stroke: var(--gust); stroke-width: 1.5; }
.series-avg  { fill: none; stroke: var(--avg);  stroke-width: 2; }
.series-lull { fill: none; stroke: var(--lull); stroke-width: 1.2; stroke-dasharray: 3 3; }
.band { fill: var(--avg); opacity: 0.10; }

.legend {
  display: flex; gap: 16px; flex-wrap: wrap;
  margin-top: 10px; font-size: 0.8rem; color: var(--muted);
}
.legend span { display: flex; align-items: center; gap: 6px; }
.sw { width: 14px; height: 3px; border-radius: 2px; display: inline-block; }
.sw.gust { background: var(--gust); }
.sw.avg { background: var(--avg); }
.sw.lull { background: var(--lull); }

.stats {
  display: grid; gap: 12px; margin-top: 18px;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
}
.stats > div {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; padding: 11px 13px;
  display: flex; flex-direction: column; gap: 3px;
}
.stats span:last-child {
  font-size: 1.1rem; font-weight: 600; font-variant-numeric: tabular-nums;
}
footer {
  max-width: 1000px; margin: 0 auto; padding: 22px 20px 40px;
  color: var(--muted); font-size: 0.8rem;
}
footer a { color: var(--accent); }

/* --- live camera --- */
.cam {
  margin-top: 18px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 12px; padding: 16px;
}
.cam-note { font-size: 0.78rem; color: var(--muted); }
.cam-frame {
  position: relative; margin: 0; border-radius: 10px; overflow: hidden;
  background: linear-gradient(160deg, #1b3a4b, #0d1f2a);
  aspect-ratio: 16 / 9; display: flex; align-items: center; justify-content: center;
}
.cam-frame img, .cam-frame iframe {
  width: 100%; height: 100%; object-fit: cover; display: block; border: 0;
}
.cam-frame img { transition: opacity .4s ease; }
.cam-frame.loading img { opacity: 0.35; }
.cam-fallback { position: absolute; color: #cbd5e1; font-size: 0.9rem; }

/* Overlay play control. The stream page carries third-party analytics, so it
   is loaded only on an explicit click rather than on every page view. */
.cam-play {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  display: flex; align-items: center; gap: 10px;
  font: inherit; font-weight: 600; font-size: 0.92rem; cursor: pointer;
  padding: 11px 20px 11px 16px; border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.35); color: #fff;
  background: rgba(10, 18, 26, 0.62);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  transition: background .2s ease, transform .15s ease;
}
.cam-play:hover { background: rgba(10, 18, 26, 0.82); transform: translate(-50%, -50%) scale(1.04); }
.cam-play:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.cam-play-icon {
  width: 0; height: 0; flex: none;
  border-left: 13px solid #fff;
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
}
@media (prefers-reduced-motion: reduce) {
  .cam-frame img, .cam-play { transition: none; }
  .cam-play:hover { transform: translate(-50%, -50%); }
}

/* --- next-update countdown --- */
.status-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; flex-wrap: wrap; margin: 14px 2px 22px;
}
.status-row .updated { margin: 0; }
.countdown {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.8rem; color: var(--muted); font-variant-numeric: tabular-nums;
}
.cd-ring { width: 20px; height: 20px; flex: none; transform: rotate(-90deg); }
.cd-track { fill: none; stroke: var(--line); stroke-width: 3.5; }
.cd-fill {
  fill: none; stroke: var(--accent); stroke-width: 3.5; stroke-linecap: round;
  stroke-dasharray: 97.4; stroke-dashoffset: 0;
  transition: stroke-dashoffset .95s linear;
}
/* While backing off the ring stops meaning "almost there", so de-emphasise it. */
.countdown.waiting { color: var(--warn-ink); }
.countdown.waiting .cd-fill { stroke: var(--warn-ink); transition: none; }
@media (prefers-reduced-motion: reduce) { .cd-fill { transition: none; } }

/* --- chart scrubbing --- */
#chart {
  /* Let the page scroll vertically while horizontal drags scrub the chart. */
  touch-action: pan-y;
  cursor: crosshair;
  -webkit-tap-highlight-color: transparent;
}
#chart:focus { outline: none; }
#chart:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.hover-line { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; opacity: 0.8; }
.hover-dot { stroke: var(--surface); stroke-width: 2; }
.hover-dot.gust { fill: var(--gust); }
.hover-dot.avg  { fill: var(--avg); }
.hover-dot.lull { fill: var(--lull); }

.tip {
  position: absolute; top: 8px; z-index: 2;
  min-width: 132px; padding: 9px 11px;
  border-radius: 9px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.16);
  font-size: 0.8rem; pointer-events: none;
  transform: translateX(-50%);
}
.tip-time {
  font-size: 0.72rem; color: var(--muted);
  margin-bottom: 6px; white-space: nowrap;
}
.tip-row {
  display: flex; align-items: center; gap: 7px;
  justify-content: space-between; line-height: 1.7; white-space: nowrap;
}
.tip-row .k { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.tip-row .v { font-weight: 650; font-variant-numeric: tabular-nums; }
.tip-row i { width: 9px; height: 9px; border-radius: 2px; display: inline-block; flex: none; }
.tip-row i.gust { background: var(--gust); }
.tip-row i.avg  { background: var(--avg); }
.tip-row i.lull { background: var(--lull); }
.tip-hint {
  margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--line);
  font-size: 0.68rem; color: var(--muted); white-space: nowrap;
}
