/* =========================================================
   網絡小夥伴 — site styles
   Design system: 專案說明 §8
   ========================================================= */

/* ---------- Tokens ---------- */
:root {
  --sky: #4FC3F7;
  --sun: #FFD54F;
  --coral: #FF8A65;
  --mint: #81C784;
  --ink: #263238;
  --paper: #FFFDF7;

  --bg: var(--paper);
  --surface: #FFFFFF;
  --text: #263238;
  --text-muted: #4E5F66;
  --line: #263238;            /* cartoon outlines */
  --shadow: #263238;
  --link: #01579B;            /* AA on paper; sky is used for fills */
  --focus: #0277BD;

  --sky-tint: #E1F5FE;
  --sun-tint: #FFF6D6;
  --coral-tint: #FFEAE3;
  --mint-tint: #E7F5E8;
  --code-bg: #F1F4F5;

  --ok: #2E7D32;
  --bad: #C62828;

  --radius: 16px;
  --radius-sm: 10px;
  --border: 3px solid var(--line);
  --pop: 4px 4px 0 var(--shadow);
  --pop-sm: 3px 3px 0 var(--shadow);

  --font-display: 'Huninn', 'Noto Sans TC', 'PingFang TC', 'Microsoft JhengHei', sans-serif;
  --font-body: 'Noto Sans TC', 'PingFang TC', 'Microsoft JhengHei', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;

  --step--1: 0.875rem;
  --step-0: 1.0625rem;
  --step-1: 1.25rem;
  --step-2: 1.5rem;
  --step-3: clamp(1.75rem, 1.4rem + 1.6vw, 2.25rem);
  --step-4: clamp(2rem, 1.5rem + 2.6vw, 3.125rem);

  --wrap: 1120px;
  --gutter: 16px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #172024;
    --surface: #1F2A2F;
    --text: #F3EFE4;
    --text-muted: #B5C2C7;
    --line: #0A0F11;
    --shadow: #05080A;
    --link: #8FD8FA;
    --focus: #8FD8FA;
    --sky-tint: #13303C;
    --sun-tint: #33301D;
    --coral-tint: #3A2621;
    --mint-tint: #1B3223;
    --code-bg: #26343A;
    --ok: #9CD89F;
    --bad: #FFAB91;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #172024;
  --surface: #1F2A2F;
  --text: #F3EFE4;
  --text-muted: #B5C2C7;
  --line: #0A0F11;
  --shadow: #05080A;
  --link: #8FD8FA;
  --focus: #8FD8FA;
  --sky-tint: #13303C;
  --sun-tint: #33301D;
  --coral-tint: #3A2621;
  --mint-tint: #1B3223;
  --code-bg: #26343A;
  --ok: #9CD89F;
  --bad: #FFAB91;
  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } *, *::before, *::after { animation: none !important; transition: none !important; } }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--step-0);
  line-height: 1.8;
  text-align: start;
}
img { max-width: 100%; height: auto; }
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 400; line-height: 1.35; text-wrap: balance; margin: 0; }
p { margin: 0; }
a { color: var(--link); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: 6px; }
code, kbd { font-family: var(--font-mono); font-size: 0.9em; background: var(--code-bg); padding: 0.1em 0.4em; border-radius: 6px; white-space: nowrap; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--text-muted); }
.center { text-align: center; }
[hidden] { display: none !important; }

.wrap { max-width: var(--wrap); margin-inline: auto; padding-inline: var(--gutter); }
@media (min-width: 720px) { :root { --gutter: 28px; } }

