/* ============================================================
   Rust for Students, theme
   Implements the "Rust for Students" design system:
   warm, rounded, friendly, and FLAT (no gradients).
   ============================================================ */

/* ---------- Tokens: color ---------- */
:root {
  /* Brand: Ferris orange */
  --rust-orange: #ff7a45;
  --rust-orange-dark: #e05a2b;
  --rust-orange-soft: #ff926b;
  --rust-orange-tint: #ffe6db;

  /* Ink (text) */
  --ink: #2b2742;
  --ink-soft: #5a5470;
  --ink-faint: #8a82a0;

  /* Surfaces */
  --paper: #fff9f3;
  --card: #ffffff;
  --line: #ece3d8;
  --line-strong: #ddd0c0;

  /* Callout tints + borders, muted warm "craft paper" set */
  --sky: #e3e9f1;     --sky-border: #bccddf;
  --mint: #e4ebdf;    --mint-border: #c4d6b8;
  --lemon: #f6e7c2;   --lemon-border: #e4c884;
  --grape: #ece1ea;   --grape-border: #d2bdce;
  --rose: #f3ddd5;    --rose-border: #e5b1a3;
  --stone: #efe8dd;   --stone-border: #dacbb4;

  /* Inks that read on the muted tints */
  --on-sky: #3f5269;
  --on-mint: #4c6238;
  --on-lemon: #6f5310;
  --on-grape: #6b4360;
  --on-rose: #9e4030;
  --on-stone: #6d5a3f;

  /* Status */
  --good: #2bb673;       --good-ink: #1c7a4f;
  --bad: #ff5a5f;        --bad-ink: #c0343a;
  --warn: #f0a202;
  --xp-amber: #ffb020;   --xp-ink: #5b3a00;

  /* Code */
  --code-bg: #2b2742;
  --code-fg: #f3eefe;
  --code-inline-bg: #f3ecff;
  --code-inline-fg: #5a2ca0;

  /* World map accents (one per chapter) */
  --world-1: #ff7a59;  --world-2: #f0a202;  --world-3: #56a3a6;  --world-4: #9b5de5;
  --world-5: #f15bb5;  --world-6: #00bbf9;  --world-7: #00bca7;  --world-8: #e0b400;
  --world-9: #ff595e;  --world-10: #1982c4; --world-11: #6a4c93; --world-12: #ff924c;
  --world-13: #6fae20; --world-14: #2f9e6b; --world-15: #e07a5f; --world-16: #3d5a80;
  --world-17: #ee6c4d; --world-18: #5e548e; --world-19: #8a7c88; --world-20: #2c2b45;

  /* Aliases */
  --accent: var(--rust-orange);
  --accent-hover: var(--rust-orange-dark);
  --link: var(--rust-orange-dark);
  --focus-ring: var(--rust-orange);

  /* ---------- Tokens: type ---------- */
  --font-head: "Fredoka", system-ui, -apple-system, sans-serif;
  --font-body: "Nunito", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;

  /* ---------- Tokens: spacing, radii, shadows, motion ---------- */
  --radius-xs: 7px;
  --radius-sm: 12px;
  --radius: 18px;
  --radius-lg: 24px;
  --radius-pill: 999px;

  --shadow-sm: 0 4px 12px rgba(120, 80, 40, 0.08);
  --shadow: 0 8px 24px rgba(120, 80, 40, 0.12);
  --shadow-lg: 0 14px 40px rgba(120, 80, 40, 0.18);

  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
  --dur-fast: 0.12s;
  --dur: 0.25s;
  --dur-slow: 0.6s;
  --focus-width: 3px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--paper); /* flat warm paper, no gradient washes */
  line-height: 1.65;
  font-size: 18px;
}

h1, h2, h3, h4 { font-family: var(--font-head); line-height: 1.2; color: var(--ink); }

a { color: var(--rust-orange-dark); }

/* Inline SVG icons inherit text color and sit on the baseline nicely */
.icon { display: inline-block; flex: none; vertical-align: middle; }

