:root {
  font-family: "PingFang SC", "Microsoft YaHei UI", "Microsoft YaHei", sans-serif;
  color: #f7f3ea;
  background: #090d10;
  font-synthesis: none;
  --ink: #f7f3ea;
  --muted: rgba(247, 243, 234, 0.48);
  --accent: #c6ffdc;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; overflow: hidden; background: #090d10; }
button, textarea { font: inherit; }
button { cursor: pointer; }

.demo-shell {
  position: relative;
  width: 100vw;
  height: 100dvh;
  min-height: 620px;
  overflow: hidden;
  isolation: isolate;
  background: #090d10;
}

.avatar-panel,
.avatar-stage { position: absolute; inset: 0; }
.avatar-stage { overflow: hidden; background: #090d10; }
.avatar-stage video,
.avatar-stage img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 38%;
  transform: scale(1.002);
}
.avatar-stage video { will-change: filter, opacity, transform; transition: opacity 180ms ease; }
.avatar-stage.is-quiet-cut video { opacity: 0; }
.avatar-stage img[hidden], .avatar-stage video[hidden] { display: none; }
#scene-frame-hold { position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%; object-fit: cover; object-position: center 38%; pointer-events: none; }
#scene-frame-hold[hidden] { display: none; }

.scene-vignette {
  position: absolute;
  z-index: 2;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(4, 7, 9, 0.7) 0%, rgba(4, 7, 9, 0.2) 42%, rgba(4, 7, 9, 0.08) 67%, rgba(4, 7, 9, 0.48) 100%),
    linear-gradient(180deg, rgba(4, 7, 9, 0.42) 0%, transparent 28%, transparent 56%, rgba(4, 7, 9, 0.88) 100%);
}

.stage-header {
  position: absolute;
  z-index: 8;
  top: 0;
  right: 0;
  left: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 28px 34px;
  pointer-events: none;
}
.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: rgba(255, 255, 255, 0.84);
  font-size: 11px;
  font-weight: 720;
  letter-spacing: 0.26em;
  text-decoration: none;
  pointer-events: auto;
}
.wordmark-mark {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 22px rgba(151, 255, 196, 0.58);
}
.status-row,
.scene-caption {
  display: flex;
  align-items: center;
  gap: 9px;
  color: rgba(255, 255, 255, 0.5);
  font-size: 11px;
  letter-spacing: 0.1em;
}
.status-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 12px rgba(151, 255, 196, 0.58);
}
.scene-caption {
  position: absolute;
  z-index: 8;
  right: 34px;
  bottom: 31px;
  writing-mode: vertical-rl;
  pointer-events: none;
}
.scene-caption span { color: rgba(255, 255, 255, 0.22); font-size: 9px; }
.scene-caption strong { max-height: 280px; color: rgba(255, 255, 255, 0.46); font-size: 11px; font-weight: 500; }

