/* Save-level appearance. Loaded last so a chosen palette reaches old and new pages. */
body{font-size:var(--theme-body-size);background:radial-gradient(circle at 72% -12%,rgba(var(--accent-rgb),.075),transparent 32%),var(--paper);color:var(--ink)}
h1,h2,h3,.brand span,.dossier-identity h1,.profile-card h3,details.panel>summary{font-family:var(--theme-heading-font)}
body>.app-sidebar{border-color:var(--line);background:linear-gradient(180deg,var(--panel-soft),var(--paper));box-shadow:12px 0 35px rgba(var(--paper-rgb),.28)}
.app-sidebar:before{background:linear-gradient(transparent,var(--gold) 15%,var(--line) 70%,transparent)}
.app-sidebar .brand,.sidebar-footer{border-color:var(--line)}
.app-sidebar .brand span,.sidebar-footer>span,.panel h1,.panel h2,.panel h3,.list-row h3{color:var(--ink)}
.app-sidebar .brand small,.eyebrow,.chronicle time,.profile-chronicle time{color:var(--gold)}
.save-switcher select,.nav-search input,input,select,textarea{border-color:var(--line);background:var(--panel-raised);color:var(--ink)}
input:hover,select:hover,textarea:hover{border-color:var(--gold-dim);background:var(--panel-raised)}
input:focus,select:focus,textarea:focus{border-color:var(--gold);box-shadow:0 0 0 3px rgba(var(--accent-rgb),.16)}
.nav-quick,.nav-group[open],.rule-center-nav,.statistics-nav,.profile-jump{border-color:var(--line);background:rgba(var(--panel-rgb),.94)}
.app-nav a,.nav-group>summary,.rule-center-nav a{color:var(--ink)}
.app-nav a:hover,.app-nav a:focus-visible,.nav-group>summary:hover,.nav-group>summary:focus-visible,.rule-center-nav a:hover{border-color:var(--line);background:rgba(var(--accent-rgb),.075);color:var(--ink)}
.app-nav a.active,.rule-center-nav a.active{border-color:var(--gold-dim);background:linear-gradient(90deg,rgba(var(--accent-rgb),.20),rgba(var(--accent-rgb),.06));color:var(--gold-bright);box-shadow:inset 3px 0 var(--gold)}
.nav-group-icon,.dashboard-map-card>span{border-color:var(--gold-dim);background:rgba(var(--accent-rgb),.07);color:var(--gold)}
.hero,.sim-dossier-hero{border-color:var(--gold-dim);background:radial-gradient(circle at 88% 10%,rgba(var(--accent-rgb),.15),transparent 27%),linear-gradient(135deg,var(--panel-raised),var(--panel) 72%)}
.hero:before{border-color:rgba(var(--accent-rgb),.18)}.hero:after{color:rgba(var(--accent-rgb),.09)}
.hero h1,.hero.compact h1,.dossier-identity h1{color:var(--ink)}.hero>p:not(.eyebrow),.section-heading p,.panel>p{color:var(--muted)}
.panel,.card,.list-row,.empty,.notice,.profile-card,.dashboard-map-card,details.compact-record,.historical-life-section{border-color:var(--line);background:linear-gradient(145deg,var(--panel-raised),var(--panel))}
.metrics article,.metric-strip article,.year-grid div,.fact-grid>div,.kin-card,.detected-columns>div,.detected-summary>div,.theme-preview-frame article{border-color:var(--line);background:var(--panel-soft)}
details.panel[open]>summary,details.compact-record[open]>summary,.record-editor[open]>summary{border-color:var(--line);background:rgba(var(--accent-rgb),.055)}
button,.button{border-color:var(--line);background:linear-gradient(180deg,var(--panel-raised),var(--panel));color:var(--ink)}
button:hover,.button:hover{border-color:var(--gold);background:rgba(var(--accent-rgb),.13);color:var(--gold-bright)}
.primary,.pager a.active{border-color:var(--gold);background:linear-gradient(135deg,var(--gold-bright),var(--gold));color:var(--paper);box-shadow:0 7px 18px rgba(var(--accent-rgb),.18)}
.primary:hover{border-color:var(--gold-bright);background:linear-gradient(135deg,var(--gold-bright),var(--gold));color:var(--paper)}
table{border-color:var(--line);background:var(--panel)}th{border-color:var(--line);background:var(--panel-raised);color:var(--gold-bright)}td{border-color:var(--line-soft);color:var(--ink)}tbody tr:hover td{background:rgba(var(--accent-rgb),.045)}
.portrait,.kin-portrait,.tree-portrait{border-color:var(--gold-dim);background:var(--panel-soft)}
.status,.tag-cloud span,.choice,.census-line span{border-color:var(--line)}
.historical-life-nav,.family-tree-shell,.event-filter-panel{border-color:var(--line);background:var(--panel-soft)}

