/* ================================================
   逍遥DAO — AI分身对话界面 chat.css
   庄子全息形象 + 粒子光环 + 3D效果 + 对话气泡
   ================================================ */

/* ── CSS Variables ── */
:root {
  --chat-bg: #05070d;
  --chat-bg-2: #0a0e1a;
  --chat-surface: rgba(255,255,255,0.03);
  --chat-border: rgba(255,255,255,0.06);
  --chat-gold: #c9a84c;
  --chat-gold-l: #e8d48b;
  --chat-gold-glow: rgba(201,168,76,0.3);
  --chat-cyan: #4ecdc4;
  --chat-cyan-l: #7eddd6;
  --chat-cyan-glow: rgba(78,205,196,0.3);
  --chat-t1: #f0ede4;
  --chat-t2: rgba(240,237,228,0.65);
  --chat-t3: rgba(240,237,228,0.35);
  --chat-bubble-ai: rgba(78,205,196,0.06);
  --chat-bubble-ai-border: rgba(78,205,196,0.15);
  --chat-bubble-user: rgba(201,168,76,0.08);
  --chat-bubble-user-border: rgba(201,168,76,0.2);
  --chat-radius: 16px;
  --chat-panel-bg: rgba(5,7,13,0.85);
}

[data-theme="light"] {
  --chat-bg: #f5f3ee;
  --chat-bg-2: #eae7e0;
  --chat-surface: rgba(0,0,0,0.03);
  --chat-border: rgba(0,0,0,0.08);
  --chat-t1: #1a1a1a;
  --chat-t2: rgba(26,26,26,0.65);
  --chat-t3: rgba(26,26,26,0.4);
  --chat-bubble-ai: rgba(78,205,196,0.08);
  --chat-bubble-ai-border: rgba(78,205,196,0.25);
  --chat-bubble-user: rgba(201,168,76,0.08);
  --chat-bubble-user-border: rgba(201,168,76,0.25);
  --chat-panel-bg: rgba(245,243,238,0.9);
  --chat-cyan-glow: rgba(78,205,196,0.15);
  --chat-gold-glow: rgba(201,168,76,0.15);
}

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  font-family: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--chat-bg);
  color: var(--chat-t1);
  min-height: 100vh;
  overflow: hidden;
}

/* ── Layout: sidebar + main ── */
.chat-layout {
  display: flex;
  height: 100vh;
  width: 100%;
}

/* ============================================================
   LEFT: Avatar Panel — 3D Holographic Zhuangzi
   ============================================================ */
.avatar-panel {
  width: 380px;
  min-width: 380px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 24px 24px;
  border-right: 1px solid var(--chat-border);
  position: relative;
  overflow: hidden;
  background: var(--chat-panel-bg);
  backdrop-filter: blur(30px);
}

/* deep background glow */
.avatar-panel::before {
  content: '';
  position: absolute;
  top: 30%; left: 50%;
  width: 400px; height: 400px;
  background: radial-gradient(circle, var(--chat-cyan-glow) 0%, transparent 60%);
  transform: translate(-50%, -50%);
  animation: holoPulse 5s ease-in-out infinite;
  pointer-events: none;
  z-index: 0;
}

.avatar-panel::after {
  content: '';
  position: absolute;
  bottom: 10%; left: 50%;
  width: 300px; height: 200px;
  background: radial-gradient(ellipse, var(--chat-gold-glow) 0%, transparent 70%);
  transform: translate(-50%, 0);
  animation: holoPulse 7s ease-in-out infinite reverse;
  pointer-events: none;
  z-index: 0;
}

@keyframes holoPulse {
  0%, 100% { opacity: 0.3; transform: translate(-50%, -50%) scale(1); }
  50% { opacity: 0.6; transform: translate(-50%, -50%) scale(1.15); }
}

/* holographic particle canvas */
.holo-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

/* ── 3D Avatar Container ── */
.avatar-3d-wrap {
  position: relative;
  width: 240px; height: 240px;
  perspective: 1000px;
  z-index: 2;
}

