:root {
  color-scheme: light;
  --bg: #f7f4ee;
  --surface: #fffaf1;
  --surface-strong: #ffffff;
  --ink: #24312f;
  --muted: #66736e;
  --line: #d9ddd0;
  --green: #3e8f74;
  --green-dark: #226954;
  --blue: #446fb3;
  --red: #c84f4b;
  --yellow: #f4c95d;
  --shadow: 0 18px 50px rgba(34, 49, 47, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(62, 143, 116, 0.12), transparent 42%),
    linear-gradient(315deg, rgba(244, 201, 93, 0.18), transparent 38%),
    var(--bg);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", sans-serif;
}

button,
input,
a {
  font: inherit;
}

button,
a.button {
  min-height: 48px;
}

.home-shell,
.parent-shell {
  width: min(960px, calc(100% - 32px));
  margin: 0 auto;
}

.home-shell {
  padding: 56px 0;
}

.home-hero {
  padding: 48px 0 28px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--green-dark);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

.home-hero h1 {
  margin-bottom: 12px;
  font-size: clamp(3.2rem, 10vw, 6rem);
  line-height: 0.95;
}

.lead {
  max-width: 620px;
  color: var(--muted);
  font-size: 1.12rem;
  line-height: 1.8;
}

.home-actions,
.control-band,
.message-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.button,
.icon-button,
.chip,
.talk-button {
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 800;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 18px;
  text-decoration: none;
}

.primary {
  color: white;
  background: var(--green);
}

.secondary {
  color: var(--ink);
  background: var(--surface-strong);
  border: 1px solid var(--line);
}

.accent {
  color: white;
  background: var(--blue);
}

.danger {
  color: white;
  background: var(--red);
}

.button:disabled,
.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.prototype-note,
.message-box,
.flow-log {
  margin-top: 24px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.68);
}

.prototype-note h2,
.flow-log h2 {
  margin-bottom: 12px;
  font-size: 1rem;
}

.prototype-note ul {
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
  line-height: 1.9;
}

.kids-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 20px;
}

.kids-stage {
  display: grid;
  width: min(760px, 100%);
  min-height: min(760px, calc(100vh - 40px));
  place-items: center;
  align-content: center;
  gap: 18px;
  padding: clamp(24px, 5vw, 48px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 241, 0.88);
  box-shadow: var(--shadow);
  text-align: center;
}

.soft-screen {
  position: relative;
  width: min(320px, 72vw);
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border: 8px solid #ffffff;
  border-radius: 8px;
  background:
    linear-gradient(180deg, #b8dbe9 0 48%, #dfe9d7 48% 100%);
  box-shadow: inset 0 0 0 1px rgba(36, 49, 47, 0.08);
}

#kidsLocalVideo,
#kidsRemoteVideo,
#parentLocalVideo,
#remoteVideo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#kidsLocalVideo {
  z-index: 1;
}

#kidsRemoteVideo {
  z-index: 4;
  background: #121818;
}

#remoteVideo {
  z-index: 2;
  background: #121818;
}

