/* ============================================================================
   Typimals — "Storybook Paper" theme
   Warm cream surfaces, one per-user accent, calm chrome so the cat + passage
   lead. Tokens live on :root; everything below consumes them.
   ========================================================================== */
:root {
  /* Surfaces */
  --bg:        #F7F2E9;  /* warm cream page background */
  --bg2:       #FFFFFF;  /* cards, chips, buttons */
  --card:      #FFFFFF;  /* passage card */
  --line:      #E7DEC9;  /* hairline borders */
  --track:     #EEE7DA;  /* progress-bar tracks */

  /* Ink */
  --ink:       #2A2620;  /* primary text */
  --ink2:      #8A8170;  /* secondary text */

  /* Brand accent — PER-USER (set at runtime). Default = Forest. */
  --accent:    #2F6E54;
  --accent-ink:#FFFFFF;  /* text/icon on accent fills */

  /* Semantic typing feedback — NEVER themed, always constant */
  --good:      #2E9B6B;  --good-bg: #DEF3E8;  --good-ink: #1C6B47;
  --bad:       #C8506A;  --bad-bg:  #F8E2E6;
  --auto:      #B7B19C;  /* letters the app types for you (faded) */
  --you:       #2A2620;  /* letters the child must type (dark) */
  --gold:      #C99A2E;  /* celebration star only */

  /* Keyboard */
  --keybg:     #FBF6EB;  --keyink: #4A4636;  --keyline: #E7DEC9;

  /* Finger colors (calm tints), keyed by finger id (see keyboard.js) */
  --f-left-pinky:   #B5476B;
  --f-left-ring:    #8E6BC4;
  --f-left-middle:  #2F8F6B;
  --f-left-index:   #2F6F9E;
  --f-right-index:  #2F8F87;
  --f-right-middle: #4F7BD0;
  --f-right-ring:   #7E5BC9;
  --f-right-pinky:  #B5476B;
  --f-thumb:        #8A8170;

  /* Typography */
  --font-display: 'Newsreader', Georgia, serif;
  --font-body: 'Hanken Grotesk', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;

  /* Shape & depth */
  --radius:    18px;     /* cards */
  --btn-r:     12px;     /* buttons — soft rectangle */
  --shadow:    0 8px 22px rgba(70, 58, 30, 0.10);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--bg);
}
body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ---- Top bar ------------------------------------------------------------ */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 13px clamp(16px, 4vw, 36px);
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 34px; height: 34px;
  border-radius: 10px;
  background: var(--accent);
  display: grid; place-items: center;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.25);
  flex: 0 0 auto;
}
.brand-mark svg { width: 19px; height: 19px; fill: var(--accent-ink); }
.brand-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 23px;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.points-stat {
  display: inline-flex; align-items: center; gap: 7px;
  padding-left: 14px;
  border-left: 1px solid var(--line);
  white-space: nowrap;
}
.points-dot {
  width: 11px; height: 11px; border-radius: 3px;
  transform: rotate(45deg);
  background: var(--accent);
  transition: transform 0.18s;
}
.points-stat.pop .points-dot { transform: rotate(45deg) scale(1.4); }
.points-value { font-weight: 800; font-size: 19px; color: var(--ink); }
.points-label { font-size: 13px; color: var(--ink2); font-weight: 600; }

