:root {
  color-scheme: only light;
  --theme-bg: #eaf7ff;
  --theme-surface: #fff;
  --theme-raised: #f2f8ff;
  --theme-selected: #e2f0ff;
  --theme-ink: #102b4a;
  --theme-muted: #486581;
  --theme-line: #bdd0e3;
  --theme-accent: #1758a8;
  --theme-shadow: 0 9px 27px #0c204229;
}

:root[data-climb-theme="dark"] {
  color-scheme: only dark;
  --theme-bg: #081226;
  --theme-surface: #11203d;
  --theme-elevated: #142647;
  --theme-raised: #1e355e;
  --theme-hover: #274477;
  --theme-selected: #1e3a6e;
  --theme-ink: #f8fafc;
  --theme-control-ink: #f1f5f9;
  --theme-secondary: #cbd5e1;
  --theme-muted: #94a3b8;
  --theme-line: rgb(148 184 232 / .22);
  --theme-elevated-line: rgb(148 184 232 / .28);
  --theme-accent: #a4d5ff;
  --theme-focus: #93c5fd;
  --theme-danger: #fca5a5;
  --theme-danger-fill: rgb(220 38 38 / .16);
  --theme-danger-hover: rgb(220 38 38 / .24);
  --theme-success-action: #176238;
  --theme-success-ink: #a7f3d0;
  --theme-success-surface: #153d37;
  --theme-warning-ink: #ffda92;
  --theme-warning-surface: #3b3024;
  --theme-shadow: 0 12px 34px rgb(2 7 19 / .55);
  background: var(--theme-bg);
}

.classroom-theme-symbols {
  position: absolute;
  overflow: hidden;
  pointer-events: none;
}

.classroom-theme {
  position: relative;
  z-index: 6;
  color: var(--theme-ink);
}

.classroom-theme-floating {
  position: fixed;
  z-index: 41;
  inset-inline-end: max(14px, env(safe-area-inset-right));
  inset-block-end: max(14px, env(safe-area-inset-bottom));
}

.classroom-theme-floating:dir(rtl) { inset-inline-end: max(14px, env(safe-area-inset-left)); }

body:has(dialog:modal, .modal-backdrop[style*="flex"]) .classroom-theme-floating {
  display: none;
}

@media (max-width: 640px) {
  body:has(.signed-in-dashboard) .classroom-theme-floating {
    inset-block-end: calc(74px + env(safe-area-inset-bottom));
  }
}

@media (orientation: landscape) and (max-height: 540px) {
  body:has(.signed-in-dashboard) .classroom-theme-floating {
    inset-block-end: calc(57px + env(safe-area-inset-bottom));
  }
}

.classroom-theme-board-row {
  min-inline-size: 0;
  justify-self: stretch;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}

.classroom-theme-board-row #mirrorWhiteboardReveal {
  flex: 1 1 auto;
  min-inline-size: 0;
}

.classroom-theme :is(button, svg) { flex: none; }
.classroom-theme svg { display: block; width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

body .classroom-theme .classroom-theme-toggle,
body :is(#climbTimer, #mirrorWhiteboard) .classroom-theme .classroom-theme-toggle {
  display: grid;
  place-items: center;
  inline-size: 44px;
  block-size: 44px;
  min-block-size: 44px;
  padding: 0;
  color: var(--theme-ink);
  background: var(--theme-surface);
  border: 1px solid var(--theme-line);
  border-radius: 50%;
  box-shadow: var(--theme-shadow);
  cursor: pointer;
}

body #mirrorWhiteboard .classroom-theme .classroom-theme-toggle {
  inline-size: 38px;
  block-size: 38px;
  min-block-size: 38px;
}

.classroom-theme-panel {
  position: absolute;
  inset-inline-end: 0;
  inset-block-end: calc(100% + 7px);
  display: grid;
  gap: 3px;
  inline-size: 154px;
  padding: 7px;
  color: var(--theme-ink);
  background: var(--theme-surface);
  border: 1px solid var(--theme-line);
  border-radius: 13px;
  box-shadow: var(--theme-shadow);
  text-align: start;
}

.classroom-theme-below .classroom-theme-panel { inset-block: calc(100% + 7px) auto; }
.classroom-theme-title { margin: 2px 7px 4px; color: var(--theme-muted); font-size: .84rem; font-weight: 750; }

