/* ===== 小水滴 · 清爽浅色企业风 v3 ===== */
:root {
  --bg: #f4f8fb;
  --bg-grad-a: #eaf3fa;
  --bg-grad-b: #f8fbfd;
  --ink: #17293c;
  --ink-dim: #5b7189;
  --ink-faint: #8fa3b8;
  --brand: #0066ff;
  --brand-deep: #0047c9;
  --aqua: #00a8cc;
  --teal: #00b894;
  --card: #ffffff;
  --card-soft: #f7fafd;
  --line: #e2eaf2;
  --line-strong: #c8d8e8;
  --shadow-sm: 0 1px 3px rgba(23, 41, 60, 0.06), 0 4px 14px rgba(23, 41, 60, 0.05);
  --shadow-md: 0 2px 6px rgba(23, 41, 60, 0.05), 0 16px 40px rgba(23, 41, 60, 0.09);
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --font: "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
html { color-scheme: light; }
body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, var(--bg-grad-a) 0%, var(--bg-grad-b) 40%, var(--bg) 100%);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  display: flex;
  justify-content: center;
  padding: 28px 24px;
  -webkit-font-smoothing: antialiased;
}

/* ---------- 背景氛围：柔和水面光斑 ---------- */
.backdrop { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.aurora { position: absolute; border-radius: 50%; filter: blur(80px); opacity: 0.55; }
.aurora-a {
  width: 620px; height: 620px; top: -260px; left: -140px;
  background: radial-gradient(circle, rgba(0, 102, 255, 0.12), transparent 65%);
  animation: drift-a 28s ease-in-out infinite alternate;
}
.aurora-b {
  width: 520px; height: 520px; bottom: -220px; right: -140px;
  background: radial-gradient(circle, rgba(0, 184, 148, 0.1), transparent 65%);
  animation: drift-b 34s ease-in-out infinite alternate;
}
.aurora-c {
  width: 400px; height: 400px; top: 26%; left: 56%;
  background: radial-gradient(circle, rgba(0, 168, 204, 0.09), transparent 65%);
  animation: drift-c 40s ease-in-out infinite alternate;
}
@keyframes drift-a { to { transform: translate(110px, 70px) scale(1.12); } }
@keyframes drift-b { to { transform: translate(-90px, -60px) scale(1.08); } }
@keyframes drift-c { to { transform: translate(-70px, 50px) scale(0.92); } }
.grid-overlay {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(0, 70, 201, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 70, 201, 0.04) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(ellipse 90% 70% at 50% 15%, black 30%, transparent 80%);
}
.bubble-field { position: absolute; inset: 0; }
.bubble-field::before, .bubble-field::after {
  content: "";
  position: absolute;
  width: 10px; height: 10px;
  border: 1px solid rgba(0, 102, 255, 0.18);
  border-radius: 50%;
  bottom: -20px;
  animation: rise 16s linear infinite;
}
.bubble-field::before { left: 12%; }
.bubble-field::after { left: 84%; width: 6px; height: 6px; animation-delay: 8s; animation-duration: 20s; }
@keyframes rise {
  0% { transform: translateY(0); opacity: 0; }
  10% { opacity: 0.6; }
  90% { opacity: 0.3; }
  100% { transform: translateY(-110vh); opacity: 0; }
}

/* ---------- 布局 ---------- */
.shell { width: min(1280px, 100%); display: flex; flex-direction: column; gap: 20px; position: relative; z-index: 1; }

/* ---------- 顶栏 ---------- */
.topbar { display: flex; justify-content: space-between; align-items: center; padding: 0 4px; }
.eyebrow {
  margin: 0 0 2px; font-size: 10px; letter-spacing: 0.3em;
  color: var(--ink-faint); text-transform: uppercase; font-weight: 600;
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark {
  width: 46px; height: 46px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  border-radius: 15px;
  background: linear-gradient(145deg, #e3f0ff, #d3f5f0);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-sm);
}
.brand h1 { margin: 0; font-size: 21px; font-weight: 800; letter-spacing: 0.04em; color: var(--ink); }
.top-actions { display: flex; align-items: center; gap: 10px; }
.admin-link {
  color: var(--ink);
  text-decoration: none;
  font-size: 13px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--card);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s;
}
.admin-link:hover { border-color: var(--brand); box-shadow: 0 4px 16px rgba(0, 102, 255, 0.14); transform: translateY(-1px); }
.status-pill {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--ink-dim);
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card);
  box-shadow: var(--shadow-sm);
}
.status-pill i {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--teal);
  box-shadow: 0 0 0 3px rgba(0, 184, 148, 0.15);
  animation: breathe 2.2s ease-in-out infinite;
}
@keyframes breathe { 50% { opacity: 0.4; } }