/* Top-bar buttons share a soft-rectangle language. */
.btn-quiet, .btn-cats, .icon-btn {
  height: 40px;
  border-radius: var(--btn-r);
  white-space: nowrap;
  flex: 0 0 auto;
  font-family: var(--font-body);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.btn-quiet {                 /* "Sign in to save" — deliberately understated */
  padding: 0 12px;
  background: transparent;
  border: none;
  color: var(--ink2);
  font-weight: 600;
  font-size: 13px;
}
.btn-quiet:hover { color: var(--ink); }
.btn-quiet[data-state='in'] { cursor: default; color: var(--good-ink); }
.btn-cats {                  /* "My Cats" — the one accent-filled CTA */
  padding: 0 18px;
  background: var(--accent);
  border: 1px solid var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
  font-size: 14px;
  text-decoration: none;
  box-shadow: 0 6px 14px color-mix(in srgb, var(--accent) 34%, transparent);
  transition: transform 0.14s;
}
.btn-cats:hover { transform: translateY(-2px); }
.btn-cats svg { width: 17px; height: 17px; fill: var(--accent-ink); }
.btn-quiet svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn {
  width: 40px; padding: 0;
  justify-content: center;
  background: var(--bg2);
  border: 1px solid var(--line);
  color: var(--ink2);
  font-size: 17px;
  transition: transform 0.14s;
}
.icon-btn:hover { transform: translateY(-2px); color: var(--ink); }

/* ---- Quest map ---------------------------------------------------------- */
.questmap {
  display: flex;
  align-items: center;
  gap: 0;
  overflow-x: auto;
  padding: 12px clamp(16px, 4vw, 36px);
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}
.qm-node {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
}
.qm-node:not(:last-child)::after {
  content: '';
  width: clamp(18px, 3.4vw, 46px);
  height: 2px;
  background: var(--line);
  flex: 0 0 auto;
}
.qm-star {
  width: 26px; height: 26px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-weight: 700;
  font-size: 11px;
  color: var(--ink2);
  background: var(--bg2);
  border: 1px solid var(--line);
  flex: 0 0 auto;
}
.qm-node[data-state='done'] .qm-star {
  color: var(--accent-ink);
  background: var(--accent);
  border-color: var(--accent);
}
.qm-node[data-state='current'] .qm-star {
  width: 30px; height: 30px;
  font-size: 12px;
  color: var(--ink);
  background: var(--bg2);
  border: 2px solid var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 22%, transparent);
}
.qm-label {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 13px;
  color: var(--ink);
  white-space: nowrap;
}

/* ---- Stage layout ------------------------------------------------------- */
.stage {
  flex: 1;
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: clamp(14px, 2.2vw, 22px);
  padding: 22px clamp(16px, 4vw, 36px) 30px;
  align-items: start;
}

/* ---- Companion card ----------------------------------------------------- */
.companion { position: sticky; top: 12px; }
.companion-card {
  position: relative;
  padding: 18px 16px 20px;
  border-radius: var(--radius);
  background: var(--bg2);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  text-align: center;
}
.companion-figure { position: relative; }
.companion-aura {
  position: absolute;
  left: 50%; top: 18%;
  width: 74%; aspect-ratio: 1;
  transform: translateX(-50%);
  background: radial-gradient(circle, color-mix(in srgb, var(--accent) 26%, transparent), transparent 65%);
  filter: blur(7px);
  pointer-events: none;       /* decorative — never intercept clicks */
}
.companion-img {
  position: relative;
  width: 150px; max-width: 86%;
  filter: drop-shadow(0 10px 14px rgba(0, 0, 0, 0.18));
}
.breathe { transform-origin: 50% 92%; animation: breathe 3.8s ease-in-out infinite; }
@keyframes breathe {
  0%, 100% { transform: scale(1) translateY(0); }
  50%      { transform: scale(1.02, 0.99) translateY(-2px); }
}
.companion-bounce { animation: catbounce 0.7s ease; }
@keyframes catbounce {
  0% { transform: translateY(0) scale(1); }
  30% { transform: translateY(-14px) scale(1.08, 0.96); }
  55% { transform: translateY(0) scale(0.96, 1.06); }
  100% { transform: translateY(0) scale(1); }
}
.companion-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 19px;
  color: var(--ink);
  margin: 4px 0 0;
}
/* The buddy is a link to the friends gallery. */
.companion-link { display: block; color: inherit; text-decoration: none; cursor: pointer; border-radius: 14px; }
.companion-link .companion-figure { transition: transform 0.18s ease; }
.companion-link:hover .companion-figure { transform: translateY(-3px); }
.companion-link:hover .companion-name { color: var(--accent); }
.companion-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.companion-progress-label { font-size: 11.5px; color: var(--ink2); margin: 9px 0 6px; }

/* ---- Progress bars ------------------------------------------------------ */
.bar {
  height: 9px;
  border-radius: 999px;
  background: var(--track);
  overflow: hidden;
}
.bar > span {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: var(--accent);
  transition: width 0.4s cubic-bezier(0.3, 1.2, 0.5, 1);
}

