/* Fieldbook (plan 13): a surveyor's notebook. Cool sage paper, hairlines,
   flat surfaces, a narrow editorial serif for titles, a workmanlike sans
   for everything else, and a mono for figures so columns line up.
   Hierarchy comes from rules and weight, not shadows. Every colour is a
   token here; the canvas map reads the --map-* and --mark-* tokens. */

:root {
    --bg: #f2f3ee;
    --bg-2: #e6e9e1;
    --card: #fbfbf8;
    --ink: #1e2621;
    --muted: #58635a;
    --line: #cfd5cb;
    --line-strong: #a7b0a6;
    --home: #2f5d3a;
    --home-ink: #f3f7f2;
    --away: #1f5f8b;
    --away-ink: #eef5fa;
    --warn: #8a5a1f;
    --scrim: rgba(30, 38, 33, 0.42);
    --accent: var(--home);
    --accent-ink: var(--home-ink);
    --accent-soft: color-mix(in srgb, var(--accent) 12%, var(--card));
    --shadow: none;
    --display: "Newsreader", "Iowan Old Style", Georgia, serif;
    --sans: "Source Sans 3", "Segoe UI", Arial, sans-serif;
    --mono: "JetBrains Mono", "SFMono-Regular", Menlo, monospace;
    --radius: 6px;
    --radius-s: 4px;
    --motion: 150ms ease-out;
    /* Map: an atlas sheet. Light marks are hollow rings except the top three. */
    --map-water: #dfe5e3;
    --map-land: #ebeee6;
    --map-lift: #f6f8f2;
    --map-dim: #e2e6de;
    --map-line: #a7b0a6;
    --map-coast: #6c786f;
    --map-far: #bfc8be;
    --mark-mid: #5e8a69;
    --mark-rest: #8d9a90;
    --mark-glow: rgba(47, 93, 58, 0.18);
    --mark-style: ring;
    --temp-1: #6f93c4;
    --temp-2: #8fb3cf;
    --temp-3: #9db89a;
    --temp-4: #d9a25e;
    --temp-5: #c9663d;
    color-scheme: light;
}

/* Dark: Fieldbook's night palette with Lantern's map rules (filled marks, a
   soft halo on the ones that matter, haloed labels). */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #161a17;
        --bg-2: #1e2420;
        --card: #1b211d;
        --ink: #e4e9e2;
        --muted: #9eaaa0;
        --line: #333c36;
        --line-strong: #4a554d;
        --home: #8fc79a;
        --home-ink: #10231a;
        --away: #7fb9e0;
        --away-ink: #0b1d2a;
        --warn: #e0b36a;
        --scrim: rgba(5, 8, 6, 0.6);
        --map-water: #121715;
        --map-land: #1f2622;
        --map-lift: #29312c;
        --map-dim: #1a201c;
        --map-line: #3f4a43;
        --map-coast: #6f7f74;
        --map-far: #2c352f;
        --mark-mid: #6fa17c;
        --mark-rest: #6c7a70;
        --mark-glow: rgba(143, 199, 154, 0.22);
        --mark-style: glow;
        --temp-1: #5f88c0;
        --temp-2: #7ba6c9;
        --temp-3: #86ad84;
        --temp-4: #d4a35f;
        --temp-5: #d4714a;
        color-scheme: dark;
    }
}

:root[data-theme="dark"] {
    --bg: #161a17;
    --bg-2: #1e2420;
    --card: #1b211d;
    --ink: #e4e9e2;
    --muted: #9eaaa0;
    --line: #333c36;
    --line-strong: #4a554d;
    --home: #8fc79a;
    --home-ink: #10231a;
    --away: #7fb9e0;
    --away-ink: #0b1d2a;
    --warn: #e0b36a;
    --scrim: rgba(5, 8, 6, 0.6);
    --map-water: #121715;
    --map-land: #1f2622;
    --map-lift: #29312c;
    --map-dim: #1a201c;
    --map-line: #3f4a43;
    --map-coast: #6f7f74;
    --map-far: #2c352f;
    --mark-mid: #6fa17c;
    --mark-rest: #6c7a70;
    --mark-glow: rgba(143, 199, 154, 0.22);
    --mark-style: glow;
    --temp-1: #5f88c0;
    --temp-2: #7ba6c9;
    --temp-3: #86ad84;
    --temp-4: #d4a35f;
    --temp-5: #d4714a;
    color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    min-height: 100dvh;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--sans);
    font-size: 1.05rem;
    line-height: 1.45;
}

body[data-path="vacation"] {
    --accent: var(--away);
    --accent-ink: var(--away-ink);
}

button, input, select { font: inherit; color: inherit; }

button { cursor: pointer; }

button, input, select, .card, .chip, .pill, summary {
    transition: background-color var(--motion), border-color var(--motion), color var(--motion);
}

