/* ============================================================
   Explore ML — shared design system
   Playful, chunky, kid-friendly. Light + dark themes.
   ============================================================ */

:root {
  --bg: #fff8ee;
  --bg-2: #fff1dc;
  --card: #ffffff;
  --ink: #1f2140;
  --ink-2: #4a4d70;
  --muted: #8a8cab;
  --line: #ece4d6;
  --shadow: 0 6px 0 rgba(31, 33, 64, 0.08), 0 14px 30px rgba(31, 33, 64, 0.08);
  --shadow-sm: 0 3px 0 rgba(31, 33, 64, 0.08);

  --nn: #7c5cff;
  --sup: #2f9bff;
  --unsup: #12b5a6;
  --rl: #ff8a3d;
  --diff: #ff5c9a;
  --vision: #2fbf62;
  --lang: #e0a400;
  --intro: #5b5fe0;
  --vlm: #a14bd9;
  --audio: #00a3c4;
  --video: #e0533d;
  --games: #0e9fb5;
  --ai: #8e5b3a;

  --good: #2fbf62;
  --bad: #ff4d5e;
  --warn: #ffb020;

  --accent: var(--nn);

  --radius: 22px;
  --radius-sm: 14px;
  --font-head: "Fredoka", "Nunito", system-ui, sans-serif;
  --font-body: "Nunito", system-ui, -apple-system, Segoe UI, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, monospace;

  --canvas-bg: #f4efe6;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #14152b;
  --bg-2: #1a1c38;
  --card: #1f2142;
  --ink: #f4f1ff;
  --ink-2: #c5c3e6;
  --muted: #8d8bb5;
  --line: #2e3060;
  --shadow: 0 6px 0 rgba(0, 0, 0, 0.25), 0 14px 30px rgba(0, 0, 0, 0.3);
  --shadow-sm: 0 3px 0 rgba(0, 0, 0, 0.25);
  --canvas-bg: #181a36;
  color-scheme: dark;
}