/* ---- Play column -------------------------------------------------------- */
.play { display: flex; flex-direction: column; gap: 14px; }
.level-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  border-radius: var(--radius);
  background: var(--bg2);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.level-badge {
  width: 44px; height: 44px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 20px;
  color: var(--accent-ink);
  background: var(--accent);
  flex: 0 0 auto;
}
.level-eyebrow {
  margin: 0;
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink2);
  font-weight: 700;
}
.level-name { margin: 1px 0 0; font-family: var(--font-display); font-weight: 700; font-size: 19px; color: var(--ink); }
.level-progress { margin-left: auto; text-align: right; min-width: 130px; }
.level-progress-label { font-size: 11px; color: var(--ink2); margin-bottom: 5px; }

/* ---- Passage (typewriter) ---------------------------------------------- */
.passage-card {
  position: relative;
  padding: 26px 30px;
  min-height: 88px;
  border-radius: var(--radius);
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  transition: box-shadow 0.3s;
}
.passage-card.done { box-shadow: var(--shadow), 0 0 0 2px color-mix(in srgb, var(--good) 55%, transparent); }
.passage {
  font-family: var(--font-mono);
  font-size: clamp(1.3rem, 2.6vw, 29px);
  line-height: 1.85;
  letter-spacing: 0.5px;
  color: var(--you);
}
.word { display: inline-block; white-space: nowrap; }
.ch {
  position: relative;
  display: inline-block;
  padding: 2px 1px;
  border-radius: 5px;
  white-space: pre;
  color: var(--you);
  font-weight: 700;
  transition: background 0.1s, color 0.1s;
}
.ch.you  { color: var(--you); font-weight: 700; }
.ch.auto { color: var(--auto); font-weight: 500; }      /* faded — NO italics */
.ch.autodone { color: var(--auto); font-weight: 500; }
.ch.good { color: var(--good-ink); background: var(--good-bg); }
.ch.bad  { color: var(--bad); background: var(--bad-bg); box-shadow: inset 0 0 0 1.5px var(--bad); }
/* Current letter to press: bold + accent underline. */
.ch.caret { font-weight: 800; border-bottom: 3px solid var(--accent); border-bottom-left-radius: 0; border-bottom-right-radius: 0; padding-bottom: 1px; }
/* A mistyped key briefly appears, then falls away — cueing "backspace me". */
.ghost-wrong {
  position: absolute;
  left: 50%; top: -2px;
  transform: translateX(-50%);
  color: var(--bad);
  font-weight: 800;
  pointer-events: none;
  animation: ghostdrop 0.55s ease-in forwards;
}
@keyframes ghostdrop {
  0% { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
  100% { opacity: 0; transform: translateX(-50%) translateY(24px) scale(0.78); }
}

.hint-line {
  margin: 0;
  font-size: 13.5px;
  color: var(--ink2);
  text-align: center;
  min-height: 1.4em;
}
.hint-line strong { color: var(--ink); }
.hint-line .faded { color: var(--auto); font-weight: 700; }

.legend {
  display: flex;
  gap: 18px;
  justify-content: center;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--ink2);
}
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-item[hidden] { display: none; }
.legend-sample {
  display: inline-grid;
  place-items: center;
  width: 20px; height: 22px;
  border-radius: 5px;
  background: var(--card);
  border: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 0.9rem;
  line-height: 1;
}
.legend-sample.sample-you  { color: var(--you); font-weight: 800; }
.legend-sample.sample-auto { color: var(--auto); font-weight: 700; }
.legend-sample.sample-good { color: var(--good-ink); background: var(--good-bg); border-color: transparent; font-weight: 800; }
.legend-sample.sample-bad  { color: var(--bad); background: var(--bad-bg); border-color: transparent; box-shadow: inset 0 0 0 1.5px var(--bad); font-weight: 800; }

/* ---- Keyboard ----------------------------------------------------------- */
.keyboard-wrap {
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--bg2);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  overflow-x: auto;
}
/* Hand-position overlay (public/hands/, see hand-gen/HANDOFF.md).
   The images are pixel-registered to the keyboard geometry: in their
   601×426-unit scene the keyboard CONTENT box sits at (29,31) sized 543×190 —
   exactly #keyboard's real size — so the overlay anchors to the keyboard
   itself (the wrap is wider than the harness assumed and can't be the anchor).
   Keyboard GEOMETRY (key size/gaps/offsets/padding) must not change, or the
   whole image set needs regenerating. */
