/* ==========================================================================
   CareScout styles
   1. Tokens and themes      6. Result rows           11. Forms
   2. Base and utilities     7. Score strip + badges  12. Compare table
   3. Header and hero        8. Map view              13. Tray and toasts
   4. Workspace and filters  9. States                14. Scoring + footer
   5. Toolbar, chips, plot  10. Dialogs and detail    15. Motion preferences
   ========================================================================== */

/* ---------- 1. Tokens and themes ---------- */
:root {
  --font-display: Rockwell, "Rockwell Nova", "Roboto Slab", "DejaVu Serif", "Sitka Heading", Georgia, serif;
  --font-body: "Avenir Next", Avenir, "Segoe UI Variable Text", "Segoe UI", "Nunito Sans", "Helvetica Neue", Arial, sans-serif;

  --paper: #F2F5EE;      /* green-tinted paper */
  --surface: #FCFDF9;
  --surface-2: #E7EEE3;
  --ink: #17312C;        /* spruce ink */
  --ink-soft: #496059;
  --line: #C9D5CB;
  --primary: #1F5A4E;
  --primary-ink: #FCFDF9;
  --hero: #1B4A41;
  --hero-ink: #F2F5EE;
  --hero-soft: #BAD4C9;
  --accent: #F2C230;     /* pencil butter */
  --accent-ink: #2E2300;
  --focus: #2F3FC4;

  /* severity: always paired with a shape and a word, never color alone */
  --crit: #A8262F;  --crit-bg: #F9E1E1;
  --ser: #8F5200;   --ser-bg: #FBEBCF;
  --min: #3F5F85;   --min-bg: #E1EAF4;
  --ok: #1F6B45;    --ok-bg: #DDF0E3;

  /* the five score blocks */
  --c-insp: #2F6B5E; --c-ser: #3E7CA6; --c-ratio: #D9A520; --c-acc: #8A5A9E; --c-par: #C7587A;

  --map-bg: #E4ECDF; --map-a: #EEF3E8; --map-b: #E3EBDD; --map-c: #F6F3E2; --map-road: #FCFDF9;
  --map-water: #A9CBE0; --map-park: #BFDDB8;

  --shadow: 0 1px 0 rgba(23, 49, 44, .06), 0 10px 24px -18px rgba(23, 49, 44, .45);
  --radius: 10px;
  color-scheme: light;
}
[data-theme="dark"] {
  --paper: #0E1C19; --surface: #162925; --surface-2: #1D3530;
  --ink: #E9F0E7; --ink-soft: #A7BAB1; --line: #2D4740;
  --primary: #7FD1B9; --primary-ink: #0E1C19;
  --hero: #0A1513; --hero-ink: #E9F0E7; --hero-soft: #9DB8AD;
  --focus: #F2C230;
  --crit: #FF9D9D; --crit-bg: #4A1D21;
  --ser: #FFC670;  --ser-bg: #45310E;
  --min: #A9C6EA;  --min-bg: #1F3247;
  --ok: #8FDDAE;   --ok-bg: #173A27;
  --c-insp: #4FA08F; --c-ser: #5B9CC8; --c-ratio: #E4B638; --c-acc: #AC7CC0; --c-par: #DD7696;
  --map-bg: #12231F; --map-a: #182E29; --map-b: #142722; --map-c: #1F332A; --map-road: #2B443D;
  --map-water: #24506B; --map-park: #23492F;
  --shadow: 0 1px 0 rgba(0, 0, 0, .3), 0 12px 26px -18px rgba(0, 0, 0, .9);
  color-scheme: dark;
}

/* ---------- 2. Base and utilities ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
html:has(dialog[open]) { overflow: hidden; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 400 1rem/1.55 var(--font-body); font-variant-numeric: tabular-nums;
}
body.has-tray { padding-bottom: 5.5rem; }
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 700; line-height: 1.15; margin: 0; letter-spacing: -.01em; }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
dl, dd { margin: 0; }
small { font-size: .8125rem; color: var(--ink-soft); }
a { color: var(--primary); text-underline-offset: 3px; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { display: block; }
[hidden] { display: none !important; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
main:focus, .results:focus, h2:focus { outline: none; }

.wrap { width: min(1240px, 100% - 2rem); margin-inline: auto; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip-link { position: absolute; left: 1rem; top: -4rem; z-index: 100; background: var(--accent); color: var(--accent-ink); padding: .6rem 1rem; border-radius: 8px; font-weight: 700; }
.skip-link:focus { top: 1rem; }
.noscript { padding: 1rem; text-align: center; background: var(--ser-bg); color: var(--ser); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  min-height: 44px; padding: .55rem 1.05rem; border-radius: 8px; border: 2px solid var(--primary);
  background: var(--primary); color: var(--primary-ink); font-weight: 700; text-decoration: none; line-height: 1.2;
}
.btn:hover { filter: brightness(1.08); }
.btn--ghost { background: transparent; color: var(--primary); }
.btn--ghost:hover { background: var(--surface-2); filter: none; }
.btn--accent { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn--small { min-height: 38px; padding: .35rem .8rem; font-size: .9375rem; }
.btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.btn[aria-pressed="true"] { background: var(--primary); color: var(--primary-ink); }
.btn svg { width: 1.1em; height: 1.1em; flex: none; }
.linkbtn { background: none; border: 0; padding: .35rem .2rem; color: var(--primary); font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
.count-badge { display: inline-grid; place-items: center; min-width: 1.5em; height: 1.5em; padding: 0 .4em; border-radius: 99px; background: var(--accent); color: var(--accent-ink); font-size: .8125rem; font-weight: 800; }

/* ---------- 3. Header and hero ---------- */
.site-header { background: var(--hero); color: var(--hero-ink); }
.site-header__inner { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1.25rem; padding-block: .85rem; }
.brand { display: inline-flex; align-items: center; gap: .55rem; color: inherit; text-decoration: none; margin-right: auto; }
.brand__mark { width: 34px; height: 34px; }
.brand__name { font: 700 1.5rem/1 var(--font-display); letter-spacing: -.02em; }
.site-nav { display: flex; flex-wrap: wrap; gap: .25rem; order: 3; width: 100%; }
.site-nav__btn {
  display: inline-flex; align-items: center; gap: .4rem; min-height: 44px; padding: .4rem .8rem;
  background: none; border: 0; border-bottom: 3px solid transparent; border-radius: 4px 4px 0 0;
  color: var(--hero-soft); font-weight: 700; text-decoration: none;
}
.site-nav__btn:hover { color: var(--hero-ink); }
.site-nav__btn[aria-current="page"] { color: var(--hero-ink); border-bottom-color: var(--accent); }
.theme-toggle { display: inline-flex; align-items: center; gap: .45rem; min-height: 44px; padding: .4rem .8rem; border-radius: 99px; border: 1.5px solid color-mix(in srgb, var(--hero-soft) 55%, transparent); background: transparent; color: var(--hero-ink); font-weight: 600; font-size: .9375rem; }
.theme-toggle__icon { width: 18px; height: 18px; }
.icon-sun { display: none; }
[data-theme="dark"] .icon-sun { display: block; }
[data-theme="dark"] .icon-moon { display: none; }
.site-header :focus-visible, .hero :focus-visible { outline-color: var(--accent); }

