:root {
  --nav-bg: #3c5d70;
  --nav-bg-dark: #34536a;
  --page-bg: #eef2f5;
  --card-bg: #ffffff;
  --card-border: #dde3e8;
  --card-shadow: 0 1px 2px rgba(20, 40, 60, 0.04), 0 1px 4px rgba(20, 40, 60, 0.04);
  --text: #2a3744;
  --text-muted: #6b7a87;
  --code-inline-bg: #f4f1ea;
  --code-block-bg: #f7f4ec;
  --code-text: #2a3744;
  --code-keyword: #d14;
  --code-builtin: #1f8dd6;
  --code-string: #d14;
  --code-number: #d14;
  --code-var: #2a8b9c;
  --btn-border: #d4dadf;
  --btn-hover-bg: #f4f6f8;
  --primary: #3c5d70;
  --accent-yellow: #fff8d6;
  --success: #2e9d4f;
  --error: #d14;
  --pro-bg: #ffd866;
  --pro-text: #4a3500;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
  color: var(--text);
  background: var(--page-bg);
  font-size: 16px;
  line-height: 1.55;
}

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

/* ===================== NAV ===================== */

.nav {
  background: var(--nav-bg);
  color: white;
  padding: 14px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 20px;
  font-weight: 600;
}

.nav-brand-img {
  height: 40px;
  width: auto;
  display: block;
}

.nav-brand-text {
  color: white;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 28px;
  font-size: 15px;
}

.nav-links a:hover { opacity: 0.85; }

.nav-trophy {
  display: flex;
  align-items: center;
  gap: 4px;
  color: #ffd66b;
}

/* ============== INDEX (LESSONS LIST) PAGE ============== */

.index-header {
  background: var(--nav-bg);
  color: white;
  padding: 40px 32px 80px;
  position: relative;
}

.index-header h1 {
  margin: 0 0 16px;
  font-size: 36px;
  font-weight: 700;
}

.index-header-centered {
  text-align: center;
}

.page-title-image-wrap {
  margin: 0 0 12px;
  padding: 0;
  font-size: 0;
  line-height: 0;
}

.page-title-img {
  max-width: 448px;
  width: 100%;
  height: auto;
  display: inline-block;
}

.index-header .meta {
  margin: 4px 0;
  color: #d6e0e8;
  font-size: 15px;
}

.index-header .meta b { color: white; }

.index-header a {
  text-decoration: underline;
  cursor: pointer;
}

.index-curve {
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 80px;
  pointer-events: none;
  overflow: hidden;
}

.index-curve svg {
  width: 100%;
  height: 100%;
  display: block;
}

.index-body {
  max-width: 880px;
  margin: -60px auto 60px;
  padding: 0 24px;
  position: relative;
  z-index: 1;
}

.index-card {
  background: white;
  border: 1px solid var(--card-border);
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(20, 40, 60, 0.06);
  padding: 24px;
}

/* Wave 36: curriculum-level divider banner, used to mark the start of the
   Advanced — Intermediate Python track. Sits between regular sections. */