body[data-theme-mode="light"]{color-scheme:light}
body[data-theme-mode="light"] html,body[data-theme-mode="light"]{scrollbar-color:var(--gold-dim) var(--panel-soft)}
body[data-theme-mode="light"]:before{opacity:.06}
body[data-theme-mode="light"] .panel :where(h1,h2,h3,h4,strong),body[data-theme-mode="light"] .card :where(h1,h2,h3,h4,strong),body[data-theme-mode="light"] .list-row :where(h1,h2,h3,h4,strong),body[data-theme-mode="light"] details.panel>summary{color:var(--ink)}
body[data-theme-mode="light"] .panel>h2:first-child,body[data-theme-mode="light"] .panel>.section-heading:first-child h2{color:var(--ink)}
body[data-theme-mode="light"] .metrics strong,body[data-theme-mode="light"] .metric-strip strong,body[data-theme-mode="light"] .eyebrow{color:var(--gold)}
body[data-theme-mode="light"] .notice{background:linear-gradient(100deg,rgba(70,112,145,.14),var(--panel));color:var(--ink)}
body[data-theme-mode="light"] .automation-master-control,body[data-theme-mode="light"] .automation-master-control.is-on,body[data-theme-mode="light"] .occult-quick-control,body[data-theme-mode="light"] .occult-quick-control.is-on{border-color:var(--gold-dim);background:var(--panel);color:var(--ink)}
body[data-theme-mode="light"] .automation-master-control strong,body[data-theme-mode="light"] .occult-quick-control strong{color:var(--ink)}
body[data-theme-mode="light"] .automation-master-control>a,body[data-theme-mode="light"] .occult-quick-control>a{color:var(--gold)}
body[data-theme-mode="light"] .error{background:#f4dfe0;color:#5c2026}
body[data-theme-mode="light"] .status.alive{background:#dcecdf;color:#24563a}
body[data-theme-mode="light"] .status.dead{background:#eedcdd;color:#6b2e34}
body[data-theme-mode="light"] .danger{background:#f0dddd;color:#6a292e}
body[data-theme-mode="light"] code,body[data-theme-mode="light"] pre{background:var(--panel-soft);color:var(--ink)}
body[data-theme-mode="light"] .deceased-portrait img{opacity:.72}
/* Theme coverage bridge: older feature pages used named surfaces with fixed colours.
   This tokenizes them for every palette, not only for the light presets. */
body[data-theme-mode] :is(.today-hero-date,.today-command,.attention-shell,.workload-card,.today-filters,.inline-tool,.compact-drawer,.tool-drawer,.manual-roll-form,.action-editor form,.roll-result-item,.occult-summary-row,.rule-workbench,.rule-action-item,.family-tree-shell,.tree-person,.tree-relative,.tree-generation-heading,.statistics-nav,.event-filter-panel,.event-quick-filters,.record-editor,.profile-jump,.rule-center-nav,.dashboard-map-card,.year-grid div,.progress-meter,.portrait-gallery article,.scan-row,.storyline-current-year,.storyline-vitals article,.storyline-jump,.storyline-opening,.storyline-year-index,.year-chapter-marker,.chapter-sources li,.story-hook,.arc-ledger,.story-drawer,.personal-thread-grid>article,.writing-desk-grid .desk-card,.story-check,.authored-grid>article,.profile-editor,.save-dock,.tracker-alert,.conflict-table>div,.conflict-choice,.newspaper>div,.family-plan-compact){background:var(--panel)!important;border-color:var(--line)!important;color:var(--ink)}
body[data-theme-mode] :is(.today-command,.attention-shell,.rule-workbench,.event-filter-panel,.dashboard-map-card,.family-tree-shell,.storyline-opening,.story-drawer,.profile-editor,.save-dock,.newspaper>div){background:linear-gradient(145deg,var(--panel-raised),var(--panel))!important}
body[data-theme-mode] :is(.tree-person,.tree-relative,.tree-generation-heading,.today-hero-date,.workload-card,.scan-row,.roll-result-item,.occult-summary-row,.storyline-vitals article,.year-chapter-marker,.story-check,.family-plan-compact){box-shadow:none}
body[data-theme-mode] :is(.today-command,.attention-shell,.workload-card,.today-filters,.inline-tool,.compact-drawer,.tool-drawer,.manual-roll-form,.action-editor form,.roll-result-item,.occult-summary-row,.rule-action-item,.tree-person,.tree-relative,.tree-generation-heading,.event-filter-panel,.event-quick-filters,.record-editor,.dashboard-map-card,.scan-row,.storyline-current-year,.storyline-vitals article,.storyline-jump,.storyline-opening,.storyline-year-index,.year-chapter-marker,.story-hook,.arc-ledger,.story-drawer,.personal-thread-grid>article,.writing-desk-grid .desk-card,.story-check,.authored-grid>article,.profile-editor,.save-dock,.tracker-alert,.conflict-table>div,.conflict-choice,.newspaper>div,.family-plan-compact) :is(strong,h1,h2,h3,h4,summary,legend){color:var(--ink)!important}
body[data-theme-mode] :is(.workload-card.active,.nav-quick a.active,.storyline-year-index a.active,.storyline-jump a.active){background:rgba(var(--accent-rgb),.14)!important;color:var(--ink)}
body[data-theme-mode] .app-sidebar.mobile-menu-open .app-nav{background:var(--panel-soft)!important;border-color:var(--line)}
/* The refresh, dossier, tutorial, and statistics styles were written before save-level
   palettes. Their prominent containers are bridged here as well, so switching a
   preset never leaves a page with the old gold-on-charcoal islands behind. */
body[data-theme-mode] :is(.metrics article,.metric-strip article,.profile-card,.list-row,.choice,.pager a,.year-grid div,.current-year-panel,.mini-stat-grid>div,.generation-stat,.secret-result,.tree-relative-group,.tree-relative,.tree-person,.tree-generation-heading,.sim-dossier-hero,.dossier-portrait,.identity-tags>span:not(.status),.vital-line>div,.profile-metrics article,.profile-section,.fact-grid>div,.profile-note,.household-banner,.kin-card,.tutorial-toc,.tutorial-paths article,.tutorial-feature-grid article,.tutorial-step,.tutorial-install-list li,.tutorial-step>span,.tutorial-private,.tutorial-tip,.tutorial-routine li,.guide-reader iframe,.lifespan-track,.decade-portrait-grid article,.occult-quick-control,.automation-master-control,.occult-today-control,.automation-global-notice,.nav-quick,.nav-group[open],.nav-search input,.dashboard-map-card,.between-session-grid a){border-color:var(--line)!important;background:var(--panel-soft)!important;color:var(--ink)}
body[data-theme-mode] :is(.metrics article,.metric-strip article,.profile-card,.current-year-panel,.sim-dossier-hero,.profile-metrics article,.profile-section,.tutorial-paths article,.tutorial-feature-grid article,.tutorial-step,.tutorial-install-list li,.decade-portrait-grid article){background:linear-gradient(145deg,var(--panel-raised),var(--panel))!important}
body[data-theme-mode] :is(.portrait,.tree-portrait,.dossier-portrait,.mini-portrait,.scan-portrait,.lifespan-track,.progress-meter,.bar-row div,.tutorial-step>span){background:var(--panel-soft)!important;border-color:var(--line)!important}
body[data-theme-mode] :is(.metrics article,.metric-strip article,.profile-card,.current-year-panel,.mini-stat-grid>div,.generation-stat,.tree-relative-group,.tree-relative,.tree-person,.tree-generation-heading,.sim-dossier-hero,.dossier-portrait,.identity-tags>span:not(.status),.vital-line>div,.profile-metrics article,.profile-section,.fact-grid>div,.profile-note,.household-banner,.kin-card,.tutorial-toc,.tutorial-paths article,.tutorial-feature-grid article,.tutorial-step,.tutorial-install-list li,.tutorial-private,.tutorial-tip,.tutorial-routine li,.decade-portrait-grid article,.occult-quick-control,.automation-master-control,.occult-today-control,.automation-global-notice,.nav-quick,.nav-group[open],.dashboard-map-card,.between-session-grid a) :is(h1,h2,h3,h4,strong,summary,legend){color:var(--ink)!important}
body[data-theme-mode] :is(.metrics strong,.metric-strip strong,.large-number,.mini-stat-grid strong,.generation-stat strong,.roll-stat b,.year-ledger-row>strong,.quality-total strong,.tree-relative-group h3,.tree-relation,.tree-profile-arrow,.storyline-section-heading>span,.tutorial-section-heading>span,.tutorial-step>span,.tutorial-install-list li>span,.occult-quick-control>a,.automation-master-control>a,.occult-today-control>a){color:var(--gold)!important}
body[data-theme-mode] :is(.profile-card:hover,.list-row:hover,.choice:hover,.rule-center-nav a:hover,.nav-group>summary:hover,.between-session-grid a:hover,.tutorial-toc a:hover){border-color:var(--gold-dim)!important;background:rgba(var(--accent-rgb),.10)!important;color:var(--ink)!important}
body[data-theme-mode] :is(.occult-quick-control.is-on,.automation-master-control.is-on,.occult-today-control.is-on){border-color:var(--gold-dim)!important;background:rgba(var(--accent-rgb),.14)!important}
body[data-theme-mode] :is(.story-hook.danger,.sim-dossier-hero.is-deceased,.death-row,.roll-result-item.failed){border-left-color:var(--red)!important}

/* A sorted Hogwarts Sim gets a self-contained House palette.  It only lives
   inside that Sim's profile, so the selected save-wide appearance stays intact
   everywhere else in the tracker. */
.hogwarts-profile{position:relative;--hp-house-glow:rgba(var(--accent-rgb),.18)}
.hogwarts-profile.hogwarts-house-gryffindor{--paper:#18050a;--panel:#2d0d17;--panel-raised:#3c1320;--panel-soft:#240a12;--surface-2:#421521;--line:#713040;--line-soft:rgba(255,239,231,.10);--ink:#fff4ed;--text:#fff4ed;--muted:#ddc4c7;--gold:#e7b94d;--gold-bright:#ffe19a;--gold-dim:#84313f;--accent-rgb:169,34,51;--panel-rgb:45,13,23;--paper-rgb:24,5,10;--hp-house-glow:rgba(169,34,51,.30)}
.hogwarts-profile.hogwarts-house-hufflepuff{--paper:#1b1604;--panel:#2e2708;--panel-raised:#3b3210;--panel-soft:#251f07;--surface-2:#443a11;--line:#76621d;--line-soft:rgba(255,247,206,.10);--ink:#fff8dc;--text:#fff8dc;--muted:#ddd2a8;--gold:#e4ba38;--gold-bright:#ffe895;--gold-dim:#816717;--accent-rgb:228,186,56;--panel-rgb:46,39,8;--paper-rgb:27,22,4;--hp-house-glow:rgba(228,186,56,.22)}
.hogwarts-profile.hogwarts-house-ravenclaw{--paper:#061629;--panel:#0b2748;--panel-raised:#10345e;--panel-soft:#09213e;--surface-2:#123d69;--line:#2d6494;--line-soft:rgba(228,242,255,.10);--ink:#edf7ff;--text:#edf7ff;--muted:#bbd0e0;--gold:#c9933d;--gold-bright:#f6cd83;--gold-dim:#245f95;--accent-rgb:31,102,161;--panel-rgb:11,39,72;--paper-rgb:6,22,41;--hp-house-glow:rgba(31,102,161,.31)}
.hogwarts-profile.hogwarts-house-slytherin{--paper:#04170f;--panel:#0a3021;--panel-raised:#0e402d;--panel-soft:#082719;--surface-2:#13533a;--line:#2d7c57;--line-soft:rgba(232,250,241,.10);--ink:#eefaf4;--text:#eefaf4;--muted:#bdd8ca;--gold:#b9c8c2;--gold-bright:#e0eee8;--gold-dim:#25714f;--accent-rgb:26,128,82;--panel-rgb:10,48,33;--paper-rgb:4,23,15;--hp-house-glow:rgba(26,128,82,.33)}
.hogwarts-profile .sim-dossier-hero{border-color:var(--gold-dim)!important;background:radial-gradient(circle at 12% 24%,var(--hp-house-glow),transparent 35%),linear-gradient(135deg,var(--panel-raised),var(--paper) 78%)!important;box-shadow:0 18px 42px rgba(var(--paper-rgb),.38)}
.hogwarts-profile .sim-dossier-hero:after{border-color:rgba(var(--accent-rgb),.28)}
.hogwarts-profile .sim-dossier-hero.is-deceased{background:radial-gradient(circle at 12% 24%,rgba(143,63,67,.28),transparent 35%),linear-gradient(135deg,var(--panel-raised),var(--paper) 78%)!important}
.hogwarts-profile .dossier-portrait{border-color:var(--gold-dim)!important;background:var(--panel-soft)!important;box-shadow:0 18px 42px rgba(var(--paper-rgb),.45)}
.hogwarts-profile .dossier-portrait>span{color:var(--gold)!important}.hogwarts-profile .name-history{color:var(--muted)!important}
.hogwarts-house-chip{border-color:var(--gold-dim)!important;background:rgba(var(--accent-rgb),.18)!important;color:var(--gold-bright)!important}
.hogwarts-profile .profile-back,.hogwarts-profile .profile-back:hover,.hogwarts-profile .section-heading>a,.hogwarts-profile .connected-list em{color:var(--gold)!important}

body[data-theme-density="compact"] .app-main{padding-top:25px}
body[data-theme-density="compact"] .hero{min-height:165px;margin-bottom:18px;padding:27px 31px}
body[data-theme-density="compact"] .panel{padding:15px;margin-bottom:10px}
body[data-theme-density="compact"] .list{gap:4px}
body[data-theme-density="compact"] .list-row{min-height:50px;padding:10px 13px}
body[data-theme-density="compact"] .metrics article,body[data-theme-density="compact"] .metric-strip article{padding:11px}
body[data-theme-density="compact"] .profile-card{min-height:92px;padding:10px}
body[data-theme-density="compact"] details.panel>summary{min-height:49px;padding:12px 15px}
body[data-theme-density="compact"] input,body[data-theme-density="compact"] select,body[data-theme-density="compact"] textarea{min-height:37px;padding:8px 10px}
body[data-theme-motion="reduce"] *,body[data-theme-motion="reduce"] *:before,body[data-theme-motion="reduce"] *:after{scroll-behavior:auto!important;animation-duration:.001ms!important;animation-iteration-count:1!important;transition-duration:.001ms!important}

.appearance-editor{display:grid;gap:16px}.appearance-editor>.panel{margin:0}.appearance-columns{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:16px}.appearance-columns>.panel{height:100%;margin:0}
.theme-preset-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(190px,1fr));gap:9px}.theme-preset-card{position:relative;display:grid;align-content:start;gap:6px;min-height:142px;margin:0;padding:14px;border:1px solid var(--line);border-radius:var(--radius);background:var(--panel-soft);cursor:pointer}.theme-preset-card:hover,.theme-preset-card:focus-within{border-color:var(--gold)}.theme-preset-card.selected{border-color:var(--gold);box-shadow:inset 0 0 0 1px var(--gold),0 8px 24px rgba(var(--accent-rgb),.1)}.theme-preset-card>input{position:absolute;right:11px;top:10px;width:1rem;height:1rem;min-height:0}.theme-preset-card strong{color:var(--ink)}.theme-preset-card small{line-height:1.35}.theme-swatches{display:flex;width:calc(100% - 25px);height:32px;overflow:hidden;border:1px solid rgba(127,127,127,.28);border-radius:8px}.theme-swatches i{flex:1;background:var(--swatch)}.theme-swatches.custom i:nth-child(1){background:#16151b}.theme-swatches.custom i:nth-child(2){background:#2d2732}.theme-swatches.custom i:nth-child(3){background:#bf8fd0}.theme-swatches.custom i:nth-child(4){background:#f4ecf6}
.theme-color-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}.theme-color-grid label{display:grid;grid-template-columns:minmax(0,1fr) 52px;gap:2px 10px;align-items:center;margin:0;padding:10px;border:1px solid var(--line);border-radius:10px;background:var(--panel-soft)}.theme-color-grid input[type="color"]{grid-column:2;grid-row:1/3;width:52px;height:45px;min-height:0;padding:3px;cursor:pointer}.theme-color-grid small{grid-column:1}.theme-reading-options label{margin:0}.theme-reading-options .checkbox-line{margin-top:4px}
.theme-preview-panel{overflow:hidden}.theme-preview-panel>.section-heading>span{padding:5px 9px;border:1px solid var(--line);border-radius:999px;color:var(--muted);font-size:.72rem}.theme-preview-frame{display:grid;grid-template-columns:185px minmax(0,1fr);min-height:310px;overflow:hidden;border:1px solid var(--line);border-radius:var(--radius);background:var(--paper);color:var(--ink);font-size:var(--theme-body-size)}.theme-preview-frame>aside{position:static;display:grid;width:auto;align-content:start;gap:7px;padding:20px 14px;border:0;border-right:1px solid var(--line);background:var(--panel-soft);color:var(--ink)}.theme-preview-frame>aside strong{font:700 1.25rem var(--theme-heading-font);color:var(--ink)}.theme-preview-frame>aside small{margin-bottom:12px;color:var(--gold);font-size:.55rem;letter-spacing:.12em}.theme-preview-frame>aside b,.theme-preview-frame>aside span{padding:8px;border-radius:8px}.theme-preview-frame>aside b{background:rgba(var(--accent-rgb),.16);color:var(--gold-bright)}.theme-preview-frame>div{padding:28px}.theme-preview-frame h2{font:700 2.2rem var(--theme-heading-font);color:var(--ink)}.theme-preview-frame p{color:var(--muted)}.theme-preview-frame article{display:grid;gap:3px;margin-top:22px;padding:16px;border:1px solid var(--line);border-radius:var(--radius)}.theme-preview-frame article small{color:var(--muted)}.theme-preview-frame button{justify-self:start;margin-top:10px;border-color:var(--gold);background:var(--gold);color:var(--paper)}
.appearance-save-bar{position:sticky;z-index:15;bottom:10px;display:flex;align-items:center;justify-content:space-between;gap:16px;padding:13px 15px;border:1px solid var(--gold-dim);border-radius:var(--radius);background:rgba(var(--panel-rgb),.96);box-shadow:0 15px 40px rgba(var(--paper-rgb),.42);backdrop-filter:blur(12px)}.appearance-save-bar>div{display:grid}.appearance-save-bar small{color:var(--muted)}.appearance-save-bar button{width:auto}.appearance-reset{display:flex;justify-content:flex-end;margin:10px 0 0}.appearance-reset button{color:var(--muted)}
@media(max-width:900px){.appearance-columns{grid-template-columns:1fr}.theme-preview-frame{grid-template-columns:145px minmax(0,1fr)}}
@media(max-width:600px){.theme-preset-grid,.theme-color-grid{grid-template-columns:1fr}.theme-preview-frame{grid-template-columns:1fr}.theme-preview-frame>aside{display:none}.theme-preview-frame>div{padding:22px}.appearance-save-bar{position:static;display:grid;margin-top:2px}.appearance-save-bar button{width:100%}}
