/* ═══════════════════════════════════════════════════════════
   小栈AI 全局对话弹窗 — 冰晶折射 V3.1.6
   设计语言: 冰晶折射（参考设计规范v1.0）+ 毛玻璃 + 弹性动画
   覆盖: 桌面/平板/移动端 + 日间/夜间模式 + iOS安全区
   ═══════════════════════════════════════════════════════════ */

/* ─── CSS 变量：日间模式 ─── */
:root {
  --xzd-glass-bg: rgba(245, 247, 252, 0.72);
  --xzd-glass-bg-strong: rgba(245, 247, 252, 0.92);
  --xzd-glass-border: rgba(180, 200, 230, 0.3);
  --xzd-glass-shadow: 0 12px 48px rgba(0, 0, 0, 0.12);
  --xzd-glass-shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.16);
  --xzd-bubble-ai-bg: rgba(255, 255, 255, 0.5);
  --xzd-bubble-user-bg: rgba(13, 147, 115, 0.1);
  --xzd-bubble-think-bg: rgba(59, 130, 246, 0.05);
  --xzd-bubble-tool-bg: rgba(13, 147, 115, 0.05);
  --xzd-bubble-confirm-bg: rgba(239, 68, 68, 0.05);
  --xzd-input-bg: rgba(255, 255, 255, 0.5);
  --xzd-input-border: rgba(180, 200, 230, 0.3);
  --xzd-trigger-bg: linear-gradient(135deg, #0D9373, #3b82f6);
  --xzd-trigger-shadow: 0 4px 20px rgba(13, 147, 115, 0.3), 0 0 40px rgba(13, 147, 115, 0.08);
  --xzd-accent: #0D9373;
  --xzd-accent2: #3b82f6;
  --xzd-bg: #f0f2f5;
  --xzd-bg-secondary: #f8f9fb;
  --xzd-bg-tertiary: rgba(0, 0, 0, 0.04);
  --xzd-border: rgba(0, 0, 0, 0.06);
  --xzd-text: #1a2035;
  --xzd-text-secondary: #5a6580;
  --xzd-text-muted: #8a95a8;
  --xzd-primary: #4f46e5;
  --xzd-primary-hover: #4338ca;
  --xzd-success: #10b981;
  --xzd-warning: #f59e0b;
  --xzd-danger: #ef4444;
  --xzd-radius: 22px;
  --xzd-radius-sm: 12px;
  --xzd-radius-xs: 8px;
  --xzd-blur: blur(40px);
  --xzd-blur-light: blur(16px);
  --xzd-code-bg: #f5f7fa;
  --xzd-tool-bg: rgba(255, 255, 255, 0.7);
}

