@font-face {
  font-family: Nunito;
  src: url("fonts/Nunito-Variable-Latin.woff2") format("woff2");
  font-weight: 700 1000;
  font-style: normal;
  /* swap is applied only after first paint (html.fonts-ready), so LCP is not waiting on the file. */
  font-display: swap;
}

/* Nunito is for headings, buttons, idea/age chips, labels, and styled
   pseudo-buttons, and only after first paint (html.fonts-ready). Body, p.lede,
   and promise chips stay on the system rounded stack so the home LCP text and
   About promise row cannot swap or wrap with the font. */
html.fonts-ready h1,
html.fonts-ready h2,
html.fonts-ready h3,
html.fonts-ready button,
html.fonts-ready label,
html.fonts-ready .req-label,
html.fonts-ready .card-title,
html.fonts-ready .wordmark,
html.fonts-ready .btn-start,
html.fonts-ready .btn-how,
html.fonts-ready .btn-home,
html.fonts-ready .btn-primary,
html.fonts-ready .btn-secondary,
html.fonts-ready .more,
html.fonts-ready .parent-close,
html.fonts-ready .choice,
html.fonts-ready .suggest,
html.fonts-ready .age-chip,
html.fonts-ready .req-send,
html.fonts-ready .req-cancel,
html.fonts-ready .req-back,
html.fonts-ready .about-request,
html.fonts-ready .step-label,
html.fonts-ready .eyebrow,
html.fonts-ready .chip,
html.fonts-ready .cat-chip,
html.fonts-ready .keep-drawing h2,
html.fonts-ready .keep-title,
html.fonts-ready #clear-recent,
html.fonts-ready .next,
html.fonts-ready .wide,
html.fonts-ready .icon-btn {
  font-family: Nunito, ui-rounded, "SF Pro Rounded", "Avenir Next", "Arial Rounded MT Bold", "Trebuchet MS", sans-serif;
}

/* Promise chips stay on the system rounded stack (as in v3.7.4) so a late
   Nunito swap cannot wrap "No tracking" and shift the About page. */
.promises li,
.promise-chips span,
html.fonts-ready .promises li,
html.fonts-ready .promise-chips span {
  font-family: ui-rounded, "SF Pro Rounded", "Avenir Next", "Arial Rounded MT Bold", "Trebuchet MS", sans-serif;
}

:root {
  --ink: #2B2B2B;
  --bg: #FFF4E6;
  --paper: #FFFFFF;
  --card: #ffffff;
  --muted: #6B5E55;
  --purple: #6558DC;
  --purple-ink: #4E42C4;
  --purple-tint: #F3F0FF;
  --green: #7AC74F;
  --r: 28px;
  --r-card: 28px;
  --r-board: 32px;
  --r-panel: 24px;
  --r-btn: 20px;
  --r-pill: 999px;
  --tint-animals: #FFE0B2;
  --tint-vehicles: #FFCDD2;
  --tint-family: #F8BBD0;
  --tint-nature: #C8E6C9;
  --tint-space: #D1C4E9;
  --tint-play: #FFF59D;
  --tint-food: #B2EBF2;
  --tint-seasons: #FFCCBC;
  --strip-h: 64px;
  --crayon-red: #E53935;
  --crayon-orange: #FB8C00;
  --crayon-yellow: #FDD835;
  --crayon-green: #43A047;
  --crayon-blue: #1E88E5;
  --crayon-purple: #8E24AA;
  --crayon-brown: #8D6E63;
  --crayon-black: #212121;
  --shadow: 0 4px 14px rgba(60, 40, 20, 0.10);
  --quiet: 0.45;
  --tile: min(calc((100svh - 460px) / 2 + 20px), 270px);
  --gutter: 12px;
  --kbd: 0px;
  font-family: ui-rounded, "SF Pro Rounded", "Avenir Next", "Arial Rounded MT Bold", "Trebuchet MS", sans-serif;
  color: var(--ink);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html {
  margin: 0;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

#app {
  min-height: 100dvh;
}

body.about-page,
body:has(.privacy) {
  min-height: 100dvh;
}

#app:has(.privacy) { min-height: 0; }

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  border: 0;
  touch-action: manipulation;
  background: none;
}

button:focus-visible,
a:focus-visible {
  outline: 4px solid var(--purple);
  outline-offset: 3px;
}

.home, .lesson, .celebrate, .loading, .error-screen {
  min-height: 100dvh;
  height: auto;
}

.home {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: min(1200px, 100%);
  margin: 0 auto;
  padding: 16px 24px max(24px, env(safe-area-inset-bottom));
}

.home-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
  position: relative;
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  font-size: 22px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: -0.03em;
  color: #2B2B2B;
}

.wordmark svg,
.wordmark img {
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  display: block;
  border-radius: 8px;
}

.hero .wordmark,
.about-top .wordmark { align-self: auto; }
.hero .wordmark { font-size: 17px; gap: 8px; }
.hero .wordmark img { width: 28px; height: 28px; flex-basis: 28px; }

.eyebrow {
  margin: 0;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--muted);
}

.home-head h1,
.kid-head h1 {
  margin: 0;
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1.1;
  color: var(--ink);
}
.kid-head {
  text-align: center;
}
.kid-head .eyebrow {
  font-size: 12px;
  letter-spacing: 0.14em;
}
.kid-head h1.holding,
.about-request.holding {
  color: var(--purple);
  outline: 3px solid var(--purple);
  outline-offset: 4px;
}

.chip {
  margin: 4px 0 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 6px 16px;
  border-radius: 999px;
  background: #fff;
  box-shadow: var(--shadow);
  font-size: 16px;
  font-weight: 800;
}

.grid-scroll {
  min-height: 0;
  overflow: auto;
  scrollbar-width: none;
}

.grid-scroll::-webkit-scrollbar { display: none; width: 0; height: 0; }

.rows {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  align-content: start;
}

@media (min-width: 1000px) {
  .home {
    --tile: min(260px, calc((100vw - 108px) / 4));
    gap: 12px;
    padding-top: 16px;
    padding-bottom: max(16px, env(safe-area-inset-bottom));
  }
  .home-head, .kid-head { gap: 4px; }
  .home-head h1, .kid-head h1 { font-size: 28px; }
  .chip { margin: 0; }
  .rows {
    grid-template-columns: repeat(4, var(--tile));
    justify-content: center;
  }
  .card {
    padding: 8px 8px 10px;
    gap: 6px;
  }
  .card-title {
    font-size: clamp(16px, 1.6vw, 20px);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

.card {
  min-width: 0;
  min-height: 60px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px 10px 14px;
  background: var(--card);
  border-radius: 28px;
  box-shadow: var(--shadow);
  text-align: center;
  transition: transform 150ms ease;
}

.card:active { transform: scale(0.97); }

.card-art {
  position: relative;
  aspect-ratio: 1;
  width: 100%;
  border-radius: 20px;
  overflow: hidden;
  display: grid;
  place-items: center;
}

.card-art svg {
  width: 100%;
  height: 100%;
  display: block;
}

.board svg {
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
}

.celebrate .board {
  display: grid;
  place-items: center;
  background: #fff;
  border-radius: 28px;
  box-shadow: var(--shadow);
}

.celebrate .board svg {
  width: 100%;
  height: 100%;
}

.star {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #fff;
  color: #FB8C00;
  font-size: 20px;
  box-shadow: var(--shadow);
}

.card-title {
  margin: 0;
  font-size: clamp(20px, 2.2vw, 24px);
  font-weight: 900;
  letter-spacing: -0.02em;
  line-height: 1.15;
  color: var(--ink);
}

.card-meta {
  margin: -4px 0 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--muted);
  line-height: 1.25;
}

.more-bar {
  position: relative;
  justify-self: stretch;
  display: flex;
  justify-content: center;
  background: var(--bg, #FFF4E6);
  padding-bottom: 0;
}
.more-bar::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -40px;
  height: 40px;
  background: linear-gradient(to bottom, rgba(255, 244, 230, 0), #FFF4E6);
  pointer-events: none;
  z-index: 2;
}
.more {
  justify-self: center;
  width: min(420px, 100%);
  min-width: 0;
  min-height: 64px;
  height: 64px;
  border-radius: 20px;
  background: #fff;
  color: #6558DC;
  border: 2px solid #6558DC;
  font-size: 22px;
  font-weight: 900;
  position: relative;
  z-index: 3;
}

.more[hidden] { display: none; }
.more-bar:has(.more[hidden]) { display: none; }

.lesson, .celebrate {
  display: grid;
  gap: 8px;
  width: min(1200px, 100%);
  margin: 0 auto;
  padding: 24px;
  padding-bottom: max(24px, env(safe-area-inset-bottom));
}

.lesson { grid-template-rows: auto minmax(0, 1fr) auto auto; }
.celebrate { position: relative; grid-template-rows: auto auto minmax(0, 1fr) auto; }

.board-slot { position: relative; }

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 64px;
}

.icon-btn {
  width: 64px;
  height: 64px;
  min-width: 64px;
  min-height: 64px;
  border-radius: 20px;
  background: #fff;
  border: 3px solid var(--ink);
  display: grid;
  place-items: center;
}

.icon-btn[aria-pressed="true"]:not([data-act="music"]) {
  background: var(--purple);
  color: #fff;
  border-color: var(--purple);
}

/* Music: aria-pressed=true means ON. Off uses the muted visual. */
.icon-btn[data-act="music"][aria-pressed="false"] {
  background: var(--purple);
  color: #fff;
  border-color: var(--purple);
}

.icon-btn svg { width: 32px; height: 32px; display: block; }

.step-label {
  margin: 0;
  flex: 1;
  min-width: 0;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.03em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.board-slot {
  min-height: 0;
  min-width: 0;
  display: grid;
  place-items: center;
}

.board {
  position: relative;
  background: var(--paper);
  border-radius: 32px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.progress {
  height: 16px;
  border-radius: 999px;
  background: #eadcc8;
  overflow: hidden;
  justify-self: center;
}

.progress > span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--purple);
  transform-origin: left center;
}

.is-quiet { opacity: var(--quiet); }

.next, .wide {
  min-height: 76px;
  min-width: 60px;
  border-radius: 24px;
  background: var(--purple);
  color: #fff;
  font-size: 32px;
  font-weight: 800;
}

.next, .actions {
  width: 100%;
  max-width: 560px;
  justify-self: center;
}

.actions {
  display: flex;
  gap: 10px;
}

.actions .wide,
.actions .next {
  flex: 1;
  width: auto;
  max-width: none;
  min-height: 76px;
  min-width: 60px;
}

.wide.secondary {
  background: #fff;
  color: #6558DC;
  border: 3px solid #6558DC;
}

.wide.secondary:disabled,
[data-act="prev"]:disabled {
  opacity: 0.45;
  cursor: default;
}

.celebrate .praise {
  margin: 0;
  font-size: clamp(26px, 4vw, 36px);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.15;
  text-align: center;
}

.celebrate .bits {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 8;
}

.bit {
  position: absolute;
  top: -14px;
  width: 12px;
  height: 12px;
  border-radius: 2px;
  opacity: 1;
  animation: confetti-burst 1.2s ease-out 1 forwards;
}

@keyframes confetti-burst {
  0% { transform: translate3d(0, 0, 0) rotate(0deg); opacity: 1; }
  80% { opacity: 1; }
  100% { transform: translate3d(var(--dx, 0px), 110dvh, 0) rotate(var(--rot, 180deg)); opacity: 0; }
}

.voice, .parent {
  position: fixed;
  inset: 0;
  background: rgba(255, 244, 230, 0.96);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 24px;
  /* Above sticky home chrome (.hero.collapsed is 30, .chip-bar is 25). */
  z-index: 40;
}

.voice h2, .parent h2 {
  margin: 0;
  font-size: 36px;
}

.voice-row, .choice-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 16px;
}