.skip-link { position: absolute; left: 12px; top: -60px; z-index: 100; background: var(--sun); color: #263238; padding: 8px 16px; border: var(--border); border-radius: 999px; font-weight: 700; }
.skip-link:focus { top: 12px; }
#main:focus { outline: none; }

/* ---------- Buttons, pills, chips ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-family: var(--font-display); font-size: var(--step-1); line-height: 1.2;
  padding: 12px 24px; min-height: 48px;
  border: var(--border); border-radius: 999px; box-shadow: var(--pop);
  background: var(--surface); color: var(--text); text-decoration: none; cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease;
}
.btn:hover { transform: translate(-1px, -1px); box-shadow: 5px 5px 0 var(--shadow); }
.btn:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--shadow); }
.btn-primary { background: var(--sun); color: #263238; }
.btn-ghost { background: var(--surface); }
.btn-small { font-size: var(--step-0); padding: 8px 18px; min-height: 44px; box-shadow: var(--pop-sm); }

.pill { display: inline-block; font-size: var(--step--1); font-family: var(--font-body); font-weight: 700; line-height: 1.4; padding: 2px 10px; border: 2px solid var(--line); border-radius: 999px; vertical-align: middle; }
.pill-draft { background: var(--coral-tint); color: var(--text); }
.pill-done { background: var(--mint); color: #263238; }

.chip { font: inherit; font-size: var(--step--1); font-weight: 700; padding: 6px 14px; min-height: 40px; border: 2px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--text); cursor: pointer; }
.chip:hover { background: var(--sky-tint); }
.chip[aria-pressed="true"] { background: var(--sky); color: #263238; }

.icon-btn { font: inherit; width: 40px; height: 40px; border: 2px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--text); cursor: pointer; }
.icon-btn:hover { background: var(--sun-tint); }

.eyebrow { font-weight: 700; font-size: var(--step--1); letter-spacing: .08em; color: var(--text-muted); margin-bottom: 8px; }
.lead { font-size: var(--step-1); color: var(--text-muted); max-width: 40em; }

/* ---------- Header / footer ---------- */
.site-header { background: var(--surface); border-bottom: var(--border); position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; }
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding-block: 8px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); }
.brand img { width: 48px; height: 48px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-name { font-family: var(--font-display); font-size: 1.75rem; line-height: 1.05; }
.brand-tag { font-family: var(--font-display); font-size: 0.8125rem; letter-spacing: 0.02em; color: var(--text-muted); }
.brand-dot { color: #D84315; }
:root[data-theme="dark"] .brand-dot { color: var(--coral); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .brand-dot { color: var(--coral); } }
.site-nav ul { list-style: none; margin: 0; padding: 0; display: flex; gap: 4px; flex-wrap: wrap; }
.site-nav a { display: block; padding: 6px 12px; border-radius: 999px; text-decoration: none; color: var(--text); font-weight: 500; border: 2px solid transparent; }
.site-nav a:hover { border-color: var(--line); }
.site-nav a[aria-current="page"] { background: var(--sun); color: #263238; border-color: var(--line); }
@media (max-width: 560px) {
  .site-header { position: static; }
  .header-inner { flex-direction: column; align-items: stretch; }
  .site-nav ul { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
  .site-nav a { padding: 4px 6px; font-size: 0.8125rem; white-space: nowrap; text-align: center; }
}

.site-footer { margin-top: 64px; border-top: var(--border); background: var(--surface); }
.footer-inner { padding-block: 24px; display: grid; gap: 4px; }
.footer-small { font-size: var(--step--1); color: var(--text-muted); }

/* ---------- Home ---------- */
.home-hero { background: var(--sky-tint); border-bottom: var(--border); overflow: hidden; }
.hero-grid { display: grid; gap: 24px; padding-block: 40px 32px; align-items: center; }
@media (min-width: 860px) { .hero-grid { grid-template-columns: 1.2fr 1fr; padding-block: 64px; } }
.hero-title { font-size: var(--step-4); margin-bottom: 16px; }
.hl-sun { background: linear-gradient(transparent 58%, var(--sun) 58%, var(--sun) 92%, transparent 92%); padding-inline: 2px; }
:root[data-theme="dark"] .hl-sun { color: var(--sun); background: none; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .hl-sun { color: var(--sun); background: none; } }
.hero-lead { font-size: var(--step-1); max-width: 34em; margin-bottom: 24px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 14px; }
.hero-progress { margin-top: 16px; font-weight: 700; }
.hero-art { position: relative; justify-self: center; max-width: 360px; width: 100%; }
.hero-art img { position: relative; z-index: 1; display: block; margin-inline: auto; animation: bob 3.2s ease-in-out infinite; }
.hero-trail { position: absolute; left: -10%; bottom: 0; width: 120%; color: var(--sky); z-index: 0; }
.hero-bubble { position: absolute; z-index: 2; top: 4%; right: 0; background: var(--surface); border: var(--border); border-radius: 20px; padding: 6px 14px; font-family: var(--font-display); box-shadow: var(--pop-sm); }
@keyframes bob { 0%, 100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-10px) rotate(2deg); } }

.home-sec, .home-route { padding-block: 48px 8px; }
.home-route { background: var(--sun-tint); border-block: var(--border); margin-top: 48px; padding-block: 48px; }
.sec-head { margin-bottom: 24px; display: grid; gap: 4px; }
.sec-head h2 { font-size: var(--step-3); }
.sec-head p { color: var(--text-muted); }

.cast { list-style: none; margin: 0; padding: 0; display: grid; gap: 20px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); }
@media (min-width: 860px) { .cast { grid-template-columns: repeat(3, 1fr); } }
.cast-card { background: var(--surface); border: var(--border); border-radius: var(--radius); box-shadow: var(--pop); padding: 16px 18px 20px; display: grid; gap: 4px; align-content: start; }
.cast-card img { width: 140px; height: 140px; justify-self: center; border-radius: 50%; margin-bottom: 4px; }
.cast-sky img { background: var(--sky-tint); } .cast-sun img { background: var(--sun-tint); }
.cast-coral img { background: var(--coral-tint); } .cast-mint img { background: var(--mint-tint); }
.cast-card h3 { font-size: var(--step-2); }
.cast-role { font-weight: 700; font-size: var(--step--1); }
.cast-desc { font-size: var(--step--1); color: var(--text-muted); }
.cast-quote { font-family: var(--font-display); margin-top: 6px; }

.how { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 140px), 1fr)); }
.how li { border: var(--border); border-radius: var(--radius); padding: 16px; background: var(--surface); display: grid; gap: 4px; align-content: start; }
.how-no { width: 36px; height: 36px; border: var(--border); border-radius: 50%; display: grid; place-items: center; font-family: var(--font-display); background: var(--sun); color: #263238; }
.how h3 { font-size: var(--step-1); }
.how p { font-size: var(--step--1); color: var(--text-muted); }

/* ---------- Route (lesson stations) ---------- */
.route { list-style: none; margin: 0 0 24px; padding: 0; position: relative; display: grid; gap: 16px; }
.route::before { content: ""; position: absolute; left: 21px; top: 24px; bottom: 24px; border-left: 4px dashed var(--line); opacity: .35; }
.station-link { display: grid; grid-template-columns: 46px 1fr; gap: 12px; align-items: start; text-decoration: none; color: var(--text); }
.station-dot { position: relative; z-index: 1; width: 46px; height: 46px; border: var(--border); border-radius: 50%; background: var(--sun); color: #263238; display: grid; place-items: center; font-family: var(--font-display); font-size: var(--step-1); margin-top: 10px; }
.station.is-draft .station-dot { background: var(--surface); color: var(--text); }
.station.is-complete .station-dot { background: var(--mint); }
.station-card { display: grid; gap: 4px; background: var(--surface); border: var(--border); border-radius: var(--radius); box-shadow: var(--pop-sm); padding: 12px 16px; transition: transform .12s ease, box-shadow .12s ease; }
.station-link:hover .station-card { transform: translate(-2px, -2px); box-shadow: 6px 6px 0 var(--shadow); }
.station.is-draft .station-card { border-style: dashed; box-shadow: none; }
.station-top { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.station-no { font-weight: 700; font-size: var(--step--1); color: var(--text-muted); }
.station-kicker { font-size: var(--step--1); color: var(--text-muted); }
.station-title { font-family: var(--font-display); font-size: var(--step-1); line-height: 1.4; }
.station-hook { color: var(--text-muted); font-size: var(--step--1); }
.station-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 4px; }
.station-guides { display: flex; }
.station-guides .avatar + .avatar { margin-left: -8px; }
.station-guides .more { font-size: var(--step--1); margin-left: 6px; align-self: center; }
.station-time { font-size: var(--step--1); color: var(--text-muted); }

@media (min-width: 860px) {
  .route-compact { grid-template-columns: repeat(2, 1fr); column-gap: 32px; }
  .route-compact::before { display: none; }
  .route-full { grid-template-columns: 1fr 1fr; column-gap: 72px; row-gap: 0; }
  .route-full::before { left: 50%; transform: translateX(-2px); }
  .route-full .station { grid-column: 1; padding-bottom: 28px; }
  .route-full .station:nth-child(even) { grid-column: 2; margin-top: 72px; }
  .route-full .station-link { grid-template-columns: 1fr 46px; }
  .route-full .station:nth-child(odd) .station-dot { order: 2; position: relative; left: 59px; }
  .route-full .station:nth-child(even) .station-link { grid-template-columns: 46px 1fr; }
  .route-full .station:nth-child(even) .station-dot { margin-left: -59px; }
}
@media (min-width: 860px) {
  /* keep rows paired so the path zigzags */
  .route-full { grid-auto-flow: dense; }
}

.avatar { display: inline-grid; place-items: center; border: 2px solid var(--line); border-radius: 50%; overflow: hidden; background: var(--surface); flex: none; }
.avatar img { display: block; width: 100%; height: 100%; }
.avatar-sky { background: var(--sky-tint); } .avatar-sun { background: var(--sun-tint); }
.avatar-coral { background: var(--coral-tint); } .avatar-mint { background: var(--mint-tint); }
.station-guides .avatar { width: 32px; height: 32px; }

/* ---------- Page hero (map, glossary, about) ---------- */
.page-hero { background: var(--sun-tint); border-bottom: var(--border); padding-block: 40px 32px; margin-bottom: 32px; }
.page-hero-sky { background: var(--sky-tint); }
.page-hero-mint { background: var(--mint-tint); }
.page-hero h1 { font-size: var(--step-4); margin-bottom: 8px; }

.map-progress { margin-top: 20px; max-width: 420px; }
.bar { height: 20px; border: var(--border); border-radius: 999px; background: var(--surface); overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--mint); transition: width .4s ease; }
.bar-label { margin-top: 6px; font-size: var(--step--1); }

.badges { margin-top: 32px; border: var(--border); border-radius: var(--radius); background: var(--surface); padding: 20px; box-shadow: var(--pop); }
.badges h2 { font-size: var(--step-2); }
.badge-list { list-style: none; padding: 0; margin: 16px 0; display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
@media (min-width: 720px) { .badge-list { grid-template-columns: repeat(5, 1fr); } }
.badge { display: grid; justify-items: center; gap: 2px; text-align: center; }
.badge-disc { width: 72px; height: 72px; border-radius: 50%; border: 3px dashed var(--line); display: grid; place-items: center; filter: grayscale(1); opacity: .45; }
.badge-disc img { width: 56px; height: 56px; }
.badge.is-earned .badge-disc { border-style: solid; filter: none; opacity: 1; box-shadow: var(--pop-sm); }
.badge-sky { background: var(--sky-tint); } .badge-sun { background: var(--sun-tint); } .badge-coral { background: var(--coral-tint); } .badge-mint { background: var(--mint-tint); }
.badge-name { font-weight: 700; font-size: var(--step--1); }
.badge-state { font-size: 0.75rem; color: var(--text-muted); }
.reset-note { font-size: var(--step--1); margin-top: 8px; }

/* ---------- Lesson ---------- */
.lesson-hero { border-bottom: var(--border); padding-block: 20px 28px; background: var(--sun-tint); }
.lesson-hero-sky { background: var(--sky-tint); }
.lesson-hero-mint { background: var(--mint-tint); }
.lesson-hero-coral { background: var(--coral-tint); }
.crumbs { font-size: var(--step--1); margin-bottom: 12px; color: var(--text-muted); }
.lesson-hero-grid { display: grid; gap: 16px; align-items: center; }
@media (min-width: 860px) { .lesson-hero-grid { grid-template-columns: 1fr auto; } }
.lesson-no { font-weight: 700; margin-bottom: 4px; }
.lesson-title { font-size: var(--step-4); display: grid; gap: 4px; }
.lesson-kicker { font-size: var(--step-2); color: var(--text-muted); }
.lesson-hook { font-family: var(--font-display); font-size: var(--step-1); margin-top: 12px; padding: 10px 16px; background: var(--surface); border: var(--border); border-radius: 18px 18px 18px 4px; display: inline-block; box-shadow: var(--pop-sm); }
.lesson-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; font-size: var(--step--1); color: var(--text-muted); }
.lesson-hero-art { display: none; }
@media (min-width: 860px) { .lesson-hero-art { display: flex; } .lesson-hero-art img { width: 180px; height: 180px; } .lesson-hero-art img + img { margin-left: -40px; } }

.lesson-layout { display: grid; gap: 32px; padding-top: 32px; }
@media (min-width: 1000px) { .lesson-layout:not(.is-draft) { grid-template-columns: 220px minmax(0, 1fr); } }
.lesson-toc { display: none; }
@media (min-width: 1000px) {
  .lesson-toc { display: block; position: sticky; top: 90px; align-self: start; }
  .toc-title { font-family: var(--font-display); font-size: var(--step-1); margin-bottom: 8px; }
  .lesson-toc ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
  .lesson-toc a { display: flex; gap: 10px; align-items: center; padding: 6px 10px; border-radius: 10px; text-decoration: none; color: var(--text); font-size: var(--step--1); border: 2px solid transparent; }
  .lesson-toc a:hover, .lesson-toc a.is-current { border-color: var(--line); background: var(--surface); }
  .toc-no { width: 24px; height: 24px; flex: none; border: 2px solid var(--line); border-radius: 50%; display: grid; place-items: center; font-size: 0.75rem; font-weight: 700; }
  .lesson-toc a.is-current .toc-no { background: var(--sun); color: #263238; }
}
.lesson-body { min-width: 0; display: grid; gap: 28px; }

.lesson-sec { background: var(--surface); border: var(--border); border-radius: var(--radius); box-shadow: var(--pop); padding: 20px; scroll-margin-top: 90px; min-width: 0; }
@media (min-width: 720px) { .lesson-sec { padding: 28px 32px; } }
.lesson-sec > h2 { font-size: var(--step-3); display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.sec-badge { width: 44px; height: 44px; flex: none; display: grid; place-items: center; border: var(--border); border-radius: 12px; font-size: var(--step-1); background: var(--sky); color: #263238; transform: rotate(-4deg); }
.sec-no { color: var(--text-muted); font-size: 0.8em; }
.sec-concept .sec-badge { background: var(--sun); }
.sec-tryit { background: var(--sun-tint); } .sec-tryit .sec-badge { background: var(--sun); }
.sec-limits { background: var(--coral-tint); } .sec-limits .sec-badge { background: var(--coral); }
.sec-quiz .sec-badge { background: var(--sky); }
.sec-notes { background: var(--mint-tint); } .sec-notes .sec-badge { background: var(--mint); }
.sec-concept .prose { font-size: var(--step-1); }
.sec-next { box-shadow: none; border-style: dashed; display: grid; gap: 16px; }
.sec-next > h2 { margin-bottom: 0; }

/* Prose inside lessons */
.prose { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; max-width: 70ch; }
.prose p code, .prose li code { white-space: normal; overflow-wrap: anywhere; }
.prose > * { margin: 0; }
.prose h3 { font-size: var(--step-2); margin-top: 16px; }
.prose h4 { font-size: var(--step-1); }
.prose ul, .prose ol { padding-left: 1.4em; display: grid; gap: 6px; }
.prose li > ul { margin-top: 6px; }
.prose blockquote { border: var(--border); border-radius: var(--radius-sm); background: var(--sky-tint); padding: 12px 16px; display: grid; gap: 8px; }
.sec-tryit .prose blockquote, .sec-limits .prose blockquote { background: var(--surface); }
.prose blockquote p { margin: 0; }
.prose img { display: block; border: var(--border); border-radius: var(--radius-sm); background: #FFFDF7; }
.prose p > em:only-child { display: block; font-size: var(--step--1); color: var(--text-muted); font-style: normal; margin-top: -6px; }
.prose table { border-collapse: collapse; width: 100%; font-size: var(--step--1); line-height: 1.6; }
.prose th, .prose td { border: 2px solid var(--line); padding: 8px 10px; vertical-align: top; text-align: start; }
.prose th { background: var(--sun-tint); font-weight: 700; }
.sec-tryit .prose th { background: var(--surface); }
.prose td code { white-space: nowrap; }
.table-scroll, .prose .table-wrap { overflow-x: auto; }
.prose details { border: 2px solid var(--line); border-radius: var(--radius-sm); padding: 8px 14px; background: var(--surface); }
.prose summary { cursor: pointer; font-weight: 700; }
.deeper-wide { max-width: none; }
.sec-deeper .prose { max-width: none; }
.sec-deeper .prose > p, .sec-deeper .prose > ul, .sec-deeper .prose > ol, .sec-deeper .prose > h3 { max-width: 70ch; }

/* Comic */
.comic { display: grid; gap: 14px; }
@media (min-width: 720px) { .comic { grid-template-columns: 1fr 1fr; } }
.panel { margin: 0; position: relative; border: var(--border); border-radius: 12px; overflow: hidden; background: #FFFDF7; box-shadow: var(--pop-sm); }
.panel img { display: block; width: 100%; height: auto; }
.panel-no { position: absolute; top: 8px; left: 8px; width: 32px; height: 32px; display: grid; place-items: center; border: 2px solid #263238; border-radius: 50%; background: #FFD54F; color: #263238; font-family: var(--font-display); font-size: var(--step-0); }
.comic-script { margin-top: 16px; border: 2px dashed var(--line); border-radius: var(--radius-sm); padding: 8px 14px; }
.comic-script summary { cursor: pointer; font-weight: 700; }
.comic-script .prose { margin-top: 10px; max-width: none; }

/* Try-it tasks & games */
.sec-tryit { display: grid; gap: 20px; }
.sec-tryit > h2 { margin-bottom: 0; }
.task { display: grid; gap: 10px; }
.task h3 { font-size: var(--step-2); }
.game { background: var(--surface); border: var(--border); border-radius: var(--radius); padding: 18px; display: grid; gap: 12px; box-shadow: var(--pop-sm); }
.game-label { font-size: var(--step--1); font-weight: 700; letter-spacing: .08em; color: var(--text-muted); }
.game-title { font-size: var(--step-2); margin-top: -8px; }
.game-done { font-weight: 700; padding: 10px 14px; border: 2px solid var(--line); border-radius: var(--radius-sm); background: var(--mint-tint); }

.sort-cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr)); }
.sort-card { border: 2px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; display: grid; gap: 8px; align-content: start; background: var(--bg); }
.sort-text { display: flex; gap: 8px; align-items: baseline; }
.sort-no { font-weight: 700; color: var(--text-muted); }
.sort-choices { display: flex; flex-wrap: wrap; gap: 6px; }
.sort-feedback { font-size: var(--step--1); }
.sort-card.is-right { border-color: var(--ok); background: var(--mint-tint); }
.sort-card.is-wrong { border-color: var(--bad); }
.fb-ok { color: var(--ok); font-weight: 700; }
.fb-bad { color: var(--bad); font-weight: 700; }

.order-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; counter-reset: ord; }
.order-item { counter-increment: ord; display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; border: 2px solid var(--line); border-radius: var(--radius-sm); padding: 8px 10px; background: var(--bg); }
.order-item::before { content: counter(ord); width: 28px; height: 28px; border: 2px solid var(--line); border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: var(--step--1); }
.order-year { grid-column: 2; font-family: var(--font-mono); font-size: var(--step--1); font-weight: 600; }
.order-btns { grid-row: 1 / span 2; grid-column: 3; display: flex; gap: 6px; }
.order-item.is-right { border-color: var(--ok); background: var(--mint-tint); }
.order-item.is-wrong { border-color: var(--bad); }
.order-feedback { font-weight: 700; }

/* Quiz */
.quiz { display: grid; gap: 18px; }
.quiz-q { border: var(--border); border-radius: var(--radius); padding: 16px; margin: 0; display: grid; gap: 12px; background: var(--bg); min-width: 0; }
.quiz-q legend { font-family: var(--font-display); font-size: var(--step-1); padding: 0 6px; display: grid; gap: 2px; float: left; width: 100%; }
.quiz-q legend + * { clear: both; }
.quiz-count { font-family: var(--font-body); font-size: var(--step--1); font-weight: 700; color: var(--text-muted); }
.quiz-options { display: grid; gap: 8px; }
.quiz-option { display: flex; gap: 10px; align-items: center; border: 2px solid var(--line); border-radius: var(--radius-sm); padding: 8px 12px; cursor: pointer; background: var(--surface); }
.quiz-option:hover { background: var(--sky-tint); }
.quiz-option input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.opt-letter { width: 30px; height: 30px; flex: none; border: 2px solid var(--line); border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: var(--step--1); }
.quiz-option:has(input:checked) { background: var(--sky-tint); outline: 3px solid var(--sky); }
.quiz-option:has(input:checked) .opt-letter { background: var(--sky); color: #263238; }
.quiz-option:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
.quiz-option.is-answer { background: var(--mint-tint); border-color: var(--ok); }
.quiz-option.is-answer .opt-letter::after { content: "✓"; }
.quiz-option.is-answer .opt-letter { background: var(--mint); color: #263238; font-size: 0; }
.quiz-option.is-answer .opt-letter::after { font-size: var(--step-0); }
.quiz-option.is-wrong-pick { border-color: var(--bad); border-style: dashed; }
.quiz-q .quiz-check { justify-self: start; }
.quiz-feedback:empty { display: none; }
.quiz-feedback { border: 2px solid var(--line); border-radius: var(--radius-sm); padding: 10px 14px; background: var(--surface); display: grid; gap: 4px; }
.quiz-score { font-family: var(--font-display); font-size: var(--step-2); padding: 12px 16px; border: var(--border); border-radius: var(--radius); background: var(--sun); color: #263238; }

/* Done button + pager */
.btn-done { justify-self: start; background: var(--surface); }
.btn-done .done-on { display: none; }
.btn-done[aria-pressed="true"] { background: var(--mint); color: #263238; }
.btn-done[aria-pressed="true"] .done-on { display: inline; }
.btn-done[aria-pressed="true"] .done-off { display: none; }
.pager { display: grid; gap: 12px; }
@media (min-width: 720px) { .pager { grid-template-columns: 1fr 1fr; } }
.pager-link { display: grid; gap: 2px; border: var(--border); border-radius: var(--radius); padding: 12px 16px; text-decoration: none; color: var(--text); background: var(--surface); box-shadow: var(--pop-sm); }
.pager-link:hover { background: var(--sun-tint); }
.pager-next { text-align: start; }
@media (min-width: 720px) { .pager-next { text-align: end; } }
.pager-label { font-weight: 700; font-size: var(--step--1); color: var(--text-muted); }
.pager-title { font-family: var(--font-display); }

/* Coming soon */
.coming-soon { background: var(--sun-tint); }
.coming-inner { display: grid; gap: 16px; align-items: center; }
@media (min-width: 720px) { .coming-inner { grid-template-columns: auto 1fr; } }
.coming-inner h2 { font-size: var(--step-3); margin-bottom: 8px; }
.coming-inner > div { display: grid; gap: 8px; }
.avatar-lg { width: 120px; height: 120px; border-width: 3px; }

/* Glossary pop-up (in lessons) */
.term { font: inherit; color: inherit; background: none; border: 0; padding: 0; border-bottom: 2px dotted currentColor; cursor: help; }
.term:hover { background: var(--sun-tint); }
.term-pop { position: absolute; z-index: 50; max-width: min(320px, calc(100vw - 32px)); background: var(--surface); border: var(--border); border-radius: var(--radius-sm); box-shadow: var(--pop); padding: 12px 14px; display: grid; gap: 4px; font-size: var(--step--1); line-height: 1.6; }
.term-pop-title { font-family: var(--font-display); font-size: var(--step-1); }
.term-pop-close { position: absolute; top: 4px; right: 4px; width: 32px; height: 32px; border: 0; background: none; color: var(--text); font-size: 1.25rem; cursor: pointer; }
.tag { display: inline-block; font-size: 0.75rem; font-weight: 700; border: 2px solid var(--line); border-radius: 999px; padding: 0 8px; margin-right: 6px; background: var(--sun); color: #263238; }

/* ---------- Glossary page ---------- */
.search { display: block; margin-top: 20px; max-width: 520px; }
.search input { width: 100%; font: inherit; padding: 12px 18px; border: var(--border); border-radius: 999px; background: var(--surface); color: var(--text); box-shadow: var(--pop-sm); }
.gloss-count { margin-top: 8px; font-size: var(--step--1); }
.gloss-jump { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 24px; }
.gloss-jump a { padding: 4px 14px; border: 2px solid var(--line); border-radius: 999px; text-decoration: none; color: var(--text); background: var(--surface); font-size: var(--step--1); }
.gloss-jump a:hover { background: var(--sun-tint); }
.gloss-group { margin-bottom: 36px; scroll-margin-top: 90px; }
.gloss-group h2 { font-size: var(--step-3); margin-bottom: 12px; }
.gloss-list { margin: 0; display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); }
.gloss-item { border: var(--border); border-radius: var(--radius); background: var(--surface); padding: 14px 16px; display: grid; gap: 6px; align-content: start; }
.gloss-item dt { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 2px; }
.gloss-en { font-family: var(--font-display); font-size: var(--step-1); }
.gloss-zh { font-weight: 700; }
.gloss-full { flex-basis: 100%; font-size: 0.8rem; color: var(--text-muted); }
.gloss-item dd { margin: 0; display: grid; gap: 6px; font-size: var(--step--1); }
.gloss-analogy { display: block; }

/* ---------- About ---------- */
.prose-page { display: grid; gap: 28px; max-width: 760px; }
.prose-page section { display: grid; gap: 10px; }
.prose-page h2 { font-size: var(--step-2); }
.prose-page ul { margin: 0; padding-left: 1.4em; display: grid; gap: 4px; }

/* ---------- Sections: zones (home) ---------- */
.zones { list-style: none; margin: 0; padding: 0; display: grid; gap: 20px; }
@media (min-width: 860px) { .zones { grid-template-columns: 1fr 1fr; } }
.zone a { display: grid; grid-template-columns: auto 1fr; gap: 16px; align-items: center; height: 100%; padding: 20px; border: var(--border); border-radius: var(--radius); box-shadow: var(--pop); text-decoration: none; color: var(--text); transition: transform .12s ease, box-shadow .12s ease; }
.zone a:hover { transform: translate(-2px, -2px); box-shadow: 6px 6px 0 var(--shadow); }
.zone-course a { background: var(--sun-tint); }
.zone-stories a { background: var(--coral-tint); }
.zone-art { display: flex; }
.zone-art img { width: 84px; height: 84px; background: var(--surface); border: var(--border); border-radius: 50%; }
.zone-art img + img { margin-left: -28px; }
.zone-body { display: grid; gap: 4px; }
.zone-kicker { font-weight: 700; font-size: var(--step--1); color: var(--text-muted); letter-spacing: .06em; }
.zone-title { font-family: var(--font-display); font-size: var(--step-2); line-height: 1.35; }
.zone-desc { font-size: var(--step--1); }
.zone-meta { font-size: var(--step--1); font-weight: 700; margin-top: 4px; }
@media (max-width: 480px) { .zone a { grid-template-columns: 1fr; } }

/* ---------- Stories ---------- */
.page-hero-coral { background: var(--coral-tint); }
.story-filter { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.story-count { font-size: var(--step--1); margin-bottom: 8px; min-height: 1.8em; }
.story-grid { list-style: none; margin: 0 0 24px; padding: 0; display: grid; gap: 20px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); }
.story-link { display: grid; height: 100%; text-decoration: none; color: var(--text); background: var(--surface); border: var(--border); border-radius: var(--radius); box-shadow: var(--pop-sm); overflow: hidden; transition: transform .12s ease, box-shadow .12s ease; }
.story-link:hover { transform: translate(-2px, -2px); box-shadow: 6px 6px 0 var(--shadow); }
.story-card.is-draft .story-link { border-style: dashed; box-shadow: none; }
.story-art { display: flex; justify-content: center; gap: 0; padding: 16px; background: var(--coral-tint); border-bottom: var(--border); }
.story-art img { width: 96px; height: 96px; }
.story-art img + img { margin-left: -16px; }
.story-body { display: grid; gap: 6px; padding: 14px 16px 18px; align-content: start; }
.story-title { font-family: var(--font-display); font-size: var(--step-1); line-height: 1.4; }
.story-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.lesson-hero .story-tags { margin-top: 12px; }
.topic-chip { font-size: 0.8rem; font-weight: 700; padding: 1px 10px; border: 2px solid var(--line); border-radius: 999px; background: var(--surface); }
.pill-level { background: var(--sky-tint); color: var(--text); }
.story-card.is-complete .pill-done { display: inline-block; }
.prereq { margin-top: 10px; font-size: var(--step--1); }
.story-note { border: 2px dashed var(--line); border-radius: var(--radius); padding: 16px 20px; display: grid; gap: 6px; max-width: 760px; }
.story-note h2 { font-size: var(--step-1); }
.related { display: grid; gap: 6px; }
.related-title { font-weight: 700; }
.related ul { margin: 0; padding-left: 1.2em; }
.sec-story .sec-badge { background: var(--coral); }
.sec-story .prose { font-size: var(--step-1); }
.sec-problem { background: var(--coral-tint); } .sec-problem .sec-badge { background: var(--coral); }

/* ---------- Course map: how a lesson works ---------- */
.how-sec { margin-top: 40px; display: grid; gap: 8px; }
.how-sec h2 { font-size: var(--step-3); }
.how-sec .how { margin-top: 8px; }

.coming-avatars { display: flex; }
.coming-avatars .avatar + .avatar { margin-left: -28px; }

/* ---------- Home: course block + story list ---------- */
.home-top { padding-top: 28px; }
.course-block { position: relative; display: grid; gap: 16px; align-items: center; background: var(--sky-tint); border: var(--border); border-radius: 24px; box-shadow: 6px 6px 0 var(--shadow); padding: 24px 20px; overflow: hidden; }
@media (min-width: 860px) { .course-block { grid-template-columns: 1fr auto; padding: 36px 40px; } }
.course-copy { display: grid; gap: 12px; }
.course-title { font-size: var(--step-4); }
.course-lead { font-size: var(--step-1); max-width: 34em; }
.course-dots { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.course-dots li { display: flex; align-items: center; }
.course-dots li + li::before { content: ""; width: 10px; border-top: 3px dotted var(--line); margin-right: 8px; opacity: .5; }
.course-dots a { width: 40px; height: 40px; display: grid; place-items: center; border: var(--border); border-radius: 50%; background: var(--sun); color: #263238; text-decoration: none; font-family: var(--font-display); font-size: var(--step-0); transition: transform .12s ease; }
.course-dots a:hover { transform: translateY(-3px); }
.course-dots .is-draft a { background: var(--surface); color: var(--text); border-style: dashed; }
.course-dots .is-complete a { background: var(--mint); color: #263238; border-style: solid; }
.course-meta { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: var(--step--1); font-weight: 700; }
.course-meta .hero-progress { margin: 0; }
.course-art { position: relative; justify-self: center; width: min(280px, 70vw); }
.course-art img { display: block; width: 100%; height: auto; animation: bob 3.2s ease-in-out infinite; }
.course-art .hero-bubble { top: 0; right: -8px; }
@media (max-width: 859px) { .course-art { order: -1; width: 160px; } .course-art .hero-bubble { display: none; } }

.home-stories { padding-top: 48px; }
.sec-head-row { display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: end; justify-content: space-between; }
.sec-head-row > div { display: grid; gap: 4px; max-width: 44em; }
.story-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.story-row-link { display: grid; grid-template-columns: auto 1fr auto; gap: 16px; align-items: center; padding: 14px 18px; background: var(--surface); border: var(--border); border-radius: var(--radius); box-shadow: var(--pop-sm); text-decoration: none; color: var(--text); transition: transform .12s ease, box-shadow .12s ease; }
.story-row-link:hover { transform: translate(-2px, -2px); box-shadow: 6px 6px 0 var(--shadow); }
.story-row.is-draft .story-row-link { border-style: dashed; box-shadow: none; }
.story-row-art { display: flex; width: 104px; height: 72px; align-items: center; justify-content: center; background: var(--coral-tint); border: 2px solid var(--line); border-radius: 14px; }
.story-row-art img { width: 60px; height: 60px; }
.story-row-art img + img { margin-left: -14px; }
.story-row-body { display: grid; gap: 4px; min-width: 0; }
.story-row-time { font-size: var(--step--1); color: var(--text-muted); }
.story-row-foot { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; }
.story-row-pre { font-size: var(--step--1); color: var(--text-muted); }
.story-row-go { font-family: var(--font-display); font-size: var(--step-2); }
.story-row.is-complete .pill-done { display: inline-block; }
@media (max-width: 560px) {
  .story-row-link { grid-template-columns: auto 1fr; gap: 12px; align-items: start; padding: 12px 14px; }
  .story-row-art { width: 64px; height: 64px; flex-direction: column; }
  .story-row-art img { width: 44px; height: 44px; }
  .story-row-art img + img { display: none; }
  .story-row-go { display: none; }
}
@media (max-width: 559px) {
  .course-dots { display: grid; grid-template-columns: repeat(5, 40px); justify-content: space-between; gap: 10px 0; }
  .course-dots li + li::before { display: none; }
}

/* ---------- Comic reader (full screen) ---------- */
.comic-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-bottom: 14px; font-size: var(--step--1); }
.panel-btn { display: block; width: 100%; padding: 0; border: 0; background: none; cursor: zoom-in; position: relative; }
.panel-zoom { position: absolute; right: 10px; top: 10px; width: 36px; height: 36px; display: grid; place-items: center; border: 2px solid #263238; border-radius: 10px; background: #FFFDF7; color: #263238; font-size: 1.1rem; opacity: 0; transition: opacity .15s ease; }
.panel-btn:hover .panel-zoom, .panel-btn:focus-visible .panel-zoom { opacity: 1; }
@media (hover: none) { .panel-zoom { opacity: .9; } }

.reader { position: fixed; inset: 0; z-index: 200; width: 100vw; height: 100vh; height: 100dvh; overflow: hidden; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; grid-template-columns: minmax(0, 1fr); background: #141C20; color: #FFFDF7; padding: env(safe-area-inset-top, 0px) 0 env(safe-area-inset-bottom, 0px); }
.reader[hidden] { display: none !important; }
.reader-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; min-width: 0; }
.reader-count { font-family: var(--font-display); font-size: var(--step-1); white-space: nowrap; }
.reader-close { font: inherit; font-weight: 700; display: inline-flex; align-items: center; gap: 6px; flex: none; min-height: 44px; padding: 8px 16px; border: 3px solid #0A0F11; border-radius: 999px; background: #FFD54F; color: #263238; box-shadow: 3px 3px 0 #0A0F11; cursor: pointer; white-space: nowrap; }
.reader-stage { position: relative; min-height: 0; min-width: 0; padding: 4px 84px; }
.reader-figure { position: relative; margin: 0; width: 100%; height: 100%; touch-action: pan-y; }
.reader-figure img { position: absolute; inset: 0; margin: auto; max-width: 100%; max-height: 100%; width: auto; height: auto; border: 3px solid #0A0F11; border-radius: 14px; background: #FFFDF7; box-shadow: 6px 6px 0 #05080A; }
.reader-nav { position: absolute; top: 50%; transform: translateY(-50%); z-index: 2; width: 60px; height: 60px; display: grid; place-items: center; border: 3px solid #0A0F11; border-radius: 50%; background: #FFFDF7; color: #263238; font-size: 2rem; line-height: 1; cursor: pointer; box-shadow: 3px 3px 0 #05080A; }
.reader-prev { left: 14px; } .reader-next { right: 14px; }
.reader-nav:disabled { opacity: .25; cursor: default; }
.reader-nav:not(:disabled):hover { background: #FFD54F; }
.reader-foot { display: grid; gap: 8px; padding: 10px 16px 14px; min-width: 0; }
.reader-caption { max-width: 60rem; margin: 0 auto; padding-bottom: 4px; font-size: var(--step-0); line-height: 1.7; text-align: center; max-height: 35vh; overflow-y: auto; }
.reader-caption:empty { display: none; }
.reader-caption.has-more { -webkit-mask-image: linear-gradient(#000 70%, transparent); mask-image: linear-gradient(#000 70%, transparent); }
.reader-caption code { background: rgba(255,255,255,.12); color: inherit; }
.reader-controls { display: flex; align-items: center; justify-content: center; gap: 14px; flex-wrap: wrap; }
.reader-dots { display: flex; gap: 10px; }
.reader-dots button { width: 14px; height: 14px; padding: 0; border-radius: 50%; border: 2px solid #FFFDF7; background: transparent; cursor: pointer; }
.reader-dots button[aria-current="true"] { background: #FFD54F; border-color: #FFD54F; }
.reader-hint { font-size: var(--step--1); color: #B5C2C7; }
.reader-hint kbd { background: rgba(255,255,255,.14); color: #FFFDF7; border: 1px solid rgba(255,255,255,.3); }
.reader :focus-visible { outline: 3px solid #8FD8FA; outline-offset: 3px; }
@media (max-width: 640px) {
  .reader-stage { padding: 4px 10px; }
  .reader-nav { width: 44px; height: 44px; font-size: 1.5rem; }
  .reader-prev { left: 4px; } .reader-next { right: 4px; }
  .reader-hint { display: none; }
  .reader-count { font-size: var(--step-0); }
  .reader-close { padding: 6px 12px; }
}
@media (max-height: 520px) {
  .reader-caption { display: none; }
  .reader-bar { padding-block: 6px; }
}
body.reader-open { overflow: hidden; }

/* ---------- Step-by-step animation player ---------- */
.anim { display: grid; gap: 12px; }
.anim:focus { outline: none; }
.anim-head { display: grid; gap: 2px; }
.anim-chapter { font-size: var(--step--1); font-weight: 700; letter-spacing: .04em; color: var(--text-muted); }
.anim-chapter:empty { display: none; }
.anim-count { font-size: var(--step--1); font-weight: 700; }
.anim-title { font-family: var(--font-display); font-size: var(--step-2); line-height: 1.35; }
.anim-stage { position: relative; border: var(--border); border-radius: var(--radius); background: #F4FAFD; overflow: hidden; box-shadow: var(--pop-sm); }
.anim-svg { display: block; width: 100%; height: auto; aspect-ratio: 800 / 480; }
.anim-counter { position: absolute; left: 12px; top: 10px; margin: 0; padding: 4px 12px; border: 2px solid #263238; border-radius: 999px; background: #FF8A65; color: #263238; font-weight: 700; font-size: var(--step--1); font-variant-numeric: tabular-nums; }
.anim-talk { display: grid; grid-template-columns: auto 1fr; gap: 12px; align-items: start; }
.anim-avatar { width: 72px; height: 72px; border: var(--border); border-radius: 50%; background: var(--surface); }
.anim-avatar.avatar-sky { background: var(--sky-tint); } .anim-avatar.avatar-sun { background: var(--sun-tint); }
.anim-avatar.avatar-coral { background: var(--coral-tint); } .anim-avatar.avatar-mint { background: var(--mint-tint); }
.anim-bubble { position: relative; background: var(--surface); border: var(--border); border-radius: 18px; padding: 12px 16px; display: grid; gap: 6px; min-height: 96px; }
.anim-bubble::before { content: ""; position: absolute; left: -13px; top: 22px; border: 10px solid transparent; border-right-color: var(--line); border-left: 0; }
.anim-speaker { font-weight: 700; font-size: var(--step--1); color: var(--text-muted); }
.anim-say { font-size: var(--step-1); line-height: 1.7; }
.anim-note { margin: 4px 0 0; padding: 10px 14px 10px 1.8em; background: var(--sun-tint); border: 2px dashed var(--line); border-radius: 12px; display: grid; gap: 2px; font-size: var(--step--1); }
.anim-controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.anim-next { margin-left: auto; }
.anim-controls .btn:disabled { opacity: .4; cursor: default; transform: none; box-shadow: none; }
.anim-dots { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.anim-dots button { width: 16px; height: 16px; padding: 0; border: 2px solid var(--line); border-radius: 50%; background: var(--surface); cursor: pointer; }
.anim-dots button.is-past { background: var(--sky); }
.anim-dots button[aria-current="step"] { background: var(--sun); transform: scale(1.25); }
.anim-transcript { border: 2px dashed var(--line); border-radius: var(--radius-sm); padding: 8px 14px; }
.anim-transcript summary { cursor: pointer; font-weight: 700; }
.anim-transcript ol { margin: 10px 0 0; padding-left: 1.4em; display: grid; gap: 8px; font-size: var(--step--1); }
.anim-transcript .anim-tr-chapter { list-style: none; margin-left: -1.4em; font-weight: 700; margin-top: 8px; }
@media (max-width: 560px) {
  .lesson-sec.sec-story { padding: 16px 10px; }
  .anim-talk { grid-template-columns: 44px 1fr; gap: 8px; }
  .anim-avatar { width: 44px; height: 44px; border-width: 2px; }
  .anim-bubble::before { display: none; }
  .anim-say { font-size: var(--step-0); }
  .anim-next { margin-left: 0; }
  .anim-controls .btn { flex: 1 1 40%; }
}

/* SVG drawing (colours fixed: the stage is always light) */
.anim-svg text { font-family: var(--font-body); }
.an-link line { stroke: #263238; stroke-width: 5; stroke-linecap: round; }
.an-link-hot .an-glow { stroke: #FFD54F; stroke-width: 16; }
.an-link-blocked line { stroke: #FF8A65; stroke-dasharray: 10 10; }
.an-link-cut line { stroke: #90A4AE; stroke-dasharray: 4 8; }
.an-x { stroke: #E53935; stroke-width: 6; stroke-linecap: round; fill: none; }
.an-cut-text { font-size: 15px; font-weight: 700; fill: #C62828; }
.an-halo { fill: #FFFDF7; stroke: #263238; stroke-width: 3; }
.an-halo-sky { fill: #E1F5FE; }
.an-dev { stroke: #263238; stroke-width: 4; }
.an-dev-sky { fill: #4FC3F7; } .an-dev-mint { fill: #81C784; } .an-dev-coral { fill: #FF8A65; }
.an-screen { fill: #FFFDF7; stroke: #263238; stroke-width: 3; }
.an-stroke { stroke: #263238; stroke-width: 4; fill: none; stroke-linecap: round; }
.an-thin { stroke-width: 2.5; }
.an-dot { fill: #263238; }
.an-label-bg { fill: #FFFDF7; stroke: #263238; stroke-width: 2.5; }
.an-label { font-size: 15px; font-weight: 700; fill: #263238; }
.an-sub { font-size: 12px; fill: #4E5F66; font-family: var(--font-mono) !important; }
.an-badge { fill: #FFD54F; stroke: #263238; stroke-width: 2.5; }
.an-badge-text { font-size: 13px; font-weight: 700; fill: #263238; }
.an-port { fill: #FFFDF7; stroke: #263238; stroke-width: 2; }
.an-port-dp { fill: #81C784; } .an-port-rp { fill: #4FC3F7; } .an-port-bp { fill: #FF8A65; }
.an-port-p1, .an-port-p2, .an-port-p3, .an-port-p4 { fill: #FFFDF7; }
.an-port-text { font-size: 12px; font-weight: 700; fill: #263238; }
.an-ring { fill: none; stroke: #FF8A65; stroke-width: 4; }
.an-bpdu { fill: #FFD54F; stroke: #263238; stroke-width: 2.5; }
.an-bpdu-text { font-size: 11px; font-weight: 700; fill: #263238; }
.an-marker.is-stopped image { opacity: .55; }
.an-stopx { display: none; stroke: #E53935; stroke-width: 5; stroke-linecap: round; fill: none; }
.an-marker.is-stopped .an-stopx { display: inline; }

/* Story parts */
.story-part { display: grid; gap: 12px; margin-bottom: 28px; }
.story-part-title { font-family: var(--font-display); font-size: var(--step-2); display: flex; align-items: center; gap: 10px; }
.story-part-title::after { content: ""; flex: 1; border-top: 3px dotted var(--line); opacity: .35; }
.story-no { font-family: var(--font-mono); font-weight: 600; color: var(--text-muted); font-size: .85em; }

/* Animation extensions: more devices, link modes and message tags */
.an-halo-mint { fill: #E8F5E9; } .an-halo-coral { fill: #FBE9E7; }
.an-dev-grey { fill: #B0BEC5; } .an-dev-sun { fill: #FFD54F; } .an-dev-cloud { fill: #E1F5FE; }
.an-thin-b { stroke-width: 2; }
.an-dot-mint { fill: #2E7D32; }
.an-node.is-dim { opacity: .3; }
.an-link-wifi line { stroke: #0288D1; stroke-width: 4; stroke-dasharray: 2 10; }
.an-link-trunk .an-wide { stroke: #FFD54F; stroke-width: 14; }
.an-link-bundle .an-strand { stroke: #263238; stroke-width: 4; }
.an-link-tunnel .an-tube { stroke: #FF8A65; stroke-width: 20; stroke-opacity: .55; }
.an-link-sky line { stroke: #0288D1; stroke-width: 6; }
.an-link-coral line { stroke: #E64A19; stroke-width: 6; stroke-dasharray: 14 6; }
.an-link-mint line { stroke: #2E7D32; stroke-width: 6; }
.an-linklabel { fill: #FFFDF7; stroke: #263238; stroke-width: 2; }
.an-linklabel-text { font-size: 12px; font-weight: 700; fill: #263238; }
.an-ring-mint { stroke: #2E7D32; }
.an-lock { fill: #FFD54F; stroke: #263238; stroke-width: 2; }
.an-tag { fill: #FFFDF7; stroke: #263238; stroke-width: 2; }
.an-tag-text { font-size: 11px; font-weight: 700; fill: #263238; }
.an-tone-sky { fill: #B3E5FC; } .an-tone-coral { fill: #FFCCBC; } .an-tone-mint { fill: #C8E6C9; } .an-tone-sun { fill: #FFE082; }
.an-port-v10 { fill: #B3E5FC; } .an-port-v20 { fill: #FFCCBC; } .an-port-trunk, .an-port-po1 { fill: #FFE082; }

/* Wide code blocks and tables scroll inside their own box instead of widening the page */
.prose pre { max-width: 100%; overflow-x: auto; padding: 12px 14px; background: var(--surface); border: 2px solid var(--line); border-radius: var(--radius-sm); font-size: var(--step--1); line-height: 1.6; }
.prose pre code { white-space: pre; }
.prose, .lesson-body, .lesson-sec, .lesson-sec > *, .task { min-width: 0; }
@media (max-width: 700px) {
  .prose table { display: block; overflow-x: auto; width: auto; max-width: 100%; }
}
.game, .game * { min-width: 0; } .order-text, .sort-text { overflow-wrap: anywhere; }

/* =========================================================
   Network Buddies Pro — "engineer mode" styles
   Appended to site.css at build time (see src/build.mjs).
   Theme: ink #263238 + sun #FFD54F; terminals are always dark.
   ========================================================= */
:root {
  --term-bg: #172126;
  --term-text: #E3ECEF;
  --term-muted: #9FB3BB;
  --term-cmd: #7FD6FB;
  --term-log: #FFD54F;
  --term-err: #FFAB91;
  --term-note: #9CD89F;
  --pro-bg: #263238;
  --pro-text: #FFFDF7;
}

/* ---------- Pro hero (catalogue + lesson) ---------- */
.page-hero-pro, .lesson-hero-pro {
  --text: var(--pro-text);
  --text-muted: #CFD8DC;
  --link: var(--sun);
  background: var(--pro-bg);
  color: var(--pro-text);
}
.page-hero-pro .eyebrow, .lesson-hero-pro .lesson-no { color: var(--sun); }
.page-hero-pro code, .lesson-hero-pro code { background: rgba(255, 255, 255, 0.12); color: inherit; }
.lesson-hero-pro .topic-chip { background: rgba(255, 255, 255, 0.1); color: var(--pro-text); border-color: rgba(255, 255, 255, 0.45); }
.lesson-hero-pro .lesson-hook { background: rgba(255, 255, 255, 0.08); color: var(--pro-text); border-color: var(--sun); }
.lesson-hero-pro .chip-exam, .chip-exam { background: var(--sun); color: #263238; border-color: #263238; }
.lesson-hero-pro .lesson-hero-art img { background: rgba(255, 255, 255, 0.08); border-radius: 50%; }
.pro-hero { display: grid; gap: 20px; align-items: center; }
.pro-count { margin-top: 12px; color: var(--sun); font-weight: 700; }
.pro-hero-term {
  margin: 0; padding: 16px 18px; background: var(--term-bg); color: var(--term-text);
  border: 3px solid #000; border-radius: var(--radius); box-shadow: 6px 6px 0 var(--sun);
  font-family: var(--font-mono); font-size: var(--step--1); line-height: 1.6; overflow-x: auto;
}
.pro-hero-term code { background: none; padding: 0; white-space: pre; color: inherit; }
.pro-hero-term .caret { color: var(--sun); animation: blink 1.1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
@media (min-width: 860px) { .pro-hero { grid-template-columns: 1.3fr 1fr; } }

/* ---------- Pro catalogue ---------- */
.pro-layer { margin-top: 40px; }
.pro-layer-head { display: flex; gap: 16px; align-items: center; margin-bottom: 16px; }
.pro-layer-head img { flex: none; width: 72px; height: 72px; border: var(--border); border-radius: 50%; background: var(--sky-tint); }
.pro-l3 .pro-layer-head img { background: var(--mint-tint); }
.pro-layer-head h2 { font-size: var(--step-3); }
.pro-layer-head p { color: var(--text-muted); }
.pro-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
@media (min-width: 760px) { .pro-list { grid-template-columns: 1fr 1fr; } }
.pro-link {
  display: flex; gap: 14px; height: 100%; padding: 16px; text-decoration: none; color: var(--text);
  background: var(--surface); border: var(--border); border-radius: var(--radius); box-shadow: var(--pop);
  transition: transform .15s ease, box-shadow .15s ease;
}
.pro-link:hover { transform: translate(-2px, -2px); box-shadow: 6px 6px 0 var(--shadow); }
.pro-link:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.pro-no {
  flex: none; width: 52px; height: 52px; display: grid; place-items: center; border: var(--border); border-radius: 12px;
  font-family: var(--font-mono); font-weight: 600; background: var(--pro-bg); color: var(--sun);
}
.pro-body { display: grid; gap: 6px; min-width: 0; }
.pro-title { font-family: var(--font-display); font-size: var(--step-1); line-height: 1.4; }
.pro-foot { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; justify-content: space-between; }
.pro-exam { font-family: var(--font-mono); font-size: var(--step--1); color: var(--text-muted); }
.pro-card.is-draft .pro-link { background: var(--bg); box-shadow: var(--pop-sm); }
.pro-card.is-draft .pro-no { background: var(--surface); color: var(--text-muted); }
.pill-layer { background: var(--pro-bg); color: var(--sun); }
.pill-lab { background: var(--sun); color: #263238; }

/* ---------- Home: Pro block ---------- */
.home-pro { margin-top: 48px; }
.pro-block {
  display: grid; gap: 20px; padding: 24px 20px; background: var(--pro-bg); color: var(--pro-text);
  border: var(--border); border-radius: 24px; box-shadow: 6px 6px 0 var(--sun);
  --text: var(--pro-text); --text-muted: #CFD8DC; --link: var(--sun);
}
.pro-block .eyebrow { color: var(--sun); }
.pro-block h2 { font-size: var(--step-3); margin: 4px 0 8px; }
.pro-block code { background: rgba(255, 255, 255, 0.12); color: inherit; }
.pro-block .hero-actions { margin-top: 16px; }
.pro-block-layers { display: grid; gap: 14px; }
.pro-mini { background: rgba(255, 255, 255, 0.06); border: 2px solid rgba(255, 255, 255, 0.35); border-radius: var(--radius); padding: 14px 16px; }
.pro-mini h3 { color: var(--sun); font-size: var(--step-1); margin-bottom: 6px; }
.pro-mini ol { margin: 0; padding-left: 1.4em; display: grid; gap: 4px; }
.pro-mini li { font-size: var(--step--1); }
.pro-mini li a { color: var(--pro-text); }
.pro-mini li.is-draft a { color: #CFD8DC; }
.pro-mini .pill { margin-left: 6px; vertical-align: 1px; }
@media (min-width: 900px) {
  .pro-block { grid-template-columns: 1fr 1.3fr; padding: 32px; align-items: start; }
  .pro-block-layers { grid-template-columns: 1fr 1fr; }
}

/* ---------- Pro section cards ---------- */
.sec-config .sec-badge { background: var(--pro-bg); color: var(--sun); }
.sec-verify .sec-badge { background: var(--mint); }
.sec-lab .sec-badge { background: var(--pro-bg); color: var(--term-note); font-family: var(--font-mono); font-size: var(--step--1); }
.sec-troubleshoot .sec-badge { background: var(--coral); }

/* CLI blocks in Markdown: ```cli */
.prose pre:has(> code.language-cli) {
  background: var(--term-bg); color: var(--term-text); border-color: #000;
  box-shadow: var(--pop-sm);
}
.prose pre > code.language-cli { background: none; padding: 0; color: inherit; font-size: 1em; }
.prose code.language-cli .cli-prompt { color: var(--term-cmd); }
.prose code.language-cli .cli-comment { color: var(--term-muted); font-style: italic; }
.prose code.language-cli .cli-log { color: var(--term-log); }
.prose code.language-cli .cli-hl { background: rgba(255, 213, 79, 0.22); color: #FFF3C4; border-radius: 3px; }

/* ---------- CLI Lab ---------- */
.lab {
  margin-top: 16px; padding: 16px; border: var(--border); border-radius: var(--radius);
  background: var(--sun-tint); box-shadow: var(--pop);
}
.lab-label { display: inline-block; font-family: var(--font-mono); font-size: var(--step--1); font-weight: 600; background: var(--pro-bg); color: var(--sun); padding: 0 10px; border-radius: 999px; }
.lab-title { font-size: var(--step-2); margin: 6px 0 4px; }
.lab-intro { color: var(--text); }
.lab-grid { display: grid; gap: 16px; margin-top: 14px; }
.lab { container-type: inline-size; }
@container (min-width: 900px) { .lab-grid { grid-template-columns: minmax(0, 1.6fr) minmax(260px, 1fr); align-items: start; } }
.lab-console { align-self: start; }
.lab-console { min-width: 0; background: var(--term-bg); border: 3px solid #000; border-radius: var(--radius-sm); overflow: hidden; }
.lab-tabs { display: flex; gap: 4px; padding: 8px 8px 0; background: #0E1519; overflow-x: auto; }
.lab-tab {
  display: flex; flex-direction: column; align-items: flex-start; gap: 0; padding: 6px 14px 4px; border: 0; border-radius: 8px 8px 0 0;
  font-family: var(--font-mono); font-weight: 600; font-size: var(--step--1); line-height: 1.3; cursor: pointer;
  background: #25333A; color: var(--term-muted);
}
.lab-tab-sub { font-family: var(--font-body); font-weight: 400; font-size: 0.75rem; }
.lab-tab[aria-selected="true"] { background: var(--term-bg); color: var(--sun); }
.lab-tab:focus-visible { outline: 3px solid var(--sun); outline-offset: -3px; }
.lab-screen {
  margin: 0; height: 360px; overflow: auto; padding: 12px 14px; color: var(--term-text);
  font-family: var(--font-mono); font-size: 0.8125rem; line-height: 1.55; white-space: pre; tab-size: 8;
}
.lab-screen:focus-visible { outline: 3px solid var(--sun); outline-offset: -3px; }
.lab-screen .lab-cmd { color: var(--term-cmd); }
.lab-screen .lab-log { color: var(--term-log); }
.lab-screen .lab-err { color: var(--term-err); }
.lab-screen .lab-note { color: var(--term-note); }
.lab-form { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-top: 2px solid #33444C; background: #0E1519; }
.lab-prompt { font-family: var(--font-mono); font-size: 0.875rem; color: var(--term-cmd); white-space: nowrap; }
.lab-input {
  flex: 1; min-width: 0; padding: 8px 10px; border: 2px solid #33444C; border-radius: 8px;
  background: var(--term-bg); color: var(--term-text); font-family: var(--font-mono); font-size: 1rem; caret-color: var(--sun);
}
.lab-input:focus { outline: 3px solid var(--sun); outline-offset: 1px; border-color: var(--sun); }
.lab-send { flex: none; }
.lab-help { padding: 6px 12px 10px; font-size: 0.8125rem; background: #0E1519; color: var(--term-muted); }
.lab-help code { background: #25333A; color: var(--term-text); }

.lab-side { display: grid; gap: 12px; align-content: start; }
.lab-coach { display: flex; gap: 10px; align-items: flex-start; background: var(--surface); border: var(--border); border-radius: var(--radius-sm); padding: 10px 12px; }
.lab-coach img { flex: none; width: 48px; height: 48px; border-radius: 50%; background: var(--coral-tint); border: 2px solid var(--line); }
.lab-coach-text { font-size: var(--step--1); line-height: 1.7; }
.lab-coach-text code { white-space: normal; }
.lab-tasks { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
@container (min-width: 560px) and (max-width: 899px) { .lab-tasks { grid-template-columns: 1fr 1fr; } }
.lab-task { display: flex; gap: 10px; padding: 10px 12px; background: var(--surface); border: 2px solid var(--line); border-radius: var(--radius-sm); font-size: var(--step--1); line-height: 1.7; opacity: .72; }
.lab-task.is-current { opacity: 1; outline: 3px solid var(--sun); box-shadow: var(--pop-sm); }
.lab-task.is-done { opacity: 1; background: var(--mint-tint); }
.lab-task-no { flex: none; width: 28px; height: 28px; display: grid; place-items: center; border: 2px solid var(--line); border-radius: 50%; font-weight: 700; background: var(--bg); }
.lab-task.is-done .lab-task-no { background: var(--mint); color: #263238; }
.lab-task.is-done .lab-task-no::before { content: '✓'; }
.lab-task.is-done .lab-task-no { font-size: 0; }
.lab-task.is-done .lab-task-no::before { font-size: 0.875rem; }
.lab-task-dev { display: inline-block; margin-right: 6px; padding: 0 8px; border-radius: 6px; background: var(--pro-bg); color: var(--sun); font-family: var(--font-mono); font-size: 0.75rem; font-weight: 600; vertical-align: 1px; }
.lab-task code { white-space: normal; }
.lab-task-result { margin-top: 4px; color: var(--ok); font-weight: 500; }
.lab-hint { margin-top: 4px; }
.lab-hint summary, .lab-answer summary { cursor: pointer; color: var(--link); font-weight: 500; }
.lab-answer { margin-top: 4px; }
.lab-answer pre { margin: 4px 0 0; padding: 8px 10px; background: var(--term-bg); color: var(--term-text); border-radius: 8px; overflow-x: auto; }
.lab-answer pre code { background: none; color: inherit; padding: 0; white-space: pre; }
.lab-progress { font-weight: 700; }
.lab.is-finished .lab-progress { color: var(--ok); }
@media (max-width: 600px) {
  .lab { padding: 12px; }
  .lab-screen { height: 300px; font-size: 0.75rem; }
  .lab-send { padding-inline: 10px; }
}

/* Quiz questions with inline code (e.g. `show spanning-tree`) must wrap on phones */
.quiz-q { min-width: 0; }
.quiz-q legend code, .quiz-option code { white-space: normal; overflow-wrap: anywhere; }
.pro-mini .pill-draft { background: rgba(255, 255, 255, 0.14); color: var(--pro-text); border-color: rgba(255, 255, 255, 0.5); }
