/* alivey promo demo — "Toybox" theme (see app/DESIGN.md).
   Plain HTML/CSS/JS, no build step. Section map:
   1. reset + tokens        5. onboarding overlay (photo/generating/reveal)
   2. squishy button system 6. home screen
   3. type helpers          7. bedtime mode
   4. welcome screen         8. sheets (stories/games)
                             9. reduced motion + desktop frame
*/

/* ---------- 1. reset + tokens ---------- */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

:root {
  --cream: #FFF7EC;
  --peach: #FFE9D6;
  --peach-deep: #F0C69C;
  --sky: #E7F4FF;
  --sky-deep: #C4DFF3;
  --ink: #3D2B26;
  --ink-soft: #8A7268;
  --coral: #FF6B4A;
  --coral-deep: #D14A2C;
  --gold: #FFC24B;
  --gold-deep: #D9942A;
  --mint: #BFE8CD;
  --mint-deep: #6FBB8C;
  --white: #FFFFFF;
  --stage-navy: #1A103C;

  --font: "Baloo 2", ui-rounded, -apple-system, system-ui, sans-serif;

  --ease-press: cubic-bezier(0.2, 0.9, 0.3, 1.1);
  --ease-release: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-ios: cubic-bezier(0.32, 0.72, 0, 1);
  --dur-press: 90ms;
  --dur-release: 220ms;
  --dur-screen: 300ms;
}

html, body {
  height: 100%;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

body {
  font-family: var(--font);
  background: var(--cream);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

button {
  font-family: inherit;
  cursor: pointer;
  -webkit-touch-callout: none;
  color: inherit;
}
button:focus-visible { outline: 3px solid var(--coral); outline-offset: 3px; }
button:focus:not(:focus-visible) { outline: none; }
button:disabled { cursor: default; }

svg { display: block; }

/* Desktop: center the phone-shaped app so it still demos fine off-device. */
#app {
  position: relative;
  height: 100dvh;
  max-width: 430px;
  margin: 0 auto;
  background: var(--cream);
  overflow: hidden;
}
@media (min-width: 431px) {
  body { display: flex; align-items: center; justify-content: center; }
  #app {
    /* Every .screen inside is position:absolute, so as a flex item #app has
       no intrinsic width and collapsed to 0 — the phone frame only ever
       rendered on mobile, where body isn't a flex container. */
    width: 100%;
    height: min(100dvh, 932px);
    border-radius: 44px;
    box-shadow: 0 30px 80px -20px rgba(26, 16, 60, 0.5);
  }
}

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
}

/* ---------- 2. squishy button system ----------
   Anatomy: the button box is relatively positioned; `.edge` and `.face` are
   BOTH the same size as the box (via inset), the edge sits flush at the
   bottom (top: depth), the face sits flush at the top (bottom: depth) — so
   at rest only the edge's bottom `depth` px peeks out beneath the face.
   Pressing translates the face down by exactly `depth`, landing it on the
   edge, so the button reads as "shorter". translateY only — no scale. */
.squishy {
  position: relative;
  border: none;
  background: none;
  padding: 0;
  display: block;
}
.squishy .edge {
  position: absolute;
  top: var(--sq-depth);
  right: 0;
  bottom: 0;
  left: 0;
  border-radius: inherit;
  background: var(--sq-edge);
}
.squishy .face {
  position: absolute;
  top: 0;
  right: 0;
  bottom: var(--sq-depth);
  left: 0;
  border-radius: inherit;
  background: var(--sq-face);
  color: var(--sq-ink, var(--ink));
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transform: translateY(0);
  transition: transform var(--dur-release) var(--ease-release);
}
.squishy:active .face {
  transform: translateY(var(--sq-depth));
  transition: transform var(--dur-press) var(--ease-press);
}
.squishy:disabled { opacity: 0.45; }
.squishy:disabled .face { transform: translateY(0) !important; transition: none; }

.depth-4 { --sq-depth: 4px; }
.depth-5 { --sq-depth: 5px; }
.depth-6 { --sq-depth: 6px; }
.depth-7 { --sq-depth: 7px; }

