:root {
  color-scheme: dark;
  --student-accent: #a7f3d0;
  --student-accent-strong: #5eead4;
  --student-focus: #fbbf24;
  --student-success: #6ee7b7;
  --minimal-bg: #020305;
  --minimal-panel: #0a0e14;
  --minimal-line: rgba(255, 255, 255, .16);
  --minimal-text: #f8fafc;
  --minimal-muted: #a5adba;
}

html,
body {
  background: var(--minimal-bg);
  color: var(--minimal-text);
}

body { padding: 0; }

.lesson-shell {
  width: 100%;
  max-width: none;
}

.lesson-header {
  position: relative;
  z-index: 30;
  min-height: 60px;
  margin: 0;
  padding: 8px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
  background: rgba(2, 3, 5, .94);
}

.student-brand-mark {
  width: 34px;
  height: 34px;
  border: 1px solid rgba(167, 243, 208, .4);
  background: rgba(167, 243, 208, .1);
  color: var(--student-accent);
  box-shadow: none;
}

.lesson-header .eyebrow {
  color: var(--student-accent);
  font-size: 10px;
}

.lesson-header h1 { font-size: clamp(17px, 1.6vw, 23px); }
.slide-title,
#status { display: none; }

button,
select {
  border: 1px solid var(--minimal-line);
  background: rgba(24, 30, 39, .92);
  color: var(--minimal-text);
}

button:hover {
  border-color: rgba(167, 243, 208, .72);
  background: rgba(35, 44, 56, .98);
}

.lesson-grid,
.chapters-collapsed .lesson-grid {
  position: relative;
  display: block;
}

.stage-column {
  position: relative;
  min-height: calc(100vh - 60px);
  border: 0;
  border-radius: 0;
  background: #000;
  box-shadow: none;
}

.stage {
  flex: 1 1 auto;
  min-height: min(calc(100vh - 60px), 56.25vw);
  max-height: calc(100vh - 60px);
  aspect-ratio: 16 / 9;
  border-radius: 0;
  background: #000;
}

.stage::after {
  content: "";
  position: absolute;
  z-index: 5;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(0, 0, 0, .1), transparent 18%, transparent 72%, rgba(0, 0, 0, .36));
}

.stage-student-meta { display: none !important; }
.captions { background: rgba(0, 0, 0, .9); }

.transport {
  position: absolute;
  z-index: 18;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 36px 16px 14px;
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, .94) 46%);
  opacity: .96;
  transform: none;
}

.transport::before { display: none; }

#playPause {
  background: var(--student-accent);
  color: #05231b;
}

#restart,
#fullscreen,
#studentMoreControls,
#chapterToggle {
  background: rgba(20, 27, 36, .94);
}

#chapterToggle {
  border-color: rgba(167, 243, 208, .42);
  color: var(--student-accent);
}

#chapterToggle[aria-expanded="true"] {
  background: rgba(167, 243, 208, .16);
  box-shadow: inset 0 -2px 0 var(--student-accent);
}

#timeOutput,
.secondary-controls label { color: var(--minimal-muted); }

.secondary-controls {
  border-radius: 12px;
  background: rgba(7, 10, 15, .9);
}

.focus-panel {
  position: static;
  width: 100%;
  height: auto;
  max-height: none;
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto;
  gap: 12px 18px;
  padding: 16px;
  overflow: visible;
  border: 0;
  border-top: 1px solid var(--minimal-line);
  border-radius: 0;
  background: var(--minimal-panel);
  box-shadow: none;
}

.chapters-collapsed .focus-panel { display: none; }

.focus-heading {
  align-items: center;
}

.focus-panel .eyebrow {
  color: var(--student-accent);
}

.focus-heading h2 {
  margin: 2px 0 0;
  font-size: 15px;
}

#focusPosition {
  align-self: center;
  background: rgba(167, 243, 208, .1);
  color: var(--student-accent);
}

.focus-actions {
  align-self: center;
  display: flex;
  gap: 7px;
}

.focus-actions button {
  min-width: 88px;
  background: rgba(25, 32, 42, .9);
}

.focus-list {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-height: none;
  margin: 0;
  padding: 0;
  overflow: visible;
}

.focus-list li {
  flex: 1 1 170px;
  max-width: 300px;
}

.focus-list li + li { margin-top: 0; }

