/* One palette for home, catalog, details, accounts and reading. */
html:root {
  --theme-paper:#191a1d; --theme-surface:#232529; --theme-ink:#f4f2eb;
  --theme-muted:#b5b5b4; --theme-line:#3b3c40; --theme-accent:#f2c34e;
  --theme-on-accent:#1c1b17; --theme-soft:#2d2e31; --theme-outer:#191a1d;
  --theme-focus:#f2c34e; --theme-shadow:none; color-scheme:dark;
}
html:root[data-theme="paper"] {
  --theme-paper:#f7f2e5; --theme-surface:#fffbf2; --theme-ink:#302b24;
  --theme-muted:#716657; --theme-line:#ded5c4; --theme-accent:#805b08;
  --theme-on-accent:#fffdf6; --theme-soft:#eee5d3; --theme-outer:#f7f2e5;
  --theme-focus:#805b08; --theme-shadow:0 12px 35px #302b2410; color-scheme:light;
}
html:root[data-theme="white"] {
  --theme-paper:#ffffff; --theme-surface:#f6f7f8; --theme-ink:#242529;
  --theme-muted:#606369; --theme-line:#dedfe2; --theme-accent:#795900;
  --theme-on-accent:#ffffff; --theme-soft:#eef0f2; --theme-outer:#ffffff;
  --theme-focus:#795900; --theme-shadow:0 12px 35px #2425290c; color-scheme:light;
}
/* These aliases also replace the former page-scoped green/cream overrides. */
html:root[data-theme], html:root[data-theme] body, html:root[data-theme] #accountDropdown {
  --paper:var(--theme-paper); --surface:var(--theme-surface); --ink:var(--theme-ink);
  --muted:var(--theme-muted); --line:var(--theme-line); --green:var(--theme-accent);
  --on-green:var(--theme-on-accent); --soft:var(--theme-soft); --outer:var(--theme-outer);
  --focus:var(--theme-focus); --shadow:var(--theme-shadow);
  --color-paper:var(--paper); --color-surface:var(--surface); --color-ink:var(--ink);
  --color-muted:var(--muted); --color-accent:var(--green); --color-accent-ink:var(--on-green);
  --color-rule:var(--line); --color-tint:var(--soft); --color-focus:var(--focus);
  --home-amber:#efb923; --home-amber-ink:var(--green);
}
html[data-theme] body { background:var(--paper); color:var(--ink); }
html[data-theme] .topbar { background:var(--surface); border-color:var(--line); }
html[data-theme] .top-search { background:var(--paper); border-color:var(--line); }
html[data-theme] .toc-toggle { background:var(--paper); color:var(--ink); }
html[data-theme] .toc-toggle:hover { background:var(--soft); }
html[data-theme] .toc-group { border-color:var(--line); }
html[data-theme] .seo-cover, html[data-theme] .cover-fallback { background:var(--soft); color:var(--muted); }
.theme-picker { position:relative; flex:none; }
#themeToggle { display:flex; align-items:center; justify-content:center; gap:7px; min-width:96px; min-height:44px; padding:8px 12px; color:var(--ink); background:var(--surface); border:1px solid var(--line); border-radius:10px; font:inherit; font-size:13px; white-space:nowrap; }
#themeToggle:hover, #themeToggle[aria-expanded="true"] { border-color:var(--green); }
#themePanel { position:absolute; top:calc(100% + 8px); right:0; z-index:180; width:198px; max-width:calc(100vw - 24px); padding:8px; background:var(--surface); color:var(--ink); border:1px solid var(--line); border-radius:12px; box-shadow:0 12px 35px #0003; }
#themePanel[hidden] { display:none!important; }
.theme-heading { margin:4px 8px 8px; font-size:12px; color:var(--muted); }
#themePanel button { display:flex; align-items:center; gap:10px; min-height:44px; width:100%; padding:10px; border:1px solid transparent; border-radius:8px; background:transparent; color:var(--ink); text-align:left; font:inherit; font-size:14px; }
#themePanel button:hover { background:var(--soft); }
#themePanel button[aria-pressed="true"] { background:var(--soft); border-color:var(--green); }
#themePanel button[aria-pressed="true"]::after { content:'✓'; margin-left:auto; color:var(--green); }
.theme-swatch { width:22px; height:22px; flex:none; border-radius:50%; border:1px solid #8a8a8a; }
.theme-swatch-night { background:#191a1d; box-shadow:inset -5px 0 #f2c34e; }
.theme-swatch-paper { background:#f7f2e5; }
.theme-swatch-white { background:#fff; }
.theme-picker :focus-visible { outline:2px solid var(--focus); outline-offset:3px; }
@media(max-width:600px) { #themeToggle { min-width:44px; width:44px; padding:8px; } #themeToggle .theme-label { display:none; } }