.sq-primary { --sq-face: var(--coral); --sq-edge: var(--coral-deep); --sq-ink: var(--white); }
.sq-peach   { --sq-face: var(--peach); --sq-edge: var(--peach-deep); --sq-ink: var(--ink); }
.sq-white   { --sq-face: var(--white); --sq-edge: var(--peach-deep); --sq-ink: var(--ink); }
.sq-gold    { --sq-face: var(--gold);  --sq-edge: var(--gold-deep);  --sq-ink: var(--ink); }
.sq-mint    { --sq-face: var(--mint);  --sq-edge: var(--mint-deep);  --sq-ink: var(--ink); }

/* ---------- 3. type helpers ---------- */
.display-text { font-family: var(--font); font-weight: 800; font-size: clamp(28px, 8vw, 34px); line-height: 1.15; color: var(--ink); }
.title-text { font-family: var(--font); font-weight: 700; font-size: 26px; line-height: 1.2; color: var(--ink); }
.body-text { font-family: var(--font); font-weight: 500; font-size: 17px; line-height: 1.4; color: var(--ink-soft); }
.label-text { font-family: var(--font); font-weight: 700; font-size: 16px; line-height: 1.25; }
.caption-text { font-family: var(--font); font-weight: 500; font-size: 13px; line-height: 1.35; color: var(--ink-soft); }

.ghost-btn {
  border: none;
  background: none;
  padding: 12px 16px;
  min-height: 44px;
  font-family: var(--font);
  font-weight: 700;
  font-size: 15px;
  color: var(--ink-soft);
  transition: transform var(--dur-press) ease-out, opacity var(--dur-press) ease-out;
}
.ghost-btn:active { transform: scale(0.97); opacity: 0.7; }
.ghost-btn-dark { color: var(--ink-soft); }

/* ---------- 4. welcome screen ---------- */
.welcome-screen {
  background: var(--cream);
  align-items: center;
  justify-content: center;
  gap: 40px;
  padding: calc(env(safe-area-inset-top) + 24px) 28px calc(env(safe-area-inset-bottom) + 24px);
  text-align: center;
}
/* Three stacked actions now (real scan / quick demo / demo friend) — the
   original 40px gap no longer fits on a 568px-tall viewport. */
@media (max-height: 700px) { .welcome-screen { gap: 26px; } }
.welcome-decor { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 0; }
.blob { position: absolute; border-radius: 50%; opacity: 0.55; filter: blur(1px); }
.blob-a { width: 220px; height: 220px; background: var(--peach); top: -60px; left: -70px; }
.blob-b { width: 160px; height: 160px; background: var(--sky); bottom: 8%; right: -50px; opacity: 0.7; }

.welcome-content { position: relative; z-index: 1; display: flex; flex-direction: column; gap: 14px; max-width: 340px; }
.welcome-sub { font-size: 17px; }

.welcome-actions { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; width: min(320px, 100%); }

.cta-primary {
  width: 100%;
  height: 76px;
  border-radius: 28px;
}
.cta-primary .face {
  font-weight: 700;
  font-size: 18px;
}
/* The quick flow's CTA, one step down from the real scan's. When the real
   scan is unavailable (no TRIPO_API_KEY) app.js promotes this one instead. */
.cta-secondary {
  width: 100%;
  height: 62px;
  border-radius: 22px;
}
.cta-secondary .face {
  font-weight: 700;
  font-size: 16.5px;
}
.scan-note {
  max-width: 300px;
  margin: -2px auto 4px;
  text-align: center;
  color: var(--ink);
  opacity: 0.55;
}

.btn-icon { width: 22px; height: 22px; flex: none; }
.btn-icon-sm { width: 18px; height: 18px; flex: none; }

