:root {
  --bg: #09090b;
  --bg-2: #0c0d10;
  --surface: rgba(255, 255, 255, 0.03);
  --surface-2: rgba(255, 255, 255, 0.05);
  --surface-3: rgba(255, 255, 255, 0.08);
  --panel: rgba(12, 13, 16, 0.95);
  --panel-2: rgba(15, 16, 20, 0.96);
  --line: rgba(255, 255, 255, 0.06);
  --line-2: rgba(255, 255, 255, 0.10);
  --text: #fafafa;
  --text-2: #a1a1aa;
  --gold: #d4a843;
  --gold-soft: rgba(212, 168, 67, 0.12);
  --gold-glow: rgba(212, 168, 67, 0.25);
  --green: #22c55e;
  --red: #ef4444;
  --radius-xl: 20px;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --transition: 180ms ease;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", "Manrope", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

::selection {
  background: var(--gold-soft);
  color: var(--gold);
}

button, input {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

/* ── Scrollbar ── */
::-webkit-scrollbar {
  width: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.14);
}

/* ── App Shell ── */
.app-shell {
  position: relative;
  min-height: 100vh;
  overflow: hidden;
}

.ambient {
  position: absolute;
  border-radius: 50%;
  filter: blur(120px);
  pointer-events: none;
  opacity: 0.12;
}

.ambient-a {
  width: 300px;
  height: 300px;
  top: -100px;
  right: -40px;
  background: var(--gold);
}

.ambient-b {
  width: 200px;
  height: 200px;
  left: -60px;
  bottom: 20%;
  background: var(--gold);
  opacity: 0.06;
}

.app {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  padding: 16px;
}

/* ── Loading ── */
.loading-screen {
  min-height: calc(100vh - 32px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: var(--text-2);
  font-size: 0.85rem;
  letter-spacing: 0.02em;
}

.loading-ring {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid var(--line);
  border-top-color: var(--gold);
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Shared Panel ── */
.auth-brand,
.auth-panel,
.sidebar,
.player-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  backdrop-filter: blur(12px);
}

/* ── Auth Layout ── */
.auth-layout,
.dashboard {
  min-height: calc(100vh - 32px);
  display: grid;
  gap: 16px;
}

.auth-layout {
  grid-template-columns: minmax(0, 1.2fr) minmax(340px, 420px);
  align-items: stretch;
}

.auth-brand {
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.brand-top {
  display: flex;
  gap: 20px;
  align-items: center;
}

.brand-logo {
  width: 80px;
  height: 80px;
  object-fit: cover;
  object-position: center;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  flex-shrink: 0;
}

.brand-logo-small {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
}

.brand-copy h1,
.sidebar-head h2,
.player-header h1 {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.brand-copy h1 {
  font-size: clamp(2rem, 3.5vw, 3.2rem);
  line-height: 0.95;
}

.player-header h1 {
  font-size: clamp(1.25rem, 1.8vw, 1.75rem);
}

.eyebrow {
  margin: 0 0 6px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--gold);
}

.lead {
  margin: 8px 0 0;
  max-width: 480px;
  line-height: 1.65;
  font-size: 0.9rem;
  color: var(--text-2);
}

/* ── Market Terminal ── */
.market-panel {
  padding: 16px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--line);
}

.market-terminal {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--bg);
  overflow: hidden;
}

.terminal-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
}

.terminal-head p {
  margin: 0 0 0 6px;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-2);
  font-weight: 500;
}

.terminal-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.terminal-dot.red { background: var(--red); }
.terminal-dot.gold { background: var(--gold); }
.terminal-dot.green { background: var(--green); }

.terminal-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1px;
  background: var(--line);
}

.terminal-card {
  padding: 14px 16px;
  background: var(--bg);
}

.terminal-card.emphasis {
  background: linear-gradient(135deg, rgba(212, 168, 67, 0.06), var(--bg));
}

.terminal-card small {
  display: block;
  margin-bottom: 6px;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.62rem;
  font-weight: 500;
}

.terminal-card strong {
  display: block;
  margin-bottom: 2px;
  color: var(--text);
  font-size: 0.95rem;
  font-family: "Space Grotesk", sans-serif;
  letter-spacing: -0.02em;
}

.terminal-card span {
  color: var(--text-2);
  font-size: 0.72rem;
}

/* ── Auth Panel ── */
.auth-panel {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.tabs {
  display: inline-flex;
  gap: 4px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
}

.tab {
  padding: 8px 16px;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-2);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 999px;
  transition: all var(--transition);
}

.tab:hover {
  color: var(--text);
}

.tab.is-active {
  color: var(--text);
  background: var(--surface-2);
  border-color: var(--line);
}

.panel-card {
  padding: 24px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--line);
  flex: 1;
}

