:root {
    color-scheme: only light;

    /*
     * Shared semantic color system.
     *
     * Keep literal UI colors in this palette and consume the variables from
     * application styles. Code syntax colors are also centralized here so
     * light and dark themes can express different, accessible visual voices.
     */
    --theme-bg: #ffffff;
    --theme-surface: #ffffff;
    --theme-surface-muted: #f6f8fa;
    --theme-surface-hover: #eef1f4;
    --theme-surface-active: #dddddd;
    --theme-text: #000000;
    --theme-text-strong: #1f2328;
    --theme-text-muted: #555555;
    --theme-text-secondary: #59636e;
    --theme-text-subtle: #8c959f;
    --theme-text-disabled: #afb8c1;
    --theme-text-on-accent: #ffffff;
    --theme-border: #000000;
    --theme-border-muted: #a0a0a0;
    --theme-border-soft: #d0d7de;
    --theme-border-subtle: #d8dee4;
    --theme-border-dotted: #b8b8b8;
    --theme-divider-strong: #000000;
    --theme-divider-standard: #8c959f;
    --theme-divider-soft: #d0d7de;
    --theme-divider-dotted: #8c959f;
    --theme-control-border: #d0d7de;
    --theme-input-border: #8c959f;
    --theme-link: #173f5f;
    --theme-link-hover: #6b3f2a;
    --theme-link-visited: #5e3b62;
    --theme-recruitment-gradient: linear-gradient(
        90deg,
        #9d2235 0%,
        #874500 14%,
        #5a6200 29%,
        #006142 43%,
        #0058a8 57%,
        #4532a0 71%,
        #7c2d83 86%,
        #9d2235 100%
    );
    --theme-recruitment-glow: rgb(157 34 53 / 36%);
    --theme-primary-action: #173f5f;
    --theme-primary-action-hover: #102f48;
    --theme-primary-action-text: #ffffff;
    --theme-positive-action: #1f6b3a;
    --theme-positive-action-hover: #185c34;
    --theme-positive-action-text: #ffffff;
    --theme-caution-action: #9a4f00;
    --theme-caution-action-hover: #7a3f00;
    --theme-caution-action-text: #ffffff;
    --theme-focus-ring: #174f78;
    --theme-admin-menu-border: #8b3f2f;
    --theme-accent-surface: rgba(23, 63, 95, 0.04);
    --theme-accent-surface-strong: rgba(23, 63, 95, 0.11);
    --theme-accent-hover: #edf2f6;
    --theme-overlay: rgba(0, 0, 0, 0.28);
    --theme-overlay-soft: rgba(0, 0, 0, 0.2);
    --theme-overlay-strong: rgba(0, 0, 0, 0.72);
    --theme-shadow: rgba(0, 0, 0, 0.3);
    --theme-success: #1f6b3a;
    --theme-success-bg: #e3eee4;
    --theme-reservation-slot-available: #bcff66;
    --theme-reservation-slot-available-text: #000000;
    --theme-reservation-slot-booked: #1eddff;
    --theme-reservation-slot-booked-text: #000000;
    --theme-info: #1d5d86;
    --theme-error-bg: #eee5df;
    --theme-error-surface: #f4e5e3;
    --theme-error-text: #8b1e2d;
    --theme-critical-text: #751725;
    --theme-warning-bg: #173f5f;
    --theme-warning-text: #ffffff;
    --theme-control-bg: #ffffff;
    --theme-control-muted-bg: #f6f8fa;
    --theme-control-hover: #ececec;
    --theme-control-active: #dddddd;
    --theme-control-disabled-bg: #d0d0d0;
    --theme-control-disabled-text: #6b6b6b;
    --theme-button-bg: #dcdcdc;
    --theme-button-hover: #cfcfcf;
    --theme-secondary-button-bg: #ffffff;
    --theme-secondary-button-border: #d0d7de;
    --theme-secondary-button-border-hover: #afb8c1;
    --theme-sidebar-toggle-bg: #ececec;
    --theme-sidebar-toggle-hover: #dddddd;
    --theme-calendar-disabled: #d4d4d4;
    --theme-slot-unavailable-text: #b5b5b5;
    --theme-calendar-border: #6e7781;
    --theme-unavailable-bg: #ececec;
    --theme-mark-bg: #f2e2b8;
    --theme-mark-text: #5d3a1a;
    --theme-media-bg: #000000;
    --theme-media-stage-bg: #ffffff;
    --theme-media-control-border: rgba(255, 255, 255, 0.9);
    --theme-presentation-laser-star: #159fe8;
    --theme-presentation-laser-glow-near-rgb: 76 203 255;
    --theme-presentation-laser-glow-bright-rgb: 221 247 255;
    --theme-presentation-laser-glow-far-rgb: 14 139 226;
    --theme-presentation-laser-particle-1-rgb: 243 253 255;
    --theme-presentation-laser-particle-2-rgb: 255 218 74;
    --theme-presentation-laser-particle-3-rgb: 255 154 61;
    --theme-presentation-laser-particle-4-rgb: 91 216 117;
    --theme-presentation-laser-star-yellow: #ffda4a;
    --theme-presentation-laser-star-yellow-glow-near-rgb: 255 218 74;
    --theme-presentation-laser-star-yellow-glow-bright-rgb: 255 246 182;
    --theme-presentation-laser-star-yellow-glow-far-rgb: 242 177 19;
    --theme-presentation-laser-star-orange: #ff9a3d;
    --theme-presentation-laser-star-orange-glow-near-rgb: 255 173 82;
    --theme-presentation-laser-star-orange-glow-bright-rgb: 255 233 194;
    --theme-presentation-laser-star-orange-glow-far-rgb: 238 116 20;
    --theme-presentation-laser-star-green: #5bd875;
    --theme-presentation-laser-star-green-glow-near-rgb: 97 223 126;
    --theme-presentation-laser-star-green-glow-bright-rgb: 202 255 209;
    --theme-presentation-laser-star-green-glow-far-rgb: 32 172 71;
    --theme-presentation-laser-gloss-rgb: 255 255 255;
    --theme-presentation-laser-gloss-opacity: 0.96;
    --theme-code-bg: #f7f1e7;
    --theme-code-header-bg: #eee5d7;
    --theme-code-text: #17243a;
    --theme-code-editor-text: #17243a;
    --theme-code-border: #9b8668;
    --theme-code-popup-bg: #fffaf2;
    --theme-code-popup-border: #9b8668;
    --theme-code-popup-hover: #ede3d6;
    --theme-code-selection-bg: rgba(23, 63, 95, 0.22);
    --theme-code-syntax-comment: #435348;
    --theme-code-syntax-control-keyword: #6b2747;
    --theme-code-syntax-keyword: #173f5f;
    --theme-code-syntax-type: #07504c;
    --theme-code-syntax-function: #4c2f70;
    --theme-code-syntax-attribute: #234f72;
    --theme-code-syntax-variable: #5d3a1a;
    --theme-code-syntax-constant: #184f6b;
    --theme-code-syntax-label: #243447;
    --theme-code-syntax-tag: #173f5f;
    --theme-code-syntax-number: #624500;
    --theme-code-syntax-string: #7b341e;
    --theme-code-syntax-escape: #6a3f00;
    --theme-code-syntax-interpolation: #173f5f;
    --theme-code-syntax-regex: #7a2340;
    --theme-code-syntax-operator: #17243a;
    --theme-code-syntax-word-operator: #173f5f;
    --theme-code-syntax-error: #8b1e2d;
    --theme-code-syntax-deleted: #8b1e2d;
    --theme-code-syntax-inserted: #185c34;
    --theme-code-syntax-heading: #173f5f;
    --theme-code-syntax-emphasis: #6b2747;
    --theme-code-syntax-strong: #17243a;
    --theme-code-syntax-muted: #46515c;
    --theme-assist-ghost-text: rgba(75, 85, 99, 0.72);
    --theme-assist-key-border: rgba(107, 114, 128, 0.35);
    --theme-assist-key-bg: rgba(243, 244, 246, 0.86);
    --theme-assist-key-text: #6b7280;
    --theme-inline-code-bg: #f1e7d8;
    --theme-inline-code-hover-bg: #e8d8c4;
    --theme-inline-code-text: #5d3a1a;
    --theme-scrollbar-track: rgb(31 35 40 / 0.06);
    --theme-scrollbar-thumb: rgb(31 35 40 / 0.52);
    --theme-scrollbar-thumb-hover: rgb(31 35 40 / 0.64);
    --theme-scrollbar-thumb-active: rgb(31 35 40 / 0.74);

    /* Printing is intentionally stable and light regardless of screen theme. */
    --theme-print-bg: #ffffff;
    --theme-print-surface-muted: #f6f8fa;
    --theme-print-surface-hover: #eef1f4;
    --theme-print-surface-active: #dddddd;
    --theme-print-text: #000000;
    --theme-print-text-strong: #1f2328;
    --theme-print-text-muted: #555555;
    --theme-print-text-secondary: #59636e;
    --theme-print-text-subtle: #8c959f;
    --theme-print-border: #000000;
    --theme-print-border-muted: #a0a0a0;
    --theme-print-border-soft: #d0d7de;
    --theme-print-border-subtle: #d8dee4;
    --theme-print-divider-standard: #8c959f;
    --theme-print-link: #173f5f;
    --theme-print-link-hover: #6b3f2a;
    --theme-print-link-visited: #5e3b62;
    --theme-print-code-bg: #f7f1e7;
    --theme-print-code-header-bg: #eee5d7;
    --theme-print-code-text: #17243a;
    --theme-print-code-border: #9b8668;
    --theme-print-code-comment: #435348;
    --theme-print-code-control-keyword: #6b2747;
    --theme-print-code-keyword: #173f5f;
    --theme-print-code-type: #07504c;
    --theme-print-code-function: #4c2f70;
    --theme-print-code-attribute: #234f72;
    --theme-print-code-variable: #5d3a1a;
    --theme-print-code-constant: #184f6b;
    --theme-print-code-label: #243447;
    --theme-print-code-number: #624500;
    --theme-print-code-string: #7b341e;
    --theme-print-code-escape: #6a3f00;
    --theme-print-code-regex: #7a2340;
    --theme-print-code-error: #8b1e2d;
    --theme-print-code-muted: #46515c;
    --theme-print-inline-code-bg: #f1e7d8;
    --theme-print-inline-code-text: #5d3a1a;
}