body .classroom-theme-panel button[data-theme-choice],
body :is(#climbTimer, #mirrorWhiteboard) .classroom-theme-panel button[data-theme-choice] {
  display: grid;
  grid-template-columns: 19px 1fr 19px;
  align-items: center;
  justify-items: start;
  gap: 7px;
  min-block-size: 40px;
  padding: 4px 7px;
  color: var(--theme-ink);
  background: transparent;
  border: 0;
  border-radius: 8px;
  box-shadow: none;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

body .classroom-theme .classroom-theme-panel button[data-theme-choice]:is(:hover, [aria-pressed="true"]),
body :is(#climbTimer, #mirrorWhiteboard) .classroom-theme-panel button[data-theme-choice]:is(:hover, [aria-pressed="true"]) {
  background: var(--theme-selected);
}

.classroom-theme-check { visibility: hidden; color: var(--theme-accent); }
[data-theme-choice][aria-pressed="true"] .classroom-theme-check { visibility: visible; }

/* The whiteboard uses the same paper and ink colours on the controller and projector. */
.whiteboard-area, .whiteboard-paper, #mirrorWhiteboardProjector { color-scheme: only light; }

:root:not([data-climb-theme="dark"]) #climbTimer {
  --timer-light-line: #bfd4e8;
  color: #142f50;
  background: var(--modal-mountains) center bottom / 100% clamp(76px, 24%, 152px) no-repeat,
    radial-gradient(ellipse at 50% 42%, #fff 8%, #e5f2ff 88%);
  border-color: #9fbddd;
}

:root:not([data-climb-theme="dark"]) #climbTimer :is(h2, #timerFace) { color: #142f50; text-shadow: none; }
:root:not([data-climb-theme="dark"]) #climbTimer :is(.journey-note, #timerStatus) { color: #304c6c; }
:root:not([data-climb-theme="dark"]) #climbTimer .climb-tool-error { color: #9b2343; }
:root:not([data-climb-theme="dark"]) #climbTimer > .climb-tool-actions { color: #142f50; background: #f6fbff; border-color: var(--timer-light-line); box-shadow: none; }
:root:not([data-climb-theme="dark"]) #climbTimer :is(.climb-tool-close, #timerReset, #timerProject) {
  color: #142f50;
  background: #f7fbff;
  border-color: #9cb9d6;
  box-shadow: 0 2px 4px #19375724;
}

:root:not([data-climb-theme="dark"]) #timerRing {
  background: conic-gradient(#ffd34d, #dc8d04 var(--timer-remaining, 100%), #c7d9ed 0%);
  box-shadow: 0 0 0 3px #e4a01f60, 0 4px 22px #6848123d;
}

:root:not([data-climb-theme="dark"]) #timerRing::before {
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Ccircle cx='50' cy='50' r='44' fill='none' stroke='%23a67015' stroke-width='1.8' pathLength='60' stroke-dasharray='.4 4.6'/%3E%3C/svg%3E") center / 100% no-repeat,
    radial-gradient(circle, #fff 48%, #f4f9ff);
  box-shadow: inset 0 0 12px #a980183b;
}

/* Alpine Night. Pair each surface with its text and interaction states. */
:root[data-climb-theme="dark"] body {
  color: var(--theme-ink);
  background: var(--theme-bg);
}

:root[data-climb-theme="dark"] :is(.welcome-hero, .welcome-steps, .welcome-mode .site-information) {
  background: var(--theme-bg);
  border-color: var(--theme-line);
}

:root[data-climb-theme="dark"] :is(
  .welcome-copy h2, .welcome-step h3, .welcome-auth-content h2,
  .signed-in-dashboard .workspace-grid :is(.panel-heading h3, .stage-heading h2),
  .goal-counter, .menu-caption strong, .site-information-heading strong, .information-content :is(h2, h3)
) { color: var(--theme-ink); }

:root[data-climb-theme="dark"] :is(
  .welcome-copy p, .welcome-step p, .welcome-mode .site-information-heading p, .welcome-auth-content > p,
  .panel-heading p, .stage-progress span, .goal-description, .goal-status, .empty-state p,
  .menu-caption, .information-footnote, .sign-in-identity
) { color: var(--theme-secondary); }

