:root {
  color-scheme: light;
  font-family: ui-rounded, "Arial Rounded MT Bold", "Trebuchet MS", system-ui, sans-serif;
  color: #222ca7;
  background: #fff8ef;
  --cream: #fff8ef;
  --paper: #fffdf9;
  --ink: #222ca7;
  --blue: #55d9ff;
  --mid-blue: #0099ff;
  --purple: #9e29eb;
  --plum: #4d0e35;
  --pink: #ff5d69;
  --orange: #ff8c00;
  --yellow: #ffcd00;
  --line: rgba(34, 44, 167, 0.14);
  --shadow: 0 26px 70px rgba(34, 44, 167, 0.12);
  --energy: 0;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-width: 320px; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 6% 14%, rgba(85, 217, 255, 0.26) 0 7rem, transparent 7.1rem),
    radial-gradient(circle at 96% 88%, rgba(255, 205, 0, 0.22) 0 9rem, transparent 9.1rem),
    var(--cream);
}

body::before,
body::after {
  position: fixed;
  z-index: -1;
  content: "";
  pointer-events: none;
}

body::before {
  top: 17%;
  right: -6rem;
  width: 18rem;
  height: 3px;
  border-radius: 999px;
  background: var(--pink);
  box-shadow: 0 18px 0 var(--orange), 0 36px 0 var(--yellow);
  rotate: -8deg;
}

body::after {
  bottom: 10%;
  left: -5rem;
  width: 15rem;
  height: 3px;
  border-radius: 999px;
  background: var(--mid-blue);
  box-shadow: 0 18px 0 var(--blue);
  rotate: 9deg;
}

button,
input { font: inherit; }
button,
a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }

button:focus-visible,
a:focus-visible,
input:focus-visible,
[tabindex]:focus-visible {
  outline: 4px solid rgba(0, 153, 255, 0.35);
  outline-offset: 3px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app-shell {
  width: 100%;
  min-height: 100vh;
  padding: clamp(16px, 2.4vw, 38px);
}

.auth-view { width: min(100%, 1080px); min-height: calc(100vh - clamp(32px, 4.8vw, 76px)); display: grid; place-items: center; margin: 0 auto; padding-top: 62px; }
.auth-brand { position: absolute; top: clamp(18px, 3vw, 38px); left: clamp(20px, 4vw, 54px); display: inline-flex; align-items: center; gap: 10px; color: var(--ink); font-size: 20px; font-weight: 950; letter-spacing: -0.035em; }
.auth-card { width: 100%; min-height: min(660px, calc(100vh - 120px)); display: grid; grid-template-columns: minmax(340px, 0.9fr) minmax(430px, 1.1fr); overflow: hidden; border: 1px solid var(--line); border-radius: clamp(30px, 4vw, 52px); background: var(--paper); box-shadow: var(--shadow); }
.auth-art { position: relative; min-height: 540px; overflow: hidden; isolation: isolate; background: radial-gradient(circle at 50% 32%, rgba(255, 205, 0, 0.94) 0 19%, transparent 19.3%), linear-gradient(155deg, #d928f1, #9e29eb 44%, var(--plum)); }
.auth-art::after { position: absolute; z-index: -1; inset: 46% -24% -25%; border-radius: 50% 50% 0 0; background: rgba(50, 3, 38, 0.7); content: ""; }
.auth-art img { position: absolute; z-index: 3; right: 50%; bottom: -4%; height: 88%; transform: translateX(50%); filter: drop-shadow(0 28px 18px rgba(31, 5, 26, 0.3)); }
.auth-orbit { position: absolute; z-index: 1; border: 2px solid rgba(255, 255, 255, 0.26); border-radius: 50%; }
.auth-orbit-one { top: 13%; right: 8%; width: 54%; aspect-ratio: 1; }
.auth-orbit-two { right: 1%; bottom: 7%; width: 78%; aspect-ratio: 1; }
.auth-content { min-height: 0; display: grid; place-items: center; padding: clamp(30px, 5vw, 68px); }
.auth-content > div { width: min(100%, 440px); }
.auth-loading { display: flex; align-items: center; justify-content: center; gap: 11px; color: #666aa0; font: 800 14px/1.4 system-ui, sans-serif; }
.auth-loading-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--mid-blue); animation: pulse 800ms infinite alternate; }
.auth-content .eyebrow { color: var(--purple); }
.auth-content h1 { margin: 0; color: var(--ink); font-size: clamp(42px, 5vw, 66px); line-height: 0.95; letter-spacing: -0.06em; }
.auth-intro { margin: 18px 0 0; color: #666a9d; font: 14px/1.55 system-ui, sans-serif; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-top: 28px; padding: 5px; border: 1px solid var(--line); border-radius: 17px; background: #f6f4fb; }
.auth-tabs button { min-height: 44px; border: 0; border-radius: 12px; background: transparent; color: #7377a8; cursor: pointer; font: 800 13px/1 system-ui, sans-serif; }
.auth-tabs button[aria-selected="true"] { background: white; color: var(--ink); box-shadow: 0 5px 14px rgba(34, 44, 167, 0.1); }
.auth-form { display: grid; gap: 8px; margin-top: 22px; }
.auth-form label { margin-top: 8px; color: var(--ink); font: 800 12px/1.3 system-ui, sans-serif; }
.auth-form input { width: 100%; min-height: 52px; padding: 0 15px; border: 2px solid rgba(34, 44, 167, 0.14); border-radius: 15px; background: white; color: var(--ink); font: 15px system-ui, sans-serif; }
.auth-form input:focus { border-color: var(--mid-blue); }
.auth-confirm-row { display: grid; gap: 8px; }
.auth-submit { min-height: 54px; margin-top: 15px; border: 0; border-radius: 17px; background: linear-gradient(135deg, var(--mid-blue), var(--blue)); color: var(--ink); box-shadow: 0 13px 27px rgba(0, 153, 255, 0.22); cursor: pointer; font-weight: 950; }
.auth-submit:disabled { cursor: wait; opacity: 0.56; }
.auth-message { margin: 10px 0 0; padding: 11px 13px; border-radius: 12px; background: #e9fbff; color: #146685; font: 12px/1.45 system-ui, sans-serif; }
.auth-message[data-state="error"] { background: #fff0f1; color: #9a2934; }
.auth-help { margin: 14px 0 0; color: #8589ad; font: 11px/1.5 system-ui, sans-serif; }
.account-email { max-width: 180px; overflow: hidden; color: #7478aa; font: 750 11px/1.2 system-ui, sans-serif; text-overflow: ellipsis; white-space: nowrap; }
.sign-out-button { min-height: 40px; padding: 0 13px; border: 1px solid var(--line); border-radius: 999px; background: rgba(255, 255, 255, 0.74); color: var(--ink); cursor: pointer; font: 800 11px/1 system-ui, sans-serif; }

.library-view,
.player-view {
  width: min(100%, 1440px);
  margin: 0 auto;
}

body[data-player-active="true"] {
  height: 100dvh;
  overflow: hidden;
}

body[data-player-active="true"] .app-shell {
  height: 100dvh;
  min-height: 0;
  padding: clamp(12px, 1.5vw, 22px);
}

body[data-player-active="true"] .player-view {
  height: 100%;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

body[data-player-active="true"] .player-nav { margin-bottom: 12px; }
body[data-player-active="true"] .call-card { height: 100%; min-height: 0; }

.brand-header,
.player-nav {
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.brand-header-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; }

.brand-lockup {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-size: 20px;
  font-weight: 900;
  letter-spacing: -0.03em;
  text-decoration: none;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 12px 12px 12px 4px;
  background: linear-gradient(145deg, var(--blue), var(--mid-blue));
  color: white;
  box-shadow: 0 8px 18px rgba(0, 153, 255, 0.22);
  font-size: 26px;
  font-weight: 950;
  line-height: 1;
}

.brand-mode {
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.62);
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
}

.library-grid {
  display: grid;
  grid-template-columns: minmax(360px, 0.82fr) minmax(520px, 1.18fr);
  gap: clamp(18px, 2.5vw, 38px);
  align-items: stretch;
}

.character-portal,
.story-library {
  min-height: min(720px, calc(100vh - 130px));
  border-radius: clamp(28px, 3vw, 46px);
}

.character-portal {
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  isolation: isolate;
  background: linear-gradient(155deg, #d928f1 0%, #d81ab9 31%, var(--plum) 78%);
  color: white;
  box-shadow: 0 28px 80px rgba(77, 14, 53, 0.24);
}

.character-portal::before {
  position: absolute;
  z-index: -1;
  inset: 23% -18% -18%;
  border-radius: 50% 50% 0 0;
  background: rgba(77, 14, 53, 0.66);
  content: "";
}

.portal-copy {
  position: relative;
  z-index: 3;
  max-width: 430px;
  padding: clamp(28px, 4vw, 56px);
}

.eyebrow {
  margin: 0 0 8px;
  color: inherit;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.portal-copy .eyebrow { color: var(--yellow); }
.portal-copy h1 {
  margin: 0;
  font-size: clamp(48px, 5.5vw, 82px);
  line-height: 0.92;
  letter-spacing: -0.065em;
}

.portal-copy p:last-child {
  max-width: 320px;
  margin: 18px 0 0;
  color: rgba(255, 255, 255, 0.88);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: clamp(16px, 1.4vw, 20px);
  font-weight: 650;
  line-height: 1.45;
}

.character-stage { position: relative; flex: 1; min-height: 420px; }
.character-stage img {
  position: absolute;
  z-index: 4;
  bottom: -3.5%;
  left: 50%;
  height: min(74vh, 610px);
  max-height: 87%;
  transform: translateX(-50%);
  filter: drop-shadow(0 26px 18px rgba(31, 5, 26, 0.28));
}

.stage-sun {
  position: absolute;
  top: 8%;
  left: 50%;
  width: min(65%, 300px);
  aspect-ratio: 1;
  transform: translateX(-50%);
  border-radius: 50%;
  background: var(--yellow);
  box-shadow: 0 0 0 14px rgba(255, 205, 0, 0.09);
}

.stage-column {
  position: absolute;
  bottom: 8%;
  width: 11%;
  height: 48%;
  border-radius: 999px 999px 0 0;
  background: rgba(255, 255, 255, 0.14);
}

.stage-column::before,
.stage-column::after {
  position: absolute;
  left: -28%;
  width: 156%;
  height: 8%;
  border-radius: 999px;
  background: inherit;
  content: "";
}
.stage-column::before { top: 4%; }
.stage-column::after { bottom: 0; }
.column-one { left: 5%; }
.column-two { right: 5%; height: 35%; }

.story-library {
  display: flex;
  flex-direction: column;
  padding: clamp(26px, 4vw, 54px);
  border: 1px solid rgba(34, 44, 167, 0.11);
  background: rgba(255, 253, 249, 0.9);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.library-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 22px;
  margin-bottom: 24px;
}
.library-heading .eyebrow { color: var(--purple); }
.library-heading h2,
.start-heading h2 {
  margin: 0;
  color: var(--ink);
  font-size: clamp(32px, 4vw, 54px);
  line-height: 0.98;
  letter-spacing: -0.055em;
}

.carousel-controls { display: flex; gap: 9px; }
.carousel-controls button,
.back-button,
.download-button,
.details-button {
  min-width: 48px;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: white;
  color: var(--ink);
  cursor: pointer;
  font-weight: 900;
  transition: transform 160ms ease, background 160ms ease;
}
.carousel-controls button:hover,
.back-button:hover,
.download-button:hover:not(:disabled),
.details-button:hover { transform: translateY(-2px); background: #eefbff; }
.carousel-controls button:disabled { cursor: not-allowed; opacity: 0.4; transform: none; }
.download-button:disabled { cursor: not-allowed; opacity: 0.4; transform: none; }

.story-carousel {
  display: grid;
  grid-auto-columns: minmax(min(100%, 360px), 62%);
  grid-auto-flow: column;
  gap: 16px;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  padding: 4px 4px 16px;
  scroll-behavior: smooth;
  scroll-snap-type: x mandatory;
  scrollbar-width: thin;
  scrollbar-color: rgba(34, 44, 167, 0.22) transparent;
}
.story-carousel[data-story-count="1"] { grid-auto-columns: min(100%, 520px); }

.story-card {
  min-height: 350px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 28px;
  scroll-snap-align: start;
  background: white;
  color: var(--ink);
  box-shadow: 0 15px 34px rgba(34, 44, 167, 0.09);
  cursor: pointer;
  text-align: left;
  transition: border-color 170ms ease, transform 170ms ease, box-shadow 170ms ease;
}
.story-card:hover { transform: translateY(-4px); }
.story-card[aria-pressed="true"] { border-color: var(--purple); box-shadow: 0 18px 44px rgba(158, 41, 235, 0.19); }
.story-card:disabled { cursor: not-allowed; opacity: 0.68; }

.story-cover {
  position: relative;
  min-height: 190px;
  overflow: hidden;
  background: linear-gradient(145deg, var(--purple), var(--plum));
}
.story-cover img {
  width: 100%;
  height: 100%;
  min-height: 190px;
  display: block;
  object-fit: cover;
  transition: transform 420ms ease;
}
.story-card:hover .story-cover img { transform: scale(1.035); }
.story-cover::after {
  position: absolute;
  inset: auto 0 0;
  height: 58%;
  background: linear-gradient(transparent, rgba(18, 14, 42, 0.55));
  content: "";
}

.story-badge {
  position: absolute;
  z-index: 1;
  top: 14px;
  left: 14px;
  padding: 7px 10px;
  border-radius: 999px;
  background: var(--yellow);
  color: var(--ink);
  font-size: 11px;
  font-weight: 950;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.story-card-copy { padding: 20px 21px 22px; }
.story-meta { margin: 0 0 9px; color: var(--purple); font-size: 11px; font-weight: 900; letter-spacing: 0.08em; text-transform: uppercase; }
.story-card h3 { margin: 0; color: var(--ink); font-size: 25px; line-height: 1.04; letter-spacing: -0.035em; }
.story-summary {
  display: -webkit-box;
  margin: 11px 0 0;
  overflow: hidden;
  color: #5d6198;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  font-weight: 560;
  line-height: 1.45;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.story-footer { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-top: 16px; }
.story-position { margin: 0; color: #6c70a4; font-family: system-ui, sans-serif; font-size: 13px; font-weight: 700; }
.primary-action,
.resume-audio {
  min-height: 54px;
  padding: 0 24px;
  border: 0;
  border-radius: 18px;
  background: linear-gradient(135deg, var(--mid-blue), var(--blue));
  color: var(--ink);
  box-shadow: 0 14px 30px rgba(0, 153, 255, 0.2);
  cursor: pointer;
  font-weight: 950;
  transition: transform 160ms ease, box-shadow 160ms ease;
}
.primary-action:hover,
.resume-audio:hover { transform: translateY(-2px); box-shadow: 0 18px 34px rgba(0, 153, 255, 0.28); }
.primary-action:disabled { cursor: not-allowed; opacity: 0.48; transform: none; }

.more-stories-card { display: flex; align-items: center; gap: 14px; margin-top: auto; padding-top: 24px; color: #65699b; }
.more-stories-card > span { width: 42px; height: 42px; flex: none; display: grid; place-items: center; border-radius: 14px; background: #f1e5ff; color: var(--purple); font-size: 24px; }
.more-stories-card strong { color: var(--ink); font-size: 14px; }
.more-stories-card p { margin: 3px 0 0; font: 13px/1.4 system-ui, sans-serif; }

.player-nav { margin-bottom: 16px; }
.player-nav-actions { display: flex; align-items: center; justify-content: flex-end; gap: 9px; }
.brand-lockup.compact { font-size: 16px; }
.brand-lockup.compact .brand-mark { width: 32px; height: 32px; border-radius: 10px 10px 10px 3px; font-size: 22px; }
.back-button,
.download-button,
.details-button { padding: 0 17px; font-size: 13px; }
.back-button { display: inline-flex; align-items: center; gap: 8px; }

.call-card {
  min-height: min(780px, calc(100vh - 120px));
  display: grid;
  grid-template-columns: minmax(390px, 0.92fr) minmax(460px, 1.08fr);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: clamp(28px, 3vw, 46px);
  background: var(--paper);
  box-shadow: var(--shadow);
}

.visual-panel {
  position: relative;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow: hidden;
  isolation: isolate;
  padding: 30px;
  background: linear-gradient(155deg, #d928f1 0%, #bc24d9 24%, var(--plum) 78%);
  color: white;
}
.visual-panel::before {
  position: absolute;
  z-index: -1;
  right: -22%;
  bottom: -8%;
  width: 115%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: rgba(46, 7, 35, 0.27);
  content: "";
}

.topbar { position: relative; z-index: 4; display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.topbar .eyebrow { color: var(--yellow); }
.call-time { margin: 0; color: rgba(255, 255, 255, 0.74); font: 13px/1.4 system-ui, sans-serif; }
.live-dot {
  width: 14px;
  height: 14px;
  flex: none;
  margin: 8px;
  border: 3px solid rgba(255, 255, 255, 0.72);
  border-radius: 50%;
  background: var(--yellow);
  box-shadow: 0 0 0 calc(7px + (var(--energy) * 12px)) rgba(255, 205, 0, 0.17);
}
.scene-toggle { display: none; }

.scene-artwork { position: relative; z-index: 1; min-height: 260px; flex: 1; display: grid; grid-template-rows: minmax(0, 1fr) auto; margin: 0; overflow: hidden; border: 1px solid rgba(255, 255, 255, 0.16); border-radius: 24px; background: var(--plum); box-shadow: 0 18px 40px rgba(31, 5, 26, 0.24); }
.scene-artwork::after { position: absolute; inset: 0; display: grid; place-items: center; background: var(--plum); color: rgba(255, 255, 255, 0.72); content: "Scene artwork unavailable"; font-size: 13px; opacity: 0; pointer-events: none; }
.scene-artwork[data-state="error"]::after { opacity: 1; }
.scene-artwork img { width: 100%; height: 100%; min-height: 0; display: block; object-fit: cover; opacity: 0.22; filter: saturate(0.82); transition: opacity 420ms ease, filter 420ms ease, transform 10s linear; }
.scene-artwork[data-state="loaded"] img { opacity: 1; filter: saturate(0.94); transform: scale(1.025); }
.scene-artwork[data-state="error"] img { opacity: 0; }
.scene-artwork figcaption { position: relative; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 14px; min-height: 48px; padding: 10px 13px; background: rgba(31, 4, 24, 0.92); color: white; font: 12px/1.35 system-ui, sans-serif; }
.scene-artwork figcaption > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scene-frame { flex: none; padding: 7px 9px; border: 1px solid rgba(255, 255, 255, 0.3); border-radius: 999px; background: rgba(34, 44, 167, 0.72); font-size: 9px; font-weight: 850; letter-spacing: 0.04em; text-transform: uppercase; }
.scene-artwork[data-frame="counterfactual"] .scene-frame { background: rgba(158, 41, 235, 0.78); }
.scene-artwork[data-frame="historical_record"] .scene-frame { background: rgba(0, 126, 111, 0.8); }

.character-summary { position: relative; z-index: 3; flex: 1; display: flex; flex-direction: column; }
.portrait-wrap { position: relative; flex: 1; min-height: 420px; display: grid; place-items: end center; }
.portrait { height: min(61vh, 545px); max-height: 100%; filter: drop-shadow(0 24px 18px rgba(31, 5, 26, 0.31)); }
.portrait img { width: auto; height: 100%; display: block; object-fit: contain; }

.has-scene-artwork .visual-panel { padding: 24px; }
.has-scene-artwork .character-summary { flex: none; min-height: 86px; display: grid; grid-template-columns: 76px minmax(0, 1fr); align-items: center; gap: 15px; padding: 2px 4px; }
.has-scene-artwork .portrait-wrap { width: 76px; min-height: 0; aspect-ratio: 1; display: block; overflow: hidden; border: 4px solid rgba(255, 255, 255, 0.9); border-radius: 50%; background: linear-gradient(145deg, var(--blue), white); box-shadow: 0 10px 24px rgba(20, 4, 18, 0.25); }
.has-scene-artwork .portrait { height: 112px; max-height: none; transform: translate(3px, 3px); }
.has-scene-artwork .identity { min-width: 0; margin: 0; }
.has-scene-artwork .identity .story-kicker { margin-bottom: 3px; }
.has-scene-artwork .identity h1 { font-size: clamp(28px, 2.8vw, 38px); }
.has-scene-artwork .identity > p:not(.story-kicker) { margin-top: 5px; }
.has-scene-artwork .voice-disclosure { display: none; }

.identity { position: relative; z-index: 4; margin-top: 5px; }
.identity .story-kicker { margin: 0 0 5px; color: var(--yellow); font-size: 12px; font-weight: 900; letter-spacing: 0.08em; text-transform: uppercase; }
.identity h1 { margin: 0; font-size: clamp(38px, 4vw, 60px); line-height: 0.98; letter-spacing: -0.055em; }
.identity > p:not(.story-kicker) { margin: 8px 0 0; color: rgba(255, 255, 255, 0.83); }
.identity #scene-label { font: 15px/1.4 system-ui, sans-serif; font-weight: 650; }
.voice-disclosure { font: 11px/1.4 system-ui, sans-serif; }

.conversation-panel {
  position: relative;
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 12px;
  overflow: hidden;
  padding: clamp(18px, 2.2vw, 30px);
  background: radial-gradient(circle at 100% 0%, rgba(85, 217, 255, 0.13), transparent 16rem), var(--paper);
}

.call-status-bar { min-width: 0; display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.status { display: inline-flex; align-items: center; flex: none; gap: 9px; min-height: 38px; padding: 7px 12px; border-radius: 999px; background: #f0f5ff; color: #5e649e; font: 12px/1.2 system-ui, sans-serif; font-weight: 750; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: #9499bd; }
.status[data-state="listening"] { background: #e6fbff; color: #146685; }
.status[data-state="listening"] .status-dot { background: var(--mid-blue); }
.status[data-state="thinking"] { background: #f6ebff; color: #7424ae; }
.status[data-state="thinking"] .status-dot { background: var(--purple); animation: pulse 900ms infinite alternate; }
.status[data-state="speaking"] { background: #fff5cb; color: #785b00; }
.status[data-state="speaking"] .status-dot { background: var(--yellow); }
@keyframes pulse { to { opacity: 0.35; transform: scale(0.76); } }

.details { padding: 18px; border: 1px solid var(--line); border-radius: 20px; background: white; color: #555b91; font: 13px/1.5 system-ui, sans-serif; }
.latency { min-width: 230px; flex: 1; overflow: hidden; border: 1px solid var(--line); border-radius: 14px; background: white; color: #555b91; font: 12px/1.45 system-ui, sans-serif; }
.microphone-check { flex: 1 0 100%; display: grid; grid-template-columns: auto minmax(80px, 1fr) auto; align-items: center; gap: 7px 12px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 14px; background: white; color: #555b91; font: 12px/1.4 system-ui, sans-serif; }
.details h2 { margin: 0 0 8px; color: var(--ink); font: 900 18px/1.2 ui-rounded, sans-serif; }
.details p { margin: 0; }
.details .privacy { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 11px; }
.mode-switch { display: flex; gap: 8px; margin: 18px 0 0; padding: 0; border: 0; }
.mode-switch legend { margin-bottom: 7px; color: var(--ink); font-weight: 800; }
.mode-switch input { position: absolute; opacity: 0; pointer-events: none; }
.mode-switch label { flex: 1; }
.mode-switch label span { display: block; padding: 10px; border: 1px solid var(--line); border-radius: 12px; text-align: center; }
.mode-switch input:checked + span { border-color: var(--purple); background: #f6eaff; color: #6f1ea5; }
.mode-note { margin: 8px 0 0; }
.details dl { display: grid; grid-template-columns: 1fr auto; gap: 7px 12px; margin: 14px 0 0; }
.details dt,
.details dd,
.latency dt,
.latency dd { margin: 0; }
.details dd,
.latency dd { color: var(--ink); font-weight: 750; text-align: right; }

.latency-heading { min-height: 38px; display: grid; grid-template-columns: auto auto minmax(44px, 1fr) auto; align-items: center; gap: 10px; padding: 7px 11px; color: var(--ink); cursor: pointer; list-style: none; }
.latency-heading::-webkit-details-marker { display: none; }
.latency-heading::before { color: #8b8fb3; content: "›"; font-size: 16px; transition: transform 140ms ease; }
.latency[open] .latency-heading::before { transform: rotate(90deg); }
.latency-heading > #latency-title { white-space: nowrap; }
.latency-details { padding: 0 12px 11px 28px; border-top: 1px solid rgba(34, 44, 167, 0.08); }
.latency-details > p { padding-top: 9px; }
.latency-breakdown { display: flex; flex-wrap: wrap; gap: 7px 14px; margin: 9px 0 0; }
.latency-breakdown > div { display: flex; gap: 5px; }
.microphone-check-heading { display: contents; color: var(--ink); }
.microphone-check-heading > span { grid-column: 1; }
.microphone-check-heading > strong { grid-column: 3; }
.latency-progress,
.microphone-meter { height: 6px; overflow: hidden; border-radius: 999px; background: #e9ebf6; }
.latency-progress { min-width: 38px; margin: 0; }
.microphone-meter { grid-column: 2; grid-row: 1; margin: 0; }
.latency-progress span,
.microphone-meter span { display: block; width: 20%; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--purple), var(--blue)); }
.latency[data-state="done"] .latency-progress span { width: 100%; }
.latency[data-state="failed"] .latency-progress span { width: 100%; background: var(--pink); }
.microphone-check p,
.latency p { margin: 0; }
.microphone-check p { grid-column: 1 / -1; }
.microphone-check[data-state="working"] p,
.microphone-check[data-state="paused"] p { display: none; }
.microphone-device { font-size: 11px; }

.conversation-stage { position: relative; min-height: 0; overflow: hidden; }
.conversation-scroll { height: 100%; min-height: 0; display: flex; flex-direction: column; gap: 15px; overflow-y: auto; overscroll-behavior: contain; padding: 3px 7px 10px 1px; scrollbar-width: thin; scrollbar-color: rgba(34, 44, 167, 0.2) transparent; }
.call-card:not([data-input-mode]) .conversation-scroll { justify-content: center; }
.jump-latest { position: absolute; z-index: 5; right: 15px; bottom: 12px; min-height: 40px; padding: 0 13px; border: 1px solid rgba(34, 44, 167, 0.16); border-radius: 999px; background: var(--ink); color: white; box-shadow: 0 10px 24px rgba(34, 44, 167, 0.2); cursor: pointer; font: 750 12px/1 system-ui, sans-serif; }

.conversation { flex: none; display: flex; flex-direction: column; gap: 15px; }
.turn { display: flex; flex-direction: column; align-items: flex-start; gap: 5px; }
.turn.user-turn { align-items: flex-end; }
.speaker-label { padding: 0 7px; color: #7424ae; font: 800 11px/1.2 system-ui, sans-serif; letter-spacing: 0.02em; }
.user-turn .speaker-label { color: #146685; }
.bubble { max-width: 86%; margin: 0; padding: 14px 16px; border: 1px solid rgba(158, 41, 235, 0.13); border-radius: 7px 19px 19px 19px; background: #f0e5ff; color: #42155f; font: 15px/1.45 system-ui, -apple-system, sans-serif; }
.bubble.user { border: 1px solid rgba(0, 153, 255, 0.2); border-radius: 19px 7px 19px 19px; background: #ddf8ff; color: #16566c; }

.ending-card { display: grid; gap: 7px; padding: 17px 18px; border: 1px solid rgba(38, 128, 73, 0.22); border-radius: 20px; background: linear-gradient(145deg, #eaf9ef, #f8fff9); color: #174b2b; }
.ending-eyebrow { color: #287a47; font: 800 10px/1.2 system-ui, sans-serif; letter-spacing: 0.1em; text-transform: uppercase; }
.ending-card h2 { margin: 0; font: 800 23px/1.1 system-ui, sans-serif; letter-spacing: -0.025em; }
.ending-card h3 { margin: 8px 0 -3px; font: 750 14px/1.25 system-ui, sans-serif; }
.ending-card p { margin: 0; font: 14px/1.5 system-ui, sans-serif; }
.ending-card .ending-summary { font-weight: 650; }
.ending-card .ending-continue { margin-top: 7px; padding-top: 10px; border-top: 1px solid rgba(38, 128, 73, 0.2); font-weight: 650; }
.ending-frame { justify-self: start; padding: 5px 8px; border-radius: 999px; background: rgba(40, 122, 71, 0.1); color: #246a3e; font: 750 10px/1.2 system-ui, sans-serif; }

.suggestions > p { margin: 0 0 10px; color: #7175a7; font: 12px/1.4 system-ui, sans-serif; font-weight: 750; }
#suggestion-list { display: grid; gap: 9px; }
#suggestion-list button { width: 100%; min-height: 48px; padding: 11px 14px; border: 1px solid rgba(158, 41, 235, 0.2); border-radius: 16px; background: white; color: #5e2087; cursor: pointer; font: 14px/1.35 system-ui, sans-serif; font-weight: 720; text-align: left; transition: background 140ms ease, transform 140ms ease; }
#suggestion-list button:hover { transform: translateX(3px); background: #f8efff; }
#suggestion-list button:disabled { cursor: wait; opacity: 0.55; }

.error { margin: 0; padding: 13px 14px; border-radius: 15px; background: #fff0f1; color: #9a2934; font: 13px/1.4 system-ui, sans-serif; }
.resume-audio { width: 100%; }
.start-controls { margin-block: auto; }
.start-heading .eyebrow { color: var(--purple); }
.start-heading h2 { max-width: 440px; font-size: clamp(31px, 3.4vw, 47px); }
.start-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 26px; }
.start-call { min-height: 104px; display: flex; align-items: center; gap: 13px; padding: 17px; border: 0; border-radius: 22px; background: linear-gradient(145deg, var(--mid-blue), var(--blue)); color: var(--ink); box-shadow: 0 14px 28px rgba(0, 153, 255, 0.18); cursor: pointer; text-align: left; transition: transform 160ms ease, box-shadow 160ms ease; }
.start-call:hover { transform: translateY(-3px); box-shadow: 0 18px 34px rgba(0, 153, 255, 0.24); }
.start-call:disabled { cursor: wait; opacity: 0.58; transform: none; }
.start-call.secondary-start { background: linear-gradient(145deg, #b64df3, var(--purple)); color: white; box-shadow: 0 14px 28px rgba(158, 41, 235, 0.2); }
.control-icon { width: 42px; height: 42px; flex: none; display: grid; place-items: center; border-radius: 14px; background: rgba(255, 255, 255, 0.45); }
.start-call span:last-child { display: grid; gap: 3px; }
.start-call strong { font-size: 15px; }
.start-call small { font: 11px/1.35 system-ui, sans-serif; opacity: 0.74; }
#start-help { margin: 16px 0 0; color: #7478aa; font: 12px/1.45 system-ui, sans-serif; }

.call-dock { min-width: 0; display: flex; align-items: center; justify-content: center; gap: 10px; padding-top: 11px; border-top: 1px solid rgba(34, 44, 167, 0.1); }
.call-dock:has(.text-controls[hidden]):has(.call-controls[hidden]) { display: none; }
.text-controls { min-width: 0; flex: 1; display: grid; grid-template-columns: 1fr 52px; gap: 9px; }
.text-controls input { min-width: 0; min-height: 54px; padding: 0 16px; border: 2px solid rgba(34, 44, 167, 0.16); border-radius: 18px; background: white; color: var(--ink); font: 15px system-ui, sans-serif; }
.text-controls input::placeholder { color: #9296b8; }
.text-controls button { border: 0; border-radius: 18px; background: var(--ink); color: white; cursor: pointer; font-size: 24px; font-weight: 900; }

.call-controls { flex: none; display: flex; justify-content: center; gap: 10px; }
.control-button { min-width: 78px; min-height: 58px; display: grid; place-items: center; gap: 2px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 18px; background: white; cursor: pointer; }
.control-button small { font: 11px system-ui, sans-serif; }
.end-button { border-color: rgba(255, 93, 105, 0.24); background: #fff0f1; color: #9a2934; }

body:not([data-debug="true"]) .debug-only { display: none !important; }

@media (max-width: 980px) {
  .library-grid { grid-template-columns: minmax(300px, 0.8fr) minmax(420px, 1.2fr); }
  .character-portal,
  .story-library { min-height: 680px; }
  .call-card { grid-template-columns: minmax(330px, 0.85fr) minmax(400px, 1.15fr); }
  .start-actions { grid-template-columns: 1fr; }
  .start-call { min-height: 78px; }
}

@media (max-width: 760px) {
  body { background: radial-gradient(circle at 2% 10%, rgba(85, 217, 255, 0.22) 0 5rem, transparent 5.1rem), var(--cream); }
  .app-shell { padding: 12px; }
  .brand-header { margin: 0 5px 12px; }
  .library-grid { grid-template-columns: 1fr; gap: 14px; }
  .character-portal { min-height: 390px; border-radius: 30px; }
  .portal-copy { padding: 27px; }
  .portal-copy h1 { max-width: 230px; font-size: clamp(46px, 15vw, 68px); }
  .portal-copy p:last-child { max-width: 210px; margin-top: 12px; font-size: 15px; }
  .character-stage { position: absolute; inset: 0; min-height: 0; }
  .character-stage img { right: -2%; bottom: -7%; left: auto; height: 94%; max-height: none; transform: none; }
  .stage-sun { top: 14%; left: auto; right: 7%; width: 48%; transform: none; }
  .column-one { left: auto; right: 45%; }
  .column-two { right: 3%; }
  .story-library { min-height: 0; padding: 25px 18px; border-radius: 30px; }
  .library-heading { align-items: center; }
  .library-heading h2 { font-size: 36px; }
  .story-carousel { grid-auto-columns: min(86%, 330px); margin-inline: -4px; }
  .story-card { min-height: 340px; }
  .story-footer { align-items: stretch; flex-direction: column; }
  .primary-action { width: 100%; }
  .more-stories-card { margin-top: 14px; }

  .auth-view { min-height: calc(100vh - 24px); padding-top: 48px; }
  .auth-brand { top: 18px; left: 20px; }
  .auth-card { min-height: 0; grid-template-columns: 1fr; border-radius: 28px; }
  .auth-art { min-height: 154px; }
  .auth-art img { bottom: -60%; height: 160%; }
  .auth-orbit-one { top: -20%; right: 5%; width: 42%; }
  .auth-orbit-two { right: -10%; bottom: -70%; width: 70%; }
  .auth-content { padding: 22px 20px 24px; }
  .auth-content h1 { font-size: 40px; }
  .auth-intro { margin-top: 11px; font-size: 13px; }
  .auth-tabs { margin-top: 15px; }
  .auth-form { margin-top: 14px; }
  .auth-form input { min-height: 48px; }
  .auth-submit { min-height: 50px; margin-top: 11px; }
  .auth-help { margin-top: 10px; }
  .account-email { display: none; }

  body[data-player-active="true"] .app-shell { padding: 0; }
  .player-view { margin: -12px; width: calc(100% + 24px); }
  body[data-player-active="true"] .player-view { width: 100%; margin: 0; }
  .player-nav { position: relative; z-index: 20; min-height: 60px; margin: 0; padding: 7px 10px; border-bottom: 1px solid var(--line); background: rgba(255, 248, 239, 0.96); }
  .player-nav .brand-lockup { display: none; }
  .details-button,
  .download-button,
  .back-button { min-height: 44px; padding: 0 14px; background: rgba(255, 255, 255, 0.76); }
  .call-card { min-height: 0; display: grid; grid-template-columns: 1fr; grid-template-rows: min(52dvh, calc(56.25vw + 94px)) minmax(0, 1fr); border: 0; border-radius: 0; box-shadow: none; }
  .call-card:not(.has-scene-artwork) { grid-template-rows: minmax(0, 1fr); }
  .call-card:not(.has-scene-artwork) .visual-panel { display: none; }
  .has-scene-artwork .visual-panel { min-height: 0; display: grid; grid-template-rows: minmax(0, 1fr) auto; gap: 0; padding: 0; }
  .has-scene-artwork .topbar { position: absolute; z-index: 5; top: 9px; right: 10px; left: 10px; align-items: center; pointer-events: none; }
  .has-scene-artwork .topbar > div:first-child { padding: 5px 9px; border: 1px solid rgba(255, 255, 255, 0.2); border-radius: 999px; background: rgba(31, 4, 24, 0.62); backdrop-filter: blur(10px); }
  .has-scene-artwork .topbar .eyebrow { display: none; }
  .has-scene-artwork .call-time { color: white; font-size: 11px; font-weight: 750; }
  .has-scene-artwork .live-dot { display: none !important; }
  .has-scene-artwork .scene-toggle { position: absolute; z-index: 7; top: 9px; right: 10px; display: inline-flex; align-items: center; min-height: 32px; padding: 0 11px; border: 1px solid rgba(255, 255, 255, 0.28); border-radius: 999px; background: rgba(31, 4, 24, 0.72); color: white; box-shadow: 0 8px 22px rgba(31, 4, 24, 0.24); backdrop-filter: blur(10px); cursor: pointer; font: 800 10px/1 system-ui, sans-serif; }
  .has-scene-artwork .scene-artwork { min-height: 0; grid-row: 1; border: 0; border-radius: 0; box-shadow: none; }
  .has-scene-artwork .scene-artwork img { object-position: 50% 24%; transform: none; }
  .has-scene-artwork .scene-artwork[data-state="loaded"] img { transform: none; }
  .scene-artwork figcaption { min-height: 36px; padding: 6px 10px; font-size: 10px; }
  .scene-frame { padding: 5px 7px; font-size: 8px; }
  .has-scene-artwork .character-summary { grid-row: 2; grid-template-columns: 48px minmax(0, 1fr); min-height: 58px; gap: 10px; padding: 6px 12px; background: rgba(49, 4, 37, 0.96); }
  .has-scene-artwork .portrait-wrap { width: 48px; min-height: 0; border-width: 3px; }
  .has-scene-artwork .portrait { height: 73px; }
  .has-scene-artwork .identity .story-kicker { display: none; }
  .has-scene-artwork .identity h1 { font-size: 20px; letter-spacing: -0.035em; }
  .has-scene-artwork .identity #scene-label { max-width: 100%; overflow: hidden; font-size: 10px; line-height: 1.25; text-overflow: ellipsis; white-space: nowrap; }
  .call-card.scene-expanded { grid-template-rows: minmax(0, 1fr); }
  .scene-expanded .visual-panel { grid-row: 1; }
  .scene-expanded .conversation-panel { display: none; }
  .scene-expanded .scene-artwork img { object-fit: contain; transform: none; background: #23061c; }
  .scene-expanded .scene-artwork[data-state="loaded"] img { transform: none; }
  .conversation-panel { min-height: 0; gap: 9px; padding: 11px 13px max(9px, env(safe-area-inset-bottom)); }
  .call-status-bar { gap: 7px; }
  .status { min-height: 34px; padding: 6px 10px; font-size: 11px; }
  .latency { min-width: 160px; }
  .latency-heading { min-height: 34px; gap: 7px; padding: 5px 8px; font-size: 10px; }
  .latency-heading > #latency-title { max-width: 112px; overflow: hidden; text-overflow: ellipsis; }
  .latency-details { padding: 0 9px 9px 22px; }
  .microphone-check { padding: 7px 9px; font-size: 11px; }
  .conversation-scroll { gap: 12px; padding-right: 4px; }
  .bubble { max-width: 92%; padding: 11px 13px; font-size: 14px; }
  .speaker-label { font-size: 10px; }
  .call-dock { gap: 7px; padding-top: 8px; }
  .control-button { min-width: 66px; min-height: 52px; padding: 6px 9px; border-radius: 16px; }
  .text-controls { grid-template-columns: 1fr 48px; gap: 7px; }
  .text-controls input { min-height: 50px; }
  .jump-latest { right: 9px; bottom: 9px; }
  .start-controls { margin-block: auto; }
  .start-heading h2 { font-size: 36px; }
  .start-actions { grid-template-columns: 1fr; margin-top: 21px; }
  .start-call { min-height: 78px; }
}

@media (max-width: 430px) {
  .brand-lockup { font-size: 18px; }
  .brand-mode { display: none; }
  .character-portal { min-height: 355px; }
  .portal-copy h1 { max-width: 190px; font-size: 51px; }
  .portal-copy p:last-child { max-width: 165px; font-size: 13px; }
  .character-stage img { right: -12%; height: 91%; }
  .story-carousel { grid-auto-columns: 92%; }
  .carousel-controls button { min-width: 44px; min-height: 44px; }
  .portrait { height: 290px; }
  .voice-disclosure { display: none; }
}

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