html[data-theme="dark"] {
    --theme-bg: #0d1117;
    --theme-surface: #161b22;
    --theme-surface-muted: #21262d;
    --theme-surface-hover: #30363d;
    --theme-surface-active: #30363d;
    --theme-text: #e6edf3;
    --theme-text-strong: #f0f6fc;
    --theme-text-muted: #8b949e;
    --theme-text-secondary: #8b949e;
    --theme-text-subtle: #8c959f;
    --theme-text-disabled: #6e7681;
    --theme-text-on-accent: #07131d;
    --theme-border: #ffffff;
    --theme-border-muted: #30363d;
    --theme-border-soft: #30363d;
    --theme-border-subtle: #30363d;
    --theme-border-dotted: #b8b8b8;
    --theme-divider-strong: #ffffff;
    --theme-divider-standard: #484f58;
    --theme-divider-soft: #30363d;
    --theme-divider-dotted: #6e7681;
    --theme-control-border: #d0d7de;
    --theme-input-border: #6e7681;
    --theme-link: #00d9ff;
    --theme-link-hover: #66edff;
    --theme-link-visited: #65ffb1;
    --theme-recruitment-gradient: linear-gradient(
        90deg,
        #ff5c7a 0%,
        #ff9d2e 14%,
        #ffe600 29%,
        #39ff88 43%,
        #00d9ff 57%,
        #7da8ff 71%,
        #ff4fd8 86%,
        #ff5c7a 100%
    );
    --theme-recruitment-glow: rgb(255 230 0 / 58%);
    --theme-primary-action: #007fa3;
    --theme-primary-action-hover: #006f8f;
    --theme-primary-action-text: #ffffff;
    --theme-positive-action: #0b843d;
    --theme-positive-action-hover: #097535;
    --theme-positive-action-text: #ffffff;
    --theme-caution-action: #b65700;
    --theme-caution-action-hover: #8f4500;
    --theme-caution-action-text: #ffffff;
    --theme-focus-ring: #00d9ff;
    --theme-admin-menu-border: #00d9ff;
    --theme-accent-surface: rgba(0, 217, 255, 0.06);
    --theme-accent-surface-strong: rgba(0, 217, 255, 0.16);
    --theme-accent-hover: #0a2d3b;
    --theme-overlay: rgba(0, 0, 0, 0.68);
    --theme-overlay-soft: rgba(0, 0, 0, 0.22);
    --theme-overlay-strong: rgba(0, 0, 0, 0.72);
    --theme-shadow: rgba(0, 0, 0, 0.35);
    --theme-success: #39ff88;
    --theme-success-bg: #123522;
    --theme-reservation-slot-available: #6ed746;
    --theme-reservation-slot-available-text: #000000;
    --theme-reservation-slot-booked: #0078ff;
    --theme-reservation-slot-booked-text: #000000;
    --theme-info: #00d9ff;
    --theme-error-bg: #3a1722;
    --theme-error-surface: #3a1722;
    --theme-error-text: #ff5c7a;
    --theme-critical-text: #ff7a92;
    --theme-warning-bg: #007fa3;
    --theme-warning-text: #ffffff;
    --theme-control-bg: #161b22;
    --theme-control-muted-bg: #21262d;
    --theme-control-hover: #30363d;
    --theme-control-active: #30363d;
    --theme-control-disabled-bg: #21262d;
    --theme-control-disabled-text: #6e7681;
    --theme-button-bg: #161b22;
    --theme-button-hover: #30363d;
    --theme-secondary-button-bg: #21262d;
    --theme-secondary-button-border: #484f58;
    --theme-secondary-button-border-hover: #6e7681;
    --theme-sidebar-toggle-bg: #484f58;
    --theme-sidebar-toggle-hover: #59636e;
    --theme-calendar-disabled: #6e7681;
    --theme-slot-unavailable-text: #8b949e;
    --theme-calendar-border: #21262d;
    --theme-unavailable-bg: #21262d;
    --theme-mark-bg: #3a3600;
    --theme-mark-text: #ffe600;
    --theme-media-bg: #000000;
    --theme-media-stage-bg: #000000;
    --theme-media-control-border: rgba(255, 255, 255, 0.9);
    --theme-presentation-laser-star: #ffe45c;
    --theme-presentation-laser-glow-near-rgb: 255 227 76;
    --theme-presentation-laser-glow-bright-rgb: 255 246 157;
    --theme-presentation-laser-glow-far-rgb: 255 188 36;
    --theme-presentation-laser-particle-1-rgb: 255 255 244;
    --theme-presentation-laser-particle-2-rgb: 255 246 157;
    --theme-presentation-laser-particle-3-rgb: 255 226 82;
    --theme-presentation-laser-particle-4-rgb: 255 188 36;
    --theme-presentation-laser-star-yellow: #ffe45c;
    --theme-presentation-laser-star-yellow-glow-near-rgb: 255 227 76;
    --theme-presentation-laser-star-yellow-glow-bright-rgb: 255 246 157;
    --theme-presentation-laser-star-yellow-glow-far-rgb: 255 188 36;
    --theme-presentation-laser-star-orange: #ffe45c;
    --theme-presentation-laser-star-orange-glow-near-rgb: 255 227 76;
    --theme-presentation-laser-star-orange-glow-bright-rgb: 255 246 157;
    --theme-presentation-laser-star-orange-glow-far-rgb: 255 188 36;
    --theme-presentation-laser-star-green: #ffe45c;
    --theme-presentation-laser-star-green-glow-near-rgb: 255 227 76;
    --theme-presentation-laser-star-green-glow-bright-rgb: 255 246 157;
    --theme-presentation-laser-star-green-glow-far-rgb: 255 188 36;
    --theme-presentation-laser-gloss-rgb: 255 255 255;
    --theme-presentation-laser-gloss-opacity: 0;
    --theme-code-bg: #071827;
    --theme-code-header-bg: #0b2238;
    --theme-code-text: #e6edf3;
    --theme-code-editor-text: #b8c0cc;
    --theme-code-border: #3d6074;
    --theme-code-popup-bg: #0b2238;
    --theme-code-popup-border: #3d6074;
    --theme-code-popup-hover: #123447;
    --theme-code-selection-bg: rgba(0, 217, 255, 0.28);
    --theme-code-syntax-comment: #39ff88;
    --theme-code-syntax-control-keyword: #ff4fd8;
    --theme-code-syntax-keyword: #00d9ff;
    --theme-code-syntax-type: #00ffd5;
    --theme-code-syntax-function: #ffe600;
    --theme-code-syntax-attribute: #67e8ff;
    --theme-code-syntax-variable: #67e8ff;
    --theme-code-syntax-constant: #00d9ff;
    --theme-code-syntax-label: #f5f7fa;
    --theme-code-syntax-tag: #00d9ff;
    --theme-code-syntax-number: #baff29;
    --theme-code-syntax-string: #ff9d2e;
    --theme-code-syntax-escape: #fff200;
    --theme-code-syntax-interpolation: #00d9ff;
    --theme-code-syntax-regex: #ff5c7a;
    --theme-code-syntax-operator: #f5f7fa;
    --theme-code-syntax-word-operator: #00d9ff;
    --theme-code-syntax-error: #ff5c7a;
    --theme-code-syntax-deleted: #ff5c7a;
    --theme-code-syntax-inserted: #39ff88;
    --theme-code-syntax-heading: #00d9ff;
    --theme-code-syntax-emphasis: #ff4fd8;
    --theme-code-syntax-strong: #f5f7fa;
    --theme-code-syntax-muted: #b8c7d6;
    --theme-assist-ghost-text: rgba(139, 148, 158, 0.86);
    --theme-assist-key-border: rgba(139, 148, 158, 0.4);
    --theme-assist-key-bg: rgba(33, 38, 45, 0.9);
    --theme-assist-key-text: #8b949e;
    --theme-inline-code-bg: #123447;
    --theme-inline-code-hover-bg: #18465c;
    --theme-inline-code-text: #67e8ff;
    --theme-scrollbar-track: rgb(240 246 252 / 0.07);
    --theme-scrollbar-thumb: rgb(240 246 252 / 0.4);
    --theme-scrollbar-thumb-hover: rgb(240 246 252 / 0.54);
    --theme-scrollbar-thumb-active: rgb(240 246 252 / 0.66);

    --nav-bg-color: var(--theme-bg);
    --nav-border-bottom-color: var(--theme-divider-strong);
    --nav-font-color: var(--theme-text);
    --nav-font-color-hover: var(--theme-text);
    --toggle-font-color: var(--theme-text);
    --dropdown-bg-color: var(--theme-surface);
    --main-bg-color: var(--theme-bg);
    --main-font-color: var(--theme-text);
    --footer-bg-color: var(--theme-bg);
    --footer-font-color: var(--theme-text);
    --footer-boundary-color: var(--theme-divider-strong);
    --box-blue: var(--theme-primary-action);
}