/* ── Rotating Energy Rings ── */
.avatar-ring {
  position: absolute;
  border-radius: 50%;
  border: 1px solid transparent;
  pointer-events: none;
}

.ring-1 {
  inset: -15px;
  border-color: rgba(78,205,196,0.12);
  border-style: dashed;
  animation: ringRotate 25s linear infinite;
}

.ring-2 {
  inset: -30px;
  border-color: rgba(201,168,76,0.08);
  border-style: dotted;
  animation: ringRotate 35s linear infinite reverse;
}

.ring-3 {
  inset: -45px;
  border-color: rgba(78,205,196,0.05);
  animation: ringRotate 45s linear infinite;
}

@keyframes ringRotate {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* ── Energy Arc SVGs ── */
.energy-arcs {
  position: absolute;
  top: 50%; left: 50%;
  width: 260px; height: 260px;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 3;
}

.arc {
  fill: none;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-dasharray: 60 200;
  opacity: 0.6;
}

.arc-1 {
  stroke: var(--chat-cyan);
  animation: arcDash 4s ease-in-out infinite;
}
.arc-2 {
  stroke: var(--chat-gold);
  animation: arcDash 6s ease-in-out infinite reverse;
  opacity: 0.4;
}
.arc-3 {
  stroke: var(--chat-cyan-l);
  animation: arcDash 5s ease-in-out infinite 1s;
  opacity: 0.3;
}

@keyframes arcDash {
  0% { stroke-dashoffset: 0; }
  50% { stroke-dashoffset: 200; }
  100% { stroke-dashoffset: 400; }
}

/* ── Particle Ring Dots ── */
.avatar-particles {
  position: absolute;
  top: 50%; left: 50%;
  width: 220px; height: 220px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  animation: particleRing 20s linear infinite;
  z-index: 3;
}

@keyframes particleRing {
  from { transform: translate(-50%, -50%) rotate(0deg); }
  to { transform: translate(-50%, -50%) rotate(360deg); }
}

.avatar-particles::before,
.avatar-particles::after {
  content: '';
  position: absolute;
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--chat-cyan);
  box-shadow: 0 0 10px var(--chat-cyan), 0 0 20px var(--chat-cyan-glow);
}
.avatar-particles::before { top: -2px; left: 50%; transform: translateX(-50%); }
.avatar-particles::after { bottom: -2px; left: 50%; transform: translateX(-50%); }

/* ── Avatar Image ── */
.avatar-img-wrap {
  width: 100%; height: 100%;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid rgba(78,205,196,0.3);
  box-shadow:
    0 0 30px rgba(78,205,196,0.15),
    0 0 60px rgba(78,205,196,0.06),
    0 0 100px rgba(78,205,196,0.03),
    inset 0 0 40px rgba(78,205,196,0.05);
  animation: avatarFloat 7s ease-in-out infinite;
  position: relative;
  z-index: 4;
}

.avatar-img-wrap img {
  width: 100%; height: 100%;
  object-fit: cover;
  filter: brightness(1.08) saturate(1.15);
  transition: filter 0.3s;
}

/* holographic shimmer overlay */
.holo-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    135deg,
    transparent 30%,
    rgba(78,205,196,0.08) 45%,
    rgba(201,168,76,0.06) 55%,
    transparent 70%
  );
  background-size: 300% 300%;
  animation: holoShimmer 8s ease infinite;
  pointer-events: none;
  mix-blend-mode: screen;
}