.voice-btn, .choice {
  min-width: 140px;
  min-height: 140px;
  border-radius: 32px;
  background: #fff;
  border: 3px solid var(--ink);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 22px;
  font-weight: 800;
}

.choice {
  min-width: 120px;
  min-height: 64px;
}

.voice-btn svg { width: 84px; height: 84px; }

.parent {
  align-items: stretch;
  overflow: auto;
}

.parent-card {
  width: min(560px, 100%);
  margin: auto;
  background: #fff;
  border-radius: 28px;
  padding: 22px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.parent p { margin: 0; font-size: 18px; line-height: 1.4; }

.loading, .error-screen {
  display: grid;
  place-items: center;
  padding: 24px;
  font-size: 28px;
  font-weight: 800;
  text-align: center;
}

.privacy {
  max-width: 640px;
  margin: 0 auto;
  padding: 32px 20px 48px;
  font-size: 20px;
  line-height: 1.45;
}

.privacy a {
  color: var(--purple);
  font-weight: 800;
}

@media (prefers-reduced-motion: reduce) {
  .bit { animation: none; opacity: 0.4; }
  .card { transition: none; }
}


/* ===== v3.3 parent hero, About, request form ===== */
.hero {
  background: #fff;
  border-radius: var(--r-card);
  box-shadow: var(--shadow);
  padding: 16px;
  display: grid;
  gap: 12px 20px;
  width: 100%;
  margin: 0 auto;
  overflow: hidden;
  box-sizing: border-box;
}
.hero-art {
  background: var(--tint-play, #FFF59D);
  border-radius: var(--r-panel);
  min-height: 120px;
  display: grid;
  place-items: center;
  overflow: hidden;
}
.hero-art svg { width: 100%; height: auto; display: block; max-height: 160px; }
.hero-copy { min-width: 0; }
.hero-copy h2 {
  margin: 8px 0 0;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.15;
  color: var(--ink);
}
.hero-lede {
  margin: 8px 0 0;
  font-size: 15px;
  line-height: 1.4;
  color: var(--muted);
}
.promise-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 10px 0 0;
}
.promise-chips span {
  display: inline-flex;
  align-items: center;
  height: 28px;
  padding: 0 10px;
  border-radius: var(--r-pill);
  background: var(--purple-tint);
  color: var(--purple-ink);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}
.hero-actions {
  display: flex;
  gap: 10px;
  align-items: stretch;
  min-width: 0;
}
.btn-start,
.btn-how,
.req-send,
.req-cancel,
.req-back,
.btn-home,
.about-request {
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  text-align: center;
}
.btn-start {
  flex: 1.5 1 0;
  height: 72px;
  min-height: 72px;
  min-width: 60px;
  font-size: 22px;
  border-radius: var(--r-btn);
  background: var(--purple);
  color: #fff;
  box-shadow: 0 6px 0 var(--purple-ink);
  border: 0;
}
.btn-start:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--purple-ink); }
.btn-start .arrow {
  margin-left: 8px;
  display: inline-flex;
  align-items: center;
  font-weight: 900;
}
.btn-start .arrow svg {
  width: 0.95em;
  height: 0.95em;
  display: block;
}
.btn-how {
  flex: 1 1 0;
  height: 72px;
  min-height: 72px;
  min-width: 60px;
  font-size: 18px;
  background: #fff;
  color: var(--purple-ink);
  border: 3px solid var(--purple);
  border-radius: var(--r-btn);
  box-shadow: none;
}

.hero.collapsed {
  max-height: 76px;
  height: 76px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  overflow: hidden;
}
.hero.collapsed .hero-art,
.hero.collapsed h2,
.hero.collapsed .hero-lede { display: none; }
.hero.collapsed .hero-copy {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}
.hero.collapsed .promise-chips { margin: 0; flex-wrap: nowrap; }
.hero.collapsed .hero-actions { flex: none; }
.hero.collapsed .btn-start { display: none; }
.hero.collapsed .btn-how {
  height: 60px;
  min-height: 60px;
  min-width: 60px;
  width: auto;
  padding: 0 16px;
  font-size: 16px;
  border-width: 2px;
}

@media (min-width: 1000px) {
  .hero {
    grid-template-columns: minmax(180px, 1.1fr) minmax(240px, 1.4fr) minmax(220px, 1fr);
    align-items: center;
    padding: 16px 20px;
    width: min(100%, calc(4 * var(--tile) + 60px));
    max-height: 30dvh;
  }
  .hero-art { min-height: 140px; }
  .hero-art svg { max-height: 148px; }
  .hero-actions { flex-direction: column; gap: 10px; }
  .hero-actions .btn-start,
  .hero-actions .btn-how {
    width: 100%;
    flex: none;
  }
  .hero-actions .btn-how { height: 64px; min-height: 64px; }
}

@media (max-width: 999.98px) {
  .hero {
    grid-template-columns: minmax(140px, 1fr) minmax(0, 1.4fr);
    grid-template-areas:
      "art copy"
      "actions actions";
  }
  .hero-art { grid-area: art; min-height: 132px; }
  .hero-copy { grid-area: copy; }
  .hero-actions { grid-area: actions; }
}

@media (min-width: 1000px) and (max-height: 900px) {
  .hero { padding: 12px 16px; gap: 10px 16px; }
  .hero-copy h2 { font-size: 20px; margin-top: 4px; }
  .hero-lede { margin-top: 6px; font-size: 14px; }
  .hero-art { min-height: 120px; }
  .hero-art svg { max-height: 120px; }
}