/* ---------- 5. onboarding overlay: photo confirm / generating / reveal ---------- */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 22px;
  padding: calc(env(safe-area-inset-top) + 24px) 24px calc(env(safe-area-inset-bottom) + 28px);
}
.onboard-overlay {
  /* Deeper take on the app's warm stage wash — the white plush needs the
     darker peach rim to pop. Keep in sync with .home-stage-wrap. */
  background: radial-gradient(120% 90% at 50% 34%, #FFEBD2 0%, #F5CFA6 52%, #E6B27E 100%);
  color: var(--ink);
  animation: screen-in var(--dur-screen) var(--ease-ios);
}
@keyframes screen-in {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

.scan-frame {
  position: relative;
  --frame-w: min(58vw, 220px);
  width: var(--frame-w);
  aspect-ratio: 3 / 4;
  margin: auto auto 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.scan-photo {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 26px;
  background: var(--peach);
  box-shadow: 0 20px 50px rgba(61, 43, 38, 0.18);
}
.bracket { position: absolute; z-index: 2; width: 26px; height: 26px; border: 3px solid rgba(61, 43, 38, 0.4); display: block; animation: bracket-pulse 1.8s var(--ease-ios) infinite; }
.bracket.tl { top: -8px; left: -8px; border-right: none; border-bottom: none; border-radius: 10px 0 0 0; }
.bracket.tr { top: -8px; right: -8px; border-left: none; border-bottom: none; border-radius: 0 10px 0 0; }
.bracket.bl { bottom: -8px; left: -8px; border-right: none; border-top: none; border-radius: 0 0 0 10px; }
.bracket.br { bottom: -8px; right: -8px; border-left: none; border-top: none; border-radius: 0 0 10px 0; }
@keyframes bracket-pulse { 0%, 100% { opacity: 0.6; } 50% { opacity: 1; } }

/* Perfect circles, centered on the photo and painted BEHIND it (the photo
   carries z-index 1) — sized off the frame's HEIGHT (width * 4/3) so they
   stay round instead of stretching into the frame's 3:4 ellipse. */
.orbit-ring {
  --ring-d: calc(var(--frame-w) * 4 / 3 + 34px);
  position: absolute;
  left: 50%;
  top: 50%;
  width: var(--ring-d);
  height: var(--ring-d);
  margin-left: calc(var(--ring-d) / -2);
  margin-top: calc(var(--ring-d) / -2);
  border-radius: 50%;
  border: 2px dashed var(--coral);
  opacity: 0.35;
  animation: orbit-spin 9s linear infinite;
}
.orbit-ring.r2 { --ring-d: calc(var(--frame-w) * 4 / 3 + 72px); border-style: dotted; border-color: var(--gold); opacity: 0.3; animation-duration: 6.5s; animation-direction: reverse; }
@keyframes orbit-spin { to { transform: rotate(360deg); } }

.onboard-actions { display: flex; flex-direction: column; align-items: center; gap: 10px; width: min(320px, 100%); }

.gen-card {
  width: 100%;
  max-width: 380px;
  background: var(--white);
  border: 1px solid var(--peach-deep);
  border-radius: 26px;
  padding: 22px 20px;
  text-align: left;
}
.gen-title { font-family: var(--font); font-weight: 700; font-size: 19px; color: var(--ink); margin-bottom: 16px; }

.progress-track { height: 12px; border-radius: 8px; background: var(--peach); overflow: hidden; margin-bottom: 18px; }
.progress-fill {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 8px;
  background: linear-gradient(90deg, var(--coral), var(--gold));
}
.progress-fill.filling { transition: width 8000ms linear; }

.gen-steps { display: flex; flex-direction: column; gap: 12px; }
.gen-step { display: flex; align-items: center; gap: 10px; font-family: var(--font); font-weight: 700; font-size: 14px; color: var(--ink); transition: opacity 0.2s var(--ease-ios); }
.step-dot {
  width: 20px; height: 20px; flex: none; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--peach-deep); color: var(--gold);
}
.step-dot svg { width: 11px; height: 11px; }
.gen-step.wait { opacity: 0.45; }
.gen-step.now .step-dot { border-color: var(--gold); animation: dot-pulse 1.1s ease-in-out infinite; }
.gen-step.done { opacity: 0.6; }
.gen-step.done .step-dot { background: var(--gold); border-color: var(--gold); color: var(--ink); }
@keyframes dot-pulse { 50% { transform: scale(1.2); } }

.reveal-step { position: relative; width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 16px; }
.stage-mount { width: 100%; }
#reveal-stage-mount { flex: 1; min-height: 0; position: relative; }
#reveal-stage-mount model-viewer, #home-stage-mount model-viewer {
  width: 100%;
  height: 100%;
  --poster-color: transparent;
  background: transparent;
}
.reveal-name { color: var(--ink); text-align: center; }

.particles { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
.particle {
  position: absolute;
  top: 42%;
  left: 50%;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gold);
  opacity: 0;
}
.particles.burst .particle {
  animation: particle-burst 900ms var(--ease-ios) forwards;
  animation-delay: var(--p-delay, 0ms);
}
@keyframes particle-burst {
  0% { opacity: 1; transform: translate(-50%, -50%) rotate(var(--p-angle)) translateX(0) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -50%) rotate(var(--p-angle)) translateX(var(--p-dist)) scale(0.4); }
}