body {
    background: var(--theme-bg);
    color: var(--theme-text);
}

/* Keep document and nested overflow areas visually quiet without hiding them. */
html,
body,
:where(*) {
    scrollbar-color: var(--theme-scrollbar-thumb) var(--theme-scrollbar-track);
    scrollbar-width: thin;
}

:where(*)::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

:where(*)::-webkit-scrollbar-track {
    background: var(--theme-scrollbar-track);
    border-radius: 999px;
}

:where(*)::-webkit-scrollbar-thumb {
    border: 2px solid transparent;
    border-radius: 999px;
    background: var(--theme-scrollbar-thumb);
    background-clip: padding-box;
}

:where(*)::-webkit-scrollbar-thumb:hover {
    background-color: var(--theme-scrollbar-thumb-hover);
}

:where(*)::-webkit-scrollbar-thumb:active {
    background-color: var(--theme-scrollbar-thumb-active);
}

:where(*)::-webkit-scrollbar-corner {
    background: transparent;
}

.nav-container a,
.nav-container a:visited,
.nav-container a:hover,
.nav-container a:focus-visible {
    color: var(--theme-text);
}

.nav-container .separator {
    color: var(--theme-border);
}

.theme-toggle {
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 24px;
    height: 24px;
    margin: 0;
    padding: var(--type-control-padding-tight);
    border: 0;
    background: transparent;
    color: var(--nav-font-color, var(--theme-text));
    cursor: pointer;
    font-family: inherit;
    font-size: var(--nav-font-size, 15px);
    line-height: 1.3;
    white-space: nowrap;
}

