*, *::before, *::after { box-sizing: border-box; }
:root {
  /* Neutral dark slate — lets stoplight primaries pop without clashing */
  --bg-1: #0f172a;     /* slate-900 */
  --bg-2: #1e293b;     /* slate-800 */
  --bg-light: #faf7ee;

  /* Stoplight primaries — used for the talk button state */
  --green:  #22c55e;   /* idle: tap to start */
  --yellow: #facc15;   /* in-between: thinking / speaking */
  --red:    #ef4444;   /* active session rolling: tap to stop */

  --accent: var(--green);    /* legacy alias for non-button accents (chips, picked tags) */
  --accent-2: #38bdf8;       /* sky-400 — focus rings, soft cyan */
  --ink: #0f172a;
  --ink-soft: #334155;
  --shadow: 0 12px 36px rgba(0, 0, 0, 0.40);
  --shadow-soft: 0 6px 20px rgba(0, 0, 0, 0.18);
  --hairline: rgba(255, 255, 255, 0.08);
}

html, body { margin: 0; padding: 0; min-height: 100%; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  color: white;
  background: linear-gradient(160deg, var(--bg-1) 0%, var(--bg-2) 100%);
  background-attachment: fixed;
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

/* ====== SCREENS — show one at a time ====== */
.screen { display: none; }
.screen[data-active] { display: block; }
#screen-kid[data-active] { display: flex; }
#screen-onboarding[data-active] { display: flex; }
#screen-report[data-active] { display: block; }

/* ====== Buttons (shared) ====== */
button { font-family: inherit; }
.primary, .ghost {
  appearance: none;
  border: none;
  cursor: pointer;
  border-radius: 12px;
  padding: 12px 22px;
  font-size: 15px;
  font-weight: 700;
  font-family: inherit;
  transition: transform 0.1s ease, filter 0.15s ease, background 0.2s ease;
}
.primary {
  background: var(--accent);
  color: var(--ink);
  box-shadow: var(--shadow-soft);
}
.primary:hover { filter: brightness(1.05); }
.primary:active { transform: translateY(1px); }
.primary[disabled] { opacity: 0.4; cursor: not-allowed; }
.primary.big { padding: 16px 28px; font-size: 16px; }
.primary.block { width: 100%; padding: 14px; }
.ghost {
  background: rgba(255, 255, 255, 0.08);
  color: white;
  font-weight: 600;
}
.ghost:hover { background: rgba(255, 255, 255, 0.16); }
.ghost.small { padding: 8px 14px; font-size: 13px; }

/* ============================================
   ONBOARDING
   ============================================ */
#screen-onboarding {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 32px 24px 48px;
}
.onb-step {
  width: min(440px, 100%);
  text-align: center;
}
.onb-step[hidden] { display: none; }

.onb-mark {
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 16px;
}
.onb-progress {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin-bottom: 28px;
}
.onb-progress span {
  width: 28px;
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
}
.onb-progress[data-progress="1/3"] span:nth-child(1),
.onb-progress[data-progress="2/3"] span:nth-child(-n+2),
.onb-progress[data-progress="3/3"] span:nth-child(-n+3),
.onb-progress[data-progress="1/4"] span:nth-child(1),
.onb-progress[data-progress="2/4"] span:nth-child(-n+2),
.onb-progress[data-progress="3/4"] span:nth-child(-n+3),
.onb-progress[data-progress="4/4"] span:nth-child(-n+4) {
  background: var(--accent);
}

#screen-onboarding h1 {
  font-size: clamp(28px, 6vw, 38px);
  margin: 0 0 16px;
  line-height: 1.15;
  letter-spacing: -0.02em;
}
#screen-onboarding h1 em { color: var(--accent); font-style: normal; }
#screen-onboarding h2 {
  font-size: clamp(22px, 5vw, 28px);
  margin: 0 0 10px;
  line-height: 1.2;
  letter-spacing: -0.01em;
}
.lede {
  font-size: clamp(15px, 3.5vw, 17px);
  line-height: 1.55;
  margin: 0 0 24px;
  color: rgba(255, 255, 255, 0.88);
}
.sub {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.65);
  margin: 0 0 22px;
}
.onb-meta {
  margin-top: 14px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.5);
}

