:root {
  --bg: #f7f8fc;
  --surface: #ffffff;
  --surface-soft: #fbfcff;
  --ink: #121936;
  --muted: #66708a;
  --line: #dfe4ee;
  --line-strong: #c8d0df;
  --purple: #5b35f2;
  --purple-dark: #3f20c7;
  --purple-soft: #f0ebff;
  --green: #15956d;
  --green-soft: #e8f8f1;
  --orange: #d97a00;
  --orange-soft: #fff1dc;
  --blue: #2368d7;
  --blue-soft: #eaf1ff;
  --danger: #b84036;
  --danger-soft: #fdecea;
  --code: #101524;
  --shadow: 0 18px 45px rgba(18, 25, 54, 0.09);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
  min-width: 320px;
}

button,
textarea,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

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

h1,
h2,
h3,
p,
pre,
blockquote {
  margin: 0;
}

.loading-screen {
  display: grid;
  min-height: 100vh;
  place-items: center;
  align-content: center;
  gap: 12px;
  text-align: center;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: minmax(230px, 1fr) auto minmax(230px, 1fr);
  gap: 24px;
  align-items: center;
  min-height: 72px;
  padding: 12px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
}

.topbar-brand {
  display: inline-flex;
  gap: 12px;
  align-items: center;
  width: max-content;
}

.topbar-brand span:last-child {
  display: grid;
  gap: 2px;
}

.topbar-brand strong {
  font-size: 0.98rem;
}

.topbar-brand small,
.topbar-stats span,
.mission-row small,
.stepper small,
.page-heading p,
.mode-card p,
.chapter-card p,
.mission-card p,
.prompt,
.support-column p,
.mini-concept-card p,
.help-card p,
.profile-hero p,
.profile-card span,
.stat-list span {
  color: var(--muted);
}

.brand-mark,
.python-orb,
.profile-avatar,
.mode-icon {
  display: grid;
  place-items: center;
  border-radius: 8px;
  font-weight: 900;
}

.brand-mark {
  width: 42px;
  height: 42px;
  background: linear-gradient(135deg, var(--purple), var(--purple-dark));
  color: #fff;
}

.brand-mark.large {
  width: 64px;
  height: 64px;
  margin: 0 auto;
}

.global-nav {
  display: inline-flex;
  gap: 6px;
  justify-content: center;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f1f3f8;
}

.global-nav a {
  min-width: 82px;
  padding: 9px 12px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 850;
  text-align: center;
}

.global-nav a.active {
  background: var(--surface);
  color: var(--purple-dark);
  box-shadow: 0 1px 4px rgba(18, 25, 54, 0.1);
}

.topbar-stats {
  display: inline-flex;
  justify-content: flex-end;
  align-items: center;
  gap: 14px;
  font-size: 0.86rem;
  font-weight: 800;
}

.avatar-link {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  color: var(--purple-dark);
  font-weight: 900;
}

.page-shell {
  width: min(1380px, calc(100% - 48px));
  margin: 24px auto 40px;
}

.road-page {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.roadmap-rail {
  min-height: calc(100vh - 124px);
  padding: 28px 22px;
  border-right: 1px solid var(--line);
  background: var(--surface-soft);
}

.rail-title {
  margin-bottom: 20px;
}

.rail-title h2 {
  margin-top: 5px;
  font-size: 1rem;
  line-height: 1.3;
}

.eyebrow {
  color: var(--purple-dark);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.mission-list {
  display: grid;
  gap: 10px;
}

.mission-row {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  padding: 12px;
  border: 1px solid transparent;
  border-radius: 8px;
}

.mission-row.active {
  border-color: #ddd3ff;
  background: var(--purple-soft);
}

.mission-row strong,
.mission-row small {
  display: block;
  min-width: 0;
}

.mission-row strong {
  margin-bottom: 3px;
  font-size: 0.88rem;
  line-height: 1.25;
}

.mission-row small {
  font-size: 0.78rem;
  line-height: 1.35;
}

.day-badge,
.step-pill {
  display: inline-grid;
  place-items: center;
  min-height: 28px;
  border-radius: 999px;
  background: var(--purple-soft);
  color: var(--purple-dark);
  font-size: 0.76rem;
  font-weight: 900;
}

.launchpad {
  padding: 42px;
}

.hero-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 270px;
  gap: 28px;
  align-items: center;
  min-height: 220px;
}

.hero-row h1,
.page-heading h1 {
  margin: 8px 0 10px;
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 1.05;
}

.hero-row p,
.page-heading p {
  max-width: 720px;
  font-size: 1.02rem;
  line-height: 1.55;
}

.python-orb {
  width: 220px;
  height: 180px;
  justify-self: center;
  border-radius: 36px;
  background:
    radial-gradient(circle at 75% 25%, #ffbe55 0 10%, transparent 11%),
    radial-gradient(circle at 18% 35%, #54c7a0 0 9%, transparent 10%),
    linear-gradient(135deg, #f4efff, #eef7ff);
  color: var(--purple);
  font-size: 3rem;
  box-shadow: inset 0 0 0 1px #e4dcff;
}

.continue-card,
.mission-card,
.chapter-card,
.mode-card,
.question-card,
.editor-card,
.output-card,
.editor-file-rail,
.python-editor-card,
.editor-run-card,
.debug-card,
.idea-card,
.support-column,
.timeline-card,
.code-trace-card,
.state-card,
.concept-card,
.concept-assist-card,
.help-card,
.profile-card,
.profile-form,
.summary-card,
.empty-state,
.chapter-progress-list {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.continue-card {
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr) auto;
  gap: 20px;
  align-items: center;
  margin: 10px 0 28px;
  padding: 22px;
  border-color: #d9ccff;
}

.continue-card.compact {
  margin-top: 18px;
}

.continue-card h2 {
  margin: 5px 0 6px;
  font-size: 1.18rem;
}

.mode-icon {
  width: 52px;
  height: 52px;
  background: var(--purple);
  color: #fff;
  font-size: 1.2rem;
}

.meter-track {
  width: 100%;
  height: 8px;
  margin-top: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #e7eaf2;
}

.meter-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--purple);
}

.mode-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  margin: 26px 0;
}

.mode-card {
  display: grid;
  min-height: 230px;
  align-content: start;
  gap: 14px;
  padding: 22px;
}

.mode-card.green .mode-icon {
  background: var(--green);
}

.mode-card.orange .mode-icon {
  background: var(--orange);
}

.mode-card.purple .mode-icon {
  background: var(--purple);
}

.mode-card strong {
  font-size: 1.16rem;
}

.mode-card p {
  line-height: 1.5;
}

.card-link,
.text-link,
.mini-concept-card a {
  color: var(--purple-dark);
  font-weight: 900;
}

.stats-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.stats-strip div {
  display: grid;
  gap: 4px;
  padding: 18px 20px;
}

.stats-strip div:not(:last-child) {
  border-right: 1px solid var(--line);
}

.stats-strip span {
  color: var(--muted);
  font-size: 0.82rem;
}

.simple-page {
  display: grid;
  gap: 24px;
}

.page-heading {
  padding: 10px 0;
}

.split-heading {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: start;
}

.chapter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
}