.soft-screen[data-state="watching"] {
  background:
    linear-gradient(180deg, #a9d4df 0 48%, #d8ecd7 48% 100%);
}

.soft-screen[data-state="calling"] {
  background:
    linear-gradient(180deg, #f1d38c 0 48%, #f6edcf 48% 100%);
}

.soft-screen[data-state="talking"] {
  background:
    linear-gradient(180deg, #8fb7d9 0 48%, #d9e5f4 48% 100%);
}

.soft-screen.has-remote .sun-dot,
.soft-screen.has-remote .room-lines {
  display: none;
}

.sun-dot {
  position: absolute;
  z-index: 2;
  top: 24px;
  right: 28px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--yellow);
}

.room-lines {
  position: absolute;
  z-index: 2;
  inset: auto 24px 28px;
  display: grid;
  gap: 10px;
}

.room-lines span {
  display: block;
  height: 18px;
  border-radius: 999px;
  background: rgba(36, 49, 47, 0.18);
}

.room-lines span:nth-child(2) {
  width: 72%;
}

.room-lines span:nth-child(3) {
  width: 46%;
}

.state-label {
  margin: 0;
  padding: 8px 14px;
  border-radius: 999px;
  color: var(--green-dark);
  background: #e4f2eb;
  font-weight: 900;
}

.connection-label {
  margin: -8px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 800;
}

.kids-stage h1 {
  margin: 0;
  font-size: clamp(2.6rem, 8vw, 5.2rem);
  line-height: 1.05;
}

.kids-message {
  max-width: 520px;
  margin: 0;
  color: var(--muted);
  font-size: clamp(1.1rem, 3vw, 1.45rem);
  line-height: 1.7;
}

.talk-button {
  width: min(420px, 92%);
  min-height: 96px;
  color: white;
  background: var(--green);
  box-shadow: 0 12px 24px rgba(62, 143, 116, 0.28);
  font-size: clamp(2rem, 7vw, 3.6rem);
}

.demo-panel {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.chip {
  min-height: 40px;
  padding: 0 14px;
  color: var(--muted);
  background: #ffffff;
  border: 1px solid var(--line);
}

.chip.active {
  color: white;
  background: var(--green-dark);
}

.parent-shell {
  display: grid;
  gap: 16px;
  padding: 22px 0 36px;
}

.parent-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.parent-header h1 {
  margin: 0;
  font-size: 2rem;
}

.status-pill {
  flex: 0 0 auto;
  padding: 8px 12px;
  border-radius: 999px;
  color: var(--green-dark);
  background: #e4f2eb;
  font-size: 0.9rem;
  font-weight: 800;
}

.video-panel {
  position: relative;
  overflow: hidden;
  min-height: 48vh;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #202a2a;
  box-shadow: var(--shadow);
}

.video-placeholder {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: grid;
  place-items: center;
  padding: 28px;
  color: rgba(255, 255, 255, 0.9);
  text-align: center;
}

.video-panel.has-video .video-placeholder {
  opacity: 0;
  pointer-events: none;
}

.video-grid {
  position: absolute;
  inset: 0;
  opacity: 0.28;
  background:
    linear-gradient(90deg, transparent 0 48%, rgba(255, 255, 255, 0.25) 48% 52%, transparent 52%),
    linear-gradient(0deg, transparent 0 48%, rgba(255, 255, 255, 0.25) 48% 52%, transparent 52%),
    linear-gradient(135deg, #3e8f74, #446fb3);
}

.video-panel[data-state="watching"] .video-grid {
  opacity: 0.55;
}

.video-panel[data-state="talking"] .video-grid {
  opacity: 0.75;
  background:
    linear-gradient(90deg, transparent 0 48%, rgba(255, 255, 255, 0.2) 48% 52%, transparent 52%),
    linear-gradient(0deg, transparent 0 48%, rgba(255, 255, 255, 0.2) 48% 52%, transparent 52%),
    linear-gradient(135deg, #446fb3, #3e8f74 52%, #f4c95d);
}

.video-placeholder p {
  position: relative;
  max-width: 360px;
  margin: 0;
  font-weight: 800;
  line-height: 1.7;
}

.self-preview {
  position: absolute;
  right: 16px;
  bottom: 16px;
  display: grid;
  width: 118px;
  aspect-ratio: 3 / 4;
  place-items: center;
  border: 3px solid white;
  border-radius: 8px;
  color: white;
  background: linear-gradient(160deg, #25384f, #446fb3);
  font-weight: 800;
  overflow: hidden;
}

.self-preview span {
  position: relative;
  z-index: 1;
}

#parentLocalVideo {
  z-index: 0;
}

.self-preview.has-video span {
  padding: 4px 7px;
  border-radius: 999px;
  background: rgba(18, 24, 24, 0.55);
}

.control-band {
  align-items: center;
}

.icon-button {
  min-width: 88px;
  min-height: 48px;
  padding: 0 14px;
  color: var(--ink);
  background: var(--surface-strong);
  border: 1px solid var(--line);
}

.icon-button[aria-pressed="true"] {
  color: white;
  background: var(--ink);
}

.message-box label {
  display: block;
  margin-bottom: 10px;
  color: var(--muted);
  font-weight: 800;
}

.message-row input {
  flex: 1 1 220px;
  min-height: 48px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  background: white;
}

.sent-message {
  margin: 12px 0 0;
  color: var(--muted);
}

.flow-log ol {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.flow-log li {
  min-height: 44px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: white;
  font-weight: 800;
}

.flow-log li.active {
  color: white;
  background: var(--green-dark);
}

@media (max-width: 640px) {
  .home-shell,
  .parent-shell {
    width: min(100% - 24px, 960px);
  }

  .parent-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .control-band .button,
  .control-band .icon-button,
  .message-row .button {
    width: 100%;
  }

  .video-panel {
    min-height: 42vh;
  }

  .flow-log ol {
    grid-template-columns: 1fr;
  }
}