#onb-name, #onb-custom-input, #onb-birthdate, #onb-location {
  width: 100%;
  max-width: 100%;
  padding: 14px 16px;
  font-size: 18px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.05);
  color: white;
  font-family: inherit;
  text-align: center;
  margin-bottom: 18px;
  color-scheme: dark;
}
#onb-birthdate { margin-bottom: 8px; }
.onb-age-readout {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.7);
  margin: 0 0 22px;
  min-height: 1.2em;
}
#onb-name::placeholder, #onb-custom-input::placeholder {
  color: rgba(255, 255, 255, 0.35);
}
#onb-name:focus, #onb-custom-input:focus {
  outline: 2px solid var(--accent-2);
  outline-offset: 1px;
  background: rgba(255, 255, 255, 0.08);
}

.age-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}
.age-pick {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.04);
  color: white;
  font-size: 28px;
  font-weight: 700;
  padding: 18px 0;
  border-radius: 16px;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s, border-color 0.15s;
  font-family: inherit;
}
.age-pick:hover { background: rgba(255, 255, 255, 0.1); }
.age-pick:active { transform: scale(0.96); }
.age-pick[aria-pressed="true"] {
  background: var(--accent);
  color: var(--ink);
  border-color: var(--accent);
}

.onb-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-bottom: 16px;
}
.chip {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.04);
  color: white;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.chip:hover { background: rgba(255, 255, 255, 0.1); }
.chip:active { transform: scale(0.96); }
.chip[aria-pressed="true"] {
  background: var(--accent);
  color: var(--ink);
  border-color: var(--accent);
  font-weight: 700;
}

.onb-custom-form {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.onb-custom-form input {
  flex: 1 1 0;
  min-width: 0;
  padding: 10px 14px;
  font-size: 14px;
  text-align: left;
  margin-bottom: 0;
}
.onb-custom-form button {
  width: 44px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.06);
  color: white;
  font-size: 22px;
  cursor: pointer;
  font-family: inherit;
}
.onb-custom-form button:hover { background: rgba(255, 255, 255, 0.12); }

.onb-picked {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 40px;
  margin-bottom: 24px;
  align-items: center;
  justify-content: center;
  padding: 8px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px dashed rgba(255, 255, 255, 0.12);
}
.onb-picked:empty::after {
  content: "Picked favorites will appear here";
  color: rgba(255, 255, 255, 0.35);
  font-size: 13px;
}
.picked-tag {
  background: var(--accent);
  color: var(--ink);
  padding: 6px 10px 6px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.picked-tag button {
  appearance: none;
  border: none;
  background: rgba(0, 0, 0, 0.18);
  color: var(--ink);
  width: 18px;
  height: 18px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 11px;
  display: grid;
  place-items: center;
  font-family: inherit;
  line-height: 1;
}

.onb-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 12px;
}

.onb-checkmark {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--ink);
  font-size: 40px;
  font-weight: 800;
  display: grid;
  place-items: center;
  margin: 0 auto 24px;
  box-shadow: var(--shadow);
}

.onb-tips {
  text-align: left;
  list-style: none;
  padding: 0;
  margin: 8px 0 28px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.onb-tips li {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 14px;
  line-height: 1.5;
}

/* ============================================
   KID SCREEN — talk button + end-session button
   ============================================ */
#screen-kid {
  position: fixed;
  inset: 0;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 28px;
  padding: 24px;
}
#end-session-quick {
  appearance: none;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.14);
  padding: 12px 22px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  transition: background 0.2s, color 0.2s, transform 0.1s;
}
#end-session-quick:hover {
  background: rgba(255, 255, 255, 0.16);
  color: white;
}
#end-session-quick:active { transform: translateY(1px); }
#end-session-quick:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }
#talk {
  appearance: none;
  border: none;
  cursor: pointer;
  width: min(360px, 78vw);
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  background: var(--green);            /* idle = green ("go") */
  color: white;
  font-family: inherit;
  font-size: clamp(20px, 5.5vw, 28px);
  font-weight: 700;
  letter-spacing: -0.01em;
  box-shadow: var(--shadow);
  user-select: none;
  -webkit-user-select: none;
  transition: transform 0.1s ease, background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 24px;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.18);
}
#talk .label { display: block; line-height: 1.25; }
#talk:hover { transform: scale(1.02); }
#talk:focus-visible { outline: 4px solid white; outline-offset: 6px; }
#talk[disabled] { opacity: 0.55; cursor: not-allowed; }