:root[data-climb-theme="dark"] .welcome-step + .welcome-step { border-color: var(--theme-line); }
:root[data-climb-theme="dark"] .welcome-step svg { color: #ffc960; }
:root[data-climb-theme="dark"] :is(.welcome-actions a, .site-information a, .sign-in-privacy a, .climb-public-legal a) { color: var(--theme-accent); }
:root[data-climb-theme="dark"] .welcome-actions button.welcome-sign-in { background: #245b9b; border-color: var(--theme-elevated-line); }

:root[data-climb-theme="dark"] :is(
  .site-information, .site-information details[open], .sign-in-privacy,
  .signed-in-dashboard .workspace-grid > .card-panel, .signed-in-dashboard .workspace-grid .goal-card,
  #mirrorWhiteboard, #phoneVerification .phone-card
) {
  color: var(--theme-ink);
  background: var(--theme-surface);
  border-color: var(--theme-line);
}

:root[data-climb-theme="dark"] :is(
  #googleAuthModal .welcome-auth-card, .classroom-theme-panel, .climb-utility:where(:not(#climbTimer)), .climb-mirror,
  #phoneVerification, #lessonBoardEditor, #lessonReminderDialog, #practiceDialog,
  .signed-in-dashboard #dashboardDock,
  .signed-in-dashboard :is(#dashboardPlannerPanel, #dashboardFilesPanel, #teacherMenuWrap #teacherMenuPanel),
  .signed-in-dashboard #dashboardDock :is(#classMenuPanel, #quickToolsPanel)
) {
  color: var(--theme-ink);
  background: var(--theme-elevated);
  border-color: var(--theme-elevated-line);
  box-shadow: var(--theme-shadow);
}

:root[data-climb-theme="dark"] :is(
  .welcome-auth-close, .information-grid summary, .sign-in-privacy summary, .firebase-email summary,
  .mobile-panel-title h2, #quickToolsPanel .tools-panel-heading h2
) { color: var(--theme-ink); }

:root[data-climb-theme="dark"] :is(
  .firebase-email, .firebase-login input, .signed-in-dashboard .workspace-grid .progress-meter,
  #phoneVerification :is(input, select, .phone-secondary, .phone-steps),
  .mirror-body :is(input, select), .climb-mirror .mirror-actions button
) {
  color: var(--theme-control-ink);
  background: var(--theme-raised);
  border-color: var(--theme-elevated-line);
}

:root[data-climb-theme="dark"] :is(.welcome-auth-close:hover, .firebase-email summary:hover, .firebase-email[open] summary) {
  background: var(--theme-hover);
}

:root[data-climb-theme="dark"] .firebase-login .firebase-google {
  color-scheme: only light;
  color: #1f1f1f;
  background: #fff;
}

:root[data-climb-theme="dark"] .welcome-actions .release-open { color: var(--theme-accent); }
:root[data-climb-theme="dark"] #googleAuthModal :is(.firebase-divider, .firebase-preference small) {
  color: var(--theme-secondary);
}
:root[data-climb-theme="dark"] #googleAuthModal .firebase-email { background: transparent; }
:root[data-climb-theme="dark"] #googleAuthModal .firebase-email summary {
  color: var(--theme-control-ink);
  background: var(--theme-raised);
  border-color: #5b78a0;
}
:root[data-climb-theme="dark"] #googleAuthModal .firebase-email summary svg { color: var(--theme-accent); }
:root[data-climb-theme="dark"] #googleAuthModal .firebase-email :is(summary:hover, summary:focus-visible),
:root[data-climb-theme="dark"] #googleAuthModal .firebase-email[open] summary { background: var(--theme-hover); }
:root[data-climb-theme="dark"] #googleAuthModal .firebase-login :focus-visible { outline-color: var(--theme-focus); }

:root[data-climb-theme="dark"] #phoneVerification :is(.phone-card p:not([data-tone]), .phone-steps strong) { color: var(--theme-secondary); }
:root[data-climb-theme="dark"] #phoneVerification :is(.phone-link, .phone-legal-links :is(a,button)) { color: var(--theme-accent); }
:root[data-climb-theme="dark"] #phoneVerification .phone-card .phone-message:not([data-tone]) { background: var(--theme-raised); }

/* Secondary actions, including the landscape stage footer and Undo. */
:root[data-climb-theme="dark"] .signed-in-dashboard .workspace-grid .lesson-controls {
  background: var(--theme-surface);
  border-block-start: 1px solid var(--theme-line);
}

:root[data-climb-theme="dark"] :is(
  .signed-in-dashboard .workspace-grid :is(.btn-glass, .btn-slate), .classroom-theme .classroom-theme-toggle,
  #quickToolsPanel .panel-close, .signed-in-dashboard #teacherMenuPanel .panel-close,
  .climb-utility:where(:not(#climbTimer)) .climb-tool-close, #lessonBoardEditor .lesson-editor-head button,
  #lessonReminderDialog .lesson-editor-head button,
  #climbGroups :is(#groupsDone, #groupsReset, #groupsClass, #groupsAttendanceBtn),
  #lessonBoardEditor :is(#lessonBoardCancel, #lessonBoardQuickCheck, #lessonBoardSettings, .lesson-format .btn)
) {
  color: var(--theme-control-ink);
  background: var(--theme-raised);
  border: 1px solid var(--theme-elevated-line);
  box-shadow: none;
}

:root[data-climb-theme="dark"] :is(
  .signed-in-dashboard .workspace-grid :is(.btn-glass, .btn-slate), .classroom-theme .classroom-theme-toggle,
  #quickToolsPanel .panel-close, .signed-in-dashboard #teacherMenuPanel .panel-close,
  .climb-utility:where(:not(#climbTimer)) .climb-tool-close, #lessonBoardEditor .lesson-editor-head button,
  #lessonReminderDialog .lesson-editor-head button
):hover:not(:disabled) { background: var(--theme-hover); }

:root[data-climb-theme="dark"] .signed-in-dashboard .workspace-grid .lesson-controls button:disabled {
  color: var(--theme-muted);
  opacity: 1;
}

:root[data-climb-theme="dark"] .signed-in-dashboard .workspace-grid .mountain-canvas { background: var(--theme-surface); }

:root[data-climb-theme="dark"] .signed-in-dashboard .workspace-grid .btn-emerald {
  color: var(--theme-ink);
  background: var(--theme-success-action);
  border-color: var(--theme-elevated-line);
  box-shadow: none;
}

:root[data-climb-theme="dark"] .signed-in-dashboard .workspace-grid .btn-emerald:hover:not(:disabled) { background: #1c7342; }

:root[data-climb-theme="dark"] .signed-in-dashboard .dashboard-view-switch { background: var(--theme-surface); }
:root[data-climb-theme="dark"] .signed-in-dashboard .dashboard-view-switch button { color: var(--theme-secondary); }
:root[data-climb-theme="dark"] .signed-in-dashboard .dashboard-view-switch button[aria-pressed="true"] {
  color: #fff;
  background: var(--theme-selected);
}

:root[data-climb-theme="dark"] .signed-in-dashboard #dashboardDock :is(
  #quickToolsToggle, #practiceBtn, #dashboardBoardBtn, #dashboardFilesToggle, #classMenuToggle
) { color: var(--theme-secondary); }

:root[data-climb-theme="dark"] .signed-in-dashboard #dashboardDock :is(
  #quickToolsToggle, #practiceBtn, #dashboardBoardBtn, #dashboardFilesToggle, #classMenuToggle
):hover:not(:disabled) { color: #fff; background: var(--theme-hover); }

:root[data-climb-theme="dark"] .signed-in-dashboard #dashboardDock :is(
  #quickToolsToggle, #dashboardFilesToggle, #classMenuToggle
)[aria-expanded="true"],
:root[data-climb-theme="dark"] body:has(#practiceDialog[open]) #dashboardDock #practiceBtn,
:root[data-climb-theme="dark"] body:has(#lessonBoardEditor[open]) #dashboardDock #dashboardBoardBtn {
  color: #fff;
  background: var(--theme-selected);
  box-shadow: inset 0 -2px #3b82f6;
}

:root[data-climb-theme="dark"] .signed-in-dashboard #dashboardDock button:disabled {
  color: var(--theme-muted);
  opacity: 1;
}

/* Popovers have separate treatment for identity cards, actions and section labels. */
:root[data-climb-theme="dark"] .signed-in-dashboard :is(
  #classMenuPanel :is(button, a.btn, #classAttendanceBtn), #dashboardPlannerPanel :is(button, a.btn),
  #dashboardFilesPanel :is(button, a.btn), #teacherMenuPanel :is(button, a.btn)
) { color: var(--theme-control-ink); }

:root[data-climb-theme="dark"] .signed-in-dashboard :is(
  #classMenuPanel, #dashboardPlannerPanel, #dashboardFilesPanel, #teacherMenuPanel
) :is(button, a.btn):hover:not(:disabled) { background: var(--theme-hover); }

:root[data-climb-theme="dark"] .signed-in-dashboard :is(
  #classMenuPanel .class-menu-identity, #classMenuPanel #addClassBtn,
  #dashboardPlannerPanel #timetableMode, #dashboardFilesPanel .files-panel-heading,
  #dashboardFilesPanel #driveShortcutLinks a, #teacherMenuPanel .account-identity,
  #teacherMenuPanel .panel-language, #teacherMenuPanel #dashboardLanguage
) {
  color: var(--theme-ink);
  background: var(--theme-raised);
  border-color: var(--theme-elevated-line);
}

:root[data-climb-theme="dark"] .signed-in-dashboard :is(#dashboardClassBadge, #dashboardFilesClass, #teacherMenuPanel .panel-language [aria-pressed="true"]) {
  color: #fff;
  background: var(--theme-selected);
}

:root[data-climb-theme="dark"] .signed-in-dashboard #dashboardFilesPanel #driveShortcutLinks a:hover {
  background: var(--theme-hover);
}

:root[data-climb-theme="dark"] .signed-in-dashboard :is(
  #lessonScheduleText, .dashboard-panel p, .file-provider small, #teacherMenuPanel .panel-language button
) { color: var(--theme-secondary); }

:root[data-climb-theme="dark"] .signed-in-dashboard :is(#classMenuPanel [data-class-section], .tools-section-title) {
  color: var(--theme-muted);
  border-color: var(--theme-elevated-line);
}

:root[data-climb-theme="dark"] .signed-in-dashboard :is(
  #dashboardAccountPreferences, #dashboardPlannerActions, #dashboardFilesPanel :is(#setupDriveShortcutBtn, #editDriveShortcutBtn)
) { border-color: var(--theme-elevated-line); }

:root[data-climb-theme="dark"] .signed-in-dashboard :is(
  #classMenuPanel #deleteClassBtn, #teacherMenuPanel #accountSignOutBtn
) { color: var(--theme-danger); background: var(--theme-danger-fill); }

:root[data-climb-theme="dark"] .signed-in-dashboard :is(
  #classMenuPanel #deleteClassBtn, #teacherMenuPanel #accountSignOutBtn
):hover:not(:disabled) { color: var(--theme-danger); background: var(--theme-danger-hover); }

:root[data-climb-theme="dark"] .signed-in-dashboard :is(
  #classMenuPanel, #dashboardPlannerPanel, #dashboardFilesPanel, #teacherMenuPanel
) button:disabled { color: var(--theme-muted); opacity: 1; }

/* Tool colours identify categories while the label and subtitle share readable tokens. */
:root[data-climb-theme="dark"] .signed-in-dashboard #quickToolsList .quick-tool {
  --tile-bg: rgb(var(--tool-tint, 37 99 235) / .16);
  --tile-line: rgb(var(--tool-tint, 37 99 235) / .45);
  --tile-ink: rgb(var(--tool-tint, 37 99 235) / .38);
}

:root[data-climb-theme="dark"] #quickToolsList :is([data-tool="picker"], [data-tool="stage1"]) { --tool-tint: 217 119 6; }
:root[data-climb-theme="dark"] #quickToolsList :is([data-tool="noise"], [data-tool="stage4"]) { --tool-tint: 13 148 136; }
:root[data-climb-theme="dark"] #quickToolsList :is([data-tool="groups"], [data-tool="seats"]) { --tool-tint: 124 58 237; }
:root[data-climb-theme="dark"] #quickToolsList [data-tool="brain-booster"] { --tool-tint: 190 70 161; }

:root[data-climb-theme="dark"] .signed-in-dashboard #quickToolsList .quick-tool-action { color: var(--theme-ink); }
:root[data-climb-theme="dark"] .signed-in-dashboard #quickToolsList .quick-tool-action:hover:not(:disabled) {
  background: rgb(var(--tool-tint, 37 99 235) / .12);
}

:root[data-climb-theme="dark"] .signed-in-dashboard #quickToolsList .quick-tool-status { color: var(--theme-secondary); }
:root[data-climb-theme="dark"] .signed-in-dashboard #quickToolsList .quick-tool:not([data-state="utility"]) .quick-tool-status {
  background: var(--theme-surface);
  border-color: var(--theme-elevated-line);
}
:root[data-climb-theme="dark"] .signed-in-dashboard #quickToolsList .tools-section-divider { border-color: var(--theme-line); }

