/* === DESIGN TOKENS === */
:root {
    --bg: #0a0e17;
    --surface: #131a2b;
    --surface-2: #1a2332;
    --border: #1e2d3f;
    --border-light: #2a3a4e;
    /* P2-6 a11y audit: every text token verified ≥ 4.5:1 against the darkest
       surface it sits on (WCAG 2.1 AA). --text-muted was #64748b (3.32:1 on
       --surface-2) → lightened; --accent was #3b82f6 (4.29:1 on --surface-2)
       → lightened; --purple was #8b5cf6 (3.47:1 on its badge tint) →
       lightened. --accent-strong is the darker fill used when white text
       must sit on the accent (white on #3b82f6 was 3.68:1; on #2563eb it is
       5.17:1). See work/scratch/a11y_audit.md for the full matrix. */
    --text: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-muted: #8494ab;
    --accent: #5b9dff;
    --accent-hover: #2563eb;
    --accent-strong: #2563eb;
    --accent-glow: rgba(91, 157, 255, 0.15);
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --purple: #a78bfa;
    --cyan: #06b6d4;
    --pink: #ec4899;
    /* P4-1 chart palette: the SVG chart classes (.seg-1…7, .swatch-1…7,
       .bar, .dot) resolve to these, so the inline SVGs stay theme-driven
       (no inline color values) and new data picks up the theme for free.
       Seven slots so the backend donut can show every distinct engine
       (a 7th backend, e.g. Colibri, without reusing a color). */
    --chart-1: var(--accent);
    --chart-2: var(--cyan);
    --chart-3: var(--purple);
    --chart-4: var(--success);
    --chart-5: var(--warning);
    --chart-6: var(--danger);
    --chart-7: var(--pink);

    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    --font-mono: 'SF Mono', 'Fira Code', 'JetBrains Mono', monospace;

    --radius: 8px;
    --radius-lg: 12px;
    --shadow: 0 4px 12px rgba(0,0,0,0.3);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.4);

    --max-width: 1200px;
    /* Reading width for long-form content (guides / articles). Comfortable
       for sustained reading — wide enough to not feel cramped, narrow enough
       that line length stays legible. Centered inside the --max-width page
       container with breathing room on both sides. */
    --content-max-width: 900px;
    /* Comfortable width for multi-field forms (recommend / submit) so the
       fields don't stretch across the full 1200px page container. */
    --form-max-width: 760px;
    --nav-height: 60px;
}

/* === BASE === */
* { margin: 0; padding: 0; box-sizing: border-box; }
/* The `hidden` attribute must win over any author `display` rule (e.g. the
   command dialog's flex overlay), so it is always forced to none. */
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
    font-family: var(--font-sans);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
code, .mono { font-family: var(--font-mono); font-size: 0.9em; }

/* Visible keyboard focus (WCAG 2.4.7): a single high-contrast ring for every
   focusable element. Components that define their own :focus-visible ring
   (buttons, inputs) have higher specificity and keep theirs. */
:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Screen-reader-only text (status announcements, labels). */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Skip link (WCAG 2.4.1 Bypass Blocks): hidden until keyboard-focused. */
.skip-link {
    position: absolute;
    top: -100%;
    left: 1rem;
    z-index: 300;
    display: inline-block;
    background: var(--accent-strong);
    color: #fff;
    padding: 0.75rem 1.25rem;
    border-radius: 0 0 var(--radius) var(--radius);
    font-weight: 600;
    text-decoration: none;
}
.skip-link:focus {
    top: 0;
    color: #fff;
}

/* Decorative icon/emoji spans: hidden from the accessibility tree so
   screen readers read the adjacent text label only. */
.icon {
    /* No visual styling — the glyph inherits the surrounding font. */
}

/* === NAVIGATION === */
.nav {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(10, 14, 23, 0.9);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    height: var(--nav-height);
    display: flex;
    align-items: center;
    padding: 0 2rem;
}
.nav-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.nav-logo {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;   /* ≥ 44px touch target */
    border-radius: var(--radius);
}
.nav-logo span { color: var(--accent); }
.nav-links {
    display: flex;
    gap: 0.25rem;
    list-style: none;
}
.nav-links a {
    color: var(--text-secondary);
    padding: 0.7rem 1rem;     /* ≥ 44px touch target */
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s;
}
.nav-links a:hover { color: var(--text); background: var(--surface); }
.nav-links a.active { color: var(--accent); background: var(--accent-glow); }

/* Guides dropdown (P1-9 populates the menu; P1-0 leaves the plain link) */
.nav-dropdown { position: relative; }
/* The Guides toggle must share the exact box model of every other .nav-links a
   (inline, same font-size/line-height/padding) so "Guides" sits on the same
   baseline as Home/Matrix/etc. It was display:inline-flex + align-items:center,
   which centered the label+caret in its own box and shifted the text vertically.
   The ▾ caret is now just a (slightly smaller) inline glyph on the shared
   baseline — the markup already carries the separating space. */
.nav-dropdown-toggle {
    color: var(--text-secondary);
    padding: 0.7rem 1rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s;
    display: inline;
}
.nav-dropdown-toggle .icon { font-size: 0.75em; line-height: 1; }
.nav-dropdown-toggle:hover { color: var(--text); background: var(--surface); }
.nav-dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 230px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    list-style: none;
    padding: 0.5rem;
    margin: 0.25rem 0 0;
    z-index: 200;
}
.nav-dropdown:hover .nav-dropdown-menu,
.nav-dropdown:focus-within .nav-dropdown-menu,
.nav-dropdown.open .nav-dropdown-menu { display: block; }
.nav-dropdown-menu li a {
    display: block;
    padding: 0.7rem 0.75rem;  /* ≥ 44px touch target */
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-size: 0.9rem;
}
.nav-dropdown-menu li a:hover { color: var(--text); background: var(--surface-2); }
.nav-dropdown-menu li a.active { color: var(--accent); background: var(--accent-glow); }