.about-page {
  background: var(--bg);
  min-height: 100dvh;
  height: auto;
  overflow: auto;
  margin: 0;
  color: var(--ink);
  user-select: text;
}
.about-top {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 24px;
  max-width: 640px;
  margin: 0 auto;
}
.about-top .btn-home,
a.btn-home {
  height: 64px;
  min-height: 64px;
  min-width: 64px;
  padding: 0 20px;
  border-radius: var(--r-btn);
  background: #fff;
  color: var(--purple-ink);
  border: 3px solid var(--purple);
  font-size: 18px;
}
.about-main {
  max-width: 640px;
  margin: 0 auto;
  padding: 8px 24px 32px;
}
.about-main h2 {
  margin: 0;
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1.15;
}
.about-lede {
  margin: 10px 0 24px;
  font-size: 18px;
  line-height: 1.45;
  color: var(--muted);
}
.about-steps {
  list-style: none;
  margin: 0 0 20px;
  padding: 0;
  display: grid;
  gap: 12px;
}
.about-steps li,
.about-card {
  background: #fff;
  border-radius: var(--r-card);
  box-shadow: var(--shadow);
  padding: 20px 22px;
}
.about-steps li {
  display: grid;
  grid-template-columns: 40px 1fr;
  gap: 14px;
  align-items: start;
}
.step-num {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--purple-tint);
  color: var(--purple-ink);
  font-weight: 900;
  font-size: 20px;
  display: grid;
  place-items: center;
}
.about-steps h3,
.about-card h3 {
  margin: 0 0 6px;
  font-size: 20px;
  font-weight: 800;
}
/* v3.7.6: Nunito is slightly wider; keep step titles on one line at phone widths. */
@media (max-width: 400px) {
  .about-steps h3 {
    font-size: 18px;
    letter-spacing: -0.02em;
  }
}
.about-steps p,
.about-card p {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.45;
}
.about-card p:last-child { margin-bottom: 0; }
.promises-card .promise-chips { margin: 0 0 12px; }
.about-foot {
  max-width: 640px;
  margin: 0 auto;
  padding: 8px 24px 40px;
  display: grid;
  gap: 16px;
  justify-items: start;
}
.quiet-link {
  color: var(--muted);
  font-weight: 700;
  font-size: 16px;
  text-decoration: underline;
}
.about-request {
  width: min(420px, 100%);
  height: 64px;
  min-height: 64px;
  background: #fff;
  color: var(--purple-ink);
  border: 2px solid var(--purple);
  border-radius: 20px;
  box-shadow: none;
  font-size: 20px;
}
.about-ver { margin: 0; color: var(--muted); font-size: 14px; }

