/* Weather station — the page. System sans, one card language, light and
   dark from the same tokens. Chart colours are the validated defaults from
   the house's data-viz palette; series are never coloured by rank. */

:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11,11,11,0.10);
  --accent: #2a78d6;
  --temp: #eb6834;
  --rain: #2a78d6;
  --wind: #2a78d6;
  --gust: #eb6834;
  --pressure: #4a3aa7;
  --humidity: #1baf7a;
  --solar: #eda100;
  --good: #0ca30c;
  --warn: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255,255,255,0.10);
    --accent: #3987e5;
    --temp: #d95926;
    --rain: #3987e5;
    --wind: #3987e5;
    --gust: #d95926;
    --pressure: #9085e9;
    --humidity: #199e70;
    --solar: #c98500;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--page);
  color: var(--ink);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
  padding: 0 16px calc(24px + env(safe-area-inset-bottom));
  -webkit-text-size-adjust: 100%;
}
h1 { font-size: 20px; margin: 0; font-weight: 650; letter-spacing: -0.01em; }
h2 { font-size: 13px; margin: 0 0 8px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-2); }
h3 { font-size: 14px; margin: 0 0 6px; font-weight: 600; color: var(--ink-2); }
main { max-width: 1100px; margin: 0 auto; }
.top { max-width: 1100px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 0 12px; }
.top-right { display: flex; gap: 8px; }
.sub { color: var(--muted); font-size: 13px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }

.btn {
  font: inherit; font-weight: 600; border-radius: 10px; padding: 8px 14px; cursor: pointer;
  background: var(--accent); color: #fff; border: 1px solid transparent;
}
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--border); }
.btn.ghost:hover { border-color: var(--axis); }
.btn:disabled { opacity: .5; cursor: default; }

.alerts { display: grid; gap: 8px; margin-bottom: 14px; }
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 10px 14px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); }
.alert .dot { flex: none; width: 10px; height: 10px; border-radius: 50%; margin-top: 6px; }
.alert.info .dot { background: var(--accent); }
.alert.warn .dot { background: var(--warn); }
.alert.alarm .dot { background: var(--critical); }
.alert .lvl { font-weight: 600; margin-right: 4px; }

.hero { margin-bottom: 14px; }
.hero-main { display: flex; align-items: center; gap: 28px; flex-wrap: wrap; }
.hero-temp { font-size: 76px; font-weight: 300; letter-spacing: -0.03em; line-height: 1; }
.hero-unit { font-size: 28px; color: var(--muted); margin-left: 4px; vertical-align: top; }
.hero-side { display: grid; gap: 4px; }
.hero-foot { color: var(--ink-2); margin-top: 12px; }
.kv { display: flex; gap: 8px; align-items: baseline; }
.kv .k { color: var(--muted); min-width: 84px; font-size: 13px; }
.kv .v { font-variant-numeric: tabular-nums; }
.k.small { min-width: 0; font-size: 12px; }
.big { font-size: 28px; font-weight: 500; letter-spacing: -0.01em; margin-bottom: 6px; }
.big .unit { font-size: 15px; color: var(--muted); font-weight: 400; }
.big .k { font-size: 13px; color: var(--muted); font-weight: 400; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 12px; margin-bottom: 22px; }
.wind-row { display: flex; gap: 14px; align-items: center; }
.compass { width: 84px; height: 84px; flex: none; }
.compass-ring { fill: none; stroke: var(--grid); stroke-width: 2; }
.compass-pt { font-size: 11px; fill: var(--muted); text-anchor: middle; dominant-baseline: middle; }
.compass-arrow polygon { fill: var(--wind); }
.compass-arrow line { stroke: var(--wind); stroke-width: 3; stroke-linecap: round; }
.compass-arrow { transition: transform .6s ease; transform-origin: 50px 50px; }

.charts-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.ranges { display: flex; gap: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 3px; }
.ranges button { font: inherit; font-size: 13px; padding: 5px 10px; border: 0; background: transparent; color: var(--ink-2); border-radius: 7px; cursor: pointer; }
.ranges button.on { background: var(--accent); color: #fff; }
.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 12px; margin-bottom: 22px; }
.charts h2 { margin: 0; }
.chart .plot { position: relative; height: 200px; }
.chart svg { display: block; width: 100%; height: 100%; overflow: visible; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .baseline { stroke: var(--axis); stroke-width: 1; }
.chart .tick { fill: var(--muted); font-size: 11px; }
.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .band { opacity: .18; }
.chart .area { opacity: .22; }
.chart .bar { rx: 2; }
.chart .crosshair { stroke: var(--axis); stroke-width: 1; stroke-dasharray: 3 3; pointer-events: none; }
.chart .marker { stroke: var(--surface); stroke-width: 2; pointer-events: none; }
.chart .hit { fill: transparent; cursor: crosshair; }
.chart .empty { fill: var(--muted); font-size: 13px; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--ink-2); margin-top: 4px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.tooltip {
  position: fixed; z-index: 10; pointer-events: none; background: var(--surface); color: var(--ink);
  border: 1px solid var(--border); border-radius: 8px; padding: 6px 9px; font-size: 12px; line-height: 1.4;
  box-shadow: 0 6px 18px rgba(0,0,0,.14); white-space: nowrap;
}
.tooltip b { font-variant-numeric: tabular-nums; }

.upkeep { margin-bottom: 20px; }
.tasks { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.task { display: flex; flex-direction: column; gap: 8px; }
.task .head { display: flex; align-items: center; gap: 8px; }
.task .state { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--border); color: var(--ink-2); }
.task.ok .state { color: #006300; border-color: transparent; background: color-mix(in srgb, var(--good) 14%, transparent); }
@media (prefers-color-scheme: dark) { .task.ok .state { color: var(--good); } }
.task.soon .state { background: color-mix(in srgb, var(--warn) 22%, transparent); border-color: transparent; }
.task.due .state { background: color-mix(in srgb, var(--serious) 22%, transparent); border-color: transparent; }
.task.overdue .state { background: color-mix(in srgb, var(--critical) 22%, transparent); border-color: transparent; }
.task .label { font-weight: 600; }
.task .how { color: var(--ink-2); font-size: 13px; }
.task .when { color: var(--muted); font-size: 13px; }
.task .actions { margin-top: auto; }
.log-wrap { margin-top: 12px; color: var(--ink-2); }
.log { margin: 8px 0 0; padding-left: 18px; font-size: 13px; }
.log li { margin: 2px 0; }

.foot { max-width: 1100px; margin: 0 auto; color: var(--muted); font-size: 12px; padding-top: 8px; }

dialog { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--ink); padding: 20px; width: min(92vw, 380px); }
dialog::backdrop { background: rgba(0,0,0,.35); }
dialog h2 { font-size: 16px; text-transform: none; letter-spacing: 0; color: var(--ink); }
dialog input { width: 100%; font: inherit; padding: 9px 11px; border-radius: 9px; border: 1px solid var(--axis); background: var(--page); color: var(--ink); margin: 8px 0; }
dialog .row { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.err { color: var(--critical); font-size: 13px; margin: 4px 0; }
.stale { opacity: .6; }
.tone-warn { color: var(--serious); }
.tone-good { color: var(--good); }
[hidden] { display: none !important; }

@media (max-width: 560px) {
  .hero-temp { font-size: 60px; }
  .hero-main { gap: 16px; }
  .top { padding-top: 12px; }
}