/* Mobile nav */
.nav-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text);
    font-size: 1.5rem;
    cursor: pointer;
    min-width: 44px;          /* ≥ 44px touch target */
    min-height: 44px;
    align-items: center;
    justify-content: center;
}
@media (max-width: 768px) {
    .nav-toggle { display: block; }
    .nav-links {
        display: none;
        position: absolute;
        top: var(--nav-height);
        left: 0;
        right: 0;
        background: var(--surface);
        flex-direction: column;
        padding: 1rem;
        border-bottom: 1px solid var(--border);
    }
    .nav-links.open { display: flex; }
}

/* === LAYOUT === */
.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 2rem;
}
.page-header {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}
.page-header h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}
.page-header .subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
}
.page-header .meta {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-top: 0.5rem;
}

/* === CARDS === */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 1rem;
    transition: border-color 0.2s;
}
.card:hover { border-color: var(--border-light); }
.card h3 {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
/* Card headings + body spacing: the global "* { margin: 0 }" reset zeroes every
   margin, so a card's heading, text lines, and CTA button all touch (this is
   what made the community "Want to be here?" button overlap its text). Restore
   the vertical rhythm here — ≥1rem between body lines, 0 after the last. */
.card h2 {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.card p { color: var(--text-secondary); font-size: 0.95rem; margin-bottom: 1rem; }
.card p:last-child { margin-bottom: 0; }
/* About page: its info cards are the only bare `.card` elements that are
   *direct* children of `<main class="container">` (verified — the homepage /
   community / guides-index cards all live inside `.card-grid`). Constrain them
   to a comfortable reading width and center, so the prose reads better than
   full-bleed across the 1200px container. */
main.container > .card {
    max-width: 820px;
    margin-left: auto;
    margin-right: auto;
}
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
}

/* === STATS === */
.stats-row {
    display: flex;
    gap: 1rem;
    margin: 1.5rem 0;
    flex-wrap: wrap;
}
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.5rem;
    text-align: center;
    flex: 1;
    min-width: 120px;
}
.stat-card .value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--accent);
}
.stat-card .label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 0.25rem;
}

/* === TABLES === */
.table-wrapper {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin: 1rem 0;
}
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}
thead { background: var(--surface-2); }
th {
    text-align: left;
    padding: 0.75rem 1rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    white-space: nowrap;
}
th:hover { color: var(--accent); }
td {
    padding: 0.7rem 1rem;     /* ≥ 44px row height for the clickable data rows */
    border-bottom: 1px solid var(--border);
    max-width: 250px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Sortable table headers (P2-6): the click target is a real <button> inside
   the <th>, so keyboard users can focus it and activate it with Enter/Space.
   The <th> carries the ARIA state (aria-sort); the button carries the
   visual sort arrow. Non-interactive headers (guide tables, compare, the
   "Actions" column) keep the plain <th> styling above. */
th.th-sort { padding: 0; }
.th-btn {
    display: block;
    width: 100%;
    min-height: 44px;         /* ≥ 44px touch target */
    padding: 0.75rem 1rem;
    background: none;
    border: none;
    font: inherit;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
    text-align: left;
    cursor: pointer;
    white-space: nowrap;
}
.th-btn:hover { color: var(--accent); }
.th-btn.sort-asc::after { content: ' ↑'; color: var(--accent); }
.th-btn.sort-desc::after { content: ' ↓'; color: var(--accent); }
td[title]:hover {
    white-space: normal;
    overflow: visible;
    position: relative;
    z-index: 10;
    background: var(--surface-2);
    box-shadow: var(--shadow-lg);
    border-radius: 4px;
}
tr:hover td { background: rgba(59, 130, 246, 0.03); }
tr.highlighted { border-left: 3px solid var(--warning); }
.tier-header td {
    background: var(--surface-2);
    font-weight: 700;
    color: var(--accent);
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* === FILTERS === */
.filter-bar {
    display: flex;
    gap: 0.75rem;
    margin: 1.5rem 0;
    flex-wrap: wrap;
    align-items: center;
}
.filter-bar input, .filter-bar select {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 0.7rem 1rem;    /* ≥ 44px touch target */
    border-radius: var(--radius);
    font-size: 0.9rem;
}
.filter-bar input { flex: 1; min-width: 200px; }
.filter-bar input:focus, .filter-bar select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}
.btn {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 0.7rem 1rem;    /* ≥ 44px touch target */
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s;
}
.btn:hover { color: var(--text); border-color: var(--accent); }
/* Primary buttons use the darker --accent-strong fill: white text on
   #3b82f6 measured 3.68:1 (fail); on #2563eb it is 5.17:1 (pass). */
.btn-primary {
    background: var(--accent-strong);
    border-color: var(--accent-strong);
    color: white;
}
.btn-primary:hover { background: var(--accent-hover); }

/* === BADGES === */
.badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}
.badge-green { background: rgba(16, 185, 129, 0.15); color: var(--success); }
.badge-blue { background: var(--accent-glow); color: var(--accent); }
.badge-purple { background: rgba(167, 139, 250, 0.15); color: var(--purple); }
.badge-amber { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.badge-cyan { background: rgba(6, 182, 212, 0.15); color: var(--cyan); }

/* === HERO (homepage) === */
.hero {
    text-align: center;
    padding: 4rem 2rem;
    max-width: 800px;
    margin: 0 auto;
}
.hero h1 {
    font-size: clamp(2rem, 1.6rem + 1.8vw, 3rem);
    font-weight: 800;
    margin-bottom: 1rem;
    line-height: 1.2;
}
.hero h1 span { color: var(--accent); }
.hero .tagline {
    font-size: clamp(1.05rem, 0.95rem + 0.6vw, 1.3rem);
    color: var(--text-secondary);
    margin-bottom: 2rem;
}
.hero .actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}
.hero .actions a {
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 1rem;
}
.btn-large {
    padding: 0.75rem 2rem;
    font-size: 1rem;
    border-radius: var(--radius);
    font-weight: 600;
    display: inline-block;
}
.btn-large-primary {
    background: var(--accent-strong);
    color: white;
    border: none;
}
.btn-large-primary:hover { background: var(--accent-hover); }
.btn-large-secondary {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
}
.btn-large-secondary:hover { border-color: var(--accent); }

