/* Neutral interface surfaces. No filters or recoloring on artwork, canvas or scenes. */
html[data-theme]{--ui-bg:#f7f4ea;--ui-panel:#efe9d8;--ui-fg:#011015;--ui-muted:#53615f;--ui-line:#01101530;--ui-glass:#f7f4eaf5;--ui-accent:#b93600;color-scheme:light}
html[data-theme=dark]{--ui-bg:#011015;--ui-panel:#10232a;--ui-fg:#efe9d8;--ui-muted:#acb9b8;--ui-line:#efe9d838;--ui-glass:#011015f5;--ui-accent:#ff8652;color-scheme:dark}
html[data-theme] body{background:var(--ui-bg);color:var(--ui-fg)}
html[data-theme] .site-nav{color:var(--ui-fg);--sn-bg:var(--ui-glass);--sn-bar:var(--ui-bg);--sn-line:var(--ui-line)}
html[data-theme] :is(.site-nav,.tg-nav) .sn-sites a:not(:hover):not([aria-current="true"]){color:var(--ui-muted);opacity:1}
html[data-theme=light] :is(.site-nav,.tg-nav) .sn-logo-b{display:block}html[data-theme=light] :is(.site-nav,.tg-nav) .sn-logo-w{display:none}
html[data-theme=dark] :is(.site-nav,.tg-nav) .sn-logo-b{display:none}html[data-theme=dark] :is(.site-nav,.tg-nav) .sn-logo-w{display:block}
.sn-theme{position:relative;display:inline-flex;align-items:center;flex:0 0 36px;color:inherit;letter-spacing:normal}
.sn-theme-button{width:36px;height:36px;display:inline-flex;align-items:center;justify-content:center;border:0;padding:0;margin:0;background:none;color:inherit;cursor:pointer;border-radius:50%}
.sn-theme-button:hover{background:rgba(1,16,21,.06)}
.sn-theme-menu{display:none;position:absolute;top:calc(100% + 6px);right:0;min-width:150px;padding:6px;background:#F7F4EA;border:1px solid #011015;box-shadow:0 18px 40px rgba(1,16,21,.18);z-index:1000}
.sn-theme.open .sn-theme-menu{display:block}
.sn-theme .sn-theme-item{display:flex;align-items:center;gap:10px;width:100%;padding:8px 10px;border:0;background:none;color:#011015;text-align:left;cursor:pointer;font:500 13px/1.2 Rules,Arial,sans-serif;letter-spacing:.06em;text-transform:uppercase}
.sn-theme-item:hover{background:rgba(1,16,21,.06)}
.sn-theme-item i{width:7px;height:7px;border-radius:50%;flex:0 0 7px;background:transparent}
.sn-theme-item[aria-checked=true] i{background:#FF4C00}
html[data-theme=dark] .sn-theme-menu{background:#0A1B21;border-color:rgba(239,233,216,.3)}
html[data-theme=dark] .sn-theme-item{color:#EFE9D8}
html[data-theme=dark] :is(.sn-theme-item,.sn-theme-button):hover{background:rgba(239,233,216,.048)}
html[data-theme=light] :is(.site-nav,.tg-nav){--sn-bg:#efe9d8;color:#011015}
html[data-theme=dark] :is(.site-nav,.tg-nav){--sn-bg:#011015;color:#efe9d8}
@media(max-width:860px){html[data-theme=light] :is(.site-nav,.tg-nav){--sn-bg:rgba(245,242,231,.96)}}
html[data-theme] :is(.rp-page,#rp-root,#mv-paper,.pp-panel,.mc,.lr-reader){--lr-paper:var(--ui-bg);--lr-cream:var(--ui-fg);--lr-ink:var(--ui-fg);--lr-dim:var(--ui-muted);--lr-hair:var(--ui-line);--rp-paper:var(--ui-bg);--rp-muted:var(--ui-muted);--rp-line:var(--ui-line);background:var(--ui-bg);color:var(--ui-fg)}
html[data-theme] :is(.rp-context,.lr-reader-bar){background:var(--ui-panel);color:var(--ui-fg);border-color:var(--ui-line)}
html[data-theme] :is(.rp-position,#lt-reader-position){color:var(--ui-muted)}
html[data-theme] :is(.rp-image-button,.rp-related-item img,.rp-related-blank,.mv-static figure){background:var(--ui-panel);color:var(--ui-fg)}
html[data-theme] .rp-prose a:hover{color:var(--ui-accent)}
html[data-theme] :is(.rp-sources a,.rp-pod-links a){text-decoration-color:var(--ui-muted)}
html[data-theme] :is(.rp-lightbox,.rp-lightbox button){color:var(--ui-fg)}
html[data-theme] #lt{background:var(--ui-bg);color:var(--ui-fg)}
html[data-theme] #lt :is(input,select,button,a){color:inherit}
html[data-theme] #lt :is(.lt-modes a[aria-current=page],.lt-modes a:hover){background:var(--ui-panel);color:var(--ui-fg)}
html[data-theme] #lt :is(.lt-eyebrow,.lt-intro,.lt-count,.lt-foot,.lt-year,.lt-card-title){color:var(--ui-muted)}
html[data-theme] #lt :is(.lt-heading,.lt-modes,.lt-search){border-color:var(--ui-line)}
html[data-theme] :is(.cz-deck,.cz-tools,.cz-toolbar,.iv-panel,.pn,.iv-strip,.th-panel,.th-bar){background:var(--ui-bg);color:var(--ui-fg);--cream:var(--ui-fg);--paper:var(--ui-bg);--ink:var(--ui-bg);--dim-c:var(--ui-muted);--hair-c:var(--ui-line);--cz-dimtx:var(--ui-muted)}
html[data-theme] .cz-deck :is(.cz-era,.cz-ch-links a,.cz-ch-links button,.cz-chip){color:var(--ui-fg);border-color:var(--ui-line)}
html[data-theme] .cz-ch-desc{color:var(--ui-muted)}
html[data-theme] .cz-chip[aria-pressed=true]{background:var(--ui-panel);color:var(--ui-fg)}
html[data-theme] .mc{--paper:var(--ui-bg);--ink:var(--ui-fg);--dim:var(--ui-muted);--hair:var(--ui-line);--dw-bg:var(--ui-bg);--dw-ink:var(--ui-fg)}
html[data-theme] .mc-plate{background:var(--ui-panel);color:var(--ui-fg)}
html[data-theme] .mc-plate[aria-pressed=true]{border-color:var(--lr-orange);background:var(--ui-bg);--dw-bg:var(--ui-bg);--dw-ink:var(--ui-fg)}
html[data-theme] :is(.hm-ways,.hm-ledger,.hm-reading,.hm-mosaic,.hm-about){background:var(--ui-bg);color:var(--ui-fg)}
html[data-theme] :is(.hm-ways,.hm-ledger,.hm-reading,.hm-about) :is(p,a,h2,h3,dt,dd,small){color:inherit}
html[data-theme] :is(.hm-ways,.hm-ledger,.hm-reading,.hm-about){--hm-ink:var(--ui-fg);--hm-cream:var(--ui-bg);--hm-paper:var(--ui-bg);--hm-card:var(--ui-panel)}
/* Ways-in labels are spans, so they must not retain the scene's cream text. */
html[data-theme] .hm-ways{border-color:var(--ui-line)}
html[data-theme] .hm-ways .hm-door{border-color:var(--ui-line)}
html[data-theme] .hm-ways :is(.hm-door-n,.hm-fcap .lab){color:var(--ui-fg)}
html[data-theme] .hm-ways :is(.hm-door-k,.hm-door-d,.hm-fcap-t){color:var(--ui-muted)}
html[data-theme] .hm-ways :is(.hm-door-go,.hm-fcap-go){color:var(--ui-accent)!important}
html[data-theme] .hm-ways .hm-ftab{color:var(--ui-fg);border-color:var(--ui-line)}
html[data-theme] .hm-ways .hm-ftab[aria-selected=true]{background:var(--ui-panel);color:var(--ui-fg);border-color:var(--ui-fg)}
/* Keep scene canvases and the overlaid stage text in their designed palette. */
html[data-theme] :is(.hm-hero,.iv-map,.cz-canvas,.th-stage){color:#efe9d8}

html[data-theme] #lt :is(select,#lt-titles){background:var(--ui-panel);color:var(--ui-fg)}
html[data-theme] #lt :is(.lt-footer){background:var(--ui-panel);color:var(--ui-fg)}
html[data-theme] #lt :is(.lt-chapter-era,.lt-chapter-total,.lt-chapter-total span,.lt-count,.lt-count b){color:var(--ui-muted)}
html[data-theme] #lt .lt-plate,html[data-theme] #lt .lt-plate .lt-caption{color:#efe9d8}
html[data-theme] #lt input::placeholder{color:var(--ui-muted)}
html[data-theme] .iv-panel{--ink:var(--ui-fg);--paper:var(--ui-bg)}
html[data-theme] .iv-panel :is(p,small,.pn-eye,.pn-meta,.pn-x){color:var(--ui-muted)!important}
html[data-theme] .iv-panel :is(h1,h2,h3,a,button,.pn-year){color:var(--ui-fg)}
html[data-theme] :is(#hm-count,#hm-lr,#hm-chance){background:var(--ui-bg);color:var(--ui-fg);--hm-ink:var(--ui-fg);--hm-paper:var(--ui-bg);--hm-cream:var(--ui-bg);--hm-card:var(--ui-panel)}
html[data-theme] :is(#hm-count,#hm-lr,#hm-chance) :is(p,dt,dd,small,h2,h3,a){color:inherit}
html[data-theme] #lt-reader{background:var(--ui-bg)}
html[data-theme] .rp-page{background:var(--ui-bg)!important;color:var(--ui-fg)!important}
html[data-theme] #lt .lt-footer :is(span,strong,time){color:var(--ui-fg)}
html[data-theme] :is(.iv-side,.iv-help-dialog,.tv-notes,.lm-head,.lm-tools,.lm-keys){background:var(--ui-bg);color:var(--ui-fg);border-color:var(--ui-line)}
html[data-theme] :is(.lm-head,.lm-tools,.lm-keys) :is(p,h1,button){color:inherit}
html[data-theme] .tv-notes{--ink:var(--ui-fg);--paper:var(--ui-bg);--cream:var(--ui-panel)}
/* Scene cards retain their authored palette: their textures and local surfaces use it too. */
html[data-theme] #lr-strip{--lr-chrome-bg:var(--ui-glass);--lr-chrome-fg:var(--ui-fg);--lr-chrome-dim:var(--ui-muted);--lr-chrome-hair:var(--ui-line)}
/* Search surfaces and their text must change theme together, including selected rows and previews. */
html[data-theme] .lrs-root{color:var(--ui-fg)}
html[data-theme] .lrs-panel{background:var(--ui-bg);color:var(--ui-fg)}
html[data-theme] :is(.lrs-pane,.lrs-pane:empty,.lrs-row.is-sel,.lrs-note,.lrs-chip){background:var(--ui-panel);color:var(--ui-fg)}
html[data-theme] .lrs-root :is(.lrs-input,.lrs-t,.lrs-pane h3,.lrs-pane dd,.lrs-pv-y,.lrs-pv-desc,.lrs-pv-terms,.lrs-pv-list){color:var(--ui-fg)}
html[data-theme] .lrs-root :is(.lrs-x,.lrs-filters button,.lrs-g,.lrs-y,.lrs-t small,.lrs-c,.lrs-empty,.lrs-foot,.lrs-pane dt,.lrs-pv-n,.lrs-pv-list b,.lrs-pv-go){color:var(--ui-muted)}
html[data-theme] .lrs-filters button[aria-selected="true"]{color:var(--ui-fg);border-bottom-color:var(--ui-accent)}
html[data-theme] .lrs-root :is(.lrs-icon,.lrs-more,.lrs-hash,.lrs-t .lrs-dice,.lrs-pv-lab){color:var(--ui-accent)}
/* Chapter labels carry inline ink colors intended for pale paper. */
html[data-theme] .lrs-pane .lrs-pv-lab{color:var(--ui-accent)!important}
html[data-theme] .lrs-row.is-sel{border-left-color:var(--ui-accent)}
html[data-theme] .lrs-note{border-left-color:var(--ui-accent)}
html[data-theme] .lrs-root :is(.lrs-bar,.lrs-filters,.lrs-foot,.lrs-pane,.lrs-hash,.lrs-ed,.lrs-pv-flags span){border-color:var(--ui-line)}
html[data-theme] .lrs-root kbd{background:var(--ui-bg);color:var(--ui-fg);border-color:var(--ui-line)}
html[data-theme] .lrs-ini{background:var(--ui-fg);color:var(--ui-bg)}
html[data-theme] .lrs-input::placeholder{color:var(--ui-muted)}

/* People: the reading panel has its own palette; the star map keeps its scene palette. */
html[data-theme] .pp-panel{--ink:var(--ui-fg);--paper:var(--ui-bg);--cream:var(--ui-bg);border-color:var(--ui-line)}
html[data-theme] .pp-panel :is(.pv-lede,.pv-bio){color:var(--ui-fg)}
html[data-theme] .pp-panel :is(.pv-note,.pv-empty,.pv-stats,.pv-strip-ch span,.pm-w){color:var(--ui-muted)}
html[data-theme] .pp-panel :is(.pv-lens,.pv-linkbox){background:var(--ui-panel);color:var(--ui-fg)}
html[data-theme] .pp-panel :is(.pv-chip[aria-pressed="true"],.pv-era[aria-pressed="true"],.pv-az-l button[aria-pressed="true"]){background:var(--ui-fg);color:var(--ui-bg)}
html[data-theme] .pp-panel :is(.pv-chip[aria-pressed="true"],.pv-era[aria-pressed="true"]) :is(small,b){color:inherit}
html[data-theme] .pp-panel .pv-window{background:#011015;color:#efe9d8;--cream:#efe9d8}
html[data-theme] .pp-panel .pv-seg-panel{background:var(--ui-panel);--cream:var(--ui-fg);--ink:var(--ui-bg)}
html[data-theme] .pp-panel :is(.pv-strip-axis,.pv-wbars .b,.pp-handle span){background:var(--ui-line)}

/* Ideas: scope paper/ink tokens to the sidebar so filled controls invert both colors. */
html[data-theme] .iv-panel{--ink:var(--ui-fg);--paper:var(--ui-bg);--cream:var(--ui-bg);--or:var(--ui-accent)}
html[data-theme] .iv-panel :is(.pn-body,.pn-now){color:var(--ui-fg)!important}
html[data-theme] .iv-panel :is(.pn-btn,.pn-chip.on){background:var(--ui-fg)!important;color:var(--ui-bg)!important}
html[data-theme] .iv-panel :is(.pn-btn.alt,.pn-chip:not(.on)){color:var(--ui-fg)!important}
html[data-theme] .iv-panel .pn-btn.alt{background:transparent!important}
html[data-theme] .iv-panel .pn-chip small{opacity:1}
html[data-theme] .iv-panel .pn-chip.on small{color:var(--ui-bg)!important}
html[data-theme] .iv-panel :is(.pn-btn.alt:hover,.pn-chip:hover,.pn-step>a:hover){background:var(--ui-panel)!important;color:var(--ui-fg)!important}
html[data-theme] .iv-panel .pn-chip.on:hover{background:var(--ui-fg)!important;color:var(--ui-bg)!important}
html[data-theme] .iv-panel :is(.pn-list .y,.pn-list .t small,.pn-grp,.pn-sgl,.pn-step .k,.pn-bars span,.pn-bars em,.pn-bars-cap,.pn-atlas .c,.pn-key li,.pn-eras span,.pn-small,.pn-fig figcaption span,.pn-fig figcaption small){color:var(--ui-muted)}
html[data-theme] .iv-panel .pn-small b{color:var(--ui-fg)!important}
html[data-theme] .iv-panel .pn-step>span{color:var(--ui-muted)}
html[data-theme] .iv-side :is(.iv-grab-t,.iv-sheet-x){color:var(--ui-fg)!important}
html[data-theme] .iv-side .iv-grab-bar{background:var(--ui-line)}

/* Tour notes: prose, hover fills and the next-up box must share the notes palette. */
html[data-theme] .tv-notes{--orange:var(--ui-accent)}
html[data-theme] .tv-notes .tn-read p{color:var(--ui-fg)}
html[data-theme] .tv-notes :is(.tn .lab,.tn-fig figcaption,.tn-src li>span,.tn-sg h4 span,.tn-hint,.tn-row small,.tn-none,.tn-ed small,.tn-run-head p,.tn-foot p,.tn-empty){color:var(--ui-muted)}
html[data-theme] .tv-notes :is(.tn-y,.tn-row b span,.tn-ed-n,.tn-grp h4 span,.tn-grp button span){color:var(--ui-accent)}
html[data-theme] .tv-notes .tn-chip:hover{background:var(--ui-panel);color:var(--ui-fg)}
html[data-theme] .tv-notes .tn-watch{background:var(--ui-panel);color:var(--ui-fg);--cream:var(--ui-fg)}
html[data-theme] .tv-notes .tn-watch .lab{color:var(--ui-muted)}
html[data-theme] .tv-notes :is(.tn-btn.is-solid:hover,.tn-btn.is-done){background:var(--ui-accent);color:var(--ui-bg)}
html[data-theme] .tv-notes .tn-grp button.is-now span{color:inherit}

/* Machines: pale subcards and register fills previously outlived the dark text switch. */
html[data-theme] .mc :is(.mc-reg,.mc-rg-plate,.mc-nb,.mc-mx,.mc-im-map,.mc-im-k,.mc-miss){background:var(--ui-panel);color:var(--ui-fg)}
html[data-theme] .mc :is(.mc-rg-dek,.mc-homecard-x,.mc-ring-mark){color:var(--ui-muted)}
html[data-theme] .mc :is(.mc-homecard-go,.mc-rg-k span:first-child,.mc-mx-ch b,.mc-bc-ch span.has b,.mc-fl.is-at,.mc-fl.is-w,.mc-pdl li.is-own .lab){color:var(--ui-accent)}
html[data-theme] .mc .mc-btn.is-ghost{color:var(--ui-fg)!important}
html[data-theme] .mc kbd{background:var(--ui-panel);color:var(--ui-fg)}
html[data-theme] .mc .mc-im-go{background:var(--ui-panel);color:var(--ui-accent)}
html[data-theme] .mc .mc-im-list li:first-child .mc-im-k{background:var(--ui-fg);color:var(--ui-bg)}
html[data-theme] .mc .mc-mx-r.is-cur .mc-mx-ch b{color:inherit}
html[data-theme] .mc :is(.mc-plate,.mc-rg-plate,.mc-nb){--dw-ink:var(--ui-fg);--dw-bg:var(--ui-panel);--dw-acc:var(--ui-accent)}
html[data-theme] .mc .mc-rg-k{opacity:1;color:var(--ui-muted)}
html[data-theme] .mc :is(.mc-rg-note,.mc-sec-note,.mc-wait-l,.mc-homecard-t .lab,.mc-tagk,.mc-edl .lab,.mc-foot .lab,.mc-foot-n){opacity:1;color:var(--ui-muted)}

/* Chronology controls sit on a themed deck; canvas labels remain untouched. */
html[data-theme] .cz-deck{--cz-hair:var(--ui-line)}
html[data-theme] .cz-deck :is(.cz-count b,.cz-zb,.cz-range,.cz-filters-btn){color:var(--ui-fg)}
html[data-theme] .cz-deck :is(.cz-hint,.cz-hint kbd,.cz-lg,.cz-sg-l){color:var(--ui-muted)}
html[data-theme] .cz-controls{background:var(--ui-bg);color:var(--ui-fg)}
html[data-theme] .cz-deck :is(.cz-mv,.cz-mv.is-on,.cz-zb:hover,.cz-filters-btn[aria-expanded="true"]){background:var(--ui-panel);color:var(--ui-fg);border-color:var(--ui-line)}
html[data-theme] .cz-deck :is(.cz-num,.cz-ch-years,.cz-in-window){color:var(--ui-accent)}
html[data-theme] #lt :is(.lt-titles span,.lt-empty span,.lt-loading){color:var(--ui-muted)}
html[data-theme] #lt :is(.lt-chapter-number,.lt-chapters button b){color:var(--ui-accent);opacity:1}

/* Dark artwork/tooltips retain a complete dark palette in the light interface too. */
html[data-theme] .lm-tip{color:#efe9d8}
html[data-theme] .hm-deal-tag.is-print{background:#011015}
html[data-theme] .hm-deal-tag.is-print :is(.hm-deal-cr,.hm-deal-cr a){color:#efe9d8}
html[data-theme] :is(#hm-count,#hm-lr,#hm-chance) :is(.hm-deal-x,.hm-led dt small,.hm-mchip b,.hm-more-n){color:var(--ui-muted)}
html[data-theme] :is(#hm-count,#hm-lr,#hm-chance) .hm-led-f .lab{color:var(--ui-muted)!important}
html[data-theme] #hm-chance .hm-recent .lab,html[data-theme] #hm-lr .hm-ed-t>.lab{color:var(--ui-muted)}
html[data-theme] #hm-chance .hm-deal-y{color:var(--ui-accent)}
html[data-theme] #hm-chance .hm-deal.is-empty :is(.hm-deal-y,.hm-deal-t){color:var(--ui-muted)}