.hero { background: var(--hero); color: var(--hero-ink); padding: 2rem 0 3rem; }
.hero__grid { display: grid; gap: 2.25rem; }
.hero h1 { font-size: clamp(2.1rem, 1.2rem + 3.6vw, 3.5rem); max-width: 14ch; line-height: 1.02; letter-spacing: -.025em; }
.hero__lede { margin-top: 1.1rem; max-width: 56ch; color: var(--hero-soft); font-size: 1.0938rem; }
.search { margin-top: 1.75rem; max-width: 40rem; }
.search label { display: block; font-weight: 700; margin-bottom: .45rem; }
.search__field { display: flex; align-items: center; gap: .6rem; background: var(--surface); color: var(--ink); border-radius: 10px; padding: .2rem .5rem .2rem .9rem; border: 2px solid transparent; }
.search__field:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 45%, transparent); }
.search__field svg { width: 22px; height: 22px; flex: none; color: var(--ink-soft); }
.search__field input { flex: 1; min-width: 0; border: 0; background: none; min-height: 50px; font-size: 1.0625rem; outline: none; }
.search__field input::placeholder { color: var(--ink-soft); opacity: .85; }
.search__clear { border: 0; background: var(--surface-2); color: var(--ink); border-radius: 6px; padding: .4rem .7rem; font-weight: 700; font-size: .875rem; }
.search__clear:focus-visible { outline-color: var(--focus); }

.formula { margin: 0; align-self: end; background: color-mix(in srgb, var(--hero-ink) 7%, transparent); border: 1px solid color-mix(in srgb, var(--hero-ink) 18%, transparent); border-radius: 14px; padding: 1.25rem; }
.formula figcaption { font: 700 1.125rem/1.3 var(--font-display); max-width: 30ch; }
.formula__strip { display: flex; gap: 4px; margin-top: 1rem; height: 58px; }
.formula__block { flex: var(--max) 1 0; display: grid; place-items: center; background: var(--c); border-radius: 6px; color: #fff; transform-origin: left center; animation: block-in .5s cubic-bezier(.2, .8, .2, 1) both; animation-delay: calc(var(--i) * 110ms + 200ms); }
.formula__block b { font: 700 1.25rem/1 var(--font-display); text-shadow: 0 1px 0 rgba(0, 0, 0, .25); }
@keyframes block-in { from { transform: scaleX(0); opacity: 0; } }
.formula__key { display: flex; flex-wrap: wrap; gap: .3rem 1rem; margin-top: .9rem; font-size: .875rem; color: var(--hero-soft); }
.formula__key li { display: inline-flex; align-items: center; gap: .4rem; }
.swatch { width: 12px; height: 12px; border-radius: 3px; background: var(--c); flex: none; }
.formula__note { margin-top: .8rem; font-size: .875rem; color: var(--hero-soft); }
.formula__block.is-still { animation: none; }
.formula__link { display: inline-block; margin-top: .4rem; color: var(--accent); font-weight: 700; }

@media (min-width: 720px) {
  .site-nav { order: 0; width: auto; }
  .hero { padding: 3rem 0 4rem; }
}
@media (min-width: 1000px) {
  .hero__grid { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: 4rem; }
}

/* ---------- 4. Workspace and filters ---------- */
.workspace { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1.5rem; padding-block: 2rem 3rem; }
.filters { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.15rem 1.3rem; }
.filters__head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: .5rem; }
.filters__head h2 { font-size: 1.25rem; }
.filters fieldset { border: 0; padding: 0; margin: 1.1rem 0 0; min-width: 0; }
.filters legend, .field > label { font-weight: 700; padding: 0; margin-bottom: .35rem; display: block; }
.hint { font-size: .8438rem; color: var(--ink-soft); margin-bottom: .3rem; }
.field { margin-top: 1.1rem; }
.check { display: flex; align-items: flex-start; gap: .6rem; padding: .32rem 0; cursor: pointer; }
.check input { width: 1.2rem; height: 1.2rem; margin: .15rem 0 0; accent-color: var(--primary); flex: none; }
.check small { display: block; }
select, input[type="text"], input[type="email"], input[type="tel"], input[type="date"], textarea {
  width: 100%; min-height: 44px; padding: .5rem .7rem; border-radius: 8px;
  border: 1.5px solid var(--ink-soft); background: var(--surface); color: var(--ink);
}
input[type="range"] { width: 100%; accent-color: var(--primary); min-height: 32px; }
.range-out { float: right; font-weight: 700; color: var(--primary); }
.range-ends { display: flex; justify-content: space-between; font-size: .8125rem; color: var(--ink-soft); }
.filters-toggle { display: inline-flex; }