/* === SECTION HEADINGS === */
.section-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 2rem 0 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
/* Sub-headings inside a section (replaces former inline styles, P2-6). */
.subheading {
    margin: 1.5rem 0 0.5rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.subheading--tight { margin-top: 1rem; }

/* === FOOTER === */
.footer {
    margin-top: 4rem;
    padding: 2rem;
    border-top: 1px solid var(--border);
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
}
/* Footer links meet the WCAG 2.1 AA minimum 24px target size (2.5.8);
   the stricter 44px standard is applied to all primary/functional controls. */
.footer a {
    color: var(--text-secondary);
    padding: 0.35rem 0.5rem;
}
.footer .forum-credit {
    margin-top: 0.5rem;
    font-size: 0.8rem;
}

/* === GUIDE CARDS (for guides.html) === */
.guide-card {
    display: block;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 1rem;
    transition: all 0.2s;
    color: var(--text);
}
.guide-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}
.guide-card .guide-icon {
    font-size: 2rem;
    margin-bottom: 0.75rem;
}
.guide-card h3 {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    color: var(--text);
}
.guide-card p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.5;
}
.guide-card .guide-meta {
    margin-top: 0.75rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* === GUIDE PAGE LAYER (long-form: guides/<slug>/index.html) === */
.guide {
    width: 100%;
    max-width: var(--content-max-width);
    margin: 0 auto;
}
.guide h1 {
    font-size: clamp(1.75rem, 1.4rem + 1.4vw, 2.5rem);
    font-weight: 800;
    margin-bottom: 0.5rem;
    line-height: 1.2;
}
.guide h2 {
    font-size: clamp(1.25rem, 1.1rem + 0.6vw, 1.6rem);
    font-weight: 700;
    margin: 2rem 0 0.75rem;
    padding-bottom: 0.4rem;
    border-bottom: 1px solid var(--border);
}
.guide h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 1.5rem 0 0.5rem;
}
.guide p {
    color: var(--text-secondary);
    margin-bottom: 1.1rem;
    /* Fluid body text: scales smoothly from 1rem on phones up to ~1.15rem on
       wide screens so line length stays comfortable as the 900px column
       grows. */
    font-size: clamp(1rem, 0.6rem + 1.5vw, 1.15rem);
    line-height: 1.7;
}
.guide ul, .guide ol {
    color: var(--text-secondary);
    margin: 0 0 1rem 1.5rem;
}
.guide li { margin-bottom: 0.35rem; }
.guide a { color: var(--accent); }
.guide strong { color: var(--text); }

/* Tables rendered from markdown. `display:block` turns the table into a
   scroll container so an unexpectedly wide table scrolls horizontally
   (within the 900px column) instead of overflowing the page — the rows/cells
   keep their internal table layout, and normal-width tables just fill the
   column. */
.guide table {
    display: block;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    margin: 1rem 0;
}
.guide th {
    background: var(--surface-2);
    text-align: left;
    padding: 0.6rem 0.9rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
}
.guide td {
    padding: 0.6rem 0.9rem;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Fenced code blocks + inline code */
.guide pre {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    overflow-x: auto;
    margin: 1rem 0;
}
.guide pre code {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--text);
}
.guide :not(pre) > code {
    background: var(--surface-2);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-size: 0.85em;
}

/* Table of contents (markdown `toc` extension) */
.guide .toc {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1rem 1.5rem;
    margin: 1.5rem 0;
}
.guide .toc ul { list-style: none; margin-left: 1rem; }
.guide .toc a {
    color: var(--text-secondary);
    font-size: 0.9rem;
    display: block;
    padding: 0.65rem 0.75rem;  /* ≥ 44px touch target */
}
.guide .toc a:hover { color: var(--accent); }

/* CSS-only diagrams (no images/SVG) — composed from building blocks */
.diagram {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    margin: 1.25rem 0;
}
.diagram-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}
.diagram-row:last-child { margin-bottom: 0; }
.diagram-label {
    flex: 0 0 90px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-family: var(--font-mono);
}
.diagram-bar {
    height: 18px;
    background: linear-gradient(90deg, var(--accent), var(--cyan));
    border-radius: 4px;
    min-width: 4px;
}
/* KV-cache growth: bars widen with context (width set inline in the markdown) */
.diagram--kv .diagram-bar { background: linear-gradient(90deg, var(--accent), var(--purple)); }
.diagram-cell {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.6rem 0.9rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-align: center;
}
.diagram-arrow {
    color: var(--text-muted);
    font-size: 1.2rem;
    text-align: center;
    margin: 0.25rem 0;
}
.diagram--stack { display: flex; flex-direction: column; gap: 0.4rem; }
.diagram--stack .diagram-cell { width: 100%; }
.diagram--flow { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }

/* Callouts (e.g. the 30-second summary) */
.callout {
    border-left: 3px solid var(--accent);
    background: var(--accent-glow);
    border-radius: 0 var(--radius) var(--radius) 0;
    padding: 1rem 1.25rem;
    margin: 1.25rem 0;
}
.callout p { margin-bottom: 0; }
.callout--tip { border-left-color: var(--success); background: rgba(16, 185, 129, 0.1); }
.callout--warning { border-left-color: var(--warning); background: rgba(245, 158, 11, 0.1); }
.callout--info { border-left-color: var(--cyan); background: rgba(6, 182, 212, 0.1); }

/* Progressive disclosure (<details>/<summary>) */
.progressive details {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin: 0.75rem 0;
}
.progressive summary {
    cursor: pointer;
    padding: 0.75rem 1rem;
    font-weight: 600;
    color: var(--text);
    list-style: none;
}
.progressive summary::-webkit-details-marker { display: none; }
.progressive summary::before { content: '▸ '; color: var(--accent); }
.progressive details[open] summary::before { content: '▾ '; }
.progressive .progressive-body {
    padding: 0 1rem 1rem;
    color: var(--text-secondary);
}

/* Related-guides footer on each guide page */
.guide-related {
    margin-top: 3rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}
.guide-related h2 { font-size: 1.1rem; margin-bottom: 0.75rem; }
.guide-related ul { list-style: none; display: flex; gap: 0.5rem; flex-wrap: wrap; }
.guide-related a {
    color: var(--accent);
    display: inline-block;
    padding: 0.65rem 0.75rem;  /* ≥ 44px touch target */
}