a { color: var(--accent); text-underline-offset: 0.15em; }

/* ---------------------------------------------------------------- bar */

.bar {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 0.6rem max(16px, env(safe-area-inset-right, 0px)) 0.6rem max(16px, env(safe-area-inset-left, 0px));
    padding-top: calc(0.6rem + env(safe-area-inset-top, 0px));
    background: color-mix(in srgb, var(--bg) 92%, transparent);
    backdrop-filter: blur(10px);
    border-bottom: 2px solid var(--line);
}

.logo, h1, h2, .place-name, .filter-block h3 {
    font-family: var(--display);
    font-weight: 600;
    letter-spacing: -0.02em;
}

.logo { color: var(--ink); text-decoration: none; font-size: 1.3rem; }

.theme-switch {
    display: inline-flex;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
}

.theme-switch button {
    min-height: 36px;
    padding: 0 0.7rem;
    border: 0;
    background: transparent;
    color: var(--muted);
    font-size: 0.86rem;
}

.theme-switch button + button { border-left: 1px solid var(--line); }

.theme-switch button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }

/* ---------------------------------------------------------------- type */

main {
    width: min(1120px, 100%);
    margin: 0 auto;
    padding-block: 1.5rem 4rem;
    padding-left: max(16px, env(safe-area-inset-left, 0px));
    padding-right: max(16px, env(safe-area-inset-right, 0px));
}

h1 { font-size: clamp(2.3rem, 7vw, 4rem); line-height: 1.04; margin: 0.2rem 0 0.6rem; text-wrap: balance; }

h2 { font-size: clamp(1.6rem, 4vw, 2.2rem); line-height: 1.12; margin: 0.4rem 0; text-wrap: balance; }

.eyebrow, .lead, .fade, .hint, .weight { color: var(--muted); }

.eyebrow, .limits-label, legend, .tune-caption {
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--muted);
}

.eyebrow { margin: 0; }

.lead { max-width: 40rem; }

.score, .limit-read, .badge, .section-mark, .anchor-name, .page-label, .members-tally, .tune-open.is-set {
    font-family: var(--mono);
    font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------- controls */

.choices, .segment {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.choices { margin: 1rem 0; }

.choices button, .segment button, .go, .text, .chip, summary {
    min-height: 44px;
}

.choices button, .segment button {
    border: 1px solid var(--line);
    background: var(--card);
    border-radius: var(--radius);
    padding: 0.75rem 0.95rem;
    text-align: left;
}

.choices button { display: flex; flex-direction: column; align-items: flex-start; gap: 0.1rem; flex: 1 1 14rem; max-width: 100%; }

#splash .choices button { flex-basis: 16rem; padding: 1.1rem 1.2rem; font-family: var(--display); font-size: 1.3rem; }

#splash .choices button span { font-family: var(--sans); }

.choices button span, .fade { color: var(--muted); font-size: 0.95rem; }

.choices button:hover, .segment button:hover, .pill:hover, .weight-pick:hover { border-color: var(--line-strong); }

.choices button[aria-pressed="true"], .segment button[aria-pressed="true"] {
    background: var(--accent);
    color: var(--accent-ink);
    border-color: var(--accent);
}

.choices button[aria-pressed="true"] span { color: color-mix(in srgb, var(--accent-ink) 82%, transparent); }

.cats button { min-width: min(100%, 220px); }

.aim, fieldset {
    border: 0;
    margin: 0.8rem 0 0;
    padding: 0;
}

fieldset {
    border-top: 1px solid var(--line);
    padding-top: 0.8rem;
}

legend { padding: 0; margin-bottom: 0.45rem; }

.aim { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; }

.segment button { border-radius: 999px; padding: 0.5rem 0.9rem; }

.segment.tiny button, .segment.slim button { min-height: 36px; padding: 0.3rem 0.7rem; font-size: 0.92rem; }

.age-at, label {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin-top: 0.7rem;
}

input, select {
    min-height: 44px;
    border-radius: var(--radius-s);
    border: 1px solid var(--line);
    background: var(--bg);
    padding: 0 0.75rem;
}

input::placeholder { color: var(--muted); opacity: 1; }

.weight { font-size: 1.02rem; margin: 0.4rem 0 0; }

.hint { color: var(--accent); }

.go {
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    background: var(--accent);
    color: var(--accent-ink);
    padding: 0.7rem 1.3rem;
    min-height: 48px;
    font-weight: 600;
    font-size: 0.92rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.go:disabled { opacity: 0.45; cursor: not-allowed; }

.go.slim { min-height: 44px; }

.text {
    border: 0;
    background: transparent;
    color: var(--muted);
    padding: 0;
    text-decoration: underline;
    text-underline-offset: 0.2em;
}

.text:hover { color: var(--ink); }

details { margin-top: 0.8rem; }

summary {
    cursor: pointer;
    color: var(--ink);
}

/* ---------------------------------------------------------------- results */

.result-tools, .chips, .card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.result-head { margin-bottom: 1rem; }

.chip {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--card);
    color: var(--ink);
    padding: 0 0.3rem 0 0.85rem;
    font-size: 0.95rem;
}

.chip button {
    min-width: 40px;
    min-height: 40px;
    border: 0;
    background: transparent;
    color: var(--muted);
    font-size: 1.1rem;
}

.layout { display: grid; gap: 1.25rem; }

.map-wrap { position: relative; }

#map {
    width: 100%;
    height: 280px;
    background: var(--map-water);
    border: 1px solid var(--map-coast);
    border-radius: var(--radius);
    display: block;
    touch-action: manipulation;
}

.map-legend { margin: 0.4rem 0 0; font-size: 0.88rem; }

.legend-mark {
    display: inline-block;
    width: 0.7rem;
    height: 0.7rem;
    margin: 0 0.25rem 0 0.5rem;
    border-radius: 999px;
    vertical-align: -0.05em;
    box-shadow: 0 0 0 1.5px var(--card);
}

.legend-mark.is-top { background: var(--accent); }

.legend-mark.is-mid { background: var(--card); box-shadow: inset 0 0 0 2px var(--mark-mid); }

.legend-mark.is-rest { background: var(--card); box-shadow: inset 0 0 0 1.5px var(--mark-rest); width: 0.55rem; height: 0.55rem; }

:root[data-theme="dark"] .legend-mark.is-mid { background: var(--mark-mid); box-shadow: 0 0 0 1.5px var(--card); }

:root[data-theme="dark"] .legend-mark.is-rest { background: var(--mark-rest); box-shadow: 0 0 0 1.5px var(--card); }

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .legend-mark.is-mid { background: var(--mark-mid); box-shadow: 0 0 0 1.5px var(--card); }
    :root:not([data-theme="light"]) .legend-mark.is-rest { background: var(--mark-rest); box-shadow: 0 0 0 1.5px var(--card); }
}