#request-overlay.overlay {
  position: fixed;
  inset: 0;
  background: rgba(255, 244, 230, 0.96);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 40;
}
#request-overlay.overlay[hidden],
#request-overlay.overlay.hidden { display: none; }
.request-sheet {
  max-width: 560px;
  width: min(560px, 100%);
  background: #fff;
  border-radius: var(--r-card);
  box-shadow: var(--shadow);
  padding: 28px 24px 24px;
  max-height: min(90dvh, 900px);
  overflow: auto;
}
.request-form h2,
.request-success h2 {
  margin: 0 0 8px;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.03em;
}
.request-lede,
.request-success p,
.req-note {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.4;
}
.suggest-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 0 12px;
}
.suggest,
.age-chip {
  height: 44px;
  min-height: 44px;
  padding: 0 14px;
  border: 0;
  border-radius: var(--r-pill);
  background: var(--purple-tint);
  color: var(--purple-ink);
  font-weight: 800;
  font-size: 15px;
  cursor: pointer;
}
.age-chip { height: 60px; min-height: 60px; min-width: 72px; }
.age-chip[aria-pressed="true"],
.suggest:active {
  background: var(--purple);
  color: #fff;
}
.req-label {
  display: block;
  margin: 8px 0 6px;
  font-weight: 800;
  font-size: 15px;
}
.req-input {
  width: 100%;
  height: 64px;
  min-height: 64px;
  border: 2px solid #E8E0D4;
  border-radius: 16px;
  padding: 0 16px;
  font: inherit;
  font-size: 18px;
  background: var(--paper);
  color: var(--ink);
}
.req-input:focus { outline: 3px solid var(--purple); border-color: var(--purple); }
.req-count { margin: 6px 0 0; color: var(--muted); font-size: 13px; text-align: right; }
.req-hint {
  margin: 8px 0 0;
  color: var(--ink);
  font-size: 15px;
  font-weight: 700;
}
.age-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; }
.hp {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}
.req-error {
  margin: 0 0 12px;
  color: var(--ink);
  font-weight: 700;
  font-size: 16px;
}
.request-form .req-send {
  width: 100%;
  height: 72px;
  min-height: 72px;
  margin-top: 8px;
  background: var(--purple);
  color: #fff;
  border: 0;
  border-radius: var(--r-btn);
  box-shadow: 0 6px 0 var(--purple-ink);
  font-size: 22px;
}
.request-form .req-send:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--purple-ink); }
.request-form .req-send:disabled { opacity: 0.6; }
.request-form .req-cancel,
.request-success .req-back {
  width: 100%;
  height: 64px;
  min-height: 64px;
  margin-top: 10px;
  border-radius: var(--r-btn);
  font-size: 20px;
}
.request-form .req-cancel {
  background: #fff;
  color: var(--purple-ink);
  border: 3px solid var(--purple);
  box-shadow: none;
}
.request-success { text-align: center; }
.request-success .req-back {
  background: var(--purple);
  color: #fff;
  border: 0;
  box-shadow: 0 6px 0 var(--purple-ink);
}
.success-star { margin: 0; font-size: 40px; color: var(--purple); }
.parent-card .request-form { margin-top: 8px; padding-top: 8px; border-top: 1px solid #F0E6D8; }
.parent-card .request-form h2 { font-size: 24px; }

.promises { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 0; padding: 0; }
.promises li {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 12px 0 8px;
  border-radius: var(--r-pill);
  background: var(--purple-tint);
  color: var(--purple-ink);
  font-size: 14px;
  font-weight: 900;
  white-space: nowrap;
}
.promises svg { width: 16px; height: 16px; flex: none; }
.hero .promises,
.hero .promise-chips {
  flex-wrap: nowrap;
  gap: 4px;
  margin-top: 8px;
}
.hero .promises li {
  height: 26px;
  padding: 0 7px 0 5px;
  gap: 3px;
  font-size: 12px;
}
.hero .promises svg { width: 13px; height: 13px; }
.hero.collapsed .promises { margin: 0; flex-wrap: nowrap; }
@media (max-width: 999.98px) {
  .hero-art { width: 100%; max-width: 224px; height: 160px; min-height: 160px; justify-self: center; }
  .hero-art svg { max-height: 160px; height: 100%; }
  .hero-copy h2 { font-size: 26px; }
}


/* ===== v3.7 mobile-first layout (SPEC.md wins) ===== */
@media (min-width: 412px) {
  :root { --gutter: 20px; }
}
@media (min-width: 820px) {
  :root { --gutter: 24px; }
}

.home,
.lesson,
.celebrate {
  padding-top: max(var(--gutter), env(safe-area-inset-top, 0px));
  padding-right: max(var(--gutter), env(safe-area-inset-right, 0px));
  padding-bottom: max(var(--gutter), env(safe-area-inset-bottom, 0px));
  padding-left: max(var(--gutter), env(safe-area-inset-left, 0px));
}

.home, .lesson, .celebrate, .loading, .error-screen {
  min-height: 100dvh;
  height: auto;
}

.card { min-height: 64px; }
.card-title {
  font-size: 18px;
  font-weight: 900;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rows { gap: 16px; }

.hero .promises,
.hero .promise-chips {
  flex-wrap: wrap;
  gap: 6px;
}
.hero-lede { font-size: 16px; line-height: 1.45; }
.hero-copy h2 { font-size: 22px; font-weight: 950; line-height: 1.15; }
.home-head h1,
.kid-head h1 {
  font-size: 32px;
  font-weight: 950;
  line-height: 1.1;
}
.eyebrow { font-size: 12px; font-weight: 900; }
.wordmark { font-size: 20px; }
.hero .wordmark { font-size: 17px; }

.btn-start,
.btn-how {
  min-width: 64px;
}
.btn-start {
  flex: 1.5 1 0;
  height: 64px;
  min-height: 64px;
  font-size: 22px;
  font-weight: 900;
}
.btn-how {
  flex: 1 1 0;
  height: 64px;
  min-height: 48px;
  font-size: 18px;
}
.hero-actions { gap: 10px; }

.more {
  min-height: 64px;
  height: 64px;
}

/* Lesson / celebrate shared grid (Home / label / tools on the first row). */
.lesson {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  grid-template-areas:
    "home label tools"
    "board board board"
    "progress progress progress"
    "actions actions actions";
  gap: 8px 12px;
  align-items: stretch;
}
.lesson .rail-home { grid-area: home; align-self: center; }
.lesson .step-label {
  grid-area: label;
  font-size: 20px;
  font-weight: 900;
  line-height: 1.1;
  align-self: center;
}
.lesson .rail-tools {
  grid-area: tools;
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-end;
}
.lesson .board-slot { grid-area: board; }
.lesson .progress { grid-area: progress; }
.lesson .actions {
  grid-area: actions;
  width: 100%;
  max-width: none;
  gap: 10px;
  justify-self: center;
}
.lesson .actions .wide,
.lesson .actions .next,
.lesson .actions .action-replay {
  min-height: 64px;
  min-width: 64px;
  height: 64px;
  font-size: 22px;
}
.lesson .actions .action-replay { flex: 0 0 64px; width: 64px; padding: 0; }
.lesson .actions .next { font-weight: 900; }

.celebrate {
  display: grid;
  position: relative;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  grid-template-areas:
    "home praise ."
    "praise2 praise2 praise2"
    "board board board"
    "actions actions actions";
  gap: 8px 12px;
}
.celebrate .rail-home { grid-area: home; }
.celebrate .praise {
  grid-area: praise2;
  font-size: 28px;
  font-weight: 900;
}
.celebrate .board-slot { grid-area: board; }
.celebrate .actions {
  grid-area: actions;
  width: 100%;
  max-width: none;
  gap: 10px;
}
.celebrate .actions .wide {
  min-height: 64px;
  min-width: 64px;
  height: 64px;
  font-size: 22px;
}

/* ---- Phone portrait (375–440, also any portrait under 820) ---- */
@media (orientation: portrait) and (max-width: 819.98px) {
  .rows { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
  .hero:not(.collapsed) {
    grid-template-columns: 100px minmax(0, 1fr);
    grid-template-areas:
      "art copy"
      "actions actions";
    align-items: center;
    gap: 8px 12px;
    padding: 12px;
    max-height: none;
  }
  .hero:not(.collapsed) .hero-art {
    grid-area: art;
    width: 96px;
    max-width: 100px;
    height: 88px;
    min-height: 0;
    justify-self: start;
  }
  .hero:not(.collapsed) .hero-art svg { max-height: 88px; height: 100%; width: 100%; }
  .hero:not(.collapsed) .hero-copy { grid-area: copy; min-width: 0; }
  .hero:not(.collapsed) .hero-copy h2 { font-size: 22px; margin-top: 4px; }
  .hero:not(.collapsed) .hero-actions { grid-area: actions; }
  .hero.collapsed {
    height: 64px;
    max-height: 64px;
    padding: 0 12px;
    gap: 8px;
  }
  .hero.collapsed .promise-chips,
  .hero.collapsed .promises { display: none; }
  .hero.collapsed .btn-how {
    height: 48px;
    min-height: 44px;
    min-width: 44px;
    font-size: 16px;
  }
}

@media (orientation: portrait) and (max-width: 400px),
       (orientation: portrait) and (max-height: 699.98px) {
  .hero:not(.collapsed) .hero-lede { display: none; }
}

@media (orientation: portrait) and (min-width: 412px) and (min-height: 700px) and (max-width: 819.98px) {
  .hero:not(.collapsed) {
    max-height: none;
  }
  .hero:not(.collapsed) .hero-lede {
    display: block;
    font-size: 16px;
    line-height: 1.45;
    margin-top: 6px;
  }
}

/* ---- Phone landscape: width > height, even under 1000px ---- */
@media (orientation: landscape) and (max-width: 999.98px) {
  .home { gap: 8px; }
  .home-head { gap: 2px; }
  .home-head .eyebrow { display: none; }
  .home-head h1,
  .kid-head h1 { font-size: 32px; }
  .rows {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
  }
  .card { padding: 6px 6px 8px; gap: 4px; }
  .card-title { font-size: 18px; }
  .hero:not(.collapsed) {
    grid-template-columns: 72px minmax(0, 1fr) auto;
    grid-template-areas: "art copy actions";
    align-items: center;
    gap: 8px 12px;
    padding: 8px 10px;
    max-height: min(112px, 28svh);
    overflow: hidden;
  }
  .hero:not(.collapsed) .hero-art {
    grid-area: art;
    width: 72px;
    height: 72px;
    min-height: 0;
    max-width: 72px;
    justify-self: start;
  }
  .hero:not(.collapsed) .hero-art svg { max-height: 72px; height: 100%; }
  .hero:not(.collapsed) .hero-copy { grid-area: copy; }
  .hero:not(.collapsed) .hero-lede,
  .hero:not(.collapsed) .promise-chips,
  .hero:not(.collapsed) .promises { display: none !important; }
  .hero:not(.collapsed) .hero-copy h2 {
    font-size: 22px;
    margin: 2px 0 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .hero:not(.collapsed) .hero-actions {
    grid-area: actions;
    flex-direction: row;
    gap: 10px;
  }
  .hero:not(.collapsed) .btn-start,
  .hero:not(.collapsed) .btn-how {
    width: auto;
    flex: none;
    height: 64px;
    min-height: 64px;
    min-width: 64px;
    padding: 0 14px;
    font-size: 18px;
  }
  .hero.collapsed {
    height: 64px;
    max-height: 64px;
  }
  .hero.collapsed .promise-chips,
  .hero.collapsed .promises { display: none; }

  .lesson {
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-rows: auto minmax(0, 1fr) auto;
    grid-template-areas:
      "home label tools"
      "home board actions"
      "home progress actions";
    gap: 6px 12px;
  }
  .lesson .rail-home { align-self: start; }
  .lesson .rail-tools {
    align-self: start;
    flex-direction: column;
  }
  .lesson .step-label {
    font-size: 20px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .lesson .actions {
    flex-direction: column;
    justify-content: flex-end;
    align-self: stretch;
    width: auto;
    min-width: 80px;
    max-width: 96px;
    gap: 10px;
  }
  .lesson .actions .wide,
  .lesson .actions .next,
  .lesson .actions .action-replay {
    width: 100%;
    flex: none;
    height: 64px;
    min-height: 64px;
    min-width: 64px;
    font-size: 16px;
    line-height: 1.1;
    white-space: normal;
    padding: 4px 6px;
  }
  .lesson .actions .action-replay { flex: none; width: 100%; }

  .celebrate {
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas:
      "home praise actions"
      "home board actions";
  }
  .celebrate .praise {
    grid-area: praise;
    font-size: 28px;
    align-self: center;
  }
  .celebrate .rail-home { align-self: start; }
  .celebrate .actions {
    flex-direction: column;
    justify-content: flex-end;
    width: auto;
    min-width: 80px;
    max-width: 96px;
  }
  .celebrate .actions .wide {
    width: 100%;
    font-size: 18px;
    padding: 4px 8px;
  }
}

/* ---- iPad 820 portrait ---- */
@media (orientation: portrait) and (min-width: 820px) {
  .rows {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
  }
  .home-head h1,
  .kid-head h1 { font-size: 40px; font-weight: 950; }
  .hero-copy h2,
  .about-main h2 { font-size: 28px; font-weight: 950; }
  .step-label { font-size: 24px; }
  .praise { font-size: 32px; }
  .card-title { font-size: 24px; }
  .wordmark { font-size: 22px; }
  .hero .wordmark { font-size: 22px; }
  .hero:not(.collapsed) { max-height: 30svh; }
  .hero-lede, .about-lede, .parent p, .privacy, .about-steps p, .about-card p {
    font-size: 17px;
  }
  .parent-card { max-width: 560px; }
}

/* ---- iPad 1180 landscape and desktop ---- */
@media (orientation: landscape) and (min-width: 1000px) {
  .rows {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 20px;
    justify-content: stretch;
  }
  .home-head h1,
  .kid-head h1 { font-size: 44px; font-weight: 950; }
  .hero-copy h2 { font-size: 30px; font-weight: 950; }
  .step-label { font-size: 26px; }
  .card-title { font-size: 22px; }
  .wordmark { font-size: 22px; }
  .hero:not(.collapsed) {
    width: 100%;
    max-height: 30svh;
    grid-template-columns: minmax(180px, 1.1fr) minmax(240px, 1.4fr) minmax(220px, 1fr);
    grid-template-areas: "art copy actions";
    align-items: center;
  }
  .hero:not(.collapsed) .hero-art { grid-area: art; }
  .hero:not(.collapsed) .hero-copy { grid-area: copy; }
  .hero:not(.collapsed) .hero-actions {
    grid-area: actions;
    flex-direction: column;
    gap: 10px;
  }
  .hero-lede, .about-lede, .parent p, .privacy, .about-steps p, .about-card p {
    font-size: 17px;
    line-height: 1.45;
  }
  /* Side-rail player on wide landscape too (iPad 1180). */
  .lesson {
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-rows: auto minmax(0, 1fr) auto;
    grid-template-areas:
      "home label tools"
      "home board actions"
      "home progress actions";
  }
  .lesson .rail-home { align-self: start; }
  .lesson .rail-tools { align-self: start; flex-direction: column; }
  .lesson .actions {
    flex-direction: column;
    justify-content: flex-end;
    width: auto;
    min-width: 80px;
    max-width: 96px;
  }
  .lesson .actions .wide,
  .lesson .actions .next,
  .lesson .actions .action-replay {
    width: 100%;
    flex: none;
    height: 64px;
    font-size: 16px;
    white-space: normal;
    line-height: 1.1;
  }
  .celebrate {
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas:
      "home praise actions"
      "home board actions";
  }
  .celebrate .praise { grid-area: praise; }
  .celebrate .actions {
    flex-direction: column;
    justify-content: flex-end;
    width: auto;
    min-width: 80px;
    max-width: 96px;
  }
}

/* Parent sheet */
.parent {
  padding: max(var(--gutter), env(safe-area-inset-top, 0px))
           max(var(--gutter), env(safe-area-inset-right, 0px))
           max(var(--gutter), env(safe-area-inset-bottom, 0px))
           max(var(--gutter), env(safe-area-inset-left, 0px));
  overflow: hidden;
  align-items: center;
  justify-content: center;
}
.parent-card {
  width: min(560px, 100%);
  max-height: calc(100svh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 16px);
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0;
  overflow: hidden;
}
.parent-head {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: sticky;
  top: 0;
  min-height: 56px;
  max-height: 56px;
  padding: 6px 16px;
  background: #fff;
  z-index: 1;
  border-bottom: 1px solid #F0E6D8;
}
.parent-head h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 950;
  line-height: 1.15;
}
.parent-close {
  flex: none;
  min-width: 44px;
  min-height: 44px;
  height: 44px;
  padding: 0 14px;
  border-radius: var(--r-btn);
  background: #fff;
  color: var(--purple-ink);
  border: 3px solid var(--purple);
  font-size: 16px;
  font-weight: 800;
}
.parent-body {
  --parent-gap: 14px;
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 12px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: var(--parent-gap);
}
/* Keep at least 8px between choice rows when --parent-gap is tighter; leave larger default gaps alone. */
.parent-body > .choice-row + .choice-row {
  margin-top: max(0px, calc(8px - var(--parent-gap)));
}
.parent p {
  font-size: 16px;
  line-height: 1.45;
}
.choice-row {
  gap: 8px;
}
.choice {
  flex: 1 1 calc(33.33% - 8px);
  min-width: 0;
  min-height: 44px;
  height: auto;
  font-size: 16px;
  padding: 8px 10px;
}
.parent-card .request-form {
  margin: 0;
  padding: 8px 0 0;
  border-top: 1px solid #F0E6D8;
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
}
.parent-card .req-actions,
.request-sheet .req-actions {
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 16px calc(10px + max(env(safe-area-inset-bottom, 0px), var(--kbd)));
  background: #fff;
  border-top: 1px solid #F0E6D8;
}
.parent-card > .req-actions { margin: 0; }

.request-form .req-fields {
  display: flex;
  flex-direction: column;
  gap: 0;
  min-height: 0;
  overflow: auto;
}
.req-label {
  font-size: 16px;
  font-weight: 900;
}
.req-input,
.request-form input[type="text"],
.request-form select {
  font-size: 18px;
  min-height: 48px;
  height: 56px;
}
.suggest,
.suggest-row .suggest,
.age-chip {
  min-height: 44px;
}
.suggest-row,
.age-row {
  flex-wrap: wrap;
  gap: 10px;
}
.request-form .req-send,
.request-form .req-cancel,
.request-success .req-back {
  width: 100%;
  min-height: 44px;
  height: 64px;
  margin-top: 0;
}

/* About / Privacy / request overlay */
.about-page { background: var(--bg); }
.about-top {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--bg);
  min-height: 56px;
  max-height: calc(56px + env(safe-area-inset-top, 0px));
  padding-top: max(8px, env(safe-area-inset-top, 0px));
  padding-right: max(var(--gutter), env(safe-area-inset-right, 0px));
  padding-bottom: 8px;
  padding-left: max(var(--gutter), env(safe-area-inset-left, 0px));
  box-sizing: content-box;
}
@media (max-width: 819.98px) {
  .about-top .btn-home,
  a.btn-home {
    height: 44px;
    min-height: 44px;
    min-width: 44px;
    padding: 0 14px;
    font-size: 16px;
  }
  .about-main h2 { font-size: 22px; font-weight: 950; }
  .about-lede { font-size: 16px; line-height: 1.45; }
  .about-main,
  .about-foot,
  .privacy {
    padding-left: max(var(--gutter), env(safe-area-inset-left, 0px));
    padding-right: max(var(--gutter), env(safe-area-inset-right, 0px));
  }
  .privacy { font-size: 16px; line-height: 1.45; padding-top: 24px; }
}
.about-foot {
  padding-bottom: max(24px, env(safe-area-inset-bottom, 0px));
}
.quiet-link {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}
.about-request {
  min-height: 44px;
}

#request-overlay.overlay {
  padding: max(var(--gutter), env(safe-area-inset-top, 0px))
           max(var(--gutter), env(safe-area-inset-right, 0px))
           max(var(--gutter), env(safe-area-inset-bottom, 0px))
           max(var(--gutter), env(safe-area-inset-left, 0px));
  align-items: stretch;
  justify-content: center;
}
.request-sheet {
  width: min(560px, 100%);
  max-height: calc(100svh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 16px);
  margin: auto;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #fff;
  border-radius: var(--r-card);
  box-shadow: var(--shadow);
}
.request-sheet .request-form,
.request-sheet .request-success {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
  padding: 16px 16px 0;
}
.request-sheet .req-fields {
  flex: 1 1 auto;
  overflow: auto;
  min-height: 0;
  padding-left: 6px;
  padding-right: 6px;
  padding-bottom: 8px;
  box-sizing: border-box;
}

@media (prefers-reduced-motion: reduce) {
  .bit { animation: none; opacity: 0.4; }
  .card, .btn-start, .btn-how, .next, .wide, .icon-btn, .hero-art path {
    transition: none;
  }
}

.request-sheet #request-body {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
  overflow: hidden;
}



/* v3.7 follow-up: landscape phone tile fit + larger board */
@media (orientation: landscape) and (max-width: 999.98px) {
  .home,
  .lesson,
  .celebrate {
    padding-top: max(8px, env(safe-area-inset-top, 0px));
    padding-bottom: max(8px, env(safe-area-inset-bottom, 0px));
    padding-left: max(16px, env(safe-area-inset-left, 0px));
    padding-right: max(16px, env(safe-area-inset-right, 0px));
  }
  .home { gap: 8px; }
  .grid-scroll { padding-bottom: 8px; }
  .rows {
    grid-template-columns: repeat(3, minmax(0, 160px));
    justify-content: center;
    gap: 12px;
    align-content: start;
  }
  .card { padding: 4px 6px 6px; gap: 2px; }
  .card-art { max-height: 112px; width: 100%; }
  .card-title { font-size: 16px; }
  .card-meta { font-size: 12px; line-height: 1.15; }

  /* First grid row is only the 20px step label; Home/Sound sit in the side rails
     and may overflow that row without pushing the board down. */
  .lesson {
    grid-template-columns: 64px minmax(0, 1fr) 96px;
    grid-template-rows: 22px minmax(0, 1fr) 16px;
    grid-template-areas:
      "home label tools"
      "home board actions"
      ".     progress actions";
    gap: 6px 12px;
    column-gap: 12px;
  }
  .lesson .rail-home,
  .lesson .rail-tools { align-self: start; }
  .lesson .step-label {
    font-size: 20px;
    line-height: 1.1;
    height: 22px;
    align-self: center;
  }

  .celebrate {
    grid-template-columns: 64px minmax(0, 1fr) 96px;
    grid-template-rows: 28px minmax(0, 1fr);
    grid-template-areas:
      "home praise actions"
      "home board actions";
    gap: 6px 12px;
  }
}

@media (orientation: landscape) and (max-width: 999.98px) and (min-height: 420px) {
  .rows { grid-template-columns: repeat(3, minmax(0, 180px)); }
  .card-art { max-height: 140px; }
}

@media (orientation: landscape) and (max-width: 999.98px) and (max-height: 399.98px) {
  .rows { grid-template-columns: repeat(3, minmax(0, 130px)); }
  .card-art { max-height: 88px; }
  .card-meta { display: none; }
}

@media (orientation: landscape) and (max-width: 999.98px) {
  .lesson .step-label { text-align: center; }
}
@media (orientation: landscape) and (max-width: 999.98px) and (max-height: 399.98px) {
  .hero:not(.collapsed) .hero-copy h2 {
    white-space: normal;
    font-size: 18px;
    line-height: 1.15;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
}



/* Hoisted Send/Cancel (moved to the parent-card footer, outside the form). */
.parent-card .req-actions .req-send,
.parent-card > .req-actions .req-send,
.req-actions .req-send {
  width: 100%;
  height: 64px;
  min-height: 64px;
  margin: 0;
  border: 0;
  border-radius: var(--r-btn);
  background: var(--purple);
  color: #fff;
  box-shadow: 0 6px 0 var(--purple-ink);
  font-size: 20px;
  font-weight: 800;
}
.parent-card .req-actions .req-cancel,
.parent-card > .req-actions .req-cancel,
.req-actions .req-cancel {
  width: 100%;
  height: 64px;
  min-height: 64px;
  margin: 0;
  border-radius: var(--r-btn);
  background: #fff;
  color: var(--purple-ink);
  border: 3px solid var(--purple);
  box-shadow: none;
  font-size: 20px;
  font-weight: 800;
}
.choice[aria-pressed="true"] {
  background: var(--purple);
  color: #fff;
  border-color: var(--purple);
}

/* Parent form stays one <form> so Send still submits, with fields scrolling and actions pinned. */
.parent-card > .request-form {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 0;
  overflow: hidden;
}
.parent-card > .request-form > .parent-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}
.parent-card > .request-form > .req-actions {
  flex: none;
}

/* Narrow portrait (390×844 and 375): keep the Last step / Next / Replay row on screen. */
@media (orientation: portrait) and (max-width: 400px) {
  .lesson .step-label {
    font-size: 18px;
    line-height: 1.1;
  }
  .lesson .actions .wide,
  .lesson .actions .next {
    font-size: 18px;
    font-weight: 900;
    white-space: nowrap;
    padding: 0 8px;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}


/* ===== v3.7.1 AD fix pass ===== */
/* v3.7.3: self-hosted Nunito (see @font-face); compact parent-body bottom padding is 16px so the Picture idea label clears the footer at 375. */

/* 1. Home ≤400px portrait: stacked full-width 64px hero buttons, one-line tile meta.
   Hide promise chips and tighten art/padding so the hero stays around 240px
   and the first tile row plus More still land on a 375×667 screen. */
@media (orientation: portrait) and (max-width: 400px) {
  .hero:not(.collapsed) {
    max-height: none;
    padding: 8px 10px;
    gap: 6px 10px;
  }
  .hero:not(.collapsed) .hero-art {
    width: 80px;
    max-width: 80px;
    height: 72px;
    min-height: 0;
  }
  .hero:not(.collapsed) .hero-art svg { max-height: 72px; height: 100%; width: 100%; }
  .hero:not(.collapsed) .hero-copy h2 { font-size: 20px; margin-top: 2px; }
  .hero:not(.collapsed) .promise-chips,
  .hero:not(.collapsed) .promises {
    display: none;
  }
  .hero:not(.collapsed) .hero-actions {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .hero:not(.collapsed) .btn-start,
  .hero:not(.collapsed) .btn-how {
    width: 100%;
    flex: none;
    height: 64px;
    min-height: 64px;
    min-width: 0;
    padding: 0 16px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    box-sizing: border-box;
  }
  .hero:not(.collapsed) .btn-start { font-size: 20px; }
  .hero:not(.collapsed) .btn-how { font-size: 18px; }
  .card-meta {
    font-size: 13px;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0;
  }
}

.card-meta {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 2. Phone portrait player: board + progress tight under the title; leftover space above the thumb bar. */
@media (orientation: portrait) and (max-width: 819.98px) {
  .lesson {
    grid-template-rows: auto auto auto minmax(0, 1fr) auto;
    grid-template-areas:
      "home label tools"
      "board board board"
      "progress progress progress"
      ". . ."
      "actions actions actions";
  }
  .lesson .board-slot {
    place-items: start center;
    align-self: start;
  }
  .celebrate {
    grid-template-rows: auto auto auto minmax(0, 1fr) auto;
    grid-template-areas:
      "home praise ."
      "praise2 praise2 praise2"
      "board board board"
      ". . ."
      "actions actions actions";
  }
  .celebrate .board-slot {
    place-items: start center;
    align-self: start;
  }
}

/* 3. Parent / request sheet: centred, max 560px, hugs its content, one-row footer.
   Keyboard inset is reserved on the overlay so Send sits above the keys. */
.parent {
  box-sizing: border-box;
  padding-bottom: max(var(--gutter), env(safe-area-inset-bottom, 0px), var(--kbd));
  align-items: center;
  justify-content: center;
}
.parent-card {
  width: min(560px, 100%);
  max-width: 560px;
  height: auto;
  max-height: 100%;
  min-height: 0;
  margin-left: auto;
  margin-right: auto;
  flex: 0 1 auto;
  align-self: center;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.parent .choice-row,
.choice-row {
  gap: 10px;
}
#request-overlay.overlay,
#request-overlay {
  padding-bottom: max(var(--gutter), env(safe-area-inset-bottom, 0px), var(--kbd));
  box-sizing: border-box;
}
.request-sheet {
  max-height: 100%;
}
#request-body:empty { display: none; }
.parent-body,
.request-form .req-fields {
  scroll-padding-bottom: 16px;
}
/* One scroller only: fields participate in .parent-body overflow, so focus can
   bring the idea input fully above the Send/Cancel bar. */
.parent-card > .request-form > .parent-body .req-fields {
  overflow: visible;
  flex: none;
  min-height: auto;
}


/* One-row footer on every width, including iPad and desktop. */
.parent-card .req-actions,
.parent-card > .request-form > .req-actions,
.request-sheet .req-actions,
.req-actions {
  flex-direction: row;
  align-items: center;
  gap: 10px;
  padding: 8px 16px 10px;
  position: relative;
  flex: none;
}
.parent-card .req-actions .req-send,
.parent-card > .request-form > .req-actions .req-send,
.request-sheet .req-actions .req-send,
.req-actions .req-send {
  flex: 1 1 auto;
  width: auto;
  height: 56px;
  min-height: 56px;
  margin: 0;
}
.parent-card .req-actions .req-cancel,
.parent-card > .request-form > .req-actions .req-cancel,
.request-sheet .req-actions .req-cancel,
.req-actions .req-cancel {
  flex: 0 0 auto;
  width: auto;
  min-width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0 14px;
  margin: 0;
  font-size: 16px;
}

@media (max-width: 819.98px), (max-height: 500px) {
  .parent-card .req-actions,
  .parent-card > .request-form > .req-actions,
  .request-sheet .req-actions,
  .req-actions {
    flex-direction: row;
    align-items: center;
    gap: 10px;
    padding: 8px 16px 10px;
    position: relative;
    flex: none;
  }
  .parent-card .req-actions .req-send,
  .parent-card > .request-form > .req-actions .req-send,
  .request-sheet .req-actions .req-send,
  .req-actions .req-send {
    flex: 1 1 auto;
    width: auto;
    height: 56px;
    min-height: 56px;
    margin: 0;
  }
  .parent-card .req-actions .req-cancel,
  .parent-card > .request-form > .req-actions .req-cancel,
  .request-sheet .req-actions .req-cancel,
  .req-actions .req-cancel {
    flex: 0 0 auto;
    width: auto;
    min-width: 44px;
    height: 44px;
    min-height: 44px;
    padding: 0 14px;
    margin: 0;
    font-size: 16px;
  }

  .parent-body {
    --parent-gap: 8px;
    gap: var(--parent-gap);
    padding: 8px 14px 16px;
  }
  .parent-body > p,
  .parent-card .parent-body > p {
    font-size: 16px;
    line-height: 1.35;
  }
  .choice-row { gap: 10px; }
  .parent-body .choice,
  .parent-card .choice {
    min-height: 44px;
    height: 44px;
    font-size: 15px;
    padding: 0 8px;
  }
  .parent-card .request-form {
    margin-top: 0;
    padding-top: 8px;
  }
  .parent-card .request-form h2,
  .request-form h2 {
    font-size: 20px;
    margin: 0 0 4px;
  }
  .request-lede {
    font-size: 16px;
    line-height: 1.35;
    margin: 0 0 4px;
  }
  .suggest-row {
    display: flex;
    flex-wrap: wrap;
    overflow: visible;
    gap: 10px;
    margin: 0 0 8px;
  }
  .suggest-row .suggest {
    flex: 0 0 auto;
    height: 44px;
    min-height: 44px;
    white-space: nowrap;
  }
  .req-label { margin: 4px 0 4px; font-size: 16px; }
  .req-input,
  .request-form input[type="text"] {
    height: 44px;
    min-height: 44px;
  }
  .req-count { margin: 0; line-height: 1; font-size: 12px; }
  .age-chip {
    height: 44px;
    min-height: 44px;
    min-width: 56px;
  }
  .req-note { font-size: 16px; margin: 6px 0 0; }
}


/* v3.7.4: trim the 412/440 hero so Firefox stays at or under 340px.
   Chromium and WebKit are already under the cap and still keep 64px buttons
   and the first tile row above the fold. */
@media (orientation: portrait) and (min-width: 401px) and (max-width: 440px) {
  .hero:not(.collapsed) {
    padding: 10px 12px;
    gap: 8px 14px;
  }
  .hero:not(.collapsed) .hero-art {
    min-height: 116px;
  }
  .hero:not(.collapsed) .hero-art svg { max-height: 116px; }
  .hero:not(.collapsed) .hero-copy h2 { margin-top: 4px; line-height: 1.1; }
  .hero:not(.collapsed) .hero-lede {
    margin-top: 4px;
    font-size: 15px;
    line-height: 1.35;
  }
  .hero:not(.collapsed) .promise-chips,
  .hero:not(.collapsed) .promises {
    margin-top: 6px;
  }
}

/* v3.7.4: do not tighten .parent-body gap at 375 (choice rows must stay
   8px apart). Recover the Picture idea label clearance from typography
   and padding above the label instead. */
@media (orientation: portrait) and (max-width: 375px) {
  .parent-body {
    padding: 4px 14px 16px;
  }
  .parent-body > p,
  .parent-card .parent-body > p {
    line-height: 1.25;
  }
  .parent-card .request-form {
    padding-top: 0;
  }
  .parent-card .request-form h2,
  .request-form h2 {
    margin: 0 0 2px;
  }
  .request-lede {
    margin: 0;
  }
  .suggest-row {
    margin: 0 0 2px;
  }
  .req-label { margin: 2px 0 2px; }
}

/* 4–5. Uncapped hero must keep a full first tile row and ≥8px before More.
   Phone-portrait lesson gutters are 16px so the board can reach ~408px at 440. */
@media (orientation: portrait) and (max-width: 819.98px) {
  .home { gap: 8px; }
  .grid-scroll { padding-bottom: 8px; }
  .more-bar { margin-top: 0; }
}
@media (orientation: portrait) and (max-width: 440px) {
  .lesson,
  .celebrate {
    padding-left: max(16px, env(safe-area-inset-left, 0px));
    padding-right: max(16px, env(safe-area-inset-right, 0px));
  }
}

/* Focused request field stays clear of the Send/Cancel bar. */
#request-idea,
label.req-label[for="request-idea"] {
  scroll-margin-top: 8px;
  scroll-margin-bottom: 112px;
}

/* ===== v3.8.0 home navigation: native page scroll, chips, Keep drawing ===== */
:root { --strip-h: 64px; }
@media (min-width: 600px) and (min-height: 500px) {
  :root { --strip-h: 76px; }
}
@media (min-width: 820px) and (min-height: 500px) {
  :root { --gutter: 16px; }
}
@media (min-width: 1300px) {
  :root { --gutter: 20px; }
}

html, body, #app {
  height: auto;
  overflow: visible;
}
body {
  min-height: 100dvh;
}
#app { min-height: 100dvh; }

.home {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: min(1200px, 100%);
  height: auto;
  min-height: 0;
}

.hero-spacer {
  height: 0;
  flex: none;
  pointer-events: none;
  overflow-anchor: none;
}
.hero {
  overflow-anchor: none;
  transition: box-shadow 200ms ease, background-color 200ms ease;
}
.hero.collapsed {
  overflow-anchor: none;
}
.hero.collapsed {
  position: sticky;
  top: 0;
  z-index: 30;
  width: 100%;
  height: calc(var(--strip-h) + env(safe-area-inset-top, 0px));
  max-height: calc(var(--strip-h) + env(safe-area-inset-top, 0px));
  padding-top: env(safe-area-inset-top, 0px);
  margin: 0;
  box-shadow: 0 2px 10px rgba(60, 40, 20, 0.08);
}
@media (prefers-reduced-motion: reduce) {
  .hero,
  .hero-spacer { transition: none; }
}

/* Categories: 48px visual pill, 64px hit area, sticky under the strip. */
.chip-bar {
  position: sticky;
  top: 0;
  z-index: 25;
  background: var(--bg);
  margin: 0 calc(-1 * max(var(--gutter), env(safe-area-inset-left, 0px))) 0 calc(-1 * max(var(--gutter), env(safe-area-inset-right, 0px)));
  padding: 8px max(var(--gutter), env(safe-area-inset-right, 0px)) 8px max(var(--gutter), env(safe-area-inset-left, 0px));
}
.home:has(.hero.collapsed) .chip-bar {
  top: calc(var(--strip-h) + env(safe-area-inset-top, 0px));
}
.chip-row {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  align-items: stretch;
  overflow-x: auto;
  overflow-y: hidden;
  height: 64px;
  padding: 0;
}
.chip-bar {
  position: sticky;
  /* fade on phone only, via a non-interactive gradient */
}
.cat-chip {
  position: relative;
  isolation: isolate;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 64px;
  min-height: 64px;
  padding: 0 18px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font-size: 16px;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
  box-shadow: none;
}
/* 48px visual pill; the button itself is the 64px hit area (not a clipped ::before). */
.cat-chip::before {
  content: "";
  position: absolute;
  left: 4px;
  right: 4px;
  top: 8px;
  height: 48px;
  margin: 0;
  border-radius: 999px;
  border: 2px solid #C9BCAE;
  background: #fff;
  z-index: -1;
  pointer-events: none;
}
.cat-chip .chip-check { display: none; flex: none; position: relative; z-index: 1; }
.cat-chip.is-selected {
  border-color: transparent;
  background: transparent;
  color: var(--ink);
  box-shadow: none;
}
.cat-chip.is-selected::before {
  border-color: transparent;
  background: var(--chip-tint, var(--purple));
  box-shadow: inset 0 0 0 3px var(--ink);
}
.cat-chip[data-cat="all"].is-selected {
  background: transparent;
  color: var(--purple-ink);
  box-shadow: none;
}
.cat-chip[data-cat="all"].is-selected::before {
  background: var(--purple-tint);
  box-shadow: inset 0 0 0 3px var(--purple);
}
.cat-chip.is-selected .chip-check { display: block; }

@media (max-width: 819.98px) {
  .chip-bar { position: sticky; }
  .chip-bar::after {
    content: "";
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 28px;
    pointer-events: none;
    background: linear-gradient(to right, rgba(255, 244, 230, 0), var(--bg));
  }
}
@media (min-width: 820px) {
  .chip-row {
    overflow: visible;
    justify-content: flex-start;
    gap: 8px;
  }
  .cat-chip { padding: 0 12px; font-size: 15px; }
}

/* Keep drawing: hidden when empty (not rendered). 96px+ tiles, sideways on phone. */
.keep-drawing {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}
.keep-drawing h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 900;
  letter-spacing: -0.02em;
}
.keep-row {
  display: flex;
  flex-wrap: nowrap;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 4px;
}
.keep-card {
  flex: 0 0 auto;
  width: 112px;
  min-width: 112px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  background: var(--card);
  border-radius: 20px;
  box-shadow: var(--shadow);
  text-align: center;
}
.keep-art {
  width: 96px;
  height: 96px;
  min-width: 96px;
  min-height: 96px;
  border-radius: 16px;
  overflow: hidden;
  display: grid;
  place-items: center;
  margin: 0 auto;
}
.keep-art svg { width: 100%; height: 100%; display: block; }
.keep-title {
  font-size: 14px;
  font-weight: 800;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
@media (min-width: 820px) {
  .keep-row { flex-wrap: wrap; overflow: visible; }
  .keep-card { width: 128px; min-width: 128px; }
  .keep-art { width: 112px; height: 112px; }
}

/* Denser grid: square art + one-line title. */
.rows {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  align-content: start;
  justify-content: stretch;
}
.card {
  min-height: 64px;
  padding: 8px 8px 10px;
  gap: 6px;
}
.card-art {
  aspect-ratio: 1;
  width: 100%;
  max-height: none;
}
.card-title {
  font-size: 16px;
  font-weight: 900;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card-meta { display: none; }

@media (orientation: landscape) and (max-width: 999.98px) {
  .rows {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    justify-content: stretch;
  }
  .card-art { max-height: none; }
  .card-title { font-size: 15px; }
}
@media (orientation: portrait) and (min-width: 600px) {
  .rows {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
  }
  .card-title { font-size: 18px; }
}
@media (orientation: landscape) and (min-width: 1000px) and (max-width: 1299.98px) {
  .rows {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 16px;
    justify-content: stretch;
  }
  .card-title { font-size: 16px; }
}
@media (min-width: 1300px) {
  .rows {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 20px;
    justify-content: stretch;
  }
  .card-title { font-size: 16px; }
  .hero:not(.collapsed) { width: 100%; }
}

/* Lesson / celebrate: aim to fit, but the page scrolls if they overflow.
   Sticky action bar keeps a matching bottom inset. */
.lesson,
.celebrate {
  height: auto;
  min-height: 100dvh;
}
.lesson .actions,
.celebrate .actions {
  position: sticky;
  bottom: 0;
  z-index: 8;
  background: var(--bg);
  padding-bottom: max(var(--gutter), env(safe-area-inset-bottom, 0px));
  padding-top: 8px;
}

#clear-recent {
  margin-top: 12px;
  min-height: 64px;
  min-width: 64px;
  padding: 0 20px;
  border-radius: var(--r-btn);
}
.clear-recent-status {
  margin: 10px 0 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--muted);
}

/* Retired "More pictures" / nested scroller — keep harmless if markup appears. */
.more-bar,
.more { display: none !important; }
.grid-scroll {
  overflow: visible;
  scrollbar-width: auto;
  min-height: 0;
  height: auto;
}
.grid-scroll::-webkit-scrollbar { display: block; width: auto; height: auto; }

/* ===== v3.8.0 AD spec follow-up: tile metrics, 375 cap, hero caps ===== */
.card {
  padding: 6px;
  gap: 4px;
}
.card-title {
  height: 20px;
  font-size: 16px;
  font-weight: 900;
  line-height: 1.15;
  display: flex;
  align-items: center;
  justify-content: center;
}
@media (min-width: 820px) and (min-height: 500px) {
  .card { padding: 8px; gap: 4px; }
  .card-title { height: 24px; font-size: 20px; }
}

/* 375-wide portrait only: cap tiles at 139×157 and center (42.5px inset). */
@media (orientation: portrait) and (max-width: 389.98px) {
  .home {
    padding-left: 12px;
    padding-right: 12px;
  }
  .rows {
    grid-template-columns: repeat(2, 139px);
    justify-content: center;
    gap: 12px;
  }
  .card {
    width: 139px;
    max-width: 139px;
    height: 157px;
    min-height: 157px;
    padding: 6px;
    gap: 4px;
  }
  .card-art {
    width: 127px;
    height: 127px;
    max-height: 127px;
    flex: none;
  }
}

/* Desktop: 1200px content, 16px gap, 6 columns from 1300px (1440×900). */
@media (min-width: 1300px) {
  .home {
    width: 1200px;
    max-width: 1200px;
    padding-left: 0;
    padding-right: 0;
    margin-left: auto;
    margin-right: auto;
  }
  .rows {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 16px;
  }
}

/* Hero height caps from the Option A spec. */
@media (orientation: portrait) and (max-width: 399.98px) {
  .hero:not(.collapsed) { max-height: 240px; }
  .hero:not(.collapsed) .promise-chips,
  .hero:not(.collapsed) .promises { display: none; }
}
@media (orientation: portrait) and (min-width: 390px) and (max-width: 411.98px) {
  .hero:not(.collapsed) { max-height: 240px; }
}
@media (orientation: portrait) and (min-width: 412px) and (max-width: 819.98px) {
  .hero:not(.collapsed) { max-height: 340px; }
}
@media (orientation: landscape) and (max-width: 999.98px) {
  .hero:not(.collapsed) { max-height: min(112px, 28vh); }
}
@media (orientation: portrait) and (min-width: 820px) {
  .hero:not(.collapsed) { max-height: 30svh; }
}
@media (orientation: landscape) and (min-width: 1000px) and (max-width: 1299.98px) {
  .hero:not(.collapsed) { max-height: 200px; }
}
@media (min-width: 1300px) {
  .hero:not(.collapsed) { max-height: 30svh; }
}

.hero .wordmark.holding {
  color: var(--purple);
  outline: 3px solid var(--purple);
  outline-offset: 4px;
  border-radius: 8px;
}

.grid-empty {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--muted);
}
.empty-all {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 14px;
  margin-left: 8px;
  border-radius: 999px;
  background: var(--purple-tint);
  color: var(--purple-ink);
  font-weight: 800;
}

/* Keep drawing: edge fade on phone. */
@media (max-width: 819.98px) {
  .keep-drawing { position: relative; }
  .keep-drawing::after {
    content: "";
    position: absolute;
    right: 0;
    top: 28px;
    bottom: 0;
    width: 28px;
    pointer-events: none;
    background: linear-gradient(to right, rgba(255, 244, 230, 0), var(--bg));
  }
}

#clear-recent { min-height: 44px; }
.parent-recent { margin-top: 8px; }

/* Document is the scroller: overflow-y auto so the scrollbar is visible and
   programmatic / wheel / touch scrolling all move the same container. */
html {
  overflow-x: auto;
  overflow-y: auto;
  scrollbar-width: auto;
  height: auto;
}
body, #app {
  overflow: visible;
  height: auto;
  min-height: 100dvh;
}