/* ---------- 5b. real scan: interactive hatching wait ----------
   The quick flow keeps its scripted .gen-card above. This screen exists
   because a REAL Tripo generation is ~3 minutes of nothing to look at, and
   the kid holding the phone is 4-8 years old. Two things to do while
   waiting: tap the egg (it wobbles, cracks further, throws sparkles) and
   catch the sparks drifting around it. Neither can finish the wait early —
   see the crack cap in app.js. */
.hatch-step {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 20px;
}

/* Catchable sparks. 44px tap targets around a 12px dot (the app's minimum
   touch size), parked in an aria-hidden layer — they are a bonus, and the
   egg is the labelled control that does the same job. */
.hatch-sky { position: absolute; inset: 0; overflow: hidden; z-index: 0; pointer-events: none; }
.spark {
  pointer-events: auto;
  position: absolute;
  width: 44px;
  height: 44px;
  margin: -22px 0 0 -22px;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: spark-drift var(--spark-dur, 7s) var(--ease-ios) infinite alternate;
}
.spark::before {
  content: "";
  width: var(--spark-size, 12px);
  height: var(--spark-size, 12px);
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 14px 5px rgba(255, 194, 75, 0.5);
  animation: spark-twinkle 2.4s ease-in-out infinite;
  animation-delay: var(--spark-delay, 0ms);
  transition: transform var(--dur-press) var(--ease-press);
}
.spark:active::before { transform: scale(0.8); }
.spark.is-caught { pointer-events: none; animation: none; }
.spark.is-caught::before {
  animation: none;
  opacity: 0;
  transform: scale(2.6);
  transition: opacity 300ms ease-out, transform 300ms var(--ease-release);
}
@keyframes spark-drift {
  from { transform: translate(0, 0); }
  to { transform: translate(var(--spark-dx, 20px), var(--spark-dy, -24px)); }
}
@keyframes spark-twinkle {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

.hatch-stage {
  position: relative;
  z-index: 1;
  margin: auto; /* centres the egg in whatever space .hatch-info leaves */
  display: flex;
  align-items: center;
  justify-content: center;
}
.hatch-halo {
  position: absolute;
  width: 340px;
  height: 340px;
  border-radius: 50%;
  pointer-events: none;
  /* --hatch (0..1) is written by app.js from real pipeline progress: the
     egg literally glows brighter the closer the toy is to done. */
  background: radial-gradient(circle, rgba(255, 194, 75, calc(0.1 + var(--hatch, 0) * 0.45)) 0%, rgba(255, 194, 75, 0) 62%);
  animation: halo-breathe 3.4s ease-in-out infinite;
}
@keyframes halo-breathe {
  0%, 100% { transform: scale(0.94); }
  50% { transform: scale(1.06); }
}

.hatch-egg {
  position: relative;
  border: none;
  background: none;
  padding: 0;
  width: min(62vw, 234px);
  display: block;
}
.egg-svg { width: 100%; height: auto; overflow: visible; }
.egg-body {
  transform-origin: 100px 226px; /* the egg's contact point — it rocks, not spins */
  animation: egg-breathe 2.9s ease-in-out infinite;
}
@keyframes egg-breathe {
  0%, 100% { transform: rotate(0deg) scale(1, 1); }
  35% { transform: rotate(-1.4deg) scale(1.015, 0.985); }
  70% { transform: rotate(1.4deg) scale(0.99, 1.01); }
}
/* A tap overrides the breathe animation for one wobble, then it resumes. */
.hatch-egg.is-tapped .egg-body { animation: egg-wobble 540ms var(--ease-release); }
@keyframes egg-wobble {
  0% { transform: rotate(0deg) scale(1.06, 0.9); }
  30% { transform: rotate(-6deg) scale(0.97, 1.04); }
  55% { transform: rotate(5deg) scale(1.02, 0.98); }
  78% { transform: rotate(-2.5deg) scale(1, 1); }
  100% { transform: rotate(0deg) scale(1, 1); }
}

.egg-shell { filter: drop-shadow(0 18px 36px rgba(61, 43, 38, 0.28)); }
/* The stage behind is already peach, so the shell needs its own edge to
   read as an object rather than a smudge. */
.egg-rim { stroke: rgba(61, 43, 38, 0.22); stroke-width: 2.5; }
.egg-speckles circle { fill: var(--peach-deep); opacity: 0.5; }
.egg-gloss { pointer-events: none; }

/* The photo, blurred inside the shell: a silhouette taking shape. app.js
   raises the opacity and drops the blur as real progress comes in. */
.egg-photo {
  opacity: 0;
  transition: opacity 600ms var(--ease-ios), filter 600ms var(--ease-ios);
}
.egg-core {
  opacity: calc(0.25 + var(--hatch, 0) * 0.75);
  transition: opacity 600ms var(--ease-ios);
}

/* pathLength="100" on both cracks makes the dash math plain percentages —
   app.js writes stroke-dashoffset directly. */
.egg-crack {
  fill: none;
  stroke: rgba(61, 43, 38, 0.5);
  stroke-width: 3.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
  filter: drop-shadow(0 0 5px rgba(255, 194, 75, 0.95));
  transition: stroke-dashoffset 450ms var(--ease-ios);
}
.egg-crack-b { stroke-width: 2.6; }

.hatch-burst { position: absolute; inset: 0; pointer-events: none; }
.hatch-burst .bit {
  position: absolute;
  top: 46%;
  left: 50%;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  animation: particle-burst 720ms var(--ease-ios) forwards;
}

.hatch-info {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: center;
}
.hatch-stage-label {
  color: var(--ink);
  font-size: 17px;
  min-height: 1.3em;
  transition: opacity 220ms var(--ease-ios);
}
.hatch-stage-label.is-fading { opacity: 0; }
/* NOT .filling — that class carries the quick flow's 8s scripted sweep. */
.hatch-progress { transition: width 700ms var(--ease-ios); }
.hatch-hint { color: var(--ink); opacity: 0.6; }

/* The toy is genuinely ready: the shell blows open, then the reveal. */
.hatch-step.is-hatching .egg-body { animation: egg-open 640ms var(--ease-ios) forwards; }
.hatch-step.is-hatching .hatch-halo { animation: glow-bloom 1.1s var(--ease-ios) forwards; }
@keyframes egg-open {
  0% { transform: scale(1); opacity: 1; }
  30% { transform: scale(0.94) rotate(-3deg); opacity: 1; }
  100% { transform: scale(1.45); opacity: 0; }
}

/* ---------- 5c. error card (rejected photo / failed generation) ---------- */
.err-card { text-align: center; }
.err-icon {
  width: 46px;
  height: 46px;
  margin: 0 auto 12px;
  border-radius: 999px;
  background: var(--peach);
  color: var(--coral-deep);
  display: flex;
  align-items: center;
  justify-content: center;
}
.err-icon svg { width: 24px; height: 24px; }
.err-card .gen-title { text-align: center; margin-bottom: 8px; }
.err-body { font-size: 15.5px; }
.err-actions { display: flex; flex-direction: column; align-items: center; gap: 4px; margin-top: 18px; }
.err-btn { width: 100%; height: 58px; border-radius: 20px; }
.err-btn .face { font-weight: 700; font-size: 16px; }

/* ---------- 6. home screen ---------- */
.home-screen { background: var(--cream); }

.home-stage-wrap {
  position: relative;
  flex: 0 0 60%;
  border-radius: 0 0 28px 28px;
  overflow: hidden;
  /* Deeper take on the app's warm stage wash — the white plush needs the
     darker peach rim to pop. Keep in sync with .onboard-overlay. */
  background: radial-gradient(120% 90% at 50% 34%, #FFEBD2 0%, #F5CFA6 52%, #E6B27E 100%);
  transition: flex-basis var(--dur-screen) var(--ease-ios), border-radius var(--dur-screen) var(--ease-ios);
}
/* Night sky for bedtime mode only — a navy layer that fades in with the
   stars (gradients can't transition, so it rides an opacity crossfade).
   Paints above the wrap's background but below the model/stars (DOM order). */
.home-stage-wrap::before {
  content: "";
  position: absolute; inset: 0;
  background: radial-gradient(120% 90% at 50% 15%, #2a1c54 0%, var(--stage-navy) 65%);
  opacity: 0; pointer-events: none;
  transition: opacity 0.4s var(--ease-ios);
}
.home-screen.is-bedtime .home-stage-wrap::before { opacity: 1; }
.home-screen.is-bedtime .home-stage-wrap { flex-basis: 100%; border-radius: 0; }
.home-screen.is-bedtime .home-body { opacity: 0; pointer-events: none; }

/* No rug on the day stage — the model's own contact shadow grounds it,
   matching the real app's Stage. */
.stage-rug { display: none; }
.stage-glow {
  position: absolute; inset: 12%; border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 194, 75, 0.5) 0%, rgba(255, 194, 75, 0) 62%);
  opacity: 0; pointer-events: none;
  transition: opacity 0.3s var(--ease-ios);
}
.stage-glow.bloom { animation: glow-bloom 1.3s var(--ease-ios); }
@keyframes glow-bloom {
  0% { opacity: 0; transform: scale(0.6); }
  35% { opacity: 1; transform: scale(1.15); }
  100% { opacity: 0; transform: scale(1); }
}

/* A scanned toy's GLB has no `talk` clip — Tripo's retarget presets are
   locomotion, not lip-sync — so the stage itself carries the speaking cue
   when the loaded model can't. See setSpeakingFallback in app.js. */
.home-stage-wrap.is-speaking .stage-glow {
  opacity: 0.7;
  animation: speak-pulse 1.5s ease-in-out infinite;
}
@keyframes speak-pulse {
  0%, 100% { transform: scale(0.94); opacity: 0.45; }
  50% { transform: scale(1.07); opacity: 0.8; }
}

#home-stage-mount { position: absolute; inset: 0; }

.home-body {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 14px 20px calc(env(safe-area-inset-bottom) + 14px);
  min-height: 0;
  transition: opacity var(--dur-screen) var(--ease-ios);
}

.toy-name-wrap { text-align: center; }
.toy-name { line-height: 1.05; }
.status-pill {
  display: inline-block;
  margin-top: 6px;
  padding: 5px 14px;
  font-family: var(--font);
  font-weight: 700;
  font-size: 12.5px;
  letter-spacing: 0.02em;
  border-radius: 999px;
  background: var(--peach);
  color: var(--ink);
  opacity: 0.85;
}

.reaction-chips {
  display: flex;
  justify-content: center;
  flex-wrap: nowrap; /* one clean row, always — three chips are sized to fit */
  gap: 10px;
  margin-top: 18px;
}
.chip { height: 46px; border-radius: 999px; padding: 0; }
/* The chip is the only squishy without an explicit width, so its face must
   sit in-flow (not absolute) for the button to shrink-wrap icon + label. */
.chip .face {
  position: relative;
  inset: auto;
  height: calc(100% - var(--sq-depth));
  padding: 0 16px;
}
.chip-icon { width: 15px; height: 15px; flex: none; }
.chip .face { font-family: var(--font); font-weight: 700; font-size: 13px; }

.home-spacer { flex: 1; min-height: 8px; }

.mic-status-pill {
  align-self: center;
  margin-bottom: 10px;
  padding: 6px 16px;
  border-radius: 999px;
  background: var(--peach);
  color: var(--ink);
  font-family: var(--font);
  font-weight: 700;
  font-size: 13px;
  transition: opacity 0.15s ease;
}

.action-bar {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 32px;
  width: 100%;
}
.icon-btn { width: 48px; height: 52px; border-radius: 999px; margin-bottom: 4px; }
.icon-btn .face svg { width: 22px; height: 22px; }

.mic-column { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.mic-btn { width: 72px; height: 79px; border-radius: 999px; }
.mic-icon { width: 30px; height: 30px; }
.mic-btn.is-held .face { transform: translateY(7px); transition: transform var(--dur-press) var(--ease-press); }
.mic-btn.is-held .edge { box-shadow: 0 0 0 8px rgba(255, 107, 74, 0.18); }
.mic-hint { text-align: center; }

@keyframes mic-idle-pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.05); } }
.mic-btn .face { animation: mic-idle-pulse 2.4s ease-in-out infinite; }
.mic-btn.is-held .face, .mic-btn.is-busy .face { animation: none; }

