/* ============ 情感陪护虚拟数字人 Demo ============ */
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --bg: #0b1220;
  --bg2: #111a2e;
  --panel: rgba(17, 26, 46, 0.85);
  --line: rgba(148, 163, 184, 0.15);
  --txt: #e2e8f0;
  --dim: #94a3b8;
  --accent: #6ee7b7;
  --accent2: #7dd3fc;
}
html, body { height: 100%; }
body {
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  background: radial-gradient(1200px 700px at 30% 20%, #16213f 0%, var(--bg) 55%);
  color: var(--txt);
  overflow: hidden;
}
#app { display: flex; flex-direction: column; height: 100vh; }

/* ---------------- 顶部栏 ---------------- */
#topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 22px; border-bottom: 1px solid var(--line);
  background: rgba(11, 18, 32, 0.6); backdrop-filter: blur(8px);
  z-index: 10;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  width: 40px; height: 40px; border-radius: 12px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #06251b; font-weight: 800; font-size: 20px;
  box-shadow: 0 4px 20px rgba(110, 231, 183, 0.35);
}
h1 { font-size: 19px; font-weight: 700; }
h1 .sub { font-size: 12px; font-weight: 400; color: var(--dim); margin-left: 6px; }
.top-controls { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }

.badge {
  padding: 5px 12px; border-radius: 999px; font-size: 12.5px;
  border: 1px solid var(--line); background: rgba(148, 163, 184, 0.08);
  transition: all .3s;
}
.avatar-switch { display: flex; gap: 6px; }
.avatar-btn {
  padding: 6px 14px; border-radius: 999px; font-size: 13px;
  background: rgba(148, 163, 184, 0.1); color: var(--dim);
  border: 1px solid var(--line); cursor: pointer; transition: all .2s;
}
.avatar-btn:hover { color: var(--txt); }
.avatar-btn.active { background: var(--accent); color: #06251b; border-color: var(--accent); font-weight: 600; }
.toggles { display: flex; gap: 6px; }
.toggle {
  padding: 6px 12px; border-radius: 999px; font-size: 12.5px; cursor: pointer;
  background: rgba(148, 163, 184, 0.08); color: var(--dim);
  border: 1px solid var(--line); transition: all .2s;
}
.toggle.on { background: rgba(110, 231, 183, 0.14); color: var(--accent); border-color: rgba(110, 231, 183, 0.4); }

/* ---------------- 主区 ---------------- */
#main { flex: 1; display: flex; min-height: 0; }
#stage-panel { flex: 1.6; position: relative; min-width: 0; }
#chat-panel {
  flex: 1; display: flex; flex-direction: column;
  border-left: 1px solid var(--line); background: var(--panel);
  backdrop-filter: blur(10px); min-width: 360px; max-width: 480px;
}

#stage {
  position: absolute; inset: 0;
  background: radial-gradient(900px 500px at 50% 30%, rgba(125, 211, 252, 0.10), transparent 60%);
}
#stage canvas { width: 100% !important; height: 100% !important; }

.stage-overlay {
  position: absolute; left: 22px; bottom: 22px;
  display: flex; flex-direction: column; gap: 10px;
  background: rgba(11, 18, 32, 0.55); border: 1px solid var(--line);
  border-radius: 16px; padding: 14px 18px; backdrop-filter: blur(6px);
  min-width: 220px;
}
.state-cards { display: flex; gap: 18px; }
.card { flex: 1; }
.card-label { font-size: 11px; color: var(--dim); margin-bottom: 5px; }
.bar { height: 6px; border-radius: 3px; background: rgba(148, 163, 184, 0.15); overflow: hidden; }
.bar-fill { height: 100%; width: 50%; border-radius: 3px; transition: width .5s ease; background: var(--accent); }
.trend { font-size: 12px; color: var(--dim); }

/* ---------------- 对话面板 ---------------- */
.chat-head {
  padding: 12px 18px; border-bottom: 1px solid var(--line);
  font-size: 14px; font-weight: 600; display: flex;
  justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap;
}
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent); margin-right: 6px; box-shadow: 0 0 8px var(--accent); }
.status-pills { display: flex; gap: 6px; flex-wrap: wrap; }
.pill { font-size: 11px; color: var(--dim); background: rgba(148,163,184,.08);
  padding: 3px 8px; border-radius: 999px; white-space: nowrap; }

#chat-log {
  flex: 1; overflow-y: auto; padding: 18px 16px;
  display: flex; flex-direction: column; gap: 12px;
}
#chat-log::-webkit-scrollbar { width: 5px; }
#chat-log::-webkit-scrollbar-thumb { background: rgba(148,163,184,.25); border-radius: 3px; }