/* Tile height: top pad + art + 4px gap + title = tileW+18 / +20.
   Phone: 6 + (W-12) + 4 + 20 = W+18. From 820: 8 + (W-16) + 4 + 24 = W+20. */
.card {
  padding: 6px 6px 0;
  gap: 4px;
}
.card-title {
  height: 20px;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-size: 16px;
}
@media (min-width: 820px) and (min-height: 500px) {
  .card { padding: 8px 8px 0; gap: 4px; }
  .card-title {
    height: 24px;
    padding: 0;
    box-sizing: border-box;
    font-size: 20px;
  }
}
@media (orientation: portrait) and (max-width: 389.98px) {
  .card { padding: 6px 6px 0; height: 157px; min-height: 157px; }
  .card-title { height: 20px; padding: 0; box-sizing: border-box; }
}

/* Chip row is a 64px sticky bar so the phone stack is 64+64. */
.chip-bar {
  padding-top: 0;
  padding-bottom: 0;
  height: 64px;
  display: flex;
  align-items: center;
  box-sizing: border-box;
}
.chip-row { padding: 0; }


/* ===== v3.8.0-r4: chip hit, phone-landscape strip/lesson, scrollbar-stable tiles ===== */

@media (orientation: portrait) and (max-width: 819.98px) {
  .home {
    padding-left: 12px;
    padding-right: 12px;
    width: 100%;
    box-sizing: border-box;
  }
  .rows {
    width: 100%;
    box-sizing: border-box;
    gap: 12px;
  }
}