.theme-toggle:hover,
.theme-toggle:focus-visible {
    color: var(--nav-font-color-hover, var(--theme-text));
    background: var(--theme-surface-hover);
    border-radius: 4px;
}

.theme-toggle:focus-visible {
    outline: 2px solid var(--theme-link);
    outline-offset: 3px;
}

.theme-toggle-icon {
    display: block;
    width: 18px;
    height: 18px;
    object-fit: contain;
}

.theme-toggle-sun {
    display: none;
}

html[data-theme="dark"] .theme-toggle-moon {
    display: none;
}

html[data-theme="dark"] .theme-toggle-sun {
    display: inline;
}

html[data-theme="dark"] .theme-toggle-icon {
    filter: invert(1);
}

.theme-toggle-label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

.nav-theme-item {
    display: flex;
    align-items: center;
    margin-right: 8px;
}

@media (max-width: 450px) {
    .nav-theme-item {
        margin-right: 4px;
    }

}

@media (prefers-reduced-motion: no-preference) {
    body,
    .nav-container,
    .nav-dropdown,
    .site-footer,
    .theme-toggle {
        transition: background-color 160ms ease, color 160ms ease, border-color 160ms ease;
    }
}

html[data-theme="dark"] blockquote {
    border-color: var(--theme-border);
}

html[data-theme="dark"] main > section code {
    background-color: var(--theme-code-bg);
    color: var(--theme-code-text);
}

html[data-theme="dark"] #content-window[aria-busy="true"]::before,
html[data-theme="dark"] #biography,
html[data-theme="dark"] #biography *,
html[data-theme="dark"] #biography h4,
html[data-theme="dark"] #biography h4 + p {
    color: var(--theme-text) !important;
}

html[data-theme="dark"] .professor-cv h4,
html[data-theme="dark"] .professor-cv .professor-section-note {
    color: var(--theme-text);
    border-color: var(--theme-border);
}

html[data-theme="dark"] .site-footer-visits {
    color: var(--theme-text-muted) !important;
}

html[data-theme="dark"] .site-footer-auth-link {
    color: var(--theme-text);
}

html[data-theme="dark"] .site-footer-auth-link::before {
    color: var(--theme-text-muted);
}

/* Course, MicroLecture, Resources, and Reservation navigation structures. */
html[data-theme="dark"] .lecture-section {
    --lecture-sidebar-fg: var(--theme-text);
}

html[data-theme="dark"] .microlecture-section {
    --microlecture-sidebar-fg: var(--theme-text);
}

html[data-theme="dark"] .resources-section {
    --resources-sidebar-fg: var(--theme-text);
}

html[data-theme="dark"] :is(
    .microlecture-sidebar-toggle,
    .resources-sidebar-toggle,
    .board-sidebar-toggle
) {
    background: var(--theme-sidebar-toggle-bg);
    color: var(--theme-text);
}