/* ─── 深度适配主题变量桥接 ─── */
.xzd-theme-deep #xzd-chat-panel {
  --xzd-primary: var(--focus-color, #4f46e5);
  --xzd-primary-hover: var(--focus-color, #4338ca);
  --xzd-bubble-user-bg: rgba(var(--focus-color-rgb, 79, 70, 229), 0.1);
  --xzd-trigger-bg: linear-gradient(135deg, var(--focus-color, #0D9373), var(--focus-color, #3b82f6));
  --xzd-trigger-shadow: 0 4px 20px var(--focus-shadow-color, rgba(13,147,115,0.3)), 0 0 40px rgba(13,147,115,0.08);
  --xzd-accent: var(--focus-color, #0D9373);
  --xzd-radius: var(--main-radius, 22px);
  font-family: inherit !important;
}

/* ─── 夜间模式 ─── */
body.dark-theme #xzd-chat-panel,
#xzd-chat-panel.xzd-dark {
  --xzd-glass-bg: rgba(10, 14, 24, 0.8);
  --xzd-glass-bg-strong: rgba(10, 14, 24, 0.96);
  --xzd-glass-border: rgba(60, 80, 130, 0.2);
  --xzd-glass-shadow: 0 12px 48px rgba(0, 0, 0, 0.4);
  --xzd-glass-shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.5);
  --xzd-bubble-ai-bg: rgba(20, 28, 48, 0.55);
  --xzd-bubble-user-bg: rgba(13, 147, 115, 0.14);
  --xzd-bubble-think-bg: rgba(59, 130, 246, 0.08);
  --xzd-bubble-tool-bg: rgba(16, 185, 129, 0.08);
  --xzd-bubble-confirm-bg: rgba(239, 68, 68, 0.08);
  --xzd-input-bg: rgba(20, 28, 48, 0.5);
  --xzd-input-border: rgba(60, 80, 130, 0.2);
  --xzd-trigger-bg: linear-gradient(135deg, #10B981, #2563eb);
  --xzd-trigger-shadow: 0 4px 20px rgba(16, 185, 129, 0.25), 0 0 50px rgba(16, 185, 129, 0.06);
  --xzd-accent: #10B981;
  --xzd-accent2: #60a5fa;
  --xzd-bg: #080c16;
  --xzd-bg-secondary: rgba(20, 26, 40, 0.6);
  --xzd-bg-tertiary: rgba(255, 255, 255, 0.04);
  --xzd-border: rgba(60, 70, 100, 0.18);
  --xzd-text: #e2e8f0;
  --xzd-text-secondary: #8a9ab8;
  --xzd-text-muted: #4a5a78;
  --xzd-code-bg: rgba(16, 22, 36, 0.9);
  --xzd-tool-bg: rgba(255, 255, 255, 0.04);
}

/* ─── 根容器 ─── */
#xzd-chat-root {
  position: fixed !important;
  inset: 0 !important;
  pointer-events: none !important;
  z-index: 999999 !important;
}

/* ═══════════════════════════════════════════
   触发按钮
   ═══════════════════════════════════════════ */
.xzd-chat-trigger {
  position: fixed !important;
  bottom: var(--xzd-trigger-bottom, 24px) !important;
  right: var(--xzd-trigger-right, 24px) !important;
  top: var(--xzd-trigger-top, auto) !important;
  left: var(--xzd-trigger-left, auto) !important;
  z-index: 999998 !important;
  width: var(--xzd-trigger-size, 56px) !important;
  height: var(--xzd-trigger-size, 56px) !important;
  border-radius: var(--xzd-trigger-radius, 16px) !important;
  background: var(--xzd-trigger-bg) !important;
  color: #fff !important;
  border: none !important;
  cursor: pointer !important;
  pointer-events: auto !important;
  box-shadow: var(--xzd-trigger-shadow) !important;
  opacity: var(--xzd-trigger-opacity, 1) !important;
  display: none;
  align-items: center !important;
  justify-content: center !important;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
              box-shadow 0.3s ease,
              border-radius 0.3s ease,
              opacity 0.25s ease !important;
  margin: 0 !important;
  padding: 0 !important;
  line-height: 1 !important;
}
.xzd-chat-trigger svg {
  width: calc(var(--xzd-trigger-size, 56px) * 0.39) !important;
  height: calc(var(--xzd-trigger-size, 56px) * 0.39) !important;
}
.xzd-chat-trigger:hover {
  transform: scale(1.08) !important;
}
.xzd-chat-trigger:active {
  transform: scale(0.95) !important;
}

/* ─── 按钮动效 ─── */
/* 1. 呼吸光晕 */
@keyframes xzd-breathe {
  0%, 100% { box-shadow: 0 4px 20px rgba(13,147,115,.3), 0 0 40px rgba(13,147,115,.08); }
  50%      { box-shadow: 0 4px 24px rgba(13,147,115,.5), 0 0 64px rgba(13,147,115,.18); }
}
body.dark-theme .xzd-chat-trigger.xzd-breathing {
  animation: xzd-breathe-d 3s ease-in-out infinite;
}
@keyframes xzd-breathe-d {
  0%, 100% { box-shadow: 0 4px 20px rgba(16,185,129,.25), 0 0 50px rgba(16,185,129,.06); }
  50%      { box-shadow: 0 4px 24px rgba(16,185,129,.45), 0 0 70px rgba(16,185,129,.16); }
}
.xzd-chat-trigger.xzd-breathing {
  animation: xzd-breathe 3s ease-in-out infinite;
}
.xzd-chat-trigger.xzd-breathing-off {
  animation: none !important;
}

/* 2. 脉冲扩散 */
.xzd-chat-trigger.xzd-fab-pulse,
.xzd-ai-btn.xzd-fab-pulse {
  overflow: visible;
}
.xzd-chat-trigger.xzd-fab-pulse::after,
.xzd-ai-btn.xzd-fab-pulse::after {
  content: ''; position: absolute; inset: -4px;
  border-radius: inherit;
  border: 2px solid rgba(13,147,115,.4);
  animation: xzd-fabPulse 2s ease-out infinite;
}
@keyframes xzd-fabPulse {
  to { transform: scale(1.6); opacity: 0; }
}
body.dark-theme .xzd-chat-trigger.xzd-fab-pulse::after,
body.dark-theme .xzd-ai-btn.xzd-fab-pulse::after {
  border-color: rgba(16,185,129,.4);
}

/* 3. 旋转光晕 */
.xzd-chat-trigger.xzd-fab-glow,
.xzd-ai-btn.xzd-fab-glow {
  overflow: visible;
}
.xzd-chat-trigger.xzd-fab-glow::before,
.xzd-ai-btn.xzd-fab-glow::before {
  content: ''; position: absolute; inset: -6px;
  border-radius: inherit;
  background: conic-gradient(from 0deg, transparent, rgba(13,147,115,.3), transparent, rgba(59,130,246,.3), transparent);
  animation: xzd-fabGlow 3s linear infinite;
}
@keyframes xzd-fabGlow {
  to { transform: rotate(360deg); }
}
body.dark-theme .xzd-chat-trigger.xzd-fab-glow::before,
body.dark-theme .xzd-ai-btn.xzd-fab-glow::before {
  background: conic-gradient(from 0deg, transparent, rgba(16,185,129,.3), transparent, rgba(37,99,235,.3), transparent);
}

/* 4. 形态变化 */
.xzd-chat-trigger.xzd-fab-morph,
.xzd-ai-btn.xzd-fab-morph {
  animation: xzd-fabMorph 4s ease-in-out infinite;
}
@keyframes xzd-fabMorph {
  0%, 100% { border-radius: 16px; }
  25%      { border-radius: 50%; }
  50%      { border-radius: 20px 8px; }
  75%      { border-radius: 8px 20px; }
}

/* 徽章 */
.xzd-chat-badge {
  position: absolute !important;
  top: -4px !important;
  right: -4px !important;
  min-width: 18px !important;
  height: 18px !important;
  border-radius: var(--xzd-badge-radius, 50%) !important;
  background: var(--xzd-danger) !important;
  color: #fff !important;
  font-size: 9px !important;
  font-weight: 700 !important;
  display: none;
  align-items: center !important;
  justify-content: center !important;
  padding: 0 4px !important;
  box-shadow: 0 2px 6px rgba(239,68,68,0.35) !important;
  pointer-events: none !important;
}

/* ═══════════════════════════════════════════
   弹窗面板 — 冰晶毛玻璃
   ═══════════════════════════════════════════ */
#xzd-chat-panel {
  position: fixed;
  top: auto;
  right: 20px;
  bottom: 88px;
  left: auto;
  width: 400px;
  max-width: calc(100vw - 40px);
  min-width: 320px;
  max-height: 700px;
  background: var(--xzd-glass-bg) !important;
  backdrop-filter: var(--xzd-blur) !important;
  -webkit-backdrop-filter: var(--xzd-blur) !important;
  color: var(--xzd-text) !important;
  border: 1px solid var(--xzd-glass-border) !important;
  border-radius: var(--xzd-radius) !important;
  box-shadow: var(--xzd-glass-shadow) !important;
  display: flex !important;
  flex-direction: column !important;
  z-index: 999999 !important;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif !important;
  font-size: 14px !important;
  line-height: 1.6 !important;
  pointer-events: none !important;
  margin: 0 !important;
  padding: 0 !important;
  box-sizing: border-box !important;
  visibility: hidden;
  opacity: 0;
  transform: scale(0.85) translateY(8px);
  transform-origin: bottom right;
  transition: opacity 0.25s cubic-bezier(0.4, 0, 0.2, 1),
              transform 0.25s cubic-bezier(0.4, 0, 0.2, 1),
              visibility 0s 0.25s;
  overflow: hidden;
  will-change: opacity, transform;
}

/* 打开状态 — 干净过渡 */
#xzd-chat-panel.xzd-open {
  visibility: visible;
  opacity: 1;
  transform: none;
  pointer-events: auto !important;
  transition: opacity 0.3s cubic-bezier(0.22, 0.61, 0.36, 1),
              transform 0.3s cubic-bezier(0.22, 0.61, 0.36, 1),
              visibility 0s 0s;
}