@media (min-width: 1024px) {
  .workspace { grid-template-columns: 290px minmax(0, 1fr); align-items: start; gap: 2rem; }
  .filters, .filters[hidden] { display: block !important; position: sticky; top: 1rem; max-height: calc(100vh - 2rem); overflow: auto; }
  .filters-toggle { display: none; }
}

/* ---------- 5. Toolbar, chips, plot ---------- */
.toolbar { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: .75rem 1rem; }
.toolbar__title { font-size: clamp(1.35rem, 1.1rem + 1vw, 1.75rem); }
.toolbar__controls { display: flex; flex-wrap: wrap; align-items: end; gap: .6rem; }
.sortbox label { display: block; font-size: .8438rem; font-weight: 700; color: var(--ink-soft); }
.sortbox { flex: 1 1 12rem; max-width: 100%; }
.viewswitch { display: inline-flex; border: 2px solid var(--primary); border-radius: 8px; overflow: hidden; }
.viewswitch button { display: inline-flex; align-items: center; gap: .4rem; min-height: 40px; padding: .3rem .85rem; border: 0; background: transparent; color: var(--primary); font-weight: 700; }
.viewswitch button svg { width: 18px; height: 18px; }
.viewswitch button[aria-pressed="true"] { background: var(--primary); color: var(--primary-ink); }
.viewswitch button:focus-visible { outline-offset: -4px; outline-color: var(--accent); }

.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .9rem; }
.chips:empty { display: none; }
.chip { display: inline-flex; align-items: center; gap: .15rem; background: var(--surface-2); border: 1px solid var(--line); border-radius: 99px; padding: .1rem .2rem .1rem .75rem; font-size: .9063rem; }
.chip button { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; border: 0; background: none; font-size: 1.15rem; line-height: 1; color: var(--ink-soft); }
.chip button:hover { background: var(--line); color: var(--ink); }

