/* Shared TechWise 360 light/dark theme layer. Loaded last on every portal page. */
:root {
  --theme-bg: #f3f6fc;
  --theme-shell: #ffffff;
  --theme-surface: #ffffff;
  --theme-surface-raised: #ffffff;
  --theme-surface-soft: #eef5ff;
  --theme-text: #101827;
  --theme-text-soft: #667085;
  --theme-border: #dfe7ee;
  --theme-shadow: rgba(15, 23, 42, 0.12);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --blue: #5b9cff;
  --blue-dark: #77adff;
  --primary-blue: #327ff0;
  --primary-blue-hover: #4d92f6;
  --light-blue-bg: #15263b;
  --ink: #f4f7fb;
  --text-primary: #f4f7fb;
  --muted: #a8b3c4;
  --text-muted: #a8b3c4;
  --line: #2d3949;
  --border-color: #2d3949;
  --border: var(--border-color);
  --panel: #151b24;
  --card-bg: #171e28;
  --page: #0b0f15;
  --page-bg: #0b0f15;
  --danger-soft: #3a1c25;
  --success-soft: #123329;
  --warning-soft: #3b2a16;
  --purple-soft: #2b2043;
  --shadow: 0 18px 42px rgba(0, 0, 0, 0.38);
  --card-shadow: 0 14px 34px rgba(0, 0, 0, 0.28);
  --theme-bg: #0b0f15;
  --theme-shell: #10151d;
  --theme-surface: #151b24;
  --theme-surface-raised: #19212c;
  --theme-surface-soft: #15263b;
  --theme-text: #f4f7fb;
  --theme-text-soft: #a8b3c4;
  --theme-border: #2d3949;
  --theme-shadow: rgba(0, 0, 0, 0.34);
}

:root[data-theme="dark"] body[data-page="teacher"] {
  --teacher-ink: #f4f7fb;
  --teacher-ink-soft: #dce3ed;
  --teacher-muted: #9eabba;
  --teacher-line: #2d3949;
  --teacher-line-soft: #222c39;
  --teacher-primary: #327ff0;
  --teacher-primary-hover: #4d92f6;
  --teacher-primary-soft: #70a7f7;
  --teacher-primary-muted: #315987;
  --teacher-blue: #15263b;
  --teacher-blue-strong: #1b314c;
  --teacher-blue-text: #9fc5ff;
  --home-ink: #f4f7fb;
  --home-muted: #9eabba;
  --home-line: #2d3949;
  --home-blue: #15263b;
  --home-blue-strong: #1b314c;
  background: var(--theme-bg);
}

:root[data-theme="dark"] body[data-page="student"] {
  --student-ink: #f4f7fb;
  --student-ink-soft: #dce3ed;
  --student-muted: #9eabba;
  --student-line: #2d3949;
  --student-line-soft: #222c39;
  --student-primary: #327ff0;
  --student-primary-hover: #4d92f6;
  --student-blue: #15263b;
  --student-blue-strong: #1b314c;
  background: var(--theme-bg);
}

html,
body,
.app-shell,
.app-main,
.app-sidebar,
.app-topbar,
.teacher-section,
.student-section,
.auth-shell,
.form-card,
.notification-panel,
.feedback-modal,
.app-toast {
  transition: background-color 220ms ease, border-color 220ms ease, color 180ms ease, box-shadow 220ms ease;
}

.theme-toggle {
  position: relative;
  width: 54px;
  min-width: 54px;
  height: 32px;
  min-height: 32px;
  padding: 0;
  border: 1px solid #d5dfeb;
  border-radius: 999px;
  background: #edf4fc;
  color: #526173;
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.06);
  cursor: pointer;
  touch-action: manipulation;
}

body:is([data-page="teacher"], [data-page="student"]) .theme-toggle {
  width: 54px;
  min-width: 54px;
  height: 32px;
  min-height: 32px;
  padding: 0;
  border-radius: 999px;
}

.theme-toggle-track {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 7px;
}

.theme-toggle-track > svg {
  position: relative;
  z-index: 1;
  width: 13px;
  height: 13px;
  pointer-events: none;
}

.theme-toggle-track > svg:first-child { color: #d98d10; }
.theme-toggle-track > svg:nth-child(2) { color: #6e7b8d; }

.theme-toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  z-index: 0;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.22);
  transition: transform 240ms cubic-bezier(.22, 1, .36, 1), background-color 200ms ease;
}

.theme-toggle:hover {
  border-color: #b9c9da;
  box-shadow: 0 4px 12px rgba(31, 111, 235, 0.12);
}

.theme-toggle:focus-visible {
  outline: 3px solid rgba(31, 111, 235, 0.28);
  outline-offset: 2px;
}

:root[data-theme="dark"] .theme-toggle {
  border-color: #3a4b61;
  background: #16263b;
  color: #dce9fb;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.28);
}

:root[data-theme="dark"] .theme-toggle-thumb {
  background: #e9f2ff;
  transform: translateX(22px);
}