/* Opened utilities retain their existing controls, assets and behaviour. */
:root[data-climb-theme="dark"] #climbTimer {
  background: var(--modal-mountains) center bottom / 100% clamp(94px, 29%, 184px) no-repeat,
    radial-gradient(ellipse at 55% 70%, #173d72, var(--modal-navy) 86%);
  border-color: #426890;
  box-shadow: inset 0 0 0 1px #8db9e126, 0 18px 48px #04102c66;
}

:root[data-climb-theme="dark"] :is(#climbPicker, #climbNoise) {
  --modal-glass: var(--theme-raised);
  --modal-glass-line: var(--theme-elevated-line);
  --modal-glass-shadow: none;
  background: var(--modal-mountains) center bottom / 100% clamp(84px, 22%, 152px) no-repeat, var(--theme-elevated);
}

:root[data-climb-theme="dark"] :is(
  #climbGroups #groupsCount,
  #climbGroups .climb-group-field, #climbGroups #groupsHint,
  #lessonBoardEditor .lesson-format, #lessonBoardEditor #lessonBoardEmpty, #lessonBoardEditor .lesson-editor-footer,
  #lessonBoardEditor .lesson-editor-row :is(select, input[type="date"]),
  #practiceDialog #practiceSearch, #lessonReminderList .btn,
  #mirrorWhiteboard .whiteboard-header, #mirrorWhiteboardTools, #mirrorWhiteboardZoom, #mirrorWhiteboardPaperOptions
) {
  background: var(--theme-surface);
  color: var(--theme-control-ink);
  border-color: var(--theme-elevated-line);
}

