/* PeakFour V10: module-level Dark Mode elevation. No layout or business logic changes.
   Loads after older module CSS; scoped exclusively to [data-pf-theme="dark"].
   Token mapping: canvas #0F172A, surface #1E293B, raised #273449,
   divider #334155, heading #F8FAFC, body #CBD5E1, muted #94A3B8.
*/
:root[data-pf-theme="dark"] {
  --pf-ui-canvas:#0F172A;
  --pf-surface:#1E293B;
  --pf-surface-muted:#273449;
  --pf-surface-hover:#304158;
  --pf-border:#334155;
  --pf-heading:#F8FAFC;
  --pf-text:#CBD5E1;
  --pf-secondary:#CBD5E1;
  --pf-quiet:#94A3B8;
  --pf-action:#10B981;
  --pf-action-on:#052E25;
  --pf-muted-border:rgba(148,163,184,.24);
  /* Existing module-owned semantic variables now resolve to the dark palette. */
  --pfhub-blue:#38BDF8;
  --pfhub-navy:#F8FAFC;
  --pfhub-muted:#94A3B8;
  --pfhub-line:#334155;
  --pfhub-canvas:#0F172A;
  --pfhub-surface:#1E293B;
  --pfhub-teal:#10B981;
  --pf8-ink:#CBD5E1;
  --pf8-muted:#94A3B8;
  --pf8-border:#334155;
  --pf-room-ink:#F8FAFC;
  --pf-room-muted:#94A3B8;
  --pf-room-line:#334155;
  --pf-room-blue:#38BDF8;
  --pf-sw-ink:#F8FAFC;
  --pf-sw-muted:#94A3B8;
  --pf-sw-line:#334155;
  --pf-sw-soft:#273449;
  --pf-sw-white:#1E293B;
  --pfs-text:#CBD5E1;
  --pfs-sub:#94A3B8;
  --pfs-border:#334155;
  --pfd-line:#334155;
}
/* Shell (including off-canvas sidebar under 760px). */
:root[data-pf-theme="dark"] :is(html,body,.app-shell,.peak-layout,.peak-main){background:#0F172A!important;color:#CBD5E1!important}
:root[data-pf-theme="dark"] .peak-header{background:#1E293B!important;border-color:#334155!important;box-shadow:0 1px 0 rgba(148,163,184,.1)!important}
:root[data-pf-theme="dark"] .peak-sidebar{background:#0F172A!important;border-right:1px solid #334155!important;color:#CBD5E1!important;box-shadow:none!important}
:root[data-pf-theme="dark"] .peak-sidebar :is(.peak-sidebar-heading,.peak-sidebar-separator,.tab-name){color:#94A3B8!important}
:root[data-pf-theme="dark"] .peak-sidebar :is(.category-tab,.peak-overview-button):not(.is-active):not(.pf-section-active){background:transparent!important;border-color:transparent!important;color:#94A3B8!important}
:root[data-pf-theme="dark"] .peak-sidebar :is(.category-tab,.peak-overview-button):not(.is-active):not(.pf-section-active):hover{background:#1E293B!important;color:#F8FAFC!important}
:root[data-pf-theme="dark"] .peak-sidebar :is(.category-tab,.peak-overview-button).is-active,
:root[data-pf-theme="dark"] .peak-sidebar :is(.category-tab,.peak-overview-button).pf-section-active,
:root[data-pf-theme="dark"] body[data-pf-area="hub"] #tab-discover,
:root[data-pf-theme="dark"] body[data-pf-area="lessons"] #tab-lessons{
 background:rgba(16,185,129,.13)!important;border-color:rgba(16,185,129,.31)!important;color:#6EE7B7!important;box-shadow:inset 3px 0 0 #10B981!important;
}
:root[data-pf-theme="dark"] .peak-sidebar :is(.category-tab,.peak-overview-button).pf-section-active svg{color:#6EE7B7!important}
:root[data-pf-theme="dark"] .peak-sidebar-foot{background:#1E293B!important;border-color:#334155!important}
:root[data-pf-theme="dark"] .peak-sidebar-foot :is(strong,small,span){color:#CBD5E1!important}
:root[data-pf-theme="dark"] .pf-shell-context{border-color:#334155!important}
:root[data-pf-theme="dark"] :is(#pf-shell-active-label,.peak-main .discover-heading h2){color:#F8FAFC!important}
:root[data-pf-theme="dark"] :is(.pf-shell-eyebrow,.brand-tagline,.peak-main .overline){color:#94A3B8!important}
/* Main surfaces. List only source-backed container classes; do not modify semantic statuses or SVG art. */
:root[data-pf-theme="dark"] .peak-main :is(.panel,.steps-panel,.ipa-reference,.learning-course,.peak-skill,.contrast-card,.numbers-catalog,.dictation-catalog,.listening-config,
 .sentence-card,.dictation-speaking,.dictation-writing,.numbers-stage,.record-panel,.dictation-scene,.dictation-prompt,.contrast-sound-card,.contrast-reveal,.numbers-audio,.dictation-audio-card,.dictation-cast,
 .dictation-answer-grid>div,.dictation-word-detail,.dictation-result,.numbers-speak-result,.learning-course.is-current){
 background:#1E293B!important;border-color:#334155!important;color:#CBD5E1!important;box-shadow:none!important
}
:root[data-pf-theme="dark"] .peak-main :is(.panel,.learning-course,.numbers-stage,.dictation-scene,.contrast-card,.sentence-card) :is(h1,h2,h3,strong){color:#F8FAFC!important}
:root[data-pf-theme="dark"] .peak-main :is(.learning-course,.panel,.sentence-card,.numbers-stage) :is(p,small,label){color:#CBD5E1!important}
:root[data-pf-theme="dark"] .peak-main :is(.course-icon,.peak-skill svg){background:#273449!important;color:#7DD3FC!important}
:root[data-pf-theme="dark"] .peak-main :is(.learning-course,.pf-directory-card,.pf-grammar-card):hover{background:#273449!important;border-color:#475569!important}
:root[data-pf-theme="dark"] .peak-main :is(input:not([type="checkbox"]):not([type="radio"]),textarea,select):not(:disabled){background-color:#273449!important;color:#F8FAFC!important;border-color:#475569!important}
:root[data-pf-theme="dark"] .peak-main :is(input,textarea)::placeholder{color:#94A3B8!important}
:root[data-pf-theme="dark"] :is(.pf-header-profile,.voice-picker-button,#pf-theme-toggle){background:#273449!important;color:#F8FAFC!important;border-color:#475569!important}
/* Learning hub / directory / Discover */
:root[data-pf-theme="dark"] #page-discover :is(.pf-hub-welcome,.pf-hub-skills,.pf-d-intro,.pf-d-intro-context,.pf-d-path,.pf-d-related,.pf-d-topic,.pf-d-empty,.pf-rc8-discover-card,.pf-rc8-catalog-notice,.pf-rc8-empty,.pf-rc8-discover-error,.pf-i-journey),
:root[data-pf-theme="dark"] #page-lessons :is(.pf-lesson-directory-head,.pf-directory-card,.pf-directory-search){background:#1E293B!important;border-color:#334155!important;box-shadow:none!important;color:#CBD5E1!important}
:root[data-pf-theme="dark"] #page-discover :is(.pf-hub-skill,.pf-d-state-chip,.pf-d-step-index,.pf-d-topic-marker,.pf-rc8-topic-filter,.pf-rc8-show-more,.pf-d-refresh,.pf-i-filter),
:root[data-pf-theme="dark"] #page-lessons :is(.pf-directory-icon,.pf-directory-search input){background:#273449!important;border-color:#475569!important;color:#CBD5E1!important}
:root[data-pf-theme="dark"] #page-discover :is(.pf-hub-welcome h1,.pf-hub-skill-head strong,.pf-d-title,.pf-d-related-head h2,.pf-hub-skill,.pf-d-topic strong,.pf-rc8-discover-card strong),
:root[data-pf-theme="dark"] #page-lessons :is(.pf-lesson-directory-head h1,.pf-directory-toolbar h2,.pf-directory-section-head h3,.pf-directory-card strong){color:#F8FAFC!important}
:root[data-pf-theme="dark"] #page-discover :is(.pf-hub-welcome p,.pf-d-intro p,.pf-d-related p,.pf-hub-skill-head span,.pf-d-topic small,.pf-d-join-proof),
:root[data-pf-theme="dark"] #page-lessons :is(.pf-lesson-directory-head p,.pf-directory-card small,.pf-directory-section-head p,.pf-directory-toolbar p){color:#94A3B8!important}
:root[data-pf-theme="dark"] #page-discover :is(.pf-d-topic,.pf-hub-skill,.pf-rc8-discover-card):hover,
:root[data-pf-theme="dark"] #page-lessons .pf-directory-card:hover{background:#273449!important;border-color:#475569!important}
/* Grammar: keep correct/wrong feedback distinct, preserve special warning/success fills. */
:root[data-pf-theme="dark"] #page-grammar :is(.pf-grammar-hero,.pf-grammar-card,.pf-grammar-detail,.pf-grammar-subtopic,.pf-grammar-concept,.pf-grammar-example,.pf-grammar-practice,.pf-grammar-quiz,.pf-grammar-quiz-choice,.pf-grammar-practice-answer){background:#1E293B!important;border-color:#334155!important;color:#CBD5E1!important;box-shadow:none!important}
:root[data-pf-theme="dark"] #page-grammar :is(.pf-grammar-card-number,.pf-grammar-subtopic-number){background:#273449!important;color:#6EE7B7!important}
:root[data-pf-theme="dark"] #page-grammar :is(.pf-grammar-card-title,.pf-grammar-lesson-heading,.pf-grammar-module-intro h2,.pf-grammar-catalog-caption h2,.pf-grammar-concept strong){color:#F8FAFC!important}
:root[data-pf-theme="dark"] #page-grammar :is(.pf-grammar-card-subtitle,.pf-grammar-catalog-caption p,.pf-grammar-module-intro p,.pf-grammar-example p){color:#CBD5E1!important}
:root[data-pf-theme="dark"] #page-grammar :is(.pf-grammar-subtopic,.pf-grammar-quiz-choice):hover{background:#273449!important;border-color:#475569!important}
/* Profile / authentication UI */
:root[data-pf-theme="dark"] #page-profile :is(.pf-profile-hero,.pf-profile-identity,.pf-profile-overview article,.pf-profile-panel,.pf-phone-pill,.pf-test-stage,.pf-test-choice,.pf-test-answer,.pf-test-passage,.pf-profile-settings){background:#1E293B!important;color:#CBD5E1!important;border-color:#334155!important;box-shadow:none!important}
:root[data-pf-theme="dark"] #page-profile :is(.pf-profile-overview article strong,.pf-profile-identity strong,.pf-profile-settings h2,.pf-test-stage h3,.pf-test-english,.pf-test-choice){color:#F8FAFC!important}
:root[data-pf-theme="dark"] #page-profile :is(.pf-profile-overview article small,.pf-profile-hero p,.pf-profile-identity small,.pf-test-stage p,.pf-panel-note){color:#94A3B8!important}
:root[data-pf-theme="dark"] #page-profile .pf-test-choice:hover{background:#273449!important;border-color:#475569!important}
/* Shadowing / speaking */
:root[data-pf-theme="dark"] #page-shadowing :is(.pfs-primary,.pfs-library,.pfs-clip-card,.pfs-cue,.pfs-hidden-hint,.pfs-player-controls button,.pfs-record-actions button,.pfs-filters button){background:#1E293B!important;border-color:#334155!important;color:#CBD5E1!important;box-shadow:none!important}
:root[data-pf-theme="dark"] #page-shadowing :is(.pfs-cue.is-speaking,.pfs-clip-card.is-selected,.pfs-filters button[aria-pressed="true"]){background:#16483E!important;border-color:#10B981!important;color:#D1FAE5!important}
:root[data-pf-theme="dark"] #page-shadowing :is(.pfs-hidden-hint,.pfs-player-controls select){background:#273449!important;color:#CBD5E1!important;border-color:#475569!important}
/* Numbers / Dictation / listening practice */
:root[data-pf-theme="dark"] :is(#page-numbers,#page-dictation,#page-counting,#page-pronunciation,#page-listening) :is(.numbers-stats>div,.dictation-metrics>div,.contrast-stats>div,.dictation-answer-grid>div,.dictation-word-detail,.dictation-result,.numbers-speak-result,.dictation-history-item,.contrast-answers-head,.numbers-feedback,.dictation-writing-diff,.dictation-writing-input,.numbers-writing-input){background:#1E293B!important;color:#CBD5E1!important;border-color:#334155!important}
:root[data-pf-theme="dark"] :is(#page-numbers,#page-dictation,#page-counting,#page-pronunciation,#page-listening) :is(.contrast-stats strong,.numbers-stats strong,.dictation-metrics strong,.dictation-stage-top,.numbers-stage h3,.dictation-speaking h3,.dictation-writing h3,.numbers-score-main strong,.dictation-result-top h3){color:#F8FAFC!important}
:root[data-pf-theme="dark"] :is(#page-numbers,#page-dictation,#page-counting,#page-pronunciation,#page-listening) :is(.numbers-stats small,.dictation-metrics span,.dictation-result-top p,.dictation-word-detail p,.contrast-answers-head>span,.numbers-format-help,.dictation-history-item){color:#CBD5E1!important}
:root[data-pf-theme="dark"] :is(#page-numbers,#page-dictation,#page-counting) :is(.dictation-word.is-flagged,.is-incorrect,.pf-error){background:#4C2535!important;color:#FECDD3!important;border-color:#9F3858!important}
/* Dictionary V3–V9 has its own scoped palette; patch only persistent bright control surfaces. */
:root[data-pf-theme="dark"] #page-vocabulary :is(.pf-d3-side-card,.pf-d3-info-card,.pf-d3-results-panel,.pf-d3-results-item,.pf-d3-suggest,.pf-d3-no-results,.pf-d9-daily,.pf-d9-quiz-card,.pf-d9-summary-card,.pf-d3-welcome,.vocab-detail-shell,.vocab-sense){background:#1E293B!important;border-color:#334155!important;color:#CBD5E1!important}
:root[data-pf-theme="dark"] #page-vocabulary :is(.pf-d3-searchbar,.pf-uiverse-search,.pf-uiverse-search-host,.pf-uiverse-search-icon,.pf-d3-ipa-variant,.vocab-example,.pf-d9-quiz-options button){background:#273449!important;border-color:#475569!important;color:#CBD5E1!important}
:root[data-pf-theme="dark"] #page-vocabulary :is(.pf-d9-daily h3,.pf-d9-summary-card h3,.pf-d3-section-title h2,.vocab-detail-heading h2){color:#F8FAFC!important}
:root[data-pf-theme="dark"] #page-vocabulary :is(.pf-d3-muted,.pf-d9-daily p,.pf-d9-summary-card p,.vocab-example p){color:#CBD5E1!important}
/* Built-in controls, accessible focus, and reduced-motion do not change task logic. */
:root[data-pf-theme="dark"] :is(button,a,input,select,textarea):focus-visible{outline:2px solid #38BDF8!important;outline-offset:2px}
@media(prefers-reduced-motion:reduce){:root[data-pf-theme="dark"] .peak-sidebar{transition:none}}
/* ID-specific legacy styles in learning-hub.css and the Numbers module need direct adapters. */
:root[data-pf-theme="dark"] #peak-sidebar .category-tab.pf-section-active,
:root[data-pf-theme="dark"] #peak-sidebar .category-tab.is-active,
:root[data-pf-theme="dark"] #peak-sidebar .peak-overview-button.is-active{background:rgba(16,185,129,.13)!important;border-color:rgba(16,185,129,.31)!important;color:#6EE7B7!important;box-shadow:inset 3px 0 0 #10B981!important}
:root[data-pf-theme="dark"] #peak-sidebar .category-tab:not(.pf-section-active):not(.is-active),
:root[data-pf-theme="dark"] #peak-sidebar .peak-overview-button:not(.is-active){background:transparent!important;border-color:transparent!important;color:#94A3B8!important}
:root[data-pf-theme="dark"] #peak-sidebar .category-tab:not(.pf-section-active):not(.is-active):hover{background:#1E293B!important;color:#F8FAFC!important}
:root[data-pf-theme="dark"] #page-numbers :is(.numbers-stage,.numbers-catalog,.numbers-audio,.numbers-writing,.numbers-writing-card),
:root[data-pf-theme="dark"] #page-dictation :is(.dictation-stage,.dictation-speaking,.dictation-writing,.dictation-scene,.dictation-audio-card){background:#1E293B!important;border-color:#334155!important;color:#CBD5E1!important;box-shadow:none!important}
:root[data-pf-theme="dark"] #page-numbers .numbers-stage h3,
:root[data-pf-theme="dark"] #page-dictation :is(.dictation-stage,.dictation-writing) h3{color:#F8FAFC!important}
/* Learning-hub selector uses ID-based active state (not only .pf-section-active). */
:root[data-pf-theme="dark"] body[data-pf-area="hub"] #peak-sidebar #tab-discover,
:root[data-pf-theme="dark"] body[data-pf-area="lessons"] #peak-sidebar #tab-lessons{background:rgba(16,185,129,.13)!important;color:#6EE7B7!important;border-color:rgba(16,185,129,.31)!important;box-shadow:inset 3px 0 0 #10B981!important}
:root[data-pf-theme="dark"] body[data-pf-area="hub"] #peak-sidebar #tab-lessons,
:root[data-pf-theme="dark"] body[data-pf-area="lessons"] #peak-sidebar #tab-discover{background:transparent!important;color:#94A3B8!important;border-color:transparent!important;box-shadow:none!important}
/* Page-level wrappers must not leave light gutters between raised surfaces. */
:root[data-pf-theme="dark"] .peak-main > main:is(#page-discover,#page-lessons,#page-grammar,#page-profile,#page-shadowing,#page-numbers,#page-dictation,#page-counting,#page-pronunciation,#page-listening,#page-chunking,#page-vocabulary),
:root[data-pf-theme="dark"] #page-discover :is(.pf-hub-top,.pf-d-workspace,.pf-d-workspace-header),
:root[data-pf-theme="dark"] #page-lessons :is(.pf-directory-groups,.pf-directory-card-grid),
:root[data-pf-theme="dark"] :is(#page-grammar,#page-profile,#page-numbers,#page-dictation) .pf-page-content{background:#0F172A!important}
