/* Anchor the toggle to the page header; the patient viewport owns scroll-following. */
.night-mode{position:absolute;right:max(18px,env(safe-area-inset-right));top:max(17px,env(safe-area-inset-top));z-index:40;display:flex;align-items:center;justify-content:center;gap:9px;min-height:44px;padding:9px 14px;border:1px solid #829b91;border-radius:24px;background:#f5f3e9;color:#284a40;font-size:12px;box-shadow:0 3px 15px #102a2320}
.night-mode [data-theme-icon]{font-family:Georgia,serif;font-size:22px;line-height:1}
.site-header,.in-ward .site-header{padding-right:175px}
.site-header nav{gap:22px}
.in-splash .night-mode{background:#19323e;color:#f2dfb3;border-color:#809d9b}
html[data-theme=night]{color-scheme:dark;--paper:#151e20;--white:#1e2b2d;--ink:#d9dfd4;--muted:#a7b6ac;--green:#acd0bb;--dark:#102a2a;--line:#41534f;--gold:#c9ae7b;--soft:#253532;--coral:#d69c8c}
html[data-theme=night] body{background:var(--paper);color:var(--ink)}
html[data-theme=night] body.in-splash{background:#101923;color:#e6dfce}
html[data-theme=night] .night-mode{background:#293631;color:#dfd3af;border-color:#657668;box-shadow:none}
html[data-theme=night] .splash-art{filter:brightness(.76) saturate(.88)}
html[data-theme=night] .splash-story h1{color:#e1c493}
html[data-theme=night] .splash-start{background:#d3be91;color:#17282b;border-color:#eee0b8;box-shadow:0 5px 0 #315652,0 0 0 5px #112329,0 10px 24px #0008}
html[data-theme=night] :is(.exam-toolbar,.mentor,.evidence-note,.nerve-workbench,.anatomy-explorer,.head-exam-controls,.anatomy-number-key,.patient-file,.journal-connections article,.resolution-card,.original-patient,.real-ct-unlock,.atlas-nav,.reflex-table,.feedback,.signal-explanation,.head-result,.head-structure-inspector,.settings-card,.private-course-card,#scene-fallback){background:#202e2f;border-color:#495c52;color:var(--ink)}
html[data-theme=night] :is(.patient-file.complete,.journal-connections .learned,.resolution-card.solved,.feedback:not(.incorrect)){background:#243830}
html[data-theme=night] :is(.resolution-card.reconsider,.head-result.unrecorded,.feedback.incorrect){background:#39352a}
html[data-theme=night] :is(.patient-stage,.patient-stage.has-anatomy-labels){background:#243837;border-color:#4c6860}
/* Dim emitted light without inverting anatomical colors or filtering published CT images. */
html[data-theme=night] .patient-canvas{filter:brightness(.58)}
html[data-theme=night] :is(.patient-ident h1,.patient-ident .eyebrow,.patient-stage .patient-ident p.patient-exam-status,.persistent-anatomy){color:#e0e6d7}
html[data-theme=night] .patient-stage .patient-ident p.patient-exam-status[data-observed=false]{color:#b6c9b9}
html[data-theme=night] .anatomy-region-name{background:#243b39f5;border-color:#789283}
html[data-theme=night] .anatomy-region-name.is-proposal{background:#56482e;border-color:#bc9b60}
html[data-theme=night] .anatomy-leader{stroke:#a6c4b5;opacity:.5}
html[data-theme=night] .anatomy-leader.region{opacity:.8}
html[data-theme=night] .anatomy-anchor{fill:#a6c4b5}
html[data-theme=night] .anatomy-leader.structure,html[data-theme=night] .anatomy-anchor.structure{opacity:0}
html[data-theme=night] .anatomy-leader.selected{stroke:#dab878;opacity:1}
html[data-theme=night] .anatomy-anchor.selected{fill:#dab878;opacity:1}
html[data-theme=night] :is(.anatomy-focus-label,.head-part-label){background:#424a3a;color:#ede3c6;border-color:#889779}
html[data-theme=night] body:not(.in-splash) :is(button,select,input){background-color:#293c39;color:#d0dfd0;border-color:#617769}
html[data-theme=night] body:not(.in-splash) :is(.text-button,.ward-help,.map-download){background:transparent;color:#b7cdb4}
html[data-theme=night] body:not(.in-splash) :is(button[aria-pressed=true],button.active,.primary,.compare-case,.guide-action,.atlas-nav button.selected){background:#3b6654;color:#f1eed8;border-color:#90b096}
html[data-theme=night] body:not(.in-splash) button:hover:not(:disabled){background-color:#3b5449}
html[data-theme=night] body:not(.in-splash) button:disabled{background-color:#34413b;color:#b0bbab}
html[data-theme=night] :is(.mentor,.evidence-note,.head-result,.head-exam-controls,.nerve-workbench,.patient-file,.journal-connections,.resolution-card,.field-observation,.original-patient,.real-ct-unlock) :is(h2,h3,b,strong,.observed-finding,.head-finding){color:#d9e0cb}
html[data-theme=night] :is(.mentor,.evidence-note,.head-result,.head-exam-controls,.nerve-workbench,.patient-file,.journal-connections,.resolution-card,.field-observation) :is(p,small,label,.eyebrow){color:#b0bfad}
html[data-theme=night] :is(.ward-back,.ward-chapter,.ward-case-number,.patient-interaction span,.interaction-hint,.notebook-heading,.empty-notes,.ward-course-link,.file-species,.file-open,.file-top,.reference-footer,.compare-requirement,.model-limit,.case-history,.anatomy-legend,.anatomy-scale-note,.anatomy-detail a,.anatomy-key-heading span,.vertebra-limit,.head-instruction,.head-scale-note,.head-replay-row a,.head-context-label,.signal-settings,.page-heading .eyebrow,.source-links button,.atlas-nav small,.atlas-nav span){color:#afc2ae}
html[data-theme=night] :is(.anatomy-detail>b,.head-exam-heading h2,.signal-explanation>b){color:#dbdfc5}
html[data-theme=night] .head-record-badge{background:#2b4336;color:#c8d9bb!important;border-color:#6e8c64}
html[data-theme=night] .head-record-badge.reference{background:#423c2e;color:#e0c799!important;border-color:#a38e5c}
html[data-theme=night] .observation-icon{background:#33483c;color:#c2d3b1}
html[data-theme=night] .discovery-track i{background:#405046}
html[data-theme=night] .discovery-track i.found{background:#9ab987}
html[data-theme=night] :is(.pill,.finding:nth-child(5),.answer.correct:disabled,.feedback-symbol){background:#354735;color:#d4dfbe;border-color:#788e68}
html[data-theme=night] :is(.answer.wrong:disabled,.feedback.incorrect .feedback-symbol){background:#503e35;color:#edcebd;border-color:#9e7764}
html[data-theme=night] .trap b{color:#d4b47a}
html[data-theme=night] .pause-overlay{background:#151e20ee}
html[data-theme=night] :is(.head-view-row,.head-result,.anatomy-detail,.finding,.notebook-heading,.source-links){border-color:#4a5c50}
@media(max-width:1150px) and (min-width:651px){.site-header,.in-ward .site-header{height:auto;min-height:108px;flex-wrap:wrap;padding:20px 165px 0 24px;gap:8px}.site-header nav{height:45px;gap:18px;flex-wrap:wrap}.site-header nav a{font-size:10px}}
@media(max-width:650px){.site-header,.in-ward .site-header{padding-right:20px}.brand{max-width:calc(100% - 118px);font-size:10px;letter-spacing:1px}.brand small{font-size:6px;letter-spacing:.8px}.brandmark{width:32px;height:34px;font-size:29px;flex-shrink:0}.night-mode{right:12px;top:15px;font-size:10px;padding:8px 10px;gap:6px}.night-mode [data-theme-icon]{font-size:20px}}
@media print{.night-mode{display:none}}

/* The brand gets the top row on phones; navigation always starts below the switch. */
@media(max-width:650px){
 .site-header,.in-ward .site-header{display:grid;grid-template-columns:minmax(0,1fr);min-height:118px;padding-top:16px;row-gap:15px}
 .site-header .brand,.in-ward .site-header .brand{grid-row:1;min-height:38px;max-width:calc(100% - 120px)}
 .site-header nav,.in-ward .site-header nav{grid-row:2;display:grid;grid-template-columns:repeat(5,minmax(0,1fr));width:100%;min-height:34px;gap:6px}
 .site-header nav a,.in-ward .site-header nav a{font-size:9px;min-height:34px;line-height:1.4;white-space:normal;text-align:center;justify-content:center}
}

/* Both independent switches belong to the page header and scroll away with it. */
.display-modes{position:absolute;right:max(18px,env(safe-area-inset-right));top:max(17px,env(safe-area-inset-top));z-index:40;display:flex;gap:6px}
.display-modes .display-mode{position:static;display:flex;align-items:center;justify-content:center;gap:7px;min-height:44px;padding:9px 12px;border:1px solid #829b91;border-radius:24px;background:#f5f3e9;color:#284a40;font-size:12px;box-shadow:0 3px 15px #102a2320}
.display-modes .display-mode>span:first-child{font-size:20px;line-height:1}
.display-modes .display-mode[aria-pressed=true]{background:#315f50;color:#fff5d7;border-color:#648b76;box-shadow:inset 0 0 0 1px #648b76}
.in-splash .display-modes .display-mode{background:#19323e;color:#f2dfb3;border-color:#809d9b}
.in-splash .display-modes .display-mode[aria-pressed=true]{background:#3b6654;border-color:#d7ca91}
html[data-theme=night] .display-modes .display-mode{background:#293631;color:#dfd3af;border-color:#657668;box-shadow:none}
html[data-theme=night] .display-modes .display-mode[aria-pressed=true]{background:#3b6654;color:#f1eed8;border-color:#90b096}
.site-header,.in-ward .site-header{padding-right:290px}
.splash-top{padding-right:290px}
@media(max-width:1150px) and (min-width:651px){.site-header,.in-ward .site-header{padding-right:280px}}
@media(max-width:650px){
 .display-modes{right:12px;top:15px;gap:4px}
 .display-modes .display-mode{padding:8px 9px;gap:4px;font-size:10px}
 .display-modes .display-mode>span:first-child{font-size:17px}
 .site-header,.in-ward .site-header{padding-right:16px;min-height:126px}
 .site-header .brand,.in-ward .site-header .brand{max-width:calc(100% - 204px);gap:7px;font-size:9px;letter-spacing:.6px}
 .site-header .brand small,.in-ward .site-header .brand small{font-size:6px;letter-spacing:0}
 .site-header .brandmark,.in-ward .site-header .brandmark{width:29px;height:32px;font-size:27px}
 .splash-top{padding-right:212px}
 .splash-top b{font-size:8px;letter-spacing:.6px}
}
@media print{.display-modes{display:none}}
