:root {
  color-scheme: light;
  --ink: #15233b;
  --muted: #607089;
  --paper: #fbfdff;
  --panel: #ffffff;
  --line: #dce6f4;
  --navy: #0d1f3a;
  --blue: #2563eb;
  --teal: #12b8a6;
  --lime: #c8f02d;
  --yellow: #ffc83d;
  --pink: #ff5f8f;
  --shadow: 0 22px 62px rgba(17, 32, 58, 0.16);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    linear-gradient(120deg, rgba(18, 184, 166, 0.13), transparent 40%),
    linear-gradient(300deg, rgba(255, 200, 61, 0.16), transparent 40%),
    var(--paper);
  font-family: "Plus Jakarta Sans", "Segoe UI", Arial, sans-serif;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font: inherit;
  cursor: pointer;
}

.reader-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px clamp(16px, 4vw, 48px);
  color: white;
  background: rgba(13, 31, 58, 0.94);
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 210px;
}

.brand-mark {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  color: var(--navy);
  background: var(--lime);
  border-radius: 8px;
  font-weight: 900;
}

.brand strong,
.brand small {
  display: block;
  line-height: 1.15;
}

.brand small {
  margin-top: 3px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.76rem;
}

.lesson-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
}

.lesson-nav a,
.lesson-nav button {
  padding: 9px 12px;
  border: 0;
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.84);
  font-size: 0.9rem;
  font-weight: 800;
  white-space: nowrap;
  background: transparent;
}

.lesson-nav a:hover,
.lesson-nav button:hover {
  color: white;
  background: rgba(255, 255, 255, 0.12);
}

.lesson-hero {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(320px, 1.1fr);
  gap: clamp(22px, 4vw, 56px);
  align-items: center;
  padding: clamp(34px, 6vw, 76px) clamp(16px, 5vw, 72px);
  color: white;
  background:
    linear-gradient(135deg, rgba(7, 16, 31, 0.92) 0%, rgba(21, 64, 84, 0.92) 54%, rgba(33, 33, 79, 0.92) 100%),
    url("../assets/jakademi-lesson-characters.jpg") center / cover;
}

.hero-copy {
  max-width: 720px;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--teal);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.lesson-hero .eyebrow {
  color: #8df8ea;
}

.lesson-hero h1 {
  margin: 0;
  max-width: 760px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.8rem, 7vw, 6.5rem);
  line-height: 0.95;
  letter-spacing: 0;
}

.hero-copy p:not(.eyebrow) {
  max-width: 650px;
  margin: 22px 0 0;
  color: rgba(255, 255, 255, 0.84);
  font-size: clamp(1rem, 2vw, 1.2rem);
  line-height: 1.65;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 28px;
}

.primary-action,
.secondary-action {
  display: inline-flex;
  min-height: 46px;
  align-items: center;
  justify-content: center;
  padding: 12px 18px;
  border: 0;
  border-radius: 8px;
  font-weight: 900;
}

.primary-action {
  color: var(--navy);
  background: var(--lime);
}

.secondary-action {
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.26);
  background: rgba(255, 255, 255, 0.04);
}

.hero-preview {
  display: grid;
  min-height: 310px;
  place-items: center;
}

.preview-frame {
  width: min(100%, 780px);
  overflow: hidden;
  border: 8px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: white;
  box-shadow: var(--shadow);
}

.preview-frame img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: contain;
}

.generated-preview {
  min-height: 310px;
  padding: clamp(26px, 5vw, 52px);
  color: white;
  background:
    linear-gradient(135deg, #09233b 0%, #116c7a 55%, #2c3168 100%);
}

.generated-preview strong {
  display: block;
  margin-top: 10px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.4rem, 5vw, 5.2rem);
  line-height: 0.98;
}

.lesson-section {
  padding: clamp(36px, 6vw, 76px) clamp(16px, 5vw, 72px);
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 24px;
}

.section-heading h2 {
  margin: 0;
  color: var(--navy);
  font-size: clamp(2rem, 5vw, 4rem);
  line-height: 1;
  letter-spacing: 0;
}

.focus-button {
  min-height: 44px;
  padding: 11px 15px;
  border: 0;
  border-radius: 8px;
  color: white;
  font-weight: 900;
  background: var(--navy);
}

.lesson-workspace {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 18px;
  align-items: stretch;
}

