:root{
 --bg:#f6f0e3;--surface:#fffdf7;--surface-elevated:#fffdf7;
 --text-primary:#1d2d4b;--text-secondary:#596579;--text-reading:#45536a;
 --border:#d9d5cc;--accent:#9e502d;--overlay:#15213b55;
 --input-bg:#fffdf7;--hover:#aa775b0d;--accent-soft:#aa775b14;
 --accent-border:#aa775b66;--input-border:#9b9d9a;--scrollbar:#59657966;
 --paper:var(--bg);--white:var(--surface);--ink:var(--text-primary);--muted:var(--text-secondary);--line:var(--border);
 color-scheme:light;
}
:root[data-theme="dark"]{
 --bg:#1e2023;--surface:#26282b;--surface-elevated:#2c2e31;
 --text-primary:#eae4d8;--text-secondary:#b4ada2;--text-reading:#c7bfb2;
 --border:#414446;--accent:#d99a77;--overlay:#0e141980;
 --input-bg:#25272b;--hover:#37322f;--accent-soft:#d99a771a;
 --accent-border:#d99a7766;--input-border:#6f736f;--scrollbar:#b4ada266;--gold:#4a3b2e;
 color-scheme:dark;
}
/* CSS fallback for Auto if JavaScript is unavailable. No image inversion. */
@media(prefers-color-scheme:dark){:root:not([data-theme]){
 --bg:#1e2023;--surface:#26282b;--surface-elevated:#2c2e31;
 --text-primary:#eae4d8;--text-secondary:#b4ada2;--text-reading:#c7bfb2;
 --border:#414446;--accent:#d99a77;--overlay:#0e141980;
 --input-bg:#25272b;--hover:#37322f;--accent-soft:#d99a771a;
 --accent-border:#d99a7766;--input-border:#6f736f;--scrollbar:#b4ada266;--gold:#4a3b2e;
 color-scheme:dark;
}}
html,body{background:var(--bg);color:var(--text-primary)}
button,input,select,textarea{color:var(--text-primary)}
::selection{background:var(--accent-soft);color:var(--text-primary)}
input::placeholder,textarea::placeholder{color:var(--text-secondary);opacity:1}
.topbar,.drawer-top{background:var(--bg)}
.archive-drawer,.quick-search,.filter-panel{background:var(--surface-elevated);border-color:var(--border)}
.archive-drawer::backdrop,.quick-search::backdrop{background:var(--overlay)}
.sidebar-scroll,#quick-results,.filter-options{scrollbar-width:thin;scrollbar-color:var(--scrollbar) transparent}
.sidebar-scroll::-webkit-scrollbar-thumb{background:var(--scrollbar)}
.sidebar-scroll::-webkit-scrollbar-track{background:transparent}
.menu-toggle:hover,.close-menu:hover,.archive-groups a:hover,.archive-groups a[aria-current],.taxonomy-grid>a:hover,.quick-top button:hover{background:var(--hover)}
.archive-groups a,.quick-result{border-bottom-color:var(--border);border-top-color:var(--border)}
.search-toggle{border-color:var(--border)}
.search-toggle:hover{background:var(--hover);border-color:var(--accent-border);color:var(--accent)}
.quick-search input,.filters input,.filters select,.editorial-filters .filter-search input,.editorial-filters .topic-find input,#archive-search{background:var(--input-bg);border-color:var(--input-border)}
.quick-search input:focus-visible{border-color:var(--accent);outline:1px solid var(--accent-border)}
.quick-result mark{background:var(--accent-soft)}
.quick-result:hover,.quick-result:focus-visible,.filter-options button:hover,.filter-options button:focus-visible{background:var(--hover)}
.quick-result:focus-visible{outline-color:var(--accent)}
.quick-more{border-color:var(--accent-border);color:var(--accent)}
.filter-panel{box-shadow:none}
.filter-options button[aria-selected="true"]{color:var(--accent)}
.filter-chip:hover{border-color:var(--accent);color:var(--accent)}
.feature-copy>p,.card-copy p,.article-lead,.article-body .lead{color:var(--text-reading)}
.taxonomy-grid>a{background:var(--surface)}
.card-image{background:var(--surface);border:1px solid var(--border)}
.feature-quote .label{color:var(--text-primary)}
.theme-control{border:0;border-top:1px solid var(--border);padding:20px 0 0;margin:24px 0 0;min-width:0}
.theme-control legend{float:left;width:100%;font-size:.8rem;color:var(--text-secondary);margin-bottom:12px;padding:0}
.theme-options{clear:both;display:flex;gap:4px;padding:3px;border:1px solid var(--border);border-radius:4px;background:var(--bg)}
.theme-options label{position:relative;flex:1;cursor:pointer;min-width:0}
.theme-options input{position:absolute;opacity:0;width:1px;height:1px}
.theme-options span{display:block;text-align:center;padding:9px 4px;font-size:.82rem;line-height:1.4;border:1px solid transparent;border-radius:3px;color:var(--text-secondary)}
.theme-options input:checked+span{color:var(--text-primary);background:var(--hover);border-color:var(--accent-border)}
.theme-options input:focus-visible+span{outline:2px solid var(--accent);outline-offset:2px}
.theme-options label:hover span{color:var(--accent)}
button:disabled{color:var(--text-secondary);opacity:.7}
html.theme-switching,html.theme-switching body{transition:background-color 160ms ease-out,color 160ms ease-out}
/* Editorial surfaces that previously used literal light colors. */
:root[data-theme="dark"] .book-spine{background:var(--surface-elevated);border-left-color:var(--accent)}
:root[data-theme="dark"] .book-card:nth-child(2) .book-spine{background:#29313a;border-left-color:#9cabb8}
:root[data-theme="dark"] .book-card:nth-child(3) .book-spine{background:#352c28;border-left-color:var(--accent)}
:root[data-theme="dark"] :is(.dark-note,.steps>div:last-child){background:var(--surface-elevated);color:var(--text-primary);border-color:var(--border)}
:root[data-theme="dark"] :is(.closing,.comparison>div:last-child){background:#352f29;color:var(--text-primary)}
:root[data-theme="dark"] :is(.quote-mark,.feature-quote .label,.type-cover .label,.dark-note .label,.steps>div:last-child .label){color:var(--accent)}
:root[data-theme="dark"] .type-cover{background:var(--surface-elevated)}
:root[data-theme="dark"] .post-card.blue .type-cover{background:#29313a}
:root[data-theme="dark"] .post-card.orange .type-cover{background:#352c28}
:root[data-theme="dark"] :is(code,pre){background:var(--surface);color:var(--text-primary);border-color:var(--border)}
@media(prefers-reduced-motion:reduce){html.theme-switching,html.theme-switching body{transition:none}}