.skip-link {
  position: absolute; left: -999px; top: 0; background: var(--ink); color: #fff;
  padding: 10px 16px; border-radius: 0 0 10px 0; z-index: 100;
}
.skip-link:focus { left: 0; }

:where(a, button, textarea, summary, [tabindex]):focus-visible {
  outline: var(--focus-width) solid var(--focus-ring);
  outline-offset: 2px;
  border-radius: 8px;
}

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  padding: 12px clamp(16px, 4vw, 40px);
  background: rgba(255, 249, 243, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 3px solid var(--line);
}
.brand {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--font-head); font-weight: 700; font-size: 1.35rem;
  text-decoration: none; color: var(--ink);
}
.brand-mark { display: inline-flex; width: 40px; }
.brand-mark .ferris { width: 40px; max-width: 40px; height: auto; animation: none; }
.brand-text em { color: var(--rust-orange-dark); font-style: normal; }
.site-nav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.site-nav a {
  display: inline-flex; align-items: center; gap: 6px;
  text-decoration: none; color: var(--ink-soft); font-weight: 700;
  font-family: var(--font-head);
  padding: 8px 12px; border-radius: 12px;
}
.site-nav a:hover { background: #fff; box-shadow: var(--shadow); color: var(--ink); }
.xp-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--xp-amber); /* flat amber, gradient removed */
  color: var(--xp-ink); font-weight: 800; font-family: var(--font-head);
  padding: 8px 14px; border-radius: var(--radius-pill); box-shadow: var(--shadow);
}
.xp-sep { opacity: .45; }
.xp-star { display: inline-flex; }

/* ---------- Buttons ---------- */
.big-btn, .ghost-btn, .complete-btn, .link-btn {
  font-family: var(--font-head); cursor: pointer; border: none;
}
.big-btn {
  display: inline-flex; align-items: center; gap: 8px; text-decoration: none;
  background: var(--rust-orange); color: #fff; /* flat fill */
  font-size: 1.25rem; font-weight: 700; line-height: 1.1;
  padding: 14px 28px; border-radius: var(--radius-pill);
  border: 2px solid var(--rust-orange); box-shadow: var(--shadow);
  transition: transform var(--dur-fast) var(--ease-out), filter var(--dur-fast) var(--ease-out);
}
.big-btn:hover { transform: translateY(-2px); filter: brightness(1.04); }
.big-btn:active { transform: translateY(0); }
.ghost-btn {
  display: inline-flex; align-items: center; gap: 8px; text-decoration: none; margin-left: 10px;
  background: var(--card); color: var(--rust-orange-dark); font-weight: 700; font-size: 1rem;
  line-height: 1.1; padding: 13px 22px; border-radius: var(--radius-pill);
  border: 2px solid var(--rust-orange);
  transition: transform var(--dur-fast) var(--ease-out), filter var(--dur-fast) var(--ease-out);
}
.ghost-btn:hover { transform: translateY(-2px); filter: brightness(1.02); }
.link-btn {
  background: none; color: var(--ink-soft); text-decoration: underline;
  font-family: var(--font-body); font-weight: 700; padding: 0 4px;
}

/* ---------- Hero ---------- */
.hero {
  display: grid; grid-template-columns: 280px 1fr; gap: 28px; align-items: center;
  max-width: 1100px; margin: 24px auto 8px; padding: 24px clamp(16px, 4vw, 32px);
}
.hero-art { display: flex; justify-content: center; }
.ferris { width: 100%; max-width: 260px; animation: bob 3.5s ease-in-out infinite; }
.hero h1 { font-size: clamp(2rem, 5vw, 3.1rem); margin: 0 0 10px; line-height: 1.1; }
.rust-word { color: var(--rust-orange-dark); } /* flat, gradient text removed */
.hero-sub { font-size: 1.15rem; color: var(--ink-soft); max-width: 52ch; }