/* 滑入变体：从底部上滑 */
#xzd-chat-panel.xzd-popup-slide {
  transform: translateY(32px);
}
#xzd-chat-panel.xzd-popup-slide.xzd-open {
  transform: none;
}

/* 冰晶折射Canvas背景 */
.xzd-fx-canvas {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  width: 100%;
  height: 100%;
  border-radius: inherit;
}

/* 滚动阴影 */
.xzd-scroll-shadow-top {
  box-shadow: inset 0 4px 12px rgba(0,0,0,0.04) !important;
}

/* ═══════════════════════════════════════════
   头部
   ═══════════════════════════════════════════ */
.xzd-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(180, 200, 230, 0.25);
  background: rgba(245, 247, 252, 0.5);
  backdrop-filter: var(--xzd-blur-light);
  -webkit-backdrop-filter: var(--xzd-blur-light);
  flex-shrink: 0;
  border-radius: var(--xzd-radius) var(--xzd-radius) 0 0;
  min-height: 52px;
  position: relative;
  z-index: 2;
}
body.dark-theme .xzd-chat-header,
#xzd-chat-panel.xzd-dark .xzd-chat-header {
  background: rgba(10, 14, 24, 0.4);
  border-bottom-color: rgba(60, 80, 130, 0.15);
}

.xzd-chat-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.xzd-chat-logo {
  line-height: 1;
  display: flex;
  align-items: center;
  position: relative;
}

/* 在线状态绿点 */
.xzd-online-dot {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10b981;
  border: 1.5px solid var(--xzd-glass-bg-strong);
  animation: xzd-online-pulse 2s ease-in-out infinite;
}
@keyframes xzd-online-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.6); }
  50% { box-shadow: 0 0 0 4px rgba(16, 185, 129, 0); }
}

.xzd-chat-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--xzd-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.xzd-chat-subtitle {
  font-size: 11px;
  color: var(--xzd-text-muted);
  font-weight: 400;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.xzd-chat-header-titles {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.xzd-chat-admin-badge {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--xzd-primary);
  color: #fff;
  font-weight: 600;
  flex-shrink: 0;
}

.xzd-chat-header-right {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}

.xzd-chat-btn-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--xzd-text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}
.xzd-chat-btn-icon:hover {
  background: rgba(128, 128, 128, 0.08);
  color: var(--xzd-text);
}
.xzd-chat-btn-icon:active {
  transform: scale(0.92);
}

/* 按钮 tooltip */
.xzd-chat-btn-icon[data-tooltip] {
  position: relative;
}
.xzd-chat-btn-icon[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: -28px;
  left: 50%;
  transform: translateX(-50%);
  padding: 3px 8px;
  border-radius: 4px;
  background: var(--xzd-text);
  color: var(--xzd-bg);
  font-size: 10px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 10;
}
.xzd-chat-btn-icon[data-tooltip]:hover::after {
  opacity: 1;
}

.xzd-chat-btn-text {
  background: none;
  border: none;
  color: var(--xzd-primary);
  font-size: 13px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background 0.15s;
}
.xzd-chat-btn-text:hover {
  background: var(--xzd-bg-secondary);
}

/* ═══════════════════════════════════════════
   消息区域
   ═══════════════════════════════════════════ */
.xzd-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
  overscroll-behavior: contain;
}
.xzd-chat-messages::-webkit-scrollbar { width: 3px; }
.xzd-chat-messages::-webkit-scrollbar-track { background: transparent; }
.xzd-chat-messages::-webkit-scrollbar-thumb {
  background: rgba(128, 128, 128, 0.18);
  border-radius: 2px;
}
.xzd-chat-messages::-webkit-scrollbar-thumb:hover {
  background: var(--xzd-text-muted);
}

/* ─── 欢迎界面 ─── */
.xzd-chat-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 16px;
  gap: 10px;
}
.xzd-chat-welcome-icon { font-size: 52px; margin-bottom: 4px; }
.xzd-chat-welcome h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--xzd-text);
  margin: 0;
}
.xzd-chat-welcome p {
  font-size: 13px;
  color: var(--xzd-text-secondary);
  margin: 0 0 14px 0;
  line-height: 1.6;
}
.xzd-chat-welcome-hints {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  max-width: 320px;
}
.xzd-chat-hint {
  padding: 7px 16px;
  border-radius: 18px;
  border: 1px solid var(--xzd-glass-border);
  background: var(--xzd-bubble-ai-bg);
  color: var(--xzd-text);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.18s;
  white-space: nowrap;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.xzd-chat-hint:hover {
  background: var(--xzd-primary);
  border-color: var(--xzd-primary);
  color: #fff;
  transform: translateY(-1px);
}

/* 欢迎界面 3列功能卡片 */
.xzd-welcome-cards {
  display: flex;
  gap: 8px;
  width: 100%;
  max-width: 360px;
  margin-top: 4px;
}
.xzd-welcome-card {
  flex: 1;
  padding: 12px 8px;
  border-radius: var(--xzd-radius-sm);
  background: var(--xzd-bubble-ai-bg);
  border: 1px solid var(--xzd-glass-border);
  cursor: pointer;
  text-align: center;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.xzd-welcome-card:hover {
  background: var(--xzd-primary);
  border-color: var(--xzd-primary);
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(79, 70, 229, 0.25);
}
.xzd-welcome-card:hover .xzd-welcome-card-icon,
.xzd-welcome-card:hover .xzd-welcome-card-label,
.xzd-welcome-card:hover .xzd-welcome-card-desc {
  color: #fff;
}
.xzd-welcome-card-icon {
  width: 24px;
  height: 24px;
  color: var(--xzd-primary);
  transition: color 0.2s;
}
.xzd-welcome-card-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--xzd-text);
  transition: color 0.2s;
}
.xzd-welcome-card-desc {
  font-size: 10px;
  color: var(--xzd-text-muted);
  line-height: 1.4;
  transition: color 0.2s;
}