.sparse-tag {
    font-family: var(--mono);
    font-size: 0.72rem;
    letter-spacing: 0;
    color: var(--warn);
    white-space: nowrap;
}

#ask .sparse-tag { display: block; margin-top: 0.15rem; }

/* Inside a pressed button the background is the accent, so the tag takes
   the button's own text colour instead of the warning gold. */
button[aria-pressed="true"] .sparse-tag { color: inherit; opacity: 0.85; }

.drawer .limits { margin-top: 0.9rem; border-top: 1px solid var(--line); }

.gap-note .chips { flex: 1 1 100%; margin: 0.3rem 0 0.2rem; }

/* Plan 07: hearts, blurbs, climate strips, hand-off links, the shortlist panel. */

.heart {
    display: inline-grid;
    place-items: center;
    width: 36px;
    height: 36px;
    min-height: 36px;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: transparent;
    color: var(--muted);
}

.heart:hover { color: var(--ink); border-color: var(--line-strong); }

.heart[aria-pressed="true"] { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }

.heart[aria-pressed="true"] svg path { fill: currentColor; }

.blurb { margin: 0.35rem 0 0; color: var(--ink); font-size: 0.95rem; }

.near { margin: 0.15rem 0 0; color: var(--muted); font-size: 0.9rem; }

.strip-wrap { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.4rem; }

.strip-wrap-wide { flex-direction: column; align-items: flex-start; gap: 0.2rem; }

.strip { display: block; overflow: visible; }

.strip-wide { width: 100%; max-width: 460px; height: auto; }

.strip-bar { stroke: none; }

.strip-t1 { fill: var(--temp-1); }
.strip-t2 { fill: var(--temp-2); }
.strip-t3 { fill: var(--temp-3); }
.strip-t4 { fill: var(--temp-4); }
.strip-t5 { fill: var(--temp-5); }

.strip-freeze { stroke: var(--line-strong); stroke-width: 1; stroke-dasharray: 2 3; }

.strip-month { fill: var(--ink); fill-opacity: 0.08; }

.strip-tick { font-family: var(--sans); font-size: 8.5px; fill: var(--muted); }

.strip-tick-soft { font-size: 8px; }

.strip-num { font-family: var(--mono); font-size: 8.5px; fill: var(--muted); font-variant-numeric: tabular-nums; }

.strip-num-strong { fill: var(--ink); font-weight: 600; }

.strip-wide .strip-num, .strip-wide .strip-tick { font-size: 9.5px; }

.strip-note { color: var(--muted); font-size: 0.78rem; }

.handoff { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.3rem 0 0.2rem; }

.handoff-link {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    padding: 0 0.75rem;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    color: var(--ink);
    text-decoration: none;
    font-size: 0.9rem;
}