.hands-anchor { position: relative; width: fit-content; margin: 0 auto; }
#hand-overlay {
  position: absolute;
  left: -29px;
  top: -31px;
  width: 601px;
  height: 426px;
  max-width: none;
  pointer-events: none;
  z-index: 2;
  opacity: 0.7;          /* key labels stay readable through the hands */
}
#hand-overlay[hidden] { display: none; }
body.hands-on .keyboard-wrap {
  overflow: visible;     /* the wrists hang ~190px below the wrap */
  margin-bottom: 190px;
}
/* Screens narrower than the fixed-size keyboard: keep it scrollable, no hands. */
@media (max-width: 700px) {
  body.hands-on .keyboard-wrap { overflow-x: auto; margin-bottom: 0; }
  #hand-overlay { display: none; }
}
.keyboard {
  display: flex;
  flex-direction: column;
  gap: 5px;
  width: fit-content;
  margin: 0 auto;
}
.kb-row { display: flex; gap: 5px; justify-content: flex-start; }
.key {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 8px;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--keyink);
  background: color-mix(in srgb, var(--fc, var(--keyline)) 15%, var(--keybg));
  border: 1px solid color-mix(in srgb, var(--fc, var(--keyline)) 38%, var(--keyline));
  flex: 0 0 auto;
  --fc: var(--f-left-index);
}
.key[data-home='true'] {
  font-weight: 700;
  background: color-mix(in srgb, var(--fc) 30%, var(--keybg));
  border-color: color-mix(in srgb, var(--fc) 60%, var(--keyline));
}
.key.active {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
  font-weight: 800;
}
.key-shift {
  width: 74px;
  font-size: 11px;
  color: var(--ink2);
  background: var(--keybg);
  border: 1px solid var(--keyline);
}
/* Shift is half of the chord the learner must press — highlight it exactly as
   loudly as the letter key (a washed-out Shift read as "less important"). */
.key-shift.shift-active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 800;
}
.key-space {
  width: 240px;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink2);
  background: var(--keybg);
  border: 1px solid var(--keyline);
}

/* ---- Buttons ------------------------------------------------------------ */
.btn {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 15px;
  padding: 12px 22px;
  border-radius: var(--btn-r);
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.14s, box-shadow 0.14s, background 0.14s;
}
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(0); }
.btn-primary {
  color: var(--accent-ink);
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 8px 18px color-mix(in srgb, var(--accent) 36%, transparent);
}
.btn-ghost {
  color: var(--ink);
  background: var(--bg2);
  border: 1px solid var(--line);
}
.btn-quiet-text {
  color: var(--ink2);
  background: transparent;
  border: 1px solid transparent;
}
.btn-grownup { width: 100%; color: var(--ink2); background: transparent; border: 1px solid var(--line); font-size: 14px; }
.btn-sm { font-size: 13px; padding: 8px 14px; }
.btn[disabled] { opacity: 0.5; cursor: default; transform: none; }

