/* ============ 3D 数字人语音对话 —— 样式 ============ */
:root {
  --bg: #eef0f4;
  --panel: #ffffff;
  --ink: #1c2333;
  --ink-2: #5a6478;
  --line: #dfe3ea;
  --brand: #2b3f66;
  --brand-2: #4a6bb5;
  --accent: #1e2a46;
  --ok: #2e9e6b;
  --warn: #d9a441;
  --err: #d26a5a;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(24, 34, 56, 0.10);
  font-size: 15px;
}

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

html, body { height: 100%; }
body {
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  overflow: hidden;
}

.app { display: flex; flex-direction: column; height: 100vh; }

/* ============ 顶部栏 ============ */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-2), var(--brand));
  box-shadow: 0 0 0 4px rgba(74, 107, 181, 0.15);
}
.brand h1 { font-size: 17px; font-weight: 700; letter-spacing: 0.5px; }
.brand h1 em { font-style: normal; font-weight: 500; color: var(--ink-2); font-size: 13px; margin-left: 6px; }

.topbar-right { display: flex; align-items: center; gap: 10px; }
.mode-badge {
  font-size: 12px; padding: 4px 10px; border-radius: 999px;
  background: #fdf3dd; color: #9a6b16; border: 1px solid #f0dfb2;
}
.mode-badge.llm { background: #e4f5ec; color: #1d7a52; border-color: #bfe5d2; }
.mode-badge.err { background: #fbe9e6; color: #b04a3a; border-color: #f0cdc5; }

.ghost-btn {
  border: 1px solid var(--line); background: #fff; color: var(--ink-2);
  padding: 6px 14px; border-radius: 9px; cursor: pointer; font-size: 13px;
  transition: all 0.15s;
}
.ghost-btn:hover { border-color: var(--brand-2); color: var(--brand); }

/* ============ 主布局 ============ */
.layout {
  flex: 1; display: flex; gap: 16px;
  padding: 16px 20px 20px;
  min-height: 0;
}

/* ---- 3D 舞台 ---- */
.stage-wrap {
  flex: 1.5; position: relative; border-radius: var(--radius);
  overflow: hidden; background: #e9ebf0;
  box-shadow: var(--shadow); min-width: 0;
}
#stage { width: 100%; height: 100%; display: block; }

.status-pill {
  position: absolute; top: 16px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px;
  padding: 7px 16px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.9); backdrop-filter: blur(8px);
  font-size: 13px; color: var(--ink-2);
  box-shadow: 0 4px 14px rgba(24, 34, 56, 0.12);
  transition: all 0.25s;
}
.status-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: #9aa2b5; transition: background 0.25s; }
.status-pill.listen .dot { background: var(--ok); animation: pulse 1.1s infinite; }
.status-pill.think .dot { background: var(--warn); animation: pulse 0.7s infinite; }
.status-pill.speak .dot { background: var(--brand-2); animation: pulse 0.5s infinite; }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(46, 158, 107, 0.4); }
  50% { box-shadow: 0 0 0 6px rgba(46, 158, 107, 0); }
}

.subtitle {
  position: absolute; left: 50%; bottom: 46px; transform: translateX(-50%);
  max-width: 78%;
  padding: 10px 20px; border-radius: 12px;
  background: rgba(28, 35, 51, 0.82); color: #fff;
  font-size: 15.5px; line-height: 1.6; text-align: center;
  backdrop-filter: blur(6px);
  transition: opacity 0.2s;
  pointer-events: none;
}
.subtitle:empty { opacity: 0; }

.stage-hint {
  position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%);
  font-size: 12px; color: #8a93a6; white-space: nowrap;
  background: rgba(255,255,255,0.65); padding: 3px 12px; border-radius: 999px;
  pointer-events: none;
}

