:root {
  color-scheme: light;
  --ink: #172b3d;
  --muted: #5c6d7c;
  --navy: #17324a;
  --cream: #fff8ea;
  --paper: #fffdf8;
  --gold: #f2b741;
  --gold-dark: #c98a08;
  --line: #ddd2bd;
  --red: #d63a2f;
  --purple: #7048b6;
  --green: #2f9e5f;
  --danger: #a2261d;
  --shadow: 0 18px 50px rgba(23, 50, 74, 0.13);
  font-family: Inter, ui-rounded, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html { min-height: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(242, 183, 65, 0.2), transparent 34rem),
    linear-gradient(180deg, #fffaf0 0%, #f6efe1 100%);
}

button, input, select, textarea { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 4px solid rgba(242, 183, 65, 0.65);
  outline-offset: 3px;
}

[hidden] { display: none !important; }

.topbar {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 18px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
}

.topbar h1 {
  margin: 0;
  font-size: clamp(1.85rem, 4vw, 3.4rem);
  line-height: 1.02;
  letter-spacing: -0.04em;
}

.eyebrow {
  margin: 0 0 8px;
  color: #8a6100;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.tagline {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 1.08rem;
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding-top: 8px;
}

main {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding-bottom: 42px;
}

.panel {
  background: rgba(255, 253, 248, 0.94);
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
  padding: clamp(22px, 4vw, 44px);
}

.panel-heading { max-width: 780px; }
.panel-heading h2, .child-stage h2 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 4rem);
  line-height: 1.05;
  letter-spacing: -0.035em;
}
.panel-heading p:not(.eyebrow) {
  color: var(--muted);
  font-size: 1.08rem;
  line-height: 1.55;
}

.row-heading {
  max-width: none;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
}

form { margin-top: 28px; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.field {
  display: grid;
  gap: 9px;
  margin-top: 20px;
  font-weight: 750;
}
.form-grid .field { margin-top: 0; }
.field small { color: var(--muted); font-weight: 550; }

input[type="text"], input[type="time"], select, textarea {
  width: 100%;
  border: 2px solid #cfc4ab;
  border-radius: 16px;
  background: white;
  color: var(--ink);
  padding: 14px 16px;
  min-height: 54px;
}
textarea { resize: vertical; line-height: 1.5; }

.choice-group {
  border: 0;
  padding: 0;
  margin: 28px 0 0;
}
.choice-group legend {
  padding: 0;
  margin-bottom: 13px;
  font-weight: 800;
}

.character-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}
.character-option {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 8px;
  min-height: 190px;
  padding: 18px;
  border: 3px solid var(--line);
  border-radius: 24px;
  background: white;
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}
.character-option:hover { transform: translateY(-2px); }
.character-option:has(input:checked) {
  border-color: var(--navy);
  box-shadow: 0 0 0 5px rgba(242, 183, 65, 0.35);
}
.character-option input {
  position: absolute;
  opacity: 0;
  inset: 12px auto auto 12px;
  width: 22px;
  height: 22px;
}
.character-option:focus-within {
  outline: 4px solid rgba(242, 183, 65, 0.65);
  outline-offset: 3px;
}
.character-visual {
  display: grid;
  place-items: center;
  width: clamp(96px, 14vw, 142px);
  aspect-ratio: 1;
}
.character-visual img, .profile-character img, .child-character img, .message-character img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.character-name { font-size: 1.25rem; font-weight: 850; }

.segmented-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.segmented-options label { position: relative; }
.segmented-options input {
  position: absolute;
  opacity: 0;
  inset: 0 auto auto 0;
}
.segmented-options span {
  display: grid;
  place-items: center;
  min-height: 58px;
  padding: 12px;
  border: 2px solid var(--line);
  border-radius: 16px;
  background: white;
  font-weight: 800;
  text-align: center;
  cursor: pointer;
}
.segmented-options label:has(input:checked) span {
  border-color: var(--navy);
  background: #fff0bd;
}
.segmented-options label:focus-within span {
  outline: 4px solid rgba(242, 183, 65, 0.65);
  outline-offset: 3px;
}

.consent {
  display: flex;
  gap: 13px;
  align-items: flex-start;
  margin-top: 26px;
  padding: 18px;
  border-radius: 18px;
  background: #fff4cf;
  line-height: 1.5;
}
.consent input { width: 24px; height: 24px; flex: 0 0 auto; margin-top: 2px; accent-color: var(--navy); }

.form-error {
  margin: 18px 0 0;
  padding: 14px 16px;
  border-radius: 14px;
  background: #ffe7e3;
  color: #7c1710;
  font-weight: 750;
}
.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 24px;
}