@keyframes holoShimmer {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* floating animation with subtle 3D tilt */
@keyframes avatarFloat {
  0%, 100% { transform: translateY(0) rotateX(0deg) rotateY(0deg); }
  15% { transform: translateY(-5px) rotateX(1deg) rotateY(-1deg); }
  30% { transform: translateY(-9px) rotateX(0.5deg) rotateY(1deg); }
  50% { transform: translateY(-12px) rotateX(-0.5deg) rotateY(0deg); }
  70% { transform: translateY(-7px) rotateX(0deg) rotateY(-0.5deg); }
  85% { transform: translateY(-3px) rotateX(0.5deg) rotateY(0.5deg); }
}

/* scan line effect */
.avatar-img-wrap::after {
  content: '';
  position: absolute;
  top: -100%; left: 0; right: 0;
  height: 40%;
  background: linear-gradient(to bottom, transparent, rgba(78,205,196,0.06), transparent);
  animation: scanLine 5s ease-in-out infinite;
  pointer-events: none;
}

@keyframes scanLine {
  0% { top: -40%; }
  100% { top: 140%; }
}

/* ── Speaking State ── */
.avatar-3d-wrap.speaking .avatar-img-wrap {
  box-shadow:
    0 0 40px rgba(78,205,196,0.35),
    0 0 80px rgba(78,205,196,0.15),
    0 0 120px rgba(78,205,196,0.08),
    inset 0 0 40px rgba(78,205,196,0.1);
  border-color: rgba(78,205,196,0.55);
}

.avatar-3d-wrap.speaking .avatar-particles {
  animation-duration: 6s;
}

.avatar-3d-wrap.speaking .arc {
  animation-duration: 2s;
  opacity: 0.9;
}

.avatar-3d-wrap.speaking .ring-1 {
  animation-duration: 10s;
  border-color: rgba(78,205,196,0.25);
}

/* ── Avatar Info ── */
.avatar-name {
  margin-top: 20px;
  font-family: 'Noto Serif SC', Georgia, serif;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--chat-cyan);
  letter-spacing: 0.12em;
  z-index: 2;
  text-shadow: 0 0 20px var(--chat-cyan-glow);
}

.avatar-role {
  font-size: 0.78rem;
  color: var(--chat-t3);
  margin-top: 4px;
  z-index: 2;
  letter-spacing: 0.05em;
}

.avatar-status {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  font-size: 0.72rem;
  color: var(--chat-cyan);
  z-index: 2;
}

.avatar-status .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--chat-cyan);
  box-shadow: 0 0 8px var(--chat-cyan);
  animation: dotBlink 2s ease-in-out infinite;
}

@keyframes dotBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* Stats row */
.avatar-stats {
  display: flex;
  gap: 24px;
  margin-top: 20px;
  z-index: 2;
}

.stat-item {
  text-align: center;
}

.stat-value {
  display: block;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--chat-gold);
}

.stat-label {
  display: block;
  font-size: 0.65rem;
  color: var(--chat-t3);
  margin-top: 2px;
}

.avatar-version {
  margin-top: 16px;
  font-size: 0.62rem;
  color: var(--chat-t3);
  z-index: 2;
  padding: 4px 12px;
  border: 1px solid var(--chat-border);
  border-radius: 20px;
}

/* Mode Selector */
.mode-selector {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  z-index: 2;
}

.mode-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 14px;
  border: 1px solid var(--chat-border);
  border-radius: 20px;
  background: var(--chat-surface);
  color: var(--chat-t3);
  font-size: 0.72rem;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.mode-btn:hover {
  border-color: var(--chat-cyan);
  color: var(--chat-t2);
}

.mode-btn.active {
  border-color: var(--chat-cyan);
  color: var(--chat-cyan);
  background: rgba(78,205,196,0.06);
}

.mode-icon { font-size: 0.85rem; }

/* API Status Indicator */
.api-status-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  z-index: 2;
  font-size: 0.65rem;
  color: var(--chat-t3);
}

.api-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #666;
  flex-shrink: 0;
  transition: all 0.3s;
}

.api-label {
  transition: color 0.3s;
}

/* back link */
.chat-back {
  position: absolute;
  top: 20px; left: 20px;
  font-size: 0.78rem;
  color: var(--chat-t3);
  text-decoration: none;
  z-index: 10;
  transition: color 0.2s;
}
.chat-back:hover { color: var(--chat-cyan); }


/* ============================================================
   RIGHT: Chat Area
   ============================================================ */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--chat-bg);
}

/* messages container */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 32px 32px 16px;
  scroll-behavior: smooth;
}