.panel-card h2 {
  margin: 0 0 6px;
  font-size: 1.6rem;
  font-family: "Space Grotesk", sans-serif;
  letter-spacing: -0.03em;
}

.panel-kicker {
  margin: 0 0 4px;
  color: var(--gold);
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.panel-copy {
  color: var(--text-2);
  font-size: 0.85rem;
  margin-bottom: 4px;
}

.message-banner {
  margin: 8px 0;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text-2);
  font-size: 0.84rem;
}

/* ── Auth Form ── */
.auth-form {
  display: grid;
  gap: 14px;
  margin-top: 8px;
}

.auth-form label {
  display: grid;
  gap: 6px;
}

.auth-form span {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-2);
}

.auth-form input {
  width: 100%;
  padding: 10px 14px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  outline: none;
  font-size: 0.88rem;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.auth-form input::placeholder {
  color: rgba(255, 255, 255, 0.2);
}

.auth-form input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-soft);
}

/* ── Buttons ── */
.primary-btn,
.ghost-btn {
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.84rem;
  font-weight: 600;
  transition: all var(--transition);
}

.primary-btn {
  margin-top: 4px;
  background: var(--gold);
  color: #09090b;
  border: none;
}

.primary-btn:hover {
  background: #c49b3a;
  transform: translateY(-1px);
  box-shadow: 0 4px 16px var(--gold-soft);
}

.primary-btn:active {
  transform: translateY(0);
}

.ghost-btn {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text-2);
}

.ghost-btn:hover {
  border-color: var(--line-2);
  color: var(--text);
  background: var(--surface-2);
}

/* ── Dashboard ── */
.dashboard {
  grid-template-columns: 300px minmax(0, 1fr);
  height: calc(100vh - 32px);
  overflow: hidden;
}

.sidebar {
  padding: 16px;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 12px;
  min-height: 0;
  overflow: hidden;
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-head h2 {
  font-size: 1rem;
}

/* ── User Card ── */
.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1px solid var(--line);
}

.user-card strong {
  font-size: 0.84rem;
}

.user-card p {
  margin: 0;
  color: var(--text-2);
  font-size: 0.75rem;
}

.user-badge {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  background: var(--gold-soft);
  color: var(--gold);
  font-weight: 700;
  font-size: 0.78rem;
  flex-shrink: 0;
}

/* ── Lesson List ── */
.lesson-list {
  display: grid;
  align-content: start;
  gap: 4px;
  min-height: 0;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 4px;
  padding-bottom: 16px;
}

.lesson-item {
  width: 100%;
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 10px;
  align-items: center;
  padding: 10px;
  text-align: left;
  color: inherit;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  transition: all var(--transition);
}

.lesson-item:hover {
  background: var(--surface);
  border-color: var(--line);
}

.lesson-item.is-selected {
  background: var(--gold-soft);
  border-color: rgba(212, 168, 67, 0.18);
}

.lesson-item.is-selected .lesson-order {
  background: var(--gold);
  color: #09090b;
}

.lesson-order {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 0.72rem;
  font-weight: 700;
  transition: all var(--transition);
}

.lesson-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.lesson-copy strong {
  font-size: 0.82rem;
  font-weight: 500;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lesson-copy small {
  color: var(--text-2);
  font-size: 0.7rem;
}

/* ── Lesson Group (Accordion) ── */
.lesson-group {
  border-radius: var(--radius-md);
}

.lesson-group-toggle {
  width: 100%;
  display: grid;
  grid-template-columns: 36px 1fr 20px;
  gap: 10px;
  align-items: center;
  padding: 10px;
  text-align: left;
  color: inherit;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition);
}

.lesson-group-toggle:hover {
  background: var(--surface);
  border-color: var(--line);
}

.lesson-group.is-open > .lesson-group-toggle {
  background: var(--surface);
  border-color: var(--line);
}

.lesson-group-arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--transition);
}

.lesson-group-arrow svg {
  width: 14px;
  height: 14px;
  color: var(--text-2);
}

.lesson-group.is-open .lesson-group-arrow {
  transform: rotate(180deg);
}

.lesson-group-parts {
  display: grid;
  gap: 2px;
  max-height: 0;
  overflow: hidden;
  padding-left: 18px;
  transition: max-height 250ms ease, padding 250ms ease;
}

.lesson-group.is-open .lesson-group-parts {
  max-height: 500px;
  padding-top: 4px;
  padding-bottom: 4px;
}

.lesson-sub {
  grid-template-columns: 28px 1fr;
  padding: 8px 10px;
}

.lesson-order-sub {
  width: 22px;
  height: 22px;
  font-size: 0.65rem;
  border-radius: 6px;
}

/* ── Player Panel ── */
.player-panel {
  padding: 20px;
  display: grid;
  gap: 16px;
  align-content: start;
  overflow: auto;
}

