/* Sniffcast — see BRAND.md. Calm warm neutrals, one accent (radar teal), warm red only for "Not Fine". */
@font-face { font-family: "Fraunces"; src: url(fonts/fraunces-latin-full-normal.woff2) format("woff2"); font-weight: 100 900; font-style: normal; font-display: swap; }
@font-face { font-family: "Fraunces"; src: url(fonts/fraunces-latin-full-italic.woff2) format("woff2"); font-weight: 100 900; font-style: italic; font-display: swap; }
@font-face { font-family: "Inter"; src: url(fonts/inter-latin-wght-normal.woff2) format("woff2"); font-weight: 100 900; font-style: normal; font-display: swap; }

:root {
  --bg: #f7f4ee;
  --surface: #fffdf9;
  --surface-2: #efeae1;
  --ink: #24262b;
  --ink-2: #50545e;
  --ink-3: #7d808a;
  --line: #e4ddd1;
  --accent: #1f7a80;
  --accent-soft: #dcecec;
  --on-accent: #ffffff;
  /* level colors: only "Not Fine" is red */
  --fine: #4f8a5b;
  --fineish: #a98216;
  --less: #b8662a;
  --notfine: #c43d2f;
  --shadow: 0 1px 2px rgba(36, 38, 43, .04), 0 8px 28px rgba(36, 38, 43, .06);
  --radius: 20px;
  --serif: "Fraunces", Georgia, serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #16171a; --surface: #1e2024; --surface-2: #282b30; --ink: #f1ede6; --ink-2: #c6c2bb; --ink-3: #96938d;
    --line: #2e3136; --accent: #5ab8bd; --accent-soft: #1f3638; --on-accent: #0f1a1b;
    --fine: #7cbf88; --fineish: #e0bb4f; --less: #e8955a; --notfine: #f0705f;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 28px rgba(0,0,0,.25); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #16171a; --surface: #1e2024; --surface-2: #282b30; --ink: #f1ede6; --ink-2: #c6c2bb; --ink-3: #96938d;
  --line: #2e3136; --accent: #5ab8bd; --accent-soft: #1f3638; --on-accent: #0f1a1b;
  --fine: #7cbf88; --fineish: #e0bb4f; --less: #e8955a; --notfine: #f0705f;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 28px rgba(0,0,0,.25); color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.6 var(--sans); }
img, svg { max-width: 100%; }
a { color: inherit; text-decoration-color: var(--accent); text-decoration-thickness: 1.5px; text-underline-offset: 3px; }
a:hover { color: var(--accent); }
h1, h2, h3 { font-family: var(--serif); font-variation-settings: "SOFT" 100, "WONK" 0; font-weight: 650; line-height: 1.15; margin: 0 0 .5em; letter-spacing: -.01em; }
h2 { font-size: clamp(1.45rem, 1.2rem + 1vw, 1.9rem); }
h3 { font-size: 1.15rem; }
p { margin: 0 0 1em; }
.wrap { max-width: 1040px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--ink-3); }
.small { font-size: .875rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- header + wordmark ---------- */
.site-header { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 64px; }
.brand { display: flex; flex-direction: column; text-decoration: none; line-height: 1; }
.brand:hover { color: inherit; }
.wordmark { font-family: var(--serif); font-variation-settings: "SOFT" 100, "WONK" 0, "opsz" 72; font-weight: 640; font-size: 1.6rem; letter-spacing: -.015em; white-space: nowrap; }
.wm-i { position: relative; display: inline-block; }
.wm-drop { position: absolute; left: 50%; top: -.2em; width: .56em; height: .56em; transform: translateX(-50%); color: var(--accent); overflow: visible; }
.tagline { font-family: var(--serif); font-style: italic; font-variation-settings: "SOFT" 100; font-size: .8rem; color: var(--ink-3); margin-top: 4px; }
.nav { display: flex; gap: 2px; flex-wrap: wrap; justify-content: flex-end; }
.nav a { text-decoration: none; padding: 7px 11px; border-radius: 999px; font-size: .9rem; color: var(--ink-2); }
.nav a:hover, .nav a[aria-current="page"] { background: var(--surface-2); color: var(--ink); }
@media (max-width: 640px) { .nav a:not([aria-current="page"]):not(.nav-reports) { display: none; } }

.banner { background: var(--ink); color: var(--bg); text-align: center; padding: 9px 16px; font-size: .9rem; font-weight: 600; }

/* ---------- forecast-first verdict card ---------- */
.forecast { padding: 20px 0 8px; }
.verdict { --lvl: var(--ink-3); position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: 24px; box-shadow: var(--shadow); padding: 22px 22px 20px; overflow: hidden; }
.verdict::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 6px; background: var(--lvl); }
.verdict.lvl-low { --lvl: var(--fine); }
.verdict.lvl-moderate { --lvl: var(--fineish); }
.verdict.lvl-high { --lvl: var(--less); }
.verdict.lvl-very_high { --lvl: var(--notfine); }
.vc-top { display: flex; justify-content: space-between; gap: 10px; font-size: .8rem; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-3); }
.vc-label { font-family: var(--serif); font-variation-settings: "SOFT" 100, "WONK" 0, "opsz" 144; font-weight: 650; font-size: clamp(2.4rem, 1.6rem + 4.4vw, 4rem); line-height: 1.02; margin: 14px 0 6px; color: var(--lvl); letter-spacing: -.02em; }
.vc-quip { font-family: var(--serif); font-style: italic; font-variation-settings: "SOFT" 100; font-size: 1.2rem; color: var(--ink-2); margin-bottom: 16px; }
.vc-stats { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.stat { display: inline-flex; align-items: baseline; gap: 6px; background: var(--surface-2); border-radius: 12px; padding: 7px 12px; font-size: .9rem; color: var(--ink-2); }
.stat b { font-size: 1.05rem; color: var(--ink); font-variant-numeric: tabular-nums; }
.scale { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.scale span { height: 8px; border-radius: 999px; background: var(--surface-2); }
.scale span.on { background: var(--lvl); }
.scale-labels { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin-top: 6px; font-size: .72rem; color: var(--ink-3); }
.scale-labels span.on { color: var(--ink); font-weight: 600; }
@media (max-width: 520px) {
  .verdict { padding: 20px 16px 16px; }
  .vc-top .vc-region { display: none; }
  .stat { font-size: .82rem; padding: 6px 10px; }
  .scale-labels { font-size: .66rem; }
}

.story { padding: 26px 0 8px; }
.story h1 { font-size: clamp(1.6rem, 1.2rem + 1.8vw, 2.3rem); max-width: 24ch; }
.narration { font-size: clamp(1.06rem, 1rem + .3vw, 1.2rem); line-height: 1.65; max-width: 64ch; }
.meta-row { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; margin-top: 14px; }
.source-line { font-size: .82rem; color: var(--ink-3); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 999px; padding: 11px 18px; font: 600 .95rem var(--sans); cursor: pointer; text-decoration: none; background: var(--accent); color: var(--on-accent); }
.btn:hover { color: var(--on-accent); filter: brightness(1.05); }
.btn.secondary { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line); }
.btn.secondary:hover { color: var(--ink); background: var(--surface-2); }
.btn[aria-disabled="true"] { background: var(--surface-2); color: var(--ink-2); cursor: default; }
.btn:focus-visible, .chip:focus-visible, .tab:focus-visible, .bug:focus-visible, a:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

section { padding: 26px 0; }
.section-head { margin-bottom: 14px; }
.section-head p { margin: 0; color: var(--ink-2); max-width: 62ch; }
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; border: 1px solid var(--line); }