/* ---- Overlays / popups -------------------------------------------------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(42, 38, 32, 0.5);
  backdrop-filter: blur(4px);
  animation: fade 0.2s ease;
}
.overlay[hidden] { display: none; }
@keyframes fade { from { opacity: 0; } }
.popup {
  position: relative;
  width: min(460px, 94vw);
  max-height: 90vh;
  overflow-y: auto;
  padding: 28px 26px 24px;
  border-radius: 22px;
  text-align: center;
  background: var(--bg);
  color: var(--ink);
  border: 1px solid var(--line);
  box-shadow: 0 22px 54px rgba(24, 20, 44, 0.18);
  animation: popin 0.32s cubic-bezier(0.2, 1.2, 0.4, 1);
}
@keyframes popin { from { transform: scale(0.94); opacity: 0; } }
.popup-title-sm { font-size: 1.4rem; }
.popup-close {
  position: absolute;
  top: 12px; right: 14px;
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border: none; border-radius: 50%;
  background: color-mix(in srgb, var(--ink) 6%, transparent);
  color: var(--ink2);
  font-size: 1rem;
  cursor: pointer;
  z-index: 2;
}
.popup-close:hover { background: color-mix(in srgb, var(--ink) 12%, transparent); color: var(--ink); }
.popup-divider { height: 1px; margin: 18px 0 14px; background: var(--line); }
.popup-kicker {
  margin: 0 0 4px;
  font-family: var(--font-body);
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 0.72rem;
  color: var(--accent);
}
.popup-title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.7rem;
  color: var(--ink);
}
.popup-sub { margin: 6px 0 16px; color: var(--ink2); font-size: 0.92rem; }
.popup-keys { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-bottom: 20px; }
.popup-key {
  min-width: 40px; height: 46px;
  padding: 0 10px;
  display: grid; place-items: center;
  border-radius: 10px;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--accent-ink);
  background: var(--accent);
  border: 1px solid var(--accent);
  animation: keypop 0.4s backwards;
}
@keyframes keypop { from { transform: translateY(-14px) scale(0.6); opacity: 0; } }
.popup-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.popup-confetti { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
@keyframes confetti { to { transform: translateY(420px) rotate(540deg); opacity: 0; } }
.popup-levelup, .popup-catunlock { overflow: hidden; }

/* ---- Unlock celebration (big reveal) ----------------------------------- */
#catunlock-overlay { background: radial-gradient(120% 90% at 50% 0%, #403726, #2A2620); }
.popup-catunlock { width: min(430px, 94vw); padding: 28px 30px 26px; }
.catunlock-stage { position: relative; margin: 14px 0 6px; display: grid; place-items: center; min-height: 250px; }
.catunlock-glow {
  position: absolute; left: 50%; top: 50%;
  width: 300px; height: 300px;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, color-mix(in srgb, var(--accent) 34%, transparent), transparent 62%);
  filter: blur(6px);
  pointer-events: none;
}
.catunlock-rays {
  position: absolute; left: 50%; top: 50%;
  width: 280px; height: 280px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: conic-gradient(from 0deg, transparent 0 8deg, color-mix(in srgb, var(--gold) 34%, transparent) 8deg 16deg, transparent 16deg 24deg);
  opacity: 0.5;
  animation: spin 26s linear infinite;
  pointer-events: none;
}
@keyframes spin { to { transform: translate(-50%, -50%) rotate(360deg); } }
.catunlock-img {
  position: relative;
  width: 240px; max-width: 70%;
  filter: drop-shadow(0 14px 20px rgba(0, 0, 0, 0.32));
  animation: floaty 3.4s ease-in-out infinite;
}
@keyframes floaty { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-7px); } }

/* ---- Adult / settings panel -------------------------------------------- */
/* Wide, clearly sectioned grown-up panel: an Account bar, then two side-by-
   side cards — Profiles (applies immediately) and Fine-tuning (optional,
   with its own Save/Discard so its scope is unambiguous). */
/* Only the unlocked settings panel is wide — the sign-in gate and the math
   challenge (a 4-digit answer) stay at the compact default popup width. */