/* ---- 开始遮罩 ---- */
.overlay {
  position: absolute; inset: 0; z-index: 20;
  display: flex; align-items: center; justify-content: center;
  background: rgba(233, 235, 240, 0.88); backdrop-filter: blur(10px);
  transition: opacity 0.45s, visibility 0.45s;
}
.overlay.hide { opacity: 0; visibility: hidden; }
.overlay-card { text-align: center; padding: 20px; }
.overlay-avatar { font-size: 54px; margin-bottom: 12px; }
.overlay-card h2 { font-size: 22px; margin-bottom: 10px; }
.overlay-card p { color: var(--ink-2); line-height: 1.8; margin-bottom: 22px; }
.overlay-tip { font-size: 12px; color: #98a0b2; margin-top: 14px; margin-bottom: 0; }

.primary-btn {
  border: none; cursor: pointer;
  padding: 12px 44px; border-radius: 999px;
  font-size: 16px; font-weight: 600; color: #fff;
  background: linear-gradient(135deg, #3d5a94, var(--brand));
  box-shadow: 0 8px 22px rgba(43, 63, 102, 0.35);
  transition: transform 0.15s, box-shadow 0.15s;
}
.primary-btn:hover { transform: translateY(-2px); box-shadow: 0 12px 26px rgba(43, 63, 102, 0.42); }

/* ---- 对话面板 ---- */
.chat-panel {
  width: 380px; flex-shrink: 0;
  display: flex; flex-direction: column;
  background: var(--panel); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
}
.chat-head {
  padding: 14px 18px; font-weight: 700; font-size: 14px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #fbfcfe, #f5f7fb);
}

.chat-list {
  flex: 1; overflow-y: auto; padding: 16px 14px;
  display: flex; flex-direction: column; gap: 14px;
}
.chat-list::-webkit-scrollbar { width: 6px; }
.chat-list::-webkit-scrollbar-thumb { background: #d3d8e2; border-radius: 3px; }

.bubble-row { display: flex; gap: 8px; align-items: flex-start; }
.bubble-row.user { flex-direction: row-reverse; }
.bubble-avatar {
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, #4a6bb5, #2b3f66);
}
.bubble-row.user .bubble-avatar { background: linear-gradient(135deg, #e79c8f, #c9685a); }
.bubble {
  max-width: 76%;
  padding: 10px 14px; border-radius: 14px;
  font-size: 14px; line-height: 1.65; white-space: pre-wrap; word-break: break-word;
  background: #f2f4f8; color: var(--ink);
  border-top-left-radius: 4px;
}
.bubble-row.user .bubble {
  background: linear-gradient(135deg, #3d5a94, #2b3f66);
  color: #fff; border-top-left-radius: 14px; border-top-right-radius: 4px;
}
.bubble:empty::after { content: "…"; color: #9aa2b5; animation: blink-dots 1s infinite; }
@keyframes blink-dots { 50% { opacity: 0.3; } }

/* ---- 输入区 ---- */
.input-area { padding: 14px; border-top: 1px solid var(--line); background: #fbfcfe; }
.mic-btn {
  width: 100%; display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 13px; border-radius: 12px; border: 1px solid var(--line);
  background: #fff; cursor: pointer; font-size: 14.5px; font-weight: 600;
  color: var(--brand); transition: all 0.2s;
}
.mic-btn svg { width: 19px; height: 19px; }
.mic-btn:hover { border-color: var(--brand-2); background: #f6f9ff; }
.mic-btn.listening {
  background: linear-gradient(135deg, #35b37e, #2e9e6b);
  border-color: transparent; color: #fff;
  animation: mic-pulse 1.4s infinite;
}
@keyframes mic-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(46, 158, 107, 0.45); }
  50% { box-shadow: 0 0 0 10px rgba(46, 158, 107, 0); }
}

.text-row { display: flex; gap: 8px; margin-top: 10px; }
#chatInput {
  flex: 1; padding: 11px 14px; border-radius: 10px;
  border: 1px solid var(--line); font-size: 14px; outline: none;
  transition: border 0.15s;
}
#chatInput:focus { border-color: var(--brand-2); }
.send-btn {
  width: 42px; border-radius: 10px; border: none; cursor: pointer;
  background: linear-gradient(135deg, #3d5a94, var(--brand));
  color: #fff; display: flex; align-items: center; justify-content: center;
}
.send-btn svg { width: 17px; height: 17px; transform: translateX(1px); }
.send-btn:hover { filter: brightness(1.12); }

/* ============ 弹窗 ============ */
.modal {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  background: rgba(24, 32, 50, 0.35); backdrop-filter: blur(4px);
  opacity: 0; visibility: hidden; transition: all 0.25s;
}
.modal.show { opacity: 1; visibility: visible; }
.modal-card {
  width: min(420px, 92vw);
  background: #fff; border-radius: 16px;
  box-shadow: 0 24px 60px rgba(20, 28, 45, 0.25);
  transform: translateY(14px) scale(0.97); transition: transform 0.25s;
}
.modal.show .modal-card { transform: none; }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--line);
}
.modal-head h3 { font-size: 15px; }
.modal-close {
  border: none; background: none; font-size: 22px; line-height: 1;
  color: var(--ink-2); cursor: pointer;
}
.modal-body { padding: 18px 20px 20px; display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 7px; font-size: 13.5px; color: var(--ink-2); }
.field b { color: var(--brand); }
.field select {
  padding: 9px 10px; border-radius: 9px; border: 1px solid var(--line);
  font-size: 13.5px; outline: none; background: #fff;
}
.field input[type="range"] { accent-color: var(--brand-2); }
.field.row { flex-direction: row; align-items: center; gap: 9px; }
.field.row input { width: 16px; height: 16px; accent-color: var(--brand-2); }
.modal-tip { font-size: 12px; color: #98a0b2; line-height: 1.7; }
.modal-tip code {
  background: #f0f2f7; padding: 1px 6px; border-radius: 5px;
  font-family: Consolas, monospace; font-size: 11.5px; color: var(--brand);
}

/* ============ Toast ============ */
.toast-box {
  position: fixed; top: 70px; left: 50%; transform: translateX(-50%);
  z-index: 80; display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none;
}
.toast {
  padding: 10px 20px; border-radius: 10px;
  background: rgba(28, 35, 51, 0.92); color: #fff;
  font-size: 13.5px; box-shadow: 0 10px 26px rgba(20, 28, 45, 0.3);
  opacity: 0; transform: translateY(-8px); transition: all 0.3s;
}
.toast.show { opacity: 1; transform: none; }

/* ============ 响应式 ============ */
@media (max-width: 900px) {
  .layout { flex-direction: column; }
  .chat-panel { width: auto; flex: 1; min-height: 240px; }
  .stage-wrap { min-height: 46vh; }
}
