:root {
  color-scheme: light;
  --page: #ece9f6;
  --page-soft: #f7f4fb;
  --panel: #fffafd;
  --panel-solid: #fffafd;
  --panel-tint: #f2ecff;
  --body-bg: linear-gradient(135deg, #e9e5f7 0%, #f7e5ef 52%, #edf8f2 100%);
  --app-bg: #f8f3fb;
  --soft-control: rgba(255, 255, 255, 0.72);
  --input-bg: rgba(255, 255, 255, 0.9);
  --module-bg: rgba(255, 255, 255, 0.68);
  --lesson-bg: rgba(255, 255, 255, 0.68);
  --ink: #151217;
  --text: #211d25;
  --muted: #77707e;
  --line: rgba(38, 30, 48, 0.12);
  --shadow: 0 10px 30px rgba(50, 39, 73, 0.1);
  --shadow-soft: 0 4px 14px rgba(50, 39, 73, 0.07);
  --accent: #161318;
  --accent-2: #7c5cff;
  --accent-3: #37c6a0;
  --danger: #e45858;
  --radius: 28px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #050805;
  --page-soft: #07130d;
  --panel: #07100b;
  --panel-solid: #0d1711;
  --panel-tint: #0f2218;
  --body-bg: #020403;
  --app-bg: #050805;
  --soft-control: rgba(15, 32, 22, 0.88);
  --input-bg: #0d1711;
  --module-bg: #0d1711;
  --lesson-bg: #0c1510;
  --ink: #f4fff8;
  --text: #e8f5ec;
  --muted: #91a696;
  --line: rgba(89, 236, 145, 0.18);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
  --shadow-soft: 0 4px 14px rgba(0, 0, 0, 0.22);
  --accent: #e9fff0;
  --accent-2: #5df094;
  --accent-3: #2ee88c;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  padding: 12px 0;
  background: var(--body-bg);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

button,
select {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--soft-control);
  color: var(--text);
}

button {
  cursor: pointer;
}

button:hover,
button:focus-visible,
select:hover,
select:focus-visible,
input:focus-visible {
  border-color: rgba(124, 92, 255, 0.6);
  outline: none;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.38;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 390px);
  gap: 18px;
  width: min(1480px, calc(100vw - 24px));
  min-height: calc(100vh - 70px);
  margin: 0 auto;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 34px;
  background: var(--app-bg);
  box-shadow: var(--shadow);
}

.player-pane,
.library-pane {
  min-width: 0;
  border: 1px solid rgba(255, 255, 255, 0.68);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow-soft);
}

.player-pane {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px;
}

.library-pane {
  position: sticky;
  top: 12px;
  display: flex;
  flex-direction: column;
  align-self: start;
  max-height: calc(100vh - 70px);
  overflow: hidden;
  padding: 16px;
}

.topbar,
.library-header,
.current-meta,
.lesson-row,
.module-button {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar,
.library-header,
.current-meta {
  justify-content: space-between;
}

.topbar {
  align-items: flex-start;
}

.top-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent-2);
  font-size: 0.76rem;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1 {
  max-width: 860px;
  margin: 0;
  color: var(--ink);
  font-size: clamp(1.75rem, 3.35vw, 3.25rem);
  font-weight: 840;
  line-height: 1;
}

h2 {
  margin: 0;
  color: var(--ink);
  font-size: 1.28rem;
  font-weight: 830;
}

.ghost-button {
  flex: 0 0 auto;
  min-width: 112px;
  padding: 0 18px;
  background: var(--ink);
  color: #fff;
  font-weight: 760;
}

.theme-button {
  min-width: 86px;
  background: var(--panel-solid);
  color: var(--text);
}

.video-shell {
  position: relative;
  align-self: center;
  width: min(100%, calc((100vh - 285px) * 16 / 9));
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 26px;
  background: #050507;
  box-shadow: 0 8px 20px rgba(18, 12, 28, 0.15);
  contain: layout paint;
  touch-action: manipulation;
}

.video-shell.fullscreen {
  width: 100vw;
  height: 100vh;
  aspect-ratio: auto;
  border: 0;
  border-radius: 0;
}

.video-shell.full-window {
  position: fixed;
  inset: 0;
  z-index: 50;
  width: 100vw;
  height: 100vh;
  margin: 0;
  aspect-ratio: auto;
  border: 0;
  border-radius: 0;
}

.video-shell video {
  display: block;
  width: 100%;
  height: 100%;
  background: #000;
  object-fit: contain;
}

.player-top-actions {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 8;
  display: flex;
  gap: 8px;
}

.settings-panel {
  position: absolute;
  top: 64px;
  right: 14px;
  z-index: 9;
  width: min(250px, calc(100% - 28px));
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 18px;
  background: #17141b;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18);
}

