/* ===========================================================================
   Paper — a quieter, academic take on a broadsheet (preview).
   Loaded after app.css (and after explore.html's inline <style>), so it only
   overrides. Warm paper, black ink, hairline rules, square-ish corners, no
   shadows. Serif for reading and headings, a plain sans for controls in
   sentence case, a mono for the apparatus (axes, captions, sources). Tables
   follow booktabs; methodology sections are numbered like a paper.
=========================================================================== */

/* --- 00 Tokens ------------------------------------------------------------ */
:root {
    --paper: #F6F3EC;
    --ink: #1C1B17;
    --ink2: #3D3B33;
    --red: #C4381F;
    --mute: #6E6B61;
    --rule: #D8D3C6;
    --plate: #EDE9DF;

    --display: 'Fraunces', Georgia, 'Times New Roman', serif;
    --read: 'Newsreader', Georgia, serif;
    --sans: 'Archivo', 'Helvetica Neue', Arial, sans-serif;
    --mono: 'DM Mono', ui-monospace, Menlo, monospace;
    --hed: 'opsz' 72, 'SOFT' 30, 'WONK' 0;
    --ease: cubic-bezier(.2, .7, .2, 1);
    --nav-h: 60px;
    --pad: clamp(16px, 3.4vw, 48px);
    --max: 1240px;
    --g: 20px;
    --r: 2px;

    /* app.css tokens, re-pointed */
    --bg-body: var(--paper);
    --bg-card: var(--paper);
    --bg-sidebar: var(--paper);
    --bg-input: var(--plate);
    --bg-subtle: #F0ECE3;
    --bg-hover: #E6E1D5;
    --text-primary: var(--ink);
    --text-secondary: var(--ink2);
    --text-muted: var(--mute);
    --accent: var(--red);
    --accent-light: #F3E2DB;
    --accent-dark: #9E2C17;
    --border: var(--rule);
    --border-strong: var(--ink);
    --border-focus: var(--ink);

    --alert-info-bg: var(--paper);
    --alert-info-border: var(--rule);
    --alert-info-fg: var(--ink2);
    --alert-info-accent: var(--ink);
    --alert-warn-bg: var(--paper);
    --alert-warn-border: var(--rule);
    --alert-warn-fg: var(--ink2);
    --alert-warn-accent: var(--ink);
    --alert-danger-bg: var(--paper);
    --alert-danger-border: var(--red);
    --alert-danger-fg: var(--ink);
    --alert-danger-accent: var(--red);

    --font-sans: var(--sans);
    --font-serif: var(--display);
    --font-mono: var(--mono);

    --radius-sm: var(--r);
    --radius-md: var(--r);
    --radius-lg: var(--r);
    --radius-xl: var(--r);
    --radius-full: var(--r);
    --shadow-xs: none;
    --shadow-sm: none;
    --shadow-md: none;
    --shadow-lg: none;
    --shadow-xl: none;
    --shadow-accent: none;
    --shadow-inner: none;
    --focus-ring: 0 0 0 2px var(--ink);
}

/* --- 01 Base --------------------------------------------------------------- */
html { scroll-padding-top: calc(var(--nav-h) + 12px); }
body { background: var(--paper); color: var(--ink); font-family: var(--read); text-rendering: optimizeLegibility; }
a { color: var(--ink); }
a:hover { color: var(--ink); }
:focus-visible,
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
::selection { background: var(--ink); color: var(--paper); }
* { scrollbar-color: var(--rule) transparent; }

/* Shared furniture */
.bs-label { font: 700 11px/1.3 var(--sans); letter-spacing: .09em; text-transform: uppercase; color: var(--mute); margin: 0; }
.bs-mono { font: 400 11.5px/1.5 var(--mono); letter-spacing: .03em; color: var(--mute); margin: 0; }
.bs-wrap { width: min(100% - 2 * var(--pad), var(--max)); margin-inline: auto; }

/* Buttons: an ink button and an underlined text link */
.btn {
    border-radius: var(--r);
    box-shadow: none;
    font: 600 14px/1 var(--sans);
    letter-spacing: 0;
    padding: 13px 18px 12px;
    gap: .6em;
    transform: none;
}
.btn-lg { padding: 14px 20px 13px; font-size: 14.5px; }
.btn-primary { background: var(--ink); color: var(--paper); border: 1px solid var(--ink); }
.btn-primary::before { display: none; }
.btn-primary:hover { background: var(--ink2); color: var(--paper); transform: none; box-shadow: none; }
.btn-secondary {
    background: none; border: 0; border-radius: 0; border-bottom: 1px solid var(--ink); color: var(--ink);
    padding: 0 0 3px; align-self: center;
}
.btn-secondary:hover { background: none; color: var(--ink); border-bottom-width: 2px; padding-bottom: 2px; transform: none; box-shadow: none; }
.btn svg, .btn-lg svg { width: 15px; height: 15px; }
.btn .btn-arrow { width: auto; height: auto; background: none; }
.landing-actions .btn-secondary { width: auto; }