.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--chat-border); border-radius: 4px; }

/* message row */
.msg-row {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  max-width: 800px;
  animation: msgFadeIn 0.5s ease-out;
}

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

.msg-row.ai { align-items: flex-start; }
.msg-row.user { margin-left: auto; flex-direction: row-reverse; }

/* avatar in message */
.msg-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  flex-shrink: 0;
  overflow: hidden;
  border: 1px solid var(--chat-border);
}
.msg-avatar img { width: 100%; height: 100%; object-fit: cover; }

.msg-row.user .msg-avatar {
  background: linear-gradient(135deg, var(--chat-gold), #d4b65c);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.9rem;
  color: #000;
  border-color: var(--chat-bubble-user-border);
}

/* bubble */
.msg-bubble {
  padding: 14px 18px;
  border-radius: var(--chat-radius);
  font-size: 0.88rem;
  line-height: 1.75;
  max-width: 640px;
  position: relative;
}

.msg-row.ai .msg-bubble {
  background: var(--chat-bubble-ai);
  border: 1px solid var(--chat-bubble-ai-border);
  border-top-left-radius: 4px;
  color: var(--chat-t1);
}

.msg-row.user .msg-bubble {
  background: var(--chat-bubble-user);
  border: 1px solid var(--chat-bubble-user-border);
  border-top-right-radius: 4px;
  color: var(--chat-t1);
}

.msg-bubble strong, .msg-bubble b { color: var(--chat-gold); font-weight: 600; }
.msg-bubble em { color: var(--chat-cyan); font-style: normal; }

/* typing indicator */
.typing-dots {
  display: inline-flex;
  gap: 5px;
  padding: 4px 0;
}
.typing-dots span {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--chat-cyan);
  animation: typingBounce 1.4s ease-in-out infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.3; }
  30% { transform: translateY(-8px); opacity: 1; }
}

/* quick questions */
.quick-questions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.quick-btn {
  background: var(--chat-surface);
  border: 1px solid var(--chat-border);
  color: var(--chat-t2);
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 0.78rem;
  cursor: pointer;
  transition: all 0.25s;
  font-family: inherit;
}

.quick-btn:hover {
  border-color: var(--chat-cyan);
  color: var(--chat-cyan);
  background: rgba(78,205,196,0.06);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(78,205,196,0.1);
}

/* follow-up buttons */
.followup-questions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--chat-border);
}

.followup-btn {
  background: none;
  border: 1px solid var(--chat-border);
  color: var(--chat-t3);
  padding: 5px 12px;
  border-radius: 16px;
  font-size: 0.72rem;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.followup-btn:hover {
  border-color: var(--chat-cyan);
  color: var(--chat-cyan);
}


/* ── Input Bar ── */
.chat-input-bar {
  padding: 12px 32px 8px;
  display: flex;
  gap: 12px;
  align-items: flex-end;
}

.chat-input-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  background: var(--chat-surface);
  border: 1px solid var(--chat-border);
  border-radius: 24px;
  padding: 4px 6px 4px 18px;
  transition: all 0.3s;
}

.chat-input-wrap:focus-within {
  border-color: var(--chat-cyan);
  box-shadow: 0 0 24px rgba(78,205,196,0.1);
}

#chat-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--chat-t1);
  font-size: 0.9rem;
  font-family: inherit;
  padding: 10px 0;
  resize: none;
  max-height: 120px;
  line-height: 1.5;
}
#chat-input::placeholder { color: var(--chat-t3); }

.chat-send-btn {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--chat-cyan);
  color: #000;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.25s;
  flex-shrink: 0;
}
.chat-send-btn:hover { background: var(--chat-gold); transform: scale(1.08); }
.chat-send-btn:disabled { opacity: 0.25; cursor: not-allowed; transform: none; }

/* disclaimer */
.chat-disclaimer {
  text-align: center;
  font-size: 0.65rem;
  color: var(--chat-t3);
  padding: 4px 32px 14px;
  opacity: 0.7;
}