.settings-panel[hidden] {
  display: none;
}

.settings-panel label {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.82rem;
}

.settings-panel label:last-child {
  margin-bottom: 0;
}

.settings-panel select {
  width: 100%;
  min-height: 38px;
  padding: 0 10px;
  border-color: rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.transport-controls {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 7;
  display: flex;
  align-items: center;
  gap: clamp(20px, 5vw, 62px);
  transform: translate(-50%, -50%);
  transition: opacity 160ms ease, transform 160ms ease;
}

.round-control,
.center-play {
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(20, 18, 24, 0.56);
  color: #fff;
  font-weight: 850;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.16);
}

.round-control {
  width: 58px;
  height: 58px;
  min-height: 58px;
  font-size: 1.42rem;
}

.settings-button {
  width: 46px;
  height: 46px;
  min-height: 46px;
  font-size: 1.22rem;
}

.center-play {
  width: 82px;
  height: 82px;
  min-height: 82px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  font-size: 2.08rem;
  transition: opacity 160ms ease, transform 160ms ease;
}

.video-shell.controls-hidden .transport-controls,
.video-shell.controls-hidden .player-top-actions,
.video-shell.controls-hidden .settings-panel {
  opacity: 0;
  pointer-events: none;
}

.video-shell.controls-hidden .transport-controls {
  transform: translate(-50%, -50%) scale(0.92);
}

.tap-layer {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: 1fr 0.7fr 1fr;
  pointer-events: none;
}

.tap-feedback {
  position: absolute;
  top: 50%;
  z-index: 8;
  min-width: 86px;
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.66);
  color: #fff;
  font-size: 1rem;
  font-weight: 850;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-50%) scale(0.88);
  transition: opacity 150ms ease, transform 150ms ease;
}

.tap-feedback-left {
  left: 12%;
}

.tap-feedback-right {
  right: 12%;
}

.tap-feedback.show {
  opacity: 1;
  transform: translateY(-50%) scale(1);
}

.custom-controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 6;
  padding: 34px 18px 16px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.82), rgba(0, 0, 0, 0.35), transparent);
  opacity: 1;
  transition: opacity 180ms ease;
}

.video-shell.controls-hidden .custom-controls {
  opacity: 0;
  pointer-events: none;
}

.seek-bar,
.volume-slider {
  width: 100%;
  accent-color: #fff;
}

.seek-wrap {
  position: relative;
}

.seek-bar {
  display: block;
  height: 18px;
  margin-bottom: 4px;
}

.seek-preview {
  position: absolute;
  left: var(--seek-preview-left, 50%);
  bottom: 28px;
  z-index: 12;
  width: min(184px, 34vw);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 14px;
  background: #050507;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.38);
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(8px) scale(0.98);
  transition: opacity 120ms ease, transform 120ms ease;
}

.seek-preview.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0) scale(1);
}

.seek-preview[hidden] {
  display: none;
}

.seek-preview video {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  object-fit: cover;
}

.seek-preview span {
  position: absolute;
  left: 50%;
  bottom: 6px;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  font-size: 0.76rem;
  font-weight: 820;
  transform: translateX(-50%);
}

.controls-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.icon-button {
  flex: 0 0 40px;
  width: 40px;
  min-height: 40px;
  padding: 0;
  border-color: transparent;
  background: transparent;
  color: #fff;
  font-weight: 850;
}

.icon-button:hover,
.icon-button:focus-visible {
  border-color: rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.12);
}

.time-readout {
  flex: 1 1 auto;
  min-width: 110px;
  color: #fff;
  font-size: 0.88rem;
  font-weight: 760;
  white-space: nowrap;
}

.control-select {
  flex: 0 0 auto;
  width: 76px;
  min-height: 34px;
  padding: 0 9px;
  border-color: rgba(255, 255, 255, 0.18);
  background: rgba(0, 0, 0, 0.48);
  color: #fff;
  font-size: 0.84rem;
  font-weight: 800;
}

.volume-slider {
  flex: 0 1 98px;
  max-width: 118px;
}

.current-meta {
  padding: 0 4px;
  color: var(--muted);
  font-size: 0.94rem;
}

#current-progress {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 54px;
  min-height: 34px;
  border-radius: 999px;
  border: 1px solid var(--progress-border, var(--line));
  background: var(--progress-bg, var(--panel-solid));
  color: var(--progress-accent, var(--ink));
  font-weight: 820;
}

.library-header {
  display: block;
  padding: 2px 2px 14px;
}

.library-header .eyebrow {
  color: var(--accent-3);
}