html[data-theme="dark"] :is(
    .microlecture-sidebar-toggle,
    .resources-sidebar-toggle,
    .board-sidebar-toggle
):is(:hover, :focus-visible) {
    background: var(--theme-sidebar-toggle-hover);
}

html[data-theme="dark"] :is(
    .resources-resource-index,
    .resources-home-category-code,
    .resources-home-session-code,
    .resources-home-resource-index,
    .resources-session-count,
    .resources-card-uploaded-at,
    .resources-action-label,
    .resources-description-empty,
    .resources-download-unavailable,
    .resources-no-session,
    .resources-home-empty
) {
    color: var(--theme-text-muted);
}

html[data-theme="dark"] .resources-action-link,
html[data-theme="dark"] .resources-markdown-body a {
    color: var(--theme-link);
}

/* GitHub-style Markdown and Notebook surfaces. */
html[data-theme="dark"] :is(
    .resources-markdown-body,
    .resources-notebook-embed,
    .resources-notebook-cell,
    .resources-notebook-outputs
) {
    background: var(--theme-bg);
    color: var(--theme-text);
}

html[data-theme="dark"] :is(
    .resources-notebook-toolbar,
    .resources-colab-toolbar,
    .resources-notebook-local-files,
    .resources-notebook-cell-heading,
    .resources-notebook-text-output
) {
    background: var(--theme-surface);
    color: var(--theme-text);
}

html[data-theme="dark"] :is(
    .resources-notebook-toolbar-button,
    .resources-notebook-run-cell,
    .resources-notebook-stop-cell,
    .resources-notebook-local-file-button,
    .resources-notebook-remove-local-file
) {
    background: var(--theme-surface);
    color: var(--theme-text);
    border-color: var(--theme-border-soft);
}

html[data-theme="dark"] .resources-colab-runtime-info span {
    color: var(--theme-text-muted);
}

html[data-theme="dark"] .resources-colab-open-link {
    background: var(--theme-surface);
    color: var(--theme-text);
    border-color: var(--theme-border-soft);
}

html[data-theme="dark"] .resources-colab-open-link:is(:hover, :focus-visible) {
    background: var(--theme-surface-hover);
}

html[data-theme="dark"] :is(
    .resources-notebook-toolbar-button,
    .resources-notebook-run-cell,
    .resources-notebook-stop-cell,
    .resources-notebook-local-file-button,
    .resources-notebook-remove-local-file
):not(:disabled):is(:hover, :focus-visible) {
    background: var(--theme-surface-hover);
}

html[data-theme="dark"] :is(
    .resources-notebook-toolbar-button,
    .resources-notebook-run-cell,
    .resources-notebook-stop-cell,
    .resources-notebook-local-file-button,
    .resources-notebook-remove-local-file
):disabled {
    border-color: var(--theme-border-subtle) !important;
    background: var(--theme-surface-muted);
    color: var(--theme-text-disabled);
    cursor: default;
    opacity: 0.5;
}

html[data-theme="dark"] :is(
    .resources-notebook-runtime-status,
    .resources-notebook-local-file-status,
    .resources-notebook-local-file-help,
    .resources-notebook-local-file-size,
    .resources-notebook-status,
    .resources-notebook-cell-label,
    .resources-notebook-output-note,
    .resources-markdown-status,
    .resources-markdown-empty,
    .resources-markdown-body h6,
    .resources-markdown-body blockquote,
    .resources-markdown-body .footnotes
) {
    color: var(--theme-text-muted);
}

html[data-theme="dark"] .resources-markdown-body tr {
    background: var(--theme-bg);
}

html[data-theme="dark"] .resources-markdown-body tr:nth-child(2n) {
    background: var(--theme-surface);
}

html[data-theme="dark"] .resources-markdown-body :not(pre) > code {
    background: var(--theme-inline-code-bg);
    color: var(--theme-inline-code-text);
}

html[data-theme="dark"] .resources-code-block,
html[data-theme="dark"] .resources-code-pre,
html[data-theme="dark"] .resources-notebook-code-editor-surface {
    background: var(--theme-code-bg);
    color: inherit;
}

html[data-theme="dark"] .resources-notebook-code-input {
    background: transparent;
    color: transparent;
    -webkit-text-fill-color: transparent;
}

html[data-theme="dark"] .resources-code-header {
    background: var(--theme-code-header-bg);
}

html[data-theme="dark"] .resources-code-copy-button {
    color: var(--theme-text-strong);
}

html[data-theme="dark"] .resources-code-copy-button:hover,
html[data-theme="dark"] .resources-code-copy-button:focus-visible {
    background: transparent;
}

html[data-theme="dark"] .resources-code-pre code {
    background: transparent;
    color: inherit;
}

html[data-theme="dark"] .resources-notebook-text-output.is-error,
html[data-theme="dark"] .resources-notebook-local-file-status.is-error {
    background: var(--theme-error-bg);
    color: var(--theme-error-text);
}