/* ---------- Progress panel ---------- */
.progress-panel {
  display: grid; grid-template-columns: repeat(3, auto) 1fr; gap: 16px;
  align-items: center; max-width: 1100px; margin: 8px auto 28px;
  padding: 18px clamp(16px, 4vw, 28px);
  background: var(--card); border: 3px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.stat { text-align: center; }
.stat-num {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font-family: var(--font-head); font-weight: 700; font-size: 1.8rem;
  color: var(--rust-orange-dark);
}
.stat-label { font-size: .85rem; color: var(--ink-soft); font-weight: 700; }
.stat-wide { text-align: left; }
.progress-bar { height: 16px; background: #f0e6da; border-radius: var(--radius-pill); overflow: hidden; }
.progress-fill {
  height: 100%; width: 0%;
  background: var(--good); /* flat green, gradient removed */
  border-radius: var(--radius-pill); transition: width var(--dur-slow) var(--ease-out);
}
.badges-row { display: inline-flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.badge-pill {
  background: var(--lemon); border: 2px solid var(--lemon-border); color: var(--on-lemon);
  border-radius: var(--radius-pill); padding: 3px 11px;
  font-family: var(--font-head); font-weight: 800; font-size: .82rem;
}

/* ---------- World map ---------- */
.worlds { max-width: 1100px; margin: 0 auto 60px; padding: 0 clamp(16px, 4vw, 32px); }
.section-title { font-size: clamp(1.6rem, 4vw, 2.2rem); margin: 8px 0 4px; }
.section-sub { color: var(--ink-soft); margin-top: 0; }
.world-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px;
}
.world-card {
  background: var(--card); border-radius: var(--radius);
  border: 3px solid var(--line); box-shadow: var(--shadow);
  padding: 18px; position: relative; overflow: hidden;
  transition: transform var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
  border-top: 8px solid var(--world-color, var(--rust-orange));
}
.world-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.world-head { display: flex; align-items: center; gap: 12px; }
.world-tile {
  font-family: var(--font-head); font-weight: 700; font-size: 1.35rem;
  color: var(--world-color, var(--rust-orange));
  background: color-mix(in srgb, var(--world-color, var(--rust-orange)) 16%, white);
  border-radius: 14px; width: 52px; height: 52px; display: grid; place-items: center; flex: none;
}
.world-num { font-size: .78rem; font-weight: 800; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .04em; }
.world-title { margin: 0; font-size: 1.25rem; }
.world-progress {
  margin-left: auto; align-self: flex-start; font-family: var(--font-head); font-weight: 700;
  font-size: .85rem; background: var(--mint); color: var(--good-ink);
  padding: 3px 10px; border-radius: var(--radius-pill); border: 2px solid #bfead4;
}
.world-progress.complete { background: #d8f5e3; }
.world-blurb { color: var(--ink-soft); font-size: .98rem; margin: 10px 0 12px; }
.lesson-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.lesson-link {
  display: flex; align-items: center; gap: 8px; text-decoration: none;
  color: var(--ink); padding: 7px 10px; border-radius: 12px; background: var(--paper);
  border: 2px solid transparent; font-weight: 600;
  transition: background var(--dur-fast), border-color var(--dur-fast);
}
.lesson-link:hover { border-color: var(--world-color, var(--rust-orange)); background: #fff; }
.lesson-check { display: inline-flex; flex: none; color: #cbbfae; }
.lesson-link.done { background: var(--mint); }
.lesson-link.done .lesson-check { color: var(--good); }
.lesson-name { font-size: .95rem; }

/* ---------- Lesson layout ---------- */
.lesson-shell {
  display: grid; grid-template-columns: 290px minmax(0, 1fr);
  gap: 0; max-width: 1180px; margin: 0 auto; align-items: start;
}
.sidebar {
  position: sticky; top: 70px; align-self: start;
  max-height: calc(100vh - 80px); overflow-y: auto;
  padding: 18px 10px 40px 16px; border-right: 3px solid var(--line);
}
.sidebar-home {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--font-head); font-weight: 700; text-decoration: none;
  color: var(--ink); background: #fff; border: 2px solid var(--line);
  padding: 10px 12px; border-radius: 12px; margin-bottom: 12px;
}
.side-world { margin-bottom: 4px; }
.side-world > summary {
  cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px;
  font-family: var(--font-head); font-weight: 600;
  padding: 8px 10px; border-radius: 10px; color: var(--ink);
}
.side-world > summary::-webkit-details-marker { display: none; }
.side-world > summary:hover { background: #fff; }
.side-num {
  font-family: var(--font-head); font-weight: 700; font-size: .8rem;
  color: var(--world-color, var(--rust-orange));
  background: color-mix(in srgb, var(--world-color, var(--rust-orange)) 16%, white);
  border-radius: 7px; width: 22px; height: 22px; display: inline-grid; place-items: center; flex: none;
}
.side-world ul { list-style: none; margin: 2px 0 8px; padding: 0 0 0 6px; display: grid; gap: 2px; }
.side-lesson {
  display: flex; align-items: center; gap: 6px; text-decoration: none;
  color: var(--ink-soft); font-size: .92rem; padding: 6px 10px; border-radius: 10px;
  font-weight: 600;
}
.side-lesson:hover { background: #fff; color: var(--ink); }
.side-lesson.is-current { background: var(--rust-orange); color: #fff; }
.side-check { display: inline-flex; flex: none; color: #cbbfae; }
.side-lesson.done .side-check { color: var(--good); }
.side-lesson.is-current .side-check,
.side-lesson.is-current.done .side-check { color: #fff; }

.sidebar-toggle {
  display: none; position: sticky; top: 66px; z-index: 30;
  margin: 8px 16px; padding: 10px 16px; border: none; cursor: pointer;
  background: var(--ink); color: #fff; font-family: var(--font-head);
  font-weight: 700; border-radius: 12px; box-shadow: var(--shadow);
  align-items: center; gap: 8px;
}

/* ---------- Lesson content ---------- */
.lesson { padding: 18px clamp(16px, 4vw, 48px) 80px; min-width: 0; }
.crumbs { font-size: .85rem; color: var(--ink-soft); display: flex; gap: 8px; flex-wrap: wrap; }
.crumbs a { color: var(--ink-soft); text-decoration: none; font-weight: 700; }
.lesson-head {
  display: flex; align-items: center; gap: 16px; margin: 12px 0 8px;
  padding-bottom: 16px; border-bottom: 3px dashed var(--line);
}
.lesson-num-big {
  flex: none; width: 70px; height: 70px; display: grid; place-items: center;
  font-family: var(--font-head); font-weight: 700; font-size: 2rem;
  color: var(--world-color, var(--rust-orange));
  background: color-mix(in srgb, var(--world-color, var(--rust-orange)) 16%, white);
  border-radius: 18px;
}
.lesson-kicker { font-size: .8rem; font-weight: 800; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .04em; }
.lesson-head h1 { margin: 2px 0 0; font-size: clamp(1.7rem, 4vw, 2.4rem); }

.lesson-body { font-size: 1.08rem; }
.lesson-body p { margin: 0 0 1em; }
.lesson-body h2 { font-size: 1.6rem; margin: 1.6em 0 .4em; }
.lesson-body h3 { font-size: 1.25rem; margin: 1.3em 0 .3em; }
.lesson-body ul, .lesson-body ol { padding-left: 1.4em; }
.lesson-body li { margin: .3em 0; }
.lesson-body img { max-width: 100%; border-radius: 12px; }
.lesson-body a { font-weight: 700; }
.lesson-body strong { color: var(--ink); }

/* inline + block code (non-interactive prose code) */
.lesson-body :not(pre) > code {
  font-family: var(--font-mono); font-size: .9em;
  background: var(--code-inline-bg); color: var(--code-inline-fg);
  padding: 2px 7px; border-radius: var(--radius-xs); font-weight: 600;
}
.lesson-body pre {
  background: var(--code-bg); color: var(--code-fg); padding: 16px 18px; border-radius: 14px;
  overflow-x: auto; font-family: var(--font-mono); font-size: .92rem; line-height: 1.5;
  box-shadow: var(--shadow);
}
.lesson-body pre code { background: none; color: inherit; padding: 0; font-weight: 400; }

.lesson-body blockquote {
  margin: 1em 0; padding: 10px 18px; border-left: 6px solid var(--rust-orange);
  background: #fff; border-radius: 0 12px 12px 0; color: var(--ink-soft);
}

/* ---------- Callout boxes (SVG icons, muted tints) ---------- */
.ferris-says, .try-this, .watch-out, .big-idea, .analogy, .vocab {
  margin: 1.3em 0; padding: 16px 18px 16px 56px; border-radius: 16px;
  position: relative; border: 2px solid; font-size: 1.02rem; line-height: 1.55;
}
.big-idea::before, .analogy::before, .ferris-says::before,
.try-this::before, .watch-out::before, .vocab::before {
  content: ""; position: absolute; left: 18px; top: 16px; width: 22px; height: 22px;
  background-repeat: no-repeat; background-position: center; background-size: 22px 22px;
}
.big-idea { background: var(--lemon); border-color: var(--lemon-border); }
.big-idea::before { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236f5310' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 4 13.4 7.6 17 9l-3.6 1.4L12 14l-1.4-3.6L7 9l3.6-1.4Z'/%3E%3Cpath d='M18 14l.7 1.8L20.5 16.5l-1.8.7L18 19l-.7-1.8L15.5 17.2l1.8-.7Z'/%3E%3C/svg%3E"); }
.analogy { background: var(--grape); border-color: var(--grape-border); }
.analogy::before { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b4360' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1.3.5 2.6 1.5 3.5.8.8 1.3 1.5 1.5 2.5'/%3E%3Cpath d='M9 18h6'/%3E%3Cpath d='M10 22h4'/%3E%3C/svg%3E"); }
.ferris-says { background: var(--sky); border-color: var(--sky-border); }
.ferris-says::before { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%233f5269' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7.9 20A9 9 0 1 0 4 16.1L2 22Z'/%3E%3C/svg%3E"); }
.try-this { background: var(--mint); border-color: var(--mint-border); }
.try-this::before { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%234c6238' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Ccircle cx='12' cy='12' r='6'/%3E%3Ccircle cx='12' cy='12' r='2'/%3E%3C/svg%3E"); }
.watch-out { background: var(--rose); border-color: var(--rose-border); }
.watch-out::before { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239e4030' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m21.7 18-8-14a2 2 0 0 0-3.4 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.7-3Z'/%3E%3Cpath d='M12 9v4'/%3E%3Cpath d='M12 17h.01'/%3E%3C/svg%3E"); }
.vocab { background: var(--stone); border-color: var(--stone-border); }
.vocab::before { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236d5a3f' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 7v14'/%3E%3Cpath d='M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3Z'/%3E%3C/svg%3E"); }
.ferris-says strong, .analogy strong, .big-idea strong,
.try-this strong, .watch-out strong, .vocab strong { color: var(--ink); }
.callout-title { display: block; font-family: var(--font-head); font-weight: 700; margin-bottom: 2px; }

/* ---------- Code playground ---------- */
.rust-play {
  margin: 1.4em 0; border-radius: 16px; overflow: hidden;
  border: 3px solid var(--code-bg); box-shadow: var(--shadow); background: var(--code-bg);
}
.rust-play.is-raw { display: none; }
.rp-bar {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px;
  background: #3a3556; color: #d9d2f0; font-family: var(--font-head); font-weight: 600; font-size: .85rem;
}
.rp-dots { display: flex; gap: 5px; margin-right: 4px; }
.rp-dot { width: 11px; height: 11px; border-radius: 50%; }
.rp-dot.r { background: #ff5f57; } .rp-dot.y { background: #febc2e; } .rp-dot.g { background: #28c840; }
.rp-title { opacity: .8; }
.rp-actions { margin-left: auto; display: flex; gap: 8px; }
.rp-btn {
  font-family: var(--font-head); font-weight: 700; cursor: pointer; border: none;
  border-radius: 10px; padding: 6px 14px; font-size: .85rem;
}
.rp-run { background: #28c840; color: #06310f; display: inline-flex; align-items: center; gap: 5px; }
.rp-run:hover { filter: brightness(1.08); }
.rp-reset { background: #57516f; color: #ece8fa; }
.rp-code {
  width: 100%; border: none; outline: none; resize: vertical;
  background: var(--code-bg); color: var(--code-fg); font-family: var(--font-mono);
  font-size: .92rem; line-height: 1.55; padding: 14px 16px; display: block;
  tab-size: 4; min-height: 60px;
}
.rp-output {
  border-top: 2px dashed #4a4566; background: #1f1b30; color: #c8f7d4;
  font-family: var(--font-mono); font-size: .9rem; padding: 0 16px;
  max-height: 0; overflow: hidden; transition: max-height .35s ease, padding .35s ease;
}
.rp-output.show { max-height: 420px; overflow: auto; padding: 12px 16px; }
.rp-output .out-label { color: #8fb7ff; font-family: var(--font-head); display: block; margin-bottom: 4px; font-size: .82rem; }
.rp-output pre { margin: 0; white-space: pre-wrap; word-break: break-word; background: none; box-shadow: none; padding: 0; color: inherit; }
.rp-note { color: #ffd479; margin-top: 8px; font-family: var(--font-body); font-size: .85rem; }
.rp-compiling { color: #ffd479; }
.rp-output pre.rp-error { color: #ff9b8a; }
.rp-live {
  font-family: var(--font-head); font-weight: 700; font-size: .66rem;
  letter-spacing: .06em; text-transform: uppercase;
  color: #06310f; background: #28c840; padding: 2px 8px; border-radius: 999px;
}
.rp-run:disabled { opacity: .6; cursor: progress; }

/* ---------- Quiz ---------- */
.kid-quiz {
  margin: 1.4em 0; padding: 18px; border-radius: 16px;
  background: var(--card); border: 3px solid var(--line); box-shadow: var(--shadow);
}
.kid-quiz .q { font-family: var(--font-head); font-weight: 600; font-size: 1.15rem; margin: 0 0 12px; }
.kid-quiz .q::before {
  content: ""; display: inline-block; width: 18px; height: 18px; vertical-align: -3px; margin-right: 7px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23e05a2b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7.9 20A9 9 0 1 0 4 16.1L2 22Z'/%3E%3C/svg%3E") no-repeat center / contain;
}
.quiz-options { display: grid; gap: 10px; }
.kid-quiz button.opt {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  text-align: left; font-family: var(--font-body); font-weight: 700; font-size: 1rem;
  cursor: pointer; background: var(--paper); border: 2px solid var(--line);
  border-radius: 12px; padding: 12px 16px; color: var(--ink); transition: transform .08s ease;
}
.kid-quiz button.opt:hover { border-color: var(--rust-orange); transform: translateX(3px); }
.kid-quiz button.opt:disabled { cursor: default; opacity: 1; }
.kid-quiz button.opt.correct { background: var(--mint); border-color: var(--good); }
.kid-quiz button.opt.correct::after {
  content: ""; display: inline-block; width: 18px; height: 18px; flex: none;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231c7a4f' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") no-repeat center / contain;
}
.kid-quiz button.opt.wrong { background: var(--rose); border-color: var(--bad); animation: shake .35s; }
.kid-quiz button.opt.wrong::after { content: "\2715"; color: var(--bad-ink); font-weight: 800; flex: none; }
.kid-quiz .explain {
  margin: 12px 0 0; padding: 12px 16px; border-radius: 12px;
  background: var(--lemon); border: 2px solid var(--lemon-border); display: none;
}
.kid-quiz .explain.show { display: block; }
.kid-quiz .explain::before {
  content: ""; display: inline-block; width: 17px; height: 17px; vertical-align: -3px; margin-right: 7px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236f5310' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 4 13.4 7.6 17 9l-3.6 1.4L12 14l-1.4-3.6L7 9l3.6-1.4Z'/%3E%3Cpath d='M18 14l.7 1.8L20.5 16.5l-1.8.7L18 19l-.7-1.8L15.5 17.2l1.8-.7Z'/%3E%3C/svg%3E") no-repeat center / contain;
}

/* ---------- Lesson footer ---------- */
.lesson-done { text-align: center; margin: 40px 0 10px; }
.complete-btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--good); color: #053019; /* flat green, gradient removed */
  font-size: 1.25rem; font-weight: 700; line-height: 1.1;
  padding: 14px 28px; border-radius: var(--radius-pill);
  border: 2px solid var(--good); box-shadow: var(--shadow);
  transition: transform var(--dur-fast) var(--ease-out), filter var(--dur-fast) var(--ease-out);
}
.complete-btn:hover { transform: translateY(-2px); filter: brightness(1.04); }
.complete-btn:active { transform: translateY(0); }
.complete-btn.done {
  background: #d8f5e3; color: var(--good-ink); border-color: #bfead4;
  cursor: default; transform: none; filter: none; box-shadow: var(--shadow-sm);
}
.complete-btn .btn-ico { display: inline-flex; }

.prev-next { display: flex; gap: 14px; justify-content: space-between; margin-top: 28px; flex-wrap: wrap; }
.pn-btn {
  display: flex; flex-direction: column; gap: 2px; text-decoration: none;
  background: #fff; border: 3px solid var(--line); border-radius: 16px;
  padding: 12px 18px; min-width: 200px; flex: 1; box-shadow: var(--shadow); color: var(--ink);
  transition: transform var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out);
}
.pn-btn:hover { transform: translateY(-2px); border-color: var(--rust-orange); }
.pn-next { text-align: right; }
.pn-dir { display: inline-flex; align-items: center; gap: 4px; font-size: .8rem; font-weight: 800; color: var(--ink-soft); }
.pn-next .pn-dir { justify-content: flex-end; }
.pn-title { font-family: var(--font-head); font-weight: 600; }
.pn-finish { background: var(--rust-orange-tint); border-color: var(--rust-orange-soft); } /* flat tint */

/* ---------- Misc pages ---------- */
.page-narrow { max-width: 760px; margin: 0 auto; padding: 30px clamp(16px,4vw,24px) 80px; }
.page-narrow h1 { font-size: 2.2rem; }
.page-narrow a { font-weight: 700; }
.notfound { text-align: center; max-width: 600px; margin: 40px auto; padding: 20px; }
.notfound .ferris { max-width: 200px; }
.notfound .big-btn { justify-content: center; }

/* ---------- Footer ---------- */
.site-footer {
  margin-top: 40px; padding: 28px clamp(16px,4vw,40px);
  background: #fff; border-top: 3px solid var(--line); color: var(--ink-soft);
  text-align: center; font-weight: 600;
}
.footer-small { font-size: .85rem; margin-top: 6px; }

/* ---------- Confetti ---------- */
#confetti-canvas { position: fixed; inset: 0; pointer-events: none; z-index: 9999; }

/* ---------- Animations ---------- */
@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-12px); } }
@keyframes shake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-6px)} 75%{transform:translateX(6px)} }
@keyframes pop { 0%{transform:scale(.6);opacity:0} 60%{transform:scale(1.15)} 100%{transform:scale(1);opacity:1} }
.pop { animation: pop .35s ease; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; scroll-behavior: auto !important; transition: none !important; }
}

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  body { font-size: 17px; }
  .hero { grid-template-columns: 1fr; text-align: center; }
  .hero-art { order: -1; }
  .ferris { max-width: 180px; }
  .hero-sub { margin-left: auto; margin-right: auto; }
  .progress-panel { grid-template-columns: repeat(3, 1fr); }
  .stat-wide { grid-column: 1 / -1; }
  .lesson-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; width: 86%; max-width: 340px;
    background: var(--paper); z-index: 50; transform: translateX(-105%);
    transition: transform .25s ease; border-right: 3px solid var(--line);
    max-height: 100vh; box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-toggle { display: inline-flex; }
}
@media (max-width: 480px) {
  .progress-panel { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .ghost-btn { margin-left: 0; margin-top: 10px; }
  .pn-btn { min-width: 100%; }
}
