/* The theme switch belongs to the shared student shell, including legacy pages. */
.student-ui { color-scheme: light; }
body.student-ui { min-height: 100vh; }
.student-ui .portal-theme-host { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; }
.student-ui .portal-masthead-actions.portal-theme-host { gap: 16px; }
.student-ui .portal-theme-bar { display: flex; justify-content: flex-end; padding: 12px 24px 0; max-width: 1336px; margin: 0 auto; }
.student-ui .portal-theme-toggle {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; width: auto; flex-shrink: 0; margin: 0; padding: 8px 10px;
  border: 1px solid var(--portal-line); border-radius: 7px; box-shadow: none;
  background: var(--portal-surface); color: var(--portal-ink);
  font: 400 14px/1.3 Abel, 'Arial Narrow', sans-serif; letter-spacing: 0; cursor: pointer;
}
.student-ui .portal-theme-toggle:hover { background: var(--portal-soft); }
.student-ui .portal-theme-toggle svg { width: 17px; height: 17px; flex-shrink: 0; }
.student-ui .portal-theme-track { position: relative; display: block; width: 26px; height: 16px; border-radius: 10px; background: #7c858e; }
.student-ui .portal-theme-track::after { content: ''; position: absolute; top: 3px; left: 3px; width: 10px; height: 10px; border-radius: 50%; background: #fff; }
.student-ui .portal-theme-toggle[aria-checked='true'] .portal-theme-track { background: #c91d32; }
.student-ui .portal-theme-toggle[aria-checked='true'] .portal-theme-track::after { transform: translateX(10px); }
@media (max-width: 600px) {
  .student-ui .portal-masthead-actions.portal-theme-host { width: 100%; gap: 8px; justify-content: space-between; }
  .student-ui .portal-masthead-actions .portal-label { display: none; }
  .student-ui .portal-masthead-actions .portal-theme-toggle { order: 3; }
  .student-ui .portal-masthead-actions .portal-theme-toggle > span:not(.portal-theme-track) { display: none; }
  .student-ui .portal-theme-bar { padding-inline: 16px; }
}
@media print {
  .portal-theme-toggle, .portal-theme-bar { display: none !important; }
}

/* All overrides are screen-only: documents and printed records keep white paper.
   Theme scope never inverts images, video, signatures or embedded documents. */
@media screen {
  html[data-student-theme='dark']:has(> body.student-ui) { background: #151a22; color-scheme: dark; }
  [data-student-theme='dark'] .student-ui {
    color-scheme: dark;
    --portal-ink: #e9edf2;
    --portal-muted: #aab4c1;
    --portal-line: #35404d;
    --portal-surface: #151a22;
    --portal-soft: #1e2631;
    --portal-accent: #ff8293;
    --portal-red: #c91d32;
    --portal-red-dark: #ac172a;
    --ink: var(--portal-ink);
    --muted: var(--portal-muted);
    --line: var(--portal-line);
    --accent: var(--portal-accent);
    --paper: var(--portal-surface);
    --ground: #10151c;
    --wash: var(--portal-soft);
    --surface: var(--portal-surface);
    --slate-900: var(--portal-ink);
    --slate-700: #c4ccd6;
    --slate-500: var(--portal-muted);
    --academy-ink: var(--portal-ink);
    --academy-muted: var(--portal-muted);
    --academy-line: var(--portal-line);
    --academy-bg: var(--portal-surface);
    --bs-body-color: var(--portal-ink);
    --bs-body-color-rgb: 233, 237, 242;
    --bs-body-bg: var(--portal-surface);
    --bs-body-bg-rgb: 21, 26, 34;
    --bs-secondary-color: var(--portal-muted);
    --bs-secondary-color-rgb: 170, 180, 193;
    --bs-secondary-bg: var(--portal-soft);
    --bs-tertiary-bg: var(--portal-soft);
    --bs-tertiary-bg-rgb: 30, 38, 49;
    --bs-emphasis-color: var(--portal-ink);
    --bs-emphasis-color-rgb: 233, 237, 242;
    --bs-border-color: var(--portal-line);
    --bs-link-color: var(--portal-accent);
    --bs-link-color-rgb: 255, 130, 147;
    --bs-link-hover-color: #ffafbb;
    background: var(--portal-surface);
    color: var(--portal-ink);
  }
  [data-student-theme='dark'] .student-ui :is(a, button, summary, input, select, textarea):focus-visible { outline-color: var(--portal-accent); }
  [data-student-theme='dark'] .student-ui :is(.service-entry, .hero-eyebrow, .commerce-eyebrow, .learning-label, .ci-eyebrow, .ci-link, .academy-brand em, .cert-back-link, .btn-link) { color: var(--portal-accent); }
  [data-student-theme='dark'] .student-ui :is(.text-muted, .text-secondary, .text-body-secondary, .form-text) { color: var(--portal-muted) !important; }
  [data-student-theme='dark'] .student-ui :is(.text-dark, .text-black, .text-body) { color: var(--portal-ink) !important; }
  [data-student-theme='dark'] .student-ui :is(.bg-light, .bg-white, .bg-body-tertiary) { background-color: var(--portal-soft) !important; }
  [data-student-theme='dark'] .student-ui :is(.card, .card-header, .panel, .section-card, .service-options-panel, .hero-tile, .dashboard-account a, .modal-content, .modal-header, .modal-footer, .contact-section, .contact-section-header, .contact-section-body, .dropdown-menu, .list-group-item, .accordion-item, .accordion-button, .question-card, .material-card, .doc-card, .entry-card) {
    background-color: var(--portal-surface); color: var(--portal-ink); border-color: var(--portal-line);
  }
  [data-student-theme='dark'] .student-ui :is(.service-tile:hover, .service-options > summary:hover, .hero-tile:hover, .dashboard-account a:hover, .class-program-link:hover, .agenda-more > summary:hover, .agenda-details > summary:hover, .dropdown-item:hover) { background: var(--portal-soft); color: var(--portal-ink); }
  [data-student-theme='dark'] .student-ui :is(.service-unlocked .service-access, .service-state-active .service-access) { color: #89d5b1; }
  [data-student-theme='dark'] .student-ui :is(.service-state-expiring, .service-state-hold, .service-state-attention) .service-access { color: #f0c87d; }
  [data-student-theme='dark'] .student-ui :is(.service-state-expired, .service-state-terminated) .service-access { color: var(--portal-accent); }
  [data-student-theme='dark'] .student-ui :is(.dashboard-button, .btn-ghost, .btn-outline-secondary, .btn-outline-dark, .button.secondary, button.secondary, .ci-button-secondary, .attendance-override-trigger) { background: var(--portal-surface); color: var(--portal-ink); border-color: var(--portal-line); }
  [data-student-theme='dark'] .student-ui :is(.dashboard-button:hover, .btn-ghost:hover, .btn-outline-secondary:hover, .btn-outline-dark:hover, .button.secondary:hover, button.secondary:hover, .ci-button-secondary:hover) { background: var(--portal-soft); color: var(--portal-ink); }
  [data-student-theme='dark'] .student-ui :is(.btn-primary, .btn-brand, .btn-danger, .dashboard-button-primary, .portal-brand-symbol, .portal-updates-count, .classroom-join, .button:not(.secondary)) { background: var(--portal-red); border-color: var(--portal-red); color: #fff; }
  [data-student-theme='dark'] .student-ui :is(.btn-primary:hover, .btn-brand:hover, .btn-danger:hover, .dashboard-button-primary:hover, .button:not(.secondary):hover) { background: var(--portal-red-dark); border-color: var(--portal-red-dark); color: #fff; }
  [data-student-theme='dark'] .student-ui :is(.btn-outline-primary, .btn-outline-brand, .btn-outline-danger) { color: var(--portal-accent); border-color: #965363; }
  [data-student-theme='dark'] .student-ui :is(.btn-outline-primary, .btn-outline-brand, .btn-outline-danger) { background: var(--portal-surface); }
  [data-student-theme='dark'] .student-ui :is(.btn-outline-primary:hover, .btn-outline-brand:hover, .btn-outline-danger:hover) { color: #ffafbb; background: #38222c; }
  [data-student-theme='dark'] .student-ui :is(.agenda-badge, .agenda-count, .agenda-focus, .agenda-more > summary, .message-count-pill, .hero-chip, .session-option, .next-session, .attendance-timeline-item, .attendance-status-badge, .adx-record-card, .stat-card, .summary-tile) { background: var(--portal-soft); color: var(--portal-ink); border-color: var(--portal-line); }
  [data-student-theme='dark'] .student-ui .service-options-panel { box-shadow: 0 10px 28px #0005; }
  [data-student-theme='dark'] .student-ui .dashboard-skip-link { background: var(--portal-soft); color: var(--portal-ink); }
  [data-student-theme='dark'] .student-ui.student-portal .hero-meta .hero-chip { background: transparent; color: var(--portal-muted); }
  [data-student-theme='dark'] .student-ui .table thead th { background: var(--portal-soft); color: var(--portal-muted); }
  [data-student-theme='dark'] .student-ui :is(.template-chip, .scope-pill, .doc-detail-grid) { background: var(--portal-soft); color: var(--portal-ink); border-color: var(--portal-line); }
  [data-student-theme='dark'] .student-ui :is(.doc-html-preview, .typed-preview) { color: #1a2430; background: #fff; color-scheme: light; }
  [data-student-theme='dark'] .student-ui .accordion { --bs-accordion-active-bg: #38222c; --bs-accordion-active-color: var(--portal-accent); --bs-accordion-bg: var(--portal-surface); --bs-accordion-color: var(--portal-ink); --bs-accordion-btn-color: var(--portal-ink); }
  [data-student-theme='dark'] .student-ui .accordion-button:not(.collapsed) { background: #38222c; color: var(--portal-accent); }
  [data-student-theme='dark'] .student-ui :is(.form-control, .form-select, input:not([type='checkbox']):not([type='radio']):not([type='range']):not([type='hidden']):not([type='submit']):not([type='button']), select, textarea) { background-color: var(--portal-soft); color: var(--portal-ink); border-color: #546273; }
  [data-student-theme='dark'] .student-ui ::placeholder { color: var(--portal-muted); opacity: 1; }
  [data-student-theme='dark'] .student-ui input { accent-color: var(--portal-red); }
  [data-student-theme='dark'] .student-ui .table { --bs-table-bg: transparent; --bs-table-color: var(--portal-ink); --bs-table-border-color: var(--portal-line); --bs-table-striped-bg: #ffffff05; --bs-table-striped-color: var(--portal-ink); --bs-table-hover-bg: var(--portal-soft); --bs-table-hover-color: var(--portal-ink); }
  [data-student-theme='dark'] .student-ui .table-light { --bs-table-bg: var(--portal-soft); --bs-table-color: var(--portal-ink); --bs-table-border-color: var(--portal-line); }
  [data-student-theme='dark'] .student-ui :is(.alert-info, .alert-secondary, .ci-alert) { background: #202f40; color: #c4d9ed; border-color: #405b75; }
  [data-student-theme='dark'] .student-ui :is(.alert-warning, .notice, .ci-note, .dashboard-notice) { background: #342d21; color: #f0d299; border-color: #6e5934; }
  [data-student-theme='dark'] .student-ui .alert-danger { background: #39232c; color: #ffb2be; border-color: #824352; }
  [data-student-theme='dark'] .student-ui .alert-success { background: #1c342b; color: #9fdfbf; border-color: #3c6956; }
  [data-student-theme='dark'] .student-ui .text-danger { color: #ff96a5 !important; }
  [data-student-theme='dark'] .student-ui .text-success { color: #89d5b1 !important; }
  [data-student-theme='dark'] .student-ui .text-warning { color: #f0c87d !important; }
  [data-student-theme='dark'] .student-ui :is(.journey-meta, .portal-hint, .stat-label, .email-app .muted) { color: var(--portal-muted); }
  [data-student-theme='dark'] .student-ui :is(.today-step a, .reading-paper a, .lesson-copy a, .activation-card a, .portal-eyebrow, .cert-eyebrow) { color: var(--portal-accent); }
  [data-student-theme='dark'] .student-ui :is(.adx-status-pill.failed, .status-absent) { color: #ff96a5; }
  [data-student-theme='dark'] .student-ui :is(.adx-status-pill.passed, .status-present) { color: #89d5b1; }
  [data-student-theme='dark'] .student-ui :is(.exam-shell, .exam-header, .question-footer, .question-attachment, .option-tile, .empty-state, .email-app .message-body) { background: var(--portal-soft); color: var(--portal-ink); border-color: var(--portal-line); }
  [data-student-theme='dark'] .student-ui .timer { color: var(--portal-accent); }
  [data-student-theme='dark'] .student-ui .progress { background: var(--portal-line); }
  [data-student-theme='dark'] .student-ui :is(.stat-value, .progress-label, .question-title, .email-app) { color: var(--portal-ink); }
  [data-student-theme='dark'] .student-ui :is(.pill, .portal-alert) { background: var(--portal-soft); color: var(--portal-ink); border-color: var(--portal-line); }

  /* Course libraries and learner workspaces use older independent stylesheets. */
  [data-student-theme='dark'] .student-ui :is(.commerce-page, .certification-shell) { color-scheme: dark; background: var(--portal-surface); color: var(--portal-ink); }
  [data-student-theme='dark'] .student-ui :is(.commerce-mast, .mast, .commerce-account > div, .commerce-card, .commerce-hero, .learning-card, .today-session, .today-aside, .catalog-course, .course-outline, .study-panel, .study-pane, .lesson-stage, .subpanel, .study-toolbar, .lesson-next, .studio-dialog, .note-card, .coach-message, .skill-card, .mission, .mission-body) { background: var(--portal-surface); color: var(--portal-ink); border-color: var(--portal-line); }
  [data-student-theme='dark'] .student-ui :is(.commerce-brand, .commerce-navigation a, .commerce-account summary, .commerce-title, .learning-card h2, .today-header h1, .today-session h2, .today-aside h2, .academy-brand, .mast nav a, .lesson-link, .study-tab, .course-heading h1) { color: var(--portal-ink); }
  [data-student-theme='dark'] .student-ui :is(.commerce-brand span, .learning-card p, .today-session p, .today-aside p, .today-step small, .academy-brand span, .lesson-sources, .course-progress-summary) { color: var(--portal-muted); }
  [data-student-theme='dark'] .student-ui :is(.commerce-navigation a[aria-current], .lesson-link.active, .study-tab[aria-selected='true'], .lesson-link:hover, .study-tab:hover, .commerce-account a:hover) { color: var(--portal-accent); background: var(--portal-soft); }
  [data-student-theme='dark'] .student-ui :is(.course-art, .catalog-art, .learning-card .badge, .learning-progress .progress, .today-step .step-number, .course-progress-summary, .callout, .outline-module, .skill-state) { background-color: var(--portal-soft); color: var(--portal-ink); border-color: var(--portal-line); }
  [data-student-theme='dark'] .student-ui .today-session-top { background: var(--portal-soft); }
  [data-student-theme='dark'] .student-ui.academy :is(strong, b) { color: inherit; }
  [data-student-theme='dark'] .student-ui .certification-shell { --cert-ink: var(--portal-ink); --cert-muted: var(--portal-muted); --cert-line: var(--portal-line); --cert-paper: var(--portal-surface); --cert-surface: var(--portal-soft); }
  [data-student-theme='dark'] .student-ui .certification-shell a:not(.btn):not(.cert-brand) { color: var(--portal-accent); }
  [data-student-theme='dark'] .student-ui .certification :is(.btn-outline-primary, .btn-outline-danger) { color: var(--portal-accent); background: var(--portal-surface); }
  [data-student-theme='dark'] .student-ui :is(.cert-pill, .cert-step-mark) { background: var(--portal-soft); color: var(--portal-ink); border-color: var(--portal-line); }
  [data-student-theme='dark'] .student-ui :is(.ci-nav, .ci-card, .ci-ticket, .ci-ticket-stub, .ci-wallet, .ci-document, .ci-boarding-pass, .ci-map-scroll, .ci-classroom-front, .ci-seat > span) { background: var(--portal-surface); color: var(--portal-ink); border-color: var(--portal-line); }
  [data-student-theme='dark'] .student-ui :is(.ci-steps a, .ci-upload small, .ci-map-caption, .ci-review dt, .ci-pass-grid dt) { color: var(--portal-muted); }
  [data-student-theme='dark'] .student-ui .ci-steps a[aria-current] { background: #38222c; color: var(--portal-accent); }
  [data-student-theme='dark'] .student-ui .ci-seat input:checked + span { background: var(--portal-red); color: #fff; }
  [data-student-theme='dark'] .student-ui .ci-seat-unavailable > span { background: var(--portal-soft); color: var(--portal-muted); }
  [data-student-theme='dark'] .student-ui :is(.email-app, .ai-shell) { --surface: var(--portal-surface); }
  [data-student-theme='dark'] .student-ui :is(.message.user, .message.assistant, .suggestion, .message-card, .compose-card, .session-card, .classroom-card) { background: var(--portal-soft); color: var(--portal-ink); border-color: var(--portal-line); }
  [data-student-theme='dark'] .student-ui .ai-shell a:not(.button) { color: var(--portal-accent); }
  [data-student-theme='dark'] .student-ui .ai-shell .button { background: var(--portal-red); color: #fff; }
  [data-student-theme='dark'] .student-ui .ai-shell .button.secondary { background: var(--portal-soft); color: var(--portal-ink); }
  [data-student-theme='dark'] .student-ui .portal-theme-toggle { background: var(--portal-surface); color: var(--portal-ink); border-color: var(--portal-line); }
  [data-student-theme='dark'] .student-ui .portal-theme-toggle:hover { background: var(--portal-soft); }
}