/* ---------- level pills ---------- */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: .8rem; font-weight: 600; white-space: nowrap; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.lvl-low .pill, .pill.lvl-low { background: color-mix(in srgb, var(--fine) 14%, transparent); color: var(--fine); }
.pill.lvl-moderate { background: color-mix(in srgb, var(--fineish) 16%, transparent); color: color-mix(in srgb, var(--fineish) 80%, var(--ink)); }
.pill.lvl-high { background: color-mix(in srgb, var(--less) 14%, transparent); color: var(--less); }
.pill.lvl-very_high { background: color-mix(in srgb, var(--notfine) 14%, transparent); color: var(--notfine); }
.pill.lvl-unknown { background: var(--surface-2); color: var(--ink-3); }

/* ---------- bug cards ---------- */
.bug-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 12px; }
.bug { display: grid; gap: 8px; cursor: pointer; text-align: left; font: inherit; color: inherit; width: 100%; }
.bug:hover { border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.bug-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.bug-name { font-family: var(--serif); font-variation-settings: "SOFT" 100; font-size: 1.3rem; font-weight: 650; }
.rank { font-size: .75rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-3); }
.bug-num { font-size: .875rem; color: var(--ink-2); }
.bug-num b { color: var(--ink); font-variant-numeric: tabular-nums; }
.bug-stats { display: flex; justify-content: space-between; gap: 8px; font-size: .875rem; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.trend-up { color: var(--ink); font-weight: 600; }
.trend-down { color: var(--ink-2); font-weight: 600; }
.trend-flat { color: var(--ink-2); font-weight: 600; }
.spark { height: 40px; width: 100%; color: var(--accent); }

/* ---------- decoder ---------- */
.decoder { display: grid; gap: 18px; grid-template-columns: 1fr; }
@media (min-width: 820px) { .decoder { grid-template-columns: 1fr 1fr; } }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 999px; padding: 9px 14px; font: 500 .95rem var(--sans); cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.match { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.match:last-of-type { border-bottom: 0; }
.match-bar { grid-column: 1 / -1; height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.match-bar span { display: block; height: 100%; border-radius: inherit; background: var(--accent); }

/* ---------- chart ---------- */
.tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.tab { border: 0; background: var(--surface-2); color: var(--ink-2); border-radius: 999px; padding: 8px 14px; font: 600 .875rem var(--sans); cursor: pointer; }
.tab[aria-selected="true"] { background: var(--ink); color: var(--bg); }
.chart-controls { display: flex; flex-wrap: wrap; gap: 10px; justify-content: space-between; align-items: center; margin-bottom: 12px; }
select { font: 500 .9rem var(--sans); padding: 8px 12px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); max-width: 100%; }
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid line { stroke: var(--line); }
.chart .axis text { fill: var(--ink-3); font: 11px var(--sans); }
.chart .typical { stroke: var(--ink-3); stroke-dasharray: 4 4; }
.tooltip { position: absolute; pointer-events: none; background: var(--ink); color: var(--bg); font-size: .8rem; padding: 6px 10px; border-radius: 10px; white-space: nowrap; transform: translate(-50%, -120%); opacity: 0; transition: opacity .1s; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: .85rem; color: var(--ink-2); margin-top: 8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 12px; height: 3px; border-radius: 2px; flex: none; }

/* ---------- guide ---------- */
.guide { display: grid; gap: 12px; align-items: start; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); }
details.card summary { cursor: pointer; list-style: none; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
details.card summary::-webkit-details-marker { display: none; }
details.card summary::after { content: "+"; font: 500 1.4rem var(--sans); color: var(--ink-3); }
details.card[open] summary::after { content: "–"; }
dl.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 14px 0; font-size: .925rem; }
dl.facts dt { color: var(--ink-3); font-weight: 600; }
dl.facts dd { margin: 0; }
ul.helps { margin: 0 0 12px; padding-left: 1.1em; }
.callout { background: var(--surface-2); border-left: 3px solid var(--ink-2); padding: 10px 14px; border-radius: 10px; font-size: .925rem; }

/* ---------- misc ---------- */
.two-up { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); }
.aqi-num { font-family: var(--serif); font-variation-settings: "SOFT" 100; font-size: 2.8rem; font-weight: 650; line-height: 1; }
.event { display: flex; gap: 14px; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.event:last-child { border-bottom: 0; }
.event-date { flex: none; width: 54px; text-align: center; background: var(--surface-2); border-radius: 12px; padding: 6px 0; font-weight: 700; line-height: 1.1; }
.event-date small { display: block; font-size: .68rem; font-weight: 600; text-transform: uppercase; color: var(--ink-3); }
.tipjar { background: var(--accent-soft); border-color: transparent; }
.tipjar .row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }

/* ---------- reports ---------- */
.report-list { list-style: none; margin: 0; padding: 0; }
.report-list li a { display: flex; justify-content: space-between; gap: 12px; padding: 10px 12px; border-radius: 12px; text-decoration: none; }
.report-list li a:hover, .report-list li a[aria-current="true"] { background: var(--surface-2); color: var(--ink); }
.report-layout { display: grid; gap: 20px; grid-template-columns: 1fr; }
@media (min-width: 900px) { .report-layout { grid-template-columns: 260px 1fr; } }
.stat-table { width: 100%; border-collapse: collapse; font-size: .925rem; font-variant-numeric: tabular-nums; }
.stat-table th, .stat-table td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); }
.stat-table th { color: var(--ink-3); font-weight: 600; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; }
.table-scroll { overflow-x: auto; }
.eyebrow { font-size: .8rem; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 10px; }

.prose { max-width: 68ch; }
.prose h1 { font-size: clamp(1.9rem, 1.4rem + 2vw, 2.7rem); }
.prose h2 { margin-top: 1.4em; }

footer { border-top: 1px solid var(--line); margin-top: 32px; padding: 28px 0 40px; color: var(--ink-3); font-size: .875rem; }
footer .wrap { display: grid; gap: 8px; }
footer .footer-line { font-family: var(--serif); font-style: italic; font-variation-settings: "SOFT" 100; font-size: 1.1rem; color: var(--ink-2); }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 999px; font-weight: 600; opacity: 0; transition: opacity .2s; pointer-events: none; }
.toast.show { opacity: 1; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }

/* ---------- v2: linked numbers + hover charts ---------- */
.fact { font-weight: 650; font-variant-numeric: tabular-nums; text-decoration: underline dotted; text-decoration-color: color-mix(in srgb, var(--accent) 70%, transparent); text-decoration-thickness: 2px; text-underline-offset: 4px; border-radius: 4px; padding: 0 2px; margin: 0 -2px; cursor: help; transition: background .15s; }
.fact:hover, .fact.active, .fact:focus-visible { background: var(--accent-soft); color: var(--ink); text-decoration-style: solid; }
.hint { margin-top: 6px; }
.fact-pop { position: absolute; z-index: 50; width: min(340px, calc(100vw - 16px)); background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 12px 40px rgba(0,0,0,.18); padding: 14px 16px 12px; opacity: 0; pointer-events: none; transform: translateY(4px); transition: opacity .14s, transform .14s; font-size: .9rem; line-height: 1.45; }
.fact-pop.show { opacity: 1; pointer-events: auto; transform: none; }
.pop-label { font-size: .72rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-3); }
.pop-value { font-family: var(--serif); font-variation-settings: "SOFT" 100; font-size: 1.8rem; font-weight: 650; line-height: 1.1; margin: 4px 0 6px; font-variant-numeric: tabular-nums; }
.pop-value small { display: block; font-family: var(--sans); font-size: .8rem; font-weight: 500; color: var(--ink-2); margin-top: 2px; }
.pop-chart { display: block; width: 100%; height: auto; margin: 4px 0 6px; overflow: visible; }
.pop-line { fill: none; stroke: var(--accent); stroke-width: 2.25; stroke-linejoin: round; stroke-linecap: round; }
.pop-typical { stroke: var(--ink-3); stroke-dasharray: 3 4; opacity: .7; }
.pop-level { stroke: var(--fineish); stroke-dasharray: 2 3; }
.pop-guide { stroke: var(--ink-3); stroke-dasharray: 2 3; opacity: .6; }
.pop-axis { font-size: 10px; fill: var(--ink-3); font-family: var(--sans); }
.pop-now { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.pop-then { fill: var(--surface); stroke: var(--ink-2); stroke-width: 2; }
.bar-hit { fill: var(--less); } .bar-zero { fill: var(--surface-2); }
.pop-cmp { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; border-top: 1px dashed var(--line); font-variant-numeric: tabular-nums; }
.pop-cmp span { color: var(--ink-2); }
.sw { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: 0; }
.sw.now { background: var(--accent); } .sw.then { border: 2px solid var(--ink-2); width: 7px; height: 7px; } .sw.hit { background: var(--less); border-radius: 2px; }
.pop-legend { font-size: .78rem; color: var(--ink-2); }
.pop-note { margin: 8px 0 0; color: var(--ink-2); font-size: .84rem; }
.pop-foot { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--line); font-size: .78rem; color: var(--ink-3); }
.pop-go { font-weight: 600; color: var(--accent); white-space: nowrap; text-decoration: none; }
@keyframes flash { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 55%, transparent); } 100% { box-shadow: 0 0 0 14px transparent; } }
.flash { animation: flash 1.1s ease-out 2; border-color: var(--accent) !important; }
:target { scroll-margin-top: 90px; }
[id^="signal-"], [id^="alert-"], [id^="bug-"], [id^="guide-"], #trends, #sources { scroll-margin-top: 90px; }