:root[data-climb-theme="dark"] :is(
  #groupsHint, #lessonReminderDate, #lessonReminderEmpty, #lessonReminderDeviceStatus,
  #lessonBoardEditor .lesson-format small, #lessonBoardEditor #lessonBoardEmpty p
) { color: var(--theme-secondary); }

:root[data-climb-theme="dark"] :is(
  #practiceDialog .practice-choice, #practiceDialog #practiceFilters button,
  #practiceDialog #practiceClassSection, #practiceDialog .practice-close,
  #dayOneWelcome .day-one-action, #dayOneMountainPill
) {
  color: var(--theme-control-ink);
  background: var(--theme-raised);
  border-color: var(--theme-elevated-line);
}

:root[data-climb-theme="dark"] :is(
  #practiceDialog .practice-choice, #practiceDialog #practiceFilters button,
  #dayOneWelcome .day-one-action
):hover:not(:disabled) { background: var(--theme-hover); }

:root[data-climb-theme="dark"] #practiceDialog #practiceFilters button[aria-pressed="true"] {
  color: #fff;
  background: var(--theme-selected);
  border-color: var(--theme-accent);
}

:root[data-climb-theme="dark"] :is(
  #dayOneWelcome, #pendingJourneyPanel, #practiceDialog :is(h3, h4)
) { color: var(--theme-ink); }