.chat-panel {
  position: absolute;
  z-index: 6;
  inset: 0;
  display: grid;
  grid-template-rows: 1fr auto;
  pointer-events: none;
}
.mobile-heading { display: none; }
.messages {
  position: absolute;
  left: clamp(28px, 6vw, 96px);
  bottom: 156px;
  width: min(690px, calc(100vw - 330px));
  max-height: min(43vh, 410px);
  overflow-y: auto;
  padding: 44px 12px 4px 0;
  mask-image: linear-gradient(180deg, transparent 0, #000 18%, #000 100%);
  scroll-behavior: smooth;
  pointer-events: auto;
  scrollbar-width: none;
}
.messages::-webkit-scrollbar { display: none; }
#program-caption {
  position: absolute;
  left: clamp(28px, 6vw, 96px);
  bottom: 156px;
  width: min(690px, calc(100vw - 330px));
  margin: 0;
  color: rgba(255, 255, 255, 0.72);
  font-family: "Songti SC", STSong, "Noto Serif CJK SC", serif;
  font-size: clamp(19px, 2vw, 27px);
  line-height: 1.62;
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.45);
}
#program-caption:empty { display: none; }
.chat-panel.is-program-presenting .messages { visibility: hidden; }
.message {
  margin: 0 0 14px;
  color: rgba(255, 255, 255, 0.6);
  line-height: 1.72;
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.45);
  transition: opacity 180ms ease;
}
.message:not(:last-child) { opacity: 0.42; }
.message p { margin: 0; white-space: pre-wrap; }
.message.assistant:last-child {
  color: rgba(255, 255, 255, 0.72);
  font-family: "Songti SC", STSong, "Noto Serif CJK SC", serif;
  font-size: clamp(19px, 2vw, 27px);
  line-height: 1.62;
}
.message.user { margin-left: clamp(10px, 6vw, 84px); color: rgba(198, 255, 220, 0.64); font-size: 14px; }
.message.error { color: #ffd0c9; }
.message-role {
  display: block;
  margin-bottom: 5px;
  color: rgba(255, 255, 255, 0.3);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.keyword-ticker {
  position: absolute;
  z-index: 8;
  top: 50%;
  right: 28px;
  width: 150px;
  transform: translateY(-50%);
  text-align: right;
  pointer-events: auto;
}
.keyword-ticker-heading { margin-bottom: 12px; color: rgba(255, 255, 255, 0.26); font-size: 10px; letter-spacing: 0.12em; }
.keyword-ticker-heading small { display: block; margin-top: 4px; color: rgba(255, 255, 255, 0.16); font-size: 9px; letter-spacing: 0; }
.keyword-list { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.keyword-list button {
  padding: 3px 0;
  border: 0;
  color: rgba(255, 255, 255, 0.26);
  background: transparent;
  font-size: 12px;
  text-align: right;
  transition: color 180ms ease, transform 180ms ease;
}
.keyword-list button:hover,
.keyword-list button:focus-visible { color: rgba(255, 255, 255, 0.86); outline: none; transform: translateX(-4px); }

.conversation-controls {
  position: absolute;
  z-index: 9;
  right: clamp(68px, 11vw, 180px);
  bottom: 28px;
  left: clamp(28px, 6vw, 96px);
  pointer-events: auto;
}
.composer {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) 42px 48px;
  align-items: center;
  gap: 2px;
  min-height: 62px;
  padding: 7px 8px;
  border: 0;
  border-radius: 999px;
  background: rgba(15, 20, 23, 0.64);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.34), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(24px) saturate(130%);
}
.composer:focus-within { background: rgba(15, 20, 23, 0.79); box-shadow: 0 20px 60px rgba(0, 0, 0, 0.42), 0 0 0 3px rgba(198, 255, 220, 0.08); }
.composer textarea {
  width: 100%;
  max-height: 110px;
  min-height: 28px;
  resize: none;
  overflow-y: auto;
  padding: 5px 10px;
  border: 0;
  outline: 0;
  color: #fff;
  background: transparent;
  line-height: 1.55;
}
.composer textarea::placeholder { color: rgba(255, 255, 255, 0.36); }
.icon-button,
.send-button {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: rgba(255, 255, 255, 0.52);
  background: transparent;
}
.icon-button svg { width: 19px; height: 19px; fill: currentColor; }
.icon-button:hover,
.icon-button:focus-visible { color: #fff; outline: none; background: rgba(255, 255, 255, 0.07); }
.voice-toggle[aria-pressed="false"] { color: rgba(255, 255, 255, 0.22); }
.mic-button.is-listening { color: #ffcec7; background: rgba(224, 82, 68, 0.18); animation: listening-pulse 1.3s ease-in-out infinite; }
.mic-button:disabled { cursor: not-allowed; opacity: 0.22; }
.send-button { width: 44px; height: 44px; color: #07110c; background: var(--accent); box-shadow: 0 0 26px rgba(151, 255, 196, 0.2); }
.send-button svg { width: 18px; height: 18px; fill: currentColor; }
.send-button:disabled { cursor: wait; opacity: 0.4; }
.send-button:focus-visible { outline: 3px solid rgba(198, 255, 220, 0.24); outline-offset: 2px; }
@keyframes listening-pulse { 50% { box-shadow: 0 0 0 9px rgba(224, 82, 68, 0.06); } }

.connection-status,
.privacy-note { margin: 7px 18px 0; color: rgba(255, 255, 255, 0.36); font-size: 10px; line-height: 1.45; }
.privacy-note { color: rgba(255, 255, 255, 0.19); }

.scene-transition-overlay {
  position: absolute;
  z-index: 3;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  opacity: 0;
  background:
    radial-gradient(circle at 50% 46%, rgba(255, 246, 205, 0.9) 0 4%, rgba(255, 197, 91, 0.42) 15%, transparent 43%),
    linear-gradient(112deg, transparent 20%, rgba(119, 189, 247, 0.18) 44%, rgba(255, 217, 144, 0.56) 50%, rgba(119, 189, 247, 0.14) 56%, transparent 80%);
  mix-blend-mode: screen;
}
.portal-ring, .portal-flare { position: absolute; top: 50%; left: 50%; border-radius: 50%; transform: translate(-50%, -50%); }
.portal-ring { border: 1px solid rgba(255, 238, 189, 0.72); box-shadow: 0 0 24px rgba(255, 197, 91, 0.5), inset 0 0 28px rgba(111, 194, 255, 0.3); }
.portal-ring-outer { width: 78%; aspect-ratio: 1; }
.portal-ring-inner { width: 48%; aspect-ratio: 1; }
.portal-flare { width: 16%; aspect-ratio: 1; background: #fff7d8; box-shadow: 0 0 42px 18px rgba(255, 203, 105, 0.62); }
.avatar-stage.is-portal-transitioning .scene-transition-overlay { animation: scene-portal-sweep 1500ms cubic-bezier(0.64, 0, 0.36, 1) both; }
.avatar-stage.is-portal-transitioning video { animation: scene-portal-video 1500ms cubic-bezier(0.64, 0, 0.36, 1) both; }
.avatar-stage.is-soft-transitioning .scene-transition-overlay { animation: scene-soft-sweep 450ms ease-in-out both; }
.avatar-stage.is-soft-transitioning video { animation: scene-soft-video 450ms ease-in-out both; }
@keyframes scene-portal-sweep { 0%, 100% { opacity: 0; transform: scale(.82) rotate(-5deg); } 18%, 82% { opacity: .9; } 50% { opacity: .32; transform: scale(1.18) rotate(4deg); } }
@keyframes scene-portal-video { 0%, 100% { filter: blur(0) saturate(1); opacity: 1; transform: scale(1.002); } 18%, 82% { filter: blur(7px) saturate(.72); opacity: .32; transform: scale(1.045); } 50% { filter: blur(1px) saturate(1.08); opacity: .92; transform: scale(1.015); } }
@keyframes scene-soft-sweep { 0%, 100% { opacity: 0; } 50% { opacity: .42; } }
@keyframes scene-soft-video { 0%, 100% { filter: blur(0); opacity: 1; transform: scale(1.002); } 50% { filter: blur(3px); opacity: .24; transform: scale(1.015); } }

.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;
}

@media (max-width: 820px) and (min-width: 471px) {
  .messages { width: calc(100vw - 250px); left: 28px; }
  .conversation-controls { left: 28px; right: 76px; }
  .stage-header { padding: 22px 24px; }
  .keyword-ticker { right: 20px; }
  .scene-caption { right: 24px; }
}

@media (max-width: 470px) {
  :root { color: #15202a; background: #f7f6f1; }
  body { overflow: hidden; background: #f7f6f1; }
  .demo-shell { min-height: 100svh; height: 100dvh; background: #f7f6f1; }
  .avatar-panel, .keyword-ticker, .voice-toggle, .privacy-note, #program-caption { display: none; }
  .chat-panel { position: relative; height: 100%; display: flex; flex-direction: column; padding: max(20px, env(safe-area-inset-top)) 16px max(10px, env(safe-area-inset-bottom)); pointer-events: auto; }
  .mobile-heading { display: grid; gap: 5px; color: #17242d; }
  .mobile-heading span { color: #65727b; font-size: 9px; letter-spacing: .2em; }
  .mobile-heading strong { font-family: "Songti SC", STSong, serif; font-size: 24px; font-weight: 600; }
  .messages { position: static; width: 100%; max-height: none; flex: 1; padding: 38px 2px 14px; overflow-y: auto; mask-image: none; }
  .message { color: #52616b; text-shadow: none; }
  .message:not(:last-child) { opacity: .58; }
  .message.assistant:last-child { color: #43515a; font-size: 18px; line-height: 1.65; }
  .message.user { color: #246647; }
  .message-role { color: #8b969d; }
  .conversation-controls { position: static; }
  .composer { grid-template-columns: 44px minmax(0, 1fr) 46px; min-height: 58px; padding: 6px; background: #fff; box-shadow: 0 10px 35px rgba(20, 34, 43, .1); }
  .composer:focus-within { background: #fff; box-shadow: 0 12px 40px rgba(20, 34, 43, .13), 0 0 0 3px rgba(44, 126, 83, .07); }
  .composer textarea { color: #17242d; }
  .composer textarea::placeholder { color: #9aa3a8; }
  .icon-button { color: #66747d; }
  .icon-button:hover, .icon-button:focus-visible { color: #17242d; background: #f0f2ef; }
  .send-button { color: #fff; background: #234f3a; }
  .connection-status { min-height: 15px; margin: 7px 12px 0; color: #7c888f; }
}

@media (prefers-reduced-motion: reduce) {
  .avatar-stage video, .scene-transition-overlay, .mic-button { animation: none !important; transition: none !important; }
}