.section-divider {
  margin: 36px 0 16px;
  padding: 14px 18px;
  background: linear-gradient(135deg, #2c3e50, #34495e);
  color: #fff;
  border-radius: 6px;
  text-align: center;
  font-weight: 600;
  letter-spacing: 0.04em;
  font-size: 17px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}
.section-divider-label::before,
.section-divider-label::after {
  content: "━━";
  margin: 0 12px;
  opacity: 0.6;
}

.section {
  border: 1px solid var(--card-border);
  border-radius: 4px;
  margin-bottom: 8px;
  overflow: hidden;
}

.section-header {
  padding: 16px 20px;
  background: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
  font-size: 17px;
  color: var(--text);
}

.section-header:hover { background: #fafbfc; }

.section.expanded .section-header {
  background: #f6f7f9;
  border-bottom: 1px solid var(--card-border);
}

.section-chevron {
  transition: transform 0.2s ease;
  color: var(--text-muted);
  font-size: 14px;
}

.section.expanded .section-chevron { transform: rotate(180deg); }

/* F15: ribbon shown next to the section title when every playable item
   in the section is fully complete. */
.section-title {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.section-done {
  background: var(--success);
  color: white;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.4px;
  padding: 3px 10px;
  border-radius: 999px;
  text-transform: uppercase;
}

/* Wave 13: soft-green completion tint on a fully-complete section header.
   The strong reward (the "Done!" ribbon above) stays; this is the quiet
   ambient confirmation around it. Material Design green-50/100. */
.section.complete .section-header { background: #e8f5e9; }
.section.complete .section-header:hover { background: #dcedc8; }
.section.complete.expanded .section-header { background: #d4ecd5; }

/* F13: short confetti burst on a passed Submit. Container covers the
   viewport but ignores pointer events; pieces fall + spin + fade then
   the whole container is removed by JS. */
.confetti-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 9999;
  overflow: hidden;
}

.confetti-piece {
  position: absolute;
  top: -24px;
  width: 10px;
  height: 14px;
  opacity: 0;
  border-radius: 2px;
  animation: confetti-fall 1.4s ease-out forwards;
}

@keyframes confetti-fall {
  0%   { transform: translateY(0) rotate(0deg);    opacity: 1; }
  100% { transform: translateY(110vh) rotate(720deg); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .confetti-container { display: none; }
}

/* Wave 22 (G2): section-complete fireworks burst + banner. Layers on top
   of the confetti rain. Pointer-events none — pure visual overlay. */
.fireworks-container {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 9999;
}

.firework-burst {
  position: absolute;
  width: 0;
  height: 0;
}

.firework-piece {
  position: absolute;
  left: 0;
  top: 0;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  transform-origin: 0 0;
  opacity: 0;
  animation: pp-firework-radiate 1.2s ease-out forwards;
}

@keyframes pp-firework-radiate {
  0%   { opacity: 1; transform: rotate(var(--angle)) translate(0, 0) scale(1); }
  80%  { opacity: 1; }
  100% { opacity: 0; transform: rotate(var(--angle)) translate(90px, 0) scale(0.4); }
}

.section-complete-banner {
  position: fixed;
  top: 30%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: linear-gradient(135deg, #4caf50, #66bb6a);
  color: white;
  font-size: 26px;
  font-weight: 700;
  padding: 18px 36px;
  border-radius: 14px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
  z-index: 10000;
  pointer-events: none;
  white-space: nowrap;
  max-width: calc(100vw - 32px);
  overflow: hidden;
  text-overflow: ellipsis;
  animation: pp-banner-pop 4s ease-out forwards;
}

@keyframes pp-banner-pop {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.6); }
  15%  { opacity: 1; transform: translate(-50%, -50%) scale(1.05); }
  25%  { transform: translate(-50%, -50%) scale(1); }
  80%  { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(0.95); }
}

@media (prefers-reduced-motion: reduce) {
  .fireworks-container,
  .section-complete-banner { display: none; }
}

.section-body {
  display: none;
  padding: 16px 20px 20px;
  background: #f6f7f9;
}

.section.expanded .section-body { display: block; }

.section-desc {
  margin: 0 0 16px;
  color: var(--text);
  font-size: 15px;
}

.lesson-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: white;
  border: 1px solid var(--card-border);
  border-radius: 4px;
  margin-bottom: 8px;
  font-size: 15px;
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.lesson-link:hover {
  border-color: var(--nav-bg);
  box-shadow: 0 1px 3px rgba(20, 40, 60, 0.08);
}

.lesson-link.locked {
  cursor: not-allowed;
  opacity: 0.95;
}
.lesson-link.locked:hover {
  border-color: var(--card-border);
  box-shadow: none;
}

.lesson-link-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.lesson-link-icon {
  color: var(--text);
  display: inline-flex;
  width: 20px;
  justify-content: center;
}

/* Green tick at the right of a completed lesson row (replaces the old
   green-icon-on-completed treatment — that was too subtle). */
.lesson-link-tick {
  color: var(--success);
  font-weight: 700;
  font-size: 18px;
  line-height: 1;
}

/* Wave 13: soft-green completion tint on a completed item row. Pairs
   with the green tick above. Hover deepens slightly to signal the row
   is still clickable. */
.lesson-link.completed {
  background: #e8f5e9;
  border-color: #c8e6c9;
}
.lesson-link.completed:hover {
  background: #dcedc8;
  border-color: #81c784;
  box-shadow: 0 1px 3px rgba(76, 175, 80, 0.15);
}

.lesson-link-right {
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--text-muted);
}

.pro-badge {
  background: var(--pro-bg);
  color: var(--pro-text);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
  padding: 4px 8px;
  border-radius: 3px;
}

.soon-badge {
  background: #e8edf1;
  color: #6b7a87;
  font-size: 12px;
  font-style: italic;
  padding: 4px 8px;
  border-radius: 3px;
}

.row-chevron {
  color: var(--text-muted);
  font-size: 14px;
}

/* ============== CHALLENGES TABLE PAGE ============== */

.chall-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
}

.chall-table thead th {
  text-align: left;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 13px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding: 12px 16px;
  border-bottom: 1px solid var(--card-border);
}

.chall-table tbody td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--card-border);
  color: var(--text);
}

.chall-table tbody tr:last-child td {
  border-bottom: none;
}

.chall-table tbody tr:hover {
  background: #fafbfc;
}

.chall-table tbody tr.stub:hover {
  background: transparent;
}

.chall-table a {
  color: var(--nav-bg);
  text-decoration: none;
  font-weight: 500;
}

.chall-table a:hover { text-decoration: underline; }

.chall-stub-title {
  color: #9aa6b1;
  cursor: not-allowed;
}

.chall-coming {
  color: #9aa6b1;
  font-style: italic;
  font-size: 13px;
}

.chall-solved { color: var(--success); font-weight: 500; }

/* ============== LESSON / CHALLENGE PAGE ============== */

.lesson-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  padding: 24px;
  max-width: 1500px;
  margin: 0 auto;
}

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