/* ---------- v2: county picker, basis badge ---------- */
.section-head.with-control { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 12px 24px; }
.section-head.with-control > div { flex: 1 1 420px; }
.county-pick { display: grid; gap: 4px; }
.county-pick select, #site-select, #range-select { font: 500 .95rem var(--sans); padding: 9px 12px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); }
.basis { font-size: .78rem; color: var(--ink-3); }
.basis.lab::before { content: "◆ "; color: var(--accent); }
.bug .fact { position: relative; z-index: 1; }

/* ---------- v2: clinical signals ---------- */
.group-h { margin: 18px 0 10px; font-size: 1.05rem; }
.group-h:first-child { margin-top: 0; }
.signal-grid, .alert-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); gap: 12px; }
.alert-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); }
.signal { display: grid; gap: 6px; align-content: start; }
.sig-name { font-weight: 650; }
.sig-value { font-family: var(--serif); font-variation-settings: "SOFT" 100; font-size: 1.7rem; font-weight: 650; line-height: 1.1; font-variant-numeric: tabular-nums; }
.sig-value .fact { font-weight: 650; }
.also-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 12px; }
.also { display: inline-flex; gap: 6px; align-items: baseline; background: var(--surface-2); border-radius: 999px; padding: 5px 12px; font-size: .84rem; text-decoration: none; color: var(--ink-2); }
.also b { color: var(--ink); font-variant-numeric: tabular-nums; }
.also:hover { background: var(--accent-soft); }

/* ---------- v2: alerts ---------- */
.alert { display: grid; gap: 8px; align-content: start; }
.alert.hit { border-color: color-mix(in srgb, var(--less) 45%, var(--line)); }
.alert p { margin: 0; }
.alert-status { font-size: .95rem; }
.det-bars { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 3px; height: 22px; align-items: end; }
.det-bars span { height: 6px; border-radius: 3px; background: var(--surface-2); }
.det-bars span.hit { height: 22px; background: var(--less); }

/* ---------- v2: sources table ---------- */
.stat-table.sources td { vertical-align: top; }
.stat-table.sources td:first-child { font-weight: 600; min-width: 160px; }