/* ---------- 舞台卡片 ---------- */
.stage-card {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  grid-template-rows: minmax(0, 1fr);
  gap: 20px;
  min-height: 640px;
  padding: 20px;
  border-radius: var(--radius-lg);
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-md);
}

/* 左列 */
.avatar-panel { display: grid; grid-template-rows: auto 1fr auto; gap: 14px; min-width: 0; }
.stage-answer-card {
  position: relative;
  padding: 16px 18px;
  border-radius: var(--radius-md);
  background: linear-gradient(160deg, #f2f7fd, #eef5fb);
  border: 1px solid var(--line);
  overflow: hidden;
}
.stage-answer-card::before {
  content: "";
  position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: linear-gradient(180deg, var(--brand), var(--aqua));
}
.stage-answer-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.stage-answer-head small { color: var(--brand); font-size: 11px; letter-spacing: 0.08em; font-weight: 600; }
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 10.5px; letter-spacing: 0.08em;
  color: var(--ink-dim);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 11px;
  background: var(--card);
}
.chip-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--brand); }
#stageQuestion { display: block; font-size: 16px; font-weight: 700; margin-bottom: 6px; color: var(--ink); }
#stageAnswer { margin: 0; font-size: 13.5px; line-height: 1.8; color: var(--ink); opacity: 0.85; white-space: pre-wrap; max-height: 110px; overflow-y: auto; }

.avatar {
  position: relative;
  min-height: 340px;
  border-radius: var(--radius-md);
  overflow: hidden;
  background:
    radial-gradient(560px 320px at 50% 118%, rgba(0, 168, 204, 0.14), transparent 70%),
    radial-gradient(420px 260px at 50% -60px, rgba(0, 102, 255, 0.08), transparent 70%),
    linear-gradient(180deg, #f0f7fd, #e9f2fa);
  border: 1px solid var(--line);
}
#avatarCanvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.scene-loading {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  font-size: 12px; color: var(--ink-dim); letter-spacing: 0.12em;
}
.spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(0, 102, 255, 0.2);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.scene-loading[hidden], .avatar-fallback[hidden] { display: none; }
.avatar-fallback {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 110px;
  animation: float 3.5s ease-in-out infinite;
}
@keyframes float { 50% { transform: translateY(-14px); } }

.avatar-caption { display: flex; flex-direction: column; gap: 10px; }
.avatar-name { display: flex; align-items: center; gap: 10px; }
.live-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--brand);
  box-shadow: 0 0 0 4px rgba(0, 102, 255, 0.12);
  animation: breathe 1.8s ease-in-out infinite;
}
.avatar-name strong { display: block; font-size: 15px; }
.avatar-name small { color: var(--ink-faint); font-size: 11.5px; }
.speech-bubble {
  position: relative;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  background: var(--card-soft);
  border: 1px solid var(--line-strong);
  font-size: 13px;
  line-height: 1.7;
  color: var(--ink);
  max-height: 88px;
  overflow-y: auto;
}

/* ---------- 右列：聊天 ---------- */
.chat-panel {
  display: flex; flex-direction: column; gap: 12px;
  padding: 18px;
  border-radius: var(--radius-md);
  background: linear-gradient(170deg, #fbfdff, #f4f9fd);
  border: 1px solid var(--line);
  min-width: 0;
  min-height: 0;
  max-height: 100%;
  overflow: hidden;
}
.panel-heading { display: flex; justify-content: space-between; align-items: center; }
.panel-heading h2 { margin: 0; font-size: 17px; font-weight: 800; letter-spacing: 0.03em; }
.icon-button {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--card);
  color: var(--ink-dim);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  font-size: 12px;
  padding: 7px 12px;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}
.icon-button:hover { border-color: var(--brand); color: var(--brand); box-shadow: 0 2px 10px rgba(0, 102, 255, 0.1); }
.icon-button.off { opacity: 0.5; }