.button {
  border: 0;
  border-radius: 999px;
  padding: 12px 20px;
  min-height: 48px;
  font-weight: 850;
  cursor: pointer;
  text-decoration: none;
}
.button-primary { background: var(--navy); color: white; }
.button-primary:hover { background: #234764; }
.button-secondary { background: #ffe083; color: var(--ink); border: 2px solid #d8a41d; }
.button-secondary:hover { background: #ffd65c; }
.button-quiet { background: transparent; color: var(--navy); border: 2px solid var(--line); }
.button-large { min-height: 58px; padding: 15px 24px; font-size: 1.03rem; }
.button:disabled { cursor: default; opacity: 0.62; }

.status-pill {
  flex: 0 0 auto;
  border-radius: 999px;
  background: #dff5e6;
  color: #176337;
  padding: 9px 14px;
  font-weight: 850;
}
.status-pill.paused { background: #eceff1; color: #53636e; }

.profile-card {
  display: grid;
  grid-template-columns: 190px 1fr;
  gap: 28px;
  align-items: center;
  margin-top: 28px;
  padding: 24px;
  border: 2px solid var(--line);
  border-radius: 24px;
  background: white;
}
.profile-character { width: 180px; aspect-ratio: 1; }
.profile-details h3 { margin: 0 0 18px; font-size: 2rem; }
.profile-details dl {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px 28px;
  margin: 0;
}
.profile-details dt { color: var(--muted); font-size: 0.82rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.07em; }
.profile-details dd { margin: 4px 0 0; font-size: 1.08rem; font-weight: 750; }

.action-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 24px;
}
.note-box {
  margin-top: 24px;
  padding: 20px;
  border-radius: 20px;
  background: #eef6ff;
  color: #29465e;
  line-height: 1.55;
}
.note-box h3 { margin: 0 0 7px; }
.note-box p { margin: 0; }
.text-danger {
  margin-top: 22px;
  border: 0;
  background: transparent;
  color: var(--danger);
  font-weight: 800;
  cursor: pointer;
  padding: 8px 0;
}

.footer {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 0 0 30px;
  color: var(--muted);
  line-height: 1.5;
}

/* Child mode */
body.showing-child { background: var(--cream); }
body.showing-child .topbar, body.showing-child .footer { display: none; }
body.showing-child main { width: 100%; padding: 0; }

.child-shell {
  position: relative;
  min-height: 100svh;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: clamp(20px, 5vw, 64px);
  background:
    radial-gradient(circle at 50% 12%, rgba(242, 183, 65, 0.35), transparent 28rem),
    var(--cream);
}
.child-stage {
  width: min(1050px, 100%);
  text-align: center;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 22px;
  min-height: calc(100svh - 110px);
}
.grown-up-button {
  position: absolute;
  top: max(16px, env(safe-area-inset-top));
  right: 16px;
  z-index: 3;
  border: 2px solid rgba(23, 50, 74, 0.16);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  padding: 10px 15px;
  font-weight: 750;
  cursor: pointer;
}
.character-button {
  display: grid;
  justify-items: center;
  gap: 12px;
  border: 0;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  padding: 0;
}
.character-button:not(:disabled):active .child-character { transform: scale(0.97); }
.child-character {
  width: clamp(230px, 52vw, 470px);
  aspect-ratio: 1;
  filter: drop-shadow(0 22px 28px rgba(23, 50, 74, 0.18));
  animation: character-in 520ms ease both;
}
.tap-label {
  border-radius: 999px;
  background: var(--navy);
  color: white;
  padding: 11px 18px;
  font-weight: 850;
}
.character-button:disabled .tap-label { background: #8b98a2; }
.child-subline {
  max-width: 760px;
  margin: 0;
  color: var(--muted);
  font-size: clamp(1.2rem, 3vw, 1.8rem);
  line-height: 1.4;
}
.message-stage { gap: 26px; }
.message-character { width: clamp(150px, 28vw, 270px); aspect-ratio: 1; }
.message-kicker {
  margin: 0;
  color: #8a6100;
  font-size: 0.9rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.daily-message {
  max-width: 980px;
  margin: 0;
  font-size: clamp(2.35rem, 7.2vw, 5.7rem);
  line-height: 1.13;
  font-weight: 850;
  letter-spacing: -0.035em;
  text-wrap: balance;
}
.done-button {
  min-width: min(340px, 82vw);
  min-height: 76px;
  background: var(--gold);
  color: var(--ink);
  border: 3px solid var(--gold-dark);
  font-size: 1.45rem;
  box-shadow: 0 14px 30px rgba(201, 138, 8, 0.25);
}

/* Read-aloud: the character on the message stage is one big friendly button. */
.message-character-button {
  display: grid;
  justify-items: center;
  gap: 12px;
  border: 0;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  padding: 0;
}
.message-character-button:active .message-character { transform: scale(0.97); }
.listen-label {
  border-radius: 999px;
  background: var(--navy);
  color: white;
  padding: 11px 18px;
  font-weight: 850;
  font-size: 1.05rem;
}

/* Read-along: one span per word; the spoken word lights up big and clear. */
.msg-word {
  border-radius: 0.16em;
  padding: 0 0.05em;
  transition: background-color 120ms ease;
}
.msg-word.word-read { background: rgba(242, 183, 65, 0.22); }
.msg-word.word-active {
  background: var(--gold);
  box-shadow: 0 0 0 0.07em var(--gold-dark);
}

/* The daily star: one tap on the all-done stage, and the character cheers. */
.star-button {
  display: grid;
  justify-items: center;
  gap: 4px;
  border: 0;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  padding: 6px 12px;
}
.star-icon {
  font-size: clamp(4.2rem, 15vw, 7.5rem);
  line-height: 1;
  color: #b7c2ca;
  transition: color 200ms ease;
}
.star-button.earned .star-icon {
  color: var(--gold-dark);
  animation: star-pop 480ms ease;
}
.star-label { font-weight: 850; font-size: 1.2rem; }
@keyframes star-pop {
  0% { transform: scale(0.55) rotate(-14deg); }
  60% { transform: scale(1.28) rotate(7deg); }
  100% { transform: scale(1) rotate(0deg); }
}
.character-cheer { animation: character-cheer 620ms ease; }
@keyframes character-cheer {
  0% { transform: translateY(0); }
  30% { transform: translateY(-16px) rotate(-2deg); }
  55% { transform: translateY(0) rotate(2deg); }
  80% { transform: translateY(-8px); }
  100% { transform: translateY(0); }
}

@keyframes character-in {
  from { opacity: 0; transform: translateY(18px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (max-width: 760px) {
  .topbar { flex-direction: column; }
  .form-grid, .character-options, .profile-card, .profile-details dl, .action-grid {
    grid-template-columns: 1fr;
  }
  .profile-character { width: min(210px, 72vw); margin: 0 auto; }
  .profile-details h3 { text-align: center; }
  .segmented-options { grid-template-columns: 1fr; }
  .panel { border-radius: 22px; }
  .child-stage { min-height: calc(100svh - 72px); }
}

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

/* ---- Live-app additions (auth, children list, pairing, billing) ---- */

input[type="email"], input[type="password"], input[type="text"] {
  width: 100%;
  border: 2px solid #cfc4ab;
  border-radius: 16px;
  background: white;
  color: var(--ink);
  padding: 14px 16px;
  min-height: 54px;
}

.auth-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px;
  margin-top: 28px;
}
.auth-card {
  border: 2px solid var(--line);
  border-radius: 24px;
  background: white;
  padding: 24px;
  margin-top: 0;
}
.auth-card h3 { margin: 0 0 6px; font-size: 1.35rem; }
.auth-card .field:first-of-type { margin-top: 14px; }
.auth-card .button { margin-top: 20px; width: 100%; }
.auth-note { color: var(--muted); line-height: 1.5; margin: 6px 0 0; }
.pair-card { margin-top: 22px; }
.pair-card .field { max-width: 420px; }

.parent-intro { color: var(--muted); font-size: 1.05rem; line-height: 1.55; margin: 14px 0 0; }

.children-list { display: grid; gap: 20px; margin-top: 24px; }
.child-card {
  border: 2px solid var(--line);
  border-radius: 24px;
  background: white;
  padding: 24px;
}
.child-card-main {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 24px;
  align-items: center;
}
.child-card-character { width: 150px; aspect-ratio: 1; }
.child-card-character img { display: block; width: 100%; height: 100%; object-fit: contain; }
.child-card-details h3 { margin: 0 0 12px; font-size: 1.7rem; display: inline-block; margin-right: 12px; }
.child-card-details dl {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 24px;
  margin: 10px 0 0;
}
.child-card-details dt { color: var(--muted); font-size: 0.8rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.07em; }
.child-card-details dd { margin: 3px 0 0; font-size: 1.02rem; font-weight: 750; }
.child-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}
.pairing-box {
  margin-top: 16px;
  padding: 16px 18px;
  border-radius: 16px;
  background: #fff4cf;
  line-height: 1.5;
}
.pairing-box .pairing-code {
  font-size: 1.9rem;
  font-weight: 900;
  letter-spacing: 0.22em;
}
.empty-note {
  border: 2px dashed var(--line);
  border-radius: 20px;
  padding: 22px;
  color: var(--muted);
  line-height: 1.55;
  background: rgba(255, 255, 255, 0.6);
}
.child-form { margin-top: 38px; border-top: 2px solid var(--line); padding-top: 8px; }
.child-form h3 { font-size: 1.5rem; margin-bottom: 0; }
.push-status { margin: 10px 0 0; font-weight: 700; }
.account-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 18px;
  margin-top: 30px;
  border-top: 2px solid var(--line);
  padding-top: 22px;
}
.account-actions .text-danger { margin-top: 0; }
.footer a { color: var(--navy); font-weight: 700; }

@media (max-width: 760px) {
  .auth-grid, .child-card-main, .child-card-details dl { grid-template-columns: 1fr; }
  .child-card-character { margin: 0 auto; }
  .child-card-details h3 { text-align: center; }
}