:root[data-climb-theme="dark"] :is(
  #pendingJourneyPanel p, .day-one-intro, .day-one-action small, .day-one-footer-note
) { color: var(--theme-secondary); }

:root[data-climb-theme="dark"] #lessonReminderList .btn:hover { background: var(--theme-hover); }

:root[data-climb-theme="dark"] #lessonBoardEditor .lesson-editable {
  color-scheme: only light;
  color: #122541;
}

:root[data-climb-theme="dark"] #mirrorWhiteboard button:not([data-ink-setting], .classroom-theme-toggle, [data-theme-choice], #mirrorWhiteboardClose) {
  color: var(--theme-control-ink);
  background: var(--theme-raised);
  border-color: var(--theme-elevated-line);
}

:root[data-climb-theme="dark"] #mirrorWhiteboard button[aria-pressed="true"]:not([data-ink-setting], [data-theme-choice]) {
  background: var(--theme-selected);
  border-color: var(--theme-accent);
}

:root[data-climb-theme="dark"] #mirrorWhiteboard #mirrorWhiteboardClose {
  color: var(--theme-danger);
  background: var(--theme-danger-fill);
  border-color: var(--theme-elevated-line);
}

:root[data-climb-theme="dark"] :is(#dashboardDock, .climb-utility, .classroom-theme, #dashboardPlannerPanel, #teacherMenuPanel) :is(button, a, input, select):focus-visible {
  outline: 2px solid var(--theme-focus);
  outline-offset: 2px;
}

@media (orientation: landscape) and (max-height: 540px) {
  :root[data-climb-theme="dark"] .signed-in-dashboard #dashboardDock :is(#classMenuPanel, #dashboardFilesPanel) {
    max-height: min(75dvh, calc(100dvh - 86px - env(safe-area-inset-top) - env(safe-area-inset-bottom)));
  }

  :root[data-climb-theme="dark"] .signed-in-dashboard:not(.day-one-dashboard) #dashboardDock {
    padding-inline: max(62px, env(safe-area-inset-left)) max(62px, env(safe-area-inset-right));
  }

  :root[data-climb-theme="dark"] body:has(.signed-in-dashboard:not(.day-one-dashboard)) .classroom-theme-floating {
    inset-block-end: calc(2px + env(safe-area-inset-bottom));
  }

  :root[data-climb-theme="dark"] .signed-in-dashboard #dashboardDock :is(#quickTools, .dashboard-dock-slot:has(#quickTools)) {
    position: static;
  }

  :root[data-climb-theme="dark"] .signed-in-dashboard #dashboardDock #quickToolsPanel {
    position: absolute;
    /* Replace the portrait sheet inset when a narrow phone rotates. */
    inset: auto auto calc(100% + 6px) 50% !important;
    width: min(540px, calc(100dvw - 24px - env(safe-area-inset-left) - env(safe-area-inset-right)));
    max-height: calc(100dvh - 24px);
    max-height: calc(100dvh - 24px - max(64px, var(--landscape-dock-size, 0px)) - env(safe-area-inset-top));
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 0 12px 10px;
    border-radius: 16px;
  }

  :root[data-climb-theme="dark"] .signed-in-dashboard #dashboardDock #quickToolsPanel::before { display: none; }
  :root[data-climb-theme="dark"] #quickToolsPanel > .tools-panel-heading {
    position: sticky;
    inset-block-start: 0;
    flex: none;
    padding-block-start: max(8px, env(safe-area-inset-top));
    background: var(--theme-elevated);
  }

  :root[data-climb-theme="dark"] #quickToolsPanel > .tools-section-title { flex: none; }
  :root[data-climb-theme="dark"] #quickToolsPanel #quickToolsList {
    min-height: 0;
    overflow: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    padding: 2px 3px 5px;
  }

  :root[data-climb-theme="dark"] dialog.climb-utility:not(.timer-project, :fullscreen) {
    max-height: calc(100dvh - 24px);
    padding-block-start: 0;
    overscroll-behavior: contain;
  }

  :root[data-climb-theme="dark"] dialog.climb-utility:not(.timer-project, :fullscreen) > header {
    position: sticky;
    inset-block-start: 0;
    z-index: 9;
    margin-block-start: 0;
    padding-block: max(8px, env(safe-area-inset-top)) 7px;
    background: var(--theme-elevated);
    border-block-end: 1px solid var(--theme-line);
  }

  :root[data-climb-theme="dark"] #climbGroups > header::before { display: none; }
}