.player-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.duration-pill {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text-2);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── Video Stage ── */
.video-stage {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-lg);
  background: #000;
  border: 1px solid var(--line);
  width: min(100%, 1180px);
  margin: 0 auto;
}

.video-stage:fullscreen,
.video-stage:-webkit-full-screen {
  display: flex;
  flex-direction: column;
  background: #000;
  border: none;
  border-radius: 0;
  width: 100vw;
  height: 100vh;
}

.video-stage:fullscreen .course-video,
.video-stage:-webkit-full-screen .course-video {
  max-height: none;
  aspect-ratio: auto;
  flex: 1;
  min-height: 0;
  object-fit: contain;
}

.video-stage:fullscreen .player-controls,
.video-stage:-webkit-full-screen .player-controls {
  flex-shrink: 0;
  position: relative;
  z-index: 3;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(12px);
  padding: 12px 20px;
}

.video-stage:fullscreen .play-overlay,
.video-stage:-webkit-full-screen .play-overlay {
  z-index: 4;
}

.course-video {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: min(62vh, 720px);
  background: #000;
  object-fit: contain;
}

/* ── Big Play Overlay ── */
.play-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.4);
  cursor: pointer;
  z-index: 2;
  transition: opacity var(--transition);
}

.play-overlay.is-hidden {
  opacity: 0;
  pointer-events: none;
}

.play-overlay-btn {
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  border: none;
  color: #fff;
  cursor: pointer;
  transition: transform var(--transition), background var(--transition);
}

.play-overlay-btn:hover {
  transform: scale(1.1);
  background: rgba(0, 0, 0, 0.7);
}

.play-overlay-btn svg {
  width: 28px;
  height: 28px;
}

/* ── Player Controls ── */
.player-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  transition: opacity 0.35s ease, visibility 0.35s ease;
}

.video-stage.controls-hidden .player-controls {
  opacity: 0;
  visibility: hidden;
}

.video-stage.controls-hidden {
  cursor: none;
}

.player-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--surface-2);
  color: var(--text);
  transition: all var(--transition);
  flex-shrink: 0;
}

.player-btn:hover {
  background: var(--surface-3);
}

.player-btn svg {
  width: 16px;
  height: 16px;
}

.time-label {
  color: var(--text-2);
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  flex-shrink: 0;
}

.seek-wrap {
  flex: 1;
  min-width: 80px;
}

.volume-wrap {
  display: flex;
  align-items: center;
  width: 80px;
  flex-shrink: 0;
}

/* ── Range Inputs ── */
.seek-bar,
.volume-bar {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.1);
  outline: none;
  cursor: pointer;
}

.seek-bar::-webkit-slider-thumb,
.volume-bar::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--gold);
  border: none;
  cursor: pointer;
  transition: transform var(--transition);
}

.seek-bar::-webkit-slider-thumb:hover,
.volume-bar::-webkit-slider-thumb:hover {
  transform: scale(1.3);
}

.seek-bar::-moz-range-thumb,
.volume-bar::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--gold);
  border: none;
  cursor: pointer;
}

/* ── Lesson Summary ── */
.lesson-summary {
  padding: 16px 20px;
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text-2);
  font-size: 0.88rem;
  line-height: 1.6;
}

.lesson-summary strong {
  display: block;
  margin-bottom: 6px;
  color: var(--text);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* ── Course Progress ── */
.course-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1px solid var(--line);
}

.course-progress span {
  font-size: 0.78rem;
  color: var(--text-2);
  font-weight: 500;
}

.course-progress small {
  font-size: 0.72rem;
  color: var(--text-2);
}

/* ── Responsive ── */
@media (max-width: 1120px) {
  .auth-layout,
  .dashboard {
    grid-template-columns: 1fr;
    height: auto;
    overflow: visible;
  }

  .auth-brand {
    display: none;
  }

  .lesson-list {
    max-height: 300px;
  }

  .sidebar {
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  }

  .player-panel {
    border-radius: 0 0 var(--radius-xl) var(--radius-xl);
  }
}

@media (max-width: 720px) {
  .app {
    padding: 8px;
  }

  .auth-panel {
    padding: 16px;
  }

  .sidebar,
  .player-panel {
    padding: 12px;
  }

  .brand-top {
    flex-direction: column;
    align-items: flex-start;
  }

  .terminal-grid {
    grid-template-columns: 1fr;
    gap: 1px;
  }

  .player-controls {
    flex-wrap: wrap;
    gap: 6px;
  }

  .seek-wrap {
    order: -1;
    width: 100%;
    flex: none;
  }

  .volume-wrap {
    width: 60px;
  }

  .player-header {
    flex-direction: column;
    align-items: flex-start;
  }
}
