/* Two switchable looks: "almanac" (light, paper and ink) and "instrument"
   (dark, weather-station readout). Every colour is a token here; the charts
   only reference roles. Compare-year colours were checked with the dataviz
   validator (all pairs, CVD and normal vision) against each theme's card. */
:root,
:root[data-theme="almanac"] {
  color-scheme: light;
  --bg: #F3ECDD;
  --card: #FBF6EA;
  --ink: #2B2118;
  --muted: #6F604E;
  --edge: #DDD0B8;
  --grid: #E7DCC6;
  --rec: #E9DCC2;
  --nor: #BBA889;
  --act: #5B3A22;
  --hot: #B8432E;
  --cold: #2F6F8F;
  --rain: #3E6B7A;
  --warm: #C0582E;
  --cool: #3E7A93;
  --c1: #2a78d6;
  --c2: #c03a73;
  --c3: #6b7d12;
  --band: rgba(62, 107, 122, .16);
  --tip-bg: #2B2118;
  --tip-ink: #FBF6EA;
  --font: Georgia, "Iowan Old Style", "Palatino Linotype", serif;
  --num: Georgia, serif;
  --rad: 3px;
  --shadow: 0 1px 0 #d8cbb0;
}
:root[data-theme="instrument"] {
  color-scheme: dark;
  --bg: #0E1417;
  --card: #141C20;
  --ink: #E3EEF0;
  --muted: #8DA0A6;
  --edge: #24323A;
  --grid: #1D2A30;
  --rec: #263840;
  --nor: #3A5762;
  --act: #E8A03C;
  --hot: #FF5D4A;
  --cold: #7FD3F0;
  --rain: #4FC3D9;
  --warm: #E8763C;
  --cool: #4FB6D0;
  --c1: #3987e5;
  --c2: #d55181;
  --c3: #8a9a2a;
  --band: rgba(79, 195, 217, .14);
  --tip-bg: #E3EEF0;
  --tip-ink: #0E1417;
  --font: ui-monospace, "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;
  --num: ui-monospace, Menlo, monospace;
  --rad: 10px;
  --shadow: none;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  line-height: 1.45;
}
a { color: inherit; text-underline-offset: 3px; }
.wrap { max-width: 1140px; margin: 0 auto; padding: 22px 16px 40px; }
:focus-visible { outline: 2px solid var(--act); outline-offset: 2px; }

/* ---- header ---- */
header { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 12px 24px; }
.titles { flex: 1 1 420px; min-width: 0; }
.kicker { color: var(--muted); font-size: 15px; }
h1 { margin: .05em 0 .1em; font-size: clamp(30px, 5.4vw, 50px); line-height: 1.08; }
:root[data-theme="almanac"] h1 { font-style: italic; font-weight: 400; }
:root[data-theme="instrument"] h1 { font-weight: 600; letter-spacing: -.02em; }
:root[data-theme="instrument"] .kicker { color: var(--act); }
.sub { color: var(--muted); font-size: 15px; }
.sub .warn { color: var(--hot); }
.t-almanac, .t-instrument { display: none; }
:root[data-theme="almanac"] .t-almanac,
:root[data-theme="instrument"] .t-instrument { display: inline; }
.home { font-size: 13px; color: var(--muted); }

/* ---- segmented buttons, chips ---- */
.seg { display: inline-flex; flex-wrap: wrap; gap: 6px; }
button, select, input[type="date"] {
  font: inherit; font-size: 14px; color: var(--ink);
  background: transparent; border: 1px solid var(--edge);
  border-radius: var(--rad); padding: 6px 11px; min-height: 34px;
}
select, input[type="date"] { background: var(--card); }
button { cursor: pointer; }
button:hover { border-color: var(--muted); }
button[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.theme-switch { flex: 0 0 auto; }

.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin: 18px 0 14px; }
.controls .grow { flex: 1; }
.custom { display: none; align-items: center; gap: 6px; flex-wrap: wrap; }
.custom.on { display: inline-flex; }
.compare { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 6px 4px 10px; font-size: 14px; }
.chip i { width: 14px; height: 3px; border-radius: 2px; display: inline-block; }
.chip button { border: 0; padding: 0 6px; min-height: 24px; }

details.menu { position: relative; }
details.menu > summary {
  list-style: none; cursor: pointer; font-size: 14px;
  border: 1px solid var(--edge); border-radius: var(--rad); padding: 6px 11px;
}
details.menu > summary::-webkit-details-marker { display: none; }
.menu-body {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 20;
  background: var(--card); border: 1px solid var(--edge); border-radius: var(--rad);
  padding: 8px; min-width: 250px; box-shadow: 0 8px 24px rgba(0,0,0,.18);
}
.menu-row { display: flex; align-items: center; gap: 6px; padding: 3px 0; font-size: 14px; }
.menu-row label { flex: 1; display: flex; gap: 8px; align-items: center; cursor: pointer; }
.menu-row button { padding: 2px 8px; min-height: 28px; }