/* ---------- 7. bedtime mode ---------- */
.bedtime-decor {
  position: absolute; inset: 0; z-index: 1;
  opacity: 0; pointer-events: none;
  transition: opacity 0.4s var(--ease-ios);
}
.home-screen.is-bedtime .bedtime-decor { opacity: 1; }
.star {
  position: absolute;
  width: 3px; height: 3px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.85);
  animation: star-twinkle 3.2s ease-in-out infinite;
}
.star:nth-child(2n) { animation-delay: 0.6s; }
.star:nth-child(3n) { animation-delay: 1.2s; }
@keyframes star-twinkle { 0%, 100% { opacity: 0.35; } 50% { opacity: 1; } }
.bedtime-moon { position: absolute; top: 8%; right: 10%; width: 46px; height: 46px; color: var(--gold); }

.bedtime-close {
  position: absolute;
  top: max(env(safe-area-inset-top), 18px);
  right: 18px;
  z-index: 3;
}

.bedtime-caption {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  z-index: 2;
  padding: 24px 28px calc(env(safe-area-inset-bottom) + 32px);
  text-align: center;
  opacity: 0;
  transition: opacity 0.4s var(--ease-ios);
}
.home-screen.is-bedtime .bedtime-caption { opacity: 1; }
.bedtime-story-title {
  font-family: var(--font); font-weight: 700; font-size: 15px;
  letter-spacing: 0.03em; text-transform: uppercase;
  color: var(--gold); opacity: 0.9; margin-bottom: 12px;
}
.bedtime-beat {
  font-family: var(--font); font-weight: 600; font-size: 19px; line-height: 1.45;
  color: var(--white); min-height: 3.6em;
  transition: opacity 0.5s var(--ease-ios);
}
.bedtime-beat.is-fading { opacity: 0; }
.bedtime-hint { margin-top: 14px; color: rgba(255, 255, 255, 0.55); }