input[type="search"] {
  width: 100%;
  min-height: 48px;
  margin-top: 14px;
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--input-bg);
  color: var(--text);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.library-grid {
  flex: 1 1 auto;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 14px;
  height: auto;
  min-height: 0;
}

.modules-strip {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) 32px;
  align-items: stretch;
  gap: 7px;
  min-width: 0;
}

.module-nav {
  width: 32px;
  min-height: 98px;
  padding: 0;
  border-radius: 18px;
  background: var(--panel-solid);
  color: var(--text);
  font-size: 1.45rem;
  font-weight: 850;
}

.module-nav:disabled {
  opacity: 0.28;
}

.modules-list {
  display: flex;
  gap: 8px;
  min-width: 0;
  overflow-x: auto;
  padding: 2px 2px 4px;
  scroll-padding-inline: 2px;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
}

.modules-list::-webkit-scrollbar {
  display: none;
}

.module-button {
  flex: 0 0 176px;
  align-items: flex-start;
  justify-content: space-between;
  min-height: 98px;
  padding: 14px;
  border-radius: 22px;
  background: var(--module-bg);
  text-align: left;
  scroll-snap-align: start;
  contain: layout paint;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.66);
}

.module-button.active {
  border-color: rgba(45, 218, 126, 0.58);
  background: #17141b;
  color: #fff;
}

.module-button.next:not(.active) {
  border-color: rgba(45, 218, 126, 0.32);
}

.module-button.done:not(.active) {
  border-color: rgba(48, 202, 126, 0.35);
  background: rgba(222, 251, 239, 0.9);
}

.module-name {
  min-width: 0;
  font-size: 0.92rem;
  font-weight: 820;
  line-height: 1.18;
}

.module-count {
  flex: 0 0 auto;
  align-self: flex-end;
  color: inherit;
  font-size: 0.78rem;
  font-weight: 800;
  opacity: 0.68;
}

.lessons-list {
  min-height: 0;
  overflow: auto;
  padding: 2px 3px 12px 2px;
  scrollbar-width: thin;
}

.module-section {
  margin-bottom: 18px;
  content-visibility: auto;
  contain-intrinsic-size: 1px 360px;
}

.module-title {
  margin: 0 0 10px;
  color: var(--ink);
  font-size: 1.05rem;
  font-weight: 850;
}

.lesson-row {
  width: 100%;
  min-height: 64px;
  justify-content: space-between;
  margin-bottom: 8px;
  padding: 10px 12px;
  border-radius: 18px;
  position: relative;
  overflow: hidden;
  border-color: var(--progress-border, var(--line));
  background: var(--progress-bg, var(--lesson-bg));
  text-align: left;
  contain: layout paint;
}

.lesson-row::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: calc(var(--progress-pct, 0) * 1%);
  background: linear-gradient(90deg, var(--progress-accent, #d9a300), transparent);
  opacity: 0.16;
  pointer-events: none;
}

.lesson-row > * {
  position: relative;
  z-index: 1;
}

.lesson-row.active {
  border-color: var(--progress-accent, rgba(45, 218, 126, 0.7));
  background: var(--progress-bg, var(--lesson-bg));
  color: var(--text);
}

.lesson-row.done:not(.active) {
  background: rgba(222, 251, 239, 0.9);
}

.lesson-main {
  min-width: 0;
}

.lesson-title {
  display: block;
  font-size: 0.94rem;
  font-weight: 820;
  line-height: 1.2;
}

.lesson-meta {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 720;
}

.lesson-row.active .lesson-meta {
  color: var(--muted);
}

.lesson-progress {
  flex: 0 0 auto;
  min-width: 44px;
  color: var(--progress-accent, inherit);
  font-size: 0.78rem;
  font-weight: 850;
  text-align: right;
  opacity: 0.92;
}

.empty-state,
.materials {
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.62);
}

.empty-state {
  padding: 18px;
  color: var(--muted);
}

.materials {
  margin-top: 10px;
  padding: 12px;
}

.materials h3 {
  margin: 0 0 8px;
  font-size: 0.92rem;
}

.materials a {
  display: block;
  margin-top: 6px;
  color: var(--accent-2);
  text-decoration: none;
}

.materials a:hover,
.materials a:focus-visible {
  text-decoration: underline;
}

:root[data-theme="dark"] .app-shell,
:root[data-theme="dark"] .player-pane,
:root[data-theme="dark"] .library-pane {
  border-color: rgba(89, 236, 145, 0.16);
}

:root[data-theme="dark"] .ghost-button:not(.theme-button) {
  background: #39e884;
  color: #031009;
}

:root[data-theme="dark"] .theme-button,
:root[data-theme="dark"] .module-nav {
  background: #0d1711;
  color: #dfffea;
}