/* ---- layout ---- */
.layout { display: grid; grid-template-columns: minmax(0, 3fr) minmax(260px, 1fr); gap: 14px; align-items: start; }
@media (max-width: 820px) { .layout { grid-template-columns: minmax(0, 1fr); } .daycol { order: -1; } }
.daycol { position: sticky; top: 12px; }
@media (max-width: 820px) { .daycol { position: static; } }
.card {
  background: var(--card); border: 1px solid var(--edge); border-radius: var(--rad);
  padding: 14px; margin-bottom: 14px; box-shadow: var(--shadow); position: relative;
}
.card h2 {
  font-size: 13px; letter-spacing: .12em; text-transform: uppercase;
  margin: 0 0 4px; color: var(--muted); font-weight: 600;
}
.card .lede { margin: 0 0 8px; font-size: 15px; }
.chart { position: relative; touch-action: pan-y; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart:focus-visible { outline-offset: 4px; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13px; color: var(--muted); margin-top: 8px; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.sw { width: 11px; height: 11px; border-radius: 2px; display: inline-block; }
.sw.line { height: 3px; width: 16px; }

/* svg roles */
.g-grid { stroke: var(--grid); stroke-width: 1; }
.g-base { stroke: var(--muted); stroke-width: 1; }
.g-ax { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.f-rec { fill: var(--rec); }
.f-nor { fill: var(--nor); }
.f-act { fill: var(--act); }
.f-hot { fill: var(--hot); }
.f-cold { fill: var(--cold); }
.f-rain { fill: var(--rain); }
.f-warm { fill: var(--warm); }
.f-cool { fill: var(--cool); }
.f-band { fill: var(--band); }
.l-norm { stroke: var(--muted); stroke-width: 1.5; fill: none; stroke-dasharray: 3 3; }
.l-act { stroke: var(--act); stroke-width: 2.5; fill: none; }
.l-c { stroke-width: 2; fill: none; stroke-linejoin: round; }
.lbl-c { font-size: 11px; font-family: var(--font); fill: var(--ink); }
.cross { stroke: var(--ink); stroke-width: 1; opacity: .45; }
.sel { stroke: var(--ink); stroke-width: 1; stroke-dasharray: 2 3; opacity: .7; }

.tip {
  position: absolute; pointer-events: none; z-index: 10; display: none;
  background: var(--tip-bg); color: var(--tip-ink); border-radius: var(--rad);
  padding: 7px 9px; font-size: 12.5px; line-height: 1.4; white-space: nowrap;
  box-shadow: 0 6px 18px rgba(0,0,0,.25);
}
.tip b { font-weight: 700; }
.tip i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }

/* ---- stats tiles ---- */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.tile { border-top: 1px solid var(--edge); padding-top: 8px; }
.tile .v { font-family: var(--num); font-size: 26px; font-weight: 700; line-height: 1.1; }
.tile .k { font-size: 13px; color: var(--muted); }

/* ---- day card ---- */
.daynav { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.daynav input { flex: 1 1 140px; min-width: 0; }
.big { font-family: var(--num); white-space: nowrap; font-size: 46px; font-weight: 700; line-height: 1; }
:root[data-theme="instrument"] .big { color: var(--act); font-size: 38px; }
:root[data-theme="instrument"] .big small { font-size: 20px; }
.big small { font-size: 24px; color: var(--muted); font-weight: 600; }
.dayline { font-size: 14px; margin-top: 6px; }
.dayline .m { color: var(--muted); }
.ranks { margin: 10px 0 4px; padding: 0; list-style: none; font-size: 14px; }
.ranks li { padding: 3px 0; border-top: 1px solid var(--edge); }
.strip-title { font-size: 12px; color: var(--muted); margin-top: 10px; }

details.table { margin-top: 4px; }
details.table summary { cursor: pointer; color: var(--muted); font-size: 14px; }
.tablewrap { max-height: 360px; overflow: auto; margin-top: 8px; }
table { border-collapse: collapse; width: 100%; font-size: 13px; font-variant-numeric: tabular-nums; }
th, td { text-align: right; padding: 4px 8px; border-bottom: 1px solid var(--edge); }
th:first-child, td:first-child { text-align: left; }
th { position: sticky; top: 0; background: var(--card); color: var(--muted); font-weight: 600; }

.status { padding: 40px 0; text-align: center; color: var(--muted); }
footer { font-size: 13px; color: var(--muted); margin-top: 8px; }
footer p { margin: 6px 0; max-width: 80ch; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
