html[data-theme="dark"] {
    --color-bg: #12100e;
    --color-bg-alt: #1a1714;
    --color-paper: #1c1915;
    --color-text: #efeae2;
    --color-text-secondary: #c4bdb0;
    --color-text-muted: #8f877c;
    --color-border: #2e2922;
    --color-primary: #c4a574;
    --color-primary-light: #d4b483;
    --color-primary-dark: #a88955;
    --color-secondary: #0a0908;
    --color-accent: #d4b483;
}

html[data-theme="dark"] body {
    color-scheme: dark;
    background:
        radial-gradient(ellipse at 15% 0%, rgba(196, 165, 116, 0.1), transparent 45%),
        linear-gradient(180deg, #12100e 0%, #0a0908 100%);
}

html[data-theme="dark"] .cover,
html[data-theme="dark"] .sheet-card,
html[data-theme="dark"] .sheet-page,
html[data-theme="dark"] .nav-prev,
html[data-theme="dark"] .nav-next,
html[data-theme="dark"] .nav-toc,
html[data-theme="dark"] .rulebook-table,
html[data-theme="dark"] .search-hit a {
    background: var(--color-paper);
    color: var(--color-text);
    border-color: var(--color-border);
}

html[data-theme="dark"] .main-content .btn {
    background: #221e18;
    color: var(--color-text);
    border-color: var(--color-border);
}

html[data-theme="dark"] .page-toc {
    background: rgba(28, 24, 20, 0.94);
    border-color: rgba(207, 198, 184, 0.2);
}
html[data-theme="dark"] .page-toc-link {
    background: rgba(255, 255, 255, 0.06);
    color: #d8d0c4;
}
html[data-theme="dark"] .page-toc-item--h3 .page-toc-link {
    background: transparent;
    border-color: rgba(207, 198, 184, 0.25);
    color: #a89f93;
}
html[data-theme="dark"] .page-toc-link.is-active {
    background: #c4a574;
    border-color: #c4a574;
    color: #14110e;
}
html[data-theme="dark"] .attr-mode-chip {
    color: #e8e0d4;
    border-color: rgba(196, 165, 116, 0.4);
}
html[data-theme="dark"] .attr-mode-chip.is-active {
    background: #c4a574;
    border-color: #c4a574;
    color: #14110e;
}
html[data-theme="dark"] .attr-mode-bar {
    background: var(--color-bg, #14110e);
    border-bottom-color: rgba(196, 165, 116, 0.28);
}
html[data-theme="dark"] .attr-diff-chip {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(196, 165, 116, 0.35);
    color: #e8e0d4;
}
html[data-theme="dark"] .attr-diff-chip.is-active {
    background: #c4a574;
    border-color: #c4a574;
    color: #14110e;
}
html[data-theme="dark"] .attr-diff-pane {
    background: rgba(255, 255, 255, 0.04);
}
html[data-theme="dark"] .attr-mod-chip {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(196, 165, 116, 0.35);
    color: #e8e0d4;
}
html[data-theme="dark"] .attr-mod-chip.is-active {
    background: #c4a574;
    border-color: #c4a574;
    color: #14110e;
}
html[data-theme="dark"] .attr-mod-pane {
    background: rgba(255, 255, 255, 0.04);
}
html[data-theme="dark"] .attr-mod-table td {
    border-bottom-color: rgba(207, 198, 184, 0.12);
}
html[data-theme="dark"] .attr-mod-code {
    color: #c4a574;
}
html[data-theme="dark"] .attr-level-chip {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(196, 165, 116, 0.35);
    color: #e8e0d4;
}
html[data-theme="dark"] .attr-level-chip.is-active {
    background: #c4a574;
    border-color: #c4a574;
    color: #14110e;
}
html[data-theme="dark"] .attr-level-card {
    background: rgba(255, 255, 255, 0.04);
}
html[data-theme="dark"] .attr-fork-chip {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(196, 165, 116, 0.35);
    color: #e8e0d4;
}
html[data-theme="dark"] .attr-fork-chip.is-active {
    background: #c4a574;
    border-color: #c4a574;
    color: #14110e;
}
html[data-theme="dark"] .attr-level-jump input {
    background: #1a1612;
    border-color: rgba(196, 165, 116, 0.35);
    color: #e8e0d4;
}
html[data-theme="dark"] .outcome-pane {
    background: rgba(255, 255, 255, 0.04);
}
html[data-theme="dark"] .outcome-picker-hint {
    color: #a89f93;
}
html[data-theme="dark"] .rule-block {
    background: rgba(196, 165, 116, 0.08);
    color: var(--color-text-secondary);
}

/* --color-secondary stays near-black (chrome fills); headings need light ink */
html[data-theme="dark"] .chapter-content h1,
html[data-theme="dark"] .chapter-content h2,
html[data-theme="dark"] .chapter-content h3,
html[data-theme="dark"] .chapter-content h4,
html[data-theme="dark"] .chapter-content h5,
html[data-theme="dark"] .chapter-header h1,
html[data-theme="dark"] .chapter-header .chapter-title,
html[data-theme="dark"] .sheet-card h1,
html[data-theme="dark"] .sheet-card h2,
html[data-theme="dark"] .sheet-card h3 {
    color: #f0e8dc;
}

html[data-theme="dark"] .chapter-content code {
    color: var(--color-accent);
    background: rgba(196, 165, 116, 0.12);
}

html[data-theme="dark"] .chapter-content a,
html[data-theme="dark"] .chapter-content a.rule-ref {
    color: var(--color-accent-soft);
}

html[data-theme="dark"] .chapter-content strong {
    color: #f0e8dc;
}
html[data-theme="dark"] .rule-spoiler {
    border-color: rgba(207, 198, 184, 0.2);
    background: rgba(255, 255, 255, 0.03);
}
html[data-theme="dark"] .rule-spoiler > summary:hover {
    background: rgba(255, 255, 255, 0.05);
}
html[data-theme="dark"] .rule-spoiler-body {
    border-top-color: rgba(207, 198, 184, 0.14);
}