.handoff-link:hover { background: var(--accent-soft); border-color: var(--accent); }

.filters-open .count { font-family: var(--mono); color: var(--accent); }

.filters-open .count:empty { display: none; }

.rest-row { display: flex; align-items: center; gap: 0.3rem; }

.rest-row .rest-main { flex: 1 1 auto; min-width: 0; }

.rest-row .heart { width: 32px; height: 32px; min-height: 32px; flex: 0 0 32px; }

.sheet-head .heart { margin: 0.4rem 0 0; }

.save-block, .saved-searches, .saved-places { padding: 0.6rem 0; border-top: 1px solid var(--line); }

.save-block:first-child { border-top: 0; padding-top: 0.2rem; }

.save-block h3, .saved-searches h3, .saved-places h3 { margin: 0.3rem 0 0.4rem; font-family: var(--display); font-size: 1.05rem; }

.save-form { display: flex; gap: 0.5rem; }

.save-form input { flex: 1 1 auto; min-width: 0; }

.saved-list { margin: 0; padding: 0; list-style: none; }

.saved-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.3rem 0.8rem; padding: 0.4rem 0; border-top: 1px solid var(--line); }

.saved-name { color: var(--ink); font-weight: 500; }

.compare-scroll { overflow-x: auto; margin: 0.4rem -1rem 0; padding: 0 1rem; }

.compare { border-collapse: collapse; min-width: 100%; font-size: 0.9rem; }

.compare th, .compare td { padding: 0.4rem 0.5rem; vertical-align: top; text-align: left; border-top: 1px solid var(--line); min-width: 9rem; }

.compare thead th { border-top: 0; vertical-align: bottom; }

.compare th[scope="row"], .compare-corner { position: sticky; left: 0; background: var(--card); min-width: 7rem; font-weight: 500; color: var(--muted); }

.compare-name { display: block; font-family: var(--display); font-size: 1rem; color: var(--ink); }

.compare-blurb { display: block; margin: 0.15rem 0 0.25rem; color: var(--muted); font-size: 0.8rem; font-weight: 400; }

.compare-cell { display: block; }

.compare-value { display: block; font-family: var(--mono); font-variant-numeric: tabular-nums; color: var(--ink); }

.compare-text { display: block; color: var(--ink); font-size: 0.9rem; }

.compare .fig-scale { margin-top: 0.2rem; }

.compare td.is-best { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }

.compare .handoff { margin-top: 0.2rem; }

.compare-wrap { margin-top: 0.2rem; }

.map-reset {
    position: absolute;
    top: 0.7rem;
    right: 0.7rem;
    min-height: 40px;
    border-radius: var(--radius);
    border: 1px solid var(--line-strong);
    background: var(--card);
    padding: 0 0.9rem;
    font-size: 0.92rem;
}

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-left: 3px solid var(--line);
    border-radius: var(--radius);
    padding: 0.85rem 1rem 0.9rem;
    margin-bottom: 0.7rem;
}

.card:hover { border-left-color: var(--line-strong); }

.card.is-selected { border-color: var(--accent); border-left-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 35%, transparent); }

.card-main {
    width: 100%;
    border: 0;
    background: transparent;
    text-align: left;
    padding: 0;
    min-height: 44px;
}

.place-name { font-size: 1.35rem; display: block; line-height: 1.15; }

.badge {
    display: inline-grid;
    place-items: center;
    min-width: 1.7rem;
    height: 1.7rem;
    margin-right: 0.4rem;
    border-radius: 999px;
    background: var(--accent);
    color: var(--accent-ink);
    font-size: 0.9rem;
    font-weight: 500;
    vertical-align: 0.15em;
}

.facts { margin: 0.4rem 0 0; padding: 0; list-style: none; color: var(--muted); font-size: 0.95rem; }

.facts li + li { margin-top: 0.15rem; }

.score { display: block; margin: 0.5rem 0 0; padding-top: 0.4rem; border-top: 1px solid var(--line); color: var(--ink); font-size: 1rem; }

.note { color: var(--muted); font-size: 0.95rem; }

.empty { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; }

.backdrop {
    position: fixed;
    inset: 0;
    background: var(--scrim);
    z-index: 20;
}

/* ---------------------------------------------------------------- drawer and sheet */

.drawer, .sheet {
    background: var(--card);
    z-index: 30;
    display: flex;
    flex-direction: column;
}

.panel-head, .panel-foot {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 0.8rem 1rem;
}

.panel-body { overflow: auto; padding: 0 1rem 1rem; }

.panel-foot { border-top: 1px solid var(--line); padding-bottom: calc(0.8rem + env(safe-area-inset-bottom, 0px)); }

.panel-foot .go { width: 100%; }