.chapter-card {
  display: grid;
  gap: 12px;
  min-height: 190px;
  padding: 20px;
}

.chapter-card-head,
.editor-head,
.task-toolbar,
.modal-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.chapter-card-head {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 900;
}

.topic-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.topic-cloud span,
.task-tags span {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--purple-soft);
  color: var(--purple-dark);
  font-size: 0.8rem;
  font-weight: 850;
}

.mission-card-list {
  display: grid;
  gap: 14px;
}

.mission-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 20px;
  align-items: center;
  padding: 20px;
}

.mission-card h2 {
  margin: 5px 0 8px;
  font-size: 1.16rem;
}

.mission-card-actions {
  display: grid;
  justify-items: end;
  gap: 12px;
  color: var(--muted);
  font-weight: 850;
}

.mission-shell {
  display: grid;
  grid-template-columns: 292px minmax(0, 1fr);
  width: min(1380px, calc(100% - 48px));
  min-height: calc(100vh - 112px);
  margin: 24px auto 40px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.lesson-rail {
  padding: 28px 22px;
  border-right: 1px solid var(--line);
  background: var(--surface-soft);
}

.mission-content {
  min-width: 0;
  padding: 32px;
}

.stepper {
  display: grid;
  gap: 8px;
  margin-bottom: 28px;
}

.stepper a {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 8px 12px;
  align-items: center;
  min-height: 70px;
  padding: 12px;
  border: 1px solid transparent;
  border-radius: 8px;
}

.stepper a.active {
  border-color: #d9ccff;
  background: var(--purple-soft);
}

.stepper a.complete {
  border-color: #c5ecd9;
}

.stepper span {
  display: grid;
  grid-row: 1 / span 2;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #e9edf5;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
}

.stepper a.active span {
  background: var(--purple);
  color: #fff;
}

.stepper a.complete span {
  background: var(--green);
  color: #fff;
}

.stepper strong,
.stepper small {
  min-width: 0;
}

.stepper small {
  font-size: 0.78rem;
}

.full {
  width: 100%;
  justify-content: center;
}

.mission-main,
.lesson-flow,
.concept-workspace,
.quiz-workspace,
.code-workspace,
.visual-workspace,
.editor-workspace,
.review-page {
  display: grid;
  gap: 22px;
}

.concept-head,
.concept-title-row,
.related-topics-strip {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
}

.concept-head h1 {
  margin: 5px 0 8px;
  font-size: clamp(1.7rem, 3vw, 2.4rem);
}

.concept-head p {
  color: var(--muted);
  line-height: 1.5;
}

.concept-path {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
  gap: 8px;
}

.concept-path a {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  min-height: 52px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.concept-path a.active {
  border-color: var(--purple);
  background: var(--purple-soft);
}

.concept-path span {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(109, 61, 245, 0.1);
  color: var(--purple-dark);
  font-size: 0.8rem;
  font-weight: 1000;
}

.concept-path a.active span {
  background: var(--purple);
  color: #fff;
}

.concept-study-card,
.related-topics-strip {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.concept-study-card {
  display: grid;
  gap: 20px;
  padding: 22px;
}

.concept-title-row {
  align-items: flex-start;
}

.concept-title-row > div:nth-child(2) {
  flex: 1;
}

.concept-title-row h2 {
  margin-bottom: 5px;
  font-size: 1.45rem;
}

.concept-title-row p {
  color: var(--muted);
}

.concept-study-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(280px, 1.25fr);
  gap: 18px;
}

.concept-study-grid section {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.concept-study-grid p,
.concept-assist-card p {
  color: var(--muted);
  line-height: 1.5;
}

.concept-study-grid ul,
.concept-assist-card ul {
  margin: 8px 0 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.5;
}

.example-panel {
  padding: 0 !important;
  overflow: hidden;
}

.example-panel pre {
  padding: 16px;
  overflow: auto;
  color: #1f3153;
  background: #fbfcff;
  white-space: pre-wrap;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

.explanation-strip {
  display: grid;
  gap: 4px;
  padding: 14px 16px;
  border-radius: 8px;
  background: var(--purple-soft);
  color: var(--purple-dark);
}

.explanation-strip p {
  color: #423073;
  line-height: 1.45;
}

.concept-assist-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.4fr);
  gap: 16px;
}

.concept-assist-card {
  display: grid;
  align-content: start;
  gap: 10px;
  padding: 16px;
  box-shadow: none;
}

.panel-title-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.panel-title-row h3 {
  margin-top: 4px;
  font-size: 1rem;
}

.note-box {
  width: 100%;
  min-height: 110px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: var(--surface-soft);
  color: var(--ink);
}

.note-box.compact {
  min-height: 92px;
}

.concept-assist-card small,
.form-note {
  color: var(--muted);
  font-size: 0.82rem;
}

.related-topics-strip {
  padding: 14px 16px;
  box-shadow: none;
}

.related-topics-strip span {
  color: var(--muted);
  font-weight: 900;
}

.related-topics-strip a,
.related-topics-strip strong {
  min-width: 0;
}

.related-topics-strip a.disabled {
  pointer-events: none;
  color: var(--muted);
  opacity: 0.5;
}

.concept-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

.concept-card {
  display: grid;
  gap: 12px;
  align-content: start;
  min-height: 210px;
  padding: 20px;
}

.concept-card h2 {
  font-size: 1.12rem;
}

.concept-card p {
  color: var(--muted);
  line-height: 1.5;
}

.text-link {
  width: max-content;
  border: 0;
  background: transparent;
  padding: 0;
}

.quiz-workspace,
.code-workspace,
.visual-workspace {
  min-width: 0;
}

.mission-content:has(.quiz-workspace),
.mission-content:has(.code-workspace) {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 22px;
}

.task-toolbar h1 {
  margin: 5px 0 8px;
  font-size: clamp(1.55rem, 3vw, 2.25rem);
  line-height: 1.08;
}

.task-toolbar p {
  max-width: 780px;
  color: var(--muted);
  line-height: 1.5;
}

.progress-line {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: #e7eaf2;
}

.progress-line span {
  display: block;
  height: 100%;
  background: var(--purple);
}

.question-card {
  display: grid;
  gap: 18px;
  padding: 28px;
}

.task-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.question-card h2 {
  font-size: 1.22rem;
}

.prompt {
  font-size: 1.02rem;
  line-height: 1.55;
}

.option-list {
  display: grid;
  gap: 10px;
}

.option-button {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
  min-height: 58px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  text-align: left;
}

.option-button span {
  color: var(--muted);
  font-weight: 900;
}

.option-button.selected {
  border-color: var(--purple);
  background: var(--purple-soft);
}

.option-button.correct {
  border-color: var(--green);
  background: var(--green-soft);
}

.support-column {
  display: grid;
  align-content: start;
  gap: 14px;
  padding: 18px;
  box-shadow: none;
}

.support-column.compact {
  position: sticky;
  top: 96px;
}

.mini-concept-card {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.mini-concept-card p {
  font-size: 0.88rem;
  line-height: 1.45;
}

.idea-card {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  padding: 18px;
  box-shadow: none;
}

.idea-card p {
  color: #303950;
  line-height: 1.5;
}

.editor-card,
.output-card {
  overflow: hidden;
  box-shadow: none;
}

.editor-head {
  min-height: 48px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
}

.editor-head div {
  display: inline-flex;
  gap: 8px;
}

#codeEditor {
  display: block;
  width: 100%;
  min-height: 330px;
  resize: vertical;
  border: 0;
  padding: 20px;
  background: var(--code);
  color: #eef4ff;
  line-height: 1.55;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.95rem;
}

.output-card pre,
.code-trace-card pre,
.output-preview pre {
  overflow: auto;
  white-space: pre-wrap;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

.output-card pre {
  min-height: 110px;
  padding: 18px;
  background: var(--code);
  color: #eef4ff;
  line-height: 1.55;
}

.runtime-status {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
}

.runtime-status.ready {
  color: var(--green);
}

.runtime-status.fallback {
  color: var(--orange);
}

.syntax-box {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--purple-soft);
  color: var(--purple-dark);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.86rem;
}

.editor-page {
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr);
  gap: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.editor-mount-page {
  display: grid;
  min-height: calc(100vh - 156px);
  place-items: center;
}

.mount-card {
  position: relative;
  display: grid;
  justify-items: start;
  gap: 16px;
  width: min(760px, 100%);
  padding: 30px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.mount-card h1 {
  max-width: 620px;
  color: var(--purple-dark);
  font-size: clamp(2rem, 4vw, 3.1rem);
  line-height: 1.02;
}

.mount-card p {
  max-width: 650px;
  color: var(--muted);
  line-height: 1.55;
}

.mount-card small {
  color: var(--muted);
}

.mount-card .primary-button {
  gap: 8px;
}

.mount-card .primary-button:disabled {
  cursor: not-allowed;
  border-color: #cfd6e6;
  background: #eef1f7;
  color: #7a8499;
  opacity: 1;
  box-shadow: none;
}

.mount-warning,
.mount-ready {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 6px;
  width: 100%;
  padding: 14px 16px;
  border-radius: 8px;
  line-height: 1.45;
}

.mount-warning {
  border: 1px solid rgba(240, 90, 90, 0.28);
  background: #fff1f1;
  color: #7b2430;
}

.mount-ready {
  border: 1px solid rgba(48, 184, 111, 0.28);
  background: #edfff2;
  color: #17643c;
}

.mount-warning strong,
.mount-ready strong {
  font-size: 1rem;
}

.mount-warning span,
.mount-ready span {
  color: inherit;
}

.mount-card svg,
.explorer-icon-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.editor-file-rail {
  min-height: calc(100vh - 124px);
  padding: 24px 18px;
  border-right: 1px solid var(--line);
  border-radius: 0;
  background: var(--surface-soft);
  box-shadow: none;
}

.explorer-toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
}

.explorer-icon-button {
  color: var(--ink);
}

.browser-notice {
  margin-bottom: 18px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.4;
}

.editor-file-list {
  display: grid;
  gap: 2px;
}

.file-row {
  display: grid;
  gap: 4px;
  min-height: 58px;
  padding: 10px 12px 10px calc(12px + (var(--depth, 0) * 16px));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  text-align: left;
}

.file-row.active {
  border-color: var(--purple);
  background: var(--purple-soft);
}

.file-row span {
  overflow: hidden;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-row small {
  color: var(--muted);
}

.explorer-folder {
  display: grid;
  gap: 2px;
}

.folder-row {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr);
  gap: 6px;
  align-items: center;
  min-height: 34px;
  padding: 6px 8px 6px calc(8px + (var(--depth, 0) * 16px));
  color: var(--muted);
  font-size: 0.88rem;
}

.folder-row strong {
  overflow: hidden;
  color: var(--ink);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.folder-caret {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
}

.folder-children {
  display: grid;
  gap: 2px;
}

.editor-toolbar {
  align-items: flex-start;
}

.editor-toolbar-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.editor-empty-workspace {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 10px;
  min-height: 520px;
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  text-align: center;
}

.editor-empty-workspace h2 {
  font-size: 1.5rem;
}

.editor-empty-workspace p:last-child {
  max-width: 440px;
  color: var(--muted);
  line-height: 1.55;
}

.editor-workspace {
  min-width: 0;
  padding: 24px;
}

.python-editor-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 18px;
  min-width: 0;
}

.python-editor-card,
.editor-run-card,
.debug-card {
  overflow: hidden;
  box-shadow: none;
}

.monaco-host {
  min-height: 560px;
  background: var(--code);
}

.python-editor-fallback {
  display: block;
  width: 100%;
  min-height: 560px;
  resize: vertical;
  border: 0;
  padding: 20px;
  background: var(--code);
  color: #eef4ff;
  line-height: 1.55;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.95rem;
}

.editor-run-column {
  display: grid;
  align-content: start;
  gap: 18px;
  min-width: 0;
}

.editor-run-card pre {
  min-height: 180px;
  max-height: 300px;
  overflow: auto;
  padding: 18px;
  background: var(--code);
  color: #eef4ff;
  line-height: 1.55;
  white-space: pre-wrap;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

.debug-card .editor-head span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
}

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

.debug-frame-list {
  display: grid;
  max-height: 520px;
  overflow: auto;
}

.debug-frame {
  display: grid;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.debug-frame > div:first-child {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.debug-frame strong {
  font-size: 0.92rem;
}

.debug-frame span,
.debug-frame p {
  color: var(--muted);
  font-size: 0.84rem;
}

.debug-frame dl {
  display: grid;
  gap: 6px;
  margin: 0;
}

.debug-frame dl div {
  display: grid;
  grid-template-columns: minmax(70px, 0.4fr) minmax(0, 1fr);
  gap: 8px;
  padding: 8px;
  border-radius: 8px;
  background: var(--surface-soft);
}

.debug-frame dt,
.debug-frame dd {
  margin: 0;
  min-width: 0;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.82rem;
}

.debug-frame dt {
  color: var(--muted);
}

.debug-frame dd {
  overflow-wrap: anywhere;
}

.visual-grid {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr) 280px;
  gap: 18px;
}

.timeline-card,
.code-trace-card,
.state-card {
  padding: 18px;
  box-shadow: none;
}

.timeline-card {
  display: grid;
  align-content: start;
  gap: 10px;
}

.timeline-card button {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  text-align: left;
}

.timeline-card button.active {
  border-color: var(--purple);
  background: var(--purple-soft);
}

.timeline-card span {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #e8ebf3;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 900;
}

.code-trace-card pre {
  margin-top: 14px;
  min-height: 380px;
  padding: 18px;
  border-radius: 8px;
  background: var(--code);
  color: #eef4ff;
  line-height: 1.55;
}

.state-card {
  display: grid;
  align-content: start;
  gap: 14px;
}

.state-card h2 {
  font-size: 1.1rem;
}

.state-card p {
  color: var(--muted);
  line-height: 1.5;
}

.state-table {
  display: grid;
  gap: 8px;
}

.state-table div {
  display: grid;
  gap: 4px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.state-table span {
  color: var(--muted);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.86rem;
}

.output-preview {
  display: grid;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.feedback {
  display: grid;
  gap: 6px;
  padding: 16px;
  border: 1px solid;
  border-radius: 8px;
}

.feedback.correct {
  border-color: #bde8d3;
  background: var(--green-soft);
  color: #0d5b42;
}

.feedback.hint,
.feedback.running {
  border-color: #d9ccff;
  background: var(--purple-soft);
  color: var(--purple-dark);
}

.feedback.wrong {
  border-color: #efc0bc;
  background: var(--danger-soft);
  color: var(--danger);
}

.feedback p {
  line-height: 1.5;
}

.bottom-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.primary-button,
.quiet-button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 44px;
  border-radius: 8px;
  padding: 10px 16px;
  font-weight: 900;
}

.primary-button {
  border: 1px solid var(--purple-dark);
  background: var(--purple);
  color: #fff;
  box-shadow: 0 12px 22px rgba(91, 53, 242, 0.22);
}

.quiet-button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
}

.quiet-button.small {
  min-height: 34px;
  padding: 6px 10px;
  font-size: 0.8rem;
}

.review-grid,
.profile-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.summary-card {
  display: grid;
  gap: 4px;
  padding: 22px;
  box-shadow: none;
}

.summary-card strong {
  font-size: 2rem;
}

.summary-card.success {
  background: var(--green-soft);
}

.summary-card.warning {
  background: var(--orange-soft);
}

.summary-card.purple {
  background: var(--purple-soft);
}

.tab-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.tab-row button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  padding: 8px 12px;
  font-weight: 900;
}

.tab-row button.active {
  border-color: var(--purple);
  background: var(--purple-soft);
  color: var(--purple-dark);
}

.tab-row span {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  margin-left: 4px;
  border-radius: 999px;
  background: #eef1f7;
  font-size: 0.76rem;
}

.help-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.help-list {
  display: grid;
  gap: 14px;
}

.help-card {
  display: grid;
  gap: 12px;
  padding: 18px;
}

.help-card.wide {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.help-card h2 {
  margin: 5px 0 7px;
  font-size: 1.12rem;
}

.help-card blockquote {
  margin-top: 10px;
  padding: 12px;
  border-left: 3px solid var(--purple);
  background: var(--purple-soft);
  color: #33255c;
  line-height: 1.45;
}

.help-actions {
  display: flex;
  gap: 8px;
}

.print-notes-button {
  white-space: nowrap;
}

.note-card blockquote {
  white-space: pre-wrap;
}

.empty-state {
  padding: 28px;
  color: var(--muted);
  box-shadow: none;
}

.profile-hero {
  display: flex;
  gap: 18px;
  align-items: center;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.profile-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--purple-soft);
  color: var(--purple-dark);
  font-size: 1.4rem;
}

.profile-hero h1 {
  margin: 4px 0;
  font-size: 2rem;
}

.profile-grid {
  grid-template-columns: minmax(280px, 380px) minmax(0, 1fr);
}

.profile-form,
.profile-card,
.chapter-progress-list {
  display: grid;
  gap: 14px;
  padding: 20px;
}

.profile-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 850;
}

.profile-form input,
.annotation-modal textarea,
.annotation-modal select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
}