@media (orientation: portrait) and (min-width: 412px) and (max-width: 439.98px) {
  .home { padding-left: 12px; padding-right: 12px; }
  .rows {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    justify-content: stretch;
  }
  .card { width: auto; max-width: none; height: auto; min-height: 0; }
  .card-art { width: 100%; height: auto; aspect-ratio: 1; max-height: none; }
}

@media (orientation: portrait) and (min-width: 440px) and (max-width: 819.98px) {
  .home { padding-left: 12px; padding-right: 12px; }
  .rows {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    justify-content: stretch;
  }
  .card { width: auto; max-width: none; height: auto; min-height: 0; }
  .card-art { width: 100%; height: auto; aspect-ratio: 1; max-height: none; }
}

@media (orientation: portrait) and (min-width: 820px) {
  .home {
    padding-left: max(16px, env(safe-area-inset-left, 0px));
    padding-right: max(16px, env(safe-area-inset-right, 0px));
  }
  .rows {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
  }
}

@media (orientation: landscape) and (max-width: 999.98px) {
  :root { --strip-h: 64px; }
  .home {
    padding-left: 12px;
    padding-right: 12px;
    padding-top: max(8px, env(safe-area-inset-top, 0px));
    padding-bottom: max(8px, env(safe-area-inset-bottom, 0px));
  }
  .hero.collapsed {
    height: calc(64px + env(safe-area-inset-top, 0px));
    max-height: calc(64px + env(safe-area-inset-top, 0px));
  }
}