/* ---------- 8. sheets (stories / games) ---------- */
.sheet-scrim {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: flex-end;
  background: rgba(26, 16, 60, 0.4);
  animation: scrim-in var(--dur-screen) var(--ease-ios);
}
@keyframes scrim-in { from { opacity: 0; } to { opacity: 1; } }

.sheet-panel {
  position: relative;
  width: 100%;
  max-height: 84%;
  overflow-y: auto;
  background: var(--cream);
  border-radius: 28px 28px 0 0;
  padding: 20px 20px calc(env(safe-area-inset-bottom) + 24px);
  animation: sheet-up var(--dur-screen) var(--ease-ios);
}
@keyframes sheet-up {
  from { opacity: 0; transform: translateY(28px); }
  to { opacity: 1; transform: translateY(0); }
}

.sheet-close-btn { position: absolute; top: 16px; right: 16px; width: 44px; height: 48px; border-radius: 999px; z-index: 2; }
.sheet-title { margin-top: 6px; padding-right: 52px; }
.sheet-sub { margin-top: 6px; margin-bottom: 20px; }

.card-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.story-card { aspect-ratio: 0.82; border-radius: 24px; }
.story-card .face { flex-direction: column; padding: 10px; gap: 8px; }
.cover-svg { width: 100%; flex: 1; border-radius: 16px; overflow: hidden; }
.card-label { font-family: var(--font); font-weight: 700; font-size: 13.5px; text-align: center; color: var(--ink); }