/* === COMMUNITY / CONTRIBUTOR CARDS === */
.contributor-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 1rem;
}
.contributor-card .contributor-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}
.contributor-card .avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--accent-glow);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent);
}
.contributor-card .contributor-name {
    font-size: 1.1rem;
    font-weight: 600;
}
.contributor-card .contributor-role {
    font-size: 0.85rem;
    color: var(--text-muted);
}
.contributor-card .setup-list {
    list-style: none;
    padding: 0;
}
.contributor-card .setup-list li {
    padding: 0.5rem 0;
    border-top: 1px solid var(--border);
    font-size: 0.9rem;
    color: var(--text-secondary);
}
.contributor-card .setup-list li strong {
    color: var(--text);
}

/* === RECOMMEND (P2-1: the recommendation engine) === */

/* Homepage teaser card */
.recommend-teaser { margin: 1.5rem 0; }
.recommend-teaser-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    flex-wrap: wrap;
    background: linear-gradient(135deg, var(--surface), var(--surface-2));
    border-color: var(--border-light);
}
.recommend-teaser-copy h2 { font-size: 1.4rem; margin-bottom: 0.5rem; }
.recommend-teaser-copy p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    max-width: 60ch;
}
.recommend-teaser-cta { white-space: nowrap; }

/* The interactive tool. Capped to a comfortable form width and centered so
   the fields don't stretch across the full page container. */
.recommend-tool {
    max-width: var(--form-max-width);
    margin: 2rem auto;
}
.rec-form {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
}
.rec-field { margin-bottom: 1.25rem; }
.rec-field:last-child { margin-bottom: 0; }
.rec-field label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text);
}
.rec-field--primary label { font-size: 1.05rem; }
.rec-field select {
    width: 100%;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    font-size: 1rem;
}
.rec-field select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

/* Advanced options — progressive disclosure */
.rec-advanced {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-2);
}
.rec-advanced summary {
    cursor: pointer;
    padding: 0.75rem 1rem;
    font-weight: 600;
    color: var(--text);
    list-style: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.rec-advanced summary::-webkit-details-marker { display: none; }
.rec-advanced summary::before { content: '▸ '; color: var(--accent); }
.rec-advanced[open] summary::before { content: '▾ '; }
.rec-advanced-hint {
    font-weight: 400;
    font-size: 0.85rem;
    color: var(--text-muted);
}
.rec-advanced-body {
    padding: 0.75rem 1rem 1rem;
    border-top: 1px solid var(--border);
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0 1.25rem;
}

/* Results */
.rec-results { margin-top: 1.5rem; }
.rec-placeholder, .rec-error {
    text-align: center;
    color: var(--text-muted);
    padding: 2rem 1rem;
    background: var(--surface);
    border: 1px dashed var(--border);
    border-radius: var(--radius-lg);
}
.rec-empty {
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 3px solid var(--warning);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.5rem;
}
.rec-empty h3 { font-size: 1.1rem; margin-bottom: 0.5rem; color: var(--text); }
.rec-empty p { color: var(--text-secondary); font-size: 0.95rem; }

.rec-list { display: flex; flex-direction: column; gap: 1rem; }
.rec-card {
    display: flex;
    gap: 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem 1.5rem;
    align-items: flex-start;
}
.rec-card:hover { border-color: var(--border-light); }
.rec-rank {
    flex: 0 0 40px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--accent-glow);
    color: var(--accent);
    font-weight: 700;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
}
.rec-body { flex: 1; min-width: 0; }
.rec-model {
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
    color: var(--text);
    word-break: break-word;
}
.rec-meta {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
}
.rec-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 0.75rem;
}
.rec-why {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
}
.rec-why strong { color: var(--text); }
.rec-actions {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 0.5rem;
}
.rec-actions a {
    font-weight: 600;
    font-size: 0.9rem;
    display: inline-block;
    padding: 0.7rem 0.75rem;  /* ≥ 44px touch target */
}
.rec-contributor { color: var(--text-muted); font-size: 0.85rem; }
/* A2: the confidence badge next to the contributor name (verified / community
   / unverified) and the lifecycle labels for non-current entries. */
.rec-conf {
    display: inline-block;
    margin-left: 0.4rem;
    padding: 0.05rem 0.45rem;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 700;
    vertical-align: middle;
}
.rec-conf-verified { background: rgba(16, 185, 129, 0.15); color: var(--success); }
.rec-conf-community { background: var(--accent-glow); color: var(--accent); }
.rec-conf-unverified { background: rgba(132, 148, 171, 0.18); color: var(--text-muted); }
.rec-lifecycle {
    font-size: 0.78rem;
    font-weight: 700;
    margin: 0.15rem 0 0.5rem;
}
.rec-lifecycle-superseded { color: var(--warning); }
.rec-lifecycle-discontinued { color: var(--danger); }
.rec-count {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-top: 1rem;
}

/* === START-HERE WIZARD (C1) ===
   Three tappable-card steps that feed the form's own controls. Real
   <button> cards (min 88px tall) in a 2-col grid; one column on mobile.
   The visible title + description is each card's accessible name. */
.wizard { max-width: var(--form-max-width); margin: 2rem auto 0; }
.wizard-top { display: flex; justify-content: flex-end; margin-bottom: 0.5rem; }
.wizard-skip { color: var(--text-muted); font-size: 0.85rem; padding: 0.5rem 0.75rem; }
.wizard-skip:hover { color: var(--text); }
.wizard-step { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1.5rem; }
.wizard-progress { color: var(--text-muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.5px; }
.wizard-step h2 { font-size: 1.4rem; margin: 0.25rem 0; }
.wizard-sub { color: var(--text-secondary); font-size: 0.95rem; margin-bottom: 1.25rem; }
.wizard-back { background: none; border: none; color: var(--text-muted); font-size: 0.85rem; cursor: pointer; padding: 0.5rem 0.75rem; margin-bottom: 0.5rem; }
.wizard-back:hover { color: var(--text); }
.wizard-cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.75rem; }
.wizard-card { display: flex; flex-direction: column; align-items: flex-start; gap: 0.3rem; text-align: left; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; min-height: 88px; cursor: pointer; font: inherit; color: var(--text); }
.wizard-card:hover { border-color: var(--accent); }
.wizard-card .icon { font-size: 1.5rem; line-height: 1; }
.wizard-card-title { font-weight: 700; font-size: 1rem; }
.wizard-card-desc { color: var(--text-muted); font-size: 0.82rem; }
.wizard-actions { display: flex; gap: 0.75rem; flex-wrap: wrap; margin-top: 1rem; }