.page-rail {
  position: sticky;
  top: 86px;
  height: calc(100vh - 106px);
  min-height: 520px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  box-shadow: 0 14px 34px rgba(17, 32, 58, 0.08);
}

.rail-heading {
  padding: 16px;
  color: var(--navy);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
  border-bottom: 1px solid var(--line);
}

.page-buttons {
  display: grid;
  gap: 8px;
  height: calc(100% - 51px);
  padding: 12px;
  overflow-y: auto;
}

.page-buttons button {
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  font-weight: 900;
  text-align: left;
  background: #f8fbff;
}

.page-buttons button[aria-current="true"] {
  color: white;
  border-color: var(--blue);
  background: var(--blue);
}

.stage-card {
  display: grid;
  gap: 18px;
  min-width: 0;
  padding: clamp(14px, 3vw, 26px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  box-shadow: var(--shadow);
}

.stage-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 900;
  text-transform: uppercase;
}

.slide-canvas {
  display: grid;
  min-height: min(68vh, 720px);
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #edf5ff;
}

.slide-canvas img {
  display: block;
  width: 100%;
  height: 100%;
  max-height: min(74vh, 820px);
  object-fit: contain;
  background: white;
}

.generated-slide {
  display: grid;
  width: 100%;
  min-height: min(68vh, 720px);
  place-items: center;
  padding: clamp(28px, 6vw, 80px);
  color: white;
  background:
    linear-gradient(135deg, #082033 0%, #146a77 54%, #27336c 100%);
}

.generated-slide-inner {
  width: min(860px, 100%);
}

.generated-slide .lesson-label {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  margin-bottom: 18px;
  padding: 8px 12px;
  border-radius: 8px;
  color: var(--navy);
  font-weight: 900;
  background: var(--lime);
}

.generated-slide h3 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(3rem, 8vw, 7rem);
  line-height: 0.95;
  letter-spacing: 0;
}

.generated-slide p {
  max-width: 660px;
  margin: 20px 0 0;
  color: rgba(255, 255, 255, 0.84);
  font-size: clamp(1rem, 2vw, 1.25rem);
  line-height: 1.55;
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 24px;
}

.badge-row span {
  padding: 8px 11px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 8px;
  font-weight: 900;
  background: rgba(255, 255, 255, 0.1);
}

.teacher-strip {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.teacher-strip div {
  min-height: 92px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
}

.teacher-strip span {
  display: block;
  margin-bottom: 6px;
  color: var(--blue);
  font-size: 0.74rem;
  font-weight: 900;
  text-transform: uppercase;
}

.teacher-strip p {
  margin: 0;
  color: var(--ink);
  line-height: 1.5;
}

.player-controls {
  display: grid;
  grid-template-columns: minmax(92px, auto) minmax(90px, 1fr) minmax(92px, auto);
  gap: 12px;
  align-items: center;
}

.player-controls button {
  min-height: 46px;
  padding: 12px 18px;
  border: 0;
  border-radius: 8px;
  color: white;
  font-weight: 900;
  background: var(--navy);
}

.player-controls button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.progress-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #dfe8f5;
}

.progress-track span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--blue));
  transition: width 0.2s ease;
}

.is-focused .topbar,
.is-focused .lesson-hero,
.is-focused .section-heading,
.is-focused .page-rail {
  display: none;
}

.is-focused .lesson-section {
  padding: 0;
}

.is-focused .lesson-workspace {
  display: block;
}

.is-focused .stage-card {
  min-height: 100vh;
  border: 0;
  border-radius: 0;
}

.is-focused .slide-canvas,
.is-focused .generated-slide {
  min-height: calc(100vh - 146px);
}

@media (max-width: 1050px) {
  .lesson-hero {
    grid-template-columns: 1fr;
  }

  .lesson-workspace {
    grid-template-columns: 1fr;
  }

  .page-rail {
    position: static;
    height: auto;
    min-height: 0;
  }

  .page-buttons {
    grid-auto-flow: column;
    grid-auto-columns: minmax(130px, 1fr);
    height: auto;
    overflow-x: auto;
    overflow-y: hidden;
  }
}

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

  .hero-actions,
  .teacher-strip,
  .player-controls {
    grid-template-columns: 1fr;
    width: 100%;
  }

  .primary-action,
  .secondary-action,
  .player-controls button {
    width: 100%;
  }

  .lesson-hero {
    padding-top: 34px;
  }

  .slide-canvas,
  .generated-slide {
    min-height: 360px;
  }
}