/* Office Hours and GPU Server reservation interfaces. */
html[data-theme="dark"] .officehours-section {
    --officehours-available-green: var(--theme-reservation-slot-available);
}

html[data-theme="dark"] .serverreservation-section {
    --serverreservation-available-green: var(--theme-reservation-slot-available);
    --serverreservation-unavailable-gray: var(--theme-surface-muted);
}

html[data-theme="dark"] :is(
    .officehours-month-arrow,
    .serverreservation-month-arrow
) {
    color: var(--theme-link);
}

html[data-theme="dark"] :is(
    .officehours-booking-dialog,
    .serverreservation-booking-dialog
) {
    background: var(--theme-surface);
    color: var(--theme-text);
    border-color: var(--theme-border);
}

html[data-theme="dark"] :is(
    .officehours-booking-backdrop,
    .serverreservation-booking-backdrop
) {
    background: var(--theme-overlay);
}

html[data-theme="dark"] :is(
    .officehours-booking-fields input,
    .officehours-booking-fields textarea,
    #officehours-submit-btn,
    #officehours-cancel-submit-btn,
    .serverreservation-maintenance-cancel-btn,
    .serverreservation-maintenance-fields input,
    .serverreservation-maintenance-fields select,
    .serverreservation-maintenance-submit-btn,
    .serverreservation-booking-fields input,
    .serverreservation-booking-fields select,
    .serverreservation-booking-fields textarea,
    .serverreservation-submit-btn,
    .serverreservation-cancel-submit-btn
) {
    background: var(--theme-surface);
    color: var(--theme-text);
    border-color: var(--theme-border);
}

html[data-theme="dark"] :is(
    #officehours-submit-btn,
    #officehours-cancel-submit-btn,
    .serverreservation-maintenance-cancel-btn,
    .serverreservation-maintenance-submit-btn,
    .serverreservation-submit-btn,
    .serverreservation-cancel-submit-btn
):is(:hover, :focus-visible) {
    background: var(--theme-surface-hover);
}

html[data-theme="dark"] :is(
    .officehours-message.success,
    .serverreservation-message.success
) {
    background: var(--theme-success-bg);
}

html[data-theme="dark"] :is(
    .officehours-message.error,
    .serverreservation-message.error
) {
    background: var(--theme-error-bg);
}

html[data-theme="dark"] :is(
    .officehours-slot,
    .serverreservation-slot
) {
    background: var(--theme-surface);
    color: var(--theme-reservation-slot-booked-text);
}

html[data-theme="dark"] :is(
    .officehours-slot.is-unavailable,
    .serverreservation-slot.is-unavailable
) {
    background: var(--theme-surface-muted);
    color: var(--theme-primary-action-text);
}

html[data-theme="dark"] :is(
    .officehours-slot.is-available,
    .serverreservation-slot.is-available
) {
    background: var(--theme-reservation-slot-available);
    color: var(--theme-reservation-slot-available-text);
    opacity: 1;
}

html[data-theme="dark"] :is(
    .officehours-slot.is-booked,
    .serverreservation-slot.is-booked,
    .officehours-dot-booked,
    .serverreservation-dot-booked
) {
    background: var(--theme-reservation-slot-booked);
    color: var(--theme-primary-action-text);
    opacity: 1;
}

html[data-theme="dark"] :is(
    .officehours-slot.is-selected,
    .serverreservation-slot.is-selected
) {
    border-color: var(--theme-text);
}

html[data-theme="dark"] :is(
    .serverreservation-maintenance-hint,
    .serverreservation-duration-hint
) {
    color: var(--theme-text-muted);
}

/* Standalone API usage dashboard. */
.dashboard-theme-toggle {
    position: absolute;
    top: 0;
    right: 0;
}

.usage-dashboard-hero {
    position: relative;
    padding-right: 90px;
}

html[data-theme="dark"] :is(
    .shell,
    .notice,
    .summary > div,
    .card,
    .usage-tooltip
) {
    background: var(--theme-bg);
    color: var(--theme-text);
}

html[data-theme="dark"] :is(
    .hero h1,
    .hero h1 span,
    .notice,
    .notice strong,
    .summary span,
    .card h2,
    .amount,
    .amount strong
) {
    color: var(--theme-text);
}

html[data-theme="dark"] :is(.card, .progress, .usage-tooltip) {
    border-color: var(--theme-border);
}

html[data-theme="dark"] :is(.amount span, .status) {
    color: var(--theme-text-muted);
}

@media (max-width: 550px) {
    .usage-dashboard-hero {
        padding-right: 0;
    }

    .dashboard-theme-toggle {
        position: static;
        margin-top: var(--type-space-compact);
    }
}

@media print {
    .theme-toggle {
        display: none !important;
    }
}

