/* Shape and layout come from the existing styles; themes change colour only. */
html[data-color-theme=oled]{--ct-bg:#000;--ct-panel:#101010;--ct-card:#202020;--ct-raised:#303030;--ct-button:#414141;--ct-input:#080808;--ct-input-focus:#181818;--ct-fg:#f5f5f5;--ct-muted:#b8b8b8;--ct-primary:#e8e8e8;--ct-on-primary:#111;--ct-selected:#454545;--ct-border:#858585;--ct-scrim:#0009}
html[data-color-theme=light]{--ct-bg:#fff;--ct-panel:#f6f6f6;--ct-card:#eaeaea;--ct-raised:#dedede;--ct-button:#cecece;--ct-input:#fff;--ct-input-focus:#f0f0f0;--ct-fg:#171717;--ct-muted:#575757;--ct-primary:#262626;--ct-on-primary:#fff;--ct-selected:#cecece;--ct-border:#777;--ct-scrim:#0004}
html:root:root:root[data-color-theme] body :is(dialog.modal,dialog.photo-viewer,dialog.textbook-mobile-reader,.modal-inner,.modal-scroll,.scroll-viewport,.subject-history-toolbar,.calendar-popup,.date-picker,.schedule-select-popup,.phone-orientation-notice){background:var(--ct-panel)!important;color:var(--ct-fg)!important;--history-surface:var(--ct-panel);--history-toolbar:var(--ct-raised)}
html:root:root:root[data-color-theme] body dialog.modal::backdrop{background:var(--ct-scrim)!important}
html:root:root:root[data-color-theme] body :is(dialog.modal,dialog.photo-viewer,dialog.textbook-mobile-reader) :is(.cabinet-account-block,.account-profile-card,.dated-schedule,.week-grid,.textbook-reader,.textbook-pages,.textbook-viewer,.textbook-page-container,.textbook-pages-viewport,.quick-entry-field){background:var(--ct-bg)!important;background-image:none!important}
html:root:root:root[data-color-theme] body :is(dialog.modal,dialog.photo-viewer,dialog.textbook-mobile-reader) :is(.task-card,.homework-unit,.homework-card,.quick-card,.member-row,.session-row,.notification-item,.lesson-edit,.activity-option,.settings-menu-row,.dated-schedule-lesson,.date-schedule-event,.schedule-flow-summary,.schedule-category,.schedule-change-card,.schedule-event-card,.schedule-day-note,.settings-menu-group,.settings-theme-group,.class-details,.invite,.quick-auto,.notification-setting,.textbook-group-option){background:var(--ct-card)!important;background-image:none!important;color:var(--ct-fg)!important;box-shadow:none!important}
html:root:root:root[data-color-theme] body :is(dialog.modal,dialog.photo-viewer,dialog.textbook-mobile-reader) :is(.task-card.is-completed,.homework-unit.is-completed,.quick-card.saved,.quick-card.unknown-homework-saved,.date-schedule-event,.dated-schedule-lesson.is-activity,.schedule-picked,.settings-menu-row:hover){background:var(--ct-raised)!important}
html:root:root:root[data-color-theme] body :is(dialog.modal,dialog.photo-viewer,dialog.textbook-mobile-reader) :is(h1,h2,h3,h4,p,label,strong,span,a):not(.color-theme-card *){color:inherit!important}
html:root:root:root[data-color-theme] body :is(dialog.modal,dialog.photo-viewer,dialog.textbook-mobile-reader) :is(small,.muted,.date-month-label,.task-group,.lesson-time,.task-card-heading>span,.homework-card small,.date-neighbor,.schedule-notify-past){color:var(--ct-muted)!important}
html:root:root:root[data-color-theme] body :is(dialog.modal,dialog.photo-viewer,dialog.textbook-mobile-reader) :is(.subject-icon,.dated-event-icon,.session-device-icon,.notification-icon){background:var(--ct-raised)!important;color:var(--ct-fg)!important}
html:root:root:root:is([data-color-theme=oled],[data-color-theme=light]) body :is(dialog.modal,dialog.photo-viewer,dialog.textbook-mobile-reader) :is(.subject-icon,.dated-event-icon,.session-device-icon) svg{color:var(--ct-fg)!important;stroke:currentColor!important}
html:root:root:root[data-color-theme] body :is(dialog.modal,dialog.photo-viewer,dialog.textbook-mobile-reader) button:where(:not(.sheet-handle):not(.danger-button):not(.change-action):not(.accent-swatch):not(.quick-subject):not(.schedule-change-card-main):not(.schedule-pick-day):not(.color-theme-card):not(.color-theme-card *):not(.completion-button):not(.schedule-lesson-history-trigger):not(.primary):not(.active):not([aria-pressed=true]):not(.toggle-switch):not(.text-scale-options button):not(.auth-inline-reset):not(.notification-delete):not(.session-history-remove):not(.photo-attach):not(.settings-menu-row)){background-color:var(--ct-button)!important;background-image:none!important;color:var(--ct-fg)!important;box-shadow:none!important}
html:root:root:root[data-color-theme] body :is(dialog.modal,dialog.photo-viewer,dialog.textbook-mobile-reader) :is(button.primary,button.active,button[aria-pressed=true],.segmented button.active,.text-scale-thumb){background:var(--ct-primary)!important;color:var(--ct-on-primary)!important}
html:root:root:root[data-color-theme] body :is(dialog.modal,dialog.photo-viewer,dialog.textbook-mobile-reader) .text-scale-options button{background:transparent!important;color:var(--ct-fg)!important}
html:root:root:root[data-color-theme] body :is(dialog.modal,dialog.photo-viewer,dialog.textbook-mobile-reader) .text-scale-options button[aria-pressed=true]{color:var(--ct-on-primary)!important}
html:root:root:root[data-color-theme] body :is(dialog.modal,dialog.photo-viewer,dialog.textbook-mobile-reader) :is(.segmented,.text-scale-options,.subject-history-search,.subject-search-sheet,.date-orb,.dated-schedule-day-tabs,.mobile-week-navigation,.cluster-week-navigation){background:var(--ct-card)!important;color:var(--ct-fg)!important}
html:root:root:root[data-color-theme] body :is(dialog.modal,dialog.photo-viewer,dialog.textbook-mobile-reader) :is(input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=file]),textarea,select,.schedule-select-trigger){background:var(--ct-input)!important;color:var(--ct-fg)!important;caret-color:var(--ct-fg)!important}
html:root:root:root[data-color-theme] body :is(dialog.modal,dialog.photo-viewer,dialog.textbook-mobile-reader) :is(input,textarea,select):focus-visible{background:var(--ct-input-focus)!important}
html:root:root:root[data-color-theme] body :is(dialog.modal,dialog.photo-viewer,dialog.textbook-mobile-reader) :is(input,textarea)::placeholder{color:var(--ct-muted)!important;opacity:1}
html:root:root:root[data-color-theme] body :is(dialog.modal,dialog.photo-viewer,dialog.textbook-mobile-reader) .quick-entry-field textarea{background:transparent!important}
html:root:root:root[data-color-theme] body :is(dialog.modal,dialog.photo-viewer,dialog.textbook-mobile-reader) :is(.auth-inline-reset,.notification-delete,.session-history-remove,.photo-attach){background:transparent!important;color:var(--ct-fg)!important}
html:root:root:root[data-color-theme] body :is(dialog.modal,dialog.photo-viewer,dialog.textbook-mobile-reader) :is(.toggle-switch,input[type=checkbox]){background:var(--ct-selected)!important;accent-color:var(--ct-primary);color:var(--ct-fg)!important}
html:root:root:root[data-color-theme] body :is(dialog.modal,dialog.photo-viewer,dialog.textbook-mobile-reader) :is(.toggle-switch.on,input[type=checkbox]:checked){background:var(--ct-primary)!important}
html:root:root:root[data-color-theme] body :is(dialog.modal,dialog.photo-viewer,dialog.textbook-mobile-reader) .toggle-switch>span{background:var(--ct-fg)!important}
html:root:root:root[data-color-theme] body :is(dialog.modal,dialog.photo-viewer,dialog.textbook-mobile-reader) .toggle-switch.on>span{background:var(--ct-on-primary)!important}
html:root:root:root[data-color-theme] body :is(dialog.modal,dialog.photo-viewer,dialog.textbook-mobile-reader) input[type=checkbox]:checked::after{border-color:var(--ct-on-primary)!important}
html:root:root:root[data-color-theme] body :is(dialog.modal,dialog.photo-viewer,dialog.textbook-mobile-reader) :is(.calendar-day.selected,.calendar-selected,.dated-schedule-day-tabs .has-event,.dated-schedule-day-tabs [data-active=true]){background:var(--ct-selected)!important;color:var(--ct-fg)!important}
html:root:root:root[data-color-theme] body :is(dialog.modal,dialog.photo-viewer,dialog.textbook-mobile-reader) :is(.homework-progress,.summary-fold-strip){background:var(--ct-raised)!important}
html:root:root:root[data-color-theme] body :is(dialog.modal,dialog.photo-viewer,dialog.textbook-mobile-reader) .homework-progress>div{background:var(--ct-primary)!important}
html:root:root:root[data-color-theme] body :is(dialog.modal,dialog.photo-viewer,dialog.textbook-mobile-reader) .homework-achievement{color:var(--ct-fg)!important}
html:root:root:root[data-color-theme] body :is(dialog.modal,dialog.photo-viewer,dialog.textbook-mobile-reader) .dated-schedule-lesson.is-cancelled-lesson{border-color:var(--ct-border)!important}
html:root:root:root[data-color-theme] body :is(.undo-toast,.site-notification){background:var(--ct-raised)!important;color:var(--ct-fg)!important}
html:root:root:root[data-color-theme] body .undo-button{background:var(--ct-selected)!important;color:var(--ct-fg)!important}
html:root:root:root[data-color-theme] body .undo-button rect{stroke:var(--ct-fg)!important}
html:root:root:root[data-color-theme] body .textbook-mark{background:#80808044!important}
/* Preview palettes stay independent of the currently selected theme. */
.color-theme-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:14px;min-width:0}
html body :is(dialog.modal,dialog.photo-viewer,dialog.textbook-mobile-reader) .color-theme-card{padding:0!important;min-width:0;border:0!important;border-radius:22px!important;overflow:hidden;text-align:left;background:var(--preview-caption)!important;color:var(--preview-fg)!important;box-shadow:none!important;transition:transform .18s ease,background-color .2s ease;isolation:isolate}
.color-theme-card:active{transform:scale(.97)}
.theme-preview-blue{--preview-bg:#0d1929;--preview-surface:#24364e;--preview-icon:#314b68;--preview-line:#bed4f3;--preview-caption:#263a54;--preview-fg:#edf4ff;--preview-selected:#b6d2fa;--preview-on:#18314d}
.theme-preview-oled{--preview-bg:#000;--preview-surface:#191919;--preview-icon:#2c2c2c;--preview-line:#ddd;--preview-caption:#252525;--preview-fg:#f4f4f4;--preview-selected:#eee;--preview-on:#111}
.theme-preview-light{--preview-bg:#fff;--preview-surface:#ededed;--preview-icon:#fff;--preview-line:#333;--preview-caption:#e4e4e4;--preview-fg:#202020;--preview-selected:#222;--preview-on:#fff}
.color-theme-preview{display:grid!important;place-items:center;min-height:145px;padding:20px 14px;background:var(--preview-bg)!important;box-sizing:border-box}
.preview-surface{display:flex!important;align-items:center;gap:10px;width:100%;padding:14px 12px;border-radius:14px;background:var(--preview-surface)!important;box-sizing:border-box}
.preview-icon{display:block;width:28px;height:30px;flex-shrink:0;border-radius:9px;background:var(--preview-icon)!important}
.preview-lines{display:grid!important;gap:8px;min-width:0;flex:1}.preview-lines>span{display:block;height:6px;border-radius:99px;background:var(--preview-line)!important;width:100%}.preview-lines>span:last-child{width:62%;opacity:.65}
.color-theme-caption{display:flex!important;align-items:center;gap:9px;padding:16px 13px;color:var(--preview-fg)!important;font-size:15px;font-weight:500;line-height:1.35;min-height:54px;box-sizing:border-box}
.color-theme-indicator{width:16px;height:16px;border-radius:50%;background:var(--preview-icon)!important;flex-shrink:0;display:grid;place-items:center;transition:background .2s ease}
.color-theme-card.is-selected .color-theme-indicator{background:var(--preview-selected)!important}
.color-theme-card.is-selected .color-theme-caption{font-weight:650}
@media(max-width:600px){.color-theme-grid{grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}.color-theme-preview{min-height:135px;padding:18px 12px}.color-theme-caption{padding:14px 12px;font-size:14px}.preview-surface{padding:12px 10px;gap:8px}.preview-icon{width:24px;height:26px}}
@media(prefers-reduced-motion:reduce){.color-theme-card,.color-theme-indicator{transition:none!important}}
html:root:root:root[data-color-theme] body :is(.modal-heading,.modal-top-actions,.subject-history-title,.dated-week-header,.dated-mobile-header,.dated-week-surface,.textbook-toolbar,.textbook-reader-toolbar,.textbook-header,.schedule-select-menu,.calendar-header){background:var(--ct-panel)!important;color:var(--ct-fg)!important}
html:root:root:root[data-color-theme] body :is(dialog.modal,dialog.photo-viewer,dialog.textbook-mobile-reader) button.color-theme-card{background:var(--preview-caption)!important;color:var(--preview-fg)!important}
html:root:root:root[data-color-theme] body :is(dialog.modal,dialog.photo-viewer,dialog.textbook-mobile-reader) .color-theme-card .color-theme-caption{background:var(--preview-caption)!important;color:var(--preview-fg)!important}
html:root:root:root[data-color-theme] body .dated-week-header>*,html:root:root:root[data-color-theme] body .dated-mobile-header>*{color:var(--ct-fg)!important}
html:root:root:root[data-color-theme] body .dated-week-header [data-has-event=true],html:root:root:root[data-color-theme] body .dated-week-header .has-event{background:var(--ct-selected)!important}

html:root:root:root:is([data-color-theme=oled],[data-color-theme=light]) body :is(dialog.modal,dialog.photo-viewer,dialog.textbook-mobile-reader) svg{color:inherit!important}
html:root:root:root:is([data-color-theme=oled],[data-color-theme=light]) body :is(dialog.modal,dialog.photo-viewer,dialog.textbook-mobile-reader) svg [stroke]:not([stroke=none]){stroke:currentColor!important}
html:root:root:root[data-color-theme] body :is(.dated-week-header .has-schedule-event,.dated-mobile-header){background:var(--ct-card)!important}
html:root:root:root[data-color-theme=oled] body dialog.cabinet-modal{background:var(--ct-bg)!important}
html:root:root:root[data-color-theme=light] body dialog.cabinet-modal{background:var(--ct-bg)!important}

/* Every opened surface shares the same palette. The cosmic landing page is deliberately outside this scope. */
html:root:root:root[data-color-theme] body :is(dialog.modal,dialog.textbook-mobile-reader){--md-surface:var(--ct-panel);--md-container:var(--ct-card);--md-raised:var(--ct-raised);--md-accent:var(--ct-primary);--md-text:var(--ct-fg);--md-muted:var(--ct-muted);--group-row:var(--ct-card);color-scheme:dark}
html:root:root:root[data-color-theme=light] body :is(dialog.modal,dialog.textbook-mobile-reader){color-scheme:light}
html:root:root:root[data-color-theme] body :is(dialog.modal,dialog.textbook-mobile-reader) :is(.dated-schedule-frame,.dated-week-columns,.week-grid,.day-column,.textbook-stage,.textbook-mobile-pages){background:var(--ct-bg)!important;color:var(--ct-fg)!important;background-image:none!important}
html:root:root:root[data-color-theme] body :is(dialog.modal,dialog.textbook-mobile-reader) :is(.dated-week-toolbar,.dated-week-header,.dated-day-controls,.day-header,.textbook-mobile-bar,.textbook-homework){background:var(--ct-card)!important;color:var(--ct-fg)!important;background-image:none!important;box-shadow:none!important;border:0!important}
html:root:root:root[data-color-theme] body .dated-week-toolbar{border-radius:32px!important;overflow:hidden;isolation:isolate}
html:root:root:root[data-color-theme] body .dated-week-toolbar::before,html:root:root:root[data-color-theme] body .dated-week-toolbar::after{background:transparent!important;box-shadow:none!important}
html:root:root:root[data-color-theme] body :is(dialog.modal,dialog.textbook-mobile-reader) :is(.class-audit-list>article,.holiday-row,.holiday-view-row,.bell-row,.time-input,.textbook-placeholder,.textbook-context-menu){background:var(--ct-card)!important;color:var(--ct-fg)!important;box-shadow:none!important;border:0!important}
html:root:root:root[data-color-theme] body :is(dialog.modal,dialog.textbook-mobile-reader) :is(.homework-progress-heading,.quick-number,.quick-due,.quick-date-note,.bell-table-head,.bell-row>span,.holiday-date-field,.lesson-edit,.textbook-mobile-count,.textbook-mobile-status,.textbook-homework,.textbook-reader-warning){color:var(--ct-fg)!important}
html:root:root:root[data-color-theme] body :is(dialog.modal,dialog.textbook-mobile-reader) :is(.quick-subject,.schedule-change-card-main,.schedule-pick-day,.schedule-lesson-history-trigger){background:transparent!important;color:inherit!important;box-shadow:none!important;border:0!important}
html:root:root:root[data-color-theme] body :is(dialog.modal,dialog.textbook-mobile-reader) .quick-entry-field{background:var(--ct-input)!important;border:0!important;box-shadow:none!important}
html:root:root:root[data-color-theme] body :is(dialog.modal,dialog.textbook-mobile-reader) .quick-entry-field :is(textarea,textarea:focus-visible,.photo-controls){background:transparent!important;border:0!important;box-shadow:none!important}
html:root:root:root[data-color-theme] body :is(dialog.modal,dialog.textbook-mobile-reader) :is(.time-input,.lesson-edit){border:0!important}
html:root:root:root[data-color-theme] body :is(dialog.modal,dialog.textbook-mobile-reader) .dated-week-header time[aria-current=date]{background:var(--ct-selected)!important;border-radius:999px}
html:root:root:root[data-color-theme] body .textbook-homework-mark{background:color-mix(in srgb,var(--ct-primary) 30%,transparent)!important;border-color:color-mix(in srgb,var(--ct-primary) 55%,transparent)!important}
html:root:root:root[data-color-theme] body :is(dialog.modal,dialog.textbook-mobile-reader) :is(.textbook-stage-navigation button,.textbook-zoom button,.textbook-mobile-close,.textbook-page-jump button){background:var(--ct-button)!important;color:var(--ct-fg)!important}
/* Photographs keep a quiet, dark viewing stage even with a light interface. */
html:root:root:root[data-color-theme] body dialog.photo-viewer{background:#0b0b0bed!important;color:#f5f5f5!important;--ct-fg:#f5f5f5;--ct-muted:#c6c6c6;--ct-button:#414141;--ct-raised:#292929;--ct-on-primary:#142133;color-scheme:dark}
html:root:root:root[data-color-theme] body dialog.photo-viewer::backdrop{background:#000b!important}
html:root:root:root[data-color-theme] body dialog.photo-viewer :is(.photo-viewer-tools,.photo-gallery-nav,.photo-source-menu){background:var(--ct-raised)!important;color:var(--ct-fg)!important;border:0!important}
html:root:root:root[data-color-theme] body dialog.photo-viewer .photo-tool-divider{background:#ffffff30!important}
html:root:root:root[data-color-theme] body dialog.photo-viewer input[type=range]{accent-color:var(--ct-primary)}
.theme-personalization{display:grid;gap:28px}.accent-settings{display:grid;gap:16px}.accent-settings h3{margin:0;font-size:17px;font-weight:600}.accent-swatches{display:flex;align-items:center;gap:14px;flex-wrap:wrap}
html:root:root:root[data-color-theme] body dialog.modal button.accent-swatch{display:grid;place-items:center;width:48px;height:48px;min-width:48px;padding:0;border:0!important;border-radius:50%!important;background:var(--swatch)!important;color:#142133!important;font-size:24px;line-height:1;box-shadow:none!important;transition:transform .18s ease}
.accent-swatch:active{transform:scale(.92)}
/* A single accessible button covers the entire event card, including its padding. */
.schedule-change-card{position:relative;isolation:isolate}
.schedule-change-card-main::after{content:"";position:absolute;inset:0;border-radius:inherit}
.schedule-change-card>button.icon-button{position:relative;z-index:2;margin-inline-end:4px}
.schedule-change-card:has(.schedule-change-card-main:focus-visible){outline:2px solid var(--ct-primary);outline-offset:3px}
.class-audit-list{gap:3px!important}.class-audit-list>article{border-radius:6px!important}.class-audit-list>article:first-of-type{border-start-start-radius:28px!important;border-start-end-radius:28px!important}.class-audit-list>article:last-of-type{border-end-start-radius:28px!important;border-end-end-radius:28px!important}

html:root:root:root[data-color-theme] body :is(dialog.modal,dialog.textbook-mobile-reader) .time-field{background:var(--ct-input)!important;border:0!important;box-shadow:none!important;color:var(--ct-fg)!important}
html:root:root:root[data-color-theme] body :is(dialog.modal,dialog.textbook-mobile-reader) .time-field input{background:transparent!important}
html:root:root:root[data-color-theme] body :is(dialog.modal,dialog.textbook-mobile-reader) :is(.task-card.is-completed,.homework-unit.is-completed,.quick-card.saved){background:color-mix(in srgb,var(--ct-card) 82%,#239c70)!important}
html:root:root:root[data-color-theme] body :is(dialog.modal,dialog.textbook-mobile-reader) .quick-card.unknown-homework-saved{background:color-mix(in srgb,var(--ct-card) 82%,#438cca)!important}

html:root:root:root[data-color-theme] body dialog.modal .dated-schedule{background:transparent!important}
html:root:root:root[data-color-theme] body dialog.modal .dated-schedule-frame{background:var(--ct-bg)!important;border-radius:28px!important;overflow:hidden}
html:root:root:root[data-color-theme] body dialog.modal .scroll-line{background:color-mix(in srgb,var(--ct-fg) 30%,transparent)!important}
html:root:root:root[data-color-theme] body dialog.modal .avatar-edit-badge{background:var(--ct-button)!important;color:var(--ct-fg)!important}

html:root:root:root[data-color-theme] body :is(dialog.modal,dialog.textbook-mobile-reader) .textbook-page-jump{background:transparent!important;border:0!important;box-shadow:none!important}
html:root:root:root[data-color-theme] body :is(dialog.modal,dialog.textbook-mobile-reader){--textbook-controls:var(--ct-card);--textbook-button:var(--ct-button)}
html:root:root:root[data-color-theme] body dialog.modal .accent-swatches button.accent-swatch[aria-pressed]{background:var(--swatch)!important;color:#142133!important}
@media(prefers-reduced-motion:no-preference){html[data-color-theme] :is(dialog.modal,dialog.textbook-mobile-reader),html[data-color-theme] dialog.modal :is(.settings-menu-row,.modal-heading,.schedule-change-card,.dated-schedule-lesson){transition:background-color .18s ease,color .18s ease}}

html[data-color-theme]{--ct-danger-bg:#4b2934;--ct-danger-fg:#ffbcc7;--ct-warning-bg:#453d29;--ct-warning-fg:#f1d78f}
html[data-color-theme=light]{--ct-danger-bg:#f3d9df;--ct-danger-fg:#84283c;--ct-warning-bg:#f1e4bb;--ct-warning-fg:#655015}
html:root:root:root[data-color-theme] body dialog.modal :is(button.danger-button,.change-action-delete){background:var(--ct-danger-bg)!important;color:var(--ct-danger-fg)!important}
html:root:root:root[data-color-theme] body dialog.modal :is(.change-action-move,.change-action-pick){background:var(--ct-selected)!important;color:var(--ct-fg)!important}
html:root:root:root[data-color-theme] body dialog.modal .change-action-replace{background:var(--ct-warning-bg)!important;color:var(--ct-warning-fg)!important}

.quick-card:not(.is-editing){cursor:pointer}
html:root:root:root[data-color-theme] body dialog.photo-viewer input.photo-zoom-range{background:var(--ct-button)!important}
html:root:root:root[data-color-theme] body dialog.photo-viewer input.photo-zoom-range::-webkit-slider-thumb{background:var(--ct-primary)!important;border:0!important;box-shadow:none!important}
html:root:root:root[data-color-theme] body dialog.photo-viewer input.photo-zoom-range::-moz-range-thumb{background:var(--ct-primary)!important;border:0!important;box-shadow:none!important}

html:root:root:root[data-color-theme] body dialog.modal .sheet-handle{background:var(--ct-panel)!important;color:var(--ct-muted)!important;box-shadow:none!important}
html:root:root:root[data-color-theme] body dialog.modal .sheet-handle::after{background:var(--ct-muted)!important}
html:root:root:root[data-color-theme] body dialog.cabinet-modal > :is(.modal-heading,.modal-scroll),html:root:root:root[data-color-theme] body dialog.cabinet-modal > .modal-scroll > .scroll-viewport{background:var(--ct-bg)!important}

html:root:root:root[data-color-theme] body dialog.modal .color-theme-card.is-selected .color-theme-indicator{background:var(--ct-primary)!important}

/* Small metadata badges stay beside their label, with the selected accent. */
.theme-beta-heading,.theme-option-name{display:inline-flex!important;align-items:center;gap:6px;flex-wrap:wrap;min-width:0}
html:root:root:root:root[data-color-theme] body dialog.modal span.theme-beta-badge{display:inline-flex!important;align-items:center;justify-content:center;flex:none;padding:3px 6px;border:0;border-radius:999px;background:var(--ct-primary)!important;color:var(--ct-on-primary)!important;font-size:10px!important;font-weight:700;line-height:1;letter-spacing:.35px;white-space:nowrap;vertical-align:middle}
html:root:root:root[data-color-theme] body dialog.modal .color-theme-indicator{color:var(--ct-on-primary)!important;display:grid;place-items:center}
.theme-selection-check{display:block;flex:none}

/* Changed days keep the same visible gaps between independent lesson cards. */
html:root:root:root[data-color-theme] body dialog.modal .dated-schedule-day,html:root:root:root[data-color-theme] body dialog.modal .dated-schedule-day.has-day-change{background:transparent!important;gap:3px}

/* Stable history toolbar: three filters, an always open search, then close. */
html body dialog.modal.subject-history-modal .subject-history-toolbar{display:grid;grid-template-columns:auto minmax(0,1fr);align-items:center;gap:12px;padding-block:10px;border-radius:22px;isolation:isolate}
html body dialog.modal.subject-history-modal .subject-history-filters{grid-column:1;justify-self:start;gap:6px;padding:0!important}
html body dialog.modal.subject-history-modal .subject-history-actions{grid-column:2;display:grid;grid-template-columns:minmax(0,1fr) 40px;align-items:center;gap:10px;width:100%;min-width:0}
html:root:root:root[data-color-theme] body dialog.subject-history-modal .subject-history-search{position:static;transform:none;width:100%;min-width:0;max-width:none;flex:1;display:flex;gap:0;overflow:hidden;border:0;border-radius:999px!important;background:var(--ct-input)!important}
html body dialog.modal.subject-history-modal .subject-history-search :is(input,input:hover,input:focus){display:block!important;flex:1;width:100%!important;min-width:0!important;max-width:none!important;padding:10px 14px!important;opacity:1!important;transition:none!important;border-radius:999px!important}
html:root:root:root[data-color-theme] body dialog.subject-history-modal .subject-history-search button{background:transparent!important;color:var(--ct-fg)!important;border-radius:50%!important;flex:none}
html body dialog.modal.subject-history-modal .subject-history-close{position:static!important;left:auto!important;right:auto!important;transform:none!important;grid-column:auto;justify-self:end;margin:0!important}
@media(max-width:480px){html body dialog.modal.subject-history-modal .subject-history-toolbar{grid-template-columns:minmax(0,1fr) 40px;gap:8px}html body dialog.modal.subject-history-modal .subject-history-filters{grid-column:1;grid-row:1}html body dialog.modal.subject-history-modal .subject-history-actions{display:contents}html body dialog.modal.subject-history-modal .subject-history-close{grid-column:2;grid-row:1}html body dialog.modal.subject-history-modal .subject-history-search{grid-column:1/-1;grid-row:2}}
/* Book controls share a palette, including links, menus and mobile-only surfaces. */
html:root:root:root[data-color-theme] body :is(dialog.modal,dialog.textbook-mobile-reader) :is(.textbook-warning-toggle,.textbook-delete-confirm,.textbook-group-options,.textbook-group-option,.textbook-context-menu){background:var(--ct-card)!important;color:var(--ct-fg)!important;border:0!important;border-radius:20px}
html:root:root:root[data-color-theme] body :is(dialog.modal,dialog.textbook-mobile-reader) :is(.textbook-mobile-status,.textbook-loading,.textbook-edition-warning,.textbook-reader-warning){color:var(--ct-fg)!important}
html:root:root:root[data-color-theme] body :is(dialog.modal,dialog.textbook-mobile-reader) .textbook-loading svg{color:var(--ct-primary)!important}
html:root:root:root[data-color-theme] body :is(dialog.modal,dialog.textbook-mobile-reader) .textbook-inline-jump:not([aria-pressed=true]){background:transparent!important;color:inherit!important;border-radius:8px!important}
html:root:root:root[data-color-theme] body :is(dialog.modal,dialog.textbook-mobile-reader) .textbook-reference-jumps button{border-radius:999px!important}
html:root:root:root[data-color-theme] body :is(dialog.modal,dialog.textbook-mobile-reader) :is(.textbook-cover,.textbook-group-cover){overflow:hidden;border-radius:20px!important;background:var(--ct-card)!important}
html:root:root:root[data-color-theme] body :is(dialog.modal,dialog.textbook-mobile-reader) .textbook-context-menu button{border-radius:14px!important}
html:root:root:root[data-color-theme] body :is(dialog.modal,dialog.textbook-mobile-reader) .textbook-page-jump{border-radius:999px!important;overflow:hidden}
html:root:root:root[data-color-theme] body :is(dialog.modal,dialog.textbook-mobile-reader) .textbook-reader>a{border-radius:999px!important;background:var(--ct-button)!important;color:var(--ct-fg)!important}
html:root:root:root[data-color-theme] body dialog.textbook-mobile-reader .textbook-mobile-bar{display:grid;grid-template-columns:auto minmax(0,1fr) 42px;gap:6px}
html:root:root:root[data-color-theme] body dialog.textbook-mobile-reader .textbook-mobile-count{grid-column:1;grid-row:1}
html:root:root:root[data-color-theme] body dialog.textbook-mobile-reader .textbook-page-jump{grid-column:2;grid-row:1;justify-self:end;min-width:0}
html:root:root:root[data-color-theme] body dialog.textbook-mobile-reader .textbook-mobile-close{grid-column:3;grid-row:1;display:grid;place-items:center;justify-self:end;flex:none;border-radius:50%!important;padding:0!important;left:auto!important;right:0}

.color-theme-grid{grid-template-columns:repeat(2,minmax(0,1fr))}
.theme-preview-custom{--preview-bg:#1e283b;--preview-surface:#35445d;--preview-icon:#1e283b;--preview-line:#bed4f3;--preview-caption:#29374e;--preview-fg:#edf4ff;--preview-selected:#b6d2fa;--preview-on:#18314d}
.color-theme-card.theme-preview-custom .color-theme-preview{position:relative;padding:0;overflow:hidden}
.custom-preview-stripes{position:absolute;inset:0;display:grid;grid-template-columns:repeat(5,minmax(0,1fr))}
.custom-preview-slice{position:relative;overflow:hidden;background:var(--preview-bg)}
.custom-preview-scene{position:absolute;top:0;bottom:0;left:calc(var(--slice) * -100%);width:500%;display:grid;place-items:center;box-sizing:border-box;padding:20px 14px}
.custom-preview-scene .preview-surface{width:100%;max-width:100%}
@media(max-width:480px){.theme-preview-custom .theme-option-name{font-size:13px}.theme-preview-custom .color-theme-caption{align-items:flex-start}.custom-preview-scene{padding:18px 12px}}

html body dialog.modal .settings-menu-row>.settings-type-icon{display:inline-flex!important;align-items:center;justify-content:center;flex:0 0 22px!important;width:22px;font-size:21px!important;font-weight:500;line-height:1;letter-spacing:-1px}
html body dialog.modal .color-theme-card{display:flex;flex-direction:column;align-items:stretch}
.color-theme-card .color-theme-preview{flex:none}
.color-theme-card .color-theme-caption{flex:1}
html:root:root:root[data-color-theme] body dialog.modal .task-card-content,html:root:root:root[data-color-theme] body dialog.modal .task-card-heading{background:transparent!important;background-image:none!important;box-shadow:none!important}