/* === VERIFICATION INDICATORS (B4/C4) ===
   One quiet color system for how well-corroborated a setup is, shared by
   the Matrix (dot next to the contributor), the detail panel (worded
   confidence line), and the Recommend cards (dot + label next to the
   name): green = verified, blue = community-reported, gray = unverified.
   Dots are tiny and carry role="img" + aria-label for screen readers. */
.confidence-dot {
    display: inline-block;
    font-size: 0.7em;
    line-height: 1;
    margin-left: 0.35rem;
    vertical-align: middle;
}
.confidence-dot.verified { color: var(--success); }
.confidence-dot.community { color: var(--accent); }
.confidence-dot.unverified { color: var(--text-muted); }

/* Small lifecycle tags in the Matrix model cell: "older" (superseded) and
   "retired" (discontinued). Outlined pills keep them subtle and their
   colors stay readable on the table surface. */
.lifecycle-tag {
    display: inline-block;
    margin-left: 0.4rem;
    padding: 0.05rem 0.4rem;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 700;
    vertical-align: middle;
    background: transparent;
}
.lifecycle-tag-superseded { border: 1px solid var(--warning); color: var(--warning); }
.lifecycle-tag-discontinued { border: 1px solid var(--danger); color: var(--danger); }

/* Detail panel: the confidence line + lifecycle warning under the badges. */
.detail-confidence { font-weight: 600; margin: 0.6rem 0 0; }
.detail-confidence.detail-conf-verified { color: var(--success); }
.detail-confidence.detail-conf-community { color: var(--accent); }
.detail-confidence.detail-conf-unverified { color: var(--text-muted); }
.detail-lifecycle {
    font-size: 0.9rem;
    font-weight: 600;
    margin: 0.25rem 0 0.6rem;
}
.detail-lifecycle-superseded { color: var(--warning); }
.detail-lifecycle-discontinued { color: var(--danger); }

/* === SHARED UTILITIES === */
.is-hidden { display: none !important; }

/* === LAUNCH COMMAND (P2-3) === */

/* The 🚀 button in a Matrix row (icon-only, so it carries an aria-label). */
.launch-btn {
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: var(--radius);
    padding: 0.4rem 0.55rem;
    cursor: pointer;
    font-size: 0.95rem;
    line-height: 1;
    min-width: 44px;      /* ≥ 44px touch target */
    min-height: 44px;
    transition: all 0.2s;
}
.launch-btn:hover { border-color: var(--accent); background: var(--accent-glow); }
.launch-btn:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }

/* The Matrix "Actions" cell: compare checkbox + launch button, side by side. */
.cell-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
    max-width: none;
    overflow: visible;
}
/* The checkbox itself is 18px; the negative-margin padding around the label
   widens the clickable hit area to ≥ 44px without moving the visual layout
   (WCAG 2.5.x target size). */
.compare-check-wrap {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    padding: 0.85rem;
    margin: -0.85rem;
}
.compare-check-wrap input {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
    cursor: pointer;
}

/* The launch button on a Recommend result card. */
.launch-card-btn {
    font-size: 0.85rem;
    padding: 0.7rem 1rem;   /* ≥ 44px touch target */
    min-height: 44px;
}

/* The shared command dialog (one instance, reused by every trigger). */
.cmd-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.72);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
body.cmd-open { overflow: hidden; }
.cmd-dialog {
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 640px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 1.5rem;
}
.cmd-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}
.cmd-header h2 { font-size: 1.3rem; }
.cmd-close {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    border-radius: var(--radius);
    width: 44px;       /* ≥ 44px touch target */
    height: 44px;
    cursor: pointer;
    font-size: 1rem;
    flex: 0 0 auto;
}
.cmd-close:hover { color: var(--text); border-color: var(--accent); }
.cmd-close:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.cmd-model { font-size: 1.05rem; margin-bottom: 0.5rem; }
.cmd-model .cmd-backend { color: var(--text-muted); font-size: 0.9rem; }
.cmd-note { margin-bottom: 1rem; }
.cmd-flag {
    display: inline-block;
    background: var(--accent-glow);
    color: var(--accent);
    border-radius: 4px;
    padding: 0.3rem 0.6rem;
    font-size: 0.8rem;
}
.cmd-flag--warn { background: rgba(245, 158, 11, 0.12); color: var(--warning); }
.cmd-code-wrap {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1rem;
}
.cmd-code {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-word;
    font-family: var(--font-mono);
    font-size: 0.9rem;
    color: var(--text);
    margin: 0;
}
.cmd-meta {
    display: flex;
    gap: 0.5rem;
    align-items: baseline;
    flex-wrap: wrap;
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
}
.cmd-meta-label {
    font-weight: 600;
    color: var(--text);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.cmd-expect, .cmd-tips { margin-bottom: 0.75rem; color: var(--text-secondary); font-size: 0.9rem; }
.cmd-expect p { margin-top: 0.25rem; }
.cmd-tips ul { margin: 0.25rem 0 0 1.25rem; }
.cmd-tips li { margin-bottom: 0.25rem; }
.cmd-steps ol { margin: 0 0 0 1.25rem; color: var(--text-secondary); font-size: 0.9rem; }
.cmd-steps li { margin-bottom: 0.35rem; }

/* The Backends-guide "pick a backend" picker (reuses the same generator). */
.cmd-picker {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem 1.5rem;
    margin: 1.25rem 0;
}
.cmd-picker h2 { font-size: 1.1rem; margin-bottom: 0.5rem; color: var(--text); }
.cmd-picker > p { color: var(--text-secondary); font-size: 0.9rem; margin-bottom: 0.75rem; }
.cmd-picker-row { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.cmd-picker-row label { font-weight: 600; font-size: 0.9rem; }
.cmd-picker-select {
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 0.7rem 1rem;   /* ≥ 44px touch target */
    border-radius: var(--radius);
    font-size: 0.9rem;
    min-width: 200px;
}
.cmd-picker-select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.cmd-picker-output { margin-top: 1rem; }

/* === COMPARE (P2-2) === */

/* The Matrix compare-selection bar (lights up once 2+ rows are ticked). */
.compare-bar {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    background: var(--surface);
    border: 1px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: 0.75rem 1rem;
    margin: 1rem 0;
    color: var(--text-muted);
    font-size: 0.9rem;
}
.compare-bar.active {
    border-style: solid;
    border-color: var(--accent);
    background: var(--accent-glow);
    color: var(--text);
}
.compare-bar-label { flex: 1; min-width: 180px; }
.compare-count { font-weight: 700; color: var(--accent); }
.matrix-actions-help { margin-top: 0.75rem; font-size: 0.9rem; }

/* The compare-page picker (shown when nothing is selected). */
.compare-picker-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin: 1.5rem 0;
}
.compare-pick-hint { color: var(--text-secondary); font-size: 0.9rem; margin-bottom: 1rem; }
.compare-pick-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1rem;
}
.compare-pick {
    width: 100%;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
}
.compare-pick:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.compare-pick-actions { display: flex; gap: 0.75rem; flex-wrap: wrap; }