.filter-block { border-top: 1px solid var(--line); padding: 0.3rem 0 0.8rem; }

.drawer details.filter-block {
    margin: 0;
    padding: 0;
}

.drawer details.filter-block > summary {
    position: sticky;
    top: 0;
    z-index: 4;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--card);
    padding: 0.55rem 0;
    font-family: var(--display);
    font-size: 1.1rem;
    font-weight: 600;
    list-style: none;
}

.drawer details.filter-block > summary::-webkit-details-marker { display: none; }

.drawer details.filter-block > summary::after {
    content: "";
    margin-left: auto;
    width: 8px;
    height: 8px;
    border-right: 2px solid var(--muted);
    border-bottom: 2px solid var(--muted);
    transform: rotate(45deg);
}

.drawer details.filter-block[open] > summary::after { transform: rotate(-135deg); }

.drawer details.filter-block[open] > summary {
    box-shadow: 0 1px 0 var(--line);
}

.drawer details.filter-block[open] {
    padding-bottom: 0.35rem;
}

.section-mark {
    margin-left: 0;
    padding: 0.05rem 0.5rem;
    border-radius: 999px;
    background: var(--accent);
    color: var(--accent-ink);
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0;
    text-transform: none;
}

.section-mark:empty { display: none; }

.drawer-find { padding: 0 1rem 0.6rem; }

.drawer-find input { width: 100%; }

.filter-block h3 { font-size: 1.2rem; margin: 0.6rem 0; }

.check { flex-direction: row; align-items: center; gap: 0.6rem; min-height: 44px; }

.check input { width: 1.2rem; height: 1.2rem; accent-color: var(--accent); }

.figure { padding: 0.7rem 0; border-top: 1px solid var(--line); }

/* Plan 15: the ZIP sheet */
.sheet-head { padding-bottom: 0.6rem; border-bottom: 1px solid var(--line); }

.sheet-rank, .fig-value, .fig-pct { font-family: var(--mono); font-variant-numeric: tabular-nums; }

.sheet-meta, .fig-vs { font-variant-numeric: tabular-nums; }

.sheet-meta { margin: 0; color: var(--muted); font-size: 0.85rem; }

.sheet-rank { margin: 0.25rem 0 0; color: var(--ink); font-size: 0.95rem; }

.sheet-head .fade { margin: 0.4rem 0 0; font-size: 0.92rem; }

.why { margin: 0.6rem 0 0.2rem; padding: 0.2rem 0.8rem 0.5rem; border-left: 3px solid var(--accent); background: var(--accent-soft); border-radius: 0 var(--radius) var(--radius) 0; }

.why h3 { margin: 0.5rem 0 0.2rem; font-size: 1.05rem; }

.sheet-cat { margin: 0; border-top: 1px solid var(--line); }

.sheet-cat > summary { padding: 0.6rem 0; font-family: var(--display); font-size: 1.05rem; color: var(--ink); }

.sheet-cat details { margin: 0 0 0 0.6rem; }

.sheet-cat details > summary { padding: 0.4rem 0; color: var(--muted); font-size: 0.95rem; }

.fig-row {
    display: grid;
    grid-template-columns: minmax(7rem, 1fr) auto;
    grid-template-areas: "label value" "scale scale" "note note" "vs vs";
    column-gap: 0.7rem;
    row-gap: 0.15rem;
    align-items: baseline;
    padding: 0.45rem 0;
    border-top: 1px solid var(--line);
}

.why .fig-row:first-of-type, .sheet-cat .fig-row:first-of-type { border-top: 0; }

.fig-label { grid-area: label; display: flex; align-items: center; gap: 0.4rem; min-width: 0; }

.fig-label strong { font-weight: 500; }

.fig-label .info { flex: 0 0 auto; }

.fig-value { grid-area: value; justify-self: end; text-align: right; font-size: 0.92rem; color: var(--ink); }

.fig-scale { grid-area: scale; }

.fig-note { grid-area: note; }

.fig-vs { grid-area: vs; }

@media (max-width: 420px) {
    .fig-row { grid-template-columns: 1fr; grid-template-areas: "label" "value" "scale" "note" "vs"; }
    .fig-value { justify-self: start; text-align: left; }
}

.fig-note { margin: 0.25rem 0 0; color: var(--muted); font-size: 0.88rem; }

.fig-scale { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.15rem; }

.fig-bar { position: relative; flex: 1 1 6rem; height: 6px; border-radius: 999px; background: var(--bg-2); overflow: visible; }

.fig-bar i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 999px; background: var(--accent); }

.fig-bar .tick { position: absolute; top: -3px; width: 2px; height: 12px; margin-left: -1px; background: var(--ink); }

.fig-pct { font-size: 0.78rem; color: var(--muted); white-space: nowrap; }

.fig-pct b { font-weight: 500; color: var(--ink); }

