/* Weather dashboard — system fonts, no external requests, light/dark via light-dark(). */
:root {
  color-scheme: light dark;
  --bg: light-dark(#eef2f7, #0a0f16);
  --card: light-dark(#ffffff, #121a24);
  --card2: light-dark(#f4f7fb, #182332);
  --line: light-dark(#dbe2ea, #223042);
  --text: light-dark(#0f1b2a, #e8eef6);
  --muted: light-dark(#566678, #8fa0b5);
  --accent: light-dark(#1d6fdc, #5aa9ff);
  --warn: light-dark(#b45309, #fbbf24);
  --bad: light-dark(#c62828, #ff6b6b);

  --c-temp: light-dark(#e2570b, #ff8a3d);
  --c-feels: light-dark(#b7791f, #f5c451);
  --c-hum: light-dark(#0b7bc4, #4fb3ff);
  --c-dew: light-dark(#0d9488, #3dd6c0);
  --c-baro: light-dark(#7c3aed, #b794ff);
  --c-wind: light-dark(#0e7490, #3ccbe6);
  --c-gust: light-dark(#be185d, #ff7ab8);
  --c-rain: light-dark(#1d4ed8, #6ea8ff);
  --c-cum: light-dark(#0f766e, #34d399);
  --c-solar: light-dark(#d97706, #ffc233);
  --c-uv: light-dark(#a21caf, #e879f9);
  --c-nws: light-dark(#1d4ed8, #6ea8ff);
  --c-om: light-dark(#7c3aed, #b794ff);
  --c-adj: light-dark(#0f766e, #34d399);

  --radius: 16px;
  --shadow: 0 1px 2px light-dark(rgb(15 27 42 / .06), rgb(0 0 0 / .35)), 0 8px 24px light-dark(rgb(15 27 42 / .05), rgb(0 0 0 / .25));
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.4; }
h1, h2, h3, p { margin: 0; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }
b { font-weight: 650; }
.muted { color: var(--muted); }
.k { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
.unit { color: var(--muted); font-size: .5em; font-weight: 500; margin-left: 2px; }
.t { color: var(--muted); font-size: 12px; }

/* ---------- header ---------- */
.top, main, .foot { max-width: 1240px; margin-inline: auto; padding-inline: max(16px, env(safe-area-inset-left)); }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: max(14px, env(safe-area-inset-top)); padding-bottom: 8px; }
.brand { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; min-width: 0; }
.brand h1 { font-size: clamp(20px, 4vw, 26px); font-weight: 700; letter-spacing: -.01em; }
.pill { font-size: 12px; padding: 3px 10px; border-radius: 99px; background: var(--card); border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.pill.ok::before, .pill.warn::before, .pill.err::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 6px; background: #3ba55d; }
.pill.warn::before { background: var(--warn); }
.pill.err::before { background: var(--bad); }
.pill.demo { color: var(--warn); border-color: var(--warn); }
.tools { display: flex; gap: 6px; flex: none; }
.tools button { padding: 6px 12px; min-width: 52px; border-radius: 10px; background: var(--card); border: 1px solid var(--line); cursor: pointer; }
.tools button:hover { border-color: var(--accent); }
.units-wrap { position: relative; }
.panel { position: absolute; right: 0; top: calc(100% + 8px); z-index: 20; width: min(300px, calc(100vw - 32px)); padding: 12px; display: grid; gap: 10px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 10px 30px rgba(0, 0, 0, .18); }
.panel[hidden] { display: none; }
.panel .seg { display: flex; }
.panel .seg button { flex: 1; min-width: 0; padding: 6px 8px; border: 0; }
.panel .seg button:disabled { cursor: default; opacity: 1; }
.panel label { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 14px; }
.panel select { font: inherit; color: inherit; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 5px 8px; min-width: 96px; }
.panel p { margin: 0; font-size: 12px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- grid ---------- */
main { padding-bottom: 24px; }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.w-hero, .w-m, .w-full, .w-half { grid-column: 1 / -1; }
.w-s { grid-column: span 1; }
@media (min-width: 700px) {
  .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
  .w-m, .w-half { grid-column: span 2; }
}
@media (min-width: 1100px) {
  .grid { grid-template-columns: repeat(12, minmax(0, 1fr)); }
  .w-hero, .w-half { grid-column: span 6; }
  .w-m, .w-s { grid-column: span 3; }
}
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); min-width: 0; }
.card h2 { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin-bottom: 8px; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 8px; }
.card-head h2 { margin: 0; }
.mid { font-size: clamp(28px, 6vw, 36px); font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.mini { margin: 10px 0 0; display: grid; gap: 6px; }
.mini div { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; border-top: 1px solid var(--line); padding-top: 6px; }
.mini dt { color: var(--muted); }
.mini dd { margin: 0; font-variant-numeric: tabular-nums; font-weight: 600; text-align: right; }
.trends-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.trends-head h2 { font-size: 18px; font-weight: 700; }
.note { font-size: 13px; }

/* ---------- hero ---------- */
.hero { display: flex; flex-direction: column; gap: 12px; position: relative; overflow: hidden; }
.hero.day { background: linear-gradient(135deg, light-dark(#e3f0ff, #10253b), light-dark(#fff1cf, #1a3556)); }
.hero.night { background: linear-gradient(135deg, light-dark(#d9e0f2, #0b1220), light-dark(#c8d2ee, #121c38)); }
.hero-main { display: flex; align-items: center; gap: 16px; }
.hero-icon { width: clamp(64px, 16vw, 96px); height: clamp(64px, 16vw, 96px); color: light-dark(#e08a00, #ffc94d); flex: none; }
.hero-icon svg, .ico svg, .fc svg, .hr svg { width: 100%; height: 100%; display: block; }
.big { font-size: clamp(60px, 13vw, 92px); font-weight: 700; letter-spacing: -.04em; line-height: 1; font-variant-numeric: tabular-nums; }
.big .unit { font-size: .32em; vertical-align: top; position: relative; top: .35em; }
.sub { color: var(--muted); margin-top: 4px; }
.sub b { color: var(--text); }
.sky { font-size: 16px; font-weight: 500; min-height: 1.2em; }
.hilo { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 16px; font-size: 14px; }
.hilo .k { margin-right: 4px; }
@media (min-width: 500px) { .hilo { grid-template-columns: repeat(4, auto); justify-content: space-between; } }
.spark svg { width: 100%; height: 44px; display: block; }
.spark.tall svg { height: 56px; }
.spark path { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.spark .fill { fill: var(--accent); opacity: .12; stroke: none; }
#spark-temp path { stroke: var(--c-temp); }
#spark-temp .fill { fill: var(--c-temp); }
#spark-baro path { stroke: var(--c-baro); }
#spark-baro .fill { fill: var(--c-baro); }

/* ---------- wind ---------- */
.compass-wrap { display: flex; align-items: center; gap: 14px; }
.compass { width: clamp(120px, 34vw, 160px); flex: none; }
.compass-txt { flex: 1; min-width: 0; }
.compass .ring { fill: var(--card2); stroke: var(--line); stroke-width: 2; }
.compass .ticks line { stroke: var(--muted); stroke-width: 1.5; opacity: .6; }
.compass text { fill: var(--muted); font-size: 15px; font-weight: 600; }
.compass .card-n { fill: var(--bad); }
.compass .arrow { fill: var(--accent); }
.compass .arrow-tail { stroke: var(--accent); stroke-width: 4; opacity: .35; stroke-linecap: round; }
.compass .hub { fill: var(--card); stroke: var(--accent); stroke-width: 3; }

/* ---------- pressure / outlook ---------- */
.trend { display: flex; align-items: center; gap: 6px; margin: 4px 0 6px; font-size: 14px; }
.arrow-ico { display: inline-block; font-size: 18px; width: 22px; text-align: center; }
.outlook { display: flex; align-items: center; gap: 10px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.outlook .ico { width: 34px; height: 34px; flex: none; color: var(--accent); }

/* ---------- small tiles ---------- */
.uvbar { position: relative; height: 8px; border-radius: 99px; margin: 12px 4px 6px; background: linear-gradient(90deg, #3ba55d 0 17%, #f0c419 17% 42%, #f08a24 42% 58%, #e5484d 58% 92%, #8e4ec6 92%); }
.uvbar i { position: absolute; top: -4px; left: 0; width: 4px; height: 16px; border-radius: 2px; background: var(--text); box-shadow: 0 0 0 2px var(--card); transform: translateX(-2px); }

/* ---------- forecast ---------- */
.hourly, .days { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 8px; scrollbar-width: thin; scroll-snap-type: x proximity; }
.hr { flex: 0 0 auto; width: 58px; text-align: center; font-size: 13px; scroll-snap-align: start; }
.hr .h { color: var(--muted); font-size: 12px; }
.hr .dow { min-height: 16px; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--accent); white-space: nowrap; }
.hr.newday { position: relative; border-left: 2px solid var(--accent); }
.hr.clockchg .dow { color: var(--warn); }
.hr.clockchg:not(.newday) { position: relative; border-left: 2px dotted var(--warn); }
.hr .i { width: 28px; height: 28px; margin: 4px auto; color: var(--accent); }
.hr .tt { font-weight: 650; font-variant-numeric: tabular-nums; }
.hr .p { color: var(--c-rain); font-size: 11px; min-height: 14px; font-variant-numeric: tabular-nums; }
.days { margin-top: 8px; padding-top: 12px; border-top: 1px solid var(--line); }
.fc { flex: 0 0 auto; width: 128px; text-align: left; background: var(--card2); border: 1px solid var(--line); border-radius: 14px; padding: 10px; cursor: pointer; scroll-snap-align: start; }
.fc:hover { border-color: var(--accent); }
.fc[aria-expanded="true"] { outline: 2px solid var(--accent); outline-offset: -1px; }
.fc .n { font-size: 13px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fc .dt { color: var(--muted); font-size: 12px; min-height: 16px; }
.fc .i { width: 32px; height: 32px; margin: 4px 0 6px; color: var(--accent); }
.fc .tt { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.fc .p { color: var(--c-rain); font-size: 12px; min-height: 16px; }
.fc .s { color: var(--muted); font-size: 12px; line-height: 1.25; margin-top: 2px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.detail { margin-top: 10px; font-size: 14px; min-height: 1.4em; }

/* ---------- alerts ---------- */
.alerts:not(:empty) { margin-bottom: 12px; }
.alert { background: var(--card); border: 1px solid var(--line); border-left: 5px solid var(--accent); border-radius: 12px; padding: 10px 14px; margin-bottom: 8px; box-shadow: var(--shadow); }
.alert.sev-Extreme, .alert.sev-Severe { border-left-color: var(--bad); }
.alert.sev-Moderate { border-left-color: #f08a24; }
.alert.sev-Minor { border-left-color: #f0c419; }
.alert summary { cursor: pointer; font-weight: 650; list-style: none; display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.alert summary::-webkit-details-marker { display: none; }
.alert .until { color: var(--muted); font-weight: 400; font-size: 13px; }
.alert .body { margin-top: 8px; font-size: 14px; white-space: pre-line; color: var(--muted); }
.alert .body b { color: var(--text); }
.alert .lnk { margin-left: auto; font-size: 13px; font-weight: 600; color: var(--accent); text-decoration: none; white-space: nowrap; }
.alert .lnk:hover { text-decoration: underline; }
.alert .meta { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 10px; font-size: 12px; }
.alert.old { opacity: .7; }

/* ---------- charts ---------- */
.chart header { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.chart h3 { font-size: 14px; font-weight: 650; }
.legend { display: flex; gap: 10px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; background: var(--c); display: inline-block; }
.plot { position: relative; min-height: 200px; }
.plot svg { display: block; width: 100%; height: auto; touch-action: pan-y; }
.plot .empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 13px; text-align: center; padding: 0 16px; }
.stats { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 8px; font-size: 12.5px; color: var(--muted); }
.stats b { color: var(--text); font-variant-numeric: tabular-nums; }

.c-temp { --c: var(--c-temp); } .c-feels { --c: var(--c-feels); } .c-hum { --c: var(--c-hum); }
.c-nws { --c: var(--c-nws); } .c-om { --c: var(--c-om); } .c-adj { --c: var(--c-adj); }
.c-dew { --c: var(--c-dew); } .c-baro { --c: var(--c-baro); } .c-wind { --c: var(--c-wind); }
.c-gust { --c: var(--c-gust); } .c-rain { --c: var(--c-rain); } .c-cum { --c: var(--c-cum); }
.c-solar { --c: var(--c-solar); } .c-uv { --c: var(--c-uv); }

.chart text { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .grid line { stroke: var(--line); stroke-width: 1; }
.chart .axis-line { stroke: var(--line); }
.chart .ln { fill: none; stroke: var(--c); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .ln.thin { stroke-width: 1.4; opacity: .9; }
.chart .ln.dash { stroke-dasharray: 5 4; }
.chart .ar { fill: var(--c); opacity: .16; }
.chart .bd { fill: var(--c); opacity: .2; }
.chart .br { fill: var(--c); opacity: .9; }
.chart .xh { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
.chart .dot { fill: var(--c); stroke: var(--card); stroke-width: 2; }
.chart .hit { fill: transparent; touch-action: pan-y; }
.tip { position: absolute; z-index: 3; pointer-events: none; background: var(--card2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; font-size: 12px; box-shadow: var(--shadow); white-space: nowrap; }
.tip .tt { color: var(--muted); margin-bottom: 4px; }
.tip .row { display: flex; align-items: center; gap: 6px; }
.tip .row i { width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.tip .row b { margin-left: auto; padding-left: 12px; font-variant-numeric: tabular-nums; }

/* seg control */
.seg { display: inline-flex; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 9px; cursor: pointer; color: var(--muted); font-weight: 600; font-size: 13px; }
.seg button[aria-pressed="true"] { background: var(--accent); color: #fff; }

/* records */
#records .card-head { flex-wrap: wrap; gap: 8px 12px; }
#records .seg, .trends-head .seg { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.trends-head .seg button { white-space: nowrap; padding-inline: 10px; }
#records .seg button { white-space: nowrap; }
#records .note { margin: 2px 0 10px; }
.recs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 700px) { .recs { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.rec { background: var(--card2); border-radius: 12px; padding: 10px 12px; }
.rec .v { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.rec .d { color: var(--muted); font-size: 12px; }

.foot { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); padding-block: 8px max(24px, env(safe-area-inset-bottom)); }

@media (prefers-reduced-motion: no-preference) {
  .hero-icon, .arrow-ico { transition: transform .3s ease; }
  #wind-arrow { transition: transform .6s cubic-bezier(.2, .8, .2, 1); }
}

/* wind needle rotates via CSS so it can animate */
#wind-arrow { transform-box: view-box; transform-origin: 50% 50%; }
.spark path { vector-effect: non-scaling-stroke; }

.sub-h { font-size: 11px; font-weight: 500; text-transform: none; letter-spacing: 0; margin-left: 4px; }

/* ---- forecast comparison ---- */
#compare .card-head .seg { max-width: 100%; }
#compare .note { margin: 2px 0 10px; }
#compare .small { font-size: 12px; }
#compare .sub { font-size: 14px; font-weight: 650; margin: 18px 0 6px; }
.cmp-chart { margin-bottom: 8px; }
.tbl-wrap { overflow-x: auto; margin: 6px 0 4px; scrollbar-width: thin; }
table.cmp { border-collapse: collapse; width: 100%; font-size: 13px; font-variant-numeric: tabular-nums; }
table.cmp th, table.cmp td { padding: 6px 10px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--line); }
table.cmp th { color: var(--muted); font-weight: 600; font-size: 12px; vertical-align: bottom; }
table.cmp th small { font-weight: 400; }
table.cmp th:first-child, table.cmp td:first-child { text-align: left; }
table.cmp td.dn { font-weight: 600; }
table.cmp td.raw { color: var(--muted); }
table.cmp td.adj { color: var(--c-adj); font-weight: 650; }
table.cmp td.adj.far { background: color-mix(in srgb, var(--c-adj) 14%, transparent); border-radius: 6px; }
table.cmp td.best { color: var(--c-adj); font-weight: 700; }
table.cmp tr.first td { border-top: 1px solid var(--line); }
.toggle { border: 1px solid var(--line); background: var(--card); color: var(--text, inherit); border-radius: 10px; padding: 5px 12px; font-size: 13px; font-weight: 600; cursor: pointer; }
.toggle:hover { border-color: var(--accent); }
#cmp-summary { margin: 2px 0 0; }
#cmp-summary b { font-variant-numeric: tabular-nums; }
#cmp-metric { margin: 4px 0 6px; }
.adjtxt { color: var(--c-adj); }