/* ─── 消息气泡 ─── */
.xzd-chat-message {
  display: flex;
  gap: 7px;
  align-items: flex-start;
  max-width: 100%;
  animation: xzd-msg-in 0.3s ease;
}
@keyframes xzd-msg-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
.xzd-chat-msg-user {
  flex-direction: row;
  justify-content: flex-end;
}
.xzd-chat-msg-assistant {
  flex-direction: row;
}
.xzd-chat-msg-avatar { flex-shrink: 0; }
.xzd-chat-avatar {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  object-fit: cover;
  display: block;
}
.xzd-chat-avatar-text {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--xzd-bg-tertiary);
  color: var(--xzd-text-secondary);
  font-size: 13px;
  font-weight: 600;
}
.xzd-chat-msg-content {
  display: flex;
  flex-direction: column;
  min-width: 0;
  max-width: 88%;
}
.xzd-chat-msg-user .xzd-chat-msg-content { align-items: flex-end; }
.xzd-chat-msg-assistant .xzd-chat-msg-content { align-items: flex-start; }
.xzd-chat-msg-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
  flex-shrink: 0;
}
.xzd-chat-msg-name {
  font-size: 11px;
  color: var(--xzd-text-muted);
  font-weight: 500;
}

/* 时间分隔线 */
.xzd-chat-time-divider {
  text-align: center;
  margin: 10px 0 6px;
}
.xzd-chat-time-divider span {
  display: inline-block;
  font-size: 11px;
  color: var(--xzd-text-muted);
  opacity: 0.55;
}

/* ─── 气泡：AI ─── */
.xzd-chat-bubble-ai {
  background: var(--xzd-bubble-ai-bg);
  color: var(--xzd-text);
  padding: 8px 12px;
  border-radius: 12px;
  border-bottom-left-radius: 3px;
  font-size: 13px;
  word-break: break-word;
  line-height: 1.65;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  position: relative;
}
.xzd-chat-bubble-ai:hover .xzd-msg-copy-btn {
  opacity: 0.5;
}
.xzd-chat-bubble-ai .xzd-msg-copy-btn:hover {
  opacity: 1;
}

/* ─── 气泡：用户 ─── */
.xzd-chat-bubble-user {
  background: var(--xzd-bubble-user-bg);
  color: var(--xzd-text);
  padding: 8px 12px;
  border-radius: 12px;
  border-bottom-right-radius: 3px;
  font-size: 13px;
  word-break: break-word;
  line-height: 1.65;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

/* ─── think 消息：蓝色左边框 + 脉冲圆点 ─── */
.xzd-chat-bubble-think {
  background: var(--xzd-bubble-think-bg);
  border-left: 3px solid #3b82f6;
  padding: 8px 12px;
  border-radius: 0 8px 8px 0;
  font-size: 12px;
  color: var(--xzd-text-secondary);
  line-height: 1.5;
}
.xzd-think-dot {
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #3b82f6;
  animation: tdot 1.2s infinite;
  margin-right: 5px;
  vertical-align: middle;
}
@keyframes tdot {
  0%, 100% { opacity: .3; transform: scale(.8); }
  50% { opacity: 1; transform: scale(1.2); }
}
body.dark-theme .xzd-chat-bubble-think {
  background: var(--xzd-bubble-think-bg);
}

/* ─── tool 消息：绿色左边框 + 工具头部 ─── */
.xzd-chat-bubble-tool {
  background: var(--xzd-bubble-tool-bg);
  border-left: 3px solid var(--xzd-accent);
  padding: 8px 12px;
  border-radius: 0 8px 8px 0;
  font-size: 12px;
  line-height: 1.5;
}
.xzd-tool-hdr {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 4px;
}
.xzd-tool-ico {
  width: 18px;
  height: 18px;
  border-radius: 5px;
  background: linear-gradient(135deg, var(--xzd-accent), var(--xzd-accent2));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 9px;
  flex-shrink: 0;
}
.xzd-tool-nm {
  font-weight: 600;
  color: var(--xzd-accent);
  font-size: 11px;
}
.xzd-tool-dtl {
  color: var(--xzd-text-secondary);
  font-size: 10px;
  line-height: 1.5;
}
body.dark-theme .xzd-chat-bubble-tool {
  background: var(--xzd-bubble-tool-bg);
}

/* ─── confirm 消息：红色左边框 ─── */
.xzd-chat-bubble-confirm {
  background: var(--xzd-bubble-confirm-bg);
  border-left: 3px solid #ef4444;
  padding: 8px 12px;
  border-radius: 0 8px 8px 0;
  font-size: 12px;
}
.xzd-confirm-title {
  color: #ef4444;
  font-weight: 600;
  font-size: 11px;
  margin-bottom: 3px;
}
.xzd-confirm-acts {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}
.xzd-confirm-btn-y {
  padding: 4px 12px;
  border-radius: 7px;
  border: none;
  font-size: 10px;
  cursor: pointer;
  font-weight: 500;
  background: #ef4444;
  color: #fff;
}
.xzd-confirm-btn-n {
  padding: 4px 12px;
  border-radius: 7px;
  border: none;
  font-size: 10px;
  cursor: pointer;
  font-weight: 500;
  background: rgba(128, 128, 128, 0.1);
  color: var(--xzd-text-secondary);
}
body.dark-theme .xzd-chat-bubble-confirm {
  background: var(--xzd-bubble-confirm-bg);
}

/* ─── 思考中动画 ─── */
.xzd-chat-thinking {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  color: var(--xzd-text-secondary);
  font-size: 13px;
  animation: xzd-fade-in 0.25s ease;
}
@keyframes xzd-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
.xzd-chat-thinking .xzd-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--xzd-border);
  border-top-color: var(--xzd-primary);
  border-radius: 50%;
  animation: xzd-spin 0.7s linear infinite;
  flex-shrink: 0;
}
@keyframes xzd-spin {
  to { transform: rotate(360deg); }
}
.xzd-chat-thinking-text {
  display: flex;
  align-items: center;
  gap: 2px;
}
.xzd-chat-thinking-dots {
  display: inline-flex;
  gap: 1px;
}
.xzd-chat-thinking-dots span {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--xzd-text-secondary);
  animation: xzd-dot-fade 1.2s infinite;
}
.xzd-chat-thinking-dots span:nth-child(2) { animation-delay: 0.2s; }
.xzd-chat-thinking-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes xzd-dot-fade {
  0%, 80%, 100% { opacity: 0.2; }
  40% { opacity: 0.8; }
}