.msg { display: flex; }
.msg.user { justify-content: flex-end; }
.msg.ai { justify-content: flex-start; }
.bubble {
  max-width: 78%; padding: 10px 14px; border-radius: 16px;
  font-size: 14px; line-height: 1.65; word-break: break-word;
  background: rgba(110, 231, 183, 0.12); color: var(--txt);
  border: 1px solid rgba(110, 231, 183, 0.25);
  border-bottom-right-radius: 4px;
}
.ai-bubble {
  background: rgba(125, 211, 252, 0.10); border-color: rgba(125, 211, 252, 0.2);
  border-bottom-left-radius: 4px; border-bottom-right-radius: 16px;
}
.sys {
  text-align: center; font-size: 12px; color: var(--dim);
  padding: 4px 10px; align-self: center;
}
.sys.hint { color: #cbd5e1; }

#input-bar {
  display: flex; align-items: flex-end; gap: 8px;
  padding: 12px 14px; border-top: 1px solid var(--line);
}
#btn-mic {
  width: 42px; height: 42px; border-radius: 12px; font-size: 18px;
  border: 1px solid var(--line); background: rgba(148,163,184,.08);
  cursor: pointer; transition: all .2s; flex-shrink: 0;
}
#btn-mic:hover { background: rgba(148,163,184,.18); }
#btn-mic.recording { background: #f87171; border-color: #f87171; animation: pulse 1.2s infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(248,113,113,.5);} 50% { box-shadow: 0 0 0 8px rgba(248,113,113,0);} }

#input-text {
  flex: 1; resize: none; padding: 11px 14px; border-radius: 12px;
  border: 1px solid var(--line); background: rgba(148,163,184,.07);
  color: var(--txt); font-size: 14px; font-family: inherit; line-height: 1.5;
  outline: none; max-height: 96px;
}
#input-text:focus { border-color: var(--accent); }
.send {
  padding: 11px 20px; border-radius: 12px; border: none;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #06251b; font-weight: 700; font-size: 14px; cursor: pointer;
  flex-shrink: 0; transition: all .2s;
}
.send:hover { filter: brightness(1.1); }
.send:disabled { opacity: .5; cursor: wait; }

/* ---------------- 设置弹窗 ---------------- */
.modal {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(5, 10, 20, 0.7); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  opacity: 1; transition: opacity .2s;
}
.modal.hidden { display: none; }
.modal-box {
  width: 460px; max-width: 92vw; max-height: 88vh; overflow-y: auto;
  background: #0f1a2e; border: 1px solid var(--line); border-radius: 18px;
  padding: 22px 26px; box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.modal-box h2 { font-size: 18px; margin-bottom: 4px; }
.modal-sub { font-size: 12px; color: var(--dim); margin-bottom: 14px; }
.section-title {
  font-size: 12px; color: var(--accent2); font-weight: 600;
  margin: 16px 0 6px; padding-top: 10px; border-top: 1px dashed var(--line);
}
.field { margin-bottom: 10px; }
.field label { display: block; font-size: 12px; color: var(--dim); margin-bottom: 4px; }
.field input, .field select {
  width: 100%; padding: 9px 11px; border-radius: 10px;
  border: 1px solid var(--line); background: rgba(148,163,184,.08);
  color: var(--txt); font-size: 13px; outline: none; font-family: inherit;
}
.field input:focus, .field select:focus { border-color: var(--accent); }
.field .hint { font-size: 11px; color: var(--dim); margin-top: 3px; line-height: 1.5; }
.modal-status {
  min-height: 20px; font-size: 12.5px; margin: 10px 0 4px;
  color: var(--accent); word-break: break-all; line-height: 1.5;
}
.modal-status.err { color: #f87171; }
.modal-status.ok { color: var(--accent); }
.modal-actions { display: flex; gap: 8px; margin-top: 14px; justify-content: flex-end; }
.modal-actions button {
  padding: 9px 16px; border-radius: 10px; font-size: 13px; cursor: pointer;
  border: 1px solid var(--line); transition: all .2s;
}
.btn-primary { background: var(--accent); color: #06251b; font-weight: 700; border: none !important; }
.btn-primary:hover { filter: brightness(1.1); }
.btn-secondary { background: rgba(148,163,184,.12); color: var(--txt); }
.btn-secondary:hover { background: rgba(148,163,184,.22); }
.btn-ghost { background: transparent; color: var(--dim); }
.btn-ghost:hover { color: var(--txt); }

/* 摄像头小窗 */
#camera-video {
  position: fixed; right: 400px; bottom: 20px; width: 200px;
  border-radius: 12px; border: 2px solid rgba(110,231,183,.4);
  box-shadow: 0 8px 30px rgba(0,0,0,.5); z-index: 20; display: none;
  transform: scaleX(-1);
}

@media (max-width: 900px) {
  #main { flex-direction: column; }
  #chat-panel { max-width: none; min-width: 0; height: 46vh; }
}