/* Active session = red ("stop") */
#talk[aria-pressed="true"] {
  background: var(--red);
  color: white;
  animation: pulse-red 1.1s ease-in-out infinite;
}
@keyframes pulse-red {
  0%, 100% { box-shadow: var(--shadow), 0 0 0 0 rgba(239, 68, 68, 0.55); }
  50%      { box-shadow: var(--shadow), 0 0 0 28px rgba(239, 68, 68, 0); }
}

/* In-between states (Why thinking / speaking) override active to yellow */
body.thinking #talk,
body.speaking #talk {
  background: var(--yellow) !important;
  color: var(--ink);
  text-shadow: none;
  animation: none;
}

/* ============================================
   REPORT SCREEN
   ============================================ */
#screen-report {
  background: var(--bg-light);
  color: var(--ink);
  min-height: 100vh;
  padding: 28px 20px 100px;
}
#report-content {
  max-width: 720px;
  margin: 0 auto;
}
.report-eyebrow {
  font-weight: 800;
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
#report-content h1 {
  font-size: clamp(28px, 6vw, 36px);
  margin: 6px 0 4px;
  line-height: 1.15;
  letter-spacing: -0.02em;
}
#report-content .report-meta {
  font-size: 13px;
  color: var(--ink-soft);
  margin: 0 0 24px;
}
#report-content h2 {
  font-size: clamp(18px, 4vw, 22px);
  margin: 32px 0 8px;
  letter-spacing: -0.01em;
}
#report-content h3 {
  font-size: 16px;
  margin: 20px 0 6px;
  color: var(--ink);
}
#report-content h4 {
  font-size: 13px;
  margin: 14px 0 4px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
}
#report-content p { line-height: 1.6; margin: 0 0 12px; font-size: 15px; }
#report-content ul { margin: 0 0 12px 18px; padding: 0; }
#report-content li { line-height: 1.5; margin: 0 0 6px; font-size: 14px; }
.report-card {
  background: white;
  border: 1px solid rgba(42, 26, 74, 0.08);
  border-radius: 16px;
  padding: 18px 20px;
  margin: 12px 0;
  box-shadow: 0 2px 8px rgba(42, 26, 74, 0.04);
}
.report-topic-list {
  list-style: none;
  padding: 0;
  margin: 12px 0 24px;
}
.report-topic-list li {
  background: white;
  border: 1px solid rgba(42, 26, 74, 0.08);
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 6px;
  display: flex;
  gap: 10px;
}
.report-topic-list strong { color: var(--ink); }
.report-divider { border: 0; border-top: 1px solid rgba(42, 26, 74, 0.1); margin: 32px 0; }
.report-transcript {
  background: white;
  border-radius: 12px;
  padding: 16px;
  font-size: 13px;
  line-height: 1.55;
  border: 1px solid rgba(42, 26, 74, 0.08);
}
.report-transcript .row { margin-bottom: 8px; }
.report-transcript .role {
  font-weight: 700;
  margin-right: 6px;
}
.report-transcript .row.kid .role { color: #6a4cff; }
.report-transcript .row.why .role { color: #c79100; }

.report-actions {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 14px 20px;
  background: linear-gradient(to top, var(--bg-light) 70%, rgba(250, 247, 238, 0));
  display: flex;
  gap: 10px;
  justify-content: center;
}
.report-actions .ghost {
  background: rgba(42, 26, 74, 0.08);
  color: var(--ink);
}
.report-actions .ghost:hover { background: rgba(42, 26, 74, 0.16); }

/* ============================================
   PARENT GEAR + PANEL
   ============================================ */
#parent-toggle {
  position: fixed;
  top: 14px;
  right: 14px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.85);
  font-size: 18px;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 0.2s, color 0.2s, transform 0.1s;
  z-index: 30;
  font-family: inherit;
}
#parent-toggle:hover {
  background: rgba(255, 255, 255, 0.22);
  color: white;
  transform: rotate(30deg);
}
#screen-report ~ #parent-toggle,
body[data-screen="report"] #parent-toggle {
  background: rgba(42, 26, 74, 0.08);
  color: var(--ink-soft);
}