/* 流式输出光标 */
.xzd-chat-cursor {
  display: inline-block;
  width: 2px;
  height: 15px;
  background: var(--xzd-primary);
  margin-left: 2px;
  vertical-align: text-bottom;
  border-radius: 1px;
  animation: xzd-cursor-breathe 1.6s ease-in-out infinite;
}
@keyframes xzd-cursor-breathe {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

/* 消息复制按钮 */
.xzd-msg-copy-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 24px;
  height: 24px;
  border-radius: 4px;
  border: none;
  background: transparent;
  color: var(--xzd-text);
  cursor: pointer;
  opacity: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s;
  font-size: 12px;
  padding: 0;
}
.xzd-msg-copy-btn:active {
  transform: scale(0.88);
}

/* 代码块 */
.xzd-code-block-wrapper {
  position: relative;
  margin: 6px 0;
}
.xzd-code-block-wrapper pre {
  margin: 0;
}
.xzd-code-copy-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  padding: 3px 8px;
  border-radius: 4px;
  border: 1px solid var(--xzd-glass-border);
  background: var(--xzd-glass-bg-strong);
  color: var(--xzd-text-secondary);
  font-size: 10px;
  cursor: pointer;
  transition: all 0.15s;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.xzd-code-copy-btn:hover {
  color: var(--xzd-text);
  border-color: var(--xzd-text-muted);
}
.xzd-code-copy-btn.xzd-copied {
  color: var(--xzd-success);
  border-color: var(--xzd-success);
}

/* ─── 内容 Markdown 样式 ─── */
.xzd-chat-content h1, .xzd-chat-content h2,
.xzd-chat-content h3, .xzd-chat-content h4 {
  margin: 8px 0 4px;
  font-size: 14px;
  font-weight: 600;
}
.xzd-chat-content p { margin: 4px 0; }
.xzd-chat-content ul, .xzd-chat-content ol { margin: 4px 0; padding-left: 20px; }
.xzd-chat-content code {
  background: var(--xzd-bg-tertiary);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 12px;
  font-family: "SF Mono", "Menlo", "Consolas", monospace;
}
.xzd-chat-content pre {
  background: var(--xzd-code-bg);
  padding: 10px;
  border-radius: 8px;
  overflow-x: auto;
  font-size: 12px;
  margin: 6px 0;
  border: 1px solid var(--xzd-glass-border);
}
.xzd-chat-content pre code { background: none; padding: 0; }
/* ─── 表格（GFM pipe table）─── */
.xzd-chat-content table {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  font-size: 12px;
  margin: 8px 0;
  border-radius: var(--xzd-radius-xs);
  overflow: hidden;
  border: 1px solid var(--xzd-glass-border);
}
.xzd-chat-content thead th {
  background: linear-gradient(135deg, var(--xzd-accent), var(--xzd-accent2));
  color: #fff;
  font-weight: 600;
  padding: 7px 10px;
  text-align: left;
  font-size: 11px;
  letter-spacing: 0.3px;
}
.xzd-chat-content tbody td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--xzd-border);
  background: rgba(255,255,255,0.35);
}
.xzd-chat-content tbody tr:nth-child(even) td {
  background: rgba(0,0,0,0.02);
}
.xzd-chat-content tbody tr:last-child td {
  border-bottom: none;
}
.xzd-chat-content tbody tr:hover td {
  background: rgba(79,70,229,0.04);
}

/* ─── 键值对数据网格 ─── */
.xzd-chat-content .xzd-data-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 10px;
  margin: 6px 0;
  padding: 8px 10px;
  background: rgba(255,255,255,0.35);
  border: 1px solid var(--xzd-glass-border);
  border-radius: var(--xzd-radius-xs);
}
.xzd-chat-content .xzd-data-kv {
  display: flex;
  align-items: baseline;
  gap: 4px;
  padding: 3px 8px;
  background: var(--xzd-bg-secondary);
  border-radius: 5px;
  min-width: 0;
  font-size: 12px;
}
.xzd-chat-content .xzd-data-k {
  flex-shrink: 0;
  color: var(--xzd-text-muted);
  font-size: 11px;
  font-weight: 500;
}
.xzd-chat-content .xzd-data-k::after { content: ':'; }
.xzd-chat-content .xzd-data-v {
  color: var(--xzd-text);
  font-weight: 600;
  word-break: break-word;
  min-width: 0;
}
.xzd-chat-content a {
  color: var(--xzd-primary);
  text-decoration: none;
}
.xzd-chat-content a:hover { text-decoration: underline; }