/* F20: quiz items hide the right-column and use the full row. */
.lesson-layout.lesson-layout-single { grid-template-columns: 1fr; }

.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 6px;
  box-shadow: var(--card-shadow);
  overflow: hidden;
}

.lesson-content {
  padding: 32px 36px;
  min-height: 500px;
}

.lesson-content h2 {
  margin: 0 0 12px;
  font-size: 18px;
  font-weight: 700;
}

/* F16: header row holds the page label + Read-aloud controls side by side. */
.lesson-content-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.lesson-content-header h2 { margin: 0; }

.readaloud-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.voice-picker {
  font-family: inherit;
  font-size: 12px;
  padding: 4px 6px;
  border: 1px solid var(--btn-border);
  border-radius: 4px;
  background: white;
  color: var(--text-muted);
  max-width: 180px;
}

.btn-readaloud {
  font-size: 13px;
  padding: 5px 12px;
  color: var(--text-muted);
}
.btn-readaloud:hover:not(:disabled) {
  color: var(--text);
  background: var(--btn-hover-bg);
}
.btn-readaloud.speaking {
  background: var(--success);
  color: white;
  border-color: var(--success);
}
.btn-readaloud.speaking:hover:not(:disabled) {
  background: #267e40;
  border-color: #267e40;
  color: white;
}

.lesson-content hr {
  border: none;
  border-top: 1px solid var(--card-border);
  margin: 4px 0 28px;
}

.lesson-content h3 {
  font-size: 19px;
  font-weight: 700;
  margin: 0 0 18px;
}

.lesson-content p { margin: 0 0 18px; }

.lesson-content em { font-style: italic; }

.lesson-content code {
  background: var(--code-inline-bg);
  padding: 1px 6px;
  border-radius: 3px;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.9em;
  color: var(--code-text);
  border: 1px solid #eae5da;
}

.lesson-content code .kw { color: var(--code-keyword); }
.lesson-content code .bn { color: var(--code-builtin); }
.lesson-content code .st { color: var(--code-string); }
.lesson-content code .nm { color: var(--code-number); }
.lesson-content code .vn { color: var(--code-var); }

.code-block {
  background: var(--code-block-bg);
  border: 1px solid #eae5da;
  border-radius: 4px;
  padding: 12px 16px;
  margin: 0 0 18px;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 14px;
  white-space: pre;
  overflow-x: auto;
  color: var(--code-text);
  line-height: 1.55;
}