/* The diff table (rows = attributes, columns = setups). */
.compare-takeaway {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin: 1rem 0;
    padding: 0.75rem 1rem;
    background: var(--surface);
    border-left: 3px solid var(--accent);
    border-radius: var(--radius);
}
.compare-table { min-width: 640px; }
.compare-table th, .compare-table td {
    white-space: normal;
    max-width: none;
    text-overflow: clip;
    overflow: visible;
    cursor: default;
}
.compare-attr {
    background: var(--surface-2);
    color: var(--text-secondary);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    text-align: left;
    min-width: 120px;
    vertical-align: top;
    position: sticky;
    left: 0;
    z-index: 2;
}
.compare-col { vertical-align: top; }
.compare-col-head { display: flex; flex-direction: column; gap: 0.25rem; }
.compare-model { font-size: 1rem; font-weight: 700; color: var(--text); }
.compare-col-meta { font-size: 0.8rem; color: var(--text-muted); }
.compare-matrix-link {
    font-size: 0.9rem;
    font-weight: 600;
    margin-top: 0.25rem;
    display: inline-block;
    padding: 0.65rem 0.5rem;  /* ≥ 44px touch target */
}
.compare-cell { vertical-align: top; color: var(--text-secondary); font-size: 0.9rem; }
.compare-diff {
    background: var(--accent-glow);
    color: var(--text);
    box-shadow: inset 3px 0 0 var(--accent);
}
.compare-empty { color: var(--text-muted); }
.compare-actions .compare-launch { font-size: 0.85rem; }
.compare-edit-row { margin-top: 1rem; }

/* B2/C3 decision support: the "best" micro-label on a numeric row's leading
   cell (green, quiet) and the directional Tradeoffs paragraph below the
   table. Close values (<20% apart) get no label — the paragraph calls them
   comparable instead of crowning a winner. */
.compare-winner {
    color: var(--success);
    font-size: 0.7rem;
    font-weight: 700;
    margin-left: 0.4rem;
    white-space: nowrap;
}
.compare-tradeoffs {
    margin-top: 0.5rem;
    padding: 0.75rem 1rem;
    background: var(--surface);
    border-left: 3px solid var(--success);
    border-radius: var(--radius);
}
.compare-tradeoffs-title {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    margin-bottom: 0.35rem;
}
.compare-tradeoffs-text {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.6;
}

/* === FILTER EMPTY STATE (P2-4) === */
.filter-empty {
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 3px solid var(--warning);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    margin: 1rem 0;
}
.filter-empty p { color: var(--text-secondary); font-size: 0.95rem; margin-bottom: 0.75rem; }

/* === CHARTS (P4-1: inline SVG, design-token styled) ===
   The <svg> blocks are generated by tools/site/charts.py. Every visual
   property resolves to a token above — the charts are part of the theme. */
.chart-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1rem;
    margin: 1rem 0;
}
.charts-intro { color: var(--text-secondary); font-size: 0.95rem; margin: 0.5rem 0 1rem; }
.chart-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin: 0;
}
.chart-card:hover { border-color: var(--border-light); }
.chart-card h3 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.chart-body {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    flex-wrap: wrap;
}
/* Responsive: viewBox scales the SVG to its container; no fixed pixels. */
.chart-svg {
    flex: 1 1 260px;
    min-width: 220px;
    width: 100%;
    height: auto;
    display: block;
}
/* The <svg> root is class="chart-svg" (not ".chart"), so every chart rule
   scopes to .chart-svg — this is what makes the design tokens resolve. (The
   earlier ".chart" scope matched nothing, so every shape fell back to the
   SVG default black fill and the "By the numbers" charts rendered all-black.) */
.chart-svg .grid-line { stroke: var(--border); stroke-width: 1; }
.chart-svg .axis-line { stroke: var(--border-light); stroke-width: 1.5; }
.chart-svg .tick-label { fill: var(--text-muted); font-size: 11px; font-family: var(--font-mono); }
.chart-svg .axis-title { fill: var(--text-secondary); font-size: 12px; font-family: var(--font-sans); }
.chart-svg .bar { fill: var(--chart-1); }
.chart-svg .bar:hover { fill: var(--accent-hover); }
.chart-svg .bar-value { fill: var(--text); font-size: 12px; font-weight: 600; font-family: var(--font-mono); }
.chart-svg .seg-1 { fill: var(--chart-1); }
.chart-svg .seg-2 { fill: var(--chart-2); }
.chart-svg .seg-3 { fill: var(--chart-3); }
.chart-svg .seg-4 { fill: var(--chart-4); }
.chart-svg .seg-5 { fill: var(--chart-5); }
.chart-svg .seg-6 { fill: var(--chart-6); }
.chart-svg .seg-7 { fill: var(--chart-7); }
.chart-svg .seg-1, .chart-svg .seg-2, .chart-svg .seg-3,
.chart-svg .seg-4, .chart-svg .seg-5, .chart-svg .seg-6,
.chart-svg .seg-7 { cursor: default; }
.chart-svg .dot { fill: var(--chart-2); stroke: var(--bg); stroke-width: 1.5; opacity: 0.9; }
.chart-svg .dot:hover { opacity: 1; }
.chart-svg .donut-center-value { fill: var(--text); font-size: 30px; font-weight: 700; font-family: var(--font-sans); }
.chart-svg .donut-center-label { fill: var(--text-muted); font-size: 11px; font-family: var(--font-sans); }
/* A 100% donut degenerates to a <circle> ring (fill:none + stroke-width);
   color it via stroke so the general .seg-N fill rule can't turn it into a disc. */