/* 追问建议 pills */
.xzd-followup-pills {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.xzd-followup-pill {
  padding: 5px 12px;
  border-radius: 14px;
  border: 1px solid var(--xzd-glass-border);
  background: var(--xzd-glass-bg);
  color: var(--xzd-text-secondary);
  font-size: 11px;
  cursor: pointer;
  transition: all 0.18s;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.xzd-followup-pill:hover {
  background: var(--xzd-primary);
  border-color: var(--xzd-primary);
  color: #fff;
  transform: translateY(-1px);
}

/* ═══════════════════════════════════════════
   输入区
   ═══════════════════════════════════════════ */
.xzd-chat-input-area {
  padding: 10px 14px 12px;
  border-top: 1px solid rgba(180, 200, 230, 0.25);
  display: flex;
  gap: 8px;
  align-items: flex-end;
  background: rgba(245, 247, 252, 0.5);
  backdrop-filter: var(--xzd-blur-light);
  -webkit-backdrop-filter: var(--xzd-blur-light);
  flex-shrink: 0;
  position: relative;
  z-index: 2;
}
body.dark-theme .xzd-chat-input-area,
#xzd-chat-panel.xzd-dark .xzd-chat-input-area {
  background: rgba(10, 14, 24, 0.4);
  border-top-color: rgba(60, 80, 130, 0.15);
}

.xzd-chat-input {
  flex: 1;
  border: 1px solid var(--xzd-input-border);
  border-radius: var(--xzd-radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  font-family: inherit;
  resize: none;
  outline: none;
  background: var(--xzd-input-bg);
  color: var(--xzd-text);
  min-height: 40px;
  max-height: 120px;
  line-height: 1.5;
  transition: border-color 0.2s, box-shadow 0.2s;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.xzd-chat-input:focus {
  border-color: var(--xzd-primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.10);
}
.xzd-chat-input:disabled { opacity: 0.5; cursor: not-allowed; }
.xzd-chat-input::placeholder { color: var(--xzd-text-muted); }
.xzd-chat-input::-webkit-scrollbar { display: none; }
.xzd-chat-input { scrollbar-width: none; -ms-overflow-style: none; }

.xzd-chat-send-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--xzd-radius-sm);
  border: none;
  background: linear-gradient(135deg, var(--xzd-accent), var(--xzd-accent2));
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s;
}
.xzd-chat-send-btn:hover:not(:disabled) {
  transform: scale(1.06);
  box-shadow: 0 0 16px rgba(13, 147, 115, 0.35);
}
.xzd-chat-send-btn:active:not(:disabled) { transform: scale(0.94); }
.xzd-chat-send-btn:disabled { opacity: 0.35; cursor: not-allowed; transform: none; }

/* 停止按钮 */
.xzd-chat-send-btn.xzd-stop-btn {
  background: var(--xzd-danger);
  animation: xzd-stop-pulse 1.6s ease-in-out infinite;
}
.xzd-chat-send-btn.xzd-stop-btn:hover {
  background: #dc2626;
  box-shadow: 0 0 16px rgba(239, 68, 68, 0.4);
}
@keyframes xzd-stop-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
  50% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
}

/* ═══════════════════════════════════════════
   状态栏 + 快捷栏
   ═══════════════════════════════════════════ */
.xzd-chat-status-bar {
  padding: 5px 16px;
  border-top: 1px solid var(--xzd-glass-border);
  background: var(--xzd-glass-bg-strong);
  font-size: 11px;
  color: var(--xzd-text-muted);
  display: flex;
  justify-content: space-between;
  flex-shrink: 0;
}
.xzd-chat-status-bar strong { color: var(--xzd-text-secondary); font-weight: 500; }

.xzd-chat-quickbar {
  padding: 8px 14px;
  border-top: 1px solid var(--xzd-glass-border);
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  background: var(--xzd-glass-bg-strong);
  flex-shrink: 0;
}
.xzd-chat-quick-btn {
  padding: 4px 9px;
  border-radius: 8px;
  border: 1px solid var(--xzd-glass-border);
  background: rgba(255, 255, 255, 0.3);
  color: var(--xzd-text-secondary);
  font-size: 11px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.xzd-chat-quick-btn:hover {
  border-color: var(--xzd-accent);
  color: var(--xzd-accent);
}

/* ═══════════════════════════════════════════
   会话列表
   ═══════════════════════════════════════════ */
.xzd-chat-sessions {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.xzd-chat-sessions-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--xzd-glass-border);
  font-size: 14px;
  font-weight: 600;
  color: var(--xzd-text);
}
.xzd-chat-sessions-list { flex: 1; overflow-y: auto; padding: 8px; }
.xzd-chat-session-item {
  padding: 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s;
  margin-bottom: 4px;
}
.xzd-chat-session-item:hover { background: var(--xzd-bg-secondary); }
.xzd-chat-session-item.active {
  background: rgba(79, 70, 229, 0.06);
  border: 1px solid var(--xzd-primary);
}
.xzd-chat-session-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--xzd-text);
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.xzd-chat-session-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--xzd-text-muted);
}
.xzd-chat-btn-delete {
  background: none;
  border: none;
  color: var(--xzd-text-muted);
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s;
}
.xzd-chat-session-item:hover .xzd-chat-btn-delete { opacity: 1; }
.xzd-chat-btn-delete:hover { color: var(--xzd-danger); }

/* ═══════════════════════════════════════════

   ═══════════════════════════════════════════ */
.xzd-proactive-toast {
  position: fixed !important;
  z-index: 999997 !important;
  max-width: 320px;
  min-width: 200px;
  background: var(--xzd-glass-bg-strong);
  backdrop-filter: var(--xzd-blur);
  -webkit-backdrop-filter: var(--xzd-blur);
  border: 1px solid var(--xzd-glass-border);
  border-radius: var(--xzd-radius-sm);
  padding: 10px 14px;
  box-shadow: var(--xzd-glass-shadow);
  display: flex;
  align-items: flex-start;
  gap: 10px;
  pointer-events: auto;
  opacity: 0;
  transform: translateX(20px);
  transition: opacity 0.3s cubic-bezier(0.22, 0.61, 0.36, 1),
              transform 0.35s cubic-bezier(0.22, 0.61, 0.36, 1);
  font-size: 13px;
  line-height: 1.5;
  color: var(--xzd-text);
}
.xzd-proactive-toast.xzd-toast-visible {
  opacity: 1;
  transform: translateX(0);
}
.xzd-proactive-toast.xzd-toast-hiding {
  opacity: 0;
  transform: translateX(24px);
  transition: opacity 0.18s ease, transform 0.2s ease;
}
.xzd-toast-icon { flex-shrink: 0; width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.xzd-toast-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  word-break: break-word;
}
.xzd-toast-close {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--xzd-text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  line-height: 1;
  transition: background 0.15s, color 0.15s;
  padding: 0;
}
.xzd-toast-close:hover { background: var(--xzd-bg-tertiary); color: var(--xzd-text); }