/* --- 02 Top bar (all pages) ------------------------------------------------ */
.navbar {
    height: var(--nav-h);
    background: var(--paper);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    border-bottom: 1px solid var(--ink);
    padding: 0 clamp(16px, 2.4vw, 36px);
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    gap: 24px;
}
.navbar-brand {
    justify-self: start;
    min-width: 0;
    gap: 10px;
    color: var(--ink);
    font: 600 17px/1 var(--display);
    font-variation-settings: var(--hed);
    letter-spacing: -.01em;
    white-space: nowrap;
}
.navbar-brand:hover { transform: none; color: var(--ink); }
.navbar-brand:hover .navbar-logo { color: var(--ink); }
.navbar-logo, .navbar-logo svg { width: 21px; height: 21px; color: var(--ink); }
.navbar-brand .np-motto { font-style: italic; font-weight: 400; color: var(--ink2); margin-left: -.2em; overflow: hidden; text-overflow: ellipsis; }
.navbar-center { align-self: stretch; gap: 28px; }
.navbar-link {
    display: inline-flex;
    align-items: center;
    height: 100%;
    padding: 0;
    border-radius: 0;
    font: 500 14px/1 var(--sans);
    color: var(--ink2);
}
.navbar-link::after {
    left: 0; right: 0; bottom: -1px;
    width: auto;
    height: 2px;
    border-radius: 0;
    background: var(--ink);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform .3s var(--ease);
}
.navbar-link:hover { color: var(--ink); }
.navbar-link:hover::after,
.navbar-link.active::after { width: auto; background: var(--ink); transform: scaleX(1); }
.navbar-link.active { font-weight: 600; color: var(--ink); }
.navbar-right { justify-self: end; }

.lang-toggle { border: 1px solid var(--ink); border-radius: var(--r); }
.lang-toggle button { font: 600 11px/1 var(--sans); letter-spacing: .06em; color: var(--ink); padding: 6px 9px 5px; }
.lang-toggle button:first-child { border-right: 1px solid var(--ink); }
.lang-toggle button:hover { background: var(--plate); color: var(--ink); }
.lang-toggle button.active { background: var(--ink); color: var(--paper); }

/* --- 03 Explorer: filters ------------------------------------------------ */
.explorer-layout { min-height: calc(100vh - var(--nav-h)); }
.explorer-sidebar {
    top: var(--nav-h);
    height: calc(100vh - var(--nav-h));
    background: var(--paper);
    border-right: 1px solid var(--rule);
    padding: 22px clamp(16px, 1.6vw, 24px) 32px;
}
.explorer-sidebar .divider { display: none; }
.sidebar-section { margin-bottom: 28px; }
.sidebar-title {
    font: 700 11px/1.3 var(--sans);
    letter-spacing: .09em;
    color: var(--mute);
    border-top: 1px solid var(--ink);
    padding-top: 9px;
    margin-bottom: 16px;
}
.sidebar-title::before, .sidebar-title svg { display: none; }

.control-group { margin-bottom: 20px; }
.control-label { font: 600 13px/1.3 var(--sans); color: var(--ink); margin-bottom: 8px; }
.control-label svg { display: none; }
.control-hint { font: 400 11px/1.5 var(--mono); color: var(--mute); }

/* Chips (statistics, ages) */
.pill-group { gap: 6px; }
.pill label {
    background: transparent;
    border: 1px solid var(--rule);
    border-radius: var(--r);
    font: 500 12.5px/1 var(--sans);
    padding: 7px 10px 6px;
    color: var(--ink2);
}
.pill label:hover { background: transparent; border-color: var(--ink); color: var(--ink); }
.pill input:checked + label { background: var(--ink); border-color: var(--ink); color: var(--paper); box-shadow: none; }
.pill input:checked + label:hover { background: var(--ink2); border-color: var(--ink2); }
.pill input:focus-visible + label { box-shadow: none; outline: 2px solid var(--ink); outline-offset: 2px; }
.pill input:disabled + label { opacity: .4; }
.pill-subheading { font: 400 11px/1.4 var(--mono); letter-spacing: .02em; text-transform: none; color: var(--mute); margin-top: 10px; }

/* Sex, education, origin: a checklist */
.filter-row { gap: 20px; }
.filter-row .pill label,
.filter-row .pill input:checked + label {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    border: 0;
    background: none;
    padding: 4px 0;
    font: 400 15px/1.25 var(--read);
    color: var(--ink);
}
.filter-row .pill label::before {
    content: "";
    flex: none;
    width: 12px;
    height: 12px;
    margin-top: 3px;
    border: 1.5px solid var(--ink);
    border-radius: 1px;
    background: transparent;
}
.filter-row .pill input:checked + label::before { background: var(--ink); box-shadow: inset 0 0 0 2px var(--paper); }
.filter-row .pill label:hover,
.filter-row .pill input:checked + label:hover { background: none; text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }

/* Chart type: a segmented control */
.chart-type-selector {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    background: none;
    border: 1px solid var(--ink);
    border-radius: var(--r);
    padding: 0;
    gap: 0;
    overflow: hidden;
}
.chart-type-btn {
    border-radius: 0;
    border: 0;
    border-left: 1px solid var(--ink);
    border-top: 1px solid var(--ink);
    margin: -1px 0 0 -1px;
    padding: 10px 8px 9px;
    font: 500 13px/1 var(--sans);
    color: var(--ink);
    background: none;
    gap: 6px;
}
.chart-type-btn svg { width: 13px; height: 13px; color: currentColor; }
.chart-type-btn.active svg { color: currentColor; }
.chart-type-btn:hover { background: var(--plate); color: var(--ink); }
.chart-type-btn:active { transform: none; }
.chart-type-btn.active { background: var(--ink); color: var(--paper); box-shadow: none; }

/* Variable picker */
.multi-select-trigger { background: transparent; border: 1px solid var(--ink); border-radius: var(--r); padding: 10px 12px 9px; }
.multi-select-trigger:hover { background: var(--plate); border-color: var(--ink); transform: none; }
.multi-select-trigger.open { background: var(--paper); border-color: var(--ink); box-shadow: none; transform: none; }
.multi-select-text { font: 400 16px/1.25 var(--read); color: var(--ink); }
.multi-select-arrow, .multi-select-trigger:hover .multi-select-arrow, .multi-select-trigger.open .multi-select-arrow { color: var(--ink); }
.multi-select-dropdown {
    top: calc(100% + 6px);
    background: var(--paper);
    border: 1px solid var(--ink);
    border-radius: var(--r);
    box-shadow: 0 10px 24px -14px rgba(28, 27, 23, .35);
    padding: 0 12px 8px;
}
.multi-select-option { border-radius: 0; margin: 0; padding: 8px 0 7px; gap: 10px; border-bottom: 1px solid var(--rule); }
.multi-select-option:hover,
.multi-select-option:has(input:checked) { background: transparent; }
.multi-select-option:hover label { text-decoration: underline; text-underline-offset: 3px; }
.multi-select-option input[type="checkbox"] { width: 13px; height: 13px; border: 1.5px solid var(--ink); border-radius: 1px; background: transparent; }
.multi-select-option input[type="checkbox"]:hover { border-color: var(--ink); }
.multi-select-option input[type="checkbox"]:checked { background: var(--ink); border-color: var(--ink); box-shadow: inset 0 0 0 2px var(--paper); }
.multi-select-option input[type="checkbox"]:checked::after { display: none; }
.multi-select-option label { font: 400 15.5px/1.3 var(--read); color: var(--ink2); }
.multi-select-option:has(input:checked) label { color: var(--ink); font-weight: 600; }
.variable-search-wrapper { background: var(--paper); padding: 10px 0 8px; border-bottom: 1px solid var(--ink); }
.variable-search-icon { color: var(--ink); }
.variable-search-input { font-family: var(--read) !important; font-size: 16px; font-style: italic; color: var(--ink); }
.variable-search-input::placeholder { color: #A9A597; }
.variable-group-header {
    background: none;
    border-bottom: 1px solid var(--rule);
    font: 700 10.5px/1.3 var(--sans);
    letter-spacing: .09em;
    color: var(--mute);
    padding: 14px 0 6px;
    margin: 0;
}
.variable-no-results { font: italic 400 15px var(--read); color: var(--mute); }

/* Net / gross switch inside the picker */
.income-basis { background: none; border-radius: 0; padding: 8px 0; margin: 0; border-bottom: 1px solid var(--rule); }
.income-basis-label { font: 400 12px/1.3 var(--sans); color: var(--mute); }
.income-basis-toggle { background: none; border: 1px solid var(--ink); border-radius: var(--r); padding: 0; gap: 0; overflow: hidden; }
.income-basis-btn { border-radius: 0; padding: 5px 9px 4px; font: 500 12px/1 var(--sans); color: var(--ink); }
.income-basis-btn + .income-basis-btn { border-left: 1px solid var(--ink); }
.income-basis-btn:hover { background: var(--plate); color: var(--ink); }
.income-basis-btn.active { background: var(--ink); color: var(--paper); box-shadow: none; }

/* Selects: mono with an ink border and a drawn chevron */
select,
.dist-year-field select {
    appearance: none;
    -webkit-appearance: none;
    border: 1px solid var(--ink);
    border-radius: var(--r);
    background-color: transparent;
    background-image: linear-gradient(45deg, transparent 50%, var(--ink) 50%), linear-gradient(-45deg, transparent 50%, var(--ink) 50%);
    background-position: calc(100% - 15px) 55%, calc(100% - 10px) 55%;
    background-size: 5px 5px;
    background-repeat: no-repeat;
    padding: 9px 30px 8px 10px;
    font-family: var(--mono) !important;
    font-size: 12.5px;
    color: var(--ink);
}
select:hover { background-color: var(--plate); }
select:focus { background-color: var(--paper); border-color: var(--ink); box-shadow: none; outline: 2px solid var(--ink); outline-offset: 2px; }

/* Year range */
.year-range-display { justify-content: space-between; font: 500 13px/1 var(--mono); }
.year-range-display span { font-weight: 500; color: var(--ink); }
.year-range-separator { color: var(--mute) !important; }
.range-slider-dual input[type="range"] { height: 2px; }
.range-track { height: 2px; background: var(--rule); border-radius: 0; }
.range-track-fill { height: 2px; background: var(--ink); border-radius: 0; }
.range-slider-dual input[type="range"]::-webkit-slider-thumb {
    width: 14px; height: 14px; border-radius: 50%;
    background: var(--ink); border: 2px solid var(--paper); box-shadow: 0 0 0 1px var(--ink);
}
.range-slider-dual input[type="range"]::-webkit-slider-thumb:hover,
.range-slider-dual input[type="range"]:active::-webkit-slider-thumb { transform: none; box-shadow: 0 0 0 2px var(--ink); }
.range-slider-dual input[type="range"]::-moz-range-thumb {
    width: 12px; height: 12px; border-radius: 50%;
    background: var(--ink); border: 2px solid var(--paper); box-shadow: 0 0 0 1px var(--ink);
}

/* Exclude students */
.students-toggle { margin-top: 26px; padding-top: 14px; border-top: 1px solid var(--rule); }
.students-toggle-label { font: 400 15.5px/1.3 var(--read); color: var(--ink); }
.students-toggle-icon, .students-toggle:hover .students-toggle-icon, .students-toggle input:checked ~ .students-toggle-icon { color: var(--ink); }
.students-toggle-switch { width: 36px; height: 20px; border: 1.5px solid var(--ink); border-radius: 10px; background: transparent; }
.students-toggle-switch::after { top: 2px; left: 2px; width: 13px; height: 13px; border-radius: 50%; background: var(--ink); box-shadow: none; }
.students-toggle input:checked + .students-toggle-switch { background: var(--ink); }
.students-toggle input:checked + .students-toggle-switch::after { left: 18px; background: var(--paper); }

/* --- 04 Explorer: the figure --------------------------------------------- */
.explorer-main { background: transparent; padding: 22px clamp(16px, 2.4vw, 36px) 32px; }
.chart-wrapper { background: transparent; border: 0; border-radius: 0; box-shadow: none; }
.chart-header { padding: 0 0 14px; border-bottom: 1px solid var(--ink); gap: 20px; }
.chart-title {
    font: 600 clamp(24px, 2.2vw, 32px)/1.1 var(--display);
    font-variation-settings: var(--hed);
    letter-spacing: -.015em;
    color: var(--ink);
    text-wrap: balance;
}
.chart-subtitle { font: 400 12px/1.5 var(--mono); letter-spacing: .02em; color: var(--mute); margin-top: 7px; }
.chart-subtitle .sep { opacity: .6; }
.chart-container { padding: 14px 0 0; }
.chart-footer { background: none; border-top: 1px solid var(--rule); border-radius: 0; }
.chart-footer p { font: 400 11px/1.55 var(--mono); }

.title-skeleton-line { height: 30px; width: 320px; }
.skeleton { background: var(--plate); border-radius: var(--r); }
.chart-spinner-container { background: rgba(246, 243, 236, .88); -webkit-backdrop-filter: none; backdrop-filter: none; }
.spinner-ring { border: 2px solid var(--rule); border-top-color: var(--ink); }
.spinner-text { font: 400 12px/1.4 var(--mono); color: var(--mute); }

/* Chart actions */
.chart-actions, .chart-action { height: 30px; }
.chart-action {
    min-width: 30px;
    background: transparent;
    border: 1px solid var(--rule);
    border-radius: var(--r);
    color: var(--ink);
    font: 500 13px/1 var(--sans);
}
.chart-action:hover,
.chart-action:focus-visible,
.chart-action.is-active { border-color: var(--ink); color: var(--ink); background: var(--plate); }
.chart-action-info { border-color: var(--ink); color: var(--ink); padding: 0 10px 0 8px; }
.chart-action-info.is-active { background: var(--ink); color: var(--paper); }
.chart-action.is-copied { border-color: var(--ink); color: var(--ink); background: var(--plate); }
.chart-info {
    top: calc(30px + 8px);
    background: var(--paper);
    border: 1px solid var(--ink);
    border-radius: var(--r);
    box-shadow: 0 12px 28px -16px rgba(28, 27, 23, .35);
    padding: 10px 16px 16px;
}
.chart-info-label { font: 700 11px/1.3 var(--sans); letter-spacing: .09em; color: var(--mute); }
.chart-info-close { border-radius: var(--r); color: var(--ink); }
.chart-info-close:hover, .chart-info-close:focus-visible { background: var(--plate); }
.chart-info-text { font: 400 15.5px/1.5 var(--read); color: var(--ink2); }
#info-text .info-def + .info-def { margin-top: 6px; }
.chart-action-status { top: calc(30px + 8px); border-radius: var(--r); background: var(--ink); color: var(--paper); font: 400 12px/1.45 var(--sans); padding: 6px 10px 5px; }

@keyframes export-pulse {
    0%, 100% { stroke: #D8D3C6; stroke-width: 1px; }
    50% { stroke: #1C1B17; stroke-width: 2px; }
}

/* Highcharts export button and menu. Literal hexes: Safari does not resolve
   CSS variables in SVG presentation attributes. */
.highcharts-button-box { fill: #F6F3EC !important; stroke: #D8D3C6 !important; rx: 2 !important; ry: 2 !important; }
.highcharts-contextbutton:hover .highcharts-button-box { fill: #EDE9DF !important; stroke: #1C1B17 !important; }
.highcharts-contextbutton .highcharts-button-symbol,
.highcharts-contextbutton:hover .highcharts-button-symbol { stroke: #1C1B17 !important; }
.highcharts-contextmenu > div {
    background: var(--paper) !important;
    border: 1px solid var(--ink) !important;
    border-radius: var(--r) !important;
    box-shadow: 0 10px 24px -14px rgba(28, 27, 23, .35) !important;
    padding: 4px 0 !important;
}
.highcharts-menu-item { font-family: var(--sans) !important; font-size: 13px !important; font-weight: 500 !important; color: var(--ink) !important; }
.highcharts-menu-item:hover { background: var(--plate) !important; color: var(--ink) !important; }

/* Toasts and warnings */
.series-warning { background: var(--ink); border: 0; border-radius: var(--r); color: var(--paper); font: 500 13px/1.45 var(--sans); box-shadow: none; }
.series-warning svg { color: var(--paper); }
.origin-warning {
    top: calc(var(--nav-h) + 16px);
    background: var(--paper);
    border: 1px solid var(--ink);
    border-radius: var(--r);
    box-shadow: 0 12px 28px -16px rgba(28, 27, 23, .35);
}
.origin-warning-content > svg { color: var(--ink); }
.origin-warning-text, .origin-warning-text p { font: 400 15px/1.45 var(--read); color: var(--ink2); }
.origin-warning-text strong { font: 600 14px/1.3 var(--sans); color: var(--ink); margin-bottom: 4px; }
.origin-warning-dismiss { border: 1px solid var(--ink); border-radius: var(--r); color: var(--ink); font: 500 12.5px/1 var(--sans); padding: 7px 12px 6px; }
.origin-warning-dismiss:hover { background: var(--ink); color: var(--paper); }
.alert { border-radius: var(--r); box-shadow: none; }
.alert__title { font: 600 14px/1.3 var(--sans); }
.alert__body p { font-family: var(--read); font-size: 15px; }

/* Mobile: filters drawer and its button */
.mobile-toggle { background: var(--ink); color: var(--paper); border-radius: var(--r); box-shadow: none; height: 46px; font: 600 14px/1 var(--sans); }
.mobile-toggle:hover { background: var(--ink2); transform: none; box-shadow: none; }
.sidebar-overlay { top: var(--nav-h); background: rgba(28, 27, 23, .25); -webkit-backdrop-filter: none; backdrop-filter: none; }

@media (max-width: 1024px) {
    .explorer-sidebar,
    .docs-toc { top: var(--nav-h); height: calc(100vh - var(--nav-h)); box-shadow: none; border-right: 1px solid var(--ink); }
    .toc-overlay { top: var(--nav-h); -webkit-backdrop-filter: none; backdrop-filter: none; background: rgba(28, 27, 23, .25); }
    .navbar-center { display: flex; }
    .navbar-brand .np-motto { display: none; }
}
@media (max-width: 720px) {
    :root { --nav-h: 54px; }
    .navbar { grid-template-columns: minmax(0, 1fr) auto; }
    .navbar-center { display: none; }
}

/* --- 05 Methodology: set like a paper ------------------------------------ */
.docs-wrapper { min-height: calc(100vh - var(--nav-h)); max-width: 1180px; grid-template-columns: 15rem minmax(0, 1fr); }
.docs-toc { top: var(--nav-h); height: calc(100vh - var(--nav-h)); background: var(--paper); border-right: 1px solid var(--rule); padding: 28px 22px 28px 0; }
.toc-header { border-top: 1px solid var(--ink); border-bottom: 0; padding: 9px 0 0; margin-bottom: 8px; }
.toc-header svg { display: none; }
.toc-header span { font: 700 11px/1.3 var(--sans); letter-spacing: .09em; color: var(--mute); }
.toc-nav ul { counter-reset: toc; }
.toc-nav li { margin: 0; counter-increment: toc; }
.toc-nav a {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding: 6px 0 5px;
    border-radius: 0;
    font: 400 15px/1.3 var(--read);
    color: var(--ink2);
}
.toc-nav a::before {
    content: counter(toc);
    min-width: 1.1em;
    width: auto;
    height: auto;
    border-radius: 0;
    background: none !important;
    transform: none !important;
    font: 400 11px/1 var(--mono);
    color: var(--mute);
}
.toc-nav a:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
.toc-nav a.active { color: var(--ink); font-weight: 600; }

.docs-main { max-width: 44rem; padding: 40px clamp(16px, 4vw, 56px) 80px; }
.docs-content { font: 400 18.5px/1.6 var(--read); color: var(--ink); counter-reset: sec; }
.docs-content h1 {
    font: 600 clamp(38px, 4.2vw, 56px)/1.02 var(--display);
    font-variation-settings: var(--hed);
    letter-spacing: -.025em;
    color: var(--ink);
    padding-bottom: 20px;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--ink);
    text-wrap: balance;
}
.docs-content h2 {
    counter-increment: sec;
    font: 600 26px/1.15 var(--display);
    font-variation-settings: var(--hed);
    letter-spacing: -.015em;
    color: var(--ink);
    border-top: 1px solid var(--rule);
    padding-top: 18px;
    margin: 2.2em 0 .6em;
}
/* Numbered sections, as in a paper (matches the contents list) */
.docs-content h2::before,
.docs-content h2:hover::before {
    content: counter(sec) ".";
    display: inline;
    position: static;
    width: auto;
    height: auto;
    background: none;
    margin-right: .45em;
    color: var(--mute);
    font-weight: 400;
}
.docs-content h2:first-of-type { margin-top: 1.6em; padding-top: 18px; border-top: 1px solid var(--rule); }
.docs-content h3 { font: italic 500 20px/1.3 var(--read); color: var(--ink); margin: 1.6em 0 .4em; letter-spacing: 0; text-transform: none; }
.docs-content p, .docs-content li { font-size: 18.5px; line-height: 1.6; color: var(--ink); }
.docs-content p { hyphens: auto; -webkit-hyphens: auto; }
.docs-content strong { color: var(--ink); font-weight: 600; }
.docs-content a { color: var(--ink); text-decoration: underline; text-decoration-thickness: 1px; text-decoration-color: var(--mute); text-underline-offset: .18em; }
.docs-content a:hover { color: var(--ink); text-decoration-color: var(--ink); }
.docs-content code { font: 400 .82em var(--mono); background: var(--plate); border: 0; border-radius: var(--r); color: var(--ink); padding: .1em .35em; }
.docs-content pre { background: var(--plate); border: 0; border-radius: var(--r); }
/* Sections already open on a rule; the markdown's --- would stack a second one */
.docs-content hr { display: none; }
/* Tables: booktabs — a heavier top and bottom rule, a light one under the header, no verticals */
.docs-content table { border: 0; border-radius: 0; box-shadow: none; border-collapse: collapse; font-variant-numeric: tabular-nums; border-top: 1.5px solid var(--ink); border-bottom: 1.5px solid var(--ink); }
.docs-content th { background: none; font: 600 13px/1.3 var(--sans); letter-spacing: 0; text-transform: none; color: var(--ink); border-bottom: 1px solid var(--ink); padding: 8px 14px 6px 0; }
.docs-content td { font: 400 15.5px/1.45 var(--read); color: var(--ink); border-bottom: 0; padding: 6px 14px 6px 0; }
.docs-content tr:last-child td { padding-bottom: 9px; }
.docs-content tr:hover td { background: none; }
.docs-content td code { font-size: .8em; }
.docs-content blockquote { background: none; border: 0; border-left: 2px solid var(--ink); border-radius: 0; padding: 2px 0 2px 18px; margin: 1.4em 0 1.5em; }
.docs-content blockquote p { font: italic 400 19px/1.5 var(--read); color: var(--ink2); }
.docs-content .callout { background: var(--bg-subtle); border: 0; border-left: 2px solid var(--ink); border-radius: 0; padding: 12px 18px 14px; margin: 1.4em 0 1.6em; }
.docs-content .callout-title,
.docs-content .callout-info .callout-title { font: 600 14px/1.3 var(--sans); letter-spacing: 0; text-transform: none; color: var(--ink); }
.docs-content .callout-title svg,
.docs-content .callout-info .callout-title svg { color: var(--ink); }
.docs-content .callout-content,
.docs-content .callout-info .callout-content,
.docs-content .callout-content p { font-size: 16.5px; line-height: 1.5; color: var(--ink2); }
.docs-content .callout.callout-danger { border-left-color: var(--red); }
.docs-content .callout-danger .callout-title,
.docs-content .callout-danger .callout-title svg { color: var(--red); }
.docs-content .callout-danger .callout-content { color: var(--ink2); }
.loading-spinner { border-color: var(--rule); border-top-color: var(--ink); }
.docs-loading { font: 400 12px var(--mono); color: var(--mute); }
.docs-footer { background: none; border-radius: 0; border-top: 1px solid var(--ink); text-align: left; padding: 12px 0 0; }
.docs-footer p { font: 400 11.5px/1.6 var(--mono); color: var(--mute); }
.docs-footer a { color: var(--ink); text-decoration: underline; text-decoration-color: var(--rule); text-underline-offset: 3px; }
.docs-footer a:hover { text-decoration-color: var(--ink); }
.toc-mobile-toggle { background: var(--ink); color: var(--paper); border-radius: 50%; box-shadow: none; }

@media (max-width: 1024px) {
    .docs-toc { padding: 24px 20px; background: var(--paper); }
}
@media (max-width: 640px) {
    .docs-content h1 { font-size: 38px; }
    .docs-content h2 { font-size: 23px; }
    .docs-content p, .docs-content li { font-size: 17.5px; }
}

/* --- 06 Landing ------------------------------------------------------------ */
.bs-front { display: block; min-height: 0; z-index: auto; }

.bs-hero {
    display: grid;
    grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
    column-gap: clamp(32px, 5vw, 80px);
    align-items: start;
    padding: clamp(40px, 6vw, 88px) 0 clamp(40px, 5vw, 64px);
    border-bottom: 1px solid var(--rule);
}
.bs-hero-main { min-width: 0; }
.bs-kicker { font: 400 12px/1.4 var(--mono); letter-spacing: .03em; color: var(--mute); margin: 0; }

.landing-title {
    font: 600 clamp(44px, 5.6vw, 80px)/1 var(--display);
    font-variation-settings: var(--hed);
    letter-spacing: -.03em;
    color: var(--ink);
    text-align: left;
    margin: 16px 0 0;
    opacity: 1;
    animation: none;
    text-wrap: balance;
}
.landing-title .highlight { color: var(--red); font-style: italic; font-weight: 500; }

.landing-rule { display: flex; align-items: center; gap: 6px; width: 132px; margin: 26px 0 0; opacity: 1; animation: none; }
.landing-rule-line { flex: 1; height: 1px; background: var(--ink); opacity: 1; }
.landing-rule-line:last-child { background: var(--ink); }
.landing-rule-mark { width: 5px; height: 5px; background: var(--red); transform: rotate(45deg); border: 0; border-radius: 0; box-shadow: none; }

.landing-subtitle {
    font: 400 clamp(18px, 1.5vw, 21px)/1.5 var(--read);
    color: var(--ink2);
    max-width: 34em;
    margin: 22px 0 0;
    text-align: left;
    opacity: 1;
    animation: none;
}
.landing-actions {
    display: flex;
    flex-direction: row;
    width: auto;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-start;
    gap: 16px 28px;
    margin-top: 30px;
    opacity: 1;
    animation: none;
}
.landing-meta {
    display: flex;
    justify-content: flex-start;
    gap: 0;
    margin: 40px 0 0;
    padding-top: 12px;
    border-top: 1px solid var(--rule);
    opacity: 1;
    animation: none;
}
.landing-meta > div { display: flex; flex-direction: column; align-items: flex-start; text-align: left; gap: 3px; padding: 0 22px; border-left: 1px solid var(--rule); }
.landing-meta > div:first-child { padding-left: 0; border-left: 0; }
.landing-meta > div + div::before { display: none; }
.landing-meta dt { font: 400 11.5px/1.3 var(--mono); letter-spacing: .02em; text-transform: none; color: var(--mute); }
.landing-meta dd { font: 600 17px/1.25 var(--display); font-variation-settings: var(--hed); color: var(--ink); margin: 0; }

/* Key figures: a small table beside the title */
.bs-figs-panel { border-top: 1px solid var(--ink); padding-top: 10px; margin-top: 6px; }
.bs-panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 4px; }
.bs-figs { margin: 0; padding: 0; list-style: none; }
.bs-figs li { display: grid; grid-template-columns: 7.2rem minmax(0, 1fr); column-gap: 16px; align-items: baseline; padding: 13px 0 12px; border-bottom: 1px solid var(--rule); }
.bs-fig-n { font: 600 26px/1 var(--display); font-variation-settings: var(--hed); letter-spacing: -.02em; white-space: nowrap; color: var(--ink); margin: 0; font-variant-numeric: lining-nums; }
.bs-fig-n small { font-size: .62em; font-weight: 500; margin-left: .1em; }
.bs-fig-l { font: 400 15.5px/1.35 var(--read); color: var(--ink); margin: 0; }
.bs-fig-s { grid-column: 2; font: 400 11px/1.4 var(--mono); letter-spacing: .02em; color: var(--mute); margin: 4px 0 0; }
.bs-figs.is-loading .bs-fig-n { color: var(--rule); }

/* Stories */
.landing-stories { padding: 0; border-top: 0; margin-top: clamp(48px, 6vw, 80px); }
.landing-stories-inner { max-width: none; }
.landing-stories-head { text-align: left; margin-bottom: 26px; max-width: 42rem; }
.landing-stories-eyebrow { font: 700 11px/1.3 var(--sans); letter-spacing: .09em; color: var(--mute); }
.landing-stories-title {
    font: 600 clamp(28px, 3vw, 40px)/1.08 var(--display);
    font-variation-settings: var(--hed);
    letter-spacing: -.02em;
    color: var(--ink);
    margin: 8px 0 8px;
    text-wrap: balance;
}
.landing-stories-sub { font: italic 400 17px/1.45 var(--read); color: var(--mute); max-width: none; margin: 0; }
/* Column rule between the cards; the outer edges stay flush with the text */
.story-grid {
    gap: 0;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow: hidden;
    margin-inline: 0;
    border-top: 1px solid var(--ink);
}
.story-card,
.story-card:hover {
    background: none;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    transform: none;
    border-left: 1px solid var(--rule);
    border-top: 1px solid var(--rule);
    margin: -1px 0 0 -1px;
    padding: 22px var(--g) 30px;
    gap: 10px;
}
.story-card:nth-child(odd) { padding-left: 0; }
.story-card:nth-child(even) { padding-right: 0; }
.story-tag { font: 700 11px/1.3 var(--sans); letter-spacing: .09em; text-transform: uppercase; color: var(--mute); }
.story-title { font: 600 clamp(22px, 1.9vw, 27px)/1.12 var(--display); font-variation-settings: var(--hed); letter-spacing: -.015em; color: var(--ink); text-wrap: balance; }
.story-card .story-stat { display: flex; align-items: baseline; gap: 14px; margin-top: 2px; }
.story-stat-value { font: 600 clamp(34px, 3vw, 44px)/1 var(--display); font-variation-settings: var(--hed); letter-spacing: -.025em; flex: none; }
.story-stat-label { font: 400 15.5px/1.4 var(--read); color: var(--ink2); }
.story-pills { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--ink); border-radius: var(--r); background: none; padding: 0; gap: 0; margin-top: 6px; overflow: hidden; }
.story-pill { border: 0; border-left: 1px solid var(--ink); border-radius: 0; background: none; padding: 7px 11px 6px; font: 500 12.5px/1 var(--sans); color: var(--ink); }
.story-pill:first-child { border-left: 0; }
.story-pill:hover { background: var(--plate); color: var(--ink); }
.story-pill.active { background: var(--ink); color: var(--paper); box-shadow: none; }
.story-pill:focus-visible { box-shadow: none; outline: 2px solid var(--ink); outline-offset: 2px; }
.story-chart { background: none; padding: 0; border-radius: 0; margin-top: 4px; }
.story-chart.is-loading { background: var(--plate); animation: none; }
.story-link { display: inline-flex; align-items: center; gap: .4em; font: 500 14px/1.3 var(--sans); color: var(--ink); text-decoration: none; border-bottom: 1px solid var(--ink); padding-bottom: 2px; margin-top: 4px; }
.story-link:hover { color: var(--ink); border-bottom-width: 2px; padding-bottom: 1px; }
.story-link svg { width: 13px; height: 13px; }
.story-link:focus-visible { box-shadow: none; outline: 2px solid var(--ink); outline-offset: 3px; }

/* Footer */
.bs-foot { margin-top: 88px; border-top: 1px solid var(--ink); padding: 28px 0 56px; background: none; opacity: 1; animation: none; }
.bs-foot-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr); gap: 24px 40px; }
.bs-foot-name { font: 600 20px/1.2 var(--display); font-variation-settings: var(--hed); letter-spacing: -.01em; color: var(--ink); margin: 0; }
.bs-foot-name em { font-weight: 400; }
.bs-foot-desc { font: 400 15.5px/1.45 var(--read); color: var(--ink2); max-width: 30em; margin: 8px 0 0; }
.bs-foot h3 { font: 700 11px/1.3 var(--sans); letter-spacing: .09em; text-transform: uppercase; color: var(--mute); margin: 0 0 10px; }
.bs-foot ul { margin: 0; padding: 0; list-style: none; }
.bs-foot li { font: 400 15.5px/1.35 var(--read); color: var(--ink); padding: 3px 0; }
.bs-foot a { text-decoration: none; color: var(--ink); }
.bs-foot a:hover { text-decoration: underline; text-underline-offset: 3px; }
.bs-foot-base { margin-top: 32px; padding-top: 12px; border-top: 1px solid var(--rule); }
.bs-foot-base p { font: 400 11.5px/1.6 var(--mono); color: var(--mute); margin: 0; }

@media (max-width: 1024px) {
    .bs-hero { grid-template-columns: minmax(0, 1fr); }
    .bs-figs-panel { margin-top: 44px; }
}
@media (max-width: 720px) {
    .story-grid { grid-template-columns: minmax(0, 1fr); }
    .story-card, .story-card:hover { padding-inline: 0; }
    .bs-foot-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
    .bs-foot-grid > :first-child { grid-column: 1 / -1; }
}
@media (max-width: 480px) {
    .landing-meta > div { padding: 0 12px; }
    .bs-figs li { grid-template-columns: 6.2rem minmax(0, 1fr); column-gap: 12px; }
    .bs-fig-n { font-size: 23px; }
    .landing-actions .btn-primary { width: auto; }
    .story-card .story-stat { flex-direction: column; gap: 6px; }
}
@media (prefers-reduced-motion: reduce) {
    .navbar-link::after { transition: none; }
}