#parent-panel {
  position: fixed;
  top: 0; right: 0;
  width: min(420px, 100%);
  height: 100vh;
  background: rgba(20, 10, 40, 0.97);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 40;
  padding: 20px 22px 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  border-left: 1px solid var(--hairline);
}
#parent-panel[hidden] { display: none; }
#parent-panel header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
#parent-panel h2 { margin: 0; font-size: 18px; font-weight: 700; }
#parent-close {
  appearance: none;
  border: none;
  background: rgba(255, 255, 255, 0.08);
  color: white;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
}
#parent-close:hover { background: rgba(255, 255, 255, 0.16); }

.parent-section {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--hairline);
  border-radius: 12px;
  padding: 12px 14px;
}
.parent-section[open] { padding-bottom: 14px; }
.parent-section summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: rgba(255, 255, 255, 0.7);
  list-style: none;
  position: relative;
  padding-right: 18px;
  user-select: none;
}
.parent-section summary::-webkit-details-marker { display: none; }
.parent-section summary::after {
  content: "▾";
  position: absolute;
  right: 0;
  transition: transform 0.2s;
}
.parent-section[open] summary::after { transform: rotate(180deg); }

.hint { font-size: 12px; color: rgba(255, 255, 255, 0.55); margin: 8px 0 0; }

.settings { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.settings label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
}
.settings select {
  font-size: 13px;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  font-family: inherit;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  background: rgba(255, 255, 255, 0.06);
  color: white;
  text-overflow: ellipsis;
}
.settings input[type="range"] { width: 100%; min-width: 0; }

#transcript {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
  max-height: 240px;
  overflow-y: auto;
}
.bubble {
  padding: 7px 10px;
  border-radius: 10px;
  font-size: 12px;
  line-height: 1.4;
  word-wrap: break-word;
  max-width: 92%;
}
.bubble.kid {
  align-self: flex-end;
  background: rgba(255, 255, 255, 0.12);
  color: white;
}
.bubble.why {
  align-self: flex-start;
  background: var(--accent);
  color: var(--ink);
}
.bubble.thinking {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.7);
  font-style: italic;
}
#transcript:empty::after {
  content: "No questions yet.";
  color: rgba(255, 255, 255, 0.4);
  font-size: 12px;
}

.profile-summary {
  font-size: 13px;
  margin: 10px 0;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.85);
}

/* ===== Session report inside parent panel ===== */
.parent-section-title {
  margin: 0 0 8px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.75);
}
.report-stats {
  font-size: 12px;
  margin: 0 0 12px;
  color: rgba(255, 255, 255, 0.65);
}
.report-categories {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 10px 12px;
  margin: 0 0 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.report-categories legend {
  padding: 0 4px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: rgba(255, 255, 255, 0.55);
}
.report-categories label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  cursor: pointer;
  color: rgba(255, 255, 255, 0.85);
}
.report-categories label:hover { color: white; }
.report-categories input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--green);
  cursor: pointer;
}
.report-output {
  margin-top: 14px;
}
.report-output:empty { display: none; }
.report-output h3 {
  font-size: 14px;
  margin: 14px 0 6px;
  color: var(--accent);
  letter-spacing: 0.2px;
  font-weight: 700;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 4px;
}
.report-output h3:first-child { margin-top: 0; }
.report-output p {
  font-size: 13px;
  line-height: 1.55;
  margin: 0 0 10px;
  color: rgba(255, 255, 255, 0.92);
}
.report-output ul {
  margin: 0 0 10px 18px;
  padding: 0;
}
.report-output li {
  font-size: 13px;
  line-height: 1.5;
  margin: 0 0 4px;
  color: rgba(255, 255, 255, 0.92);
}
.report-output strong { color: white; font-weight: 700; }
.report-output em { color: rgba(255, 255, 255, 0.95); font-style: italic; }
.report-output .report-error {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #fecaca;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 12px;
  margin: 8px 0;
}
.report-output .report-meta {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.4);
  font-family: ui-monospace, monospace;
  margin-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  padding-top: 8px;
}

.meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.5);
  margin: 0;
}
.badge {
  background: var(--accent);
  color: var(--ink);
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-size: 10px;
}

@media (prefers-reduced-motion: reduce) {
  #talk, #talk[aria-pressed="true"] { animation: none !important; }
}