.messages {
  flex: 1 1 0;
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 12px;
  min-height: 200px;
  max-height: 540px;
  padding: 4px 6px 4px 2px;
  scroll-behavior: smooth;
}
.messages::-webkit-scrollbar, #stageAnswer::-webkit-scrollbar, .speech-bubble::-webkit-scrollbar { width: 4px; }
.messages::-webkit-scrollbar-thumb, #stageAnswer::-webkit-scrollbar-thumb, .speech-bubble::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 4px;
}
.message { display: flex; gap: 10px; max-width: 94%; animation: msg-in 0.3s ease; }
@keyframes msg-in { from { opacity: 0; transform: translateY(8px); } }
.message-avatar {
  flex: 0 0 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
  border-radius: 10px;
  background: linear-gradient(145deg, var(--brand), var(--aqua));
  color: #fff;
  box-shadow: 0 4px 12px rgba(0, 102, 255, 0.3);
}
.message.user { flex-direction: row-reverse; align-self: flex-end; }
.message.user .message-avatar {
  background: linear-gradient(145deg, #8697ab, #5d7086);
  box-shadow: none;
}
.message > div {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 4px 14px 14px 14px;
  padding: 10px 14px;
  font-size: 13px;
  line-height: 1.75;
  box-shadow: var(--shadow-sm);
}
.message.user > div {
  background: linear-gradient(140deg, #0d6cff, #0053e0);
  border-color: transparent;
  color: #fff;
  border-radius: 14px 4px 14px 14px;
}
.message time { display: block; margin-top: 5px; font-size: 10px; color: var(--ink-faint); letter-spacing: 0.06em; }
.message.user time { color: rgba(255, 255, 255, 0.7); }
.src-tag {
  display: inline-flex; align-items: center; gap: 5px;
  margin-top: 7px;
  font-size: 10px; letter-spacing: 0.05em;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid rgba(0, 184, 148, 0.35);
  color: #00805f;
  background: rgba(0, 184, 148, 0.07);
}
.src-tag[data-source="llm"] { border-color: rgba(0, 102, 255, 0.3); color: var(--brand-deep); background: rgba(0, 102, 255, 0.06); }
.src-tag[data-source="fallback"] { border-color: rgba(214, 140, 0, 0.4); color: #a06a00; background: rgba(255, 184, 0, 0.08); }

.suggestions { display: flex; flex-wrap: wrap; gap: 8px; }
.suggestions button {
  background: var(--card);
  color: var(--ink-dim);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  font-size: 12px;
  padding: 7px 14px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s;
}
.suggestions button:hover {
  border-color: var(--brand);
  color: var(--brand);
  background: rgba(0, 102, 255, 0.04);
  transform: translateY(-1px);
}

.composer { display: flex; gap: 10px; }
.composer input {
  flex: 1;
  min-width: 0;
  background: var(--card);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  color: var(--ink);
  padding: 12px 16px;
  font-size: 13.5px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.25s, box-shadow 0.25s;
}
.composer input::placeholder { color: var(--ink-faint); }
.composer input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(0, 102, 255, 0.12);
}
.send-button {
  background: linear-gradient(140deg, #0d6cff, #0053e0);
  color: #fff;
  border: 0;
  border-radius: var(--radius-sm);
  padding: 0 24px;
  font-size: 13px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  letter-spacing: 0.08em;
  box-shadow: 0 6px 16px rgba(0, 102, 255, 0.3);
  transition: transform 0.15s, box-shadow 0.2s;
}
.send-button:hover { transform: translateY(-1px); box-shadow: 0 8px 22px rgba(0, 102, 255, 0.4); }
.send-button:active { transform: translateY(0); }

/* ---------- 底部统计 ---------- */
.dashboard-strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.dashboard-strip > div {
  display: flex; flex-direction: column; gap: 2px;
  padding: 15px 18px;
  border-radius: var(--radius-md);
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s, box-shadow 0.2s;
}
.dashboard-strip > div:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.dashboard-strip span { font-size: 11px; color: var(--ink-faint); letter-spacing: 0.14em; }
.dashboard-strip strong { font-size: 20px; font-weight: 800; color: var(--ink); }
.dashboard-strip small { font-size: 10.5px; color: var(--ink-faint); }

/* ---------- 响应式 ---------- */
@media (max-width: 960px) {
  body { padding: 14px 12px; }
  .stage-card { grid-template-columns: 1fr; min-height: unset; }
  .dashboard-strip { grid-template-columns: repeat(2, 1fr); }
  .brand h1 { font-size: 18px; }
  .avatar { min-height: 300px; }
}
@media (max-width: 520px) {
  .topbar { flex-direction: column; gap: 12px; }
  .messages { min-height: 160px; }
}
@media (prefers-reduced-motion: reduce) {
  .aurora, .bubble-field::before, .bubble-field::after { animation: none; }
}

.mic-button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--card);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  color: var(--ink-dim);
  font-size: 12.5px;
  font-family: inherit;
  padding: 9px 14px;
  cursor: pointer;
  transition: all 0.2s;
  width: 100%;
}
.mic-button:hover { border-color: var(--brand); color: var(--brand); }
.mic-button.recording {
  border-style: solid;
  border-color: #e5484d;
  color: #e5484d;
  background: #fff5f5;
  animation: mic-pulse 1.2s ease-in-out infinite;
}
@keyframes mic-pulse { 50% { box-shadow: 0 0 0 6px rgba(229, 72, 77, 0.1); } }
.mic-button[hidden] { display: none; }

.voice-row { display: flex; gap: 10px; }
.voice-row[hidden] { display: none; }
.mic-button.live { border-style: solid; color: var(--brand); border-color: var(--line-strong); }
.mic-button.live.on {
  color: #fff; border-color: var(--brand); background: linear-gradient(140deg, #0d6cff, #0053e0);
  animation: none;
}