/* ── (API Key Banner removed — Key is now server-side only) ── */

/* ── Theme Toggle ── */
.chat-theme-toggle {
  position: fixed;
  top: 20px; right: 20px;
  z-index: 100;
}
.chat-theme-toggle button {
  background: var(--chat-surface);
  border: 1px solid var(--chat-border);
  color: var(--chat-t2);
  width: 36px; height: 36px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s;
  backdrop-filter: blur(10px);
}
.chat-theme-toggle button:hover { border-color: var(--chat-cyan); color: var(--chat-cyan); }

/* ── Markdown in messages ── */
.msg-bubble ul, .msg-bubble ol { padding-left: 18px; margin: 6px 0; }
.msg-bubble li { margin-bottom: 4px; }
.msg-bubble p { margin-bottom: 8px; }
.msg-bubble p:last-child { margin-bottom: 0; }
.msg-bubble code {
  background: rgba(78,205,196,0.1);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.82rem;
  font-family: 'SF Mono', Monaco, Consolas, monospace;
}

/* Highlighted data cards in messages */
.data-card {
  background: rgba(78,205,196,0.04);
  border: 1px solid rgba(78,205,196,0.12);
  border-radius: 10px;
  padding: 10px 14px;
  margin: 8px 0;
  font-size: 0.82rem;
}