:root[data-theme="dark"] .settings-panel,
:root[data-theme="dark"] .module-button.active {
  background: #06100b;
}

:root[data-theme="dark"] input[type="search"] {
  box-shadow: none;
}

:root[data-theme="dark"] .module-button.done:not(.active) {
  background: #10261a;
}

:root[data-theme="dark"] .lesson-row {
  border-color: var(--progress-border-dark, var(--line));
  background: var(--progress-bg-dark, var(--lesson-bg));
}

:root[data-theme="dark"] .lesson-row.active {
  border-color: var(--progress-accent-dark, var(--accent-3));
  background: var(--progress-bg-dark, var(--lesson-bg));
}

:root[data-theme="dark"] .lesson-progress,
:root[data-theme="dark"] #current-progress {
  color: var(--progress-accent-dark, var(--accent-3));
}

:root[data-theme="dark"] #current-progress {
  border-color: var(--progress-border-dark, var(--line));
  background: var(--progress-bg-dark, var(--panel-solid));
}

:root[data-theme="dark"] .empty-state,
:root[data-theme="dark"] .materials {
  background: #0b1510;
}

@media (max-width: 1080px) {
  .app-shell {
    grid-template-columns: 1fr;
    width: min(920px, calc(100vw - 24px));
    margin: 0 auto;
    padding: 12px;
    border-radius: 28px;
  }

  .player-pane {
    padding: 16px;
  }

  .library-pane {
    position: static;
    max-height: none;
    padding: 16px;
  }

  .library-grid {
    height: auto;
  }

  .lessons-list {
    max-height: none;
    overflow: visible;
  }
}

@media (max-width: 680px) {
  body {
    padding: 0;
    background: var(--body-bg);
  }

  .app-shell {
    width: 100%;
    min-height: 100vh;
    margin: 0;
    padding: 10px;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
  }

  .player-pane,
  .library-pane,
  .video-shell {
    box-shadow: none;
  }

  .player-pane,
  .library-pane {
    border-radius: 24px;
  }

  .topbar {
    align-items: flex-start;
  }

  .top-actions {
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
  }

  h1 {
    font-size: clamp(1.42rem, 8vw, 2.05rem);
    line-height: 1.03;
  }

  .eyebrow {
    font-size: 0.68rem;
  }

  .ghost-button {
    min-width: 88px;
    min-height: 40px;
    padding: 0 12px;
    font-size: 0.86rem;
  }

  .theme-button {
    min-width: 74px;
  }

  .video-shell {
    width: 100%;
    max-width: 100%;
    border-radius: 20px;
  }

  .custom-controls {
    padding: 28px 10px calc(10px + env(safe-area-inset-bottom));
  }

  .seek-preview {
    display: none;
  }

  .controls-row {
    justify-content: space-between;
    gap: 8px;
    width: 100%;
  }

  #play-toggle,
  #mute-toggle,
  .volume-slider {
    display: none;
  }

  .time-readout {
    flex: 0 1 auto;
    min-width: 0;
    padding: 7px 11px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.56);
    font-size: 0.82rem;
  }

  .control-select {
    width: 70px;
    min-height: 40px;
    padding: 0 7px;
    font-size: 0.78rem;
  }

  #fullscreen-toggle {
    flex: 0 0 44px;
    width: 44px;
    min-height: 44px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.56);
    font-size: 1.24rem;
  }

  .center-play {
    width: 70px;
    height: 70px;
    min-height: 70px;
  }

  .transport-controls {
    gap: clamp(24px, 10vw, 42px);
  }

  .transport-button {
    width: 52px;
    height: 52px;
    min-height: 52px;
    font-size: 1.18rem;
  }

  .player-top-actions {
    top: 10px;
    right: 10px;
  }

  .settings-button {
    width: 42px;
    height: 42px;
    min-height: 42px;
  }

  .settings-panel {
    top: 58px;
    right: 10px;
    width: min(230px, calc(100% - 20px));
  }

  .current-meta {
    font-size: 0.86rem;
  }

  .library-pane {
    padding: 14px;
  }

  h2 {
    font-size: 1.06rem;
  }

  input[type="search"] {
    min-height: 46px;
    margin-top: 12px;
  }

  .module-button {
    flex-basis: 160px;
    min-height: 90px;
    border-radius: 20px;
  }

  .modules-strip {
    grid-template-columns: 28px minmax(0, 1fr) 28px;
    gap: 5px;
  }

  .module-nav {
    width: 28px;
    min-height: 90px;
    border-radius: 16px;
    font-size: 1.25rem;
  }

  .lesson-row {
    align-items: flex-start;
    min-height: 62px;
  }
}

@media (hover: none) and (pointer: coarse) {
  #mute-toggle,
  .volume-slider {
    display: none;
  }
}