.popup-adult.adult-wide { width: min(760px, 94vw); }
#adult-panel { text-align: left; }
#adult-panel .popup-title { text-align: center; margin-bottom: 14px; }
.adult-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  align-items: start;
  margin-top: 14px;
}
.adult-card {
  padding: 16px 18px 18px;
  border-radius: 16px;
  background: var(--bg2);
  border: 1px solid var(--line);
  text-align: left;
}
/* Section headers — bigger and darker than any label inside them. */
.adult-card-head {
  display: flex; align-items: center; gap: 9px;
  margin: 0 0 6px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.18rem;
  color: var(--ink);
}
.adult-optional-tag {
  padding: 2px 9px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 13%, #fff);
  color: var(--accent);
  font-family: var(--font-body);
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.adult-subhead {
  margin: 16px 0 8px;
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--ink2);
}
/* Inputs/chips sit on a white card — use the cream page tone for contrast. */
.adult-card .profile-chip { background: var(--bg); }
.adult-card .profile-chip[data-active='true'] { background: color-mix(in srgb, var(--accent) 12%, #fff); }
.adult-card .profile-edit input, .adult-card .profile-add-form input { background: var(--bg); }
.adult-card .profile-add-form { background: var(--bg); }
.adult-card .animal-card { background: var(--bg); }
.adult-card .animal-card[data-active='true'] { background: color-mix(in srgb, var(--accent) 12%, #fff); }
.animal-grid-sm.adult-animal-grid { grid-template-columns: repeat(6, 1fr); gap: 6px; }
.animal-grid-sm.adult-animal-grid .animal-card { padding: 9px 2px 7px; border-radius: 12px; }
.animal-grid-sm.adult-animal-grid .animal-card img { width: 34px; height: 34px; }
.animal-grid-sm.adult-animal-grid .animal-card-name { font-size: 10px; }
.swatch-row-start { justify-content: flex-start; gap: 10px; margin-bottom: 4px; }
.swatch-row-start .swatch { width: 34px; height: 34px; }
.swatch-row-start .swatch[data-active='true'] { width: 38px; height: 38px; }
.adult-tuning-actions { justify-content: flex-end; margin-top: 16px; }
@media (max-width: 700px) {
  .adult-columns { grid-template-columns: 1fr; }
}

.adult-account { text-align: left; }
.adult-acct-status { margin: 0 0 8px; font-size: 0.88rem; color: var(--ink); }
.adult-acct-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.adult-acct-actions:empty { display: none; }
.adult-hint { margin: 0 0 10px; font-size: 0.82rem; color: var(--ink2); line-height: 1.45; }
.profile-list { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.profile-chip {
  padding: 8px 14px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--ink);
  background: var(--bg2);
  border: 1px solid var(--line);
  cursor: pointer;
}
.profile-chip[data-active='true'] {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, #fff);
  border-color: var(--accent);
}
.profile-edit { display: flex; gap: 8px; flex-wrap: wrap; }
.profile-edit input, .profile-add-form input {
  flex: 1 1 120px;
  padding: 9px 12px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--bg2);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 0.95rem;
}
.profile-add-form {
  margin-top: 12px;
  padding: 14px;
  border-radius: 14px;
  background: var(--bg2);
  border: 1px solid var(--line);
  text-align: left;
}
.profile-add-form input { width: 100%; margin-bottom: 8px; }
.adult-version { margin: 14px 0 0; text-align: center; font-size: 0.72rem; color: var(--ink2); letter-spacing: 0.02em; }
.adult-signin-note { margin: 12px 0 0; font-size: 0.82rem; color: var(--ink2); }

/* Math challenge */
.challenge-prompt {
  margin: 6px 0 14px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.3rem;
  color: var(--accent);
  text-transform: capitalize;
}
.adult-input {
  width: 100%;
  margin: 12px 0;
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg2);
  color: var(--ink);
  font-size: 1.4rem;
  text-align: center;
  letter-spacing: 8px;
  font-family: var(--font-mono);
}
.adult-error { color: var(--bad); margin: 0 0 8px; font-weight: 600; }
.adult-field { display: block; text-align: left; margin: 16px 0; }
.adult-field .adult-field-label { display: block; margin-bottom: 8px; font-weight: 700; font-size: 0.9rem; color: var(--ink); }
.adult-field input[type='range'] { width: 100%; accent-color: var(--accent); }
.adult-field-help { display: block; margin-top: 7px; font-size: 0.78rem; line-height: 1.45; color: var(--ink2); font-weight: 400; }
/* "2 · Stepping Stones" stays glued together on one line with its label. */
.adult-stage-value { white-space: nowrap; }
.adult-stage-name { color: var(--accent); font-weight: 700; }
.adult-points-field { margin: 0 0 14px; }
.adult-points-field input[type='number'] {
  width: 100%;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg2);
  color: var(--ink);
  font-size: 1.2rem;
  font-family: var(--font-mono);
}

/* ---- Animal picker grid (settings / add profile) ----------------------- */
.animal-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 11px;
  margin: 6px 0 4px;
}
.animal-grid-sm { grid-template-columns: repeat(5, 1fr); gap: 8px; }
.animal-card {
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  padding: 13px 4px 10px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--bg2);
  cursor: pointer;
  transition: transform 0.14s, box-shadow 0.14s, background 0.14s;
}
.animal-card:hover { transform: translateY(-3px); }
.animal-card img { width: 56px; height: 56px; object-fit: contain; }
.animal-grid-sm .animal-card img { width: 44px; height: 44px; }
.animal-card-name { font-weight: 700; font-size: 12px; color: var(--ink2); }
.animal-grid-sm .animal-card-name { font-size: 11px; }
.animal-card[data-active='true'] {
  background: color-mix(in srgb, var(--accent) 12%, #fff);
  border: 2px solid var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
.animal-card[data-active='true'] .animal-card-name { color: var(--ink); }

/* ---- Settings sections -------------------------------------------------- */
.settings-heading {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 19px;
  color: var(--ink);
  margin: 18px 0 2px;
}
.settings-heading:first-of-type { margin-top: 4px; }
.popup-settings .swatch-row { margin-bottom: 6px; }

/* ---- Onboarding (2 steps) ---------------------------------------------- */
.onboard-step[hidden] { display: none; }
.onboard-eyebrow {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--accent); font-weight: 800;
}
.onboard-eyebrow .step-num {
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; font-size: 11px;
}
.onboard-title { font-family: var(--font-display); font-weight: 700; font-size: 27px; color: var(--ink); margin: 10px 0 3px; }
.onboard-sub { font-size: 13px; color: var(--ink2); margin-bottom: 20px; }
.onboard-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 22px; }
.onboard-dots { font-size: 13px; color: var(--auto); font-weight: 700; letter-spacing: 2px; }
.onboard-note { margin: 14px 0 0; font-size: 12px; color: var(--ink2); }
/* color preview + swatches (step 2) */
.color-preview { position: relative; margin-bottom: 18px; display: grid; place-items: center; min-height: 130px; }
.color-preview .companion-aura { top: 50%; transform: translate(-50%, -50%); width: 130px; height: 130px; aspect-ratio: auto; }
.color-preview img { position: relative; width: 108px; filter: drop-shadow(0 8px 12px rgba(0, 0, 0, 0.16)); }
.swatch-row { display: flex; gap: 13px; justify-content: center; margin-bottom: 22px; flex-wrap: wrap; }
.swatch {
  width: 42px; height: 42px; border-radius: 50%;
  cursor: pointer; border: none; padding: 0;
  position: relative;
  transition: transform 0.12s;
}
.swatch:hover { transform: scale(1.08); }
.swatch[data-active='true'] {
  width: 46px; height: 46px;
  box-shadow: 0 0 0 3px var(--bg), 0 0 0 6px currentColor;
}
.swatch[data-active='true']::after {
  content: '✓';
  position: absolute; inset: 0;
  display: grid; place-items: center;
  color: var(--accent-ink); font-size: 20px; font-weight: 800;
}