.fig-dir { font-size: 0.78rem; color: var(--muted); white-space: nowrap; }

.fig-vs { margin: 0.2rem 0 0; font-size: 0.82rem; color: var(--muted); }


.figure strong { display: block; }

.figure p { margin: 0.2rem 0 0; color: var(--muted); }

#results { scroll-margin-top: 5rem; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

@media (min-width: 860px) {
    .layout { grid-template-columns: minmax(320px, 1.1fr) minmax(320px, 0.9fr); align-items: start; }
    .map-wrap { position: sticky; top: 5rem; }
    #map { height: min(70vh, 640px); }
    .drawer {
        position: fixed;
        top: 4.2rem;
        right: 0;
        bottom: 0;
        width: min(460px, 100%);
        border-left: 1px solid var(--line);
    }
    .sheet {
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        width: min(560px, calc(100% - 2rem));
        max-height: min(78dvh, 740px);
        border: 1px solid var(--line);
        border-radius: var(--radius);
    }
}

@media (max-width: 859px) {
    .drawer, .sheet {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        max-height: 86dvh;
        border-top: 1px solid var(--line);
        border-radius: var(--radius) var(--radius) 0 0;
    }
}

.filters-open {
    border: 1px solid var(--line);
    background: transparent;
    color: var(--muted);
    border-radius: 999px;
    min-height: 32px;
    padding: 0.15rem 0.7rem;
    font-size: 0.86rem;
    line-height: 1.2;
}

.filters-open:hover { color: var(--ink); border-color: var(--line-strong); }

.filters-open.is-needed {
    color: var(--ink);
    border-color: var(--ink);
    animation: filters-flash 0.7s ease-in-out 3;
}

@keyframes filters-flash {
    0%, 100% { box-shadow: 0 0 0 0 transparent; }
    40% { box-shadow: 0 0 0 7px color-mix(in srgb, var(--ink) 20%, transparent); background: var(--card); }
}

@media (prefers-reduced-motion: reduce) {
    .filters-open.is-needed { animation: none; }
}

.panel-title {
    display: flex;
    align-items: center;
    gap: 0.45rem;
}

.panel-title h2 { margin: 0; font-size: 1.5rem; }

#sheet-title { font-size: 1.5rem; margin: 0; }

.info {
    width: 1.15rem;
    height: 1.15rem;
    min-height: 1.15rem;
    padding: 0;
    border-radius: 999px;
    border: 1px solid var(--line-strong);
    background: transparent;
    color: var(--muted);
    font-family: var(--display);
    font-size: 0.7rem;
    line-height: 1;
}

.info[aria-expanded="true"] {
    border-color: var(--ink);
    color: var(--ink);
}

.filters-note {
    margin: 0 1rem 0.7rem;
    color: var(--muted);
    font-size: 0.95rem;
}

.check span { flex: 1; }

.cat-weight {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.45rem 0.7rem;
    margin: 0.35rem 0 0.15rem;
}

.cat-weight span { color: var(--muted); font-size: 0.92rem; }

.drawer .segment { margin-top: 0.45rem; }

.drawer .segment button {
    min-height: 36px;
    padding: 0.35rem 0.7rem;
}

.tune {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 0.35rem 0.5rem;
    margin-top: 0.55rem;
}

.tune-main {
    display: flex;
    flex: 1 1 12rem;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem 0.55rem;
    min-width: 0;
}

.tune-main .segment { margin-top: 0; }

.tune-name { font-size: 0.98rem; }

.tune .info { flex: 0 0 auto; }

.figure-note {
    flex: 1 1 100%;
    margin: 0.1rem 0 0;
    color: var(--muted);
    font-size: 0.88rem;
}

.drawer details.more-block {
    margin: 0.7rem 0 0.15rem;
    padding: 0;
    border-top: 0;
}

.drawer details.more-block > summary {
    position: static;
    z-index: auto;
    padding: 0.35rem 0;
    box-shadow: none;
    color: var(--muted);
    background: transparent;
    font-family: var(--sans);
    font-size: 0.95rem;
    font-weight: 400;
}

.drawer details.more-block > summary::after { content: none; }

.gap-note {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.25rem 0.8rem;
    margin: 0.5rem 0 0;
    padding: 0.6rem 0.9rem;
    border-left: 3px solid var(--warn);
    background: color-mix(in srgb, var(--warn) 9%, var(--card));
    border-radius: 0 var(--radius-s) var(--radius-s) 0;
    color: var(--muted);
    font-size: 0.95rem;
}

.gap-note p { margin: 0; flex: 1 1 18rem; }

.tune-stack { flex: 1 1 100%; display: flex; flex-direction: column; gap: 0.15rem; }

.tune-stack .fade { margin: 0.2rem 0 0; }

