/* Colour preference is orthogonal to the existing visual themes. */
.color-mode-control{margin-top:18px;display:grid;gap:10px}.color-mode-label{font-weight:600}.color-mode-options{display:flex;flex-wrap:wrap;gap:8px}.color-mode-options label{display:flex;align-items:center;gap:8px;min-height:44px;padding:8px 12px;border:1px solid var(--line);border-radius:10px;background:var(--surface-2);cursor:pointer}.color-mode-options label:has(input:checked){outline:2px solid var(--accent);outline-offset:-2px}.color-mode-control small{color:var(--muted);line-height:1.7}.color-mode-error{position:fixed;bottom:84px;left:16px;right:16px;z-index:4000;max-width:680px;margin:auto;padding:14px;background:var(--bad-soft);color:var(--bad);border:1px solid var(--bad);border-radius:12px}
html[data-color-mode=dark][data-theme]{color-scheme:dark;--bg:#151b24!important;--surface:#1c2532!important;--surface-2:#242f3e!important;--ink:#d0d7e2!important;--text:#d0d7e2!important;--muted:#a2adbc!important;--line:#354254!important;--accent:#8bb7ff!important;--accent-soft:#243b5c!important;--accent-ink:#accdff!important;--good:#82d9b3!important;--good-soft:#173b32!important;--bad:#ffb3ab!important;--bad-soft:#442623!important;--warn:#edc686!important;--shadow:0 8px 24px #0005!important}
html[data-color-mode=dark][data-theme] body{background:var(--bg)!important;color:var(--ink)!important}
html[data-color-mode=dark][data-theme] :is(.panel,.sidebar,.mobile-nav,.topbar,.question-card,.modal,.modal-card,.dialog-card,.sheet,.popover,.onboarding-card,.settings-guide-card,.brief-sheet,.annotation-toolbar,.annotation-list,.choice,.option,.search-result,.source-chip,.settings-section){background-color:var(--surface)!important;background-image:none!important;color:var(--ink)!important;border-color:var(--line)!important}
html[data-color-mode=dark][data-theme] :is(input,select,textarea,.button.secondary,.tag,.bank-switch,.subject-icon,.answer-sheet,.theme-field){background-color:var(--surface-2)!important;color:var(--ink)!important;border-color:var(--line)!important}
html[data-color-mode=dark][data-theme] :is(.button.primary,button.primary){background:var(--accent)!important;color:#10213a!important;border-color:var(--accent)!important}
html[data-color-mode=dark][data-theme] :is(.option.selected,.choice.selected,.bank-switch .active,.side-nav .active){background:var(--accent-soft)!important;color:var(--accent-ink)!important;border-color:var(--accent)!important}
html[data-color-mode=dark][data-theme] :is(.answer-feedback.correct,.option.correct,.choice.correct,.notice.success){background:var(--good-soft)!important;color:var(--good)!important;border-color:var(--good)!important}
html[data-color-mode=dark][data-theme] :is(.answer-feedback.wrong,.option.wrong,.choice.wrong,.notice.error){background:var(--bad-soft)!important;color:var(--bad)!important;border-color:var(--bad)!important}
html[data-color-mode=dark][data-theme] :is(.muted,.page-description,.mobile-nav a,.side-nav a,.sidebar-foot,.field-help){color:var(--muted)!important}
html[data-color-mode=dark][data-theme] :is(.mobile-nav a.active,.side-nav a.active){color:var(--accent-ink)!important}
html[data-color-mode=dark] ::selection{background:#536f9d;color:#fff}
html[data-color-mode=dark] :is(mark,.annotation-highlight){background:#70591d;color:#fff1bd}
/* Keep game art and rule colours intact, while removing bright UI surfaces. */
html[data-color-mode=dark] .pg{--pg-ink:#f4e4c2;--pg-paper:#243343;--pg-gold:#ebc36d}
html[data-color-mode=dark] .pg:before{background:rgba(10,20,31,.55)!important}
html[data-color-mode=dark] :is(.pg-modal,.pg-dialog,.pg-pause,.pg-receipt){background:#182231!important;color:#e5edf7!important}

html[data-color-mode=dark] .pg-cell{background:linear-gradient(145deg,#283a50,#1d2a3a)!important;color:#f4e6cc!important;border-color:#627181!important;box-shadow:inset 0 1px #43556c,0 2px #101721!important}
html[data-color-mode=dark] .pg-cell.is-empty{background:#182332!important;border-color:transparent!important;box-shadow:none!important}
html[data-color-mode=dark] .pg-cell.is-related:not(.is-selected){background:#263d53!important}
html[data-color-mode=dark] .pg-cell.is-selected,html[data-color-mode=dark] .pg-cell.is-valid-range{background:#3b5266!important;color:#fff0c9!important}
html[data-color-mode=dark] .pg .pg-board-sudoku .pg-cell{color:#accdff!important}
html[data-color-mode=dark] .pg .pg-board-sudoku .pg-cell.is-given{color:#f4e6cc!important}
html[data-color-mode=dark] .pg .pg-board-sudoku .pg-cell.is-conflict{background:#442623!important;color:#ffb3ab!important}
html[data-color-mode=dark] .pg-board.is-playing-trace .pg-cell{color:transparent!important}
html[data-color-mode=dark] .pg-cell small{color:#accdff}
html[data-color-mode=dark] :is(.pg-toolbar>div,.pg-dialog-paper,.pg-pause-card,.pg-scene-nav button,.pg-scene-nav a,.pg-button){background:#202e40!important;color:#e5edf7!important;border-color:#627181!important}

html[data-color-mode=dark][data-theme] :is(.main-column,#appMain){background-color:var(--bg)!important;background-image:none!important}

html[data-color-mode=dark][data-theme] .app-body{--bg:inherit!important;--surface:inherit!important;--surface-2:inherit!important;--ink:inherit!important;--text:inherit!important;--muted:inherit!important;--line:inherit!important;--accent:inherit!important;--accent-soft:inherit!important;--accent-ink:inherit!important;--good:inherit!important;--good-soft:inherit!important;--bad:inherit!important;--bad-soft:inherit!important;--warn:inherit!important;--shadow:inherit!important;}

html[data-color-mode=dark] .anatomy-viewport{background:#101721}html[data-color-mode=dark] .anatomy-load{color:var(--muted)}

html[data-color-mode=dark][data-theme] :is(.site-topbar,.admin-command-head,.permission-strip,.admin-identity,.admin-nav,.review-card,.game-paper,.game-guide,.game-overlay,.game-toolbar){background:var(--surface)!important;color:var(--ink)!important;border-color:var(--line)!important}
html[data-color-mode=dark][data-theme] .pixel-game-page button{background:var(--surface-2)!important;color:var(--ink)!important;border-color:var(--line)!important}

/* Route-owned palettes must inherit the same night surfaces as the shell. */
html[data-color-mode=dark][data-theme] .bank-page{--bank-blue:var(--accent);--bank-muted:var(--muted);--bank-ink:var(--ink);--bank-line:var(--line);color:var(--ink)}
html[data-color-mode=dark][data-theme] :is(.bank-resume,.bank-entry,.bank-course,.bank-recent,.bank-subject-filter,.home-course,.home-action,.home-info-card,.home-exam-empty,.exam-widget,.chapter-index,.chapter-index button,.grade-segment,.subject-card,.chapter-card,.stat-card,.stats-card){background:var(--surface)!important;color:var(--ink)!important;border-color:var(--line)!important;box-shadow:none!important}
html[data-color-mode=dark][data-theme] .bank-resume{background:var(--surface-2)!important;border-color:var(--line)!important}
html[data-color-mode=dark][data-theme] :is(.bank-resume small,.bank-page .grade-filter-label,.bank-grade-hint,.bank-empty){color:var(--muted)!important}
html[data-color-mode=dark][data-theme] :is(.bank-progress-track,.progress-track,.progress-bar,.exam-progress-track){background:var(--surface-2)!important}
html[data-color-mode=dark][data-theme] .bank-recent-row{border-color:var(--line)}
html[data-color-mode=dark][data-theme] :is(.grade-chip,.filter-chip,.chip){background:transparent!important;color:var(--muted)!important;border-color:transparent!important}
html[data-color-mode=dark][data-theme] :is(.grade-chip.active,.filter-chip.active,.chip.active){background:var(--accent-soft)!important;color:var(--accent-ink)!important;border-color:var(--line)!important}
html[data-color-mode=dark][data-theme] :is(.bank-page,.home-page) :is(.tone-blue,.tone-purple,.tone-rose,.tone-green,.tone-amber,.tone-teal){--icon-tint:var(--surface-2);--icon-tone:var(--accent-ink)}
html[data-color-mode=dark][data-theme] .bank-entry-icon{background:var(--icon-tint)!important;color:var(--icon-tone)!important}
html[data-color-mode=dark][data-theme] :is(.button.primary,button.primary){background:#304562!important;color:#d6e4f5!important;border-color:#587296!important}
html[data-color-mode=dark][data-theme] :is(.option.selected,.option.correct,.option.wrong) .option-letter{color:#10213a!important}

html[data-color-mode=dark][data-theme] :is(.pixel-hud,.pixel-hud button,.pixel-hud a){background:var(--surface)!important;color:var(--ink)!important;border-color:var(--line)!important;text-shadow:none!important;box-shadow:none!important}

/* Skin-specific paper panels are UI surfaces, not artwork. */
html[data-color-mode=dark][data-theme] :is(.home-resume-card,.bank-subject-card,.chapter-row,.exam-card,.chapter-grid-panel,.chapter-index-panel,.chapter-index>nav,.chapter-index>summary,.practice-actions,.practice-toolbar,.practice-top,.memorize-topbar,.question-actions,.answer-feedback,.feedback-disclosure,.feedback-disclosure>summary,.reflection-panel,.reflection-options button,.config-dialog,.config-dialog header,.config-dialog footer,.login-card,.account-dialog,.global-search,.exam-settings-button,.exam-card-pager,.lab-tip,.pixel-toast,.pixel-room,.pixel-collectible,.pixel-badge,.pixel-unlock-progress,.pixel-badge-empty,.pixel-scene-caption){background:var(--surface)!important;background-image:none!important;color:var(--ink)!important;border-color:var(--line)!important;box-shadow:none!important;text-shadow:none!important}
html[data-color-mode=dark][data-theme] :is(.home-page,.bank-page,.page-head,.question-card,.config-dialog,.login-card) :is(h1,h2,h3,h4){color:var(--ink)!important;text-shadow:none!important}
html[data-color-mode=dark][data-theme] :is(.home-arrow,.answer-number,.option-letter,.chapter-tools .chapter-tool,.chapter-tools .chapter-action,.pixel-sound){background:var(--surface-2)!important;color:var(--ink)!important;border-color:var(--line)!important}
html[data-color-mode=dark][data-theme] .main-column::before{opacity:.08!important}
html[data-color-mode=dark][data-theme] :is(.answer-number.current,.answer-number.done){background:var(--accent-soft)!important;color:var(--accent-ink)!important}
html[data-color-mode=dark][data-theme] :is(.answer-number.wrong,.answer-feedback.wrong){background:var(--bad-soft)!important;color:var(--bad)!important}
html[data-color-mode=dark][data-theme] .answer-feedback.correct{background:var(--good-soft)!important;color:var(--good)!important}