.code-block .kw { color: var(--code-keyword); }
.code-block .bn { color: var(--code-builtin); }
.code-block .st { color: var(--code-string); }
.code-block .nm { color: var(--code-number); }
.code-block .vn { color: var(--code-var); }
.code-block .cm { color: #8a96a0; font-style: italic; }

.right-column {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.panel-header {
  text-align: center;
  font-size: 12px;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  padding: 10px 0;
  border-bottom: 1px solid var(--card-border);
  background: #fafbfc;
}

.editor-host {
  background: white;
  position: relative;
}

.CodeMirror {
  height: auto !important;
  min-height: 320px;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 15px;
  background: white !important;
}

.CodeMirror-gutters {
  background: #fafbfc !important;
  border-right: 1px solid #eef0f2 !important;
}

.CodeMirror-linenumber { color: #b6bdc4 !important; padding: 0 8px 0 6px !important; }

.CodeMirror-activeline-background {
  background: var(--accent-yellow) !important;
}

/* String literals in editor - red */
.cm-s-default .cm-string { color: var(--code-string) !important; }
.cm-s-default .cm-number { color: var(--code-number) !important; }
.cm-s-default .cm-keyword { color: var(--code-keyword) !important; }
.cm-s-default .cm-builtin { color: var(--code-builtin) !important; }

.editor-toolbar {
  display: flex;
  justify-content: space-between;
  padding: 12px 16px;
  border-top: 1px solid var(--card-border);
  background: white;
}

.toolbar-group { display: flex; gap: 8px; }

.btn {
  background: white;
  border: 1px solid var(--btn-border);
  padding: 8px 14px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: inherit;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.btn:hover:not(:disabled) { background: var(--btn-hover-bg); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-icon { font-size: 14px; line-height: 1; display: inline-flex; }

/* F9: faint vertical lines every 4 character widths in the editor so kids
   can see where each indent level starts. Uses the editor's monospace font,
   so `ch` is exactly one character wide. CodeMirror's per-line element is
   `div.CodeMirror-line` containing a `<pre>` — paint on the div so the
   guides cover the full line area even when content is short. */
.CodeMirror pre.CodeMirror-line {
  background-image: repeating-linear-gradient(to right, transparent 0, transparent calc(4ch - 1px), rgba(60, 93, 112, 0.03) calc(4ch - 1px), rgba(60, 93, 112, 0.03) 4ch) !important;
}

.output-panel { min-height: 220px; }

/* Wave 43 — tkinter preview panel. Shown when a page has
   preview: "tkinter". Replaces the OUTPUT panel for those pages. */
.tk-preview-panel { min-height: 280px; display: flex; flex-direction: column; padding: 0; overflow: hidden; }
.tk-preview-stage { flex: 1; background: #d0d5da; padding: 22px; min-height: 200px; overflow: auto; }
.tk-console { background: #1a1f29; color: #e5e9f0; font-family: "SF Mono", Menlo, Consolas, monospace; font-size: 12px; padding: 8px 14px; min-height: 64px; max-height: 40%; overflow: auto; border-top: 1px solid #2a2f3a; }
.tk-console-empty { color: #6b7280; font-style: italic; }
.tk-console-line { padding: 1px 0; line-height: 1.4; }
.tk-console-line.event { color: #98c379; }
.tk-console-line.print { color: #e5e9f0; }
.tk-console-line.dim { color: #6b7280; }
.panel-header .panel-header-extra { float: right; font-weight: 400; font-size: 11px; letter-spacing: normal; text-transform: none; color: #6b7280; cursor: pointer; }

.tk-window { background: #ececec; border-radius: 6px; box-shadow: 0 8px 24px rgba(0,0,0,0.25); overflow: hidden; max-width: 100%; display: inline-block; min-width: 200px; }
.tk-titlebar { background: linear-gradient(to bottom, #e8e8e8, #c8c8c8); border-bottom: 1px solid #999; padding: 6px 10px; display: flex; align-items: center; gap: 6px; user-select: none; }
.tk-traffic { display: flex; gap: 6px; }
.tk-dot { width: 12px; height: 12px; border-radius: 50%; }
.tk-dot.red { background: #ff5f57; border: 1px solid #e0443e; }
.tk-dot.yellow { background: #febc2e; border: 1px solid #d99e1f; }
.tk-dot.green { background: #28c840; border: 1px solid #1da82f; }
.tk-title { flex: 1; text-align: center; font-size: 12px; color: #333; font-weight: 500; margin-right: 36px; }
.tk-content { padding: 8px; background: #ececec; min-height: 50px; }
.tk-content.pack-vertical { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.tk-content.pack-horizontal { display: flex; flex-direction: row; align-items: center; gap: 4px; }
.tk-content.layout-grid { display: grid; gap: 4px; }

.tk-widget { font-family: "Lucida Grande", Tahoma, sans-serif; font-size: 13px; color: #1a1a1a; }
.tk-label { padding: 2px 6px; white-space: pre; }
.tk-button { background: linear-gradient(to bottom, #fafafa, #d9d9d9); border: 1px solid #888; border-radius: 3px; padding: 3px 14px; cursor: pointer; min-width: 60px; text-align: center; box-shadow: inset 0 1px 0 rgba(255,255,255,0.5); }
.tk-button:hover { background: linear-gradient(to bottom, #ffffff, #e6e6e6); }
.tk-button:active { background: linear-gradient(to bottom, #c8c8c8, #a8a8a8); }
.tk-entry { background: white; border: 1px solid #888; padding: 2px 6px; min-width: 100px; min-height: 18px; box-shadow: inset 1px 1px 2px rgba(0,0,0,0.1); }
.tk-canvas { background: white; border: 1px solid #888; display: inline-block; }
.tk-scale { display: flex; align-items: center; gap: 6px; padding: 2px 6px; }
.tk-scale-track { position: relative; width: 120px; height: 4px; background: #ccc; border-radius: 2px; }
.tk-scale-thumb { position: absolute; top: -6px; width: 14px; height: 14px; background: linear-gradient(to bottom, #fafafa, #d9d9d9); border: 1px solid #888; border-radius: 50%; transform: translateX(-50%); }
.tk-scale-label { font-size: 11px; color: #555; min-width: 20px; }
.tk-empty-hint { color: #666; font-style: italic; font-size: 12px; padding: 16px; text-align: center; font-family: "Lucida Grande", Tahoma, sans-serif; }
.tk-console-line.test-pass { color: #98c379; }
.tk-console-line.test-pass::before { content: "✓ "; font-weight: bold; }
.tk-console-line.test-fail { color: #e06c75; }
.tk-console-line.test-fail::before { content: "✗ "; font-weight: bold; }

.output-body {
  padding: 16px 20px;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 14px;
  white-space: pre-wrap;
  min-height: 180px;
  max-height: 360px;
  overflow-y: auto;
  color: var(--text);
}

.output-body.empty { color: var(--text-muted); }
.output-body .err { color: var(--error); }

/* F1: in-page input row shown when Python's input() is called. Appears
   below the OUTPUT panel; the worker is blocked on Atomics.wait until the
   kid submits a reply. */
.input-row {
  display: flex;
  gap: 8px;
  padding: 10px 14px;
  border-top: 1px solid var(--border, #d4d8dd);
  background: #fafbfc;
  align-items: center;
}
.input-row[hidden] { display: none; }
.input-row input {
  flex: 1;
  padding: 7px 10px;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 14px;
  border: 1px solid #c3c9d0;
  border-radius: 4px;
  background: #fff;
}
.input-row input:focus {
  outline: 2px solid #1f8dd6;
  outline-offset: -1px;
}

/* F1 polish: pulse the input field until the kid interacts with it.
   showInputRow() in app.js adds .pulse on the row; first focus/input/click
   removes it. Animation is subtle enough not to distract from the prompt
   text in the OUTPUT panel. */
@keyframes pp-input-pulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(31, 141, 214, 0);
    border-color: #c3c9d0;
    background: #fff;
  }
  50% {
    box-shadow: 0 0 0 4px rgba(31, 141, 214, 0.2);
    border-color: #1f8dd6;
    background: #f0f8fd;
  }
}
.input-row.pulse input {
  animation: pp-input-pulse 1.2s ease-in-out infinite;
}
.input-row button {
  font-size: 13px;
  padding: 6px 14px;
}

.output-body .pass { color: var(--success); }
.output-body .fail { color: var(--error); }

/* F5: kid-friendly explanation block, shown above the raw traceback when
   Python errors. Soft cyan so it reads as "guidance" rather than "wrong". */
.output-body .err-kidline {
  background: #e6f3f8;
  border-left: 4px solid #1f8dd6;
  color: var(--text);
  padding: 10px 14px;
  margin: 0 0 10px;
  border-radius: 0 4px 4px 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  white-space: normal;
}
.output-body .err-kidline strong { color: #0a4e75; }
.output-body .err-kidline code {
  background: rgba(31, 141, 214, 0.12);
  color: #0a4e75;
  padding: 1px 4px;
  border-radius: 3px;
  font-family: "SF Mono", Menlo, Consolas, monospace;
}

/* The raw Python traceback shown below the kid-line — keep it red but
   slightly muted so the kid's eye lands on the friendly explanation first. */
.output-body .err-raw {
  color: var(--error);
  display: block;
  margin-top: 4px;
}

.output-body .stdout-pre { display: block; color: var(--text); margin-bottom: 6px; }

/* F10: actual-vs-expected diagnostic for a failing test. */
.output-body .diag-got { color: var(--error); font-weight: 600; }
.output-body .diag-exp { color: var(--success); font-weight: 600; }

.status-banner {
  padding: 12px 20px;
  border-top: 1px solid var(--card-border);
  font-size: 14px;
  display: none;
}

.status-banner.show { display: block; }
.status-banner.success { background: #e9f6ed; color: #1c6a35; }
.status-banner.fail { background: #fbe9e9; color: #8a1c1c; }

.hint-box {
  margin-top: 16px;
  padding: 12px 16px;
  background: #fffbe5;
  border: 1px solid #f0e3a0;
  border-radius: 4px;
  font-size: 14px;
  display: none;
}

.hint-box.show { display: block; }

/* F7: individual hint item inside the hint-box. Multiple items stack
   vertically; the small label on top tells the kid how many hints exist. */
.hint-item {
  padding: 4px 0;
}
.hint-item + .hint-item {
  border-top: 1px dashed #e0d490;
  margin-top: 8px;
  padding-top: 10px;
}
.hint-label {
  font-weight: 700;
  color: #6a5a00;
  margin-right: 4px;
}

/* F8: solution-reveal modal — full-viewport backdrop + centered card. */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 40, 60, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 24px;
}
.modal-backdrop[hidden] { display: none; }

.modal {
  background: white;
  border-radius: 8px;
  box-shadow: 0 10px 40px rgba(20, 40, 60, 0.25);
  max-width: 640px;
  width: 100%;
  max-height: calc(100vh - 80px);
  overflow-y: auto;
  padding: 20px 24px 24px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.modal-header h3 { margin: 0; font-size: 20px; }

.modal-close {
  background: none;
  border: 0;
  font-size: 26px;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0 4px;
}
.modal-close:hover { color: var(--text); }

.modal-intro {
  color: var(--text-muted);
  font-size: 14px;
  margin: 4px 0 14px;
  line-height: 1.5;
}

.modal-code {
  background: var(--code-block-bg);
  border: 1px solid var(--card-border);
  border-radius: 4px;
  padding: 12px 14px;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 13px;
  white-space: pre;
  overflow-x: auto;
  margin: 0 0 16px;
}

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

.loading-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #fff8d6;
  color: #6a5a00;
  padding: 8px 16px;
  text-align: center;
  font-size: 13px;
  border-top: 1px solid #f0e3a0;
  z-index: 100;
}

/* ============== PAGINATION ============== */

.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 32px;
  padding: 14px 24px;
  position: sticky;
  bottom: 0;
  background: var(--page-bg);
  border-top: 1px solid var(--card-border);
  z-index: 10;
}

.pagination .position {
  color: var(--text-muted);
  font-size: 14px;
  min-width: 40px;
  text-align: center;
}

/* F14: per-page progress dots row inside the pagination position slot. */
.page-dots {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.page-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: white;
  border: 1.5px solid var(--card-border);
  font-size: 12px;
  line-height: 1;
  color: transparent;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.page-dot.completed {
  background: var(--success);
  border-color: var(--success);
  color: white;
}

.page-dot.current {
  background: var(--primary);
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(60, 93, 112, 0.18);
}

.pagination .btn:disabled { visibility: hidden; }

/* Locked state for the pagination Next/Done <a> — kid sees the button
   exists but can't click it. Hover keeps the title-attribute tooltip
   visible (no pointer-events:none, which would suppress the title). */
.btn.disabled,
.btn.disabled:hover {
  opacity: 0.45;
  cursor: not-allowed;
  background: white;
  color: var(--text-muted);
  box-shadow: none;
  border-color: var(--btn-border);
}

.btn.disabled.btn-done,
.btn.disabled.btn-done:hover {
  background: white;
  color: var(--text-muted);
  border-color: var(--btn-border);
}

/* Done button on the last page of an item (and on single-page items).
   Green = match the section-done ribbon and overall completion accent. */
.btn-done {
  background: var(--success);
  color: white;
  border-color: var(--success);
  font-weight: 600;
}

.btn-done:hover:not(:disabled) {
  background: #267e40; /* slightly darker green */
  border-color: #267e40;
}

/* ===================== HOME PAGE ===================== */

.home-hero {
  max-width: 720px;
  margin: 0 auto;
  padding: 56px 24px 80px;
  text-align: center;
}

.home-logo {
  width: 240px;
  height: auto;
  margin-bottom: 20px;
}

.home-hero h1 {
  margin: 0 0 16px;
  font-size: 44px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.5px;
}

.home-tagline {
  margin: 0 auto 32px;
  max-width: 520px;
  font-size: 18px;
  line-height: 1.6;
  color: var(--text-muted);
}

.home-cta {
  display: flex;
  gap: 14px;
  justify-content: center;
  flex-wrap: wrap;
}

.home-cta-btn {
  display: inline-block;
  padding: 14px 28px;
  border-radius: 8px;
  font-size: 17px;
  font-weight: 600;
  border: 2px solid var(--primary);
  color: var(--primary);
  background: white;
  transition: transform 0.08s ease, background 0.12s ease;
}

.home-cta-btn:hover {
  background: var(--btn-hover-bg);
  transform: translateY(-1px);
}

.home-cta-btn-primary {
  background: var(--primary);
  color: white;
}

.home-cta-btn-primary:hover {
  background: var(--nav-bg-dark);
}

/* ===================== FOOTER ===================== */

.site-footer {
  display: block;
  text-align: center;
  padding: 36px 24px 28px;
  margin-top: 48px;
  border-top: 1px solid var(--card-border);
}

.site-footer-logo {
  height: 56px;
  width: auto;
  opacity: 0.85;
  transition: opacity 0.12s ease;
}

.site-footer-logo:hover { opacity: 1; }

/* ===================== F20 QUIZ PAGES ===================== */

.quiz-question {
  border: none;
  padding: 0;
  margin: 16px 0 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.quiz-choice {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: white;
  border: 1.5px solid var(--card-border);
  border-radius: 6px;
  cursor: pointer;
  font-size: 16px;
  color: var(--text);
  transition: border-color 0.12s ease, background 0.12s ease;
}

.quiz-choice:hover {
  border-color: var(--primary);
  background: #f9fbfc;
}

.quiz-choice input[type="radio"] {
  margin: 0;
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  cursor: pointer;
}

.quiz-choice input[type="radio"]:disabled {
  cursor: default;
}

.quiz-choice.right {
  border-color: var(--success);
  background: rgba(46, 157, 79, 0.08);
  color: var(--text);
  position: relative;
}

.quiz-choice.right::after {
  content: "✓";
  margin-left: auto;
  color: var(--success);
  font-weight: 700;
  font-size: 18px;
}

.quiz-choice.wrong {
  border-color: var(--error);
  background: rgba(221, 17, 68, 0.06);
  position: relative;
}

.quiz-choice.wrong::after {
  content: "✗";
  margin-left: auto;
  color: var(--error);
  font-weight: 700;
  font-size: 18px;
}

.quiz-choice:has(input:disabled):hover {
  border-color: var(--card-border);
  background: white;
}
.quiz-choice.right:has(input:disabled):hover {
  border-color: var(--success);
  background: rgba(46, 157, 79, 0.08);
}
.quiz-choice.wrong:has(input:disabled):hover {
  border-color: var(--error);
  background: rgba(221, 17, 68, 0.06);
}

.quiz-actions {
  margin-top: 20px;
}

.btn-quiz-check {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  font-weight: 600;
  padding: 10px 22px;
}

.btn-quiz-check:hover:not(:disabled) {
  background: var(--nav-bg-dark);
  border-color: var(--nav-bg-dark);
}

.btn-quiz-check:disabled {
  opacity: 0.6;
  cursor: default;
}

.quiz-feedback {
  margin-top: 12px;
  min-height: 1.2em;
}

.quiz-feedback-right { color: var(--success); font-weight: 600; }
.quiz-feedback-wrong { color: var(--error); font-weight: 600; }
.quiz-pick-warning  { color: var(--text-muted); font-style: italic; }

.quiz-score-banner { margin-top: 24px; }

.quiz-results-panel {
  padding: 28px 24px;
  background: rgba(46, 157, 79, 0.08);
  border: 1px solid var(--success);
  border-radius: 8px;
  text-align: center;
}

.quiz-results-panel.quiz-results-celebrate {
  background: rgba(46, 157, 79, 0.14);
  box-shadow: 0 4px 18px rgba(46, 157, 79, 0.18);
}

.quiz-results-panel.quiz-results-neutral {
  background: rgba(255, 216, 102, 0.18);
  border-color: var(--pro-bg);
}

.quiz-results-score {
  font-size: 56px;
  font-weight: 800;
  line-height: 1;
  color: var(--success);
  margin: 0 0 8px;
}

.quiz-results-neutral .quiz-results-score { color: var(--pro-text); }

.quiz-results-message {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 20px;
}

.quiz-results-breakdown {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
  max-width: 420px;
  margin-left: auto;
  margin-right: auto;
}

.quiz-result-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: white;
  border: 1px solid var(--card-border);
  border-radius: 6px;
  font-size: 15px;
}

.quiz-result-item.right { border-color: rgba(46, 157, 79, 0.45); }
.quiz-result-item.wrong { border-color: rgba(221, 17, 68, 0.4); }

.quiz-result-mark {
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}
.quiz-result-mark.right { background: var(--success); color: white; }
.quiz-result-mark.wrong { background: var(--error); color: white; }
.quiz-result-mark.skipped { background: var(--card-border); color: var(--text-muted); }

/* ===================== F19 RESPONSIVE — TABLET ===================== */
/* iPad portrait + everything narrower. iPad landscape (1024) keeps the
   side-by-side editor layout. */
@media (max-width: 768px) {
  /* Stack the lesson layout earlier than the 900px legacy rule. */
  .lesson-layout { grid-template-columns: 1fr; padding: 16px; gap: 14px; }

  /* Lesson card header — page label on its own row, controls below. */
  .lesson-content-header {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .readaloud-controls {
    width: 100%;
    flex-wrap: wrap;
    justify-content: flex-end;
  }
  .voice-picker { max-width: none; flex: 1 1 0; min-width: 0; }

  /* Tighter index header so the curve doesn't push content off the fold. */
  .index-header { padding: 32px 20px 60px; }
  .index-body { padding: 0 16px; margin: -50px auto 40px; }
  .index-card { padding: 18px; }

  /* Home hero scales down. */
  .home-hero { padding: 40px 20px 60px; }
  .home-logo { width: 200px; margin-bottom: 16px; }
  .home-hero h1 { font-size: 36px; }

  /* Lesson content card a bit more breathing room. */
  .lesson-content { padding: 24px 22px; }
}

/* ===================== F19 RESPONSIVE — PHONE ===================== */
@media (max-width: 480px) {
  /* Compact nav: hide the "Python Town" wordmark; snake icon is enough. */
  .nav { padding: 10px 16px; }
  .nav-brand-text { display: none; }
  .nav-brand-img { height: 36px; }
  .nav-links { gap: 18px; font-size: 14px; }
  .nav-trophy { font-size: 14px; }

  /* Bigger tap targets for buttons. */
  .btn {
    padding: 10px 16px;
    min-height: 40px;
    font-size: 15px;
  }
  .editor-toolbar { flex-wrap: wrap; gap: 8px; }
  .editor-toolbar .toolbar-group { flex-wrap: wrap; gap: 6px; }

  /* Compact F14 dot strip so 7-page items still fit one line. */
  .page-dot { width: 22px; height: 22px; font-size: 11px; }
  .page-dots { gap: 4px; }
  .pagination { gap: 14px; padding: 12px 14px; }

  /* Pagination Back / Next slim down — they're on the screen edges and
     don't need the full 40px tap target. Action buttons (Run, Submit,
     Check, Reset, Hint) elsewhere keep their bigger size via the
     more general .btn rule above. */
  .pagination .btn {
    padding: 6px 12px;
    min-height: 34px;
    font-size: 14px;
  }
  .pagination .btn .btn-icon { font-size: 13px; }

  /* Hero further compact on a phone. */
  .home-hero { padding: 28px 18px 44px; }
  .home-hero h1 { font-size: 30px; }
  .home-tagline { font-size: 16px; }
  .home-logo { width: 170px; margin-bottom: 12px; }
  .home-cta-btn { padding: 12px 22px; font-size: 16px; }

  /* Index + challenges title images shouldn't dominate on phone. */
  .index-header { padding: 22px 14px 50px; }
  .page-title-img { max-width: 320px; }
  .index-header .meta { font-size: 14px; }

  /* Lesson content padding tightens further. */
  .lesson-content { padding: 20px 18px; }
  .lesson-content h2 { font-size: 16px; }

  /* Code blocks can scroll horizontally if they're too wide. */
  .code-block { overflow-x: auto; }

  /* Footer logo a bit smaller. */
  .site-footer { padding: 28px 16px 22px; margin-top: 32px; }
  .site-footer-logo { height: 44px; }

  /* Quiz UI tweaks for phone. */
  .quiz-choice { padding: 12px 14px; font-size: 15px; }
  .quiz-results-panel { padding: 22px 18px; }
  .quiz-results-score { font-size: 44px; }
  .quiz-results-message { font-size: 16px; }

  /* Solution modal fills more of the small viewport. */
  .modal-backdrop { padding: 12px; }
  .modal { padding: 16px 18px 18px; max-height: calc(100vh - 24px); }
  .modal-header h3 { font-size: 18px; }
  .modal-code { font-size: 12px; padding: 10px 12px; }
}