.data-card .label {
  font-size: 0.68rem;
  color: var(--chat-t3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.data-card .value {
  color: var(--chat-gold);
  font-weight: 600;
  font-size: 1.1rem;
}


/* ============================================================
   RESPONSIVE — 手机端
   策略：不隐藏 avatar-panel，改为折叠式置顶显示
   保留 3D 数字人，隐藏辅助信息（模式选择移至顶部工具条）
   ============================================================ */
@media (max-width: 900px) {
  /* 布局改为纵向堆叠 */
  .chat-layout {
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
  }

  /* Avatar 面板变为顶部紧凑区域 */
  .avatar-panel {
    width: 100%;
    min-width: 0;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    padding: 4px 12px 10px;
    border-right: none;
    border-bottom: 1px solid var(--chat-border);
    flex: 0 0 auto;
    max-height: 42vh;
    transition: max-height 0.4s ease;
  }

  /* 折叠态：只留窄条 + 3D 小头像 */
  .avatar-panel.collapsed {
    max-height: 68px;
    padding: 6px 12px;
  }

  /* 手机端隐藏「返回导航」链接（已由 mobile header 替代） */
  .avatar-panel .chat-back { display: none; }

  /* 手机端光晕变弱 */
  .avatar-panel::before,
  .avatar-panel::after { opacity: 0.25; }

  /* 3D 舞台在手机端缩小 */
  .avatar-3d-stage {
    width: 200px !important;
    height: 220px !important;
    margin: 2px auto 6px !important;
    border-radius: 18px;
  }

  .avatar-panel.collapsed .avatar-3d-stage {
    width: 52px !important;
    height: 52px !important;
    border-radius: 50%;
    margin: 0 !important;
    position: absolute;
    left: 14px;
    top: 8px;
  }
  .avatar-panel.collapsed .avatar-3d-stage .avatar-3d-hint,
  .avatar-panel.collapsed .avatar-3d-stage .avatar-3d-state { display: none; }
  .avatar-panel.collapsed .avatar-3d-stage::before,
  .avatar-panel.collapsed .avatar-3d-stage::after { display: none; }

  /* Name & Role & Version 手机端更紧凑 */
  .avatar-panel .avatar-name { font-size: 1.05rem; margin-top: 2px; }
  .avatar-panel .avatar-role { font-size: 0.72rem; }
  .avatar-panel .avatar-version { display: none; }

  /* 折叠态下文字右移避让 3D 头像 */
  .avatar-panel.collapsed .avatar-name,
  .avatar-panel.collapsed .avatar-role,
  .avatar-panel.collapsed .avatar-status {
    align-self: flex-start;
    margin-left: 78px;
    text-align: left;
  }
  .avatar-panel.collapsed .avatar-name { font-size: 0.95rem; }
  .avatar-panel.collapsed .avatar-role { font-size: 0.68rem; }
  .avatar-panel.collapsed .avatar-status { font-size: 0.66rem; gap: 4px; }

  /* 统计数据手机端隐藏（节省空间） */
  .avatar-panel .avatar-stats { display: none; }

  /* Mode Selector 手机端变紧凑横条 */
  .avatar-panel .mode-selector {
    width: 100%;
    max-width: 340px;
    margin-top: 4px;
    gap: 6px;
  }
  .avatar-panel.collapsed .mode-selector,
  .avatar-panel.collapsed .api-status-row { display: none; }

  .avatar-panel .mode-btn {
    padding: 6px 10px;
    font-size: 0.72rem;
  }
  .avatar-panel .api-status-row { font-size: 0.66rem; padding: 2px 0 0; }

  /* 折叠/展开按钮 */
  .avatar-toggle-btn {
    display: flex !important;
    position: absolute;
    top: 10px;
    right: 14px;
    width: 30px; height: 30px;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--chat-border);
    border-radius: 50%;
    background: var(--chat-panel-bg);
    color: var(--chat-t2);
    cursor: pointer;
    z-index: 10;
    font-size: 0.8rem;
    transition: transform 0.3s ease, background 0.2s;
  }
  .avatar-panel.collapsed .avatar-toggle-btn { transform: rotate(180deg); }
  .avatar-toggle-btn:active { background: var(--chat-cyan-glow); }

  /* 右侧对话区自适应 */
  .chat-main { flex: 1 1 auto; min-height: 0; }
  .chat-messages { padding: 14px 12px 10px; }
  .chat-input-bar { padding: 8px 12px 4px; }
  .chat-disclaimer { padding: 4px 12px 10px; font-size: 0.66rem; }
  .msg-bubble { max-width: 82vw; }

  /* 主题切换浮于右下 */
  .chat-theme-toggle { top: auto; bottom: 86px; right: 14px; }

  /* mobile header（顶部返回栏） */
  .mobile-chat-header {
    display: flex !important;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--chat-border);
    background: var(--chat-panel-bg);
    backdrop-filter: blur(20px);
    flex: 0 0 auto;
    z-index: 11;
    position: relative;
  }
  .mobile-chat-header img {
    width: 38px; height: 38px;
    border-radius: 50%;
    border: 2px solid rgba(78,205,196,0.3);
    box-shadow: 0 0 15px rgba(78,205,196,0.15);
  }
  .mobile-chat-header .name {
    font-size: 0.95rem; font-weight: 700;
    color: var(--chat-cyan);
    font-family: 'Noto Serif SC', serif;
  }
  .mobile-chat-header .sub {
    font-size: 0.66rem; color: var(--chat-t3);
  }
  .mobile-chat-header .back {
    color: var(--chat-t3);
    text-decoration: none;
    font-size: 1.3rem;
    margin-right: 2px;
    transition: color 0.2s;
    padding: 4px 8px;
  }
  .mobile-chat-header .back:active { color: var(--chat-cyan); }
}

@media (min-width: 901px) {
  .mobile-chat-header { display: none !important; }
  .avatar-toggle-btn { display: none !important; }
}

@media (max-width: 480px) {
  .msg-bubble { font-size: 0.84rem; padding: 10px 13px; }
  .quick-btn { font-size: 0.72rem; padding: 6px 12px; }

  .avatar-panel {
    max-height: 38vh;
    padding: 2px 10px 8px;
  }
  .avatar-3d-stage {
    width: 170px !important;
    height: 190px !important;
  }
  .avatar-panel .avatar-name { font-size: 0.98rem; }
  .avatar-panel .avatar-role { font-size: 0.68rem; }
  .avatar-panel .mode-btn { padding: 5px 8px; font-size: 0.68rem; }
}

/* 默认态（桌面）下隐藏折叠按钮 */
.avatar-toggle-btn { display: none; }
