:root{
  color-scheme: light;
  --bg:#f6efe7;
  --panel:#fffaf3;
  --ink:#243042;
  --muted:#6b7280;
  --accent:#6d5dfc;
  --accent-2:#ffb86b;
  --assistant:#ffffff;
  --user:#dff7ea;
  --ring:rgba(109,93,252,.28);
  --shadow:0 18px 50px rgba(36,48,66,.14);
}
*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  font-family:Inter,ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;
  background:
    radial-gradient(circle at top left, rgba(255,184,107,.35), transparent 32rem),
    radial-gradient(circle at bottom right, rgba(109,93,252,.20), transparent 30rem),
    var(--bg);
  color:var(--ink);
}
.child-shell{
  height:100vh;
  height:100dvh;
  display:grid;
  grid-template-rows:auto minmax(0,1fr) auto auto auto;
  gap:1rem;
  width:min(980px,100%);
  margin:0 auto;
  padding:clamp(1rem,3vw,2rem);
}
.child-header{
  display:flex;
  align-items:center;
  gap:1rem;
  background:rgba(255,250,243,.86);
  border:1px solid rgba(36,48,66,.08);
  border-radius:28px;
  box-shadow:var(--shadow);
  padding:1rem 1.25rem;
}
.child-avatar{
  width:4rem;
  height:4rem;
  border-radius:1.4rem;
  display:grid;
  place-items:center;
  color:#fff;
  background:linear-gradient(135deg,var(--accent),#9a8cff);
  font-size:2rem;
  box-shadow:0 10px 24px rgba(109,93,252,.25);
}
.child-eyebrow{margin:0 0 .15rem;color:var(--muted);font-weight:700;letter-spacing:.04em;text-transform:uppercase;font-size:.75rem}
h1{margin:0;font-size:clamp(1.4rem,4vw,2.2rem)}
.child-messages{
  min-height:0;
  overflow:auto;
  overscroll-behavior:contain;
  -webkit-overflow-scrolling:touch;
  display:flex;
  flex-direction:column;
  gap:.85rem;
  padding:.25rem;
  scroll-behavior:smooth;
}
.child-messages[hidden]{display:none}
.child-login{
  display:grid;
  place-items:center;
  min-height:0;
  overflow:auto;
}
.child-login[hidden]{display:none}
.login-card{
  width:min(28rem,100%);
  background:rgba(255,250,243,.94);
  border:1px solid rgba(36,48,66,.10);
  border-radius:28px;
  box-shadow:var(--shadow);
  padding:1.4rem;
  text-align:center;
}
.login-card h2{margin:.2rem 0 .4rem;font-size:1.5rem}
.login-card p{margin:.3rem 0 1rem;color:var(--muted)}
#loginForm{display:grid;gap:.7rem}
#passwordInput{
  width:100%;
  border:0;
  outline:0;
  background:#fff;
  border-radius:20px;
  padding:.9rem 1rem;
  font:inherit;
  text-align:center;
  box-shadow:inset 0 0 0 1px rgba(36,48,66,.10);
}
#passwordInput:focus{box-shadow:inset 0 0 0 3px var(--ring)}
.bubble{
  max-width:min(42rem,92%);
  border-radius:24px;
  padding:1rem 1.1rem;
  box-shadow:0 10px 24px rgba(36,48,66,.08);
  line-height:1.55;
  overflow-wrap:anywhere;
}
.bubble.user{align-self:flex-end;background:var(--user);border-bottom-right-radius:8px}
.bubble.assistant{align-self:flex-start;background:var(--assistant);border-bottom-left-radius:8px}
.bubble.system{align-self:center;background:#fff3cd;color:#594100;max-width:90%}
.older-messages-wrap{align-self:center;position:sticky;top:.25rem;z-index:3;margin:.15rem 0 .35rem}
.older-messages-btn{border:0;border-radius:999px;background:rgba(255,250,243,.96);color:var(--accent);font:inherit;font-weight:900;padding:.55rem .9rem;box-shadow:0 8px 22px rgba(36,48,66,.12), inset 0 0 0 1px rgba(109,93,252,.16);cursor:pointer}
.older-messages-btn:hover,.older-messages-btn:focus{background:#eef2ff;outline:0}
.bubble-role{
  font-size:.75rem;
  font-weight:800;
  color:var(--muted);
  margin-bottom:.35rem;
  text-transform:uppercase;
  letter-spacing:.04em;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:.75rem;
}
.copy-bubble{
  border:0;
  background:rgba(36,48,66,.07);
  color:var(--muted);
  border-radius:999px;
  width:1.75rem;
  height:1.75rem;
  cursor:pointer;
  font-weight:900;
}
.copy-bubble:hover,.copy-bubble:focus{background:rgba(109,93,252,.14);color:var(--accent);outline:0}
.bubble-actions{display:inline-flex;gap:.35rem;align-items:center}
.speak-bubble{font-size:.8rem}
.speak-bubble.speaking{background:rgba(109,93,252,.2);color:var(--accent);animation:speak-pulse 1.1s ease-in-out infinite}
@keyframes speak-pulse{0%,100%{box-shadow:0 0 0 0 rgba(109,93,252,.25)}50%{box-shadow:0 0 0 .3rem rgba(109,93,252,.10)}}
.bubble-content :first-child{margin-top:0}.bubble-content :last-child{margin-bottom:0}
.bubble-content pre{white-space:pre-wrap;background:#172033;color:#f8fafc;padding:.8rem;border-radius:14px;overflow:auto}
.bubble-content code{background:rgba(36,48,66,.08);padding:.1rem .3rem;border-radius:.35rem}
.bubble-content pre code{background:transparent;padding:0}
.bubble-content img,.bubble-content video{max-width:100%;border-radius:18px;display:block;margin:.6rem 0}
.bubble-content audio{width:100%;margin:.6rem 0}
.child-attachments{
  display:flex;
  flex-wrap:wrap;
  gap:.5rem;
}
.attachment-chip{
  border:1px solid rgba(36,48,66,.10);
  border-radius:999px;
  padding:.45rem .7rem;
  background:#fff;
  display:inline-flex;
  gap:.4rem;
  align-items:center;
  font-weight:700;
}
.attachment-chip button{border:0;background:transparent;font-size:1rem;cursor:pointer;color:var(--muted)}
.child-composer{
  display:grid;
  grid-template-columns:auto auto 1fr auto;
  gap:.65rem;
  align-items:end;
  background:rgba(255,250,243,.92);
  border:1px solid rgba(36,48,66,.10);
  border-radius:28px;
  box-shadow:var(--shadow);
  padding:.75rem;
}
.child-composer[hidden]{display:none}
textarea{
  width:100%;
  min-height:3.1rem;
  max-height:12rem;
  resize:none;
  border:0;
  outline:0;
  background:#fff;
  border-radius:20px;
  padding:.9rem 1rem;
  font:inherit;
  color:var(--ink);
  box-shadow:inset 0 0 0 1px rgba(36,48,66,.10);
}
textarea:focus{box-shadow:inset 0 0 0 3px var(--ring)}
.round-btn,.send-btn{
  border:0;
  min-height:3.1rem;
  border-radius:20px;
  font:inherit;
  font-weight:900;
  cursor:pointer;
}
.round-btn{width:3.1rem;background:#fff;color:var(--accent);font-size:1.5rem;box-shadow:inset 0 0 0 1px rgba(36,48,66,.10)}
.record-btn{font-size:1.2rem}
.record-btn.recording{background:#fee2e2;color:#b91c1c;box-shadow:inset 0 0 0 2px rgba(185,28,28,.22),0 0 0 .35rem rgba(248,113,113,.14)}
.send-btn{padding:0 1.25rem;background:linear-gradient(135deg,var(--accent),#8b7dff);color:white;box-shadow:0 10px 20px rgba(109,93,252,.25)}
.send-btn:disabled,.round-btn:disabled{opacity:.55;cursor:not-allowed}
.child-status{min-height:1.25rem;margin:0;color:var(--muted);font-size:.92rem;text-align:center}
a{color:#4f46e5;font-weight:700}
.child-ui-card{
  position:relative;
  background:linear-gradient(180deg,#ffffff,#fffaf3);
  border:1px solid rgba(36,48,66,.10);
  border-radius:22px;
  padding:1rem;
  margin:.75rem 0 0;
  box-shadow:0 12px 26px rgba(36,48,66,.10);
  overflow:hidden;
}
.image-gen-bubble{min-width:min(24rem,92%)}
.image-gen-card{
  display:grid;
  grid-template-columns:auto 1fr;
  align-items:center;
  gap:1rem;
  background:
    radial-gradient(circle at 16% 20%, rgba(255,184,107,.34), transparent 9rem),
    radial-gradient(circle at 82% 70%, rgba(109,93,252,.18), transparent 8rem),
    linear-gradient(180deg,#ffffff,#fff7ed);
}
.image-gen-stage{position:relative;width:6rem;display:grid;place-items:center;isolation:isolate}
.image-gen-photo{
  width:5.4rem;height:4rem;border-radius:14px;position:relative;overflow:hidden;
  background:linear-gradient(180deg,#dbeafe 0 62%,#ede9fe 62% 100%);
  box-shadow:0 14px 28px rgba(36,48,66,.16), inset 0 0 0 3px #fff, inset 0 0 0 4px rgba(109,93,252,.18);
  animation:image-photo-float 2s ease-in-out infinite;
}
.image-gen-sun{position:absolute;top:.5rem;right:.8rem;width:1rem;height:1rem;border-radius:50%;background:#ffb86b;box-shadow:0 0 0 .3rem rgba(255,184,107,.35);animation:image-sun-glow 1.8s ease-in-out infinite}
.image-gen-hill{position:absolute;bottom:-.2rem;width:3.4rem;height:2.2rem;border-radius:50% 50% 0 0/100% 100% 0 0}
.image-gen-hill.back{left:-.7rem;background:#a5b4fc}
.image-gen-hill.front{right:-.9rem;height:1.7rem;background:#6d5dfc}
.image-gen-shimmer{content:'';position:absolute;inset:0;background:linear-gradient(115deg,transparent 0 30%,rgba(255,255,255,.65) 48%,transparent 62%);transform:translateX(-120%);animation:image-shimmer 1.5s ease-in-out infinite}
.image-gen-stage i{position:absolute;width:.55rem;height:.55rem;border-radius:999px;background:#ffb86b;box-shadow:0 0 0 .25rem rgba(255,184,107,.16);animation:image-spark 1.5s ease-in-out infinite}
.image-gen-stage i:nth-of-type(1){left:-.1rem;top:.35rem}.image-gen-stage i:nth-of-type(2){right:-.1rem;top:.1rem;animation-delay:.25s;background:#6d5dfc}.image-gen-stage i:nth-of-type(3){right:-.05rem;bottom:.35rem;animation-delay:.5s;background:#5eead4}
.image-gen-copy{min-width:0}
.image-gen-copy .child-ui-subtitle{margin-bottom:.45rem}
.image-gen-dots{display:flex;gap:.28rem;align-items:center}.image-gen-dots b{width:.45rem;height:.45rem;border-radius:50%;background:var(--accent);animation:image-dot 1s ease-in-out infinite}.image-gen-dots b:nth-child(2){animation-delay:.16s}.image-gen-dots b:nth-child(3){animation-delay:.32s}
@keyframes image-photo-float{0%,100%{transform:translateY(0) rotate(-1.5deg)}50%{transform:translateY(-5px) rotate(1.5deg)}}
@keyframes image-sun-glow{0%,100%{box-shadow:0 0 0 .3rem rgba(255,184,107,.35)}50%{box-shadow:0 0 0 .55rem rgba(255,184,107,.18)}}
@keyframes image-shimmer{0%{transform:translateX(-120%)}100%{transform:translateX(120%)}}
@keyframes image-spark{0%,100%{transform:scale(.72);opacity:.5}50%{transform:scale(1.18);opacity:1}}
@keyframes image-dot{0%,100%{transform:translateY(0);opacity:.45}50%{transform:translateY(-.32rem);opacity:1}}
.child-ui-title{font-weight:900;font-size:1.08rem;margin-bottom:.25rem;color:var(--ink)}
.child-ui-subtitle{color:var(--muted);font-size:.95rem;margin-bottom:.75rem}
.child-ui-buttons{display:flex;flex-wrap:wrap;gap:.5rem;margin-top:.6rem}
.child-ui-buttons.vertical{flex-direction:column;align-items:stretch}
.child-ui-button{
  border:0;
  border-radius:999px;
  background:#eef2ff;
  color:#4338ca;
  padding:.65rem .9rem;
  font:inherit;
  font-weight:900;
  cursor:pointer;
  box-shadow:inset 0 0 0 1px rgba(67,56,202,.12);
}
.child-ui-button:hover,.child-ui-button:focus{background:#ddd6fe;outline:0}
.child-ui-button.primary,.child-ui-button.selected{background:linear-gradient(135deg,var(--accent),#8b7dff);color:#fff}
.child-ui-result{min-height:1.2rem;margin-top:.6rem;font-weight:800;color:var(--muted)}
.child-ui-result.ok{color:#15803d}.child-ui-result.no{color:#b45309}
.child-ui-time{font-size:clamp(2.2rem,8vw,4rem);font-weight:950;text-align:center;letter-spacing:.03em;margin:.5rem 0;color:#4338ca}
.child-ui-progress{height:.9rem;background:#eef2ff;border-radius:999px;overflow:hidden;box-shadow:inset 0 0 0 1px rgba(36,48,66,.08)}
.child-ui-progress-fill{height:100%;width:0;background:linear-gradient(90deg,var(--accent),var(--accent-2));transition:width .3s ease}
.child-ui-checklist{display:grid;gap:.55rem;margin-top:.75rem}
.child-ui-checklist label{display:flex;align-items:center;gap:.55rem;background:#fff;border-radius:16px;padding:.65rem .75rem;box-shadow:inset 0 0 0 1px rgba(36,48,66,.08)}
.child-ui-checklist input{width:1.25rem;height:1.25rem;accent-color:var(--accent)}
.child-ui-group{margin-top:.75rem}.child-ui-label{font-weight:900;color:var(--muted);font-size:.85rem;text-transform:uppercase;letter-spacing:.04em}
.confetti-box{pointer-events:none;position:absolute;inset:0;overflow:hidden;z-index:2}
.confetti-box i{position:absolute;top:-12px;width:9px;height:14px;border-radius:3px;animation:confetti-fall 1.45s ease-in forwards;transform:rotate(20deg)}
@keyframes confetti-fall{0%{transform:translateY(-20px) rotate(0);opacity:1}100%{transform:translateY(220px) rotate(560deg);opacity:0}}
@media (max-width:640px){
  .child-shell{padding:.6rem;gap:.6rem}
  .child-header{border-radius:22px;padding:.7rem .9rem;gap:.75rem}
  .child-avatar{width:2.8rem;height:2.8rem;border-radius:1rem;font-size:1.5rem}
  .child-eyebrow{font-size:.68rem}
  h1{font-size:clamp(1.15rem,5vw,1.5rem)}
  .bubble{max-width:96%;border-radius:20px;padding:.85rem .9rem}
  .image-gen-bubble{min-width:0;width:96%}
  .image-gen-card{grid-template-columns:auto minmax(0,1fr);gap:.75rem;padding:.85rem}
  .image-gen-stage{width:5rem}
  .image-gen-photo{width:4.6rem;height:3.4rem}
  .child-composer{
    grid-template-columns:auto auto minmax(0,1fr) auto;
    grid-template-areas:"attach record input send";
    padding:.5rem;
    gap:.45rem;
    border-radius:22px;
  }
  #attachBtn{grid-area:attach}#recordBtn{grid-area:record}#messageInput{grid-area:input}.send-btn{grid-area:send}
  .round-btn{width:2.7rem;min-height:2.9rem;font-size:1.25rem}
  .record-btn{font-size:1.1rem}
  .send-btn{padding:0 .9rem;min-height:2.9rem}
  textarea{min-height:2.9rem;padding:.75rem .85rem}
  .child-ui-time{font-size:clamp(1.8rem,10vw,2.6rem)}
  .child-ui-buttons .child-ui-button{padding:.6rem .8rem}
}
