/* The reading palette stays warm in both modes. Photos and collection covers retain their colors. */
:root{--paper:#fff;--surface:#f5f3f0;--theme-chip:#f0e9e5;color-scheme:light}
:root[data-theme=dark]{--paper:#1d1c1b;--surface:#282624;--theme-chip:#251d1f;--ink:#e8e3dc;--muted:#aaa29a;--rule:#46413c;--accent:#cf6872;color-scheme:dark;background:var(--paper)}
.theme-toggle{position:fixed;left:max(22px,env(safe-area-inset-left));bottom:calc(22px + env(safe-area-inset-bottom));z-index:70;display:flex;align-items:center;gap:0;width:86px;height:44px;padding:4px;border:1px solid var(--rule);border-radius:24px;background:var(--paper);color:var(--muted);box-shadow:0 2px 10px #0000000a;isolation:isolate;-webkit-tap-highlight-color:transparent}
.theme-toggle::before{content:'';position:absolute;left:4px;top:4px;width:36px;height:34px;border-radius:18px;background:var(--theme-chip);z-index:-1;transition:transform .2s ease}
.theme-toggle svg{width:19px;height:19px;margin:auto;flex:none;stroke:currentColor;stroke-width:1.6;fill:none;stroke-linecap:round;stroke-linejoin:round}
.theme-toggle .theme-sun{color:var(--accent)}
:root[data-theme=dark] .theme-toggle::before{transform:translateX(40px)}
:root[data-theme=dark] .theme-toggle .theme-sun{color:var(--muted)}
:root[data-theme=dark] .theme-toggle .theme-moon{color:var(--accent)}
.theme-toggle:hover{border-color:var(--muted)}
:root[data-theme=dark] .collection-page{--accent:#cf6872!important}
:root[data-theme=dark] :is(.filter,.tag-picker>summary,.tag-empty,.results-head,.card-meta,.card-bottom,.back,.article-byline,.article-meta,.related-label,.related-pending,.article-body figcaption,.article-body p:has(>img)+p,.toc-title,.toc a,.article-footer,.sidenote,.sidenote button,.topnote,.header-catalog){color:var(--muted)}
:root[data-theme=dark] :is(.excerpt,.article-body,.article-body blockquote,.collection-reading-order){color:var(--ink)}
:root[data-theme=dark] :is(.filter:hover,.filter.active,.toc a:hover,.back:hover,.header-catalog:hover){color:var(--accent)}
:root[data-theme=dark] :is(.length-control select,.tag-popover,.tag-popover input,.ai-copy-dialog,.ai-copy-dialog button,.fragment-tools,.quote-dialog,.quote-edit textarea){background:var(--paper);color:var(--ink)}
:root[data-theme=dark] :is(.card-visual,.hero-media,.resume,.article-body pre,.quote-preview){background:var(--surface)}
:root[data-theme=dark] :is(.search-wrap,.length-control select,.tag-popover,.sidenote,.article-body blockquote,.collection-item,.card,.card:not(:has(.card-visual))){border-color:var(--rule)}
:root[data-theme=dark] .search-wrap:focus-within{border-color:var(--muted);box-shadow:inset 0 0 0 1px var(--muted)}
:root[data-theme=dark] .search-wrap input::placeholder{color:var(--muted)}
:root[data-theme=dark] :is(.tag-popover .filter.active,.selected-tag,.related .ai-service:hover,.collection-heading nav .ai-service:hover,.fragment-buttons button:hover,.fragment-buttons button[aria-expanded=true],.fragment-discussion .ai-service:hover){background:var(--theme-chip)}
:root[data-theme=dark] .tag-popover .filter:hover{background:var(--surface)}
:root[data-theme=dark] .article-body .figure-chart{background:#fafafa;color:#242424}
:root[data-theme=dark] .fragment-target{background:#4a3b2b;box-shadow:0 0 0 5px #4a3b2b}
:root[data-theme=dark]::highlight(shkaf-fragment){background:#70512f;color:var(--ink)}
@media(max-width:1350px){:root[data-theme=dark] .sidenote{background:var(--surface)}}
@media(max-width:600px){.theme-toggle{left:max(14px,env(safe-area-inset-left));bottom:calc(14px + env(safe-area-inset-bottom))}}
@media(prefers-reduced-motion:reduce){.theme-toggle::before{transition:none}}
:root[data-theme=dark] .ai-service[data-ai-service=chatgpt] img{filter:invert(1)}
:root[data-theme=dark] .ai-copy-dialog textarea{background:var(--surface);color:var(--ink)}