.xzd-toast-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.xzd-toast-name {
  font-size: 11px;
  font-weight: 600;
  color: var(--xzd-primary);
  line-height: 1.2;
}
.xzd-toast-links {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.xzd-toast-link {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  background: var(--xzd-primary);
  color: #fff !important;
  font-size: 12px;
  text-decoration: none !important;
  white-space: nowrap;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: opacity 0.15s, transform 0.15s;
  line-height: 1.6;
}
.xzd-toast-link:hover {
  opacity: 0.88;
  transform: scale(1.03);
  color: #fff !important;
}

/* 对话中的推荐链接 */
.xzd-suggestion-links {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.xzd-suggestion-links a {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 14px;
  background: var(--xzd-primary);
  color: #fff !important;
  font-size: 12px;
  text-decoration: none !important;
  transition: opacity 0.15s;
}
.xzd-suggestion-links a:hover { opacity: 0.85; color: #fff !important; }
.xzd-suggestion-links span {
  display: inline-block;
  padding: 4px 12px;
  font-size: 12px;
  color: var(--xzd-text-muted);
}

/* ═══════════════════════════════════════════
   自定义确认弹窗
   ═══════════════════════════════════════════ */
.xzd-confirm-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  opacity: 0;
  transition: opacity 0.2s ease;
  border-radius: inherit;
}
.xzd-confirm-overlay.xzd-confirm-visible { opacity: 1; }
.xzd-confirm-card {
  background: var(--xzd-glass-bg-strong);
  backdrop-filter: var(--xzd-blur);
  -webkit-backdrop-filter: var(--xzd-blur);
  border: 1px solid var(--xzd-glass-border);
  border-radius: 14px;
  padding: 24px;
  max-width: 300px;
  width: 85%;
  box-shadow: var(--xzd-glass-shadow-lg);
  transform: scale(0.9);
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.xzd-confirm-visible .xzd-confirm-card { transform: scale(1); }
.xzd-confirm-card > p { font-size: 13px; color: var(--xzd-text-secondary); margin-bottom: 14px; line-height: 1.5; }
.xzd-confirm-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.xzd-confirm-btn-cancel,
.xzd-chat-btn-cancel {
  padding: 6px 14px;
  border-radius: 7px;
  border: 1px solid var(--xzd-glass-border);
  background: var(--xzd-bg-secondary);
  color: var(--xzd-text);
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s;
}
.xzd-confirm-btn-cancel:hover,
.xzd-chat-btn-cancel:hover { background: var(--xzd-bg-tertiary); }
.xzd-confirm-btn-ok,
.xzd-chat-btn-confirm {
  padding: 6px 14px;
  border-radius: 7px;
  border: none;
  background: var(--xzd-danger);
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s;
}
.xzd-confirm-btn-ok:hover,
.xzd-chat-btn-confirm:hover { opacity: 0.85; }

/* 多选确认 */
.xzd-chat-btn-choice {
  display: block;
  width: 100%;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--xzd-glass-border);
  background: var(--xzd-bg-secondary);
  color: var(--xzd-text);
  font-size: 12px;
  cursor: pointer;
  text-align: left;
  margin-bottom: 6px;
  transition: all 0.15s;
}
.xzd-chat-btn-choice:hover { border-color: var(--xzd-accent); color: var(--xzd-accent); }
.xzd-chat-btn-choice small { display: block; font-size: 10px; color: var(--xzd-text-muted); margin-top: 2px; }

/* ═══════════════════════════════════════════
   移动端响应式
   ═══════════════════════════════════════════ */
@media (max-width: 768px) {
  #xzd-chat-panel {
    top: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    max-width: 100vw !important;
    min-width: unset !important;
    max-height: none !important;
    height: 100dvh !important;
    border-radius: 0 !important;
    border: none !important;
    border-left: none !important;
    transform-origin: center bottom;
  }
  #xzd-chat-panel.xzd-open {
    border-radius: 0 !important;
  }
  #xzd-chat-panel.xzd-theme-deep {
    right: 0 !important;
  }

  .xzd-chat-header {
    border-radius: 0 !important;
    padding-top: max(12px, env(safe-area-inset-top, 0px));
    min-height: 56px;
  }

  .xzd-chat-btn-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
  }

  .xzd-chat-input-area {
    padding-bottom: max(12px, env(safe-area-inset-bottom, 0px));
    padding-left: max(14px, env(safe-area-inset-left, 0px));
    padding-right: max(14px, env(safe-area-inset-right, 0px));
  }

  .xzd-chat-messages {
    padding: 12px 14px;
  }

  .xzd-chat-trigger {
    bottom: max(16px, env(safe-area-inset-bottom, 0px)) !important;
    right: 16px !important;
    width: 48px !important;
    height: 48px !important;
  }
  .xzd-chat-trigger svg {
    width: 20px !important;
    height: 20px !important;
  }

  .xzd-chat-send-btn { width: 44px; height: 44px; }

  .xzd-proactive-toast { max-width: 85vw; right: 12px !important; }

  .xzd-confirm-card { max-width: 85vw; }

  .xzd-scroll-shadow-top { box-shadow: none !important; }
}

/* ─── 小屏手机 ─── */
@media (max-width: 380px) {
  .xzd-chat-header { padding: 10px 12px; }
  .xzd-chat-title { font-size: 14px; }
  .xzd-chat-welcome h3 { font-size: 16px; }
  .xzd-chat-welcome-icon { font-size: 40px; }
  .xzd-chat-input { font-size: 16px; }
}

/* ═══════════════════════════════════════════
   WordPress 后台适配
   ═══════════════════════════════════════════ */
body.wp-admin #xzd-chat-panel { top: 32px; }
@media (max-width: 782px) {
  body.wp-admin #xzd-chat-panel { top: 46px; }
}

/* ═══════════════════════════════════════════
   主题集成按钮样式（通用）
   ═══════════════════════════════════════════ */