/* ---- Toggle switch (helping hands) -------------------------------------- */
.hands-toggle {
  display: flex;
  align-items: center;
  gap: 11px;
  width: fit-content;
  margin: 4px auto 6px;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}
#adult-panel .hands-toggle { margin: 4px 0 2px; }  /* left-aligned in the grown-up card */
.hands-toggle input {
  position: absolute;
  opacity: 0;
  width: 1px; height: 1px;
}
.hands-toggle .switch {
  flex: none;
  width: 46px; height: 26px;
  border-radius: 999px;
  background: var(--track);
  border: 1px solid var(--line);
  position: relative;
  transition: background 0.18s, border-color 0.18s;
}
.hands-toggle .switch::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(24, 20, 44, 0.25);
  transition: transform 0.18s ease;
}
.hands-toggle input:checked + .switch {
  background: var(--accent);
  border-color: var(--accent);
}
.hands-toggle input:checked + .switch::after { transform: translateX(20px); }
.hands-toggle input:focus-visible + .switch {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.hands-toggle-text { font-weight: 700; font-size: 0.9rem; color: var(--ink); }

/* ---- Responsive --------------------------------------------------------- */
@media (max-width: 820px) {
  .stage { grid-template-columns: 1fr; }
  .companion { position: static; }
  .companion-img { width: 130px; }
  .level-head { flex-wrap: wrap; }
  .level-progress { margin-left: 0; width: 100%; text-align: left; }
  .animal-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; }
}