.game-tile { aspect-ratio: 1; border-radius: 24px; }
.game-tile .face { flex-direction: column; padding: 16px; gap: 8px; }
.game-blob { width: 56px; height: 56px; border-radius: 999px; display: flex; align-items: center; justify-content: center; }
.game-icon { width: 26px; height: 26px; color: var(--ink); }

.lock-badge {
  position: absolute;
  top: 12px; right: 12px;
  width: 24px; height: 24px;
  border-radius: 999px;
  background: var(--cream);
  display: flex; align-items: center; justify-content: center;
  color: var(--ink-soft);
}
.lock-badge svg { width: 13px; height: 13px; }
.soon-pill {
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--peach);
}

/* ---------- 9. reduced motion + misc ---------- */
@media (prefers-reduced-motion: reduce) {
  .bracket, .orbit-ring, .gen-step.now .step-dot, .mic-btn .face,
  .star, .onboard-overlay, .sheet-scrim, .sheet-panel,
  .spark, .spark::before, .hatch-halo, .egg-body,
  .home-stage-wrap.is-speaking .stage-glow { animation: none !important; }
  .particles.burst .particle, .hatch-burst .bit { animation-duration: 1ms !important; }
  /* Taps still crack the egg and the progress bar still moves — only the
     looping idle motion goes. The hatch-open beat stays as a plain fade so
     the change of screen still reads. */
  .hatch-step.is-hatching .egg-body { animation: egg-fade 280ms linear forwards !important; }
}
@keyframes egg-fade { to { opacity: 0; } }