.xzd-theme-integrated-btn {
  cursor: pointer;
  position: relative;
  background: var(--float-btn-bg, var(--xzd-ai-btn-bg, #0073aa));
  color: var(--muted-2-color, #666) !important;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  transition: color 0.15s, transform 0.2s;
}
.xzd-theme-integrated-btn:hover {
  color: var(--focus-color, #4f46e5) !important;
  transform: scale(1.06);
}
.xzd-theme-integrated-btn svg {
  width: 18px;
  height: 18px;
}
.xzd-theme-integrated-btn .xzd-chat-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 18px;
  height: 18px;
  border-radius: var(--xzd-badge-radius, 50%);
  background: var(--xzd-danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  line-height: 1;
  box-shadow: 0 2px 4px rgba(239,68,68,0.4);
}

.xzd-theme-integrated-btn.xzd-breathing {
  animation: xzd-breathe var(--xzd-trigger-breath-speed, 4s) ease-in-out infinite;
}
.xzd-theme-integrated-btn.xzd-breathing-off {
  animation: none !important;
}
.xzd-theme-integrated-btn.xzd-hover-scale:hover {
  transform: scale(1.12) !important;
}
.xzd-theme-integrated-btn.xzd-hover-rotate:hover {
  transform: rotate(15deg) !important;
}
.xzd-theme-integrated-btn.xzd-hover-pulse:hover {
  animation: xzd-btn-pulse 0.6s ease-in-out;
}
@keyframes xzd-btn-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.12); }
}

body.dark-theme .xzd-chat-trigger {
  background: linear-gradient(135deg, #10B981, #2563eb) !important;
  box-shadow: 0 4px 20px rgba(16,185,129,.25), 0 0 50px rgba(16,185,129,.06) !important;
}

/* ═══════════════════════════════════════════
   暗色模式代码块 + 通用覆盖
   ═══════════════════════════════════════════ */
body.dark-theme .xzd-chat-content pre,
#xzd-chat-panel.xzd-dark .xzd-chat-content pre {
  background: #0d0d12;
}
body.dark-theme .xzd-chat-content code,
#xzd-chat-panel.xzd-dark .xzd-chat-content code {
  background: rgba(255,255,255,0.08);
  color: #e4e4ed;
}
body.dark-theme .xzd-welcome-card,
#xzd-chat-panel.xzd-dark .xzd-welcome-card {
  background: rgba(255,255,255,0.04);
}
body.dark-theme .xzd-followup-pill,
#xzd-chat-panel.xzd-dark .xzd-followup-pill {
  background: rgba(255,255,255,0.06);
  border-color: rgba(255,255,255,0.08);
}
body.dark-theme .xzd-code-copy-btn,
#xzd-chat-panel.xzd-dark .xzd-code-copy-btn {
  background: rgba(18,18,24,0.9);
  border-color: rgba(255,255,255,0.08);
  color: #9ca3af;
}

/* ─── 暗色模式：表格 ─── */
body.dark-theme .xzd-chat-content table,
#xzd-chat-panel.xzd-dark .xzd-chat-content table {
  border-color: rgba(255,255,255,0.08);
}
body.dark-theme .xzd-chat-content tbody td,
#xzd-chat-panel.xzd-dark .xzd-chat-content tbody td {
  background: rgba(255,255,255,0.02);
  border-bottom-color: rgba(255,255,255,0.06);
}
body.dark-theme .xzd-chat-content tbody tr:nth-child(even) td,
#xzd-chat-panel.xzd-dark .xzd-chat-content tbody tr:nth-child(even) td {
  background: rgba(255,255,255,0.04);
}
body.dark-theme .xzd-chat-content tbody tr:hover td,
#xzd-chat-panel.xzd-dark .xzd-chat-content tbody tr:hover td {
  background: rgba(79,70,229,0.1);
}

/* ─── 暗色模式：键值对数据网格 ─── */
body.dark-theme .xzd-chat-content .xzd-data-grid,
#xzd-chat-panel.xzd-dark .xzd-chat-content .xzd-data-grid {
  background: rgba(255,255,255,0.03);
  border-color: rgba(255,255,255,0.06);
}
body.dark-theme .xzd-chat-content .xzd-data-kv,
#xzd-chat-panel.xzd-dark .xzd-chat-content .xzd-data-kv {
  background: rgba(255,255,255,0.05);
}
body.dark-theme .xzd-chat-content .xzd-data-k,
#xzd-chat-panel.xzd-dark .xzd-chat-content .xzd-data-k {
  color: #8a8fa0;
}
body.dark-theme .xzd-chat-content .xzd-data-v,
#xzd-chat-panel.xzd-dark .xzd-chat-content .xzd-data-v {
  color: #e4e4ed;
}

/* ─── 暗色模式：工具卡片内嵌图片 ─── */
  border-color: rgba(255,255,255,0.08);
}

/* ═══════════════════════════════════════════
   打印时隐藏
   ═══════════════════════════════════════════ */
@media print {
  #xzd-chat-trigger, #xzd-chat-panel { display: none !important; }
}

/* ═══════════════════════════════════════════
   减少动效偏好
   ═══════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
  #xzd-chat-panel,
  #xzd-chat-panel.xzd-open,
  #xzd-chat-panel.xzd-closing {
    transition: opacity 0.15s ease !important;
    transform: none !important;
    animation: none !important;
  }
  .xzd-chat-message { animation: none !important; }
  .xzd-chat-trigger { animation: none !important; }
  .xzd-chat-cursor { animation: none !important; opacity: 0.6; }
  .xzd-online-dot { animation: none !important; }
  .xzd-chat-thinking .xzd-spinner { animation: none !important; }
  .xzd-chat-thinking-dots span { animation: none !important; opacity: 0.3; }
}

/* ═══════════════════════════════════════════
   V3.1.9: 移动端浮动按钮滚动缩小
   ═══════════════════════════════════════════ */
@media (max-width: 767px) {
  .xzd-floating-btn.xzd-btn-shrunk {
    transform: scale(0.6);
    opacity: 0.4;
    transition: transform 0.3s ease, opacity 0.3s ease;
  }
  .xzd-floating-btn.xzd-btn-shrunk:hover,
  .xzd-floating-btn.xzd-btn-shrunk:active {
    transform: scale(1);
    opacity: 1;
  }
}

