:root {
  --bg: #0b1020;
  --card: rgba(255, 255, 255, 0.05);
  --line: rgba(255, 255, 255, 0.1);
  --text: #eaf0ff;
  --muted: #8f9bc4;
  --primary: #5b7cfa;
  --primary-2: #8a5bfa;
  --danger: #ff5a7a;
  --ok: #35d6a4;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: radial-gradient(1200px 800px at 20% -10%, #1b2450 0%, transparent 60%),
              radial-gradient(900px 700px at 100% 110%, #2a1b4d 0%, transparent 60%),
              var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  justify-content: center;
}

.app {
  width: 100%;
  max-width: 520px;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 20px 20px calc(20px + env(safe-area-inset-bottom));
}

/* ---------- 顶栏 ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.brand { display: flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 700; letter-spacing: .5px; }
.brand-dot { width: 10px; height: 10px; border-radius: 50%; background: linear-gradient(135deg, var(--primary), var(--primary-2)); box-shadow: 0 0 14px var(--primary); }
.badge { font-size: 11px; padding: 4px 9px; border-radius: 999px; border: 1px solid var(--line); white-space: nowrap; }
.badge-muted { color: var(--muted); }
.badge-live { color: var(--ok); border-color: rgba(53, 214, 164, .4); }
.badge-demo { color: #ffc861; border-color: rgba(255, 200, 97, .4); }

/* ---------- 人格条 ---------- */
.persona-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.persona-label { font-size: 12px; color: var(--muted); flex-shrink: 0; }
.personas { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; }
.personas::-webkit-scrollbar { display: none; }
.persona-chip {
  font-size: 12px; padding: 6px 11px; border-radius: 999px; white-space: nowrap;
  border: 1px solid var(--line); background: var(--card); color: var(--muted); cursor: pointer;
  transition: all .18s; flex-shrink: 0;
}
.persona-chip.active { color: #fff; border-color: rgba(91,124,250,.6); background: rgba(91,124,250,.22); }

/* ---------- 舞台 ---------- */
.stage { flex: 1; display: flex; flex-direction: column; align-items: center; min-height: 0; }
.orb-wrap { margin: 20px 0 4px; }
.orb { position: relative; width: 150px; height: 150px; display: grid; place-items: center; }
.orb-core {
  width: 96px; height: 96px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  display: grid; place-items: center; font-size: 42px;
  box-shadow: 0 10px 40px rgba(91, 124, 250, .45);
  z-index: 2; transition: transform .25s, background .3s;
}
.ring { position: absolute; inset: 0; margin: auto; border-radius: 50%; border: 1px solid rgba(91, 124, 250, .35); opacity: 0; }
.orb.listening .orb-core { background: linear-gradient(135deg, var(--danger), #ff8a5a); animation: pulse-core 1s ease-in-out infinite; }
.orb.listening .ring { animation: ripple 1.6s ease-out infinite; border-color: rgba(255,90,122,.4); }
.orb.listening .ring-2 { animation-delay: .5s; }
.orb.listening .ring-3 { animation-delay: 1s; }
.orb.thinking .orb-core { animation: pulse-core 1.2s ease-in-out infinite; }
.orb.speaking .orb-core { animation: pulse-core .7s ease-in-out infinite; background: linear-gradient(135deg, var(--ok), var(--primary)); }
@keyframes pulse-core { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.09); } }
@keyframes ripple { 0% { transform: scale(.75); opacity: .7; } 100% { transform: scale(1.5); opacity: 0; } }

.status-line { text-align: center; margin: 8px 0 16px; }
.phase { font-size: 20px; font-weight: 700; }
.hint { font-size: 13px; color: var(--muted); margin-top: 6px; min-height: 18px; }

/* ---------- 字幕 ---------- */
.captions {
  width: 100%; flex: 1; min-height: 140px; max-height: 46vh;
  overflow-y: auto; display: flex; flex-direction: column; gap: 10px;
  padding: 4px 2px 10px;
}
.captions::-webkit-scrollbar { width: 4px; }
.captions::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 4px; }
.caption-item {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; padding: 10px 14px; font-size: 14px; line-height: 1.55;
  animation: fade-in .25s ease;
}
.caption-item .role { display: block; font-size: 11px; color: var(--muted); margin-bottom: 3px; font-weight: 600; }
.caption-item.user { align-self: flex-end; background: rgba(91, 124, 250, .16); border-color: rgba(91, 124, 250, .3); }
.caption-item.assistant { align-self: flex-start; }
.caption-item.system .role { color: #ffc861; }
.caption-item.system { align-self: center; text-align: center; }
.caption-item .text { word-break: break-word; }
@keyframes fade-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- 控制区 ---------- */
.controls { display: flex; gap: 10px; align-items: center; justify-content: center; margin-top: 12px; }
.btn {
  border: 1px solid var(--line); background: var(--card); color: var(--text);
  border-radius: 999px; padding: 14px 16px; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: transform .15s, opacity .15s, background .2s;
  font-family: inherit; user-select: none; -webkit-user-select: none;
}
.btn:active { transform: scale(.96); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-ghost { min-width: 68px; font-size: 12px; padding: 12px 12px; }
.btn-ghost.off { color: var(--muted); }
.btn-talk {
  flex: 1; max-width: 240px; border: none; color: #fff; font-size: 17px; padding: 18px 20px;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  box-shadow: 0 8px 30px rgba(91, 124, 250, .4);
  touch-action: none;
}
.btn-talk .mic { margin-right: 6px; }
.btn-talk.recording {
  background: linear-gradient(135deg, var(--danger), #ff8a5a);
  box-shadow: 0 8px 30px rgba(255, 90, 122, .5);
  transform: scale(1.03);
}
.btn-talk.busy { opacity: .6; }

.footnote { text-align: center; font-size: 11px; color: var(--muted); margin-top: 14px; line-height: 1.6; }

@media (max-width: 380px) {
  .btn-ghost { min-width: 56px; padding: 12px 8px; font-size: 11px; }
  .orb { width: 130px; height: 130px; }
  .orb-core { width: 84px; height: 84px; font-size: 36px; }
}