@media (orientation: landscape) and (max-width: 999.98px) {
  .lesson,
  .celebrate {
    padding-top: max(8px, env(safe-area-inset-top, 0px));
    padding-right: max(16px, env(safe-area-inset-right, 0px));
    padding-bottom: max(8px, env(safe-area-inset-bottom, 0px));
    padding-left: max(16px, env(safe-area-inset-left, 0px));
    overflow: visible;
    grid-template-columns: 64px minmax(0, 1fr) 64px;
    grid-template-rows: 64px minmax(0, 1fr) auto;
    grid-template-areas:
      "home label tools"
      "home board actions"
      "home progress actions";
    gap: 6px 12px;
  }
  .lesson .rail-home,
  .celebrate .rail-home {
    align-self: start;
    width: 64px;
    height: 64px;
    margin: 0;
  }
  .lesson .rail-tools {
    grid-area: tools;
    align-self: start;
    justify-self: end;
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 64px;
    min-width: 64px;
  }
  .lesson .rail-home,
  .lesson .rail-tools .icon-btn,
  .lesson .icon-btn[data-act="mute"],
  .lesson .icon-btn[data-act="music"] {
    width: 64px;
    height: 64px;
    min-width: 64px;
    min-height: 64px;
    flex: none;
    box-sizing: border-box;
  }
  .lesson .step-label { height: auto; align-self: center; }
  .celebrate {
    grid-template-areas:
      "home praise actions"
      "home board actions";
    grid-template-rows: 64px minmax(0, 1fr);
  }
}

.home, .rows, .card { box-sizing: border-box; }

/* ===== v3.8.0-r5: phone gutter matches home padding; phone-landscape tile chrome ===== */
@media (orientation: portrait) and (max-width: 819.98px) {
  :root { --gutter: 12px; }
}
@media (orientation: landscape) and (max-height: 499.98px) {
  :root { --gutter: 12px; }
}
@media (orientation: landscape) and (max-width: 999.98px) {
  .card { padding: 6px 6px 0; gap: 4px; }
  .card-title { height: 20px; font-size: 16px; }
}