.profile-form input {
  min-height: 42px;
  padding: 9px 10px;
}

.profile-form .check-row {
  color: var(--purple-dark);
}

.profile-form .check-row input {
  width: 18px;
  min-height: 0;
  padding: 0;
}

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

.stat-list div {
  display: grid;
  gap: 4px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.stat-list strong {
  font-size: 1.5rem;
}

.chapter-progress-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.chapter-notes-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(330px, 0.92fr);
  gap: 18px;
  align-items: start;
}

.markdown-reader,
.chapter-note-editor {
  overflow: hidden;
  border: 1px solid rgba(109, 61, 245, 0.16);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.markdown-body,
.chapter-note-editor {
  min-width: 0;
}

.markdown-body {
  max-height: calc(100vh - 300px);
  min-height: 520px;
  overflow: auto;
  padding: 22px;
  line-height: 1.65;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-preview h1,
.markdown-preview h2,
.markdown-preview h3 {
  margin: 18px 0 8px;
  color: var(--purple-dark);
  line-height: 1.16;
}

.markdown-body h1:first-child,
.markdown-body h2:first-child,
.markdown-body h3:first-child,
.markdown-preview h1:first-child,
.markdown-preview h2:first-child,
.markdown-preview h3:first-child {
  margin-top: 0;
}

.markdown-body p,
.markdown-body li,
.markdown-preview p,
.markdown-preview li {
  color: #343b66;
}

.markdown-body ul,
.markdown-body ol,
.markdown-preview ul,
.markdown-preview ol {
  margin: 10px 0 14px;
  padding-left: 22px;
}

.markdown-body code,
.markdown-preview code {
  padding: 2px 5px;
  border-radius: 6px;
  background: var(--purple-soft);
  color: var(--purple-dark);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

.markdown-body pre,
.markdown-preview pre {
  overflow: auto;
  margin: 14px 0;
  padding: 14px;
  border-radius: 8px;
  background: var(--code);
  color: #eef4ff;
}

.markdown-body pre code,
.markdown-preview pre code {
  padding: 0;
  background: transparent;
  color: inherit;
}

.chapter-note-editor {
  display: grid;
  gap: 0;
}

.markdown-note-box {
  min-height: 260px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: #fffdf6;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  line-height: 1.55;
}

.markdown-preview {
  display: grid;
  gap: 10px;
  max-height: 280px;
  overflow: auto;
  padding: 16px;
  background: #fbfcff;
}

.muted-copy {
  color: var(--muted);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(18, 25, 54, 0.38);
}

.annotation-modal {
  display: grid;
  gap: 16px;
  width: min(560px, 100%);
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.annotation-modal h2 {
  margin-top: 4px;
}

.annotation-modal label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-weight: 850;
}

.annotation-modal textarea {
  min-height: 130px;
  padding: 12px;
  resize: vertical;
}

.annotation-modal select {
  min-height: 44px;
  padding: 10px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-weight: 900;
}

/* Playful LearnPy redesign */
:root {
  --bg: #f3ecff;
  --surface: #ffffff;
  --surface-soft: #fbf8ff;
  --ink: #171b3a;
  --muted: #64708a;
  --line: #d8ccff;
  --line-strong: #b9a4ff;
  --purple: #6d3df5;
  --purple-dark: #2d1674;
  --purple-soft: #efe7ff;
  --green: #30b86f;
  --green-soft: #c8f7d4;
  --orange: #f19a3e;
  --orange-soft: #ffd8a8;
  --blue: #2f96dd;
  --blue-soft: #bee8ff;
  --yellow: #fff1a8;
  --danger: #f05a5a;
  --danger-soft: #ffe5e5;
  --code: #11172d;
  --shadow: 0 18px 34px rgba(45, 22, 116, 0.14);
}

html,
body {
  background:
    radial-gradient(circle at 12% 12%, rgba(255, 241, 168, 0.75), transparent 18%),
    radial-gradient(circle at 78% 8%, rgba(190, 232, 255, 0.85), transparent 20%),
    linear-gradient(135deg, #f3ecff 0%, #eef7ff 50%, #fff7d8 100%);
  color: var(--ink);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(circle, rgba(109, 61, 245, 0.16) 0 2px, transparent 3px),
    radial-gradient(circle, rgba(48, 184, 111, 0.18) 0 2px, transparent 3px);
  background-position: 22px 24px, 92px 120px;
  background-size: 180px 180px, 220px 220px;
}

.app-shell {
  position: relative;
  min-height: 100vh;
  padding: 18px 0 34px;
}

.app-shell::before,
.app-shell::after {
  content: "✦";
  position: fixed;
  z-index: 0;
  color: rgba(109, 61, 245, 0.28);
  font-size: 2rem;
  pointer-events: none;
}

.app-shell::before {
  top: 116px;
  left: 4vw;
}

.app-shell::after {
  right: 6vw;
  bottom: 78px;
  color: rgba(241, 154, 62, 0.35);
}

.top-header,
.learning-workspace,
.page-shell {
  position: relative;
  z-index: 1;
}

.top-header {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) auto minmax(330px, auto);
  gap: 18px;
  align-items: center;
  width: min(1440px, calc(100% - 40px));
  margin: 0 auto 18px;
  padding: 16px 20px;
  border: 1px solid rgba(109, 61, 245, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.course-brand {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
}

.course-brand strong {
  display: block;
  color: var(--purple-dark);
  font-size: clamp(1.2rem, 2.2vw, 2rem);
  line-height: 1.04;
}

.course-brand small {
  display: block;
  margin-top: 4px;
  color: #3f3f86;
  font-weight: 750;
}

.python-logo {
  width: 58px;
  height: 58px;
  border: 0;
  background: linear-gradient(135deg, #4fb8ff, #6d3df5 55%, #ffd66b);
  box-shadow: 0 12px 24px rgba(109, 61, 245, 0.24);
}

.global-nav {
  border-color: rgba(109, 61, 245, 0.2);
  background: rgba(243, 236, 255, 0.9);
}

.global-nav a {
  border-radius: 8px;
}

.global-nav a.active {
  background: var(--surface);
  color: var(--purple-dark);
}

.header-progress {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.header-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid rgba(109, 61, 245, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 8px 18px rgba(45, 22, 116, 0.08);
  color: var(--purple-dark);
  font-weight: 900;
}

.header-badge small {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.progress-badge strong,
.mission-badge strong {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: conic-gradient(var(--purple) 0 var(--progress, 0%), #e8ddff var(--progress, 0%) 100%);
  color: var(--purple-dark);
  font-size: 0.9rem;
}

.student-avatar {
  width: 54px;
  height: 54px;
  border: 4px solid #fff;
  background: #eef1f7;
  color: #475069;
  box-shadow: var(--shadow);
}

.boring-avatar {
  display: grid;
  place-items: center;
  border: 1px solid #cfd6e6;
  background: #eef1f7;
  color: #475069;
  font-weight: 1000;
  letter-spacing: 0;
}

.boring-avatar.large {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  font-size: 1.9rem;
}

.profile-avatar.boring-avatar {
  background: #eef1f7;
  color: #475069;
}

.learning-workspace {
  display: grid;
  grid-template-columns: 292px minmax(0, 1fr);
  gap: 18px;
  width: min(1440px, calc(100% - 40px));
  margin: 0 auto 34px;
}

.learning-sidebar {
  min-width: 0;
}

.sidebar-card {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 16px;
  height: calc(100vh - 136px);
  min-height: 610px;
  padding: 18px;
  overflow: hidden;
  border-radius: 8px;
  background:
    radial-gradient(circle at 18% 16%, rgba(255, 241, 168, 0.2), transparent 24%),
    linear-gradient(180deg, #4d21c9 0%, #27106e 100%);
  box-shadow: 0 22px 36px rgba(45, 22, 116, 0.24);
  color: #fff;
}

.lesson-art {
  position: relative;
  display: grid;
  gap: 8px;
  min-height: 118px;
  padding: 16px;
  overflow: hidden;
  border-radius: 8px;
  background:
    radial-gradient(circle at 86% 20%, rgba(255, 241, 168, 0.95) 0 9px, transparent 10px),
    radial-gradient(circle at 82% 84%, rgba(48, 184, 111, 0.28) 0 32px, transparent 33px),
    linear-gradient(135deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.04));
}

.lesson-kicker,
.lesson-art h2,
.lesson-art-mark {
  position: relative;
  z-index: 2;
}

.lesson-kicker {
  color: rgba(255, 255, 255, 0.78);
  font-size: 0.82rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.lesson-art h2 {
  max-width: 188px;
  font-size: 1.22rem;
  line-height: 1.14;
}

.lesson-art-mark {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  margin-top: 6px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 8px;
  background: linear-gradient(135deg, #fff, #fff1a8);
  color: var(--purple-dark);
  font-weight: 1000;
  box-shadow: 0 12px 20px rgba(0, 0, 0, 0.16);
}

.mini-mascot {
  position: absolute;
  right: 14px;
  bottom: 14px;
  display: grid;
  place-items: center;
  width: 70px;
  height: 62px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--green-soft), var(--blue-soft));
  color: var(--purple-dark);
  font-weight: 1000;
  box-shadow: 0 12px 22px rgba(0, 0, 0, 0.18);
}

.mini-mascot-image {
  position: absolute;
  right: 10px;
  bottom: 10px;
  width: 92px;
  height: 78px;
  object-fit: cover;
  object-position: 50% 42%;
  border: 3px solid rgba(255, 255, 255, 0.9);
  border-radius: 8px;
  box-shadow: 0 12px 18px rgba(0, 0, 0, 0.16);
}

.journey-steps {
  display: grid;
  gap: 8px;
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
}

.progress-step {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-height: 62px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.progress-step.active {
  border-color: rgba(255, 255, 255, 0.75);
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(244, 238, 255, 0.92));
  color: var(--purple-dark);
  box-shadow: 0 12px 22px rgba(255, 255, 255, 0.18);
}

.progress-step.complete .step-icon {
  background: var(--green);
}

.progress-step.next .step-icon {
  background: var(--orange);
}

.progress-step.locked {
  opacity: 0.58;
}

.step-icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--purple);
  color: #fff;
  font-size: 0.82rem;
  font-weight: 1000;
}

.progress-step strong,
.progress-step small {
  display: block;
}

.progress-step small {
  margin-top: 2px;
  color: inherit;
  opacity: 0.78;
}

.learning-main {
  min-width: 0;
  padding: 24px;
  border: 1px solid rgba(109, 61, 245, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.62);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.learning-main:has(.quiz-workspace),
.learning-main:has(.code-workspace) {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 310px;
  gap: 18px;
  align-items: start;
}

.learning-workspace.mode-focused {
  height: calc(100vh - 136px);
  min-height: 610px;
}

.mode-focused .learning-sidebar,
.mode-focused .learning-main {
  min-height: 0;
  height: 100%;
}

.mode-focused .learning-main {
  overflow: hidden;
}

.mode-focused .quiz-workspace,
.mode-focused .code-workspace {
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

.mode-focused .quiz-workspace {
  grid-template-rows: auto auto minmax(0, 1fr) auto;
}

.mode-focused .question-card,
.mode-focused .code-editor-panel {
  min-height: 0;
  overflow-y: auto;
}

.mode-focused .bottom-action-bar {
  position: static;
  align-self: end;
}

.mode-focused .coach-panel {
  max-height: 100%;
  overflow-y: auto;
}

.screen-title-row,
.concept-card-header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
}

.screen-title-row h1,
.welcome-hero h1 {
  margin: 6px 0 8px;
  color: var(--purple-dark);
  font-size: clamp(2rem, 4vw, 3.1rem);
  line-height: 1.03;
}

.screen-title-row p,
.welcome-hero p {
  color: #3f4670;
  line-height: 1.5;
}

.welcome-screen {
  display: grid;
  gap: 18px;
}

.onboarding-page {
  display: grid;
  min-height: 100vh;
  margin: 0 auto;
  place-items: center;
}

.onboarding-card {
  display: grid;
  grid-template-columns: 1fr;
  width: min(760px, 100%);
  padding: 28px;
  border: 1px solid rgba(109, 61, 245, 0.16);
  border-radius: 8px;
  background:
    radial-gradient(circle at 88% 12%, rgba(255, 241, 168, 0.75), transparent 18%),
    linear-gradient(135deg, rgba(255, 255, 255, 0.94), rgba(243, 236, 255, 0.9));
  box-shadow: var(--shadow);
}

.onboarding-copy h1 {
  margin: 8px 0 12px;
  color: var(--purple-dark);
  font-size: clamp(2.2rem, 5vw, 4rem);
  line-height: 1.02;
}

.onboarding-copy p {
  max-width: 620px;
  color: #3f4670;
  line-height: 1.55;
}

.onboarding-form {
  display: grid;
  gap: 14px;
  max-width: 520px;
  margin-top: 24px;
}

.onboarding-form label {
  display: grid;
  gap: 8px;
  color: var(--purple-dark);
  font-weight: 900;
}

.onboarding-form input {
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid rgba(109, 61, 245, 0.2);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}

.check-row {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 12px;
  border: 1px solid rgba(109, 61, 245, 0.16);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.74);
}

.check-row input {
  width: 18px;
  height: 18px;
  min-height: 0;
  margin-top: 3px;
}

.check-row strong,
.check-row small {
  display: block;
}

.check-row small {
  margin-top: 2px;
  color: var(--muted);
  font-weight: 700;
  line-height: 1.35;
}

.onboarding-preview {
  display: grid;
  align-content: start;
  justify-items: center;
  gap: 10px;
  padding: 22px;
  border: 1px solid rgba(109, 61, 245, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
}

.onboarding-preview h2 {
  margin-top: 6px;
  color: var(--purple-dark);
  font-size: 1.45rem;
}

.onboarding-preview p {
  color: var(--muted);
  font-weight: 800;
}

.onboarding-art {
  width: min(260px, 100%);
  aspect-ratio: 1;
  margin-top: 14px;
  object-fit: cover;
  border-radius: 8px;
  box-shadow: 0 16px 28px rgba(45, 22, 116, 0.16);
}

.welcome-hero {
  display: block;
  max-width: 980px;
}

.welcome-hero h1 {
  max-width: 820px;
  font-size: clamp(2.2rem, 4.6vw, 4rem);
}

.welcome-hero p {
  max-width: 920px;
}

.mascot-badge {
  display: grid;
  place-items: center;
  justify-self: center;
  width: 160px;
  height: 140px;
  border: 1px solid rgba(109, 61, 245, 0.16);
  border-radius: 8px;
  background:
    radial-gradient(circle at 72% 24%, var(--yellow) 0 12px, transparent 13px),
    linear-gradient(135deg, var(--blue-soft), var(--green-soft));
  color: var(--purple-dark);
  box-shadow: var(--shadow);
}

.welcome-mascot {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 8px;
}

.mascot-badge span {
  font-size: 2.6rem;
  font-weight: 1000;
}

.mascot-badge small {
  margin-top: -18px;
  color: var(--muted);
  font-weight: 900;
}

.hero-continue,
.continue-card,
.mode-card,
.roadmap-summary article,
.concept-learning-card,
.learning-module,
.concept-support-card,
.question-card,
.instruction-card,
.coach-panel,
.editor-card,
.output-card {
  border: 1px solid rgba(109, 61, 245, 0.16);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
}

.hero-continue {
  background: linear-gradient(135deg, #ffffff 0%, #f5eeff 58%, #fff8d6 100%);
}

.mode-card {
  min-height: 168px;
  border-color: transparent;
}

.mode-card.green {
  background: linear-gradient(135deg, #f7fff9, var(--green-soft));
}

.mode-card.orange {
  background: linear-gradient(135deg, #fffaf0, var(--orange-soft));
}

.mode-card.purple {
  background: linear-gradient(135deg, #fbf8ff, var(--purple-soft));
}

.mode-card small {
  color: var(--purple-dark);
  font-weight: 900;
}

.mode-icon {
  border-radius: 8px;
  box-shadow: 0 10px 18px rgba(109, 61, 245, 0.2);
}

.concept-icon {
  background: linear-gradient(135deg, var(--purple), #a86cff);
}

.code-icon {
  background: linear-gradient(135deg, var(--blue), var(--purple));
}

.roadmap-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.roadmap-summary article {
  display: grid;
  gap: 4px;
  padding: 14px 16px;
}

.roadmap-summary strong {
  color: var(--purple-dark);
  font-size: 1.15rem;
}

.roadmap-summary span {
  color: var(--muted);
}

.concept-path {
  display: grid;
  grid-template-columns: repeat(5, minmax(118px, 1fr));
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 0;
}

.concept-path-card {
  position: relative;
  overflow: hidden;
  padding: 10px;
  border: 1px solid rgba(109, 61, 245, 0.16);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: var(--shadow);
}

.concept-path-art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.18;
  pointer-events: none;
}

.concept-path-card .concept-path {
  position: relative;
  z-index: 1;
}

.concept-node {
  position: relative;
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  min-height: 52px;
  padding: 8px 10px;
  border: 1px solid rgba(109, 61, 245, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
}

.concept-node:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 50%;
  right: -8px;
  width: 8px;
  height: 2px;
  background: rgba(109, 61, 245, 0.34);
  transform: translateY(-50%);
}

.concept-node.active {
  border-color: var(--purple);
  background: linear-gradient(135deg, #ffffff, var(--purple-soft));
  box-shadow: 0 10px 22px rgba(109, 61, 245, 0.2);
}

.concept-node-index {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(109, 61, 245, 0.1);
  color: var(--purple-dark);
  font-size: 0.8rem;
  font-weight: 1000;
}

.concept-node.active .concept-node-index {
  background: var(--purple);
  color: #fff;
}

.concept-node strong {
  display: block;
  color: var(--ink);
  font-size: 0.82rem;
  line-height: 1.12;
}

.concept-learning-card {
  display: grid;
  gap: 20px;
  padding: 22px;
  background:
    radial-gradient(circle at 92% 10%, rgba(255, 241, 168, 0.75), transparent 12%),
    rgba(255, 255, 255, 0.92);
}

.concept-card-header h2 {
  color: var(--purple-dark);
  font-size: clamp(1.7rem, 3vw, 2.4rem);
}

.concept-card-header p {
  margin-top: 4px;
  color: var(--muted);
}

.coach-button {
  white-space: nowrap;
}

.concept-module-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(320px, 1.35fr);
  gap: 14px;
}

.learning-module {
  min-width: 0;
  padding: 18px;
  box-shadow: none;
}

.why-module {
  background: linear-gradient(135deg, #fff, #fff4fb);
}

.takeaways-module {
  background: linear-gradient(135deg, #fff, #f4f0ff);
}

.code-module {
  padding: 0;
  overflow: hidden;
  background: var(--code);
}

.module-title {
  margin-bottom: 12px;
  color: var(--purple-dark);
  font-weight: 1000;
  letter-spacing: 0;
}

.learning-module p,
.learning-module li,
.concept-support-card li,
.coach-panel p,
.coach-panel li {
  color: #343b66;
  line-height: 1.5;
}

.character-spot {
  display: grid;
  place-items: center;
  width: 70px;
  height: 58px;
  margin-top: 18px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--green-soft), var(--yellow));
  color: var(--purple-dark);
  font-weight: 1000;
}

.why-mascot-image {
  display: block;
  width: 96px;
  height: 86px;
  margin-top: 16px;
  object-fit: cover;
  object-position: 50% 38%;
  border-radius: 8px;
}

.python-code-block {
  display: grid;
  gap: 0;
  min-height: 210px;
  margin: 0;
  padding: 16px 0;
  overflow: auto;
  background: var(--code);
  color: #e9f1ff;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.9rem;
}

.code-line {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  gap: 10px;
  min-height: 26px;
  padding: 0 16px;
}

.line-number {
  color: #7d86a8;
  text-align: right;
}

.syntax-keyword {
  color: #d78bff;
  font-weight: 800;
}

.syntax-string {
  color: #88f2a8;
}

.syntax-comment {
  color: #7ed174;
}

.concept-example-output {
  display: grid;
  gap: 6px;
  padding: 12px 16px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: #0b1020;
}

.concept-example-output strong {
  color: #cbd6ff;
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.concept-example-output pre {
  min-height: 54px;
  color: #e9f1ff;
  white-space: pre-wrap;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.88rem;
  line-height: 1.5;
}

.explanation-strip {
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, var(--purple-soft), #fff2d0);
}

.explanation-strip strong,
.explanation-strip p {
  position: relative;
  z-index: 1;
}

.explanation-asset {
  position: absolute;
  right: -18px;
  bottom: -28px;
  width: 118px;
  height: 118px;
  object-fit: cover;
  opacity: 0.75;
  pointer-events: none;
}

.concept-support-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.concept-support-grid.minimal {
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
}

.concept-support-card {
  display: grid;
  align-content: start;
  gap: 10px;
  min-height: 210px;
  padding: 16px;
  box-shadow: none;
}

.mistakes-card {
  background: linear-gradient(135deg, #fff8f7, #ffe5e5);
}

.notes-card {
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, #fffdf2, var(--yellow));
}

.notes-card .note-box,
.notes-card small {
  position: relative;
  z-index: 1;
}

.notes-asset {
  position: absolute;
  right: -22px;
  bottom: -26px;
  width: 88px;
  height: 88px;
  object-fit: cover;
  opacity: 0.28;
  pointer-events: none;
}

.related-topics-strip {
  background: rgba(255, 255, 255, 0.84);
}

.quiz-workspace,
.code-workspace {
  display: grid;
  gap: 18px;
}

.question-card {
  padding: 24px;
  background:
    radial-gradient(circle at 90% 10%, rgba(255, 241, 168, 0.65), transparent 15%),
    rgba(255, 255, 255, 0.92);
}

.option-button {
  border-color: rgba(109, 61, 245, 0.16);
  background: #fff;
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease;
}

.option-button:hover {
  transform: translateY(-1px);
  border-color: var(--purple);
}

.option-button.selected {
  border-color: var(--purple);
  background: var(--purple-soft);
}

.option-button.correct {
  border-color: var(--green);
  background: var(--green-soft);
}

.option-button.incorrect {
  border-color: var(--danger);
  background: var(--danger-soft);
}

.confidence-card {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px dashed rgba(109, 61, 245, 0.28);
  border-radius: 8px;
  background: rgba(243, 236, 255, 0.52);
}

.confidence-card div {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.confidence-pill {
  min-height: 36px;
  padding: 8px 12px;
  border: 1px solid rgba(109, 61, 245, 0.18);
  border-radius: 999px;
  background: #fff;
  color: var(--purple-dark);
  font-weight: 900;
}

.coach-panel {
  display: grid;
  align-content: start;
  gap: 14px;
  padding: 18px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.95), #eef7ff);
}

.coach-panel h2 {
  color: var(--purple-dark);
  font-size: 1.12rem;
}

.coach-tips {
  margin: 0;
  padding-left: 18px;
}

.instruction-card {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  padding: 18px;
  background: linear-gradient(135deg, #ffffff, #eef7ff);
  box-shadow: none;
}

.instruction-card h2 {
  margin: 4px 0;
  color: var(--purple-dark);
}

.code-editor-panel #codeEditor {
  min-height: 370px;
}

.output-card pre {
  background: var(--code);
  color: #eef4ff;
}

.bottom-action-bar {
  position: static;
  z-index: 2;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px;
  border: 1px solid rgba(109, 61, 245, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 16px 28px rgba(45, 22, 116, 0.14);
  backdrop-filter: blur(14px);
}

.primary-button,
.quiet-button {
  border-radius: 8px;
}

.primary-button {
  border-color: var(--purple-dark);
  background: linear-gradient(135deg, var(--purple), #7d49ff);
  color: #fff;
}

.quiet-button {
  border-color: rgba(109, 61, 245, 0.18);
  background: rgba(255, 255, 255, 0.84);
}

@media (max-width: 1180px) {
  .top-header {
    grid-template-columns: 1fr;
    justify-items: start;
  }

  .header-progress {
    justify-content: flex-start;
  }

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

  .sidebar-card {
    grid-template-rows: none;
    height: auto;
    min-height: auto;
    overflow: visible;
  }

  .lesson-art {
    min-height: 120px;
  }

  .journey-steps {
    grid-template-columns: repeat(4, minmax(180px, 1fr));
    overflow-x: auto;
    overflow-y: visible;
    padding-bottom: 4px;
  }

  .learning-main:has(.quiz-workspace),
  .learning-main:has(.code-workspace) {
    grid-template-columns: 1fr;
  }

  .learning-workspace.mode-focused {
    height: auto;
    min-height: 0;
  }

  .mode-focused .learning-sidebar,
  .mode-focused .learning-main,
  .mode-focused .quiz-workspace,
  .mode-focused .code-workspace {
    height: auto;
    overflow: visible;
  }

  .mode-focused .question-card,
  .mode-focused .code-editor-panel,
  .mode-focused .coach-panel {
    max-height: none;
    overflow: visible;
  }

  .mode-focused .bottom-action-bar {
    position: sticky;
    bottom: 12px;
  }

  .concept-module-grid,
  .concept-support-grid {
    grid-template-columns: 1fr 1fr;
  }

  .concept-support-grid.minimal {
    grid-template-columns: 1fr 1fr;
  }

  .chapter-notes-layout {
    grid-template-columns: 1fr;
  }

  .markdown-body {
    max-height: none;
    min-height: 360px;
  }

  .onboarding-card {
    grid-template-columns: 1fr;
  }

  .topbar {
    grid-template-columns: 1fr;
    justify-items: start;
  }

  .topbar-stats {
    justify-content: flex-start;
  }

  .road-page,
  .mission-shell,
  .editor-page {
    grid-template-columns: 1fr;
  }

  .roadmap-rail,
  .lesson-rail,
  .editor-file-rail {
    min-height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .mission-content:has(.quiz-workspace),
  .mission-content:has(.code-workspace) {
    grid-template-columns: 1fr;
  }

  .support-column.compact {
    position: static;
  }

  .visual-grid {
    grid-template-columns: 1fr;
  }

  .python-editor-layout {
    grid-template-columns: 1fr;
  }

  .concept-study-grid,
  .concept-assist-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 820px) {
  .app-shell {
    padding-top: 12px;
  }

  .top-header,
  .learning-workspace {
    width: calc(100% - 24px);
  }

  .top-header {
    padding: 12px;
  }

  .course-brand {
    grid-template-columns: 48px minmax(0, 1fr);
  }

  .course-brand strong {
    font-size: 1.25rem;
  }

  .python-logo {
    width: 48px;
    height: 48px;
  }

  .header-progress,
  .global-nav {
    width: 100%;
  }

  .onboarding-page {
    min-height: auto;
  }

  .onboarding-card {
    padding: 18px;
  }

  .onboarding-preview {
    display: none;
  }

  .learning-main {
    padding: 16px;
  }

  .learning-sidebar {
    display: none;
  }

  .mode-focused .learning-main {
    padding-bottom: 120px;
    backdrop-filter: none;
  }

  .mode-focused .bottom-action-bar {
    position: fixed;
    right: 12px;
    bottom: 12px;
    left: 12px;
    width: auto;
  }

  .welcome-hero,
  .hero-continue,
  .roadmap-summary,
  .concept-module-grid,
  .concept-support-grid,
  .screen-title-row,
  .concept-card-header,
  .instruction-card {
    grid-template-columns: 1fr;
  }

  .screen-title-row,
  .concept-card-header,
  .welcome-hero {
    display: grid;
  }

  .journey-steps {
    grid-template-columns: 1fr;
  }

  .concept-path {
    grid-template-columns: repeat(5, minmax(132px, 1fr));
  }

  .bottom-action-bar {
    justify-content: stretch;
  }

  .bottom-action-bar > *,
  .bottom-action-bar .primary-button,
  .bottom-action-bar .quiet-button {
    flex: 1 1 auto;
  }

  .page-shell,
  .mission-shell {
    width: calc(100% - 24px);
    margin: 12px auto 28px;
  }

  .topbar {
    padding: 12px;
  }

  .global-nav,
  .topbar-stats {
    width: 100%;
  }

  .global-nav {
    display: grid;
    grid-template-columns: repeat(4, minmax(78px, 1fr));
    overflow-x: auto;
  }

  .global-nav a {
    min-width: 0;
  }

  .topbar-stats {
    justify-content: space-between;
  }

  .launchpad,
  .mission-content,
  .editor-workspace {
    padding: 22px;
  }

  .hero-row,
  .continue-card,
  .mission-card,
  .help-card.wide,
  .profile-grid,
    .review-grid,
    .stats-strip,
    .mode-grid,
    .concept-study-grid,
    .concept-assist-grid {
    grid-template-columns: 1fr;
  }

  .editor-toolbar-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .concept-head,
  .concept-title-row,
  .related-topics-strip,
  .panel-title-row {
    display: grid;
  }

  .python-orb {
    width: 100%;
    max-width: 260px;
  }

  .stats-strip div:not(:last-child) {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .task-toolbar,
  .split-heading {
    display: grid;
  }

  .bottom-actions {
    justify-content: stretch;
  }

  .bottom-actions > *,
  .primary-button,
  .quiet-button {
    flex: 1 1 auto;
  }
}

@media print {
  body {
    background: #fff;
  }

  .topbar,
  .tab-row,
  .print-notes-button,
  .help-actions {
    display: none !important;
  }

  .page-shell {
    width: 100%;
    margin: 0;
  }

  .simple-page {
    gap: 16px;
  }

  .page-heading {
    padding: 0 0 12px;
  }

  .page-heading h1 {
    font-size: 1.6rem;
  }

  .help-card {
    break-inside: avoid;
    box-shadow: none;
  }

  .help-card.wide {
    grid-template-columns: 1fr;
  }
}