.tune-open {
    width: 36px;
    height: 36px;
    min-height: 36px;
    margin-left: auto;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: transparent;
    color: var(--ink);
    display: grid;
    place-items: center;
    flex: 0 0 36px;
    line-height: 1;
}

.tune-open::before {
    content: "";
    width: 14px;
    height: 12px;
    background:
        linear-gradient(currentColor, currentColor) left top / 14px 2px no-repeat,
        linear-gradient(currentColor, currentColor) left 5px / 9px 2px no-repeat,
        linear-gradient(currentColor, currentColor) left 10px / 5px 2px no-repeat;
}

.tune-open.is-set {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--accent);
    font-weight: 500;
    font-size: 0.85rem;
}

.tune-open.is-set::before { content: none; }

.tune-weight {
    flex-basis: 100%;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
    padding: 0.15rem 0 0.2rem;
}

.tune-caption { letter-spacing: 0.04em; }

.tune .limit,
.tune .age-at {
    flex: 1 1 100%;
}

.tune .limit { margin-top: 0.45rem; }

.weight-pick, .drawer .pill {
    min-height: 36px;
    padding: 0.3rem 0.75rem;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--bg);
}

.weight-pick[aria-pressed="true"], .drawer .pill[aria-pressed="true"] {
    background: var(--accent);
    color: var(--accent-ink);
    border-color: var(--accent);
}

.limits-label { margin: 1rem 0 0; }

.limits-note { margin: 0.2rem 0 0.15rem; color: var(--muted); font-size: 0.88rem; }

.ask-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.35rem;
}

.back-arrow {
    width: 44px;
    height: 44px;
    min-height: 44px;
    padding: 0;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    background: var(--card);
    font-size: 1.3rem;
    line-height: 1;
}

.ask-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 1rem; }

#step-next { width: min(100%, 28rem); }

.ask-actions .go { width: auto; min-width: 10rem; }

.how-ranked { margin: 0.2rem 0 0.4rem; }

.how-ranked > summary { color: var(--muted); font-size: 0.92rem; padding: 0.2rem 0; }

.how-ranked .lead { margin: 0.3rem 0 0; font-size: 0.98rem; }

.rest { margin: 0.4rem 0 0; padding: 0; list-style: none; border-top: 1px solid var(--line); }

.rest-row { border-bottom: 1px solid var(--line); }

.rest-main {
    display: flex;
    align-items: baseline;
    gap: 0.6rem;
    width: 100%;
    min-height: 44px;
    padding: 0.45rem 0.3rem;
    border: 0;
    background: transparent;
    color: var(--ink);
    text-align: left;
}

.rest-main:hover { background: var(--accent-soft); }

.rest-rank, .rest-score, .rest-zip { font-family: var(--mono); font-variant-numeric: tabular-nums; }

.rest-rank { flex: 0 0 2.2rem; color: var(--muted); font-size: 0.85rem; }

.rest-name { flex: 1 1 auto; min-width: 0; }

.rest-zip { color: var(--muted); font-size: 0.82rem; }

.rest-score { flex: 0 0 auto; font-size: 0.9rem; }

.rest-flag { flex: 0 0 auto; color: var(--warn); font-size: 0.78rem; }

.foot .built { margin: 0 0 0.4rem; }

.pager {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem 1rem;
    margin: 0.35rem 0 0.2rem;
}

.pager .fade { margin: 0; }

.limit { margin: 0.85rem 0 0.15rem; }

.limit-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.75rem;
}

.limit-name { font-size: 0.95rem; color: var(--muted); }

.limit-read {
    font-weight: 500;
    white-space: nowrap;
    color: var(--ink);
}

.limit-read.is-open { color: var(--muted); font-weight: 400; }

.limit-track {
    position: relative;
    height: 36px;
    display: flex;
    align-items: center;
}

.limit-rail {
    position: absolute;
    left: 0;
    right: 0;
    height: 4px;
    border-radius: 999px;
    background: var(--line);
    z-index: 0;
}

.notch {
    position: absolute;
    top: 50%;
    left: calc(11px + (100% - 22px) * var(--p));
    width: 2px;
    height: 12px;
    margin-left: -1px;
    background: var(--muted);
    transform: translateY(-50%);
    pointer-events: none;
    z-index: 1;
}

input.limit-range {
    -webkit-appearance: none;
    appearance: none;
    position: relative;
    z-index: 2;
    width: 100%;
    height: 28px;
    min-height: 0;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
}

input.limit-range::-webkit-slider-runnable-track {
    height: 4px;
    background: transparent;
}

input.limit-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 22px;
    height: 22px;
    margin-top: -9px;
    border-radius: 50%;
    background: var(--accent);
    border: 2px solid var(--card);
    box-shadow: 0 0 0 1px var(--line-strong);
}