.insight { margin-top: 1rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.insight summary { cursor: pointer; padding: .8rem 1rem; font-weight: 700; }
.insight__fig { margin: 0; padding: 0 1rem 1rem; }
.insight__plot { overflow-x: auto; }
.insight__plot svg { width: 100%; min-width: 480px; height: auto; }
.insight figcaption { margin-top: .5rem; font-size: .9375rem; color: var(--ink-soft); max-width: 75ch; }
.plot-axis { stroke: var(--line); stroke-width: 1; }
.plot-tick { font: 12px var(--font-body); fill: var(--ink-soft); }
.plot-title { font: 700 12px var(--font-body); fill: var(--ink-soft); }
.plot-dot { stroke: var(--surface); stroke-width: 2; cursor: pointer; }
.plot-dot:hover { stroke: var(--ink); }
.plot-median { stroke: var(--ink-soft); stroke-dasharray: 4 4; }

/* ---------- 6. Result rows: report-card stub + record ---------- */
.rowlist { display: grid; gap: .9rem; margin-top: 1rem; }
.row { display: grid; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.row__stub { display: flex; align-items: center; gap: 1rem; padding: .8rem 1.1rem; border-bottom: 2px dashed var(--line); background: var(--surface-2); }
.row__score { display: flex; align-items: baseline; gap: .4rem; }
.row__num { font: 700 2.6rem/1 var(--font-display); letter-spacing: -.03em; }
.row__of { font-size: .8438rem; color: var(--ink-soft); }
.row__tier { font-weight: 700; font-size: .9063rem; }
.row__stub { flex-wrap: wrap; border-style: dashed; }
.row__tag { flex-basis: 100%; font-size: .8125rem; font-weight: 700; color: var(--ink-soft); }
.row__not { font-size: .78rem; color: var(--ink-soft); border: 1px dashed var(--ink-soft); border-radius: 4px; padding: .05rem .4rem; }
.tier-strong .row__tier { color: var(--ok); } .tier-mixed .row__tier { color: var(--ser); } .tier-concern .row__tier { color: var(--crit); }
.row__body { padding: 1rem 1.1rem; min-width: 0; }
.row__kind { font-size: .8438rem; color: var(--ink-soft); font-weight: 600; }
.row h3 { font-size: 1.3rem; }
.namelink { background: none; border: 0; padding: 0; font: inherit; color: var(--ink); text-align: left; text-decoration: underline; text-decoration-color: var(--accent); text-decoration-thickness: 3px; text-underline-offset: 4px; }
.namelink:hover { color: var(--primary); }
.row__where { margin-top: .3rem; color: var(--ink-soft); font-size: .9375rem; }
.row__dist { display: inline-block; margin-left: .6rem; padding: 0 .5rem; border-radius: 4px; background: var(--surface-2); color: var(--ink); font-weight: 700; white-space: nowrap; }
.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .7rem 1rem; margin-top: .9rem; }
.facts dt { font-size: .8125rem; color: var(--ink-soft); font-weight: 600; }
.facts dd { font-weight: 700; font-size: .9688rem; }
.facts dd.is-none { color: var(--ink-soft); font-weight: 600; }
.row__record { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .8rem; margin-top: .9rem; padding-top: .8rem; border-top: 1px solid var(--line); font-size: .9063rem; }
.row__actions { display: flex; flex-wrap: wrap; gap: .5rem; padding: 0 1.1rem 1.1rem; }
.row__actions .btn { flex: 1 1 auto; }
.savebtn svg { fill: none; stroke: currentColor; stroke-width: 2.2; }
.savebtn[aria-pressed="true"] svg { fill: currentColor; }

@media (min-width: 640px) {
  .row { grid-template-columns: 132px minmax(0, 1fr); }
  .row__stub { flex-direction: column; justify-content: center; text-align: center; gap: .35rem; border-bottom: 0; border-right: 2px dashed var(--line); grid-row: span 2; padding: 1rem .6rem; }
  .row__score { flex-direction: column; align-items: center; gap: .1rem; }
  .row__num { font-size: 3.1rem; }
  .row__stub { flex-wrap: nowrap; }
  .row__tag { flex-basis: auto; }
  .facts { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .row__actions .btn { flex: 0 0 auto; }
}

/* ---------- 7. Score strip, tallies and badges ---------- */
.strip { display: flex; gap: 3px; height: 12px; margin-top: .9rem; max-width: 30rem; }
.strip--tall { height: 20px; max-width: none; }
.strip__slot { flex: var(--max) 1 0; border-radius: 3px; overflow: hidden; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); }
.strip__fill { display: block; height: 100%; width: calc(var(--pts) / var(--max) * 100%); background: var(--c); }

.tally { display: inline-flex; flex-wrap: wrap; gap: .3rem .9rem; }
.tally li { display: inline-flex; align-items: center; gap: .35rem; font-weight: 700; }
.tally li.is-zero { color: var(--ink-soft); font-weight: 500; }
.sev-icon { display: inline-block; vertical-align: -2px; width: 14px; height: 14px; flex: none; }
.sev-critical { color: var(--crit); } .sev-serious { color: var(--ser); } .sev-minor { color: var(--min); }
.tally li.is-zero .sev-icon { color: var(--ink-soft); opacity: .6; }

.badge { display: inline-flex; align-items: center; gap: .35rem; padding: .12rem .55rem; border-radius: 6px; font-size: .8438rem; font-weight: 700; white-space: nowrap; }
.badge--critical { background: var(--crit-bg); color: var(--crit); }
.badge--serious { background: var(--ser-bg); color: var(--ser); }
.badge--minor { background: var(--min-bg); color: var(--min); }
.badge--ok { background: var(--ok-bg); color: var(--ok); }
.badge--plain { background: var(--surface-2); color: var(--ink); }

/* ---------- 8. Map view ---------- */
.mapview { display: grid; gap: 1rem; margin-top: 1rem; }
.mapview__canvas { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .6rem; }
#map { width: 100%; height: auto; border-radius: 12px; }
.map-bg { fill: var(--map-bg); }
.hood { stroke: none; } .hood--a { fill: var(--map-a); } .hood--b { fill: var(--map-b); } .hood--c { fill: var(--map-c); } .hood--c2 { fill: var(--map-b); }
.map-park { fill: var(--map-park); } .map-parkdot { fill: var(--ok); opacity: .35; }
.map-road path { fill: none; stroke: var(--map-road); stroke-width: 9; stroke-linecap: round; stroke-linejoin: round; }
.map-river { fill: none; stroke: var(--map-water); stroke-width: 20; stroke-linecap: round; }
.map-rivername { font: italic 600 12px var(--font-body); fill: var(--min); text-anchor: middle; }
.map-rings circle { fill: none; stroke: var(--ink-soft); stroke-width: 1; stroke-dasharray: 3 6; opacity: .55; }
.map-rings text { font: 600 11px var(--font-body); fill: var(--ink-soft); text-anchor: middle; paint-order: stroke; stroke: var(--map-bg); stroke-width: 4; }
.map-label text { font: 700 16px var(--font-display); fill: var(--ink-soft); text-anchor: middle; paint-order: stroke; stroke: var(--map-bg); stroke-width: 4; stroke-linejoin: round; }
.map-home path { fill: var(--ink); stroke: var(--surface); stroke-width: 2; }
.map-home text { font: 700 12px var(--font-body); fill: var(--ink); text-anchor: middle; paint-order: stroke; stroke: var(--map-bg); stroke-width: 4; }
.pin { cursor: pointer; }
.pin__shape { stroke: var(--surface); stroke-width: 2.5; transition: transform .15s ease; transform-box: fill-box; transform-origin: center; }
.pin text { font: 800 14px var(--font-body); fill: #fff; text-anchor: middle; pointer-events: none; }
.pin.tier-strong .pin__shape { fill: #1F6B45; } .pin.tier-solid .pin__shape { fill: #2F6F97; }
.pin.tier-mixed .pin__shape { fill: #9A5B00; } .pin.tier-concern .pin__shape { fill: #A8262F; }
.pin:hover .pin__shape, .pin[aria-pressed="true"] .pin__shape { transform: scale(1.25); }
.pin[aria-pressed="true"] .pin__shape { stroke: var(--accent); stroke-width: 4; }
.pin:focus, .pin:focus-visible { outline: none; }
.pin:focus-visible .pin__shape { stroke: var(--focus); stroke-width: 5; }
.pin__heart { fill: var(--accent); stroke: var(--ink); stroke-width: 1; }
.maplegend { display: flex; flex-wrap: wrap; gap: .3rem 1.1rem; padding: .7rem .4rem .2rem; font-size: .875rem; color: var(--ink-soft); }
.maplegend li { display: inline-flex; align-items: center; gap: .4rem; }
.dot { width: 12px; height: 12px; border-radius: 50%; }
.dot.tier-strong { background: #1F6B45; } .dot.tier-solid { background: #2F6F97; } .dot.tier-mixed { background: #9A5B00; } .dot.tier-concern { background: #A8262F; }
.mapview__card .row { grid-template-columns: 1fr; }
.mapview__card .row__stub { flex-direction: row; flex-wrap: wrap; grid-row: auto; border-right: 0; border-bottom: 2px dashed var(--line); justify-content: flex-start; text-align: left; padding: .8rem 1.1rem; }
.mapview__card .row__score { flex-direction: row; align-items: baseline; gap: .4rem; }
.mapview__card .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.mapview__prompt { padding: 1.2rem; border: 2px dashed var(--line); border-radius: var(--radius); color: var(--ink-soft); }
.mapview__card { max-width: 46rem; }

/* ---------- 9. Loading, empty and error states ---------- */
.state { margin-top: 1rem; padding: 2.2rem 1.4rem; text-align: center; background: var(--surface); border: 2px dashed var(--line); border-radius: var(--radius); }
.state svg { width: 64px; height: 64px; margin: 0 auto .9rem; color: var(--primary); }
.state h3 { font-size: 1.4rem; }
.state p { margin: .5rem auto 1.2rem; max-width: 46ch; color: var(--ink-soft); }
.state--error { border-color: var(--crit); border-style: solid; }
.state--error svg { color: var(--crit); }
.skeleton { display: grid; gap: .9rem; margin-top: 1rem; }
.skeleton__row { height: 168px; border-radius: var(--radius); border: 1px solid var(--line); background: linear-gradient(100deg, var(--surface) 30%, var(--surface-2) 50%, var(--surface) 70%) 0 0 / 300% 100%; animation: shimmer 1.3s linear infinite; }
@keyframes shimmer { to { background-position: -150% 0; } }

/* ---------- 10. Dialogs and the detail sheet ---------- */
dialog { border: 0; padding: 0; color: var(--ink); background: var(--paper); }
dialog::backdrop { background: rgba(10, 21, 19, .62); }
.modal { width: min(640px, 100vw - 1.5rem); max-height: calc(100dvh - 1.5rem); border-radius: 14px; box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .6); }
.modal--wide { width: min(1080px, 100vw - 1.5rem); }
.modal__inner { padding: 1.4rem; }
.sheet { margin: 0 0 0 auto; width: min(760px, 100vw); height: 100dvh; max-height: 100dvh; max-width: 100vw; }
.sheet__inner { padding: 1.25rem 1.25rem 3rem; }
dialog[open] { animation: dialog-in .25s ease both; }
.sheet[open] { animation-name: sheet-in; }
@keyframes dialog-in { from { opacity: 0; transform: translateY(12px); } }
@keyframes sheet-in { from { opacity: 0; transform: translateX(40px); } }

.dlg-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.dlg-head h2 { font-size: clamp(1.5rem, 1.2rem + 1.4vw, 2.1rem); }
.dlg-head h2:focus-visible { outline: none; }
.dlg-close { flex: none; width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; border: 1.5px solid var(--line); background: var(--surface); font-size: 1.5rem; line-height: 1; }
.detail__where { color: var(--ink-soft); margin-top: .3rem; }
.detail__actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1rem; }
.notice { display: flex; gap: .7rem; margin-top: 1rem; padding: .85rem 1rem; border-radius: 8px; border-left: 6px solid; }
.notice--critical { background: var(--crit-bg); border-color: var(--crit); }
.notice--serious { background: var(--ser-bg); border-color: var(--ser); }
.notice strong { display: block; }
.dsec { margin-top: 1.6rem; padding: 1.15rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.dsec > h3 { font-size: 1.25rem; margin-bottom: .8rem; }
.dsec__grid { display: grid; gap: 1.2rem; }
@media (min-width: 620px) { .dsec__grid { grid-template-columns: 1fr 1fr; } }

.scorehead { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.scorehead__num { font: 700 3.6rem/1 var(--font-display); letter-spacing: -.03em; }
.breakdown { width: 100%; border-collapse: collapse; margin-top: 1rem; font-size: .9375rem; }
.breakdown th, .breakdown td { text-align: left; vertical-align: top; padding: .6rem .4rem; border-top: 1px solid var(--line); }
.breakdown th { font-weight: 700; white-space: nowrap; }
.breakdown th .swatch { display: inline-block; margin-right: .45rem; }
.breakdown td.pts { text-align: right; font-weight: 800; white-space: nowrap; }
.breakdown td.why { color: var(--ink-soft); }
@media (max-width: 560px) {
  .breakdown tr { display: grid; grid-template-columns: 1fr auto; }
  .breakdown td.why { grid-column: 1 / -1; border-top: 0; padding-top: 0; }
}

/* CSS bar visualizations: tuition range, capacity, review spread */
.rangebar { position: relative; height: 14px; border-radius: 99px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); margin-top: .6rem; }
.rangebar__fill { position: absolute; top: 0; bottom: 0; left: var(--from); width: var(--span); min-width: 10px; border-radius: 99px; background: var(--primary); }
.rangebar__ends { display: flex; justify-content: space-between; font-size: .8125rem; color: var(--ink-soft); margin-top: .25rem; }
.capbar { display: flex; height: 22px; border-radius: 6px; overflow: hidden; box-shadow: inset 0 0 0 1px var(--line); margin-top: .6rem; background: var(--surface-2); }
.capbar__used { width: var(--used); background: var(--ink-soft); }
.capbar__open { width: var(--open); background: repeating-linear-gradient(45deg, var(--accent) 0 6px, color-mix(in srgb, var(--accent) 55%, var(--surface)) 6px 12px); }
.bigfact { font: 700 1.5rem/1.2 var(--font-display); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: .35rem 1rem; margin-top: .8rem; font-size: .9375rem; }
.kv dt { color: var(--ink-soft); } .kv dd { font-weight: 700; }

.timeline { overflow-x: auto; }
.timeline svg { width: 100%; min-width: 520px; height: auto; }
.tl-axis { stroke: var(--ink-soft); stroke-width: 2; }
.tl-stem { stroke: var(--line); stroke-width: 2; }
.tl-year { font: 700 12px var(--font-body); fill: var(--ink-soft); }
.tl-date { font: 600 11.5px var(--font-body); fill: var(--ink); text-anchor: middle; }
.tl-clean { fill: var(--ok-bg); stroke: var(--ok); stroke-width: 2; }
.tl-check { fill: none; stroke: var(--ok); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tl-key { display: flex; flex-wrap: wrap; gap: .3rem 1rem; font-size: .875rem; margin: .4rem 0 1rem; color: var(--ink-soft); }
.tl-key li { display: inline-flex; align-items: center; gap: .35rem; }
.insplist { display: grid; gap: .9rem; }
.insp { padding-left: 1rem; border-left: 4px solid var(--line); }
.insp--critical { border-color: var(--crit); } .insp--serious { border-color: var(--ser); } .insp--minor { border-color: var(--min); } .insp--clean { border-color: var(--ok); }
.insp h4 { font: 700 1rem var(--font-body); }
.insp h4 span { font-weight: 500; color: var(--ink-soft); }
.insp ul { margin-top: .4rem; display: grid; gap: .45rem; }
.insp li { display: grid; grid-template-columns: auto 1fr; gap: .15rem .6rem; align-items: start; font-size: .9375rem; }
.insp li .fix { grid-column: 2; font-size: .8438rem; color: var(--ink-soft); }
.insp li .fix.is-pending { color: var(--crit); font-weight: 700; }

.spread { display: grid; gap: .3rem; }
.spread__row { display: grid; grid-template-columns: 3.6rem 1fr 2.8rem; align-items: center; gap: .5rem; font-size: .875rem; }
.spread__bar { height: 10px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.spread__bar span { display: block; height: 100%; width: var(--w); background: var(--c-par); border-radius: 99px; }
.reviews { display: grid; gap: .9rem; margin-top: 1rem; }
.review { padding-top: .9rem; border-top: 1px solid var(--line); }
.review__meta { display: flex; flex-wrap: wrap; gap: .2rem .7rem; font-size: .875rem; color: var(--ink-soft); }
.review__meta b { color: var(--ink); }
.stars { color: var(--c-ratio); letter-spacing: 1px; }
.review p { margin-top: .3rem; max-width: 68ch; }

/* ---------- 11. Forms ---------- */
.form { display: grid; gap: 1rem; margin-top: 1.2rem; }
.form__row { display: grid; gap: 1rem; }
@media (min-width: 560px) { .form__row { grid-template-columns: 1fr 1fr; } }
.form label, .form legend { font-weight: 700; display: block; margin-bottom: .3rem; padding: 0; }
.form fieldset { border: 0; padding: 0; margin: 0; }
.form .opt { font-weight: 500; color: var(--ink-soft); }
.form .help { font-size: .8438rem; color: var(--ink-soft); margin-top: .25rem; }
.form textarea { min-height: 110px; resize: vertical; }
.radios { display: flex; flex-wrap: wrap; gap: .5rem; }
.radios label { display: inline-flex; align-items: center; gap: .5rem; margin: 0; padding: .5rem .9rem; border: 1.5px solid var(--ink-soft); border-radius: 8px; font-weight: 600; cursor: pointer; }
.radios input { accent-color: var(--primary); width: 1.1rem; height: 1.1rem; }
.radios label:has(input:checked) { border-color: var(--primary); background: var(--surface-2); }
[aria-invalid="true"] { border-color: var(--crit) !important; box-shadow: 0 0 0 2px color-mix(in srgb, var(--crit) 30%, transparent); }
.err { display: flex; gap: .4rem; margin-top: .35rem; color: var(--crit); font-weight: 700; font-size: .9063rem; }
.err::before { content: "!"; flex: none; display: inline-grid; place-items: center; width: 1.2rem; height: 1.2rem; border-radius: 50%; background: var(--crit); color: var(--crit-bg); font-size: .8rem; }
.errsummary { padding: 1rem; border-radius: 8px; background: var(--crit-bg); border-left: 6px solid var(--crit); }
.errsummary h3 { font: 700 1.05rem var(--font-body); color: var(--crit); }
.errsummary ul { list-style: disc; padding-left: 1.2rem; margin-top: .4rem; }
.errsummary a { color: var(--crit); font-weight: 700; }
.form__foot { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }
.spinner { width: 1em; height: 1em; border-radius: 50%; border: 2.5px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(1turn); } }
.success { text-align: center; padding: 1.5rem .5rem .5rem; }
.success svg { width: 72px; height: 72px; margin: 0 auto 1rem; color: var(--ok); }
.success p { color: var(--ink-soft); margin: .6rem auto 1.3rem; max-width: 44ch; }

/* ---------- 12. Compare table ---------- */
.cmp-scroll { overflow-x: auto; margin-top: 1.1rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.cmp { width: 100%; min-width: 640px; border-collapse: collapse; font-size: .9375rem; }
.cmp th, .cmp td { padding: .7rem .8rem; text-align: left; vertical-align: top; border-top: 1px solid var(--line); }
.cmp thead th { border-top: 0; vertical-align: bottom; background: var(--surface-2); }
.cmp thead h3 { font-size: 1.1rem; }
.cmp tbody th { width: 9.5rem; color: var(--ink-soft); font-weight: 700; position: sticky; left: 0; background: var(--surface); }
.cmp td.is-best { background: var(--ok-bg); }
.cmp .besttag { display: inline-block; margin-left: .4rem; padding: 0 .4rem; border-radius: 4px; background: var(--ok); color: var(--ok-bg); font-size: .75rem; font-weight: 800; }
.cmp__score { font: 700 2rem/1 var(--font-display); }
.cmp .strip { margin-top: .4rem; }
.cmp__colactions { display: flex; flex-wrap: wrap; gap: .2rem .8rem; margin-top: .3rem; }

/* ---------- 13. Tray and toasts ---------- */
.tray { position: fixed; inset: auto 0 0 0; z-index: 20; background: var(--hero); color: var(--hero-ink); border-top: 4px solid var(--accent); animation: tray-in .25s ease both; }
@keyframes tray-in { from { transform: translateY(100%); } }
.tray__inner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem 1rem; padding-block: .6rem; }
.tray__slots { display: flex; flex-wrap: wrap; gap: .4rem; }
.tray__slots li { display: inline-flex; align-items: center; gap: .1rem; padding-left: .7rem; border-radius: 99px; background: color-mix(in srgb, var(--hero-ink) 12%, transparent); font-size: .9063rem; font-weight: 600; }
.tray__slots button { width: 32px; height: 32px; border: 0; border-radius: 50%; background: none; color: inherit; font-size: 1.15rem; line-height: 1; }
.tray__actions { display: flex; align-items: center; gap: .7rem; flex-wrap: wrap; }
.tray__hint { font-size: .875rem; color: var(--hero-soft); }
.tray .linkbtn { color: var(--hero-ink); }
.tray__slots button:hover { background: color-mix(in srgb, var(--hero-ink) 18%, transparent); }
@media (max-width: 639px) { .tray__slots { display: none; } body.has-tray { padding-bottom: 4.5rem; } }
.tray :focus-visible { outline-color: var(--accent); }

.toasts { position: fixed; z-index: 1000; right: 1rem; bottom: 6.5rem; display: grid; gap: .5rem; width: min(360px, calc(100vw - 2rem)); pointer-events: none; }
.toast { pointer-events: auto; padding: .8rem 1rem; border-radius: 8px; background: var(--ink); color: var(--paper); font-weight: 600; border-left: 6px solid var(--accent); box-shadow: var(--shadow); animation: dialog-in .25s ease both; }
.toast--success { border-color: #4CC38A; } .toast--error { border-color: #FF7A7A; }

/* ---------- 14. Scoring explainer, state demo, footer ---------- */
.scoring { background: var(--surface); border-block: 1px solid var(--line); padding: 3rem 0; }
.scoring h2, .statedemo h2 { font-size: clamp(1.6rem, 1.2rem + 1.6vw, 2.3rem); }
.scoring__lede { margin-top: .8rem; max-width: 68ch; color: var(--ink-soft); }
.scoring__grid { display: grid; gap: 1rem; margin-top: 1.8rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); }
.scorepart { padding: 1.1rem 1.1rem 1.2rem; border-radius: var(--radius); background: var(--paper); border-top: 8px solid var(--c); }
.scorepart h3 { font-size: 1.15rem; display: flex; align-items: baseline; gap: .6rem; }
.scorepart__pts { font-size: 2.2rem; color: var(--c); }
.scorepart p { margin-top: .5rem; font-size: .9688rem; }
.scoring__note { margin-top: 1.6rem; max-width: 72ch; padding-left: 1rem; border-left: 4px solid var(--accent); }
.statedemo { padding: 3rem 0; }
.statedemo p { margin-top: .6rem; color: var(--ink-soft); max-width: 68ch; }
.statedemo__btns { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: 1.2rem; align-items: center; }
.statedemo__fail { flex-basis: 100%; }
.site-footer { background: var(--hero); color: var(--hero-soft); padding: 1.6rem 0; font-size: .9375rem; }
.site-footer strong { color: var(--hero-ink); }

/* ---------- 15. Motion preferences ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .001ms !important; animation-delay: 0s !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  .skeleton__row { animation: none; background: var(--surface-2); }
  .spinner { animation: none; border-right-color: currentColor; opacity: .6; }
}

/* ---------- 16. Unofficial-score presentation and adjustable weights ---------- */
/* Standing disclosure band under the hero */
.disclosure { background: var(--accent); color: var(--accent-ink); }
.disclosure__inner { display: flex; gap: .8rem; align-items: flex-start; padding-block: .9rem; }
.disclosure svg { width: 26px; height: 26px; flex: none; margin-top: .1rem; }
.disclosure p { max-width: 100ch; font-size: .9688rem; }
.disclosure a { color: inherit; font-weight: 700; }
.disclosure :focus-visible { outline-color: var(--accent-ink); }

/* Source tags: who stands behind a piece of information */
.src { display: inline-flex; align-items: center; gap: .3rem; padding: .1rem .5rem; border-radius: 4px; font: 700 .78rem/1.5 var(--font-body); letter-spacing: 0; white-space: nowrap; vertical-align: middle; }
.src svg { width: 13px; height: 13px; }
.src--official { background: var(--ink); color: var(--paper); }
.src--ours { border: 1.5px dashed var(--ink-soft); color: var(--ink-soft); }

/* Weight summary above the results */
.weightbar { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .2rem 1rem; margin-top: 1rem; padding: .7rem 1rem; border: 1.5px dashed var(--ink-soft); border-radius: var(--radius); font-size: .9063rem; }
.weightbar p { max-width: 80ch; }
.weightbar__actions { display: flex; gap: 1rem; }

/* Detail sheet: estimate is dashed, state record is solid */
.dsec--ours { border: 2px dashed var(--ink-soft); }
.dsec > h3 { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .7rem; }
.disclaim { padding: .7rem .9rem; border-radius: 8px; background: var(--surface-2); font-size: .9375rem; margin-bottom: 1rem; }
.scorehead .btn { margin-left: auto; }
.breakdown tr.is-off th, .breakdown tr.is-off td { color: var(--ink-soft); }
.breakdown .why b { color: var(--ink); }
.whysrc { display: block; font-size: .8438rem; }
.cmp tbody th small { display: block; font-weight: 500; }

/* Is / is not */
.scoring__split { display: grid; gap: 1rem; margin-top: 1.4rem; }
@media (min-width: 720px) { .scoring__split { grid-template-columns: 1fr 1fr; } }
.scoring__split > div { padding: 1.1rem 1.2rem; border-radius: var(--radius); }
.scoring__is { border: 2px dashed var(--ink-soft); }
.scoring__isnt { background: var(--ink); color: var(--paper); }
.scoring__split h3 { font-size: 1.3rem; margin-bottom: .5rem; }
.scoring__split ul { list-style: disc; padding-left: 1.2rem; display: grid; gap: .3rem; }

/* Weights editor */
.weights { margin-top: 2.5rem; }
.weights__title { font-size: clamp(1.4rem, 1.1rem + 1.2vw, 1.9rem); }
.glance { position: sticky; top: 0; z-index: 5; display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; margin-top: 1.2rem; padding: .7rem .9rem; background: var(--hero); color: var(--hero-ink); border-radius: 0 0 var(--radius) var(--radius); box-shadow: var(--shadow); }
.glance #glance-strip { flex: 1 1 260px; }
.glance .formula__strip { margin-top: 0; height: 34px; }
.glance .formula__block b { font-size: 1rem; }
.glance p { font-weight: 700; font-size: .9375rem; }
.glance .btn { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.glance :focus-visible { outline-color: var(--accent); }
.formula__block { min-width: 0; overflow: hidden; transition: flex-grow .25s ease; }
.weights__presets { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .8rem; margin-top: 1.2rem; font-weight: 700; }
.weights__presetbtns { display: flex; flex-wrap: wrap; gap: .4rem; }
.weights__layout { display: grid; gap: 1.5rem; margin-top: 1.4rem; align-items: start; }
@media (min-width: 1000px) { .weights__layout { grid-template-columns: minmax(0, 1fr) 320px; } .rank { position: sticky; top: 5.5rem; } }
.factors { display: grid; gap: 1rem; }
.factor { background: var(--paper); border-radius: var(--radius); border-left: 8px solid var(--c); padding: 1.1rem 1.2rem 1.2rem; display: grid; gap: 1rem; }
@media (min-width: 760px) { .factor { grid-template-columns: 250px minmax(0, 1fr); } .factor__head { grid-column: 1 / -1; } }
.factor__head { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .8rem; }
.factor__head h3 { font-size: 1.25rem; }
.factor__weight label { font-weight: 700; display: block; }
.factor__weight output { display: block; font: 700 1.5rem/1.2 var(--font-display); color: var(--c); margin-top: .1rem; }
.factor__facts { display: grid; gap: .6rem; font-size: .9375rem; }
.factor__facts dt { font-weight: 700; }
.factor__facts dd { color: var(--ink-soft); max-width: 70ch; }
.rank { background: var(--paper); border-radius: var(--radius); padding: 1.1rem 1.2rem; order: -1; }
@media (min-width: 1000px) { .rank { order: 0; } }
.rank h3 { font-size: 1.15rem; }
.rank ol { margin-top: .7rem; display: grid; gap: .6rem; }
.rank li { display: grid; grid-template-columns: 2.6rem 1fr; column-gap: .6rem; align-items: baseline; }
.rank__score { font: 700 1.4rem/1 var(--font-display); grid-row: span 2; }
.rank .namelink { font-weight: 700; font-size: .9688rem; text-decoration-thickness: 2px; }
.move { grid-column: 2; font-size: .8438rem; color: var(--ink-soft); }
.move--up { color: var(--ok); font-weight: 700; } .move--down { color: var(--crit); font-weight: 700; }
@media (max-width: 639px) { .tray__actions { flex-wrap: nowrap; gap: .5rem; width: 100%; } .tray__hint { flex: 1; font-size: .8125rem; } .tray .btn { min-height: 40px; padding: .4rem .7rem; } }