/* Account shortcuts and status rows own both parts of their colour pair. */
:root[data-climb-theme="dark"] .signed-in-dashboard #teacherMenuPanel :is(#ownerMenuLink, button#accountSecurityBtn) {
  color: var(--theme-control-ink);
  background: var(--theme-raised);
  border-color: var(--theme-elevated-line);
}

:root[data-climb-theme="dark"] .signed-in-dashboard #teacherMenuPanel :is(#ownerMenuLink, button#accountSecurityBtn):hover {
  color: var(--theme-ink);
  background: var(--theme-hover);
}

:root[data-climb-theme="dark"] #teacherMenuPanel :is(.session-next, #teacherMenuEmail) { color: var(--theme-secondary); }
:root[data-climb-theme="dark"] #teacherMenuPanel .menu-divider { background: var(--theme-elevated-line); }
:root[data-climb-theme="dark"] #teacherMenuPanel .session-shield { color: var(--theme-accent); background: var(--theme-selected); }

:root[data-climb-theme="dark"] #teacherMenuPanel #ownerMenuStatus,
:root[data-climb-theme="dark"] .signed-in-dashboard #teacherMenuPanel #phoneVerificationMenu[data-verification="verified"]:not([hidden]) {
  color: var(--theme-success-ink);
  background: var(--theme-success-surface);
  border-color: #487e6d;
}

:root[data-climb-theme="dark"] .signed-in-dashboard #teacherMenuPanel #phoneVerificationMenu[data-verification="unverified"]:not([hidden]) {
  --phone-shield-bg: var(--theme-danger-fill);
  color: var(--theme-danger);
  background: var(--theme-danger-fill);
  border-color: #986273;
}

:root[data-climb-theme="dark"] #accountSecurity {
  color: var(--theme-ink);
  background: var(--theme-elevated);
  border-color: var(--theme-elevated-line);
  box-shadow: var(--theme-shadow);
}

:root[data-climb-theme="dark"] #accountSecurity :is(.session-card, [data-session-stage="overview"], .session-status) {
  color: var(--theme-ink);
  background: var(--theme-surface);
  border-color: var(--theme-line);
}

:root[data-climb-theme="dark"] #accountSecurity :is(button:not(.session-danger, .session-danger-soft), input) {
  color: var(--theme-control-ink);
  background: var(--theme-raised);
  border-color: var(--theme-elevated-line);
}

:root[data-climb-theme="dark"] #accountSecurity button:not(.session-danger, .session-danger-soft):hover:not(:disabled) {
  background: var(--theme-hover);
}

:root[data-climb-theme="dark"] #accountSecurity :is(.session-heading, #accountDevices li) { border-color: var(--theme-elevated-line); }
:root[data-climb-theme="dark"] #accountSecurity :is(.session-or, #accountDevices small, #accountDevices li > span, #accountDevicesStatus) { color: var(--theme-secondary); }
:root[data-climb-theme="dark"] #accountSecurity #accountDevices li::before { filter: brightness(2.7); }

:root[data-climb-theme="dark"] #accountSecurity :is(.session-danger-soft, .session-status[data-error="true"]) {
  color: var(--theme-danger);
  background: var(--theme-danger-fill);
  border-color: var(--theme-elevated-line);
}

