:root {
  --bg-0: #05060d;
  --bg-1: #0b1024;
  --accent: #7c5cff;
  --accent-2: #22d3ee;
  --accent-3: #ff5ca8;
  --text: #eaf0ff;
  --muted: #8b93b8;
  --glass: rgba(255, 255, 255, 0.05);
  --glass-border: rgba(255, 255, 255, 0.12);
  --page-bg: radial-gradient(1200px 800px at 50% -10%, #131a3a 0%, var(--bg-1) 40%, var(--bg-0) 100%);
  /* 数字人舞台背景（浅色主题下保持深色“屏幕”，让发光的数字人依旧好看）*/
  --stage-bg: transparent;
  --stage-border: transparent;
  --stage-shadow: none;
  --caption-bg: linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.02));
  --caption-user: #cdd7ff;
  --caption-assistant: #ffffff;
  --fx-opacity: 1;
  font-family: -apple-system, "SF Pro Display", "PingFang SC",
    "Helvetica Neue", Arial, sans-serif;
}

/* ------------------------- 浅色（白色）主题 ------------------------- */
:root[data-theme="light"] .state-label { color: rgba(255, 255, 255, 0.55); }

:root[data-theme="light"] {
  --bg-0: #e4e8f7;
  --bg-1: #ffffff;
  --text: #1b2140;
  --muted: #5b6488;
  --glass: rgba(20, 24, 54, 0.045);
  --glass-border: rgba(20, 24, 54, 0.12);
  --page-bg: radial-gradient(1200px 800px at 50% -10%, #ffffff 0%, #eef1fb 45%, #e4e8f7 100%);
  --stage-bg: radial-gradient(120% 100% at 50% 25%, #1a2142 0%, #0b1024 82%);
  --stage-border: rgba(20, 24, 54, 0.10);
  --stage-shadow: 0 22px 55px rgba(30, 40, 90, 0.18);
  --caption-bg: linear-gradient(180deg, rgba(255,255,255,.92), rgba(245,247,255,.78));
  --caption-user: #3a4680;
  --caption-assistant: #241a5c;
  --fx-opacity: 0;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--page-bg);
  color: var(--text);
  overflow: hidden;
}

#fx-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: var(--fx-opacity);
  transition: opacity 0.4s;
}

.scene {
  position: relative;
  z-index: 1;
  height: 100%;
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  max-width: 720px;
  margin: 0 auto;
  padding: 22px 20px 28px;
}

/* ---------------- Topbar ---------------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: 10px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.brand-glyph {
  font-size: 20px;
  color: var(--accent-2);
  filter: drop-shadow(0 0 8px var(--accent-2));
  animation: spin 12s linear infinite;
}
.brand-name {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 6px;
  background: linear-gradient(90deg, var(--accent-2), var(--accent), var(--accent-3));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(12px);
}
.dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: #55607f;
  box-shadow: 0 0 0 0 rgba(124, 92, 255, 0.5);
  transition: background .3s;
}
.dot.on {
  background: var(--accent-2);
  animation: pulse 1.6s infinite;
}

/* ---------------- Stage ---------------- */
.stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--stage-bg);
  border: 1px solid var(--stage-border);
  border-radius: 28px;
  box-shadow: var(--stage-shadow);
  transition: background 0.4s;
}
#avatar {
  width: 100%;
  height: 100%;
  max-height: 52vh;
  display: block;
}
.state-label {
  position: absolute;
  bottom: 6px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  letter-spacing: 4px;
  color: var(--muted);
  text-transform: uppercase;
  opacity: .8;
}

/* ---------------- Caption ---------------- */
.caption-area {
  min-height: 96px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 18px;
  margin: 4px 0 14px;
  border-radius: 20px;
  background: var(--caption-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(16px);
  box-shadow: 0 20px 60px rgba(0,0,0,.35), inset 0 1px 0 rgba(255,255,255,.06);
  transition: background 0.4s;
}
.caption-role {
  font-size: 11px;
  letter-spacing: 3px;
  color: var(--accent-2);
  text-transform: uppercase;
  min-height: 14px;
}
.caption {
  font-size: 21px;
  line-height: 1.5;
  text-align: center;
  font-weight: 400;
  transition: opacity .25s;
  max-height: 4.6em;
  overflow-y: auto;
}
.caption.user { color: var(--caption-user); }
.caption.assistant {
  color: var(--caption-assistant);
  text-shadow: 0 0 20px rgba(124,92,255,.45);
}

/* ---------------- Controls ---------------- */
.controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
}
.btn {
  padding: 13px 26px;
  border-radius: 999px;
  border: 1px solid var(--glass-border);
  background: var(--glass);
  color: var(--text);
  font-size: 15px;
  cursor: pointer;
  backdrop-filter: blur(10px);
  transition: transform .15s, box-shadow .25s, opacity .25s;
}
.btn:hover:not(:disabled) { transform: translateY(-2px); }
.btn:disabled { opacity: .4; cursor: default; }
.btn.primary {
  background: linear-gradient(90deg, var(--accent), var(--accent-3));
  border: none;
  box-shadow: 0 10px 30px rgba(124,92,255,.45);
  font-weight: 600;
}
.mini-cam {
  width: 84px; height: 60px;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--glass-border);
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
  background: #000;
}
#camera {
  width: 100%; height: 100%;
  object-fit: cover;
  transform: scaleX(-1); /* 镜像，更像照镜子 */
  opacity: .9;
}

#theme-toggle {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  border: 1px solid var(--glass-border);
  background: var(--glass);
  color: var(--text);
  font-size: 15px;
  cursor: pointer;
  backdrop-filter: blur(12px);
  transition: transform .15s, background .2s;
}
#theme-toggle:hover { transform: translateY(-1px) rotate(-12deg); }

#debug-link {
  position: fixed;
  right: 14px;
  bottom: 12px;
  z-index: 3;
  font-size: 12px;
  letter-spacing: 1px;
  color: var(--muted);
  text-decoration: none;
  padding: 5px 10px;
  border-radius: 8px;
  border: 1px solid var(--glass-border);
  background: rgba(0, 0, 0, 0.25);
  opacity: 0.35;
  transition: opacity 0.2s, color 0.2s;
}
#debug-link:hover { opacity: 1; color: var(--accent-2); }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(34,211,238,.5); }
  70% { box-shadow: 0 0 0 8px rgba(34,211,238,0); }
  100% { box-shadow: 0 0 0 0 rgba(34,211,238,0); }
}

@media (max-height: 680px) {
  .caption { font-size: 18px; }
  #avatar { max-height: 44vh; }
}