.chart-svg circle.seg-1 { fill: none; stroke: var(--chart-1); }
.chart-svg circle.seg-2 { fill: none; stroke: var(--chart-2); }
.chart-svg circle.seg-3 { fill: none; stroke: var(--chart-3); }
.chart-svg circle.seg-4 { fill: none; stroke: var(--chart-4); }
.chart-svg circle.seg-5 { fill: none; stroke: var(--chart-5); }
.chart-svg circle.seg-6 { fill: none; stroke: var(--chart-6); }
.chart-svg circle.seg-7 { fill: none; stroke: var(--chart-7); }

/* HTML legend (real text — screen-reader and keyboard friendly). */
.chart-legend {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    flex: 0 0 auto;
}
.chart-legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}
.chart-legend-swatch { width: 12px; height: 12px; border-radius: 3px; flex: 0 0 auto; }
.chart-legend-count { color: var(--text-muted); font-family: var(--font-mono); font-size: 0.8rem; }
.swatch-1 { background: var(--chart-1); }
.swatch-2 { background: var(--chart-2); }
.swatch-3 { background: var(--chart-3); }
.swatch-4 { background: var(--chart-4); }
.swatch-5 { background: var(--chart-5); }
.swatch-6 { background: var(--chart-6); }
.swatch-7 { background: var(--chart-7); }

/* === ADVANCED FILTERS (P4-2) === */

/* Multi-select dropdown (Backend / Use Case): disclosure button + a menu
   of native checkboxes (keyboard operable: Tab + Space, Esc closes). */
.multiselect { position: relative; }
.multiselect-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 0.7rem 1rem;
    min-height: 44px;         /* ≥ 44px touch target */
    border-radius: var(--radius);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
}
.multiselect-toggle:hover { border-color: var(--accent); }
.multiselect-toggle.active {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-glow);
    font-weight: 600;
}
.multiselect-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    z-index: 150;
    min-width: 230px;
    max-width: min(320px, calc(100vw - 2rem));
    max-height: 340px;
    overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 0.5rem;
}
.multiselect-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 0.75rem;
    min-height: 44px;        /* ≥ 44px touch target */
    box-sizing: border-box;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-secondary);
}
.multiselect-option:hover { background: var(--surface-2); color: var(--text); }
.multiselect-option input {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
    cursor: pointer;
    flex: 0 0 auto;
}

/* Sort dropdown + direction toggle (VRAM / size / speed / date). */
.filter-sort-wrap {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}
.filter-sort-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

/* Active-filter chips: one per applied value, each with an ✕ to remove. */
.filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 0.75rem 0 0;
}
.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    background: var(--accent-glow);
    color: var(--accent);
    border: 1px solid var(--accent);
    border-radius: 999px;
    padding: 0.55rem 0.9rem;
    min-height: 44px;        /* ≥ 44px touch target */
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}
.filter-chip:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.filter-chip .chip-x { font-size: 0.9rem; opacity: 0.8; }

/* Live result count ("Showing N of M submissions"). */
.filter-count {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin: 0.75rem 0 0.5rem;
}

/* Row re-entry transition (P4-2): a row that (re)appears after a filter
   change fades in. Hidden rows use display:none (out of the a11y tree and
   tab order), so only the show direction animates. The site-wide
   prefers-reduced-motion block zeroes this out for reduced-motion users. */
@keyframes row-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}
tr.row-enter { animation: row-fade-in 0.25s ease; }

/* === ROW DETAIL PANEL (P2-5) === */

/* Clickable data rows (keyboard: Enter/Space on the focused row). */
tr.data-row { cursor: pointer; }
tr.data-row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

/* The ⓘ affordance in the Actions cell (matches the 🚀 button's sizing). */
.detail-btn {
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: var(--radius);
    padding: 0.4rem 0.55rem;
    cursor: pointer;
    font-size: 0.95rem;
    line-height: 1;
    min-width: 44px;     /* ≥ 44px touch target */
    min-height: 44px;
    transition: all 0.2s;
}
.detail-btn:hover { border-color: var(--cyan); background: rgba(6, 182, 212, 0.1); }
.detail-btn:focus-visible { outline: none; border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.2); }

/* The scrim behind the open panel. */
.detail-scrim {
    position: fixed;
    inset: 0;
    z-index: 900;
    background: rgba(0, 0, 0, 0.55);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}
.detail-scrim.open { opacity: 1; pointer-events: auto; }

/* The slide-in panel (right side on desktop, full screen on mobile). */
.detail-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 950;
    width: min(520px, 100%);
    background: var(--surface);
    border-left: 1px solid var(--border-light);
    box-shadow: -8px 0 24px rgba(0, 0, 0, 0.45);
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    visibility: hidden;
    transition: transform 0.28s ease, visibility 0.28s ease;
}
.detail-panel.open { transform: translateX(0); visibility: visible; }
body.detail-open { overflow: hidden; }

.detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
}
.detail-header h2 { font-size: 1.2rem; word-break: break-word; }
.detail-close {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    border-radius: var(--radius);
    width: 44px;       /* ≥ 44px touch target */
    height: 44px;
    cursor: pointer;
    font-size: 1rem;
    flex: 0 0 auto;
}
.detail-close:hover { color: var(--text); border-color: var(--accent); }
.detail-close:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }

.detail-body {
    padding: 1.25rem 1.5rem 2rem;
    overflow-y: auto;
    flex: 1;
}
.detail-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 1.25rem;
}
.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.75rem 1.25rem;
    margin-bottom: 1.25rem;
}
.detail-item dt {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 0.15rem;
}
.detail-item dd {
    color: var(--text-secondary);
    font-size: 0.9rem;
    word-break: break-word;
    margin: 0;
}
.detail-notes h3 { font-size: 1rem; margin-bottom: 0.4rem; color: var(--text); }
.detail-notes p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    white-space: pre-wrap;
    word-break: break-word;
}
.detail-credit { color: var(--text-muted); font-size: 0.85rem; margin: 0.75rem 0 1.25rem; }
.detail-actions { display: flex; flex-direction: column; gap: 0.6rem; }
.detail-actions .btn { text-align: left; }

/* Respect reduced-motion (WCAG 2.3.3): kill every transition/animation
   site-wide — the detail panel appears without sliding, cards stop
   lifting on hover, smooth scrolling becomes instant. */
@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    .detail-panel, .detail-scrim { transition: none; }
}

/* === SUBMIT (P3-4: the community submission form) === */
/* Capped to a comfortable form width and centered (same as recommend). */
.submit-tool {
    max-width: var(--form-max-width);
    margin: 2rem auto;
}

.submit-form {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
}

/* Fieldset groups, each headed by a legend (a11y grouping). */
.submit-group {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.25rem 0.25rem;
    margin-bottom: 1.25rem;
}
.submit-group legend {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--accent);
    padding: 0 0.5rem;
}
.group-opt {
    font-weight: 400;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.submit-field { margin-bottom: 1rem; }
.submit-field label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.4rem;
    color: var(--text);
}
/* B10: required fields get a red " *" marker; optional fields a muted
   "(optional)" label — the form's 3-field minimum is legible at a glance. */
.req {
    color: var(--danger);
    font-size: 1.05rem;
    font-weight: 700;
    line-height: 0;
    margin-left: 0.2rem;
    vertical-align: super;
}
.opt {
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 500;
    margin-left: 0.35rem;
}
.submit-field input,
.submit-field select,
.submit-field textarea {
    width: 100%;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 0.7rem 0.9rem;     /* ≥ 44px touch target */
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-family: inherit;
}
.submit-field textarea { resize: vertical; min-height: 90px; }
.submit-field input:focus,
.submit-field select:focus,
.submit-field textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}
.submit-field input.invalid,
.submit-field select.invalid,
.submit-field textarea.invalid {
    border-color: var(--danger);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.18);
}
.field-hint {
    color: var(--text-muted);
    font-size: 0.82rem;
    margin-top: 0.35rem;
}
.field-err {
    color: var(--danger);
    font-size: 0.82rem;
    margin-top: 0.35rem;
}

/* Actions row (copy for the forum / open a GitHub issue). */
.submit-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-top: 1.25rem;
}
.submit-actions .btn { min-height: 44px; }

/* The generated [COMMUNITY-SUBMISSION] preview. */
.submit-preview {
    margin-top: 1.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 3px solid var(--success);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
}
.submit-preview h3 { font-size: 1.05rem; margin-bottom: 0.75rem; color: var(--text); }
.submit-preview pre {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-word;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--text);
    margin: 0 0 0.75rem;
}
.submit-preview-link { color: var(--text-secondary); font-size: 0.9rem; }

.submit-next { margin: 2rem 0; }

/* === CHANGELOG (C5) ===
   Flat, scannable release list: each version heading gets an accent
   left-bar; the change lists stay in the page's reading width. */
.changelog { max-width: var(--content-max-width); }
.changelog h2 { border-left: 3px solid var(--accent); padding-left: 0.75rem; margin: 1.75rem 0 0.75rem; }
.changelog h2:first-child { margin-top: 0; }
.changelog ul { margin-left: 1.5rem; margin-bottom: 1.25rem; }
.changelog li { color: var(--text-secondary); font-size: 0.95rem; margin-bottom: 0.4rem; }
.changelog li:last-child { margin-bottom: 0; }

/* === MOBILE === */
@media (max-width: 768px) {
    .container { padding: 1.5rem; }
    .hero { padding: 2rem 1rem; }
    .hero h1 { font-size: 1.8rem; }
    .stats-row { flex-direction: column; }
    .filter-bar { flex-direction: column; align-items: stretch; }
    .filter-bar input, .filter-bar select { width: 100%; }
    .filter-bar .multiselect, .filter-bar .filter-sort-wrap, .filter-bar .btn { width: 100%; }
    .filter-bar .multiselect-toggle, .filter-sort-wrap { justify-content: space-between; }
    .filter-sort-wrap .filter-select { flex: 1; }
    .chart-grid { grid-template-columns: 1fr; }
    .chart-body { flex-direction: column; align-items: stretch; gap: 0.75rem; }
    .chart-svg { min-width: 0; }
    .card-grid { grid-template-columns: 1fr; }
    table { font-size: 0.8rem; }
    td, th { padding: 0.5rem; }
    .guide { max-width: 100%; }
    .guide h1 { font-size: 1.6rem; }
    .guide h2 { font-size: 1.2rem; }
    .diagram-label { flex-basis: 70px; }
    .nav-dropdown-menu { min-width: 200px; }
    .recommend-teaser-card { flex-direction: column; align-items: flex-start; }
    .rec-advanced-body { grid-template-columns: 1fr; }
    .wizard-cards { grid-template-columns: 1fr; }
    .wizard-step { padding: 1.25rem; }
    .rec-card { flex-direction: column; gap: 0.5rem; padding: 1rem; }
    .rec-rank { width: 32px; height: 32px; font-size: 0.95rem; }
    .cmd-dialog { padding: 1.25rem; }
    .cmd-picker-row .cmd-picker-select { min-width: 100%; }
    .compare-pick-grid { grid-template-columns: 1fr; }
    .cell-actions { gap: 0.4rem; }
    .compare-attr { min-width: 90px; }
    /* The detail panel becomes a full-screen modal on small screens. */
    .detail-panel { width: 100%; border-left: none; }
    .detail-header, .detail-body { padding-left: 1rem; padding-right: 1rem; }
    /* Submit form: tighten the padding so the fields breathe on small screens. */
    .submit-form { padding: 1rem; }
    .submit-group { padding: 0.75rem 1rem 0.1rem; }
    .submit-actions .btn { flex: 1 1 auto; }
}