body[data-topic="nn"] { --accent: var(--nn); }
body[data-topic="sup"] { --accent: var(--sup); }
body[data-topic="unsup"] { --accent: var(--unsup); }
body[data-topic="rl"] { --accent: var(--rl); }
body[data-topic="diff"] { --accent: var(--diff); }
body[data-topic="vision"] { --accent: var(--vision); }
body[data-topic="lang"] { --accent: var(--lang); }
body[data-topic="intro"] { --accent: var(--intro); }
body[data-topic="vlm"] { --accent: var(--vlm); }
body[data-topic="audio"] { --accent: var(--audio); }
body[data-topic="video"] { --accent: var(--video); }
body[data-topic="games"] { --accent: var(--games); }
body[data-topic="ai"] { --accent: var(--ai); }
body[data-topic="data"] { --accent: #e0883a; }
body[data-topic="time"] { --accent: #2aa876; }
body[data-topic="agents"] { --accent: #8a5cf6; }
body[data-topic="ethics"] { --accent: #d9487c; }
body[data-topic="ensemble"] { --accent: #c9722a; }
body[data-topic="gen"] { --accent: #b84fc2; }
body[data-topic="graphs"] { --accent: #3d7be0; }
body[data-topic="robotics"] { --accent: #5c6b7a; }
body[data-topic="optim"] { --accent: #d1a31a; }
body[data-topic="prob"] { --accent: #e0568b; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
/* Declared on elements (not :root) so it follows a page's or element's own --accent. */
body, .kicker, .tile, .btn { --accent-soft: color-mix(in srgb, var(--accent) 14%, var(--card)); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.55;
  min-height: 100vh;
  overflow-x: hidden;
}
h1, h2, h3, h4 { font-family: var(--font-head); line-height: 1.15; margin: 0 0 0.4em; letter-spacing: -0.01em; }
h1 { font-size: clamp(2rem, 5vw, 3.4rem); font-weight: 700; }
h2 { font-size: clamp(1.4rem, 3vw, 2rem); font-weight: 600; }
h3 { font-size: 1.2rem; font-weight: 600; }
p { margin: 0 0 0.8em; }
a { color: inherit; }
img, canvas, video, svg { max-width: 100%; display: block; }
button, input, select { font: inherit; color: inherit; }
kbd {
  font-family: var(--font-mono); font-size: 0.85em; padding: 1px 6px; border-radius: 6px;
  background: var(--bg-2); border: 1px solid var(--line); box-shadow: var(--shadow-sm);
}
.wrap { max-width: 1240px; margin: 0 auto; padding: 0 16px 64px; }
.muted { color: var(--muted); }
.hidden { display: none !important; }
.center { text-align: center; }

/* ---------- Icons ---------- */
.ic { width: 1.15em; height: 1.15em; display: inline-block; vertical-align: -0.2em; flex: none; }
.section-title .ic { color: var(--accent); }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 2px solid var(--line);
}
.topbar-inner {
  max-width: 1240px; margin: 0 auto; padding: 10px 16px;
  display: flex; align-items: center; gap: 12px;
}
.brand {
  display: flex; align-items: center; gap: 8px; text-decoration: none;
  font-family: var(--font-head); font-weight: 700; font-size: 1.2rem; white-space: nowrap;
}
.brand-dot {
  width: 30px; height: 30px; border-radius: 10px; display: grid; place-items: center;
  background: conic-gradient(var(--nn), var(--sup), var(--unsup), var(--vision), var(--lang), var(--rl), var(--diff), var(--nn));
  color: #fff; font-size: 17px;
}
.crumbs { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; min-width: 0; font-weight: 700; color: var(--ink-2); }
.crumbs a { text-decoration: none; padding: 4px 10px; border-radius: 999px; }
.crumbs a:hover { background: var(--bg-2); }
.crumbs .sep { color: var(--muted); }
.crumbs .here { color: var(--accent); padding: 4px 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .spacer { flex: 1; }
@media (max-width: 640px) {
  .crumbs .crumb-mid, .crumbs .crumb-mid + .sep { display: none; }
  .crumbs { flex-wrap: nowrap; }
  .crumbs .here { max-width: 52vw; }
}

/* ---------- Lesson path (chapter progress above a lesson) ---------- */
.lesson-path { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.lesson-path a { text-decoration: none; }
.lp-chapter { font-weight: 800; color: var(--accent); margin-right: 4px; font-size: 0.92rem; }
.lp-step {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px 4px 4px; border-radius: 999px;
  border: 2px solid var(--line); background: var(--card); font-weight: 700; font-size: 0.82rem; color: var(--ink-2);
}
.lp-step b {
  font-family: var(--font-head); font-size: 0.78rem; min-width: 26px; height: 22px; padding: 0 5px; border-radius: 999px;
  display: grid; place-items: center; background: var(--bg-2); color: var(--ink-2);
}
.lp-step.done b { background: color-mix(in srgb, var(--accent) 25%, var(--card)); color: var(--accent); }
.lp-step.on { border-color: var(--accent); color: var(--ink); }
.lp-step.on b { background: var(--accent); color: #fff; }
@media (max-width: 640px) { .lp-step:not(.on) span { display: none; } .lp-step:not(.on) { padding-right: 4px; } }

/* ---------- Recap + checkpoints (shared look) ---------- */
.card.recap ul { margin: 0; padding-left: 22px; display: grid; gap: 8px; color: var(--ink-2); font-weight: 600; }
.card.recap li::marker { color: var(--accent); }
.checkpoints { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 6px; }
.ckpt {
  flex: none; width: 120px; border: 2px solid var(--line); border-radius: 14px; background: var(--card); padding: 6px;
  cursor: pointer; text-align: left; font-size: 0.78rem; font-weight: 700; color: var(--ink-2);
}
.ckpt:hover, .ckpt.on { border-color: var(--accent); }
.ckpt canvas { width: 100%; border-radius: 8px; background: var(--canvas-bg); margin-bottom: 4px; }
.ckpt b { color: var(--ink); display: block; }
.inside {
  border: 3px solid color-mix(in srgb, var(--accent) 35%, var(--line)); background: var(--accent-soft);
}
.inside .flow { display: grid; gap: 6px; font-weight: 700; font-size: 0.92rem; align-content: start; }
/* Live cards update many times a second; a fixed height stops the page jumping. */
#inside { height: 240px; overflow-y: auto; }
.inside .flow .arrow { color: var(--accent); text-align: center; line-height: 1; }
.icon-btn {
  border: 2px solid var(--line); background: var(--card); border-radius: 12px;
  width: 40px; height: 40px; display: grid; place-items: center; cursor: pointer; font-size: 18px;
  flex: none;
}
.icon-btn:hover { border-color: var(--accent); }
.topbar .social { display: flex; gap: 6px; margin-right: 6px; }
.topbar .social .icon-btn { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; color: var(--ink); }
.topbar .social .sponsor { color: #e0457b; }
@media (max-width: 640px) { .topbar .social { display: none; } }

/* ---------- Robo mascot + speech ---------- */
.robo-say { display: flex; gap: 14px; align-items: flex-start; }
.robo { width: 74px; height: 74px; flex: none; }
.robo svg { width: 100%; height: 100%; overflow: visible; }
.robo .eye { transform-origin: center; transform-box: fill-box; animation: blink 5s infinite; }
.robo.talking .mouth { animation: talk 0.25s infinite alternate; transform-origin: center; transform-box: fill-box; }
@keyframes blink { 0%, 92%, 100% { transform: scaleY(1); } 95% { transform: scaleY(0.1); } }
@keyframes talk { from { transform: scaleY(0.4); } to { transform: scaleY(1.2); } }
.bubble {
  position: relative; background: var(--card); border: 3px solid var(--ink);
  border-radius: 20px; padding: 14px 18px; font-size: 1.08rem; font-weight: 600;
  box-shadow: var(--shadow-sm); margin: 0; min-height: 3.2em;
}
.bubble::before {
  content: ""; position: absolute; left: -14px; top: 22px; width: 18px; height: 18px;
  background: var(--card); border-left: 3px solid var(--ink); border-bottom: 3px solid var(--ink);
  transform: rotate(45deg);
}
.bubble b, .bubble strong { color: var(--accent); }
.bubble.pop { animation: pop 0.35s ease; }
@keyframes pop { 0% { transform: scale(0.97); } 60% { transform: scale(1.02); } 100% { transform: scale(1); } }

/* ---------- Hero ---------- */
.hero { padding: 36px 0 18px; display: grid; gap: 18px; }
.kicker {
  display: inline-flex; align-items: center; gap: 8px; font-weight: 800; text-transform: uppercase;
  letter-spacing: 0.08em; font-size: 0.78rem; color: var(--accent);
  background: var(--accent-soft); padding: 6px 12px; border-radius: 999px; width: fit-content;
}
.hero h1 .em { color: var(--accent); }
.hero-sub { font-size: 1.2rem; color: var(--ink-2); max-width: 62ch; }
.hero-split { display: grid; grid-template-columns: 1.1fr 1fr; gap: 28px; align-items: center; }
@media (max-width: 860px) { .hero-split { grid-template-columns: 1fr; } }

/* ---------- Tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 20px; }
.tile {
  --c: var(--accent);
  position: relative; display: flex; flex-direction: column; gap: 10px;
  background: var(--card); border: 3px solid var(--line); border-radius: var(--radius);
  padding: 22px; text-decoration: none; box-shadow: var(--shadow);
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s;
  overflow: hidden; isolation: isolate; min-height: 220px;
}
.tile::after {
  content: ""; position: absolute; right: -40px; top: -40px; width: 160px; height: 160px; border-radius: 50%;
  background: color-mix(in srgb, var(--c) 16%, transparent); z-index: -1; transition: transform 0.3s ease;
}
.tile:hover, .tile:focus-visible { transform: translateY(-5px) rotate(-0.4deg); border-color: var(--c); outline: none; }
.tile:hover::after { transform: scale(1.4); }
.tile .t-emoji {
  width: 64px; height: 64px; border-radius: 18px; display: grid; place-items: center; font-size: 30px; color: var(--c);
  background: color-mix(in srgb, var(--c) 18%, var(--card)); border: 3px solid color-mix(in srgb, var(--c) 40%, transparent);
}
.tile h3 { font-size: 1.4rem; margin: 4px 0 0; }
.tile p { color: var(--ink-2); margin: 0; flex: 1; }
.tile .t-meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; font-size: 0.8rem; font-weight: 800;
  padding: 4px 10px; border-radius: 999px; background: var(--bg-2); color: var(--ink-2);
  border: 2px solid var(--line); white-space: nowrap;
}
.chip.accent { background: color-mix(in srgb, var(--c, var(--accent)) 16%, var(--card)); color: var(--c, var(--accent)); border-color: transparent; }
.tile .go { font-family: var(--font-head); font-weight: 600; color: var(--c); display: flex; align-items: center; gap: 6px; }
.tile .go span { transition: transform 0.2s; }
.tile:hover .go span { transform: translateX(5px); }
.tile.star { border-color: color-mix(in srgb, var(--c) 50%, var(--line)); }
.tile .ribbon {
  position: absolute; top: 16px; right: 16px; background: var(--c); color: #fff; font-weight: 800;
  font-size: 0.72rem; padding: 4px 10px; border-radius: 999px; text-transform: uppercase; letter-spacing: 0.06em;
}

/* ---------- Buttons & controls ---------- */
.btn {
  --b: var(--accent);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 3px solid var(--ink); background: var(--card); color: var(--ink);
  padding: 10px 16px; border-radius: 14px; cursor: pointer; font-weight: 800; font-size: 0.98rem;
  box-shadow: 0 4px 0 var(--ink); transition: transform 0.08s, box-shadow 0.08s, background 0.15s;
  user-select: none; -webkit-user-select: none; touch-action: manipulation; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--bg-2); }
.btn:active, .btn.pressed { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.btn.primary { background: var(--b); color: #fff; }
.btn.primary:hover { background: color-mix(in srgb, var(--b) 88%, #000); }
.btn.ghost { border-color: var(--line); box-shadow: 0 4px 0 var(--line); }
.btn.small { padding: 6px 10px; font-size: 0.86rem; border-radius: 11px; }
.btn.on { background: var(--accent-soft); border-color: var(--accent); box-shadow: 0 4px 0 var(--accent); color: var(--accent); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }

.seg { display: inline-flex; background: var(--bg-2); border: 2px solid var(--line); border-radius: 14px; padding: 3px; gap: 3px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 7px 12px; border-radius: 10px; font-weight: 800; cursor: pointer; color: var(--ink-2); }
.seg button.on { background: var(--card); color: var(--accent); box-shadow: var(--shadow-sm); }

.field { display: grid; gap: 6px; }
.field label, .field .lbl { display: flex; justify-content: space-between; gap: 8px; font-weight: 800; font-size: 0.92rem; }
.field .val { font-family: var(--font-mono); color: var(--accent); font-weight: 700; }
.field .hint { font-size: 0.82rem; color: var(--muted); margin-top: -2px; }
input[type="range"] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 12px; border-radius: 999px;
  background: var(--bg-2); border: 2px solid var(--line); outline: none; margin: 4px 0;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 24px; height: 24px; border-radius: 50%;
  background: var(--accent); border: 3px solid var(--card); box-shadow: 0 0 0 2px var(--accent), var(--shadow-sm); cursor: grab;
}
input[type="range"]::-moz-range-thumb {
  width: 20px; height: 20px; border-radius: 50%; background: var(--accent);
  border: 3px solid var(--card); box-shadow: 0 0 0 2px var(--accent); cursor: grab;
}
input[type="text"], textarea, select {
  width: 100%; border: 2px solid var(--line); background: var(--card); border-radius: 12px; padding: 10px 12px;
}
input[type="text"]:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); }

/* ---------- Demo stage ---------- */
.stage { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; margin: 8px 0 28px; }
@media (max-width: 960px) { .stage { grid-template-columns: 1fr; } }
.card {
  background: var(--card); border: 3px solid var(--line); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow);
}
.canvas-box {
  background: var(--card); border: 3px solid var(--line); border-radius: var(--radius);
  padding: 12px; box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.canvas-box canvas { background: var(--canvas-bg); border-radius: 14px; width: 100%; touch-action: none; }
.panel { display: grid; gap: 16px; }
.panel h3 { display: flex; align-items: center; gap: 8px; margin: 0; }
.panel .card { display: grid; gap: 14px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; }
.stat { background: var(--bg-2); border-radius: 14px; padding: 10px 12px; border: 2px solid var(--line); }
.stat .k { font-size: 0.75rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.stat .v { font-family: var(--font-head); font-size: 1.6rem; font-weight: 600; line-height: 1.1; }
.stat .v small { font-size: 0.9rem; color: var(--muted); }

.overlay-msg {
  position: absolute; left: 50%; top: 18px; transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 8px 16px; border-radius: 999px; font-weight: 800;
  pointer-events: none; opacity: 0; transition: opacity 0.3s, transform 0.3s; white-space: nowrap; z-index: 5;
}
.overlay-msg.show { opacity: 1; transform: translateX(-50%) translateY(4px); }

.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 0.88rem; font-weight: 700; color: var(--ink-2); }
.legend i { display: inline-block; width: 14px; height: 14px; border-radius: 4px; margin-right: 6px; vertical-align: -2px; }

/* ---------- How it works steps ---------- */
.section-title { display: flex; align-items: center; gap: 10px; margin: 40px 0 16px; }
.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px; counter-reset: step; }
.step {
  background: var(--card); border: 3px solid var(--line); border-radius: var(--radius); padding: 18px 18px 18px;
  position: relative; counter-increment: step; box-shadow: var(--shadow-sm);
}
.step::before {
  content: counter(step); position: absolute; top: -14px; left: 16px; width: 32px; height: 32px; border-radius: 50%;
  background: var(--accent); color: #fff; font-family: var(--font-head); font-weight: 700; display: grid; place-items: center;
  border: 3px solid var(--card);
}
.step .s-emoji { font-size: 34px; margin: 6px 0 6px; color: var(--accent); }
.step h3 { margin-bottom: 4px; }
.step p { color: var(--ink-2); margin: 0; }

/* ---------- Grown-ups corner ---------- */
details.grownups {
  margin-top: 28px; background: var(--card); border: 3px dashed var(--line); border-radius: var(--radius); padding: 0;
}
details.grownups summary {
  cursor: pointer; padding: 16px 20px; font-family: var(--font-head); font-weight: 600; font-size: 1.1rem;
  list-style: none; display: flex; align-items: center; gap: 10px;
}
details.grownups summary::-webkit-details-marker { display: none; }
details.grownups summary::after { content: "＋"; margin-left: auto; color: var(--accent); font-size: 1.4rem; }
details.grownups[open] summary::after { content: "－"; }
details.grownups .gu-body { padding: 0 20px 20px; color: var(--ink-2); }
details.grownups .gu-body ul { padding-left: 20px; }
details.grownups .gu-body li { margin-bottom: 6px; }
details.grownups code { font-family: var(--font-mono); font-size: 0.88em; background: var(--bg-2); padding: 1px 6px; border-radius: 6px; }
.term { font-weight: 800; color: var(--accent); }

/* ---------- Next demo nav ---------- */
.next-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 36px; }
@media (max-width: 640px) { .next-nav { grid-template-columns: 1fr; } }
.next-nav a {
  display: flex; align-items: center; gap: 12px; padding: 16px 18px; background: var(--card);
  border: 3px solid var(--line); border-radius: var(--radius-sm); text-decoration: none; font-weight: 800;
}
.next-nav a:hover { border-color: var(--accent); }
.next-nav a .ne { font-size: 28px; color: var(--accent); display: grid; }
.next-nav a small { display: block; color: var(--muted); font-weight: 700; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; }
.next-nav a.right { justify-content: flex-end; text-align: right; }

/* ---------- Home specials ---------- */
.home-hero { padding: 48px 0 24px; }
.home-hero h1 { font-size: clamp(2.4rem, 7vw, 4.6rem); }
.rainbow {
  background: linear-gradient(90deg, var(--nn), var(--sup), var(--unsup), var(--vision), var(--lang), var(--rl), var(--diff));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.loop-strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 14px 0 6px; }
@media (max-width: 700px) { .loop-strip { grid-template-columns: repeat(2, 1fr); } }
.loop-strip .ls {
  background: var(--card); border: 3px solid var(--line); border-radius: 18px; padding: 14px; text-align: center; font-weight: 800;
}
.loop-strip .ls .e { font-size: 30px; display: block; }
.loop-strip .ls .ic { font-size: 30px; display: block; margin: 0 auto 6px; }
.loop-strip .ls small { display: block; color: var(--muted); font-weight: 700; }

.footer { margin-top: 60px; padding: 28px 16px; text-align: center; color: var(--muted); font-size: 0.9rem; border-top: 2px solid var(--line); display: grid; gap: 14px; }
.footer a { color: var(--ink-2); font-weight: 800; }
.footer-links { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }
.footer-links a {
  display: inline-flex; align-items: center; gap: 8px; text-decoration: none; padding: 8px 14px;
  border: 2px solid var(--line); border-radius: 999px; background: var(--card); color: var(--ink);
}
.footer-links a:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: var(--bg); padding: 12px 20px; border-radius: 16px; font-weight: 800;
  opacity: 0; transition: all 0.3s ease; z-index: 100; pointer-events: none; max-width: calc(100vw - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Utility ---------- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 700px) { .grid-2 { grid-template-columns: 1fr; } }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.pill-note {
  display: flex; gap: 10px; align-items: flex-start; background: var(--accent-soft); border-radius: 14px;
  padding: 12px 14px; font-weight: 700; color: var(--ink);
}
.pill-note .e { font-size: 1.3rem; line-height: 1.2; }
.confetti-piece { position: fixed; width: 10px; height: 14px; top: -20px; z-index: 200; pointer-events: none; border-radius: 2px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* ---------- Game layout: settings left · game centre · play/stats right ----------
   <section class="stage three"><aside class="panel left">…</aside><div class="stage-left">…game…</div><aside class="panel">…</aside></section>
   Both side panels stick beside the game so every control stays in view. */
.stage.three { grid-template-columns: 290px minmax(0, 1fr) 300px; }
.stage-left { display: grid; gap: 16px; min-width: 0; align-content: start; }
.stage.three > .panel { position: sticky; top: 72px; max-height: calc(100vh - 84px); overflow-y: auto; padding: 0 4px 6px 0; gap: 12px; }
.stage.three > .panel .card { padding: 14px; gap: 10px; }
.stage.three .canvas-box canvas { max-height: calc(100vh - 220px); width: auto; max-width: 100%; margin-left: auto; margin-right: auto; }
body:has(.stage.three) main.wrap { max-width: 1560px; }
@media (max-width: 1200px) { .stage.three { grid-template-columns: 250px minmax(0, 1fr) 270px; } }
@media (max-width: 960px) {
  .stage.three { grid-template-columns: 1fr; }
  .stage.three > .panel { position: static; max-height: none; overflow: visible; }
  .stage.three > .panel.left { order: 2; }
  .stage.three .canvas-box canvas { max-height: none; width: 100%; }
}

/* ---------- Model X-ray (js/xray.js) ---------- */
.xray { position: fixed; inset: 0; z-index: 150; background: rgba(20, 21, 43, 0.55); backdrop-filter: blur(4px); display: none; padding: 24px 16px; overflow-y: auto; }
.xray.open { display: block; }
.xray-card { max-width: 1100px; margin: 0 auto; background: var(--bg); border: 3px solid var(--ink); border-radius: 26px; box-shadow: var(--shadow); overflow: hidden; }
.xray-head { display: flex; gap: 14px; align-items: center; padding: 18px 20px; background: var(--card); border-bottom: 3px solid var(--line); }
.xray-head h2 { margin: 0; }
.xray-head .icon-btn { margin-left: auto; }
.xray-badge { width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; font-size: 26px; background: var(--accent); color: #fff; flex: none; }
.xray-body { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; padding: 18px; }
.xr-sec { background: var(--card); border: 3px solid var(--line); border-radius: 20px; padding: 16px; min-width: 0; }
.xr-sec h3 { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.xr-sec h3 .ic { color: var(--accent); }
.xr-wide { grid-column: 1 / -1; }
.xr-hint { font-size: 0.85rem; margin: -2px 0 10px; }
.xr-bar { display: grid; grid-template-columns: minmax(90px, 38%) 1fr 44px; gap: 10px; align-items: center; font-weight: 800; font-size: 0.88rem; margin-bottom: 7px; }
.xr-bar.on span { color: var(--accent); }
.xr-track { height: 14px; background: var(--bg-2); border-radius: 999px; overflow: hidden; border: 2px solid var(--line); }
.xr-track > div { height: 100%; border-radius: 999px; transition: width 0.25s; }
.xr-bar b { font-family: var(--font-mono); font-size: 0.8rem; text-align: right; }
.xr-rules { margin: 0; padding-left: 20px; display: grid; gap: 8px; font-weight: 600; color: var(--ink-2); }
.xr-rules li::marker { color: var(--accent); }
.xr-map-row { display: grid; grid-template-columns: minmax(0, 1fr) 180px; gap: 16px; align-items: start; }
.xr-map-row canvas, #xr-brain { width: 100%; border-radius: 14px; background: var(--canvas-bg); }
.xr-map-row select { width: auto; padding: 4px 8px; }
.xr-sliders { display: grid; gap: 10px; max-height: 300px; overflow-y: auto; padding-right: 4px; }
.xr-btns { margin-top: 10px; }
.xr-say { margin-top: 10px; font-weight: 700; }
.xray-offer { position: fixed; right: 20px; bottom: 20px; z-index: 120; transform: translateY(120px); transition: transform 0.4s cubic-bezier(.2,1.4,.4,1); }
.xray-offer.show { transform: none; }
@media (max-width: 760px) { .xray-body, .xr-map-row { grid-template-columns: 1fr; } .xray { padding: 8px; } }
.xr-big { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; font-weight: 800; }
.xr-big b { font-family: var(--font-head); font-size: 2rem; color: var(--accent); }

/* ---------- Meet the model ---------- */
.meet { display: grid; grid-template-columns: 1.1fr 1fr; gap: 20px; }
.meet-who { display: flex; gap: 14px; align-items: flex-start; }
.meet-icon { width: 60px; height: 60px; flex: none; border-radius: 18px; display: grid; place-items: center; font-size: 30px; color: var(--accent); background: var(--accent-soft); }
.meet-who h3 { margin: 0 0 6px; font-size: 1.3rem; }
.meet-who p { margin: 10px 0 0; color: var(--ink-2); }
.meet-learn { background: var(--bg-2); border-radius: 16px; padding: 14px 16px; }
.meet-learn .lbl { font-weight: 800; text-transform: uppercase; letter-spacing: .06em; font-size: .78rem; color: var(--accent); margin-bottom: 8px; }
.meet-learn ol { margin: 0; padding: 0; list-style: none; counter-reset: ml; display: grid; gap: 10px; }
.meet-learn li { counter-increment: ml; display: grid; grid-template-columns: 28px 1fr; gap: 10px; font-weight: 600; }
.meet-learn li::before { content: counter(ml); width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-family: var(--font-head); font-weight: 700; font-size: .85rem; }
@media (max-width: 760px) { .meet { grid-template-columns: 1fr; } }
.meet .chip { white-space: normal; text-align: left; } /* long model names must wrap on phones */

.footer-links a[href*="buymeacoffee"] { border-color: #f2b705; }
.footer-links a[href*="buymeacoffee"] .ic { color: #c98f00; }

/* ---------- Progress ---------- */
.prog { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 0.88rem; color: var(--ink-2); }
.prog-bar { flex: 1; height: 14px; border-radius: 999px; background: var(--bg-2); border: 2px solid var(--line); overflow: hidden; min-width: 60px; }
.prog-bar i { display: block; height: 100%; background: var(--good); border-radius: 999px; transition: width 0.4s ease; }
.prog-txt { white-space: nowrap; }
.prog[data-complete="true"] .prog-txt::before { content: "\2713  "; color: var(--good); }
.prog.big { margin: 8px 0 4px; font-size: 1rem; }
.prog.big .prog-bar { height: 20px; border-width: 3px; }
.done-badge { position: absolute; top: 14px; left: 14px; z-index: 1; display: inline-flex; align-items: center; gap: 4px; background: var(--good); color: #fff; font-weight: 800; font-size: 0.72rem; padding: 3px 9px 3px 6px; border-radius: 999px; }
.done-badge .ic { width: 14px; height: 14px; stroke-width: 3; }
.reset-link { background: none; border: 0; padding: 4px; color: var(--muted); font: inherit; font-size: 0.85rem; text-decoration: underline; cursor: pointer; }
.reset-link:hover, .reset-link:focus-visible { color: var(--ink); }
.done-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 14px; margin: 28px 0 8px; }
.done-btn[aria-pressed="true"] { background: var(--good); border-color: var(--ink); color: #fff; }
.tile .prog { margin-top: 2px; }
/* ---------- Home search ---------- */
.course-search { position: relative; max-width: 520px; margin: 0 0 16px; }
.course-search .ic { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.course-search input { width: 100%; padding-left: 44px; }
.course-search kbd { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); border: 2px solid var(--line); border-radius: 6px; padding: 0 6px; font: 700 0.8rem var(--font-head); color: var(--muted); pointer-events: none; }
.tiles.results .tile { min-height: 0; padding: 18px; padding-top: 44px; }
.tiles.results .tile h3 { font-size: 1.1rem; }
.tiles.results .tile .chap { font-size: 0.8rem; font-weight: 800; color: var(--c); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Settings dialog + preferences ---------- */
:root[data-text="large"] body { font-size: 19px; }
:root[data-text="xl"] body { font-size: 21.5px; }
:root[data-motion="reduce"] *, :root[data-motion="reduce"] *::before, :root[data-motion="reduce"] *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; scroll-behavior: auto !important; }
#settings-btn { margin-right: 6px; }
dialog.settings { border: 3px solid var(--line); border-radius: var(--radius); background: var(--card); color: var(--ink); box-shadow: var(--shadow); padding: 0; width: min(460px, calc(100vw - 32px)); }
dialog.settings::backdrop { background: rgba(20, 20, 40, .45); }
.set-body { padding: 18px 20px 16px; display: grid; gap: 14px; }
.set-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.set-head h2 { margin: 0; font-size: 1.3rem; display: flex; align-items: center; gap: 8px; }
.set-head h2 svg { width: 24px; height: 24px; }
.set-row { border: 0; margin: 0; padding: 0; min-width: 0; }
.set-row legend, .set-lbl { font-weight: 800; font-size: .9rem; margin-bottom: 6px; padding: 0; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg label { cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: inline-block; padding: 7px 13px; border-radius: 999px; border: 2px solid var(--line); background: var(--bg-2); font-weight: 800; font-size: .88rem; }
.seg input:checked + span { background: var(--accent); border-color: var(--accent); color: #fff; }
.seg input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }
.set-note { margin: 0; font-size: .8rem; }

/* ---------- learning plans ---------- */
.nav-plans { display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 12px; border: 2px solid var(--line); border-radius: 12px; background: var(--card); text-decoration: none; font-weight: 800; color: var(--ink); flex: none; }
.nav-plans:hover, .nav-plans[aria-current="page"] { border-color: var(--accent); color: var(--accent); }
@media (max-width: 640px) { .nav-plans span { display: none; } .nav-plans { width: 40px; padding: 0; justify-content: center; } }
.plans-banner { --c: var(--intro); display: flex; gap: 16px; align-items: center; flex-wrap: wrap; margin-top: 40px; border-color: color-mix(in srgb, var(--c) 40%, var(--line)); }
.plans-banner .t-emoji { width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; font-size: 28px; color: var(--c); background: color-mix(in srgb, var(--c) 16%, var(--card)); flex: none; }
.plans-banner > div { flex: 1 1 260px; }
.plans-banner h2 { font-size: 1.3rem; margin: 0 0 2px; }
.plans-banner p { margin: 0; color: var(--ink-2); }
.plans-hero h1 { font-size: clamp(2rem, 5.5vw, 3.6rem); }
.plan-howto { margin-top: 24px; }
.plan-picker, .plan-filters { display: grid; gap: 14px; }
.pick-out { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; }
.pick-out:empty { display: none; }
.pick-msg { margin: 0; font-weight: 800; color: var(--ink-2); }
.pick-card { --c: var(--accent); display: flex; gap: 14px; align-items: flex-start; background: color-mix(in srgb, var(--c) 8%, var(--card)); border: 3px solid color-mix(in srgb, var(--c) 45%, var(--line)); border-radius: 18px; padding: 14px; }
.pick-card small { font-weight: 800; text-transform: uppercase; letter-spacing: .06em; font-size: .72rem; color: var(--c); }
.pick-card h3 { margin: 2px 0 4px; }
.pick-card p { margin: 0 0 8px; color: var(--ink-2); font-size: .95rem; }
.pick-card .btn { margin-left: 6px; }
.pick-card .t-emoji, .plan .t-emoji { flex: none; width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; font-size: 28px; color: var(--c); background: color-mix(in srgb, var(--c) 16%, var(--card)); border: 3px solid color-mix(in srgb, var(--c) 40%, transparent); }
.plan-filters { margin-bottom: 8px; }
.plan-filter-foot { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; font-weight: 700; }
.plan-intro { margin-top: -6px; max-width: 75ch; }
.plans { display: grid; gap: 18px; }
.plan { --c: var(--accent); display: grid; gap: 12px; border-top: 8px solid var(--c); scroll-margin-top: 80px; }
.plan:focus { outline: none; }
.plan:focus-visible { outline: 3px solid var(--c); outline-offset: 3px; }
.pl-head { display: flex; gap: 14px; align-items: center; }
.pl-title h3 { margin: 0; font-size: 1.45rem; }
.pl-age { margin: 2px 0 0; font-weight: 800; color: var(--c); font-size: .9rem; }
.pl-why { margin: 0; color: var(--ink-2); max-width: 80ch; }
.plan .t-meta { display: flex; gap: 8px; flex-wrap: wrap; }
.plan .chip.accent { --accent: var(--c); }
.pl-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.pl-actions .btn { white-space: normal; text-align: left; }
.pl-cta { --b: color-mix(in srgb, var(--c) 72%, #000); } /* darker plan colour keeps white text readable */
.pl-body { border-top: 2px dashed var(--line); padding-top: 14px; }
.pl-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.pl-step { display: grid; grid-template-columns: 34px 1fr; gap: 12px; align-items: start; padding: 10px 12px; border-radius: 16px; background: var(--bg-2); border: 2px solid transparent; }
.pl-step.next { border-color: var(--c); background: color-mix(in srgb, var(--c) 8%, var(--card)); }
.pl-step a { color: var(--ink); text-decoration-color: color-mix(in srgb, var(--c) 60%, transparent); text-underline-offset: 3px; }
.pl-step a:hover { color: var(--c); }
.pl-step p { margin: 4px 0 0; color: var(--ink-2); font-weight: 600; }
.pl-sub { font-size: .82rem; font-weight: 700; color: var(--muted); }
.pl-num { width: 30px; height: 30px; border-radius: 50%; display: inline-grid; place-items: center; background: var(--c); color: #fff; font-family: var(--font-head); font-weight: 700; font-size: .95rem; flex: none; }
.pl-num .ic { width: 16px; height: 16px; stroke-width: 3; }
.pl-step.done .pl-num { background: var(--good); }
.pl-try { display: flex; gap: 8px; align-items: flex-start; background: var(--card); border-radius: 12px; padding: 6px 10px; font-size: .92rem; }
.pl-try .ic { color: var(--c); margin-top: 3px; }
.pl-session + .pl-session { margin-top: 22px; }
.pl-session h4 { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 1.2rem; margin: 0 0 10px; }
.pl-session h4 .pl-num { background: var(--c); }
.pl-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.pl-box { background: var(--bg-2); border-radius: 16px; padding: 12px 14px; min-width: 0; }
.pl-box h5 { margin: 0 0 6px; font-family: var(--font-head); font-size: 1rem; font-weight: 600; display: flex; gap: 6px; align-items: flex-start; }
.pl-box h5 .ic { color: var(--c); margin-top: 2px; }
.pl-box p { margin: 0 0 6px; color: var(--ink-2); font-weight: 600; }
.pl-box ul, .pl-more ol { margin: 0; padding-left: 20px; color: var(--ink-2); font-weight: 600; display: grid; gap: 4px; }
.pl-box li::marker, .pl-more li::marker { color: var(--c); }
.pl-wide { grid-column: 1 / -1; }
.pl-exit { border: 2px dashed color-mix(in srgb, var(--c) 50%, var(--line)); }
.pl-more { background: var(--card); border: 2px solid var(--line); border-radius: 14px; margin-top: 6px; }
.pl-script { background: color-mix(in srgb, var(--c) 7%, var(--card)); margin-top: 0; }
.pl-more summary { cursor: pointer; padding: 8px 12px; font-weight: 800; display: flex; gap: 8px; align-items: center; list-style: none; }
.pl-more summary::-webkit-details-marker { display: none; }
.pl-more summary::after { content: "＋"; margin-left: auto; color: var(--c); }
.pl-more[open] summary::after { content: "－"; }
.pl-more summary .ic { color: var(--c); }
.pl-more > p, .pl-more > ol { margin: 0; padding: 0 14px 12px 34px; }
.pl-more > p { padding-left: 14px; color: var(--ink-2); font-weight: 600; }
.pl-lessons { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.pl-lesson { --c: var(--accent); position: relative; display: flex; gap: 10px; align-items: center; background: var(--card); border: 2px solid var(--line); border-radius: 14px; padding: 8px 10px; text-decoration: none; }
.pl-lesson:hover { border-color: var(--c); }
.pl-lesson b { display: block; line-height: 1.2; }
.pl-lesson small { color: var(--muted); font-weight: 700; }
.pl-l-ic { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; color: var(--c); background: color-mix(in srgb, var(--c) 16%, var(--card)); flex: none; }
.pl-check { margin-left: auto; color: var(--good); }
.pl-check .ic { stroke-width: 3; }
.plan-empty { text-align: center; font-weight: 800; }
@media (max-width: 560px) { .pl-head .t-emoji { width: 46px; height: 46px; font-size: 22px; } .pl-title h3 { font-size: 1.25rem; } .plan.card { padding: 14px; } }
@media print {
  body[data-page="plans"] { background: #fff; color: #000; font-size: 12pt; }
  body[data-page="plans"] .topbar, body[data-page="plans"] .footer, body[data-page="plans"] .robo-say, .plan-filters, .plan-picker, #pick-title, #browse-title, .plan-howto, #howto-title,
  .pl-actions, .plans-hero .cta-row, body[data-page="plans"] .next-nav, .plan-empty, .toast { display: none !important; }
  .pl-body[hidden] { display: block !important; }
  .plan { box-shadow: none !important; break-inside: auto; border: 1px solid #999 !important; border-top: 6px solid var(--c) !important; }
  .pl-session, .pl-box, .pl-step { break-inside: avoid; }
  body[data-print] .plans-hero, body[data-print] .plan-intro, body[data-print] .section-title, body[data-print] .plan:not(.print-me) { display: none !important; }
  .pl-lesson::after { content: " (" attr(href) ")"; font-size: 9pt; color: #555; }
}

/* ---------- help panel & word helpers ---------- */
/* Word helpers: dotted words that open a small glossary popover (js/common.js, section 1). */
html[data-words="on"] .gloss[role="button"] { text-decoration: underline dotted; text-decoration-thickness: 2px; text-underline-offset: 3px; text-decoration-color: var(--accent); cursor: help; border-radius: 4px; }
html[data-words="on"] .gloss[role="button"]:hover, .gloss.open { background: color-mix(in srgb, var(--accent) 14%, transparent); }
.gloss:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.gloss-pop { position: fixed; z-index: 1200; top: 0; left: 0; width: min(320px, calc(100vw - 20px)); padding: 12px 14px; background: var(--card); color: var(--ink); border: 2px solid var(--accent); border-radius: var(--radius-sm); box-shadow: var(--shadow); font-size: .95rem; line-height: 1.45; text-align: left; font-weight: 600; }
.gloss-pop[hidden] { display: none; }
.gloss-pop::before { content: ""; position: absolute; left: var(--arrow-x, 50%); width: 12px; height: 12px; background: var(--card); border: 2px solid var(--accent); transform: translateX(-50%) rotate(45deg); }
.gloss-pop[data-side="below"]::before { top: -8px; border-right: 0; border-bottom: 0; }
.gloss-pop[data-side="above"]::before { bottom: -8px; border-left: 0; border-top: 0; }
.gp-term { font-family: var(--font-head); font-weight: 700; font-size: 1.05rem; display: flex; align-items: center; gap: 6px; color: var(--accent); }
.gloss-pop p { margin: 6px 0 0; }
.gp-grown { color: var(--ink-2); font-size: .88rem; font-weight: 500; }
.gp-more { display: inline-flex; align-items: center; gap: 4px; margin-top: 8px; font-weight: 800; color: var(--accent); }

/* Floating help button. Sits above the safe area; .tucked slides it mostly off-screen on phones while playing. */
.help-fab { position: fixed; z-index: 900; right: max(16px, env(safe-area-inset-right)); bottom: max(16px, env(safe-area-inset-bottom)); width: 58px; height: 58px; padding: 6px; border-radius: 50%; border: 3px solid var(--ink); background: var(--card); box-shadow: var(--shadow); cursor: pointer; transition: transform .25s ease, opacity .25s ease; }
.help-fab.at-left { right: auto; left: max(16px, env(safe-area-inset-left)); }
.help-fab:hover { transform: translateY(-2px); }
.help-fab:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.help-fab .hf-robo, .help-fab .hf-robo svg { display: block; width: 100%; height: 100%; }
.help-fab .hf-q { position: absolute; top: -6px; right: -6px; width: 24px; height: 24px; border-radius: 50%; background: var(--warn); color: #1f2140; border: 2px solid var(--ink); font: 800 14px/20px var(--font-head); text-align: center; }
.help-fab.tucked { transform: translateX(calc(100% - 14px)); opacity: .55; }
.help-fab.at-left.tucked { transform: translateX(calc(-100% + 14px)); }
.help-fab.tucked:focus-visible { transform: none; opacity: 1; }

/* First-visit tip next to the button */
.help-tip { position: fixed; z-index: 901; right: max(16px, env(safe-area-inset-right)); bottom: calc(max(16px, env(safe-area-inset-bottom)) + 70px); max-width: min(280px, calc(100vw - 32px)); display: flex; align-items: flex-start; gap: 6px; padding: 10px 8px 10px 14px; background: var(--ink); color: var(--bg); border-radius: var(--radius-sm); box-shadow: var(--shadow); font-weight: 700; animation: help-pop .35s ease both; }
.help-tip.at-left { right: auto; left: max(16px, env(safe-area-inset-left)); }
.help-tip p { margin: 0; }
.help-tip kbd { color: var(--ink); }
.help-tip .icon-btn { flex: none; width: 32px; height: 32px; background: transparent; color: inherit; border-color: transparent; }
.help-tip::after { content: ""; position: absolute; bottom: -7px; right: 24px; width: 14px; height: 14px; background: var(--ink); transform: rotate(45deg); }
.help-tip.at-left::after { right: auto; left: 24px; }
@keyframes help-pop { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* Side sheet */
dialog.help-sheet { position: fixed; inset: 0 0 0 auto; margin: 0; max-width: 100vw; height: 100%; max-height: 100dvh; width: min(420px, 100vw); padding: 0; border: 0; border-left: 3px solid var(--line); background: var(--card); color: var(--ink); box-shadow: var(--shadow); display: none; flex-direction: column; }
dialog.help-sheet[open] { display: flex; animation: help-slide .25s ease both; }
dialog.help-sheet::backdrop { background: rgba(20, 20, 40, .45); }
@keyframes help-slide { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.hs-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px 10px; padding-top: max(14px, env(safe-area-inset-top)); border-bottom: 2px solid var(--line); }
.hs-head .robo { width: 44px; height: 44px; flex: none; }
.hs-head .robo svg { width: 100%; height: 100%; }
.hs-title { flex: 1; min-width: 0; }
.hs-title h2 { margin: 0; font-family: var(--font-head); font-size: 1.3rem; }
.hs-title small { color: var(--muted); font-weight: 700; }
.hs-tabs { display: flex; gap: 4px; padding: 8px 12px 0; border-bottom: 2px solid var(--line); }
.hs-tabs [role="tab"] { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 6px; border: 0; border-bottom: 3px solid transparent; background: none; color: var(--ink-2); font: 800 .9rem var(--font-body); cursor: pointer; border-radius: 10px 10px 0 0; }
.hs-tabs [role="tab"][aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); }
.hs-tabs [role="tab"]:focus-visible { outline: 3px solid var(--accent); outline-offset: -3px; }
.hs-body { flex: 1; overflow-y: auto; padding: 14px 16px 20px; overscroll-behavior: contain; }
.hs-body [role="tabpanel"]:focus-visible { outline: none; }
.hs-foot { display: flex; flex-wrap: wrap; gap: 6px 14px; padding: 10px 16px; padding-bottom: max(10px, env(safe-area-inset-bottom)); border-top: 2px solid var(--line); }
.hs-foot a { display: inline-flex; align-items: center; gap: 5px; font-weight: 800; color: var(--accent); text-decoration: none; }
.hs-foot a:hover { text-decoration: underline; }

.hs-lesson { display: flex; gap: 12px; align-items: flex-start; }
.hs-ic { flex: none; width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; font-size: 1.6rem; color: #fff; background: var(--c, var(--accent)); }
.hs-lesson small { color: var(--muted); font-weight: 800; }
.hs-lesson h3 { margin: 0 0 4px; font-family: var(--font-head); }
.hs-lesson p { margin: 0 0 6px; color: var(--ink-2); }
.hs-said { margin-top: 12px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--bg-2); }
.hs-said b { display: flex; align-items: center; gap: 6px; }
.hs-said p { margin: 4px 0 0; color: var(--ink-2); }
.hs-h { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 18px 0 8px; font-family: var(--font-head); font-size: 1.05rem; }
.hs-how, .hs-note { margin: 0 0 8px; color: var(--ink-2); }
.hs-path, .hs-guide, .hs-lessons, .hs-chal, .hs-tips { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.hs-guide, .hs-tips { padding-left: 1.2em; list-style: revert; color: var(--ink-2); }
.hs-path { counter-reset: hs; }
.hs-path li { counter-increment: hs; }
.hs-jump, .hs-path li.missing > div { width: 100%; display: grid; grid-template-columns: 28px 1fr auto; grid-template-rows: auto auto; column-gap: 8px; align-items: center; text-align: left; padding: 8px 10px; border: 2px solid var(--line); border-radius: var(--radius-sm); background: var(--bg); color: var(--ink); font: inherit; cursor: pointer; }
.hs-jump::before, .hs-path li.missing > div::before { content: counter(hs); grid-row: 1 / 3; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: #fff; font-weight: 800; font-size: .85rem; }
.hs-jump span, .hs-path li.missing span { grid-column: 2; font-size: .88rem; color: var(--ink-2); }
.hs-jump > svg, .hs-jump > .ic { grid-column: 3; grid-row: 1 / 3; color: var(--accent); }
.hs-jump:hover, .hs-jump:focus-visible { border-color: var(--accent); outline: none; }
.hs-path li.missing > div { cursor: default; opacity: .6; }
.hs-path li.missing > div::before { background: var(--muted); }
.hs-chal li, .hs-lessons li { display: flex; align-items: center; gap: 8px; }
.hs-tick { flex: none; width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; color: #fff; }
.hs-chal li.done .hs-tick, .hs-lessons .hs-tick { background: var(--good); border-color: var(--good); }
.hs-chal li.done > span:last-child { color: var(--ink-2); }
.hs-lessons a { flex: 1; font-weight: 700; color: var(--ink); text-decoration: none; }
.hs-lessons a:hover { color: var(--accent); }
.hs-lessons b { color: var(--muted); margin-right: 4px; }
.hs-next { margin-top: 12px; }
.hs-dotted { text-decoration: underline dotted 2px var(--accent); text-underline-offset: 3px; }
.hs-words { margin: 0; display: grid; gap: 8px; }
.hs-words > div { padding: 8px 12px; border-radius: var(--radius-sm); background: var(--bg); border: 2px solid var(--line); }
.hs-words dt { font-weight: 800; display: flex; align-items: center; gap: 6px; }
.hs-words dt a { color: var(--accent); }
.hs-words dd { margin: 2px 0 0; color: var(--ink-2); font-size: .92rem; }
.hs-more { color: var(--accent); display: inline-grid; }
.hs-keys { width: 100%; border-collapse: collapse; }
.hs-keys td { padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.hs-keys td:first-child { width: 80px; white-space: nowrap; }

/* "Jump to" highlight on the lesson section */
.help-flash { animation: help-flash 1.6s ease; border-radius: var(--radius-sm); }
@keyframes help-flash { 0%, 60% { box-shadow: 0 0 0 4px var(--accent); } 100% { box-shadow: 0 0 0 0 transparent; } }
.help-target { scroll-margin-top: 80px; }

@media (max-width: 640px) {
  dialog.help-sheet { inset: auto 0 0 0; width: 100%; height: auto; max-height: 88dvh; border-left: 0; border-top: 3px solid var(--line); border-radius: var(--radius) var(--radius) 0 0; }
  .hs-tabs [role="tab"] span { font-size: .82rem; }
  .help-fab { width: 50px; height: 50px; }
}
@media (prefers-reduced-motion: reduce) {
  .help-fab, dialog.help-sheet[open], .help-tip, .help-flash { animation: none !important; transition: none !important; }
}
html[data-motion="reduce"] .help-fab, html[data-motion="reduce"] dialog.help-sheet[open], html[data-motion="reduce"] .help-tip, html[data-motion="reduce"] .help-flash { animation: none !important; transition: none !important; }
@media print {
  .help-fab, .help-tip, .gloss-pop, dialog.help-sheet { display: none !important; }
  .gloss { text-decoration: none !important; background: none !important; }
}

/* Live room tab in the help sheet */
.lv-top { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; font-weight: 700; font-size: .9rem; margin-bottom: 10px; }
.lv-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--good); margin-right: 4px; box-shadow: 0 0 0 3px color-mix(in srgb, var(--good) 25%, transparent); }
.lv-feed { list-style: none; margin: 0 0 12px; padding: 8px; display: grid; gap: 6px; max-height: 210px; overflow-y: auto; background: var(--bg-2); border: 2px solid var(--line); border-radius: 12px; }
.lv-feed li { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: baseline; font-size: .9rem; }
.lv-feed li b { color: var(--accent); white-space: nowrap; }
.lv-feed li small { color: var(--muted); font-weight: 700; white-space: nowrap; }
.lv-feed .lv-empty { display: block; color: var(--muted); font-weight: 700; }
.lv-opts { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.lv-opts .chip { border: 2px solid var(--line); background: var(--card); color: var(--ink); border-radius: 999px; padding: 6px 12px; font: 700 .88rem var(--font-body); cursor: pointer; }
.lv-opts .chip:hover:not(:disabled) { border-color: var(--accent); }
.lv-opts .chip:disabled { opacity: .5; cursor: not-allowed; }
.help-tip.live-pop { padding: 8px 6px 8px 12px; align-items: center; }
.live-pop .lp-body { all: unset; cursor: pointer; display: grid; gap: 2px; min-width: 0; }
.live-pop .lp-body small { display: inline-flex; align-items: center; gap: 4px; font-size: .75rem; opacity: .75; }
.live-pop .lp-body small svg { width: 14px; height: 14px; }
.live-pop .lp-body span { font-size: .98rem; }
.live-pop .lp-body:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }
