/* ============================================================
   冷光琉璃 · AI 实时语音接待 demo
   美术：克制、高级、苹果质感。深蓝→青的冷调，半透明琉璃感。
   ============================================================ */

:root {
  /* 冷调主色板 */
  --bg-deep: #050b18;        /* 深空底色 */
  --bg-deep-2: #0a1424;      /* 深空次色 */
  --accent: #22d3ee;         /* 青 */
  --accent-deep: #0a1e3f;    /* 深蓝 */
  --text: #e8f2ff;
  --text-dim: rgba(232, 242, 255, 0.55);
  --text-faint: rgba(232, 242, 255, 0.32);
  --glass-line: rgba(160, 220, 255, 0.14);
  --glass-fill: rgba(20, 40, 70, 0.28);
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-deep);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display",
    "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  user-select: none;
}

/* 深空渐变背景 */
body {
  background:
    radial-gradient(120% 90% at 50% 18%, #0c1d36 0%, var(--bg-deep-2) 42%, var(--bg-deep) 78%);
  position: relative;
}

/* 三维画布铺满 */
#scene {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
  z-index: 1;
}

/* CSS 柔光氛围层：在球后方加一团呼吸的冷光 */
.ambient {
  position: fixed;
  left: 50%;
  top: 46%;
  width: 70vmin;
  height: 70vmin;
  transform: translate(-50%, -50%);
  z-index: 0;
  pointer-events: none;
  background: radial-gradient(circle at 50% 50%,
      rgba(34, 211, 238, 0.16) 0%,
      rgba(20, 80, 140, 0.10) 32%,
      rgba(10, 30, 63, 0.0) 70%);
  filter: blur(8px);
  animation: ambientBreathe 7s ease-in-out infinite;
}

@keyframes ambientBreathe {
  0%, 100% { opacity: 0.7; transform: translate(-50%, -50%) scale(1.0); }
  50%      { opacity: 1.0; transform: translate(-50%, -50%) scale(1.08); }
}

/* ---------------- 字幕区 ---------------- */
.subtitle {
  position: relative;
  z-index: 3;
  text-align: center;
  padding: 0 8vw;
  pointer-events: none;
}

.subtitle-top {
  position: fixed;
  top: 8.5vh;
  left: 0;
  right: 0;
}

.subtitle-bottom {
  margin-bottom: 18px;
}

.subtitle-text {
  display: inline-block;
  font-size: clamp(15px, 2.1vw, 22px);
  font-weight: 400;
  letter-spacing: 0.04em;
  line-height: 1.6;
  color: var(--text);
  text-shadow: 0 0 22px rgba(34, 211, 238, 0.22);
  transition: opacity 0.6s ease;
}

.subtitle-top .subtitle-text { color: var(--text-dim); font-size: clamp(13px, 1.7vw, 18px); }

/* ---------------- 中心 HUD ---------------- */
.hud {
  position: fixed;
  left: 0; right: 0;
  bottom: 30vh;
  z-index: 3;
  display: flex;
  justify-content: center;
  pointer-events: none;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 7px 16px 7px 13px;
  border-radius: 999px;
  background: var(--glass-fill);
  border: 1px solid var(--glass-line);
  backdrop-filter: blur(14px) saturate(120%);
  -webkit-backdrop-filter: blur(14px) saturate(120%);
  box-shadow: 0 6px 24px rgba(0, 10, 30, 0.35), inset 0 1px 0 rgba(255,255,255,0.04);
}

.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
  transition: background 0.5s ease, box-shadow 0.5s ease;
}

.status-label {
  font-size: 13px;
  letter-spacing: 0.12em;
  color: var(--text-dim);
  transition: color 0.4s ease;
}