/* Navigation hierarchy text remains equally bright at every dark-mode level. */
html[data-theme="dark"] main :is(
    .resources-category-btn,
    .resources-category-code,
    .resources-category-name,
    .resources-session-btn,
    .resources-session-code,
    .resources-session-title,
    .resources-resource-btn,
    .resources-resource-index,
    .resources-resource-title,
    .resources-home-category-line,
    .resources-home-category-code,
    .resources-home-category-title,
    .resources-home-session-btn,
    .resources-home-session-code,
    .resources-home-session-title,
    .resources-home-resource-btn,
    .resources-home-resource-index,
    .resources-home-resource-title,
    .microlecture-category-btn,
    .microlecture-category-code,
    .microlecture-category-name,
    .microlecture-lecture-btn,
    .microlecture-lecture-code,
    .microlecture-lecture-title,
    .microlecture-home-category-line,
    .microlecture-home-category-index,
    .microlecture-home-category-title,
    .microlecture-home-lecture-btn,
    .microlecture-home-lecture-index,
    .microlecture-home-lecture-title
) {
    color: var(--theme-border);
}

html[data-theme="dark"] main :is(
    .resources-notebook-local-file-name,
    .resources-notebook-local-file-reference
) {
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
}

/* Structural divider aliases stay aligned with the shared divider policy. */
html[data-theme="dark"] {
    --nav-border-bottom-color: var(--theme-divider-strong);
    --footer-boundary-color: var(--theme-divider-strong);
}

/* Interactive notebook controls retain their stronger control boundary. */
html[data-theme="dark"] :is(
    .resources-notebook-toolbar-button,
    .resources-notebook-local-file-button,
    .resources-notebook-remove-local-file,
    .resources-notebook-run-cell,
    .resources-notebook-stop-cell
) {
    border-color: var(--theme-control-border) !important;
}

html[data-theme="dark"] :is(
    .resources-code-block,
    .resources-code-header
) {
    border-color: var(--theme-code-border) !important;
}

/* Reservation component outlines that are not dividers keep their own border role. */
html[data-theme="dark"] :is(
    .officehours-maintenance-panel,
    .officehours-booking-fields input,
    .officehours-booking-fields textarea
) {
    border-color: var(--theme-border-dotted) !important;
}

html[data-theme="dark"] :is(
    #officehours-submit-btn,
    #officehours-cancel-submit-btn
) {
    border-color: var(--theme-text-subtle) !important;
}

/* Administrator controls use the shared accent boundary in every application. */
html[data-theme="dark"] :is(
    .officehours-admin-tools,
    .officehours-bookings-panel,
    .serverreservation-server-usage-form,
    .serverreservation-admin-tools,
    .serverreservation-maintenance-panel,
    .serverreservation-bookings-panel
) {
    border-color: var(--theme-admin-menu-border) !important;
    background: var(--theme-accent-surface);
}

html[data-theme="dark"] .resources-session-empty {
    border-color: var(--theme-text-subtle) !important;
}

html[data-theme="dark"] .resources-notebook-local-file-button.resources-notebook-add-files:not(:disabled),
html[data-theme="dark"] .resources-notebook-local-file-button.resources-notebook-clear-files:not(:disabled) {
    border-color: var(--theme-border) !important;
    color: var(--theme-border);
}

html[data-theme="dark"] .resources-file-preview :is(
    .resources-notebook-local-file-list,
    .resources-notebook-local-file-name,
    .resources-notebook-local-file-separator,
    .resources-notebook-local-file-size,
    .resources-notebook-remove-local-file
) {
    color: var(--theme-text-muted) !important;
}

html[data-theme="dark"] .resources-file-preview .resources-notebook-local-file-reference {
    color: var(--theme-border) !important;
}

html[data-theme="dark"] .resources-file-preview :is(
    .resources-notebook-package-catalog,
    .resources-notebook-package-search
) {
    background: var(--theme-surface);
    color: var(--theme-text);
    border-color: var(--theme-border-soft) !important;
}

html[data-theme="dark"] .resources-file-preview .resources-notebook-package-summary:not(.notebook-reference-toggle) {
    background: transparent;
    color: var(--theme-text);
    border: 0;
}

html[data-theme="dark"] .resources-file-preview :is(
    .resources-notebook-package-note,
    .resources-notebook-package-catalog-status,
    .resources-notebook-package-count,
    .resources-notebook-package-identity span,
    .resources-notebook-package-imports,
    .resources-notebook-package-empty
) {
    color: var(--theme-text-muted);
}

html[data-theme="dark"] .resources-file-preview .resources-notebook-package-item {
    border-bottom-color: var(--theme-border-soft);
}

html[data-theme="dark"] :is(
    .officehours-slot.is-selected,
    .serverreservation-slot.is-selected
) {
    border-color: var(--theme-border) !important;
}