input.limit-range::-moz-range-track {
    height: 4px;
    background: transparent;
    border: 0;
}

input.limit-range::-moz-range-thumb {
    width: 22px;
    height: 22px;
    border: 2px solid var(--card);
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 1px var(--line-strong);
}

.drawer[hidden], .sheet[hidden], .backdrop[hidden], [hidden] { display: none !important; }

@media (prefers-reduced-motion: reduce) {
    * { scroll-behavior: auto !important; transition: none !important; }
}

/* ---------------------------------------------------------------- places and metro areas (plan 05) */

.built { margin: 0.1rem 0 0; font-size: 0.9rem; }

.members { margin-top: 0.6rem; border-top: 1px solid var(--line); padding-top: 0.5rem; }

.member-list { margin: 0; padding-left: 1.4rem; }

.member { margin: 0.35rem 0; }

.member .note { display: block; }

.member-name {
    border: 0;
    background: transparent;
    padding: 0;
    min-height: 32px;
    color: var(--ink);
    text-decoration: underline;
    text-underline-offset: 0.2em;
    text-align: left;
}

.members-tally { margin: 0.5rem 0 0; font-size: 0.95rem; }

.members-more { margin-top: 0.4rem; }

.metro-filters, .month-filter { margin-top: 0.9rem; }

.month-filter .segment { margin-top: 0.3rem; }

.month-filter .fade { margin: 0.4rem 0 0; }

.months button { min-width: 3.6rem; justify-content: center; text-align: center; }

.metro-filters .segment { margin-top: 0.3rem; }

.metro-filters .fade { margin: 0.4rem 0 0; }

.foot {
    width: min(1120px, 100%);
    margin: 0 auto;
    padding-block: 1rem 2rem;
    padding-left: max(16px, env(safe-area-inset-left, 0px));
    padding-right: max(16px, env(safe-area-inset-right, 0px));
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 0.9rem;
}

.foot p { margin: 0; }

/* ---------------------------------------------------------------- the anchor ZIP (plan 08) */

.anchor-box { margin: 0.2rem 0 0.9rem; }

.anchor-box .anchor-label { max-width: 28rem; margin-top: 0; }

.anchor-box input[type="search"] { background: var(--card); }

.suggest {
    list-style: none;
    margin: 0.3rem 0 0;
    padding: 0.2rem;
    max-width: 28rem;
    background: var(--card);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
}

.suggest button {
    width: 100%;
    min-height: 44px;
    text-align: left;
    border: 0;
    background: transparent;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-s);
}

.suggest button:hover, .suggest button:focus-visible { background: var(--bg-2); }

.anchor-set { margin: 0; }

.anchor-name { font-weight: 500; }

.anchor-note { margin: 0.3rem 0 0; }

.segment.relative { margin-top: 0.7rem; }

.segment.relative button { font-size: 0.92rem; min-height: 36px; padding: 0.3rem 0.7rem; }

.tune .segment.relative { flex-basis: 100%; margin-top: 0.3rem; }

.limit-here { margin-left: auto; margin-right: 0.6rem; font-size: 0.85rem; }

.notch.here {
    width: 4px;
    height: 18px;
    margin-left: -2px;
    background: var(--accent);
    border-radius: 2px;
    z-index: 1;
}

.anchor-filters { margin-top: 0.9rem; }

.anchor-filters .fade { margin: 0.4rem 0 0; }

/* Wikipedia lead image and paragraph on the ZIP sheet (sources brief 46). */
.wiki-photo { margin: 0.6rem 0 0; }

.wiki-photo img {
    display: block;
    width: 100%;
    max-height: 240px;
    object-fit: cover;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    background: var(--accent-soft);
}

.wiki-credit { margin: 0.25rem 0 0; color: var(--muted); font-size: 0.78rem; }

.wiki-credit a, .wiki-source a { color: inherit; }

.wiki-text { margin: 0.45rem 0 0; }

.wiki-text p { margin: 0; font-size: 0.95rem; color: var(--ink); }

.wiki-source { margin: 0.15rem 0 0 !important; color: var(--muted) !important; font-size: 0.82rem !important; }

button.linkish {
    padding: 0;
    border: 0;
    background: none;
    color: var(--accent);
    font: inherit;
    font-size: 0.82rem;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* The fine-grained tier: a second fold inside More in the drawer, and a
   button on each sheet category that reveals the hidden rows. */
.drawer details.fine-block { margin: 0.3rem 0 0 0.6rem; }

.drawer details.fine-block > summary { font-size: 0.9rem; }

.fine-toggle {
    margin: 0.4rem 0 0.5rem;
    padding: 0.3rem 0.6rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-size: 0.85rem;
    cursor: pointer;
}

.fine-toggle:hover, .fine-toggle[aria-expanded="true"] { color: var(--ink); border-color: var(--ink); }
