:root {
  color-scheme: light;
  --paper: #fdfbff;
  --page: #f5f0ff;
  --ink: #23183b;
  --muted: #625577;
  --line: #e5daf7;
  --surface: #eee5ff;
  --purple: #6434c4;
  --purple-dark: #4b2698;
  --plum: #221438;
  --light: #f9f4ff;
  --accent: #ddc8ff;
  --night: #160e25;
  --night-line: #47325e;
  --night-text: #f7f0ff;
  --night-muted: #c7b7da;
  --glow: #d0acff;
  --star: #ffda8a;
  font-family: "Aptos", "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background: var(--page);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 240px; }
button, input, select { font: inherit; color: inherit; }
button:not(:disabled), select { cursor: pointer; }
a { color: inherit; text-decoration: none; }
h1, h2, p, ul { margin: 0; }
:focus-visible { outline: 3px solid #9466e8; outline-offset: 3px; }
[hidden] { display: none !important; }

.home-screen {
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--night-text);
  background:
    radial-gradient(ellipse at 82% 19%, #412367 0%, transparent 46%),
    radial-gradient(ellipse at 3% 98%, #2d1a46 0%, transparent 47%),
    var(--night);
}

.home-shell {
  display: grid;
  grid-template-rows: auto auto 1fr;
  width: min(100%, 1230px);
  min-height: inherit;
  padding-inline: clamp(20px, 5.2vw, 62px);
  margin-inline: auto;
}

.home-topbar {
  grid-row: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  min-height: 80px;
  padding-block: 13px;
  border-bottom: 1px solid #b891e82b;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  width: fit-content;
  max-width: 100%;
  min-width: 0;
  color: var(--night-text);
}

.brand-symbol {
  position: relative;
  display: block;
  flex: 0 0 35px;
  width: 35px;
  height: 35px;
  border-radius: 11px;
  background: linear-gradient(140deg, #e5caff, #ad78f9);
  box-shadow: 0 2px 16px #a26aff32, inset 0 1px 1px #fff8;
}

.brand-symbol::before, .brand-symbol::after {
  position: absolute;
  inset: 8px 10px;
  border: 2px solid #312049;
  border-radius: 3px;
  content: "";
}
.brand-symbol::before { transform: translate(-3px, 2px) rotate(-14deg); opacity: .65; }
.brand-symbol::after { transform: translate(2px, -1px) rotate(12deg); background: #d6b1ff; }
.brand-name { font-size: 1.22rem; font-weight: 800; letter-spacing: -.045em; line-height: 1.1; }
.brand-mark:hover .brand-name { color: var(--glow); }

.app-actions {
  display: flex;
  align-items: center;
  justify-content: end;
  flex-wrap: wrap;
  min-width: 0;
  gap: 7px;
}
.score-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 10px;
  border: 1px solid #c9a1fa42;
  border-radius: 999px;
  color: var(--glow);
  background: #29183e;
  white-space: nowrap;
  font-size: .84rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.score-star { color: var(--star); }

.home-content {
  grid-row: 3;
  align-self: center;
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(0, .88fr);
  align-items: center;
  gap: clamp(30px, 7vw, 100px);
  padding-block: clamp(38px, 10dvh, 115px);
}

.home-intro { min-width: 0; }
.course-meta {
  color: var(--glow);
  font-size: .76rem;
  font-weight: 800;
  letter-spacing: .11em;
  line-height: 1.45;
  text-transform: uppercase;
}
.home-title {
  max-width: 13ch;
  margin-top: 12px;
  font-size: clamp(3.25rem, 6.8vw, 6rem);
  font-weight: 850;
  letter-spacing: -.08em;
  line-height: .99;
  text-wrap: balance;
}
.home-title em, .home-title strong {
  color: var(--glow);
  font-style: normal;
  font-weight: inherit;
}
.home-description {
  max-width: 34ch;
  margin-top: clamp(15px, 3vw, 24px);
  color: var(--night-muted);
  font-size: clamp(1rem, 2vw, 1.28rem);
  line-height: 1.55;
  text-wrap: pretty;
}
.home-course { min-width: 0; }
.course-card {
  display: grid;
  width: 100%;
  max-width: 490px;
  margin-inline: auto;
  overflow: hidden;
  border: 1px solid #c996fb5e;
  border-radius: clamp(18px, 3vw, 28px);
  color: var(--night-text);
  background: linear-gradient(135deg, #302047, #291940 75%);
  box-shadow: 0 22px 50px #0e081a77;
  transition: border-color .2s ease, transform .2s ease, box-shadow .2s ease;
}
a.course-card:hover, .course-card:focus-within {
  transform: translateY(-3px);
  border-color: var(--glow);
  box-shadow: 0 24px 62px #0e081aa3;
}
.course-info { display: grid; gap: 7px; padding: clamp(17px, 2.5vw, 27px); }
.course-title {
  font-size: clamp(1.8rem, 3.1vw, 2.6rem);
  font-weight: 820;
  letter-spacing: -.06em;
  line-height: 1.04;
}
.course-description {
  color: var(--night-muted);
  font-size: .96rem;
  line-height: 1.4;
}
.course-cta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  margin-top: 6px;
  padding: 8px 12px;
  border-radius: 10px;
  color: #25173b;
  background: #dbbaff;
  font-size: .92rem;
  font-weight: 830;
  line-height: 1.25;
}
a.course-card:hover .course-cta, a.course-cta:hover { background: #ecd4ff; }
.course-snapshot { color: #d4bee5; font-size: .83rem; font-weight: 700; }
.home-notices { grid-row: 2; }
.home-screen .save-notice {
  margin-top: 10px;
  border-radius: 9px;
}

.transfer-offer, .transfer-panel {
  border: 1px solid var(--night-line);
  border-radius: 14px;
  background: #2b1c40;
  color: var(--night-text);
}
.transfer-offer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 12px;
  justify-content: space-between;
  margin-top: 12px;
  padding: 10px 12px;
}
.transfer-offer > p:first-child { flex: 1 1 230px; padding-block: 4px; }
.transfer-screen {
  display: grid;
  align-items: center;
  justify-items: center;
  padding: 18px;
}
.transfer-panel {
  display: grid;
  gap: 12px;
  width: min(100%, 460px);
  padding: clamp(18px, 5vw, 26px);
}
.transfer-panel h1 { font-size: clamp(1.6rem, 5vw, 2rem); }
.transfer-description, .transfer-status { color: var(--night-muted); line-height: 1.45; }
.transfer-controls { display: flex; flex-wrap: wrap; gap: 8px; }
.transfer-status { flex-basis: 100%; font-size: .86rem; }
.transfer-status:not(:empty) { padding-top: 6px; }
.transfer-button {
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--glow);
  border-radius: 9px;
  background: #dbbaff;
  color: #25173b;
  font-weight: 760;
}
.transfer-button:hover:not(:disabled) { background: #ecd4ff; }
.transfer-button:disabled { opacity: .7; }
.transfer-secondary { border-color: #765896; background: #3b2b54; color: var(--night-text); }
.transfer-secondary:hover:not(:disabled) { background: #4c3669; }

@media (max-width: 700px) {
  .home-content {
    grid-template-columns: 1fr;
    align-self: start;
    gap: clamp(24px, 5dvh, 40px);
    padding-block: clamp(24px, 5dvh, 50px) 34px;
  }
  .home-title { font-size: clamp(2.8rem, 10.5vw, 4.2rem); }
  .home-course { width: min(100%, 480px); }
}

@media (max-width: 460px) {
  .home-shell { padding-inline: 16px; }
  .home-topbar { gap: 8px; min-height: 64px; }
  .home-topbar .app-actions { justify-content: start; }
  .home-topbar .brand-name { font-size: 1.06rem; }
  .home-topbar .brand-symbol { flex-basis: 32px; width: 32px; height: 32px; }
  .home-title { margin-top: 7px; }
}

.course-layout {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
}
.course-header {
  z-index: 2;
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px clamp(12px, 2.3vw, 30px);
  padding: 9px max(16px, calc((100vw - 1106px) / 2));
  background: #211532;
  border-bottom: 1px solid var(--night-line);
  color: var(--night-text);
}
.course-brand { min-width: 0; }
.course-brand .brand-name { font-size: 1.08rem; }
.course-brand .brand-symbol { flex-basis: 32px; width: 32px; height: 32px; }
.course-header .menus { display: contents; }
.course-selectors {
  display: grid;
  grid-template-columns: minmax(0, auto) minmax(0, 240px);
  justify-content: center;
  align-items: end;
  gap: 8px;
  min-width: 0;
}
.menu { display: grid; gap: 2px; min-width: 0; position: relative; }
.menu span {
  padding-left: 1px;
  color: var(--night-muted);
  font-size: .74rem;
  line-height: 1.15;
  font-weight: 760;
}
.menu select {
  appearance: none;
  min-width: 0;
  min-height: 35px;
  border: 1px solid #674986;
  border-radius: 9px;
  color-scheme: dark;
  background: #2e1e46;
  padding: 4px 26px 4px 10px;
  width: 100%;
  font-weight: 680;
  text-overflow: ellipsis;
}
.menu select:hover { border-color: #ac82d6; }
.menu::after {
  position: absolute;
  content: "";
  right: 9px;
  bottom: 14px;
  width: 6px;
  height: 6px;
  border-right: 2px solid var(--glow);
  border-bottom: 2px solid var(--glow);
  transform: rotate(45deg);
  pointer-events: none;
}

.learning-feed {
  position: relative;
  isolation: isolate;
  flex: 1 1 auto;
  min-height: 0;
  container-type: size;
  overflow: hidden;
  background: var(--night);
}
.slide {
  position: absolute;
  inset: 0;
  display: grid;
  align-content: safe center;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  scrollbar-width: thin;
  scrollbar-gutter: stable both-edges;
  padding: 14px 16px max(16px, env(safe-area-inset-bottom));
}
.slide.is-adjacent { pointer-events: none; }
.slide.fits-feed { touch-action: pan-x pinch-zoom; }
.lesson-panel { width: min(100%, 460px); min-width: 0; margin-inline: auto; }
.video-slide {
  background: radial-gradient(ellipse at 43% 20%, #362450 0%, #20152e 47%, #130d1e 100%);
  color: var(--night-text);
}
.story-slide, .quiz-slide {
  background: radial-gradient(ellipse at 50% 4%, #392556 0%, transparent 75%), var(--night);
}
.story-panel, .question-panel { width: min(100%, 490px); color: var(--night-text); }
.story-meter {
  display: flex;
  gap: 5px;
  margin-bottom: 9px;
}
.story-segment {
  flex: 1 1 0;
  height: 4px;
  border-radius: 999px;
  background: #665080;
}
.story-segment.is-past, .story-segment.is-answered { background: #bd94ee; }
.story-segment.is-current { background: #f3e6ff; }
.lesson-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 23px;
  margin-bottom: 8px;
  color: var(--muted);
  font-weight: 750;
  font-size: .875rem;
}
.video-slide .lesson-meta,
.story-panel .lesson-meta, .question-panel .lesson-meta,
.video-slide .transcript, .video-slide .media-notice { color: #ded2ed; }
.video-heading, .quiz-heading {
  font-size: clamp(1.5rem, 4.7vw, 2.1rem);
  line-height: 1.08;
  letter-spacing: -.055em;
  margin-bottom: 11px;
}
.quiz-slide .quiz-heading { color: var(--night-text); }
.video-slide > .lesson-panel { width: min(100%, 900px); }
.video-stage {
  --frame-height: clamp(150px, calc(100vh - 96px), 880px);
  --frame-height: clamp(150px, calc(100cqh - 34px), 880px);
  display: grid;
  grid-template-columns: minmax(0, min(53%, calc(var(--frame-height) * .5625))) minmax(0, 22rem);
  align-items: center;
  justify-content: center;
  gap: clamp(18px, 4vw, 48px);
}
.video-guide {
  min-width: 0;
  padding: clamp(14px, 2.4vw, 24px);
  border: 1px solid #76569765;
  border-radius: 18px;
  background: #21162eee;
}
.video-guide .lesson-meta > :first-child {
  color: var(--glow);
  font-size: .76rem;
  font-weight: 800;
  letter-spacing: .055em;
  text-transform: uppercase;
}
.video-heading {
  font-size: clamp(1.65rem, 3vw, 2.55rem);
  margin-bottom: 0;
  text-wrap: balance;
}
.video-frame {
  position: relative;
  min-width: 0;
  width: 100%;
  aspect-ratio: 9 / 16;
  overflow: hidden;
  border: 1px solid #a684cf49;
  border-radius: 19px;
  background: #120b1d;
  box-shadow: 0 12px 34px #10061f5c;
}
.video-frame video, .video-frame .preview-poster {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.sound-toggle, .play-toggle {
  position: absolute;
  z-index: 1;
  min-height: 44px;
  border: 1px solid #ffffff52;
  border-radius: 999px;
  padding: 6px 13px;
  background: #231335eb;
  color: #fff;
  font-size: .855rem;
  font-weight: 760;
  box-shadow: 0 2px 10px #0004;
}
.sound-toggle { right: 10px; top: 10px; }
.play-toggle { left: 50%; top: 50%; transform: translate(-50%, -50%); min-height: 44px; }
.sound-toggle:hover, .play-toggle:hover { background: #4d2f70; }
.action {
  display: block;
  width: 100%;
  margin-top: 10px;
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 8px 14px;
  background: var(--purple);
  color: #fff;
  font-weight: 780;
  text-align: center;
}
.action:hover:not(:disabled) { background: var(--purple-dark); }
.action:disabled { opacity: .48; cursor: default; }
.completion {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 99px;
  background: var(--surface);
  color: var(--purple-dark);
  font-weight: 750;
  font-size: .875rem;
}
.video-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: start;
  gap: 10px;
  justify-content: space-between;
  margin-top: 9px;
}
.transcript, .save-notice, .media-notice { color: var(--muted); font-size: .925rem; }
.transcript[open] { flex-basis: 100%; }
.transcript summary {
  cursor: pointer;
  width: fit-content;
  min-height: 44px;
  padding-block: 12px;
  font-weight: 700;
}
.transcript p { margin-top: 8px; line-height: 1.5; }
.save-notice { padding: 8px 14px; background: #f2e9ff; text-align: center; }
.media-notice { margin-top: 7px; }

.reel-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, auto) minmax(0, 1fr);
  align-items: center;
  justify-items: stretch;
  gap: clamp(4px, 2vw, 10px);
  margin-top: 13px;
}
.reel-controls .action { margin: 0; min-height: 44px; font-size: .875rem; padding-inline: 5px; }
.reel-position { color: var(--muted); font-size: .875rem; font-weight: 750; text-align: center; }
.video-slide .reel-position,
.story-panel .reel-position, .question-panel .reel-position { color: #ded2ed; }
.quiz-slide > .lesson-panel:not(.question-panel) .reel-position { color: #ded2ed; }
.video-slide .reel-controls .next-action,
.story-panel .reel-controls .next-action, .quiz-slide .reel-controls .next-action {
  border-color: #956ebe7a;
  color: #f8edff;
  background: #36214d;
}
.video-slide .reel-controls .next-action:hover:not(:disabled),
.story-panel .reel-controls .next-action:hover:not(:disabled),
.quiz-slide .reel-controls .next-action:hover:not(:disabled) { background: #503269; }
.reel-controls .action:not(.next-action) { background: #d3b2fc; color: #25173a; }
.reel-controls .action:not(.next-action):hover:not(:disabled) { background: #e7d0ff; }
.flashcard {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: clamp(290px, 53dvh, 490px);
  min-height: clamp(252px, 57cqh, 470px);
  border: 1px solid #8363ac;
  border-radius: 19px;
  padding: clamp(15px, 4vw, 23px);
  background: radial-gradient(ellipse at 90% 0, #51347c, #291843 62%, #201431);
  color: var(--light);
  box-shadow: 0 12px 34px #32154e26;
}
.flashcard h1 {
  max-width: 17ch;
  font-size: clamp(1.8rem, 5.8vw, 2.65rem);
  line-height: 1.06;
  letter-spacing: -.055em;
}
.flashcard p { line-height: 1.5; margin-top: 9px; }
.flashcard .prediction { font-weight: 750; }
.prediction-choices {
  list-style: none;
  padding: 0;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.prediction-choices li { background: #4a3265; border-radius: 8px; min-width: 36px; padding: 5px 8px; text-align: center; }
.reveal { padding: 10px 12px; background: #50376d; border-left: 2px solid var(--accent); border-radius: 0 8px 8px 0; }
.reveal-button { background: var(--accent); color: #24143c; margin-top: 15px; }
.reveal-button:hover:not(:disabled) { background: #e9ddff; }
.next-action { margin-top: 12px; background: var(--paper); color: var(--purple-dark); border-color: #d4bfee; }
.next-action:hover:not(:disabled) { background: var(--surface); }
.code-panel {
  margin: 12px 0 2px;
  padding: 9px 11px;
  overflow: auto;
  border-radius: 9px;
  background: #1c102c;
  border: 1px solid #604779;
  color: #f6eeff;
  font: .95rem/1.5 Consolas, ui-monospace, monospace;
  tab-size: 4;
}
.code-value { color: #e1b9ff; }
.code-string { color: #c5d2ff; }

.quiz-card {
  padding: clamp(13px, 3.5vw, 20px);
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--paper);
  box-shadow: 0 10px 26px #47247513;
}
.quiz-card h1 { font-size: 1.25rem; line-height: 1.32; letter-spacing: -.025em; }
.question-panel .quiz-card {
  background: #261a37;
  border-color: #765798;
  box-shadow: 0 12px 30px #09051264;
}
.question-panel .quiz-card h1 {
  font-size: clamp(1.3rem, 4vw, 1.75rem);
  line-height: 1.2;
}
.quiz-title { margin-bottom: 5px; color: var(--muted); font-size: .875rem; font-weight: 750; }
.quiz-note { margin-bottom: 10px; color: var(--muted); font-size: .875rem; }
.question-panel .quiz-title, .question-panel .quiz-note { color: #dac4f2; }
.quiz-result-link {
  min-height: 44px;
  padding: 4px 0;
  border: 0;
  background: none;
  color: var(--purple-dark);
  font-weight: 750;
  text-decoration: underline;
}
.question-panel .quiz-result-link { color: #e8ccff; }
progress { appearance: none; width: 100%; height: 7px; border: 0; border-radius: 30px; margin-top: 7px; accent-color: var(--purple); }
progress::-webkit-progress-bar { background: var(--surface); border-radius: 30px; }
progress::-webkit-progress-value { background: var(--purple); border-radius: 30px; }
progress::-moz-progress-bar { background: var(--purple); border-radius: 30px; }
.quiz-meter, .leaderboard-a11y {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
}
.choices { display: grid; gap: 7px; margin-top: 11px; }
.choice {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 44px;
  padding: 6px 8px;
  border: 1px solid #dfd1f1;
  border-radius: 9px;
  background: #f6f0ff;
  text-align: left;
  overflow-wrap: anywhere;
}
.choice:not(:disabled):hover { background: #eaddff; border-color: #ae8ddf; }
.choice-letter {
  flex: 0 0 25px;
  height: 25px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: #e8dcfb;
  color: var(--purple-dark);
  font-size: .86rem;
  font-weight: 780;
}
.choice.correct { background: #e9d9ff; border-color: #8759c6; }
.choice.incorrect { background: #f8effc; border-style: dashed; border-color: #9862a4; }
.question-panel .choice { background: #38264f; border-color: #79549c; }
.question-panel .choice:not(:disabled):hover { background: #493168; border-color: #ba98e5; }
.question-panel .choice-letter { color: #f2e3ff; background: #5c3f79; }
.question-panel .choice.correct { color: #2c1846; background: #e1c9fb; border-color: #f0dcff; }
.question-panel .choice.correct .choice-letter { color: #3d2558; background: #c6a2f0; }
.question-panel .choice.incorrect { background: #472942; border-color: #c38eb8; }
.feedback { color: var(--muted); font-size: .95rem; line-height: 1.4; margin-top: 10px; }
.feedback strong { color: var(--ink); }
.question-panel .feedback { color: #e6d6f3; }
.question-panel .feedback strong { color: var(--night-text); }
.correct-count { font-variant-numeric: tabular-nums; }
.star-reward {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  gap: 4px;
  margin-top: 8px;
  padding: 4px 9px;
  border: 1px solid #d8bbee;
  border-radius: 999px;
  background: #f2e4ff;
  color: #542692;
  font-size: .86rem;
  font-weight: 800;
  line-height: 1.25;
}
.results-score { font-size: 3.25rem; font-weight: 850; letter-spacing: -.07em; color: var(--purple-dark); }
.results-best { color: var(--muted); }

.progress-open, .leaderboard-open, .progress-close {
  flex: 0 0 auto;
  min-height: 38px;
  padding: 6px 11px;
  border: 1px solid #d4bfee;
  border-radius: 9px;
  background: var(--surface);
  color: var(--purple-dark);
  font-weight: 760;
  line-height: 1.2;
}
.progress-open:hover, .progress-close:hover { background: #e6d7fa; }
.app-actions .progress-open, .app-actions .leaderboard-open {
  min-height: 38px;
  padding: 6px 11px;
  border-color: #c498e646;
  border-radius: 9px;
  background: #2e1d46;
  color: var(--night-text);
  font-size: .88rem;
}
.app-actions .leaderboard-open { background: #43305c; }
.app-actions .progress-open:hover, .app-actions .leaderboard-open:hover {
  border-color: #b58ada;
  background: #533872;
}
.progress-board { display: grid; gap: 12px; }
.progress-level {
  min-width: 0;
  padding: clamp(12px, 4vw, 18px);
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--paper);
}
.progress-level-head, .progress-dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.progress-level-head h2, .progress-dialog-head h2 {
  font-size: 1.22rem;
  line-height: 1.1;
  letter-spacing: -.035em;
}
.progress-count {
  flex: 0 0 auto;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--purple-dark);
  font-size: .8rem;
  font-weight: 760;
}
.progress-meter { display: block; height: 9px; margin: 10px 0 12px; }
.progress-topics { display: grid; gap: 6px; padding: 0; list-style: none; }
.progress-topic {
  position: relative;
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  min-height: 56px;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f9f5ff;
}
.progress-topic.is-complete { background: #f2eaff; }
.progress-topic:has(.progress-topic-link:hover) { background: #ebdfff; }
.progress-mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid #d6c5ee;
  border-radius: 50%;
  background: var(--paper);
  color: var(--muted);
  font-size: .9rem;
  font-weight: 810;
}
.progress-topic.is-complete .progress-mark {
  border-color: var(--purple);
  background: var(--purple);
  color: #fff;
}
.progress-topic-body { display: grid; min-width: 0; justify-items: start; }
.progress-topic-link {
  appearance: none;
  max-width: 100%;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink);
  font-weight: 760;
  text-align: start;
  overflow-wrap: anywhere;
}
.progress-topic-link::after { position: absolute; inset: 0; border-radius: 10px; content: ""; }
.progress-status { color: var(--muted); font-size: .82rem; line-height: 1.35; }
.progress-level-result .progress-board { margin-block: 12px; }
.progress-dialog {
  --paper: #2b1e3d;
  --ink: var(--night-text);
  --muted: var(--night-muted);
  --line: #5a4270;
  --surface: #46305c;
  --purple: #ad79f6;
  --purple-dark: #ebd7ff;
  color-scheme: dark;
  width: min(calc(100% - 24px), 535px);
  max-height: min(calc(100vh - 30px), 700px);
  max-height: min(calc(100dvh - 30px), 700px);
  padding: clamp(14px, 4vw, 24px);
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--line);
  border-radius: 19px;
  background: linear-gradient(150deg, #322148, #211530 70%);
  color: var(--ink);
  box-shadow: 0 18px 70px #0d061eaa;
}
.progress-dialog::backdrop { background: #140b25c9; backdrop-filter: blur(3px); }
.progress-dialog-head { margin-bottom: 15px; }
.progress-dialog-head h2 { font-size: clamp(1.4rem, 4.8vw, 1.75rem); }
.progress-dialog .progress-close {
  min-height: 42px;
  border-color: var(--line);
  background: #352349;
}
.progress-dialog .progress-close:hover { background: #503368; }
.progress-dialog .progress-topic { background: #322241; }
.progress-dialog .progress-topic.is-complete { background: #3b2851; }
.progress-dialog .progress-topic:has(.progress-topic-link:hover) { background: #50346e; }
.progress-dialog .progress-mark { border-color: var(--line); }
.progress-dialog .progress-topic.is-complete .progress-mark { background: #7143b2; }

.leaderboard-dialog[open] {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.leaderboard-body {
  --rank-column: 58px;
  --first-try-column: 62px;
  --score-column: 66px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  gap: 10px;
}
.leaderboard-note, .guest-intro {
  color: var(--night-muted);
  font-size: .93rem;
  line-height: 1.45;
}
.leaderboard-state {
  display: grid;
  justify-items: start;
  gap: 7px;
}
.leaderboard-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 8px 12px;
  padding: 10px 12px;
  border: 1px solid #9a6cc4;
  border-radius: 12px;
  background: linear-gradient(125deg, #503268, #39244f);
}
.leaderboard-summary-copy {
  display: grid;
  min-width: 0;
  gap: 2px;
}
.leaderboard-player {
  min-width: 0;
  font-weight: 740;
  overflow-wrap: anywhere;
}
.leaderboard-rank-text {
  color: #dfcef1;
  font-size: .83rem;
  font-weight: 650;
}
.leaderboard-total {
  align-self: center;
  color: #f7edff;
  font-weight: 850;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.leaderboard-star { margin-left: 3px; color: var(--star); }
.leaderboard-name-action, .guest-later {
  min-height: 38px;
  padding: 7px 10px;
  border: 1px solid #9970bc;
  border-radius: 8px;
  background: #322045;
  color: #f0e3fb;
  font-size: .86rem;
  font-weight: 730;
}
.leaderboard-name-action:hover, .guest-later:hover { background: #56376f; }
.leaderboard-columns, .leaderboard-row {
  display: grid;
  grid-template-columns: var(--rank-column) minmax(0, 1fr) var(--first-try-column) var(--score-column);
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
}
.leaderboard-columns {
  padding-inline-end: 19px;
  border-bottom: 1px solid #a884cc46;
  color: var(--night-muted);
  font-size: .75rem;
  font-weight: 760;
  letter-spacing: .04em;
}
.leaderboard-columns :nth-last-child(2), .leaderboard-first-try { text-align: center; }
.leaderboard-first-try {
  color: #dfcef1;
  font-variant-numeric: tabular-nums;
}
.leaderboard-columns :last-child, .leaderboard-row .leaderboard-total { text-align: right; }
.leaderboard-list {
  display: grid;
  align-content: start;
  flex: 1 1 auto;
  min-height: 0;
  min-height: min(112px, 24dvh);
  gap: 5px;
  margin: 0;
  padding: 0 4px 3px 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-color: #8463a7 #281936;
  scrollbar-width: thin;
  scrollbar-gutter: stable;
  list-style: none;
}
.leaderboard-row {
  min-height: 39px;
  border: 1px solid #6e538646;
  border-radius: 8px;
  background: #17102169;
  font-size: .88rem;
}
.leaderboard-row.is-podium { border-color: #c092e277; background: #473156; }
.leaderboard-row.is-you { border-color: #ce9eff; background: #4f326b; }
.leaderboard-rank {
  width: fit-content;
  min-width: 30px;
  padding: 3px 5px;
  border-radius: 6px;
  color: #ceb7eb;
  text-align: center;
  font-weight: 820;
  font-variant-numeric: tabular-nums;
}
.is-podium .leaderboard-rank { color: #291642; background: #d5aef8; }
.leaderboard-you {
  display: inline-block;
  margin-left: 5px;
  color: #f0d9ff;
  font-size: .77rem;
  font-weight: 720;
}

.guest-dialog { width: min(calc(100% - 24px), 440px); }
.guest-form { display: grid; gap: 10px; }
.guest-intro { margin-bottom: 3px; }
.guest-label { font-size: .875rem; font-weight: 760; }
.guest-input {
  min-width: 0;
  min-height: 46px;
  margin-top: -4px;
  padding: 8px 12px;
  border: 1px solid #8b66aa;
  border-radius: 10px;
  background: #1a1128;
  color: var(--night-text);
}
.guest-input::placeholder { color: #b7a1cc; }
.guest-input:focus-visible { border-color: #debbff; outline-color: #aa77e6; outline-offset: 2px; }
.guest-note { color: var(--night-muted); font-size: .83rem; line-height: 1.4; }
.guest-error { color: #ffc7e2; font-size: .88rem; line-height: 1.4; }
.guest-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: end;
  gap: 8px;
  margin-top: 6px;
}
.guest-actions .guest-save, .guest-actions .guest-later {
  width: auto;
  min-height: 44px;
  margin: 0;
  padding-inline: 12px;
}
.guest-actions .guest-save { border-color: var(--glow); background: #dabbff; color: #281941; }
.guest-actions .guest-save:hover:not(:disabled) { background: #ead2ff; }

@media (max-width: 700px) {
  .course-header {
    grid-template-columns: auto minmax(0, 1fr);
    gap: 6px 9px;
    padding-block: 7px;
  }
  .course-selectors {
    grid-area: 2 / 1 / 3 / -1;
    grid-template-columns: minmax(0, .72fr) minmax(0, 1.28fr);
    gap: 7px;
  }
  .course-header .app-actions { grid-area: 1 / 2 / 2 / 3; }
  .video-slide {
    --video-bottom-pad: max(10px, env(safe-area-inset-bottom, 0px));
    padding-block: 7px var(--video-bottom-pad);
  }
  .video-slide > .lesson-panel { width: min(100%, 440px); }
  .video-stage {
    height: calc(100vh - 140px);
    height: calc(100cqh - 7px - var(--video-bottom-pad));
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(145px, 1fr) auto;
    align-items: stretch;
    gap: 7px;
  }
  .video-frame {
    justify-self: center;
    width: auto;
    height: 100%;
    max-width: 100%;
    border-radius: 14px;
  }
  .video-guide {
    padding: 0 2px;
    border: 0;
    background: none;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "meta transcript" "heading heading" "notice notice" "nav nav";
    align-items: center;
    column-gap: 8px;
  }
  .video-guide .lesson-meta { grid-area: meta; margin-bottom: 0; }
  .video-heading { grid-area: heading; font-size: clamp(1.22rem, 4.6vw, 1.65rem); text-wrap: pretty; }
  .video-guide .media-notice { grid-area: notice; }
  .video-guide .video-actions { grid-area: transcript; margin-top: 0; }
  .video-guide .reel-controls { grid-area: nav; margin-top: 7px; }
  .video-guide:has(.transcript[open]) {
    grid-template-areas: "meta meta" "heading heading" "notice notice" "transcript transcript" "nav nav";
  }
  .video-guide .transcript { font-size: .85rem; }
  .video-guide .transcript[open] p { font-size: .95rem; margin-block: 0 9px; }
  .story-panel, .question-panel { width: min(100%, 440px); }
}

@media (max-width: 460px) {
  .course-header { padding-inline: 10px; }
  .course-brand .brand-name { display: none; }
  .app-actions { gap: 5px; }
  .app-actions .progress-open, .app-actions .leaderboard-open { padding-inline: 7px; font-size: .8rem; }
  .score-pill { padding-inline: 7px; font-size: .78rem; }
  .menu select { font-size: .875rem; }
  .leaderboard-body { --rank-column: 42px; --first-try-column: 48px; --score-column: 48px; }
  .leaderboard-columns, .leaderboard-row { padding-inline: 7px; }
  .leaderboard-columns { padding-inline-end: 16px; }
  .leaderboard-summary { padding: 8px 9px; gap: 6px 8px; }
}

@media (max-width: 340px) {
  .leaderboard-summary { grid-template-columns: minmax(0, 1fr) auto; }
  .leaderboard-name-action { grid-column: 1 / -1; }
}

@media (max-width: 390px) {
  .menu select { padding-inline: 6px 17px; }
  .menu::after { right: 6px; width: 5px; height: 5px; }
  .slide { padding-inline: 12px; }
}
@media (pointer: coarse) {
  .app-actions .progress-open, .app-actions .leaderboard-open { min-height: 44px; }
}
@media (prefers-reduced-motion: reduce) {
  .course-card { transition: none; }
  a.course-card:hover, .course-card:focus-within { transform: none; }
}
@media (max-height: 560px) {
  .slide:not(.video-slide) { align-content: start; padding-block: 9px 12px; }
  .flashcard { min-height: 250px; }
}
@media (max-height: 400px) {
  .leaderboard-dialog[open] { overflow-y: auto; }
  .leaderboard-body { flex: 0 0 auto; }
  .leaderboard-list { max-height: 31dvh; }
}