:root[data-climb-theme="dark"] #accountSecurity[data-stage="result"]::backdrop { background: #081226c9; }
:root[data-climb-theme="dark"] #accountSecurity .session-provider { border-color: var(--theme-elevated-line); }
:root[data-climb-theme="dark"] #accountSecurity .session-provider p { color: var(--theme-secondary); }
:root[data-climb-theme="dark"] #accountSecurity #accountMicrosoftStatus { color: var(--theme-success-ink); background: var(--theme-success-surface); }
:root[data-climb-theme="dark"] #accountSecurity #accountMicrosoftStatus[data-error="true"] { color: var(--theme-danger); background: var(--theme-danger-fill); }
:root[data-climb-theme="dark"] .firebase-login .firebase-microsoft {
  color-scheme: only dark;
  color: #fff;
  background: #2f2f2f;
  border-color: #8c8c8c;
}
:root[data-climb-theme="dark"] .firebase-login .firebase-microsoft:hover:not(:disabled) { background: #3b3b3b; }
:root[data-climb-theme="dark"] .firebase-login .firebase-error { color: var(--theme-danger); }

/* Mirror pairs a dark control surface with light copy; projected materials keep their own colours. */
:root[data-climb-theme="dark"] .climb-mirror :is(
  #mirrorStartPane h3, #mirrorDesktopTools h3, .mirror-pair-heading, .mirror-pdf-drop strong
) { color: var(--theme-ink); }

:root[data-climb-theme="dark"] .climb-mirror :is(
  #mirrorStartPane p, #mirrorPairCode p, .mirror-pdf-drop p, #mirrorDesktopFileStatus, .mirror-message,
  .mirror-screen div > span:not(#mirrorConnection), #mirrorProjectOverview, #mirrorSnapOpen small,
  #mirrorNoiseHint, #mirrorNoiseMic
) { color: var(--theme-secondary); }

:root[data-climb-theme="dark"] .climb-mirror :is(
  .mirror-pair-card, .mirror-pdf-drop, .mirror-footer, .mirror-screen, .mirror-tool,
  .mirror-scan-panel, #mirrorToolCard, #mirrorGroupResults
) {
  color: var(--theme-ink);
  background: var(--theme-surface);
  border-color: var(--theme-line);
}

:root[data-climb-theme="dark"] .climb-mirror .mirror-pdf-drop[data-dragging="true"] {
  background: var(--theme-selected);
  border-color: var(--theme-accent);
}

:root[data-climb-theme="dark"] .climb-mirror :is(
  .mirror-popover-button, #mirrorCopyCode, #mirrorPdfDrop[data-loaded="true"] #mirrorPickFile,
  #mirrorSnapOpen, .mirror-tools-count, #mirrorHomeTiles button, #mirrorWakeStatus
) {
  color: var(--theme-control-ink);
  background: var(--theme-raised);
  border-color: var(--theme-elevated-line);
}

:root[data-climb-theme="dark"] .climb-mirror :is(
  .mirror-popover-button, #mirrorCopyCode, #mirrorPdfDrop[data-loaded="true"] #mirrorPickFile,
  #mirrorSnapOpen, #mirrorHomeTiles button
):hover:not(:disabled) { background: var(--theme-hover); }

:root[data-climb-theme="dark"] .climb-mirror :is(
  #mirrorCopyCode svg, .mirror-pdf-drop > svg, #mirrorSnapOpen > svg, #mirrorToolCard summary svg
) { color: var(--theme-accent); }

:root[data-climb-theme="dark"] .climb-mirror #mirrorToolCard summary::after { color: var(--theme-secondary); }

:root[data-climb-theme="dark"] .climb-mirror :is(
  #mirrorDesktopConnection, #mirrorConnection, #mirrorWakeStatus[data-state="unavailable"]
) { color: var(--theme-warning-ink); background: var(--theme-warning-surface); }

:root[data-climb-theme="dark"] .climb-mirror :is(
  #mirrorDesktopConnection[data-connected="true"], #mirrorConnection[data-connected="true"], #mirrorWakeStatus[data-state="active"]
) { color: var(--theme-success-ink); background: var(--theme-success-surface); }

:root[data-climb-theme="dark"] .climb-mirror :is(.mirror-tile-icon, .mirror-tools-count) { color: var(--theme-control-ink); }
:root[data-climb-theme="dark"] .climb-mirror #mirrorHomeTiles button .mirror-tile-icon {
  background: var(--theme-selected);
  color: var(--theme-accent);
}
:root[data-climb-theme="dark"] .climb-mirror #mirrorPairCode #mirrorQR { color-scheme: only light; }

:root[data-climb-theme="dark"] :is(#mirrorStart, #mirrorStartFresh) { text-shadow: none; }
:root[data-climb-theme="dark"] .climb-mirror #mirrorStartFresh {
  color: var(--theme-control-ink);
  background: var(--theme-raised);
  border-color: var(--theme-elevated-line);
}

:root[data-climb-theme="dark"] .climb-mirror #mirrorClock { color: var(--theme-accent); }
:root[data-climb-theme="dark"] .climb-mirror #mirrorNoiseStatus { color: var(--theme-success-ink); }
:root[data-climb-theme="dark"] .climb-mirror .noise-warned #mirrorNoiseStatus { color: var(--theme-warning-ink); }

@media (orientation: landscape) and (max-height: 540px) and (pointer: coarse) {
  :root[data-climb-theme="dark"] .climb-mirror .mirror-tool { background: transparent; }

  :root[data-climb-theme="dark"] .climb-mirror :is(.mirror-tool-visual, .mirror-tool-settings) {
    color: var(--theme-ink);
    background: var(--theme-surface);
    border-color: var(--theme-line);
  }
}
