/* Shared dark palette and portal controls. Screen-only rules preserve printing. */
@media screen {
    html:is([data-tems-portal="student"],[data-tems-portal="instructor"],[data-tems-portal="public"])[data-tems-theme="dark"] {
        color-scheme: dark;
        --tems-color-black: #f1f5f9;
        --tems-color-heading: #f1f5f9;
        --tems-color-text: #e2e8f0;
        --tems-color-muted: #b0bdd0;
        --tems-background: #0b1220;
        --tems-surface: #162033;
        --tems-surface-subtle: #1c293d;
        --tems-surface-blue: #1c2e49;
        --tems-border: #3c4d65;
        --tems-border-strong: #65758e;
        --tems-sidebar-start: #0b1220;
        --tems-sidebar-end: #111b2d;
        --tems-color-red-soft: #38202c;
        --tems-success-text: #86efac;
        --tems-success-bg: #123428;
        --tems-success-border: #317456;
        --tems-warning-text: #fcd34d;
        --tems-warning-bg: #382d17;
        --tems-warning-border: #927537;
        --tems-danger-text: #fda4af;
        --tems-danger-bg: #3b2030;
        --tems-danger-border: #995365;
        --tems-info-text: #93c5fd;
        --tems-info-bg: #1c2e49;
        --tems-info-border: #496c98;
        --tems-disabled-bg: #263246;
        --tems-dialog-backdrop: rgba(0, 0, 0, .72);
        --tems-shadow-sm: 0 8px 18px rgba(0, 0, 0, .18);
        --tems-shadow-md: 0 10px 25px rgba(0, 0, 0, .24);
        --tems-shadow-lg: 0 18px 35px rgba(0, 0, 0, .3);
        --tems-focus-ring: 0 0 0 3px rgba(147, 197, 253, .35);
        --tems-link: #93c5fd;
    }

    html[data-tems-theme-enabled] :is(#studentSidebar,#instructorSidebar) :is(.student-theme-control,.instructor-theme-control) {
        margin: 0 0 20px;
        padding: 14px;
        border: 1px solid rgba(255, 255, 255, .22);
        border-radius: 14px;
        background: rgba(255, 255, 255, .05);
        color: #f1f5f9;
    }

    html[data-tems-theme-enabled] :is(#studentSidebar,#instructorSidebar) :is(.student-theme-control,.instructor-theme-control) label {
        display: block;
        margin: 0 0 9px;
        color: #f1f5f9;
        font: 700 13px/1.3 var(--tems-font-body);
    }

    html[data-tems-theme-enabled] :is(#studentSidebar,#instructorSidebar) :is(#student-theme-mode,#instructor-theme-mode) {
        display: block;
        width: 100%;
        min-width: 0;
        min-height: 44px;
        padding: 10px 12px;
        border: 1px solid #65758e;
        border-radius: 10px;
        background: #1c293d;
        color: #f1f5f9;
        font: 600 14px/1.3 var(--tems-font-body);
        color-scheme: dark;
        cursor: pointer;
    }

    html[data-tems-theme-enabled] :is(#studentSidebar,#instructorSidebar) :is(#student-theme-mode,#instructor-theme-mode):focus-visible {
        outline: 3px solid #93c5fd;
        outline-offset: 3px;
    }

    html:is([data-tems-portal="student"],[data-tems-portal="instructor"])[data-tems-theme="dark"] body.tems-components:is(.tems-student-theme,.tems-instructor-theme) :is(a,button,input,select,textarea,summary):focus-visible {
        outline-color: var(--tems-link);
    }

    html:is([data-tems-portal="student"],[data-tems-portal="instructor"])[data-tems-theme="dark"] body.tems-components:is(.tems-student-theme,.tems-instructor-theme) :is(input,textarea)::placeholder {
        color: var(--tems-color-muted);
        opacity: .85;
    }

    html:is([data-tems-portal="student"],[data-tems-portal="instructor"])[data-tems-theme="dark"] body.tems-components:is(.tems-student-theme,.tems-instructor-theme) :is(.collapse-toggle-label,.collapse-word-toggle) {
        background: var(--tems-surface-subtle);
        border-color: var(--tems-border-strong);
        color: var(--tems-link);
    }

    html:is([data-tems-portal="student"],[data-tems-portal="instructor"])[data-tems-theme="dark"] body.tems-components:is(.tems-student-theme,.tems-instructor-theme) summary:hover > .collapse-toggle-label {
        background: var(--tems-surface-blue);
    }

    html:is([data-tems-portal="student"],[data-tems-portal="instructor"])[data-tems-theme="dark"] body.tems-components:is(.tems-student-theme,.tems-instructor-theme) :is(.portal-topbar.unified-topbar,.student-bottom-nav) {
        background: var(--tems-surface);
        border-color: var(--tems-border);
        box-shadow: var(--tems-shadow-md);
    }

}