.focus-list button {
  width: 100%;
  min-height: 42px;
  display: block;
  padding: 9px 12px;
  overflow: hidden;
  border-color: rgba(255, 255, 255, .08);
  background: rgba(20, 26, 34, .8);
  color: var(--minimal-muted);
  font-size: 13px;
  font-weight: 740;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.focus-list .focus-state { display: none; }

.focus-list button[aria-current="true"],
.transcript-list button[aria-current="true"] {
  border-color: rgba(167, 243, 208, .44);
  background: rgba(167, 243, 208, .11);
  color: var(--minimal-text);
  box-shadow: inset 3px 0 0 var(--student-accent);
}

.transcript-panel:not([hidden]) {
  position: fixed;
  z-index: 80;
  top: auto;
  right: auto;
  bottom: 16px;
  left: 50%;
  width: min(920px, calc(100vw - 24px));
  max-height: min(58vh, 560px);
  border: 1px solid var(--minimal-line);
  background: rgba(8, 12, 18, .98);
  color: var(--minimal-text);
  transform: translateX(-50%);
}

.transcript-list button {
  border-color: rgba(255, 255, 255, .12);
  background: rgba(20, 26, 34, .86);
  color: var(--minimal-muted);
}

.transcript-label { color: var(--student-accent); }

@media (max-width: 900px) {
  .focus-panel {
    grid-template-columns: 1fr;
  }

  .focus-actions {
    grid-column: 1;
    justify-content: flex-start;
  }

  .focus-list { grid-column: 1; }
}

@media (max-width: 760px) {
  .lesson-header { min-height: 56px; }

  .stage-column {
    min-height: 0;
  }

  .stage {
    min-height: 0;
    max-height: none;
    aspect-ratio: 16 / 9;
  }

  .transport {
    position: relative;
    padding: 10px;
    background: #080b10;
    opacity: 1;
  }

  .focus-panel {
    padding: 14px 10px 18px;
  }

  .focus-actions {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    width: 100%;
  }

  .focus-actions button { min-width: 0; }

  .focus-list {
    flex-wrap: nowrap;
    padding-bottom: 4px;
    overflow-x: auto;
    scroll-snap-type: x proximity;
  }

  .focus-list li {
    flex: 0 0 min(72vw, 250px);
    max-width: none;
    scroll-snap-align: start;
  }
}

@media (max-width: 520px) {
  .lesson-header { padding-inline: 10px; }
  .primary-controls { align-items: center; }
  #chapterToggle { order: 8; }
  #studentMoreControls { order: 9; }
  .seek-label { order: 10; }

  .focus-heading {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .focus-actions button {
    padding-inline: 5px;
    font-size: 12px;
  }
}

:fullscreen .lesson-grid,
.lesson-shell:fullscreen .lesson-grid {
  display: block;
  height: 100%;
}

:fullscreen .focus-panel,
.lesson-shell:fullscreen .focus-panel {
  display: none;
}

:fullscreen .transport,
.lesson-shell:fullscreen .transport {
  position: absolute;
  opacity: .96;
}
/* Student v2 refinement: viewport-fit shell with a below-stage control dock. */
html,
body {
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.lesson-shell {
  height: 100vh;
  height: 100svh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

.lesson-grid,
.chapters-collapsed .lesson-grid {
  min-height: 0;
  height: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 0;
  overflow: hidden;
}

.stage-column {
  grid-row: 1;
  min-height: 0;
  height: 100%;
  align-items: center;
}

.stage {
  flex: 0 0 auto;
  width: var(--student-stage-width, min(100%, calc((100svh - 116px) * 16 / 9)));
  height: var(--student-stage-height, auto);
  min-width: 0;
  min-height: 0;
  max-width: 100%;
  max-height: 100%;
  margin: auto;
  aspect-ratio: 16 / 9;
}

.stage .source-fallback,
.stage #lessonCanvas {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.control-dock {
  position: relative;
  inset: auto;
  z-index: 18;
  flex: 0 0 auto;
  width: 100%;
  min-height: 0;
  max-height: 320px;
  padding: 8px 12px 9px;
  overflow: hidden;
  border-top: 1px solid rgba(255, 255, 255, .1);
  background: #080b10;
  opacity: 1;
  transform: none;
  transition: max-height .2s ease, min-height .2s ease, padding .2s ease,
    border-color .2s ease, opacity .16s ease;
}

.control-dock .primary-controls,
.control-dock .secondary-controls {
  gap: 7px;
}

.control-dock .primary-controls button,
.control-dock .secondary-controls button,
.control-dock select {
  min-height: 34px;
  padding: 5px 9px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 720;
  line-height: 1.15;
}

.control-dock #playPause { min-width: 68px; }
.control-dock #restart { min-width: 88px; }
.control-dock #fullscreen { min-width: 76px; }
.control-dock #chapterToggle { min-width: 68px; }
.control-dock #studentMoreControls { min-width: 66px; }
.control-dock .seek-label { min-width: 84px; }
.control-dock #seek { height: 16px; }
.control-dock #timeOutput {
  min-width: 92px;
  font-size: 11px;
}

.control-dock .secondary-controls {
  border-radius: 9px;
}

.control-dock .secondary-controls label {
  gap: 5px;
  font-size: 11px;
}

.auto-hide-option {
  min-height: 34px;
  padding: 5px 9px;
  border: 1px solid var(--minimal-line);
  border-radius: 8px;
  background: rgba(20, 27, 36, .94);
  color: var(--minimal-text) !important;
  cursor: pointer;
  user-select: none;
}

.auto-hide-option input {
  width: 15px;
  height: 15px;
  margin: 0;
  accent-color: var(--student-accent);
}

.controls-autohide.controls-idle .control-dock {
  min-height: 7px;
  max-height: 7px;
  padding-top: 0;
  padding-bottom: 0;
  border-top-color: rgba(167, 243, 208, .38);
  opacity: .62;
}

.controls-autohide.controls-idle.controls-keyboard-focus .control-dock {
  min-height: 0;
  max-height: 320px;
  padding-top: 8px;
  padding-bottom: 9px;
  opacity: 1;
}

.focus-panel {
  grid-row: 2;
  width: 100%;
  height: auto;
  max-height: min(34svh, 280px);
  overflow: hidden;
}

.focus-list {
  max-height: min(18svh, 150px);
  overflow: auto;
}

@media (max-width: 760px) {
  .control-dock { padding: 8px; }
}

@media (pointer: coarse) {
  .control-dock .primary-controls button,
  .control-dock .secondary-controls button,
  .control-dock select,
  .auto-hide-option {
    min-height: 40px;
  }
}

html.student-fullscreen-lock,
body.student-fullscreen-lock {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  overscroll-behavior: none;
}

:fullscreen .lesson-shell,
.lesson-shell:fullscreen,
.lesson-shell.fullscreen-fallback {
  width: 100vw;
  width: var(--student-visual-vw, 100vw);
  height: 100vh;
  height: 100dvh;
  height: var(--student-visual-vh, 100dvh);
  max-width: none;
  max-height: none;
  margin: 0;
  padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px)
    env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  overflow: hidden;
  border-radius: 0;
  background: var(--minimal-bg);
  box-shadow: none;
}

.lesson-shell.fullscreen-fallback {
  position: fixed;
  inset: 0;
  z-index: 2147483647;
}

:fullscreen .lesson-header,
.lesson-shell:fullscreen .lesson-header,
.lesson-shell.fullscreen-fallback .lesson-header {
  display: none;
}

:fullscreen .lesson-grid,
.lesson-shell:fullscreen .lesson-grid,
.lesson-shell.fullscreen-fallback .lesson-grid,
:fullscreen .chapters-collapsed .lesson-grid,
.lesson-shell:fullscreen.chapters-collapsed .lesson-grid,
.lesson-shell.fullscreen-fallback.chapters-collapsed .lesson-grid {
  min-width: 0;
  min-height: 0;
  width: 100%;
  height: 100%;
  height: var(--student-visual-vh, 100dvh);
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  gap: 0;
  overflow: hidden;
}

:fullscreen .focus-panel,
.lesson-shell:fullscreen .focus-panel,
.lesson-shell.fullscreen-fallback .focus-panel {
  display: none;
}

:fullscreen .stage-column,
.lesson-shell:fullscreen .stage-column,
.lesson-shell.fullscreen-fallback .stage-column {
  min-width: 0;
  min-height: 0;
  width: 100%;
  height: 100%;
  height: var(--student-visual-vh, 100dvh);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 0;
  background: #000;
}

:fullscreen .stage,
.lesson-shell:fullscreen .stage,
.lesson-shell.fullscreen-fallback .stage {
  flex: 1 1 auto;
  align-self: stretch;
  width: 100% !important;
  height: auto !important;
  min-width: 0;
  min-height: 0;
  max-width: 100%;
  max-height: 100%;
  margin: 0;
  aspect-ratio: auto;
  border-radius: 0;
}

:fullscreen .stage .source-fallback,
:fullscreen .stage #lessonCanvas,
.lesson-shell:fullscreen .stage .source-fallback,
.lesson-shell:fullscreen .stage #lessonCanvas,
.lesson-shell.fullscreen-fallback .stage .source-fallback,
.lesson-shell.fullscreen-fallback .stage #lessonCanvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100% !important;
  height: 100% !important;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

:fullscreen .control-dock,
.lesson-shell:fullscreen .control-dock,
.lesson-shell.fullscreen-fallback .control-dock {
  position: relative;
  inset: auto;
  flex: 0 0 auto;
  width: 100%;
  max-height: min(34vh, 220px);
  padding: 8px max(12px, env(safe-area-inset-right, 0px))
    max(8px, env(safe-area-inset-bottom, 0px))
    max(12px, env(safe-area-inset-left, 0px));
  overflow: hidden;
  opacity: 1;
  transform: none;
  border-radius: 0;
}

:fullscreen .secondary-open .control-dock,
.lesson-shell:fullscreen.secondary-open .control-dock,
.lesson-shell.fullscreen-fallback.secondary-open .control-dock {
  max-height: min(48vh, 320px);
}
