:root {
  --bg: #0b1020;
  --bg-soft: #10182d;
  --panel: rgba(14, 21, 39, 0.92);
  --panel-2: rgba(18, 28, 52, 0.84);
  --border: rgba(120, 170, 255, 0.22);
  --text: #eef4ff;
  --muted: #9db1d3;
  --gold: #f2c14e;
  --cyan: #79f0ff;
  --blue: #66b3ff;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.42);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(86, 144, 255, 0.16), transparent 24%),
    radial-gradient(circle at bottom right, rgba(121, 240, 255, 0.10), transparent 22%),
    linear-gradient(180deg, #08101f 0%, #0b1020 38%, #0f1730 100%);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
  overflow-x: hidden;
}

img,
audio {
  max-width: 100%;
  display: block;
}

code {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 14px 18px;
  background: rgba(8, 14, 28, 0.78);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(121, 240, 255, 0.10);
}

.brand {
  color: var(--gold);
  font-weight: 800;
  letter-spacing: 0.02em;
}

.lesson-title {
  color: var(--muted);
  font-size: 0.95rem;
  text-align: right;
}

.lesson-stage {
  width: 100%;
  max-width: 1240px;
  margin: 0 auto;
  padding: 18px;
  flex: 1;
}

.lesson-pane {
  display: none;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 24px;
  align-items: stretch;
}

.lesson-pane.active {
  display: grid;
}

.media-wrap,
.content-wrap {
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.96), rgba(11, 17, 32, 0.96));
  border: 1px solid var(--border);
  border-radius: 28px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.media-wrap {
  min-height: 520px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
}

.lesson-image {
  width: 100%;
  height: 100%;
  max-height: 78vh;
  object-fit: cover;
  border-radius: 20px;
  background: #09101d;
}

.content-wrap {
  padding: 28px 24px 24px;
  display: flex;
  flex-direction: column;
}

.eyebrow {
  display: inline-flex;
  align-self: flex-start;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(102, 179, 255, 0.10);
  border: 1px solid rgba(102, 179, 255, 0.20);
  color: var(--cyan);
  font-size: 0.86rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 14px;
}

h1,
h2 {
  margin: 0;
  line-height: 1.08;
}

h1 {
  font-size: clamp(2rem, 4vw, 3.35rem);
  color: var(--gold);
}

h2 {
  margin-top: 8px;
  font-size: clamp(1.15rem, 2.5vw, 1.65rem);
  color: var(--text);
  font-weight: 600;
}

.narration-text {
  margin-top: 18px;
  color: var(--text);
  line-height: 1.75;
  font-size: 1.02rem;
}

.narration-text p {
  margin: 0 0 12px;
}

.code-panel {
  margin-top: 18px;
}

.code-panel.no-margin {
  margin-top: 0;
}

.code-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.code-panel-title {
  color: var(--gold);
  font-weight: 700;
  font-size: 1rem;
}

.code-block {
  background: rgba(4, 8, 18, 0.92);
  border: 1px solid rgba(102, 179, 255, 0.14);
  border-radius: 18px;
  overflow: hidden;
}

.code-block pre {
  margin: 0;
  padding: 18px;
  overflow-x: auto;
  color: #dff3ff;
  font-size: 0.97rem;
  line-height: 1.65;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  white-space: pre;
}

.copy-btn {
  appearance: none;
  border: 1px solid rgba(121, 240, 255, 0.22);
  background: rgba(102, 179, 255, 0.10);
  color: var(--cyan);
  border-radius: 999px;
  padding: 9px 13px;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.16s ease, opacity 0.16s ease, background 0.16s ease, color 0.16s ease;
  white-space: nowrap;
}

.copy-btn:hover {
  transform: translateY(-1px);
}

.copy-btn.copied {
  background: rgba(242, 193, 78, 0.14);
  border-color: rgba(242, 193, 78, 0.24);
  color: #ffe39b;
}

.audio-card {
  margin-top: 18px;
  padding: 16px;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(21, 31, 58, 0.92), rgba(12, 18, 36, 0.92));
  border: 1px solid rgba(121, 240, 255, 0.12);
}

.full-narration-card {
  border-color: rgba(242, 193, 78, 0.18);
}

.audio-label {
  font-size: 0.94rem;
  font-weight: 700;
  color: var(--cyan);
  margin-bottom: 10px;
}

.audio-help {
  margin-top: 8px;
  font-size: 0.9rem;
  color: var(--muted);
}

audio {
  width: 100%;
  border-radius: 12px;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: auto;
  padding-top: 20px;
}

.primary-btn,
.secondary-btn {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 14px 18px;
  font-size: 0.98rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.16s ease, opacity 0.16s ease, box-shadow 0.16s ease;
}

.primary-btn:hover,
.secondary-btn:hover {
  transform: translateY(-1px);
}

.primary-btn {
  background: linear-gradient(135deg, rgba(242, 193, 78, 0.96), rgba(255, 217, 111, 0.96));
  color: #1d1604;
  box-shadow: 0 12px 28px rgba(242, 193, 78, 0.22);
}

.secondary-btn {
  background: rgba(102, 179, 255, 0.12);
  color: var(--text);
  border: 1px solid rgba(102, 179, 255, 0.20);
}

.link-card {
  margin-top: 18px;
  padding: 16px;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(21, 31, 58, 0.92), rgba(12, 18, 36, 0.92));
  border: 1px solid rgba(242, 193, 78, 0.18);
}

.link-card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--gold);
  margin-bottom: 8px;
}

.external-link {
  display: inline-flex;
  align-items: center;
  margin-top: 8px;
  color: var(--cyan);
  text-decoration: none;
  font-weight: 700;
  border-bottom: 1px solid rgba(121, 240, 255, 0.35);
  padding-bottom: 2px;
}

.external-link:hover {
  opacity: 0.9;
}

.expand-panel {
  margin-top: 18px;
  border: 1px solid rgba(102, 179, 255, 0.18);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(17, 26, 47, 0.92), rgba(10, 17, 34, 0.92));
  overflow: hidden;
}

.expand-panel summary {
  cursor: pointer;
  list-style: none;
  padding: 16px 18px;
  color: var(--cyan);
  font-weight: 700;
  user-select: none;
}

.expand-panel summary::-webkit-details-marker {
  display: none;
}

.expand-panel summary::after {
  content: " +";
  color: var(--gold);
  font-weight: 800;
}

.expand-panel[open] summary::after {
  content: " −";
}

.expand-body {
  padding: 0 14px 14px;
}

.footer-note {
  padding: 12px 18px 22px;
  color: var(--muted);
  text-align: center;
  font-size: 0.94rem;
}

@media (max-width: 1024px) {
  .lesson-pane,
  .lesson-pane.active {
    grid-template-columns: 1fr;
  }

  .media-wrap {
    min-height: auto;
  }

  .lesson-image {
    max-height: none;
  }
}

@media (max-width: 640px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .lesson-title {
    text-align: left;
  }

  .lesson-stage {
    padding: 12px;
  }

  .content-wrap {
    padding: 20px 16px 18px;
  }

  .media-wrap {
    padding: 10px;
    border-radius: 22px;
  }

  .content-wrap {
    border-radius: 22px;
  }

  h1 {
    font-size: 2rem;
  }

  .narration-text {
    font-size: 0.98rem;
  }

  .button-row {
    flex-direction: column;
  }

  .primary-btn,
  .secondary-btn {
    width: 100%;
  }

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

  .copy-btn {
    width: 100%;
    text-align: center;
  }
}