/* Appearance selector. The existing light palette remains in style.css. */
:root{color-scheme:light}
.theme-picker{position:relative;color:#17475c;font-size:.9rem}
.theme-picker[hidden]{display:none!important}
.theme-picker summary{list-style:none;display:flex;align-items:center;justify-content:center;gap:8px;min-height:44px;padding:8px 12px;border:1px solid #d5e4eb;border-radius:7px;background:#f7fbfd;cursor:pointer;font-weight:600}
.theme-picker summary::-webkit-details-marker{display:none}
.theme-picker summary:hover,.theme-picker[open] summary{background:#e5f3f9;border-color:#79bed5}
.theme-picker summary:focus-visible{outline:3px solid #005d85;outline-offset:3px}
.theme-picker summary svg{width:22px;height:22px;fill:none;stroke:currentColor;stroke-width:1.8;flex:none}
.theme-picker summary svg path{fill:currentColor;stroke:none}
.theme-panel{position:absolute;right:0;top:calc(100% + 8px);z-index:60;width:270px;max-width:calc(100vw - 32px);padding:16px;border:1px solid #b6cbd5;border-radius:8px;background:#fff;box-shadow:0 8px 24px #17304426;text-align:left}
.theme-panel label{margin:0}.theme-panel select{margin-top:6px;min-height:44px;font-size:16px}
.theme-panel p{font-size:.8rem;line-height:1.45;margin:10px 0 0;color:#536b77}
.theme-panel .theme-status{font-weight:600;color:#17475c}
.auth-theme{display:flex;justify-content:flex-end;margin:-12px 0 14px}
@media(max-width:650px){
 .app-header .theme-picker summary{width:44px;padding:0}
 .app-header .theme-picker summary>span{display:none}
 .app-header .header-user-actions:has(.header-icon--logout) .theme-panel{right:-100px;max-width:calc(100vw - 32px)}
}
@media print{.theme-picker,.auth-theme{display:none!important}html{color-scheme:light}}

/* Dark colors apply only on screen: printing always uses the established light palette. */
@media screen{
html[data-theme="dark"]{
 color-scheme:dark;
 --night-bg:#0f1c26;--night-surface:#182632;--night-raised:#203443;--night-soft:#1b2e3a;
 --night-text:#e7eef4;--night-title:#e7f4fa;--night-muted:#b1c3ce;--night-link:#7bd6f4;
 --night-edge:#405868;--night-control:#7a94a4;
 --night-green-bg:#263e2a;--night-green:#c9e7ae;
 --night-red-bg:#462630;--night-red:#ffb4b8;
 --night-yellow-bg:#40351f;--night-yellow:#ffe0a3;
 background:var(--night-bg);
}
html[data-theme="dark"] body{background:var(--night-bg);color:var(--night-text)}
html[data-theme="dark"] :where(.app-header,.app-footer,.sidebar,.narrow,section,dialog,.tile,.rule-card,.rule-report-block,.calculation-form,.calculation-panel dialog,.planning-help-dialog,.block-period-row){background:var(--night-surface);border-color:var(--night-edge);color:var(--night-text)}
html[data-theme="dark"] :is(h1,h2,h3,.brand span,.tile-title,.rule-group-heading h2,.rule-card label,.class-mode-heading h2,.selected-class-identity strong,.audit-summary strong,.class-settings-fields legend,.preference-toolbar legend,.block-period-row>strong){color:var(--night-title)}
html[data-theme="dark"] .brand img{background:#fff;border-radius:4px;padding:4px}
html[data-theme="dark"] :is(.muted,.app-footer,.footer-release,.home-section-heading p,.rule-group-heading p,.rule-group-heading span,.rule-save-bar span,.rule-slider,.teacher-plan-free,.teacher-plan-lesson small,.cell-label,.selected-class-details span,.selected-class-banner p,.class-mode-copy p,.objective-area,.planning-help-kicker,.calendar-grid>strong){color:var(--night-muted)}
html[data-theme="dark"] :is(main a,main a:visited,.footer-documentation,.header-back,.link-button,.tile-detail,.selected-class-identity span,.audit-table summary){color:var(--night-link);text-decoration-color:#4e8298}
html[data-theme="dark"] :is(main a:hover,.footer-documentation:hover,.header-back:hover,.link-button:hover){color:#b9edff;text-decoration-color:var(--night-link)}
html[data-theme="dark"] :is(input,select,textarea,.consent-form textarea){background:#10212d;color:var(--night-text);border-color:var(--night-control)}
html[data-theme="dark"] input::placeholder,html[data-theme="dark"] textarea::placeholder{color:#9eafb9;opacity:1}
html[data-theme="dark"] input:is([type=checkbox],[type=radio],[type=range]),html[data-theme="dark"] progress{accent-color:#43bce7}
html[data-theme="dark"] :is(input:focus,select:focus,textarea:focus,button:focus-visible,a:focus-visible,summary:focus-visible,.table-scroll:focus-visible){outline-color:var(--night-link)}
html[data-theme="dark"] :is(th,td,fieldset,.week-grid,.class-settings-fields,.consent-form>fieldset,.preference-toolbar,.class-gap-control,.selected-class-details,.footer-release span+span){border-color:var(--night-edge)}
html[data-theme="dark"] :is(th,tfoot td,.week-grid h3,.rule-report-block h3){background:var(--night-raised);color:var(--night-title)}
html[data-theme="dark"] :is(.planning-grid td,.teacher-plan-grid td){background:var(--night-surface)}
html[data-theme="dark"] .table-pin-first>tbody>tr>td:first-child:not([colspan]){background:var(--night-surface);box-shadow:inset -1px 0 var(--night-control)}
html[data-theme="dark"] .table-pin-first>thead>tr>:first-child:not([colspan]),html[data-theme="dark"] .table-pin-first>tbody>tr>th:first-child:not([colspan]),html[data-theme="dark"] .table-pin-first>tfoot>tr>:first-child:not([colspan]){background:var(--night-raised);box-shadow:inset -1px 0 var(--night-control)}
html[data-theme="dark"] .teacher-plan-lesson{background:#1c3b4b;border-left-color:#43bce7}
html[data-theme="dark"] .teacher-plan-lesson strong{color:var(--night-title)}
html[data-theme="dark"] :is(.mode-button,.edit-link,.detail-link,.header-icon,.profile-day-toggle,.planning-help-close,.planning-help-trigger,.nav-toggle,:where(.version-view-tabs a)){background:var(--night-raised);color:var(--night-link);border-color:var(--night-control)}
html[data-theme="dark"] :is(.mode-button:hover,.edit-link:hover,.detail-link:hover,.header-icon:hover,.profile-day-toggle:hover,.planning-help-close:hover,.planning-help-trigger:hover,.nav-toggle:hover,:where(.version-view-tabs a):hover){background:#294b60;color:#b9edff;border-color:var(--night-link)}
html[data-theme="dark"] main a.school-action,html[data-theme="dark"] main a.school-action:visited,html[data-theme="dark"] main a.compact-section-link,html[data-theme="dark"] main a.compact-section-link:visited{background:var(--night-raised);color:var(--night-link);border-color:var(--night-control)}
html[data-theme="dark"] main a.school-action:hover,html[data-theme="dark"] main a.compact-section-link:hover{background:#294b60;color:#b9edff;border-color:var(--night-link)}
html[data-theme="dark"] .mode-button.active,html[data-theme="dark"] .version-view-tabs a.active{background:#176281;color:#fff;border-color:var(--night-link)}
html[data-theme="dark"] main a.school-action--primary,html[data-theme="dark"] main a.school-action--primary:visited{background:#007da8;color:#fff;border-color:#43bce7}
html[data-theme="dark"] main a.school-action--primary:hover{background:#00678d;color:#fff}
html[data-theme="dark"] .header-icon--logout:hover{background:var(--night-red-bg);color:var(--night-red);border-color:#a66a73}
html[data-theme="dark"] .header-calculate{color:#fff}
html[data-theme="dark"] .sidebar nav a{color:var(--night-title);background:transparent}
html[data-theme="dark"] .sidebar nav a:hover{background:#294b60}
html[data-theme="dark"] .sidebar nav .nav-section>summary.nav-heading{color:var(--night-title)}
html[data-theme="dark"] .sidebar nav .nav-section>summary:hover{background:#294b60}
html[data-theme="dark"] .sidebar nav .nav-section>summary:focus-visible{outline-color:var(--night-link)}
html[data-theme="dark"] :is(.nav-section,.home-section,.nav-section--planning,.home-section--planning,.nav-section--account,.home-section--account){background:var(--night-soft);border-color:var(--night-edge);border-left-color:#43bce7}
html[data-theme="dark"] :is(.nav-section--settings,.home-section--settings){background:#283422;border-left-color:#afca05}
html[data-theme="dark"] :is(.nav-section--results,.home-section--results){background:#20372e;border-left-color:#61a882}
html[data-theme="dark"] .sidebar nav .nav-section .nav-heading{color:var(--night-muted)}
html[data-theme="dark"] .sidebar nav .nav-home{background:var(--night-raised);border-color:var(--night-edge)}
html[data-theme="dark"] .sidebar nav a.active,html[data-theme="dark"] .sidebar nav .nav-home.active{background:#23485c;color:#c5f0ff;border-color:#43bce7}
html[data-theme="dark"] .sidebar nav .nav-section--settings .nav-links a.active{background:#3b5029;color:var(--night-green)}
html[data-theme="dark"] .sidebar nav .nav-section--results .nav-links a.active{background:#28513c;color:#c0f0d0}
html[data-theme="dark"] .sidebar nav .nav-section--account .nav-links a.active{background:#334757;color:var(--night-title)}
html[data-theme="dark"] .sidebar nav .nav-links a.nav-calculate{color:var(--night-red)}
html[data-theme="dark"] .sidebar nav .nav-links a.nav-calculate:hover,html[data-theme="dark"] .sidebar nav .nav-links a.nav-calculate.active{background:var(--night-red-bg);color:var(--night-red)}
html[data-theme="dark"] .home-section{--home-ink:#7bd6f4}
html[data-theme="dark"] .home-section--settings{--home-ink:#c9e7ae}
html[data-theme="dark"] .home-section--results{--home-ink:#a6dfba}
html[data-theme="dark"] .home-section--account{--home-ink:#c4d7e4}
html[data-theme="dark"] .home-section .tile--calculate .tile-title,html[data-theme="dark"] .home-section .tile--calculate .tile-detail{color:var(--night-red)}
html[data-theme="dark"] .tile{color:var(--night-text)}
html[data-theme="dark"] .tile:hover{border-color:var(--night-link)}
html[data-theme="dark"] :is(.class-settings-stage,.class-selection-empty,.consent-kind,.consent-page .class-planning-stage,.audit-notice,.audit-summary>div,.plan-empty-state,.list-search-tools,.objective-card,.block-settings){background:var(--night-soft);color:var(--night-text);border-color:var(--night-edge)}
html[data-theme="dark"] .list-search-result,html[data-theme="dark"] .table-scroll-tools{color:var(--night-muted)}
html[data-theme="dark"] .block-settings legend{color:var(--night-link)}
html[data-theme="dark"] :is(.evening-settings,.class-mode-panel,.import-order,.block-stage-note){background:#283422;color:var(--night-text);border-color:#647445}
html[data-theme="dark"] :is(.evening-settings legend,.class-mode-kicker){color:var(--night-green)}
html[data-theme="dark"] .selected-class-banner{background:linear-gradient(100deg,#1c3543,var(--night-surface));border-color:#4389a2;color:var(--night-text)}
html[data-theme="dark"] .import-card h2 span{background:#23485c;color:#c5f0ff}
html[data-theme="dark"] .rule-group{--rule-accent:#43bce7;--rule-soft:#1b2e3a;--rule-border:#405868;background:var(--rule-soft);border-color:var(--rule-border)}
html[data-theme="dark"] .rule-group--classes{--rule-accent:#afca05;--rule-soft:#283422;--rule-border:#647445}
html[data-theme="dark"] .rule-group-heading{background:var(--night-raised);border-color:var(--night-edge)}
html[data-theme="dark"] .rule-group-heading>strong{color:#0f1c26}
html[data-theme="dark"] .rule-card output{color:var(--night-title)}
html[data-theme="dark"] .rule-report-block--classes h3{background:#283422}
html[data-theme="dark"] .objective-effective{border-left-color:#b6c900}
html[data-theme="dark"] .objective-card:focus-within{outline-color:var(--night-link)}
html[data-theme="dark"] .calculation-panel{background:linear-gradient(180deg,#1c3543,var(--night-surface) 45%)}
html[data-theme="dark"] .calculation-reset{border-color:var(--night-edge)}
html[data-theme="dark"] .calculation-reset .danger-button{background:var(--night-red-bg);color:var(--night-red);border-color:#a66a73}
html[data-theme="dark"] .calculation-reset .danger-button:hover{background:#5a303a}
html[data-theme="dark"] :is(.calculation-reset .danger-button:disabled,.calculation-form button:disabled){background:#33434d;color:#c2cfd7;border-color:#71848e}
html[data-theme="dark"] :is(.planning-help-top,.theme-panel){background:var(--night-surface);border-color:var(--night-edge)}
html[data-theme="dark"] .planning-help-dialog h2{border-color:var(--night-edge)}
html[data-theme="dark"] dialog::backdrop{background:#030b13b3}
html[data-theme="dark"] .error{color:var(--night-red)}
html[data-theme="dark"] .ok{color:var(--night-green)}
html[data-theme="dark"] :is(.unsaved-notice,.unsaved-dialog,.audit-status--violation,.block-period-row .block-date-error){background:var(--night-red-bg);color:var(--night-red);border-color:#a66a73}
html[data-theme="dark"] .unsaved-dialog h2{color:var(--night-red)}
html[data-theme="dark"] .block-period-row input[aria-invalid=true]{border-color:var(--night-red)}
html[data-theme="dark"] :is(.planning-status,.class-settings-pending,.audit-status--unknown,.audit-incomplete){background:var(--night-yellow-bg);color:var(--night-yellow);border-color:#aa8749}
html[data-theme="dark"] :is(.history-current,.user-online,.class-mode-status.is-active){background:var(--night-green-bg);color:var(--night-green)}
html[data-theme="dark"] :is(.user-offline,.class-mode-status.is-inactive){background:#293844;color:var(--night-muted)}
html[data-theme="dark"] .preference-cell.pref-neutral{background:var(--night-raised);color:var(--night-title);border-color:var(--night-control)}
html[data-theme="dark"] .preference-cell.pref-neutral:hover{background:#294b60}
html[data-theme="dark"] .preference-cell.pref-blocked{background:var(--night-red-bg);color:var(--night-red);border-color:#a66a73}
html[data-theme="dark"] .preference-cell.pref-blocked:hover{background:#5a303a}
html[data-theme="dark"] .preference-cell.pref-avoid{background:var(--night-yellow-bg);color:var(--night-yellow);border-color:#aa8749}
html[data-theme="dark"] .preference-cell.pref-avoid:hover{background:#554528}
html[data-theme="dark"] .preference-cell.pref-prefer{background:var(--night-green-bg);color:var(--night-green);border-color:#739b62}
html[data-theme="dark"] .preference-cell.pref-prefer:hover{background:#355338}
html[data-theme="dark"] .time-profile-grid td label:has(input:checked),html[data-theme="dark"] .profile-day-toggle[aria-pressed="true"]{background:var(--night-green-bg);color:var(--night-green)}
html[data-theme="dark"] .profile-day-toggle[aria-pressed="true"]:hover{background:#355338}
html[data-theme="dark"] :is(.time-profile-grid .profile-disabled,.teacher-plan-grid .profile-disabled,.planning-grid .profile-disabled){background:#293844;color:var(--night-muted)}
html[data-theme="dark"] .calendar-grid .calendar-day{background:var(--night-raised);color:var(--night-title);border-color:var(--night-control)}
html[data-theme="dark"] .calendar-grid .calendar-holiday,html[data-theme="dark"] .legend-holiday{background:#244d62;color:#c5f0ff;border-color:#5bb5d8}
html[data-theme="dark"] .calendar-grid .calendar-state,html[data-theme="dark"] .legend-state{background:var(--night-red-bg);color:var(--night-red);border-color:#a66a73}
html[data-theme="dark"] .calendar-grid .calendar-school,html[data-theme="dark"] .legend-school,html[data-theme="dark"] .calendar-off{background:var(--night-green-bg);color:var(--night-green);border-color:#739b62}
html[data-theme="dark"] .calendar-grid .calendar-weekend,html[data-theme="dark"] .legend-weekend{background:#293844;color:var(--night-muted)}
html[data-theme="dark"] .calendar-marker{background:var(--night-bg);color:var(--night-title)}
html[data-theme="dark"] .theme-picker{color:var(--night-title)}
html[data-theme="dark"] .theme-picker summary{background:var(--night-raised);border-color:var(--night-control)}
html[data-theme="dark"] .theme-picker summary:hover,html[data-theme="dark"] .theme-picker[open] summary{background:#294b60;border-color:var(--night-link)}
html[data-theme="dark"] .theme-panel p{color:var(--night-muted)}
html[data-theme="dark"] .theme-panel .theme-status{color:var(--night-title)}
}

@media screen {
html[data-theme="dark"] button.planning-help-trigger,html[data-theme="dark"] button.planning-help-trigger:hover{background:transparent;border:0;color:var(--night-link)}
html[data-theme="dark"] button.planning-help-trigger > span{background:#70d5ed;color:#102b39}
html[data-theme="dark"] button.planning-help-trigger:hover > span{background:#a3e9f7}
html[data-theme="dark"] .class-create-profile{border-color:var(--night-control)}
}

@media screen{
html[data-theme="dark"] .teacher-create-wishes{border-color:var(--night-control)}
html[data-theme="dark"] .teacher-create-wishes>summary{background:#007c9e;border-color:#70d5ed;color:#fff}
html[data-theme="dark"] .teacher-create-wishes>summary:hover{background:#005d7a}
html[data-theme="dark"] .teacher-create-wishes>summary:focus-visible{outline-color:var(--night-link)}
}

@media screen{
html[data-theme="dark"] .school-confirm-dialog{background:var(--night-surface);color:var(--night-text);border-color:var(--night-edge);border-top-color:#43bce7}
html[data-theme="dark"] .school-confirm-dialog h2{color:var(--night-title)}
html[data-theme="dark"] .school-confirm-dialog.school-confirm-danger{border-top-color:var(--night-red)}
}
@media screen{html[data-theme="dark"] :is(.chain-card,.chain-form fieldset){border-color:var(--night-edge)}html[data-theme="dark"] .chain-card{border-left-color:#43bce7}}
@media screen{html[data-theme="dark"] .chain-required{background:var(--night-raised);border-color:var(--night-control);color:var(--night-text)}html[data-theme="dark"] .chain-required small{color:var(--night-muted)}html[data-theme="dark"] .chain-required input[type=checkbox]{accent-color:var(--night-link)}}
