/* ==========================================================
   设计令牌 Design Tokens
   主题：近未来控制台 / 全息终端（避免常见的纯黑+荧光绿黑客风）
   ========================================================== */
:root {
  --void: #0B0E1A;        /* 深空背景 */
  --panel: #131A2E;       /* 面板底色 */
  --panel-2: #0F1526;     /* 面板深色变体 */
  --line: rgba(110, 231, 216, 0.22);   /* 描边 */
  --line-strong: rgba(110, 231, 216, 0.45);
  --signal: #6EE7D8;      /* 主信号色：薄荷青 */
  --pulse: #FF8A5B;       /* 强调色：珊瑚橙（说话/激活状态） */
  --mist: #8C97B2;        /* 次要文字 */
  --frost: #F1F4FA;       /* 主文字 */

  --font-display: 'Space Grotesk', 'PingFang SC', sans-serif;
  --font-body: 'Inter', 'PingFang SC', sans-serif;
  --font-mono: 'JetBrains Mono', 'Consolas', monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: var(--void);
  color: var(--frost);
  font-family: var(--font-body);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

#app {
  position: relative;
  width: 100vw;
  height: 100vh;
  background:
    radial-gradient(ellipse at 65% 40%, rgba(110,231,216,0.08), transparent 55%),
    radial-gradient(ellipse at 20% 85%, rgba(255,138,91,0.06), transparent 50%),
    var(--void);
}

/* 网格背景纹理，营造"控制台"氛围 */
#app::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 64px 64px;
  opacity: 0.12;
  pointer-events: none;
}

#scene-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* ================= HUD 边角装饰 ================= */
.hud-corner {
  position: absolute;
  width: 28px;
  height: 28px;
  border: 2px solid var(--line-strong);
  opacity: 0.8;
  pointer-events: none;
  z-index: 5;
}
.hud-corner--tl { top: 18px; left: 18px; border-right: none; border-bottom: none; }
.hud-corner--tr { top: 18px; right: 18px; border-left: none; border-bottom: none; }
.hud-corner--bl { bottom: 18px; left: 18px; border-right: none; border-top: none; }
.hud-corner--br { bottom: 18px; right: 18px; border-left: none; border-top: none; }

/* ================= 顶部状态栏 ================= */
.hud-topbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 26px 56px;
  pointer-events: none;
}

.hud-brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-family: var(--font-display);
}
.hud-brand__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--signal);
  box-shadow: 0 0 8px 2px var(--signal);
  display: inline-block;
  transition: background 0.3s, box-shadow 0.3s;
}
.hud-brand__dot.speaking {
  background: var(--pulse);
  box-shadow: 0 0 10px 3px var(--pulse);
  animation: pulseDot 0.9s ease-in-out infinite;
}
@keyframes pulseDot {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.5); }
}
.hud-brand__text {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.hud-brand__sub {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  color: var(--mist);
}

.hud-status {
  display: flex;
  align-items: center;
  gap: 18px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--signal);
  letter-spacing: 0.05em;
}
.hud-clock {
  color: var(--mist);
  min-width: 78px;
  text-align: right;
}

/* ================= 语音选择器 ================= */
.voice-picker {
  position: absolute;
  top: 90px;
  right: 56px;
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--mist);
  letter-spacing: 0.08em;
}
.voice-picker select {
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--frost);
  font-family: var(--font-body);
  font-size: 13px;
  padding: 6px 10px;
  border-radius: 6px;
  outline: none;
  cursor: pointer;
}
.voice-picker select:focus {
  border-color: var(--signal);
}

/* ================= 对话记录 ================= */
.chat-log {
  position: absolute;
  left: 40px;
  bottom: 118px;
  top: 140px;
  width: 380px;
  max-width: 40vw;
  z-index: 6;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-right: 6px;
}
.chat-log::-webkit-scrollbar { width: 4px; }
.chat-log::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 2px; }

.chat-bubble {
  background: rgba(19, 26, 46, 0.78);
  border: 1px solid var(--line);
  border-left: 2px solid var(--signal);
  border-radius: 4px;
  padding: 12px 14px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--frost);
  backdrop-filter: blur(6px);
  animation: bubbleIn 0.25s ease-out;
}
.chat-bubble__meta {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--mist);
  letter-spacing: 0.08em;
  margin-bottom: 4px;
  display: block;
}
.chat-bubble--error {
  border-left-color: var(--pulse);
}
.chat-bubble--error .chat-bubble__meta {
  color: var(--pulse);
}

@keyframes bubbleIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ================= 输入区 ================= */
.input-dock {
  position: absolute;
  left: 40px;
  right: 40px;
  bottom: 32px;
  z-index: 6;
  display: flex;
  gap: 12px;
  max-width: 900px;
}

#textInput {
  flex: 1;
  background: rgba(19, 26, 46, 0.85);
  border: 1px solid var(--line);
  color: var(--frost);
  font-family: var(--font-body);
  font-size: 15px;
  padding: 16px 20px;
  border-radius: 8px;
  outline: none;
  backdrop-filter: blur(8px);
  transition: border-color 0.2s, box-shadow 0.2s;
}
#textInput::placeholder { color: var(--mist); }
#textInput:focus {
  border-color: var(--signal);
  box-shadow: 0 0 0 3px rgba(110, 231, 216, 0.12);
}

#sendBtn {
  background: var(--signal);
  color: var(--void);
  border: none;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.02em;
  padding: 0 32px;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.15s, background 0.15s, opacity 0.15s;
}
#sendBtn:hover { background: #82f0e2; }
#sendBtn:active { transform: scale(0.97); }
#sendBtn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ================= 响应式（移动端） ================= */
@media (max-width: 720px) {
  .hud-topbar { padding: 18px 20px; }
  .hud-brand__sub { display: none; }
  .voice-picker { top: 78px; right: 20px; }
  .chat-log {
    left: 20px;
    right: 20px;
    width: auto;
    max-width: none;
    top: 130px;
    bottom: 104px;
  }
  .input-dock { left: 16px; right: 16px; bottom: 16px; }
  #sendBtn { padding: 0 20px; }
  .hud-corner { display: none; }
}

/* 尊重"减少动画"系统设置 */
@media (prefers-reduced-motion: reduce) {
  .hud-brand__dot.speaking { animation: none; }
  .chat-bubble { animation: none; }
}