:root[data-theme="dark"] .theme-toggle-track > svg:first-child { color: #8290a3; }
:root[data-theme="dark"] .theme-toggle-track > svg:nth-child(2) { color: #7eaff8; }

.auth-theme-toggle {
  position: fixed;
  top: 20px;
  right: 22px;
  z-index: 50;
}

:root[data-theme="dark"] body {
  background: var(--theme-bg);
  color: var(--theme-text);
}

:root[data-theme="dark"] body :is(h1, h2, h3, h4, strong, label, legend) {
  color: var(--theme-text);
}

:root[data-theme="dark"] body :is(p, small, time, .helper-text, .subtitle, .muted, .link-label) {
  color: var(--theme-text-soft);
}

:root[data-theme="dark"] body :is(input, select, textarea) {
  border-color: var(--theme-border);
  background-color: #101722;
  color: var(--theme-text);
}

:root[data-theme="dark"] body :is(input, textarea)::placeholder { color: #748196; }
:root[data-theme="dark"] body select { color-scheme: dark; }
:root[data-theme="dark"] body hr { border-color: var(--theme-border); }

/* Authentication and account pages */
:root[data-theme="dark"] body[data-page="login"],
:root[data-theme="dark"] body[data-page="register"],
:root[data-theme="dark"] body[data-page="forgot-password"],
:root[data-theme="dark"] body[data-page="reset-password"] {
  background:
    radial-gradient(circle at 14% 18%, rgba(50, 127, 240, 0.13), transparent 28%),
    var(--theme-bg);
}

:root[data-theme="dark"] :is(.form-card, .asset-stage, .feature-strip, .input-wrap) {
  border-color: var(--theme-border);
  background: var(--theme-surface);
  color: var(--theme-text);
}

:root[data-theme="dark"] :is(.brand-mark, .brand-panel h1, .feature-strip div, .field, .input-wrap, .form-heading h2) {
  color: var(--theme-text);
}

:root[data-theme="dark"] :is(.form-heading p, .brand-panel p, .input-hint, .account-prompt) {
  color: var(--theme-text-soft);
}

/* Shared dashboard shell and overlays */
:root[data-theme="dark"] body:is([data-page="teacher"], [data-page="student"]) .app-shell,
:root[data-theme="dark"] body:is([data-page="teacher"], [data-page="student"]) .app-main,
:root[data-theme="dark"] body:is([data-page="teacher"], [data-page="student"]) :is(.teacher-section, .student-section) {
  background: var(--theme-bg);
}

:root[data-theme="dark"] body:is([data-page="teacher"], [data-page="student"]) .app-sidebar {
  border-color: var(--theme-border);
  background: #101720;
}

:root[data-theme="dark"] body:is([data-page="teacher"], [data-page="student"]) .app-topbar {
  border-color: var(--theme-border);
  background: rgba(16, 21, 29, 0.96);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.2);
}

:root[data-theme="dark"] body:is([data-page="teacher"], [data-page="student"]) :is(.brand-mark, .topbar-profile, .topbar-profile > svg, .topbar-breadcrumb, .topbar-breadcrumb strong) {
  color: var(--theme-text);
}

:root[data-theme="dark"] body:is([data-page="teacher"], [data-page="student"]) .topbar-profile span {
  color: var(--theme-text-soft);
}

:root[data-theme="dark"] body:is([data-page="teacher"], [data-page="student"]) :is(.notification-button, .icon-shell, .small-button, .secondary-button, .link-button, .sidebar-collapse-toggle) {
  border-color: var(--theme-border);
  background: #151d28;
  color: #d7e1ee;
}

:root[data-theme="dark"] body:is([data-page="teacher"], [data-page="student"]) :is(.notification-button, .icon-shell, .small-button, .secondary-button, .link-button, .sidebar-collapse-toggle):hover,
:root[data-theme="dark"] body:is([data-page="teacher"], [data-page="student"]) .notification-button[aria-expanded="true"] {
  border-color: #43536a;
  background: #1b293a;
  color: #ffffff;
}

:root[data-theme="dark"] body:is([data-page="teacher"], [data-page="student"]) .notification-badge,
:root[data-theme="dark"] .notification-badge {
  border-color: #151d28 !important;
}

:root[data-theme="dark"] :is(.notification-panel, .feedback-modal, .app-toast) {
  border-color: var(--theme-border);
  background: var(--theme-surface-raised);
  color: var(--theme-text);
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.42);
}

:root[data-theme="dark"] :is(.notification-panel-header, .feedback-modal-actions) {
  border-color: var(--theme-border);
  background: #141b25;
}

:root[data-theme="dark"] :is(.notification-item, .assessment-review-row) {
  border-color: var(--theme-border);
  background: var(--theme-surface);
  color: var(--theme-text);
}

:root[data-theme="dark"] :is(.notification-item:hover, .notification-item.unread) { background: #17283d; }
:root[data-theme="dark"] .feedback-modal-overlay { background: rgba(2, 6, 12, 0.74); }

/* VR Connect Dark Theme */
:root[data-theme="dark"] body[data-page="student"] :is(.vr-method-card, .vr-station-main-card) {
  background: var(--theme-surface, #151b24);
  border-color: var(--theme-border, #2d3949);
}

:root[data-theme="dark"] body[data-page="student"] .vr-connect-metrics .stat-card {
  background: var(--theme-surface, #151b24);
  border-color: var(--theme-border, #2d3949);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}

:root[data-theme="dark"] body[data-page="student"] .vr-connect-metrics .stat-card:hover {
  border-color: #3b495b;
}

:root[data-theme="dark"] body[data-page="student"] .vr-connect-metrics .stat-card-heading p {
  color: #94a3b8;
}

:root[data-theme="dark"] body[data-page="student"] .vr-connect-metrics .stat-card-value strong {
  color: #f4f7fb;
}

:root[data-theme="dark"] body[data-page="student"] .vr-connect-metrics .stat-card-value small {
  color: #94a3b8;
}

:root[data-theme="dark"] body[data-page="student"] .vr-connect-metrics .stat-icon.purple { background: rgba(168, 85, 247, 0.18); color: #c084fc; }
:root[data-theme="dark"] body[data-page="student"] .vr-connect-metrics .stat-icon.blue   { background: rgba(59, 130, 246, 0.18); color: #60a5fa; }
:root[data-theme="dark"] body[data-page="student"] .vr-connect-metrics .stat-icon.green  { background: rgba(16, 185, 129, 0.18); color: #34d399; }
:root[data-theme="dark"] body[data-page="student"] .vr-connect-metrics .stat-icon.gold   { background: rgba(245, 158, 11, 0.18); color: #fbbf24; }

:root[data-theme="dark"] body[data-page="student"] :is(.vr-code-box-wrapper, .vr-station-selector-box, .station-status-strip, .vr-guide-steps-card) {
  background: #10151d;
  border-color: var(--theme-border, #2d3949);
}

:root[data-theme="dark"] body[data-page="student"] .station-select-btn {
  background: #151b24;
  border-color: var(--theme-border, #2d3949);
}

:root[data-theme="dark"] body[data-page="student"] .station-select-btn:hover {
  background: #1b2330;
  border-color: #3b495b;
}

:root[data-theme="dark"] body[data-page="student"] .station-select-btn.active {
  background: #16263b;
  border-color: #327ff0;
  box-shadow: 0 0 0 1px #327ff0;
}

:root[data-theme="dark"] body[data-page="student"] .station-btn-meta strong {
  color: #f4f7fb;
}

:root[data-theme="dark"] body[data-page="student"] .station-picker-label,
:root[data-theme="dark"] body[data-page="student"] .vr-guide-steps-card h4 {
  color: #f4f7fb;
}

:root[data-theme="dark"] body[data-page="student"] .vr-security-features span {
  background: #17283d;
  color: #9fc5ff;
}

:root[data-theme="dark"] body[data-page="student"] .vr-banner-text h3 {
  color: #f4f7fb;
}

:root[data-theme="dark"] body[data-page="student"] .vr-banner-text p {
  color: #a8b3c4;
}

:root[data-theme="dark"] body[data-page="student"] .vr-connect-header-badge {
  background: #12281e;
  border-color: #1a4d33;
  color: #4ade80;
}

/* Cards, panels, tables, forms, drawers, and generated dashboard content */
:root[data-theme="dark"] body:is([data-page="teacher"], [data-page="student"]) :is(
  .welcome-block,
  .quick-access,
  .achievement-strip,
  .lesson-card,
  .quick-card,
  .stat-card,
  .panel-card,
  .teacher-home-surface,
  .student-profile-photo-card,
  .student-profile-form,
  [class$="-card"],
  [class*="-card "],
  [class$="-panel"],
  [class*="-panel "],
  [class$="-drawer"],
  [class*="-drawer "]
) {
  border-color: var(--theme-border);
  background-color: var(--theme-surface);
  color: var(--theme-text);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.18);
}

:root[data-theme="dark"] body:is([data-page="teacher"], [data-page="student"]) :is(
  .stat-card-body,
  .quarter-spotlight,
  .evidence-line-chart,
  .evidence-mastery-overview,
  .evidence-growth-score > div,
  .next-action-panel,
  .student-skill-snapshot-row,
  .student-due-row,
  .student-evidence-row,
  .compact-list .mini-row,
  .settings-switch-row,
  .profile-summary-item,
  .lesson-section,
  .assessment-question,
  .empty-state
) {
  border-color: var(--theme-border);
  background: var(--theme-surface-raised);
  color: var(--theme-text);
}

:root[data-theme="dark"] body:is([data-page="teacher"], [data-page="student"]) :is(
  .stat-card-heading,
  .settings-card-heading,
  .profile-card-heading,
  .lesson-card-heading,
  .evidence-card > .panel-title-row,
  thead,
  th
) {
  border-color: var(--theme-border);
  background-color: var(--theme-surface-soft);
  color: #dce9fb;
}

:root[data-theme="dark"] body:is([data-page="teacher"], [data-page="student"]) table,
:root[data-theme="dark"] body:is([data-page="teacher"], [data-page="student"]) :is(td, tr) {
  border-color: var(--theme-border);
  color: var(--theme-text);
}

:root[data-theme="dark"] body:is([data-page="teacher"], [data-page="student"]) tbody tr,
:root[data-theme="dark"] body:is([data-page="teacher"], [data-page="student"]) tbody td {
  background-color: transparent;
}

:root[data-theme="dark"] body:is([data-page="teacher"], [data-page="student"]) tbody tr:hover {
  background: #17283d;
}

:root[data-theme="dark"] body:is([data-page="teacher"], [data-page="student"]) :is(.soft-pill, .status-pill, .evidence-chip, .home-eyebrow, .teacher-page-eyebrow) {
  border-color: #324763;
  background: #17283d;
  color: #9fc5ff;
}

:root[data-theme="dark"] body[data-page="student"] .nav-item.active,
:root[data-theme="dark"] body[data-page="student"] .nav-item:hover {
  border-color: #315987;
  background: #15263b;
  color: #9fc5ff;
}

:root[data-theme="dark"] body[data-page="student"] .app-sidebar {
  background: #10151d;
}

:root[data-theme="dark"] body:is([data-page="teacher"], [data-page="student"]) :is(.student-search, .lesson-search, .assessment-search, .search-field, .filter-control, .input-wrap) {
  border-color: var(--theme-border);
  background: #101722;
  color: var(--theme-text);
}

:root[data-theme="dark"] body:is([data-page="teacher"], [data-page="student"]) svg text {
  fill: var(--theme-text-soft);
}

:root[data-theme="dark"] body[data-page="teacher"] .teacher-section[data-view="overview"] :is(
  .capstone-evidence-header,
  .performance-chart-summary > div,
  .performance-chart-canvas,
  .evidence-performance-empty,
  .evidence-performance-single
) {
  border-color: var(--theme-border);
  background: var(--theme-surface-raised);
}

:root[data-theme="dark"] body[data-page="teacher"] .teacher-section[data-view="overview"] .performance-chart-summary strong,
:root[data-theme="dark"] body[data-page="teacher"] .teacher-section[data-view="overview"] .capstone-evidence-header h1,
:root[data-theme="dark"] body[data-page="teacher"] .teacher-section[data-view="overview"] .evidence-performance-single strong {
  color: var(--theme-text);
}

:root[data-theme="dark"] body[data-page="teacher"] .teacher-section[data-view="overview"] .performance-grid-line {
  stroke: #344257;
}

:root[data-theme="dark"] body[data-page="teacher"] .teacher-section[data-view="overview"] .performance-callout rect {
  fill: #182231;
  stroke: #3a485c;
}

:root[data-theme="dark"] body[data-page="teacher"] .teacher-section[data-view="overview"] .performance-point,
:root[data-theme="dark"] body[data-page="teacher"] .teacher-section[data-view="overview"] .performance-point-group.is-context .performance-point {
  fill: #111923;
}

:root[data-theme="dark"] body[data-page="teacher"] .teacher-section[data-view="overview"] .performance-point-group:is(:hover, :focus, .is-active, .is-latest):not(.is-context) .performance-point {
  fill: #2d74f5;
}

:root[data-theme="dark"] body[data-page="teacher"] .teacher-section[data-view="overview"] .performance-chart-summary .is-positive strong {
  color: #5fd19e;
}

:root[data-theme="dark"] body[data-page="teacher"] .teacher-section[data-view="overview"] .performance-chart-summary .is-negative strong {
  color: #ff8490;
}

:root[data-theme="dark"] body :is(.good-text, b.good, .success-text) { color: #5fd19e !important; }
:root[data-theme="dark"] body :is(.warn-text, b.warn, .warning-text) { color: #f5b85c !important; }
:root[data-theme="dark"] body :is(.danger-text, b.danger, .error-text) { color: #ff8490 !important; }

:root[data-theme="dark"] body :is(.primary-button, .export-button) {
  border-color: var(--primary-blue);
  background: var(--primary-blue);
  color: #fff;
}

:root[data-theme="dark"] body :is(.primary-button, .export-button):hover:not(:disabled) {
  border-color: var(--primary-blue-hover);
  background: var(--primary-blue-hover);
}

:root[data-theme="dark"] body[data-page="teacher"] #openAiLessonGenerator,
:root[data-theme="dark"] body[data-page="teacher"] #openAiLessonGeneratorHeader,
:root[data-theme="dark"] body[data-page="teacher"] .upload-actions-stack .primary-button {
  background: var(--primary-blue, #1f6feb) !important;
  border-color: var(--primary-blue, #1f6feb) !important;
  color: #ffffff !important;
}

:root[data-theme="dark"] body[data-page="teacher"] #openAiLessonGenerator :is(span, svg, i),
:root[data-theme="dark"] body[data-page="teacher"] #openAiLessonGeneratorHeader :is(span, svg, i),
:root[data-theme="dark"] body[data-page="teacher"] .upload-actions-stack .primary-button :is(span, svg, i) {
  color: #ffffff !important;
  stroke: #ffffff !important;
}

:root[data-theme="dark"] body[data-page="teacher"] #openAiLessonGenerator:hover:not(:disabled),
:root[data-theme="dark"] body[data-page="teacher"] #openAiLessonGeneratorHeader:hover:not(:disabled),
:root[data-theme="dark"] body[data-page="teacher"] .upload-actions-stack .primary-button:hover:not(:disabled) {
  background: var(--primary-blue-hover, #1a5cc7) !important;
  border-color: var(--primary-blue-hover, #1a5cc7) !important;
  color: #ffffff !important;
}

:root[data-theme="dark"] body[data-page="teacher"] #openAiLessonGenerator:disabled,
:root[data-theme="dark"] body[data-page="teacher"] #openAiLessonGeneratorHeader:disabled,
:root[data-theme="dark"] body[data-page="teacher"] .upload-actions-stack .primary-button:disabled,
:root[data-theme="dark"] body[data-page="teacher"] #openAiLessonGenerator:disabled:hover,
:root[data-theme="dark"] body[data-page="teacher"] #openAiLessonGeneratorHeader:disabled:hover,
:root[data-theme="dark"] body[data-page="teacher"] .upload-actions-stack .primary-button:disabled:hover {
  background: #1e293b !important;
  border-color: #334155 !important;
  color: #64748b !important;
  transform: none !important;
  box-shadow: none !important;
}

:root[data-theme="dark"] body[data-page="teacher"] #openAiLessonGenerator:disabled :is(span, svg, i),
:root[data-theme="dark"] body[data-page="teacher"] #openAiLessonGeneratorHeader:disabled :is(span, svg, i),
:root[data-theme="dark"] body[data-page="teacher"] .upload-actions-stack .primary-button:disabled :is(span, svg, i) {
  color: #64748b !important;
  stroke: #64748b !important;
}

/* Home-only dark actions requested for Create Lesson, PDF, and the selected update range. */
body[data-page="teacher"] .home-hero-actions .primary-button,
body[data-page="teacher"] .evidence-export-actions button:first-child,
body[data-page="teacher"] .home-update-tabs button.active {
  border-color: #111318;
  background: #111318;
  color: #fff;
  box-shadow: 0 6px 14px rgba(17, 19, 24, 0.16);
}

body[data-page="teacher"] .home-hero-actions .primary-button:hover,
body[data-page="teacher"] .evidence-export-actions button:first-child:hover,
body[data-page="teacher"] .home-update-tabs button.active:hover {
  border-color: #2a2f38;
  background: #2a2f38;
}

:root[data-theme="dark"] body ::-webkit-scrollbar { width: 10px; height: 10px; }
:root[data-theme="dark"] body ::-webkit-scrollbar-track { background: #0c1118; }
:root[data-theme="dark"] body ::-webkit-scrollbar-thumb { border: 2px solid #0c1118; border-radius: 999px; background: #35445a; }

@media (max-width: 620px) {
  .theme-toggle,
  body:is([data-page="teacher"], [data-page="student"]) .theme-toggle {
    width: 50px;
    min-width: 50px;
    height: 30px;
    min-height: 30px;
  }

  .theme-toggle-thumb { width: 22px; height: 22px; }
  :root[data-theme="dark"] .theme-toggle-thumb { transform: translateX(20px); }
  .auth-theme-toggle { top: 14px; right: 14px; }
}

/* Final mobile navigation layer: keep the drawer above its backdrop and fully tappable. */
@media (max-width: 840px) {
  body:is([data-page="teacher"], [data-page="student"]).mobile-nav-open {
    overflow: hidden;
    overscroll-behavior: none;
  }

  body:is([data-page="teacher"], [data-page="student"]) .mobile-nav-toggle {
    position: fixed;
    top: calc(12px + env(safe-area-inset-top));
    left: 12px;
    z-index: 90;
    width: 44px;
    min-width: 44px;
    height: 44px;
    min-height: 44px;
    padding: 0;
    border: 1px solid #d8e2ec;
    border-radius: 13px;
    display: grid;
    place-items: center;
    color: #111318;
    background: #fff;
    box-shadow: 0 8px 22px rgba(17, 19, 24, 0.16);
    transition: color 180ms ease, background-color 180ms ease, border-color 180ms ease, transform 180ms ease, box-shadow 180ms ease;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
  }

  body:is([data-page="teacher"], [data-page="student"]) .mobile-nav-toggle:active {
    transform: scale(0.96);
  }

  body:is([data-page="teacher"], [data-page="student"]) .mobile-nav-toggle[aria-expanded="true"] {
    border-color: #111318;
    color: #fff;
    background: #111318;
    box-shadow: 0 8px 22px rgba(17, 19, 24, 0.25);
  }

  body:is([data-page="teacher"], [data-page="student"]) .mobile-nav-toggle svg {
    width: 22px;
    height: 22px;
    stroke-width: 2.25;
  }

  body:is([data-page="teacher"], [data-page="student"]) .mobile-nav-backdrop {
    position: fixed;
    inset: 0;
    z-index: 70;
    display: block;
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
    background: rgba(15, 23, 42, 0.48);
    backdrop-filter: blur(1.5px);
    transition: opacity 220ms ease, visibility 0s linear 220ms;
    touch-action: none;
  }

  body:is([data-page="teacher"], [data-page="student"]).mobile-nav-open .mobile-nav-backdrop {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
    transition-delay: 0s;
  }

  body:is([data-page="teacher"], [data-page="student"]) .app-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 80;
    width: min(320px, 86vw);
    max-width: calc(100vw - 44px);
    height: 100vh !important;
    height: 100dvh !important;
    max-height: none;
    margin: 0;
    padding: calc(12px + env(safe-area-inset-top)) 12px calc(12px + env(safe-area-inset-bottom));
    border: 0;
    border-right: 1px solid #dfe7ee;
    border-radius: 0 18px 18px 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    color: #111318;
    background: #fbfcfd;
    box-shadow: 18px 0 44px rgba(15, 23, 42, 0.2);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translate3d(-102%, 0, 0);
    transition: transform 260ms cubic-bezier(.22, 1, .36, 1), opacity 180ms ease, visibility 0s linear 260ms;
  }

  body:is([data-page="teacher"], [data-page="student"]).mobile-nav-open .app-sidebar,
  body[data-page="teacher"] .app-sidebar.open,
  body[data-page="student"] .app-sidebar.open {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
    transform: translate3d(0, 0, 0);
    transition-delay: 0s;
  }

  body:is([data-page="teacher"], [data-page="student"]).mobile-nav-open .app-sidebar .sidebar-logo-mark {
    visibility: hidden;
    opacity: 0;
  }

  body:is([data-page="teacher"], [data-page="student"]) .app-sidebar .sidebar-brand-block {
    width: 100%;
    min-height: 56px;
    height: 56px;
    flex: 0 0 56px;
    margin: 0 0 10px;
    border-bottom: 1px dashed #dfe7ee;
  }

  body[data-page="student"] .app-sidebar .sidebar-brand-block {
    padding-left: 52px;
    grid-template-columns: minmax(0, 1fr);
  }

  body:is([data-page="teacher"], [data-page="student"]) .app-sidebar .sidebar-search {
    width: 100%;
    min-height: 44px;
    height: 44px;
    flex: 0 0 44px;
    margin: 4px 0 10px;
  }

  body:is([data-page="teacher"], [data-page="student"]) .app-sidebar .sidebar-search input {
    height: 44px;
    min-height: 44px;
    border-radius: 11px;
  }

  body:is([data-page="teacher"], [data-page="student"]) .app-sidebar .sidebar-section-label {
    min-height: 18px;
    height: auto;
    flex: 0 0 auto;
    margin: 12px 10px 5px;
    color: #778394;
    font-size: 9px;
    line-height: 18px;
    letter-spacing: 0.09em;
  }

  body:is([data-page="teacher"], [data-page="student"]) .app-sidebar .nav-item {
    position: relative;
    width: 100%;
    min-height: 44px;
    height: 44px;
    flex: 0 0 44px;
    margin: 0;
    padding: 0 12px;
    border: 1px solid transparent;
    border-radius: 11px;
    display: grid;
    grid-template-columns: 22px minmax(0, 1fr);
    place-items: center start;
    align-content: center;
    gap: 10px;
    color: #4f5a68;
    background: transparent;
    box-shadow: none;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.2;
    text-align: left;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
  }

  body:is([data-page="teacher"], [data-page="student"]) .app-sidebar .nav-item svg {
    position: static;
    width: 18px;
    height: 18px;
    margin: 0;
    transform: none;
    stroke-width: 2;
  }

  body:is([data-page="teacher"], [data-page="student"]) .app-sidebar .nav-item > span {
    position: static;
    width: auto;
    max-width: 100%;
    overflow: hidden;
    visibility: visible;
    opacity: 1;
    transform: none;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body:is([data-page="teacher"], [data-page="student"]) .app-sidebar .nav-item:is(.active, [aria-current="page"]) {
    border-color: #cfe0ee;
    color: #111318;
    background: #eef7ff;
    box-shadow: none;
  }

  body:is([data-page="teacher"], [data-page="student"]) .app-sidebar .nav-item:active {
    background: #e2f0fc;
    transform: scale(0.985);
  }

  body[data-page="teacher"] .app-sidebar .sidebar-profile-card,
  body[data-page="student"] .app-sidebar .sidebar-help-card,
  body[data-page="student"] .app-sidebar .sidebar-profile-card {
    width: 100%;
    margin: auto 0 0;
    flex: 0 0 auto;
  }

  body[data-page="teacher"] .app-sidebar .sidebar-profile-card,
  body[data-page="student"] .app-sidebar .sidebar-profile-card {
    min-height: 60px;
    height: 60px;
    padding: 7px;
    border-color: #dfe7ee;
    background: #fff;
    box-shadow: 0 8px 20px rgba(17, 19, 24, 0.07);
  }
}

@media (prefers-reduced-motion: reduce) {
  .theme-toggle-thumb,
  html,
  body,
  .app-shell,
  .app-main,
  .app-sidebar,
  .app-topbar,
  .teacher-section,
  .student-section {
    transition: none !important;
  }
}

/* Shared dropdown system. Kept in the final theme layer so every static and
   JavaScript-generated select uses the same TechWise 360 control treatment. */
body {
  --select-control-bg: #ffffff;
  --select-control-text: #1b2737;
  --select-control-muted: #66758a;
  --select-control-border: #d7e1ec;
  --select-control-hover-border: #aebfd2;
  --select-control-focus: #2878e8;
  --select-control-arrow-zone: #f5f8fc;
  --select-control-option-bg: #ffffff;
  --select-control-option-selected: #eaf3ff;
  --select-control-chevron: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22%235f6f82%22%20stroke-width%3D%222.25%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpath%20d%3D%22m7%2010%205%205%205-5%22%2F%3E%3C%2Fsvg%3E");
}

body select {
  -webkit-appearance: none !important;
  appearance: none !important;
  box-sizing: border-box;
  min-height: 42px;
  padding: 0 46px 0 14px;
  padding-right: 46px !important;
  border: 1px solid var(--select-control-border);
  border-radius: 11px;
  outline: 0;
  color: var(--select-control-text);
  background-color: var(--select-control-bg);
  background-image:
    var(--select-control-chevron),
    linear-gradient(
      90deg,
      transparent 0,
      transparent calc(100% - 40px),
      var(--select-control-arrow-zone) calc(100% - 40px),
      var(--select-control-arrow-zone) 100%
    ) !important;
  background-repeat: no-repeat !important;
  background-position: right 12px center, 0 0 !important;
  background-size: 16px 16px, 100% 100% !important;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.045), inset 0 1px 0 rgba(255, 255, 255, 0.72);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
  transition: border-color 160ms ease, box-shadow 160ms ease, background-color 160ms ease;
}

body select:hover:not(:disabled) {
  --select-control-arrow-zone: #edf4fc;
  border-color: var(--select-control-hover-border);
  box-shadow: 0 3px 10px rgba(31, 111, 235, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.78);
}

body select:focus,
body select:focus-visible {
  --select-control-arrow-zone: #e7f1ff;
  border-color: var(--select-control-focus);
  outline: 0;
  box-shadow: 0 0 0 3px rgba(40, 120, 232, 0.15), 0 3px 10px rgba(31, 111, 235, 0.09);
}

@supports selector(select:open) {
  body select:open {
    --select-control-arrow-zone: #e7f1ff;
    border-color: var(--select-control-focus);
    box-shadow: 0 0 0 3px rgba(40, 120, 232, 0.15), 0 6px 16px rgba(31, 111, 235, 0.1);
  }
}

body select:disabled {
  --select-control-arrow-zone: #f1f4f8;
  color: var(--select-control-muted);
  border-color: #e1e7ee;
  background-color: #f7f9fb;
  box-shadow: none;
  cursor: not-allowed;
  opacity: 0.78;
}

body select option,
body select optgroup {
  color: var(--select-control-text);
  background: var(--select-control-option-bg);
  font-family: inherit;
  font-size: 13px;
}

body select option {
  min-height: 36px;
  padding: 9px 12px;
  font-weight: 500;
}

body select option:checked {
  color: #185fcf;
  background: var(--select-control-option-selected);
  font-weight: 700;
}

/* Registration controls already have a shared outer field; keep that single
   border while retaining the custom arrow, readable text, and even spacing. */
body .input-wrap select {
  min-height: 0;
  border: 0;
  border-radius: 0;
  background-color: transparent;
  box-shadow: none;
}

body .input-wrap select:hover:not(:disabled),
body .input-wrap select:focus,
body .input-wrap select:focus-visible {
  border: 0;
  box-shadow: none;
}

body[data-page="teacher"] select {
  font-size: 12px;
}

body[data-page="teacher"] :is(
  .student-toolbar,
  .lesson-toolbar,
  .assessment-toolbar,
  .report-toolbar,
  .reports-toolbar,
  .leaderboard-toolbar,
  .achievement-toolbar,
  .evidence-toolbar
) select {
  height: 42px;
  min-height: 42px;
  padding-right: 46px;
  padding-left: 14px;
  font-size: 12px;
}

:root[data-theme="dark"] body {
  --select-control-bg: #111925;
  --select-control-text: #eef4fb;
  --select-control-muted: #8e9bad;
  --select-control-border: #354255;
  --select-control-hover-border: #52647b;
  --select-control-focus: #5b9cff;
  --select-control-arrow-zone: #192434;
  --select-control-option-bg: #151d28;
  --select-control-option-selected: #1a3658;
  --select-control-chevron: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22%23b8c6d8%22%20stroke-width%3D%222.25%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpath%20d%3D%22m7%2010%205%205%205-5%22%2F%3E%3C%2Fsvg%3E");
}

:root[data-theme="dark"] body select {
  color-scheme: dark;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.24), inset 0 1px 0 rgba(255, 255, 255, 0.035);
}

:root[data-theme="dark"] body select:hover:not(:disabled) {
  --select-control-arrow-zone: #203047;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.22);
}

:root[data-theme="dark"] body select:focus,
:root[data-theme="dark"] body select:focus-visible {
  --select-control-arrow-zone: #1b3555;
  box-shadow: 0 0 0 3px rgba(91, 156, 255, 0.2), 0 4px 12px rgba(0, 0, 0, 0.22);
}

:root[data-theme="dark"] body select option:checked {
  color: #b9d6ff;
}

@media (max-width: 620px) {
  body select {
    min-height: 44px;
    padding-right: 46px;
    padding-left: 13px;
    font-size: 13px;
  }
}

/* Interactive dropdown menu: the native select remains connected to its form,
   while these controls provide the visible trigger and clickable option list. */
body .tw-select {
  position: relative;
  display: block;
  width: 100%;
  min-width: 0;
  max-width: 100%;
}

body select.tw-select-native {
  position: absolute !important;
  inset: 0 !important;
  z-index: -1 !important;
  width: 100% !important;
  height: 100% !important;
  min-height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

body .tw-select-trigger {
  position: relative;
  width: 100%;
  min-width: 0;
  min-height: 42px;
  padding: 0 46px 0 14px;
  border: 1px solid var(--select-control-border);
  border-radius: 11px;
  display: flex;
  align-items: center;
  color: var(--select-control-text);
  background: var(--select-control-bg);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.045), inset 0 1px 0 rgba(255, 255, 255, 0.72);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.25;
  text-align: left;
  cursor: pointer;
  overflow: hidden;
  transition: border-color 160ms ease, box-shadow 160ms ease, background-color 160ms ease, transform 160ms ease;
}

body[data-page="teacher"] .tw-select-trigger {
  font-size: 12px;
}

body .tw-select-value {
  position: relative;
  z-index: 1;
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body .tw-select-chevron {
  position: absolute;
  inset: 0 0 0 auto;
  width: 40px;
  border-left: 1px solid color-mix(in srgb, var(--select-control-border) 70%, transparent);
  display: grid;
  place-items: center;
  background: var(--select-control-arrow-zone);
  pointer-events: none;
  transition: background-color 160ms ease;
}

body .tw-select-chevron::before {
  width: 7px;
  height: 7px;
  border-right: 2px solid var(--select-control-muted);
  border-bottom: 2px solid var(--select-control-muted);
  content: "";
  transform: translateY(-2px) rotate(45deg);
  transition: transform 180ms ease, border-color 160ms ease;
}

body .tw-select-trigger:hover:not(:disabled) {
  border-color: var(--select-control-hover-border);
  background: color-mix(in srgb, var(--select-control-bg) 96%, #eaf3ff);
  box-shadow: 0 4px 12px rgba(31, 111, 235, 0.09), inset 0 1px 0 rgba(255, 255, 255, 0.78);
}

body .tw-select-trigger:focus-visible,
body .tw-select.is-open .tw-select-trigger {
  border-color: var(--select-control-focus);
  outline: 0;
  box-shadow: 0 0 0 3px rgba(40, 120, 232, 0.15), 0 4px 12px rgba(31, 111, 235, 0.09);
}

body .tw-select.is-open .tw-select-chevron {
  background: #e7f1ff;
}

body .tw-select.is-open .tw-select-chevron::before {
  border-color: var(--select-control-focus);
  transform: translateY(2px) rotate(225deg);
}

body .tw-select.is-placeholder .tw-select-value {
  color: var(--select-control-muted);
}

body .tw-select.is-disabled .tw-select-trigger,
body .tw-select-trigger:disabled {
  border-color: #e1e7ee;
  color: var(--select-control-muted);
  background: #f7f9fb;
  box-shadow: none;
  cursor: not-allowed;
  opacity: 0.78;
}

body .tw-select.is-invalid .tw-select-trigger {
  border-color: #dc4b5c;
  box-shadow: 0 0 0 3px rgba(220, 75, 92, 0.13);
}

body .tw-select-menu {
  position: fixed;
  z-index: 3400;
  display: grid;
  gap: 3px;
  margin: 0;
  padding: 7px;
  border: 1px solid var(--select-control-border);
  border-radius: 13px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  color: var(--select-control-text);
  background: var(--select-control-option-bg);
  box-shadow: 0 18px 42px rgba(15, 23, 42, 0.18), 0 4px 12px rgba(15, 23, 42, 0.08);
  scrollbar-color: #bcc9d8 transparent;
  scrollbar-width: thin;
  animation: tw-select-menu-in 150ms cubic-bezier(.2, .8, .2, 1) both;
}

body .tw-select-menu[hidden] {
  display: none !important;
}

body .tw-select-menu[data-placement="bottom"] {
  transform-origin: top center;
}

body .tw-select-menu[data-placement="top"] {
  transform-origin: bottom center;
}

body .tw-select-menu::-webkit-scrollbar {
  width: 8px;
}

body .tw-select-menu::-webkit-scrollbar-track {
  background: transparent;
}

body .tw-select-menu::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 999px;
  background: #bcc9d8;
  background-clip: padding-box;
}

body .tw-select-option {
  width: 100%;
  min-width: 0;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 9px;
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  color: var(--select-control-text);
  background: transparent;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
  text-align: left;
  cursor: pointer;
  transition: color 130ms ease, border-color 130ms ease, background-color 130ms ease, transform 130ms ease;
}

body .tw-select-option:hover:not(:disabled),
body .tw-select-option:focus-visible {
  border-color: #d7e6f8;
  outline: 0;
  color: #185fcf;
  background: #f1f6fd;
}

body .tw-select-option:active:not(:disabled) {
  transform: scale(0.985);
}

body .tw-select-option.is-selected {
  border-color: #c8dcf8;
  color: #185fcf;
  background: var(--select-control-option-selected);
  font-weight: 700;
}

body .tw-select-option:disabled {
  color: var(--select-control-muted);
  cursor: not-allowed;
  opacity: 0.52;
}

body .tw-select-option-check {
  width: 20px;
  height: 20px;
  border: 1px solid #d8e2ee;
  border-radius: 6px;
  display: grid;
  place-items: center;
  color: transparent;
  background: #fff;
  font-size: 12px;
  font-weight: 900;
}

body .tw-select-option.is-selected .tw-select-option-check {
  border-color: var(--select-control-focus);
  color: #fff;
  background: var(--select-control-focus);
  box-shadow: 0 3px 8px rgba(40, 120, 232, 0.2);
}

body .tw-select-option-text {
  min-width: 0;
  overflow-wrap: anywhere;
}

body .tw-select-group-label {
  padding: 8px 10px 4px 38px;
  color: var(--select-control-muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

body .tw-select-empty {
  padding: 14px 12px;
  color: var(--select-control-muted);
  font-size: 12px;
  font-weight: 600;
  text-align: center;
}

body .input-wrap .tw-select {
  height: 100%;
}

body .input-wrap .tw-select-trigger {
  height: 100%;
  min-height: 0;
  padding-left: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

body .input-wrap .tw-select-trigger:hover:not(:disabled),
body .input-wrap .tw-select-trigger:focus-visible,
body .input-wrap .tw-select.is-open .tw-select-trigger {
  border: 0;
  background: transparent;
  box-shadow: none;
}

body[data-page="teacher"] .teacher-section[data-view="students"] .student-toolbar .tw-select-trigger {
  height: 44px;
  min-height: 44px;
}

body :is(.modal-form-stack, .management-form, .certificate-generator-form, .student-drawer-panel) .tw-select-trigger {
  min-height: 46px;
}

:root[data-theme="dark"] body .tw-select-trigger {
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.24), inset 0 1px 0 rgba(255, 255, 255, 0.035);
}

:root[data-theme="dark"] body .tw-select-trigger:hover:not(:disabled) {
  background: #151f2e;
  box-shadow: 0 5px 14px rgba(0, 0, 0, 0.25);
}

:root[data-theme="dark"] body .tw-select.is-open .tw-select-chevron {
  background: #1b3555;
}

:root[data-theme="dark"] body .tw-select-menu {
  border-color: #354255;
  background: #151d28;
  box-shadow: 0 20px 46px rgba(0, 0, 0, 0.48), 0 5px 14px rgba(0, 0, 0, 0.26);
}

:root[data-theme="dark"] body .tw-select-option-check {
  border-color: #3a485c;
  background: #111925;
}

:root[data-theme="dark"] body .tw-select-option:hover:not(:disabled),
:root[data-theme="dark"] body .tw-select-option:focus-visible {
  border-color: #315987;
  color: #b9d6ff;
  background: #182a40;
}

:root[data-theme="dark"] body .tw-select-option.is-selected {
  border-color: #315987;
  color: #b9d6ff;
  background: #1a3658;
}

:root[data-theme="dark"] body .tw-select.is-disabled .tw-select-trigger,
:root[data-theme="dark"] body .tw-select-trigger:disabled {
  border-color: #2b3645;
  background: #111722;
}

@keyframes tw-select-menu-in {
  from {
    opacity: 0;
    transform: translateY(-4px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (max-width: 620px) {
  body .tw-select-trigger {
    min-height: 44px;
    padding-right: 46px;
    padding-left: 13px;
    font-size: 13px;
  }

  body .tw-select-menu {
    max-width: calc(100vw - 16px);
  }

  body .tw-select-option {
    min-height: 44px;
    font-size: 13px;
  }
}

@media (prefers-reduced-motion: reduce) {
  body .tw-select-menu,
  body .tw-select-trigger,
  body .tw-select-chevron,
  body .tw-select-chevron::before,
  body .tw-select-option {
    animation: none;
    transition: none;
  }
}