/* ---------------- 底部控制台 ---------------- */
.dock {
  position: fixed;
  left: 0; right: 0;
  bottom: 0;
  z-index: 4;
  padding: 0 0 max(28px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* 分段状态切换 */
.state-switch {
  display: inline-flex;
  padding: 4px;
  gap: 2px;
  border-radius: 14px;
  background: rgba(12, 26, 48, 0.42);
  border: 1px solid var(--glass-line);
  backdrop-filter: blur(16px) saturate(130%);
  -webkit-backdrop-filter: blur(16px) saturate(130%);
  box-shadow: 0 8px 30px rgba(0, 8, 24, 0.4), inset 0 1px 0 rgba(255,255,255,0.05);
  margin-bottom: 16px;
}

.seg {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-size: 13.5px;
  letter-spacing: 0.06em;
  padding: 9px 18px;
  border-radius: 11px;
  cursor: pointer;
  transition: color 0.28s ease, background 0.28s ease, box-shadow 0.28s ease;
  font-family: inherit;
}

.seg:hover { color: var(--text); }

.seg.active {
  color: #04121f;
  background: linear-gradient(180deg, #5fe6f7 0%, var(--accent) 100%);
  box-shadow: 0 4px 16px rgba(34, 211, 238, 0.35), inset 0 1px 0 rgba(255,255,255,0.4);
  font-weight: 600;
}

/* 音源控制行 */
.controls {
  display: flex;
  align-items: center;
  gap: 16px;
}

.ctrl-btn {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 10px 20px;
  border-radius: 999px;
  border: 1px solid var(--glass-line);
  background: var(--glass-fill);
  color: var(--text);
  font-size: 14px;
  letter-spacing: 0.04em;
  cursor: pointer;
  font-family: inherit;
  backdrop-filter: blur(14px) saturate(120%);
  -webkit-backdrop-filter: blur(14px) saturate(120%);
  transition: transform 0.18s ease, border-color 0.3s ease, background 0.3s ease, box-shadow 0.3s ease;
  box-shadow: 0 6px 22px rgba(0, 8, 24, 0.3);
}

.ctrl-btn:hover { transform: translateY(-1px); border-color: rgba(95, 230, 247, 0.4); }
.ctrl-btn:active { transform: translateY(0); }

.ctrl-icon {
  font-size: 11px;
  color: #ff5d6c;
  transition: color 0.3s ease, text-shadow 0.3s ease;
}

/* 麦克风已开启时的样式 */
.ctrl-btn.live .ctrl-icon { color: var(--accent); text-shadow: 0 0 8px var(--accent); animation: livePulse 1.6s ease-in-out infinite; }
.ctrl-btn.live { border-color: rgba(34, 211, 238, 0.5); }

@keyframes livePulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

/* 演示模式开关（自定义） */
.toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  color: var(--text-dim);
  font-size: 14px;
  letter-spacing: 0.04em;
}
.toggle input { display: none; }

.toggle-track {
  position: relative;
  width: 44px;
  height: 26px;
  border-radius: 999px;
  background: rgba(20, 40, 70, 0.55);
  border: 1px solid var(--glass-line);
  transition: background 0.3s ease, border-color 0.3s ease;
  flex: none;
}
.toggle-thumb {
  position: absolute;
  top: 2px; left: 2px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: #cfe9f5;
  box-shadow: 0 2px 6px rgba(0,0,0,0.35);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), background 0.3s ease;
}
.toggle input:checked + .toggle-track {
  background: linear-gradient(180deg, #2bd6ec, #14a7c4);
  border-color: rgba(95, 230, 247, 0.6);
}
.toggle input:checked + .toggle-track .toggle-thumb {
  transform: translateX(18px);
  background: #f0fbff;
}
.toggle input:checked ~ .toggle-text { color: var(--text); }

/* 提示文字 */
.hint {
  min-height: 18px;
  margin-top: 14px;
  font-size: 12.5px;
  letter-spacing: 0.03em;
  color: var(--text-faint);
  text-align: center;
  padding: 0 6vw;
  transition: color 0.3s ease, opacity 0.3s ease;
  max-width: 90vw;
}
.hint.warn { color: #ffb27a; }

/* 小屏适配 */
@media (max-width: 560px) {
  .hud { bottom: 34vh; }
  .controls { flex-direction: column; gap: 12px; }
  .seg { padding: 9px 13px; font-size: 12.5px; }
}
