/* Shared appearance controls. Light keeps the archive's original palette. */
:root{--ui-bg:#f5f3ed;--ui-panel:#fff;--ui-soft:#f6f8f3;--ui-text:#25362d;--ui-muted:#65776b;--ui-line:#dbe4d8;--ui-accent:#315c43;--ui-hover:#edf4e8;--ui-input:#fff;--ui-living:#f0f7f1;--ui-deceased:#f2f3f4;--ui-dot:#d9e3d8;--ui-shadow:0 16px 50px #203e2d0c;--ui-blur:none;color-scheme:light}
:root[data-theme=dark]{--ui-bg:#0b0c0e;--ui-panel:#202226;--ui-soft:#14161a;--ui-text:#f4f5f7;--ui-muted:#bac0c9;--ui-line:#494e57;--ui-accent:#dce8df;--ui-hover:#30343b;--ui-input:#16181c;--ui-living:#eef6ef;--ui-deceased:#eceef1;--ui-dot:#383c44;--ui-shadow:0 16px 50px #0006;color-scheme:dark}
:root[data-theme=transparent]{--ui-bg:#e8eeea;--ui-panel:rgba(255,255,255,.65);--ui-soft:rgba(247,251,247,.42);--ui-text:#223a30;--ui-muted:#4d695c;--ui-line:rgba(90,125,108,.3);--ui-accent:#244f39;--ui-hover:rgba(225,242,228,.8);--ui-input:rgba(255,255,255,.86);--ui-living:rgba(226,246,231,.72);--ui-deceased:rgba(231,234,237,.75);--ui-dot:rgba(113,147,124,.25);--ui-shadow:0 14px 48px #354d4210;--ui-blur:blur(16px);color-scheme:light}
.theme-control{position:relative;display:flex;align-items:center;gap:8px;flex:0 0 auto;margin:0;font:12px/1.4 system-ui,sans-serif;color:var(--ui-muted)}
.theme-control label{font:inherit!important;color:inherit!important;display:inline}
.theme-control select{width:140px;min-height:38px;padding:7px 25px 7px 10px;border:1px solid var(--ui-line);border-radius:10px;background:var(--ui-input);color:var(--ui-text);font:13px system-ui,sans-serif;cursor:pointer}
.theme-control select:focus-visible{outline:3px solid #82a78e;outline-offset:2px}
.theme-status{position:absolute;right:0;top:calc(100% + 2px);font-size:10px;white-space:nowrap;pointer-events:none}
.theme-floating{position:absolute;right:20px;top:16px;z-index:10}.theme-floating .theme-control{padding:7px 10px;border:1px solid var(--ui-line);border-radius:13px;background:var(--ui-panel)}
body>header{height:auto!important;min-height:72px;gap:16px;flex-wrap:wrap;padding-block:14px}
body>header nav{flex-wrap:wrap;gap:16px!important;margin-left:auto}
body>header>div{flex-shrink:0}
.family-tabs{display:flex;gap:6px;padding:14px 18px;border-bottom:1px solid var(--ui-line);overflow-x:auto;scrollbar-width:thin;background:var(--ui-panel)}
.family-tabs button{display:flex;align-items:center;justify-content:center;gap:8px;flex-shrink:0;min-height:44px;padding:10px 16px;border:1px solid transparent;border-radius:11px;background:transparent;color:var(--ui-muted);font:600 13px system-ui,sans-serif;cursor:pointer}
.family-tabs button span{font-size:10px;min-width:22px;padding:3px 6px;border-radius:7px;background:var(--ui-soft);color:var(--ui-muted)}
.family-tabs button:hover{background:var(--ui-hover);color:var(--ui-text)}
.family-tabs button[aria-selected=true]{background:var(--ui-accent);color:var(--ui-bg)}
.family-tabs button[aria-selected=true] span{background:rgba(255,255,255,.15);color:inherit}
.family-tabs button:focus-visible{outline:3px solid #82a78e;outline-offset:-3px}
.family-directory[hidden]{display:none}.family-directory .family-member-grid{grid-template-columns:repeat(auto-fill,minmax(240px,1fr));align-items:stretch;justify-content:stretch}
.family-directory .family-member{max-width:none;display:flex;flex-direction:column}
.family-directory .family-member-main{flex:1}.family-directory .family-member-detail{margin-top:auto}
.family-directory .family-member-role{letter-spacing:.06em;font-size:10px}

/* Non-default themes override surfaces, typography and form controls together. */
:root:is([data-theme=dark],[data-theme=transparent]){background:var(--ui-bg);color:var(--ui-text)}
:root:is([data-theme=dark],[data-theme=transparent]) body{min-height:100vh;background:var(--ui-bg);color:var(--ui-text)}
:root[data-theme=transparent] body{background:radial-gradient(ellipse at 12% 8%,#d5e9df 0,transparent 55%),radial-gradient(ellipse at 90% 40%,#e4d9c9 0,transparent 60%),linear-gradient(135deg,#edf1ef,#dfe9ee);background-attachment:fixed}
:root:is([data-theme=dark],[data-theme=transparent]) :is(body>header,.tree-shell,.tree-toolbar,.tree-stat,.family-tabs,.tree-results,.person-dialog,.profile,.card,.photo-info,.photo-card,.archive-card,.archive-toolbar,.faces-stats article,.face-group,.face-card,.face-sample,.research-panel,.research-stats,.empty-gallery,.pagination a,.face-quick-dialog){background:var(--ui-panel);border-color:var(--ui-line);color:var(--ui-text);box-shadow:var(--ui-shadow);backdrop-filter:var(--ui-blur)}
:root:is([data-theme=dark],[data-theme=transparent]) :is(.family-view,.tree-legend,.gallery-body,.archive-body,.faces-body,.research-body,.upload-panel,.photo-editor-bar,.face-metrics>div,.face-group-metrics>span,.face-group-collapsible.is-expanded .face-group-strip,.research-hook,.research-reference,.research-finding blockquote,.research-sources label,.face-login-state,.face-group-login span,.file-box){background:var(--ui-soft);border-color:var(--ui-line);color:var(--ui-text)}
:root:is([data-theme=dark],[data-theme=transparent]) :is(h1,h2,h3,.tree-person-name,.family-member-main,.family-view-heading h2,.face-group-metrics b,.faces-stats strong,.tree-stat span,.research-stats b,.brand){color:var(--ui-text)}
:root:is([data-theme=dark],[data-theme=transparent]) :is(p,small,.eyebrow,.tree-brand span,.tree-subtitle,.tree-header nav a,.tree-person-id,.tree-person-dates,.family-member-role,.family-member-dates,.family-generation h3,.family-view-heading p,.gallery-intro p,.gallery-count span,.face-group-title p,.face-group-title .eyebrow,.face-group-metrics small,.face-sample-source,.face-sample-metrics,.face-login-badge,.face-login-badge b,.faces-help,.faces-legend,.research-page label,.research-hero p,.research-help,.research-hook p,.research-hook small,.research-finding p,.research-empty,.research-form-footer p,.research-history-item span,.research-history-item p,.lead,.note,.privacy,.hint,.dates,.muted,.editor-status,.gallery-preloader){color:var(--ui-muted)}
:root:is([data-theme=dark],[data-theme=transparent]) :is(a,.nav-current,.family-member-detail,.modal-relation,.research-hook a,.research-finding-actions a,.research-export,.research-panel summary,.research-panel-heading a,.admin){color:var(--ui-accent)}
:root:is([data-theme=dark],[data-theme=transparent]) :is(input:not([type=checkbox]):not([type=radio]),select,textarea){background:var(--ui-input);color:var(--ui-text);border-color:var(--ui-line);accent-color:var(--ui-accent)}
:root:is([data-theme=dark],[data-theme=transparent]) :is(.tree-light-button,.tree-result,.family-member-detail,.face-group-toggle,.face-role-actions button,.face-group-login button,.editor-secondary,.modal-close,.modal-relation,.photo-editor-bar .editor-secondary,.research-hook button){background:var(--ui-panel);color:var(--ui-accent);border-color:var(--ui-line)}
:root:is([data-theme=dark],[data-theme=transparent]) :is(.tree-light-button,.tree-result,.family-member-main,.family-member-detail,.face-group-toggle,.modal-relation):hover{background:var(--ui-hover);color:var(--ui-text)}
:root:is([data-theme=dark],[data-theme=transparent]) :is(.family-member,.tree-person){background:var(--ui-panel);border-color:var(--ui-line);color:var(--ui-text);backdrop-filter:var(--ui-blur)}
:root:is([data-theme=dark],[data-theme=transparent]) :is(.family-member,.tree-person).life-living{background:var(--ui-living);border-color:#65aa7b}
:root:is([data-theme=dark],[data-theme=transparent]) :is(.family-member,.tree-person).life-deceased{background:var(--ui-deceased);border-color:#8f989e}
:root:is([data-theme=dark],[data-theme=transparent]) :is(.family-member,.tree-person).is-central{box-shadow:inset 0 0 0 1px var(--ui-accent)}
:root:is([data-theme=dark],[data-theme=transparent]) :is(.family-member-avatar,.tree-avatar,.modal-portrait,.modal-portrait-inner,.face-group-summary-thumb,.face-card-image,.face-sample-image,.gallery-image-link,.upload-drop-icon,.file-icon){background:var(--ui-soft);color:var(--ui-muted)}
:root:is([data-theme=dark],[data-theme=transparent]) .tree-viewport{background-color:var(--ui-soft);background-image:radial-gradient(var(--ui-dot) 1px,transparent 1px)}
:root:is([data-theme=dark],[data-theme=transparent]) :is(.tree-controls button,.tree-hint,.tree-year-label,.tree-family-label){background:var(--ui-panel);border-color:var(--ui-line);color:var(--ui-muted)}
:root[data-theme=dark] .tree-family-group{background:rgba(74,104,84,.12);border-color:#647e6c66}
:root[data-theme=dark] :is(.tree-line.parent,.tree-focus-edge.parent){stroke:#8cb89a}
:root[data-theme=dark] .tree-edge-year{fill:var(--ui-muted);stroke:var(--ui-bg)}
:root:is([data-theme=dark],[data-theme=transparent]) :is(.family-generation,.family-member-detail,.tagged-person,.face-diff-form,.research-finding,.research-history-item,.modal-section){border-color:var(--ui-line)}
:root[data-theme=dark] :is(.modal-review,.research-badge,.face-card-badges span,.tag){background:#423d2c;color:#e9dba7}
:root[data-theme=dark] :is(.notice,.research-message,.faces-live-notice,.face-welcome){background:#263f30;color:#c1e1c9;border-color:#55765d}
:root[data-theme=dark] :is(.error,.research-message.is-error,.faces-live-notice.is-error){background:#422b29;color:#f0bbb2;border-color:#80544e}
:root[data-theme=dark] .face-sample-metrics b{color:var(--ui-accent)}
:root:is([data-theme=dark],[data-theme=transparent]) #toggleFamilyView[aria-pressed=true]{background:var(--ui-accent);color:var(--ui-bg);border-color:var(--ui-accent)}
@supports not (backdrop-filter:blur(1px)){:root[data-theme=transparent]{--ui-panel:rgba(255,255,255,.94);--ui-soft:rgba(246,250,246,.9)}}
@media(max-width:760px){body>header{padding:14px 16px!important;gap:12px}body>header nav{order:3;width:100%;margin:0;gap:10px 16px!important}.theme-control{margin-left:auto}.theme-status{font-size:9px}.family-tabs{padding:12px;gap:4px}.family-tabs button{padding-inline:12px}.theme-floating{position:static;justify-self:end;margin-bottom:18px}.theme-floating .theme-control{margin:0}}
@media(max-width:530px){.family-directory .family-member-grid{grid-template-columns:1fr}}

/* Original-photo viewer stays dark in every theme. */
:root:is([data-theme=dark],[data-theme=transparent]) .image-lightbox-info :is(h3,a){color:#fff}
:root:is([data-theme=dark],[data-theme=transparent]) .image-lightbox-info p{color:#cad4ce}
:root:is([data-theme=dark],[data-theme=transparent]) :is(.original-open,.archive-edit-button,.modal-profile-link,.upload-pick){color:#fff}

:root:is([data-theme=dark],[data-theme=transparent]) :is(.gallery-count strong,.archive-result-note,.archive-sort,.archive-card-body>p,.archive-card-actions a,.face-sample-metrics,.upload-queue-item small){color:var(--ui-muted)}
:root:is([data-theme=dark],[data-theme=transparent]) :is(.archive-card-people span,.archive-card-image,.photo-stage,.upload-queue-item,.tree-controls){background:var(--ui-soft);border-color:var(--ui-line);color:var(--ui-text)}
:root:is([data-theme=dark],[data-theme=transparent]) .modal-source{color:var(--ui-muted)!important}

/* Neutral charcoal surroundings with independent, high-contrast light cards. */
:root[data-theme=dark] body{background:radial-gradient(ellipse at 8% 0%,#30333a 0,transparent 55%),radial-gradient(ellipse at 95% 70%,#23262c 0,transparent 60%),linear-gradient(150deg,#121316,#08090b 80%);background-attachment:fixed}
:root[data-theme=dark] :is(body>header,.tree-toolbar,.family-tabs){background:linear-gradient(135deg,#26292f,#191b1f)}
:root[data-theme=dark] :is(.family-view,.branch-viewport){background:linear-gradient(145deg,#1b1d22,#0e1013 85%)}
:root[data-theme=dark] .tree-viewport{background-color:#111317;background-image:radial-gradient(#383c44 1px,transparent 1px)}
:root[data-theme=dark] :is(.family-member,.tree-person,.branch-external,.person-dialog,.profile,.card,.photo-info,.photo-card,.archive-card,.face-card,.face-sample,.face-quick-dialog){
 --ui-bg:#fafafa;--ui-panel:#fafafa;--ui-soft:#eceef1;--ui-text:#182026;--ui-muted:#46515b;--ui-line:#c6cbd1;--ui-accent:#264c38;--ui-hover:#e7ece9;--ui-input:#fff;--ui-living:#eef6ef;--ui-deceased:#eceef1;--ui-shadow:0 8px 24px #0003;
 background:var(--ui-panel);color:var(--ui-text);border-color:var(--ui-line);color-scheme:light;
}
:root[data-theme=dark] .branch-external{border-color:#859b8b}
:root[data-theme=dark] .tree-family-group{background:#ffffff06;border-color:#a3acb544}
:root[data-theme=dark] :is(.branch-line,.tree-line.parent,.tree-focus-edge.parent){stroke:#b9c7bf;opacity:.9}
:root[data-theme=dark] .branch-generation-label{color:#c5cad2}

