/* ===== AI 聊天浮窗样式（v2，对齐 ardot 设计稿）=====
 *
 * 设计令牌通过 CSS 变量管理，支持：
 * 1. 主题色（--ai-chat-color）由 JS 注入，控制用户气泡 / header / 按钮等品牌色
 * 2. 浅 / 深主题通过 @media (prefers-color-scheme: dark) 自动切换
 * 3. 响应式：屏幕 <= 480px 时弹窗占满屏幕
 */

/* ---------- 设计令牌：浅色（默认） ---------- */
#ai-chat-window,
#ai-chat-trigger {
  --ai-chat-color: #7C3BED;            /* 品牌紫，被 JS 用配置色覆盖 */
  --ai-chat-text-accent: var(--ai-chat-color); /* 用作前景文字时的强调色（链接 / chip 文字 / 代码） */
  --ai-chat-bg-window: #FFFFFF;
  --ai-chat-bg-bubble-ai: #F5F2FF;     /* AI 气泡 / 快捷问题 chip 背景 */
  --ai-chat-bg-input: #F5F2FF;
  --ai-chat-bg-avatar: #EDEDFA;
  --ai-chat-text: #1E1C4A;
  --ai-chat-text-muted: #63738C;
  --ai-chat-text-placeholder: #A68CFA;
  --ai-chat-border: #DED6FF;
  --ai-chat-online: #33F280;
  --ai-chat-shadow-window: 0 8px 32px rgba(0,0,0,0.08), 0 2px 12px rgba(0,0,0,0.04);
  --ai-chat-shadow-trigger: 0 4px 16px rgba(124,59,237,0.3), 0 6px 20px rgba(0,0,0,0.12);
}

/* ---------- 设计令牌：深色 ---------- *
 * 触发条件（任一满足）：
 *   1. data-theme="dark"          — admin 在 Console 强制深色
 *   2. data-theme="auto" + 系统暗 — admin 选「跟随系统」且访客 OS 是深色
 * data-theme="light" 永远走上面的浅色 token，不会被这里覆盖。
 *
 * 调色注意：背景灰度比纯黑高一档 (#2A/#3A 系)，避免主题色（紫/蓝）字配纯黑底刺眼。
 */
#ai-chat-window[data-theme="dark"],
#ai-chat-trigger[data-theme="dark"] {
  --ai-chat-bg-window: #353548;
  --ai-chat-bg-bubble-ai: #45455E;
  --ai-chat-bg-input: #3E3E54;
  --ai-chat-bg-avatar: #494965;
  --ai-chat-text: #F0F0F5;
  --ai-chat-text-muted: #B8B8CE;
  --ai-chat-text-placeholder: #8A8AA8;
  --ai-chat-text-accent: #C4B5FD;        /* 深色下用浅紫做强调，避免主题色（紫蓝）在深底上对比度差 */
  --ai-chat-border: #555570;
  --ai-chat-shadow-window: 0 8px 40px rgba(0,0,0,0.45), 0 2px 12px rgba(0,0,0,0.25);
}
@media (prefers-color-scheme: dark) {
  #ai-chat-window[data-theme="auto"],
  #ai-chat-trigger[data-theme="auto"] {
    --ai-chat-bg-window: #353548;
    --ai-chat-bg-bubble-ai: #45455E;
    --ai-chat-bg-input: #3E3E54;
    --ai-chat-bg-avatar: #494965;
    --ai-chat-text: #F0F0F5;
    --ai-chat-text-muted: #B8B8CE;
    --ai-chat-text-placeholder: #8A8AA8;
    --ai-chat-text-accent: #C4B5FD;
    --ai-chat-border: #555570;
    --ai-chat-shadow-window: 0 8px 40px rgba(0,0,0,0.45), 0 2px 12px rgba(0,0,0,0.25);
  }
}

/* ===== 悬浮按钮（仿 Dream 主题 .actions > div 同款规格）===== */
#ai-chat-trigger {
  position: fixed;
  /* 后台配置/JS 自动避让给出基线，安全区保证 iPhone 底部工具栏不会压住按钮。 */
  bottom: max(
    var(--ai-chat-trigger-bottom, 120px),
    calc(12px + env(safe-area-inset-bottom, 0px))
  );
  width: 35px;
  height: 35px;
  border-radius: var(--ai-chat-trigger-radius, 5px);
  border: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  /* 优先用博客主题色变量（Dream 主题在 :root 定义 --theme），fallback 到插件配置色 */
  background-color: var(--ai-chat-color, var(--theme, #7C3BED));
  color: #fff;
  font-size: 20px;
  line-height: 32px;
  text-align: center;
  opacity: 0.9;
  transition: opacity 0.2s ease, transform 0.15s ease;
  z-index: 999998;
  padding: 0;
}
#ai-chat-trigger:hover { opacity: 1; transform: scale(1.05); }
#ai-chat-trigger:active { transform: scale(0.95); }
#ai-chat-trigger.position-right {
  right: max(
    var(--ai-chat-trigger-x, 16px),
    calc(8px + env(safe-area-inset-right, 0px))
  );
}
#ai-chat-trigger.position-left {
  left: max(
    var(--ai-chat-trigger-x, 16px),
    calc(8px + env(safe-area-inset-left, 0px))
  );
}
#ai-chat-trigger i { font-size: 20px; line-height: 1; }
/* SVG fallback（博客没装 Remix Icon 时用）*/
#ai-chat-trigger svg { width: 20px; height: 20px; stroke: currentColor; }
#ai-chat-trigger .ai-trigger-label {
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1;
}

.ai-chat-header-avatar .ai-avatar-label,
.ai-chat-row-avatar .ai-avatar-label {
  font-weight: 700;
  font-size: 12px;
  line-height: 1;
}

/* ===== 聊天窗口容器 ===== */
#ai-chat-window {
  position: fixed;
  bottom: var(--ai-chat-window-bottom, 165px);
  border-radius: 16px;
  box-shadow: var(--ai-chat-shadow-window);
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 999999;
  background: var(--ai-chat-bg-window);
  color: var(--ai-chat-text);
  font-family: -apple-system, BlinkMacSystemFont, "Plus Jakarta Sans", "Segoe UI",
               "PingFang SC", "Microsoft YaHei", Roboto, sans-serif;
  font-size: 13px;
  /* 弹窗淡入 */
  animation: ai-chat-pop 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}
#ai-chat-window.open { display: flex; }
#ai-chat-window.position-right { right: var(--ai-chat-window-x, 24px); }
#ai-chat-window.position-left  { left: var(--ai-chat-window-x, 24px); }

#ai-chat-window.ai-embed {
  position: relative !important;
  right: auto !important;
  bottom: auto !important;
  left: auto !important;
  width: 100% !important;
  height: 100% !important;
  max-height: none;
  border-radius: 0;
  box-shadow: none;
  display: flex !important;
  flex-direction: column;
}

@keyframes ai-chat-pop {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ===== 头部 ===== */
.ai-chat-header {
  background: var(--ai-chat-color);
  padding: 10px 14px;
  color: white;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.ai-chat-header-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ai-chat-color);
  flex-shrink: 0;
}
.ai-chat-header-avatar svg { width: 17px; height: 17px; }
.ai-chat-header-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}
.ai-chat-header h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.2;
}
.ai-chat-close {
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: white;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 0.2s;
}
.ai-chat-close:hover { background: rgba(255, 255, 255, 0.28); }
.ai-chat-close svg { width: 16px; height: 16px; }

.ai-chat-clear-area {
  text-align: center;
  padding: 6px 0;
}

.ai-chat-clear-btn {
  background: none;
  border: none;
  color: var(--ai-chat-text-muted, #8a94a6);
  font-size: 11px;
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: inherit;
  transition: color 0.2s, background 0.2s;
}

.ai-chat-clear-btn:hover {
  color: var(--ai-chat-text, #111827);
  background: var(--ai-chat-bg-bubble-ai, #f3f4f6);
}

.ai-chat-clear-icon {
  width: 13px;
  height: 13px;
}

/* ===== 消息区 ===== */
.ai-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--ai-chat-bg-window);
}
/* 自定义滚动条 */
.ai-chat-messages::-webkit-scrollbar { width: 6px; }
.ai-chat-messages::-webkit-scrollbar-track { background: transparent; }
.ai-chat-messages::-webkit-scrollbar-thumb {
  background: var(--ai-chat-border);
  border-radius: 3px;
}

/* 消息行（带头像）= flex 容器 */
.ai-chat-row {
  display: flex;
  gap: 8px;
  align-items: flex-start;  /* 头像对齐气泡顶部，与消息主体建立视觉连接 */
  max-width: 100%;
}
.ai-chat-row.user { justify-content: flex-end; }
.ai-chat-row.user .ai-chat-content { max-width: 100%; }
/* 气泡 + 操作区的纵向包装层，让 actions 按钮垂直排列在气泡下方 */
.ai-chat-content {
  display: flex;
  flex-direction: column;
  max-width: calc(100% - 36px);
}
.ai-chat-row-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--ai-chat-bg-avatar);
  color: var(--ai-chat-text-accent);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 6px;  /* 让头像视觉中心对齐气泡首行文字 */
}
.ai-chat-row-avatar svg { width: 14px; height: 14px; }

/* 单条消息 */
.ai-chat-msg {
  max-width: 100%;
  padding: 10px 14px;
  border-radius: 14px;
  line-height: 1.6;
  word-break: break-word;
  font-size: 13px;
}
.ai-chat-msg.user {
  background: var(--ai-chat-color);
  color: white;
  border-bottom-right-radius: 4px;
}
.ai-chat-msg.assistant {
  background: var(--ai-chat-bg-bubble-ai);
  color: var(--ai-chat-text);
  border-bottom-left-radius: 4px;
}

/* ===== 欢迎区下的快捷问题 chip ===== */
.ai-chat-shortcuts {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-left: 36px; /* 与 AI 气泡对齐（让出头像位） */
}

.ai-shortcut-card {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  max-width: 280px;
  padding: 10px 14px;
  background: var(--ai-chat-bg-bubble-ai, #F5F2FF);
  border: 1px solid var(--ai-chat-border, #DED6FF);
  border-radius: 10px;
  font-family: inherit;
  font-size: 13px;
  color: var(--ai-chat-text, #1E1C4A);
  cursor: pointer;
  text-align: left;
  transition: transform 0.15s, background 0.2s, border-color 0.2s;
}

.ai-shortcut-card:hover {
  transform: translateY(-1px);
  border-color: var(--ai-chat-color, #7C3BED);
  background: var(--ai-chat-color, #7C3BED);
  color: #fff;
}

.ai-shortcut-card:hover .ai-shortcut-card-icon {
  /* emoji 本身即显示，不额外处理 */;
}

.ai-shortcut-card:active { transform: translateY(0); }

.ai-shortcut-card-icon {
  font-size: 16px;
  flex-shrink: 0;
}

.ai-shortcut-card-text {
  flex: 1;
  min-width: 0;
}

/* ===== Markdown 渲染样式（assistant 气泡内） ===== */
.ai-chat-msg.assistant p { margin: 4px 0; }
.ai-chat-msg.assistant p:first-child { margin-top: 0; }
.ai-chat-msg.assistant p:last-child { margin-bottom: 0; }
.ai-chat-msg.assistant ul,
.ai-chat-msg.assistant ol {
  margin: 6px 0;
  padding-left: 20px;
}
.ai-chat-msg.assistant li { margin: 2px 0; }
.ai-chat-msg.assistant h1,
.ai-chat-msg.assistant h2,
.ai-chat-msg.assistant h3,
.ai-chat-msg.assistant h4 {
  margin: 10px 0 6px;
  font-weight: 600;
  line-height: 1.3;
}
.ai-chat-msg.assistant h1 { font-size: 16px; }
.ai-chat-msg.assistant h2 { font-size: 14px; }
.ai-chat-msg.assistant h3,
.ai-chat-msg.assistant h4 { font-size: 13px; }
.ai-chat-msg.assistant code {
  background: rgba(124, 59, 237, 0.12);
  color: var(--ai-chat-text-accent);
  padding: 1px 5px;
  border-radius: 3px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}
.ai-chat-msg.assistant pre {
  background: #1E1C4A;
  color: #F4F4F8;
  padding: 10px 12px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 8px 0;
  font-size: 12px;
  line-height: 1.5;
}
.ai-chat-msg.assistant pre code {
  background: none;
  padding: 0;
  color: inherit;
  font-size: inherit;
}
.ai-chat-msg.assistant blockquote {
  margin: 6px 0;
  padding: 2px 0 2px 10px;
  border-left: 3px solid var(--ai-chat-border);
  color: var(--ai-chat-text-muted);
}
.ai-chat-msg.assistant a {
  color: var(--ai-chat-text-accent);
  text-decoration: underline;
}
.ai-chat-msg.assistant table {
  border-collapse: collapse;
  margin: 8px 0;
  font-size: 12px;
}
.ai-chat-msg.assistant th,
.ai-chat-msg.assistant td {
  border: 1px solid var(--ai-chat-border);
  padding: 4px 8px;
  text-align: left;
}
.ai-chat-msg.assistant th {
  background: var(--ai-chat-bg-bubble-ai);
  font-weight: 600;
}
.ai-chat-msg.assistant hr {
  border: none;
  border-top: 1px solid var(--ai-chat-border);
  margin: 10px 0;
}

/* ===== 热门推荐卡片样式（Ardot 设计稿 — 渐变色条 + 排名徽章）===== */
/* JS 后处理将 Markdown 的 hr+p>strong>a+blockquote 重组为 .ai-hot-card[data-rank=N] */

.ai-hot-card {
  display: flex;
  background: #FFFFFF;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
  margin: 8px 0;
  transition: box-shadow 0.2s, transform 0.15s;
}
.ai-hot-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
  transform: translateY(-1px);
}
/* 左侧渐变色条 — 每个排名不同颜色 */
.ai-hot-card-bar {
  width: 4px;
  flex-shrink: 0;
}
/* 卡片内容区 */
.ai-hot-card-body {
  flex: 1;
  padding: 10px 14px;
  min-width: 0;
}
/* 排名徽章 + 标题行 */
.ai-hot-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
}
/* 渐变排名徽章 */
.ai-hot-card-badge {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
  line-height: 1;
}
/* 标题链接 */
.ai-hot-card-title {
  color: var(--ai-chat-text);
  text-decoration: none;
  font-weight: 600;
  font-size: 13.5px;
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ai-hot-card-title:hover {
  color: var(--ai-chat-text-accent);
  text-decoration: underline;
}
/* 描述行 */
.ai-hot-card-desc {
  color: var(--ai-chat-text-muted);
  font-size: 12px;
  margin-top: 4px;
  padding-left: 38px;
  line-height: 1.5;
}

/* ── 按排名分配渐变色（来自 Ardot 设计稿）── */
/* #1 蓝紫 */
.ai-hot-card[data-rank="1"] .ai-hot-card-bar { background: linear-gradient(to bottom, #6366F1, #A855F7); }
.ai-hot-card[data-rank="1"] .ai-hot-card-badge { background: linear-gradient(135deg, #6366F1, #A855F7); }
/* #2 粉橙 */
.ai-hot-card[data-rank="2"] .ai-hot-card-bar { background: linear-gradient(to bottom, #F5405E, #FA7317); }
.ai-hot-card[data-rank="2"] .ai-hot-card-badge { background: linear-gradient(135deg, #F5405E, #FA7317); }
/* #3 绿青 */
.ai-hot-card[data-rank="3"] .ai-hot-card-bar { background: linear-gradient(to bottom, #10BA82, #05B5D4); }
.ai-hot-card[data-rank="3"] .ai-hot-card-badge { background: linear-gradient(135deg, #10BA82, #05B5D4); }
/* #4 橙黄 */
.ai-hot-card[data-rank="4"] .ai-hot-card-bar { background: linear-gradient(to bottom, #F59E0A, #FABF24); }
.ai-hot-card[data-rank="4"] .ai-hot-card-badge { background: linear-gradient(135deg, #F59E0A, #FABF24); }
/* #5 粉红 */
.ai-hot-card[data-rank="5"] .ai-hot-card-bar { background: linear-gradient(to bottom, #ED4A99, #FA7085); }
.ai-hot-card[data-rank="5"] .ai-hot-card-badge { background: linear-gradient(135deg, #ED4A99, #FA7085); }
/* #6+ 循环回蓝紫 */
.ai-hot-card[data-rank="6"] .ai-hot-card-bar { background: linear-gradient(to bottom, #6366F1, #A855F7); }
.ai-hot-card[data-rank="6"] .ai-hot-card-badge { background: linear-gradient(135deg, #6366F1, #A855F7); }
.ai-hot-card[data-rank="7"] .ai-hot-card-bar { background: linear-gradient(to bottom, #F5405E, #FA7317); }
.ai-hot-card[data-rank="7"] .ai-hot-card-badge { background: linear-gradient(135deg, #F5405E, #FA7317); }
.ai-hot-card[data-rank="8"] .ai-hot-card-bar { background: linear-gradient(to bottom, #10BA82, #05B5D4); }
.ai-hot-card[data-rank="8"] .ai-hot-card-badge { background: linear-gradient(135deg, #10BA82, #05B5D4); }
.ai-hot-card[data-rank="9"] .ai-hot-card-bar { background: linear-gradient(to bottom, #F59E0A, #FABF24); }
.ai-hot-card[data-rank="9"] .ai-hot-card-badge { background: linear-gradient(135deg, #F59E0A, #FABF24); }
.ai-hot-card[data-rank="10"] .ai-hot-card-bar { background: linear-gradient(to bottom, #ED4A99, #FA7085); }
.ai-hot-card[data-rank="10"] .ai-hot-card-badge { background: linear-gradient(135deg, #ED4A99, #FA7085); }

/* ── 深色主题 ── */
#ai-chat-window[data-theme="dark"] .ai-hot-card {
  background: #1A1A2E;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}
#ai-chat-window[data-theme="dark"] .ai-hot-card:hover {
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
}
#ai-chat-window[data-theme="dark"] .ai-hot-card-title {
  color: #F0F0F5;
}
#ai-chat-window[data-theme="dark"] .ai-hot-card-title:hover {
  color: #C4B5FD;
}
#ai-chat-window[data-theme="dark"] .ai-hot-card-desc {
  color: #9CA3AF;
}
@media (prefers-color-scheme: dark) {
  #ai-chat-window[data-theme="auto"] .ai-hot-card {
    background: #1A1A2E;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
  }
  #ai-chat-window[data-theme="auto"] .ai-hot-card:hover {
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
  }
  #ai-chat-window[data-theme="auto"] .ai-hot-card-title {
    color: #F0F0F5;
  }
  #ai-chat-window[data-theme="auto"] .ai-hot-card-title:hover {
    color: #C4B5FD;
  }
  #ai-chat-window[data-theme="auto"] .ai-hot-card-desc {
    color: #9CA3AF;
  }
}

/* ===== 思考中三点动画 ===== */
.ai-chat-typing {
  display: flex;
  gap: 4px;
  padding: 12px 14px;
  background: var(--ai-chat-bg-bubble-ai);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  align-self: flex-start;
  margin-left: 36px; /* 与 AI 气泡对齐 */
  max-width: fit-content;
}
.ai-chat-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ai-chat-color);
  opacity: 0.4;
  animation: ai-bounce 1.4s infinite ease-in-out;
}
.ai-chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.ai-chat-typing span:nth-child(3) { animation-delay: 0.4s; }

.ai-chat-typing.ai-typing-text {
  font-size: 13px;
  color: var(--ai-chat-text-secondary, #6b7280);
  padding: 10px 16px;
  gap: 0;
  animation: ai-status-fade-in 0.3s ease;
}

@keyframes ai-status-fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes ai-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.3; }
  40%           { transform: translateY(-4px); opacity: 1; }
}

/* ===== 输入区 ===== */
.ai-chat-input-area {
  padding: 12px 12px 8px;
  border-top: 1px solid var(--ai-chat-border);
  display: flex;
  gap: 8px;
  flex-shrink: 0;
  background: var(--ai-chat-bg-window);
  align-items: flex-end;
}
.ai-chat-input {
  flex: 1;
  border: none;
  background: var(--ai-chat-bg-input);
  border-radius: 20px;
  padding: 10px 16px;
  font-size: 13px;
  outline: none;
  resize: none;
  font-family: inherit;
  color: var(--ai-chat-text);
  min-height: 40px;
  max-height: 100px;
  line-height: 1.5;
  transition: box-shadow 0.2s;
}
.ai-chat-input::placeholder { color: var(--ai-chat-text-placeholder); }
.ai-chat-input:focus { box-shadow: 0 0 0 2px rgba(124, 59, 237, 0.2); }
.ai-chat-send {
  border: none;
  border-radius: 50%;
  background: var(--ai-chat-color);
  color: white;
  width: 40px;
  height: 40px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.15s, opacity 0.2s;
  padding: 0;
}
.ai-chat-send:hover:not(:disabled) { transform: scale(1.05); }
.ai-chat-send:active:not(:disabled) { transform: scale(0.95); }
.ai-chat-send:disabled { opacity: 0.5; cursor: not-allowed; }
.ai-chat-send svg { width: 18px; height: 18px; }

/* ===== 引用来源：气泡内可折叠 section ===== */
.ai-chat-msg-divider {
  border: none;
  border-top: 1px solid var(--ai-chat-border);
  /* 负 margin 让分隔线延伸到气泡 padding 边界 */
  margin: 12px -14px 8px;
}

.ai-chat-msg-cites {
  margin: 0;
}

.ai-chat-msg-cites-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  padding: 4px 0;
  color: var(--ai-chat-text-muted);
  font-size: 12px;
  user-select: none;
  border-radius: 4px;
  transition: color 0.15s;
}
.ai-chat-msg-cites-header:hover { color: var(--ai-chat-text); }
.ai-chat-msg-cites-header:focus { outline: none; }
.ai-chat-msg-cites-header:focus-visible {
  outline: 2px solid var(--ai-chat-color);
  outline-offset: 2px;
}

.ai-chat-msg-cites-label { flex: 1; min-width: 0; }
.ai-chat-msg-cites-count {
  color: var(--ai-chat-text-accent);
  font-weight: 600;
  margin: 0 1px;
}

.ai-chat-msg-cites-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  margin-left: 4px;
  transition: transform 0.2s ease;
}
.ai-chat-msg-cites-toggle svg { width: 14px; height: 14px; }
.ai-chat-msg-cites.expanded .ai-chat-msg-cites-toggle {
  transform: rotate(180deg);
}

.ai-chat-msg-cites-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 4px;
}
.ai-chat-msg-cites:not(.expanded) .ai-chat-msg-cites-body {
  display: none;
}

/* 引用链接（气泡内版本）：编号徽章 + 文件图标 + 文字 */
.ai-chat-msg-cites-body .ai-cite-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
  color: var(--ai-chat-text);
  text-decoration: none;
  background: transparent;
  font-size: 12px;
  line-height: 1.4;
  word-break: break-all;
  transition: color 0.15s;
}
.ai-chat-msg-cites-body .ai-cite-link:hover {
  color: var(--ai-chat-text-accent);
  text-decoration: underline;
  background: transparent;
}
.ai-chat-msg-cites-body .ai-cite-link-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--ai-chat-color);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  flex-shrink: 0;
}
.ai-chat-msg-cites-body .ai-cite-link-text { flex: 1; min-width: 0; }

.ai-chat-msg-cites-body .ai-cite-link.ai-cite-disabled {
  opacity: 0.6;
  cursor: default;
}
.ai-chat-msg-cites-body .ai-cite-link.ai-cite-disabled .ai-cite-link-num {
  background: var(--ai-chat-text-muted);
}
.ai-chat-msg-cites-body .ai-cite-link.ai-cite-disabled:hover {
  color: var(--ai-chat-text);
  text-decoration: none;
}
/* 气泡内的链接不需要 ::before 数字小圆 — 已有 .ai-cite-link-num 元素 */
.ai-chat-msg-cites-body .ai-cite-link::before { content: none; }

/* 点击 inline 角标后的目标高亮闪烁 */
.ai-cite-link.ai-cite-highlight {
  animation: ai-cite-flash 1.2s ease-out;
}
@keyframes ai-cite-flash {
  0%   { box-shadow: 0 0 0 0 rgba(124, 59, 237, 0); }
  20%  { box-shadow: 0 0 0 4px rgba(124, 59, 237, 0.45); }
  100% { box-shadow: 0 0 0 0 rgba(124, 59, 237, 0); }
}

/* ===== AI 正文里的 inline 引用角标 [N] ===== */
.ai-cite-inline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  margin: 0 2px;
  border-radius: 8px;
  background: var(--ai-chat-color);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  vertical-align: super;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(124, 59, 237, 0.35);
  transition: transform 0.12s;
  user-select: none;
}
.ai-cite-inline:hover { transform: translateY(-1px) scale(1.08); }
.ai-cite-inline:active { transform: translateY(0); }

/* ===== 输入区下的 AI 免责声明 ===== */
.ai-chat-privacy-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 14px;
  background: var(--ai-chat-bg-bubble-ai, #F5F2FF);
  border-bottom: 1px solid var(--ai-chat-border, #DED6FF);
  font-size: 11px;
  color: var(--ai-chat-text-muted, #63738C);
  line-height: 1.5;
}

.ai-chat-privacy-close {
  background: none;
  border: none;
  color: var(--ai-chat-text-muted, #8a94a6);
  font-size: 14px;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
}

.ai-chat-privacy-close:hover { color: var(--ai-chat-text, #111827); }

.ai-chat-disclaimer {
  text-align: center;
  padding: 0 12px 8px;
  font-size: 11px;
  color: var(--ai-chat-text-muted);
  background: var(--ai-chat-bg-window);
  flex-shrink: 0;
}

/* citations chip 前缀编号（小圆徽章）— 给搜索结果页卡片用 */
.ai-cite-link {
  padding-left: 4px;            /* 给编号让点空间 */
}
.ai-cite-link::before,
.ai-cite-link.ai-cite-disabled::before {
  content: attr(data-num);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  margin-right: 6px;
  margin-left: -2px;
  border-radius: 50%;
  background: var(--ai-chat-color);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  box-shadow: 0 1px 3px rgba(124, 59, 237, 0.35);
  vertical-align: middle;
  flex-shrink: 0;
}
/* disabled 的编号也变灰，跟链接整体协调 */
.ai-cite-link.ai-cite-disabled::before {
  background: var(--ai-chat-text-muted);
  box-shadow: none;
}

/* ===== 可拖拽尺寸 — 左 / 上 / 左上角三块 handle ===== */
.ai-chat-resize-handle {
  position: absolute;
  z-index: 10;
  /* 透明，仅靠 cursor 提示 */
}
.ai-chat-resize-left {
  left: 0;
  top: 0;
  bottom: 0;
  width: 6px;
  cursor: ew-resize;
}
.ai-chat-resize-top {
  left: 0;
  right: 0;
  top: 0;
  height: 6px;
  cursor: ns-resize;
}
.ai-chat-resize-corner {
  left: 0;
  top: 0;
  width: 12px;
  height: 12px;
  cursor: nwse-resize;
  z-index: 11; /* 比左 / 上 handle 高，左上 12x12 区域优先触发斜向拖拽 */
}
/* 左下角浮窗位置时隐藏 handle —— handle 在左/上边缘会跨过屏幕边界，意义不大 */
#ai-chat-window.position-left .ai-chat-resize-handle {
  display: none;
}

/* ===== AI 消息操作工具条（点赞/点踩/重生成/复制）===== */
.ai-chat-msg-actions {
  display: flex;
  gap: 2px;
  align-items: center;
  justify-content: flex-end;  /* 右对齐 */
  margin-top: 8px;
  height: 24px;
  font-size: 11px;
}

.ai-chat-msg-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--ai-chat-text-muted, #63738C);
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
  font-family: inherit;
  line-height: 1;
}

.ai-chat-msg-btn svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.ai-chat-msg-btn:hover:not(:disabled) {
  color: var(--ai-chat-text-accent, #7C3BED);
  background: var(--ai-chat-bg-bubble-ai, #F5F2FF);
}

.ai-chat-msg-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.ai-chat-msg-btn.liked {
  color: #10b981;
}
.ai-chat-msg-btn.liked:hover { color: #059669; }
.ai-chat-msg-btn.disliked {
  color: #ef4444;
}
.ai-chat-msg-btn.disliked:hover { color: #dc2626; }

/* 深色主题下按钮 hover 背景 */
#ai-chat-window[data-theme="dark"] .ai-chat-msg-btn:hover:not(:disabled) {
  color: var(--ai-chat-text-accent, #C4B5FD);
  background: rgba(255, 255, 255, 0.08);
}
@media (prefers-color-scheme: dark) {
  #ai-chat-window[data-theme="auto"] .ai-chat-msg-btn:hover:not(:disabled) {
    color: var(--ai-chat-text-accent, #C4B5FD);
    background: rgba(255, 255, 255, 0.08);
  }
}

/* ===== 简易 toast ===== */
.ai-chat-toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 14px;
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  font-size: 12px;
  border-radius: 6px;
  z-index: 999999;
  pointer-events: none;
  animation: ai-toast-fade 1.5s ease-out;
}
@keyframes ai-toast-fade {
  0%   { opacity: 0; transform: translate(-50%, 10px); }
  10%  { opacity: 1; transform: translate(-50%, 0); }
  90%  { opacity: 1; transform: translate(-50%, 0); }
  100% { opacity: 0; transform: translate(-50%, 0); }
}

/* ===== 点踩评论弹窗（替换 window.prompt）===== */
.ai-feedback-modal {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: ai-feedback-modal-in 0.18s ease;
}
.ai-feedback-modal[hidden] { display: none; }

@keyframes ai-feedback-modal-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.ai-feedback-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

.ai-feedback-modal-card {
  position: relative;
  width: calc(100% - 32px);
  max-width: 320px;
  background: var(--ai-chat-bg-window, #fff);
  color: var(--ai-chat-text, #1E1C4A);
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
  padding: 16px 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  animation: ai-feedback-modal-pop 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes ai-feedback-modal-pop {
  from { transform: scale(0.96) translateY(4px); opacity: 0; }
  to   { transform: scale(1) translateY(0); opacity: 1; }
}

.ai-feedback-modal-title {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--ai-chat-text, #1E1C4A);
}

.ai-feedback-modal-hint {
  font-size: 11px;
  color: var(--ai-chat-text-muted, #63738C);
  line-height: 1.4;
  margin-top: -4px;
}

.ai-feedback-modal-input {
  width: 100%;
  min-height: 80px;
  max-height: 160px;
  padding: 8px 10px;
  border: 1px solid var(--ai-chat-border, #DED6FF);
  border-radius: 8px;
  background: var(--ai-chat-bg-input, #F5F2FF);
  color: var(--ai-chat-text, #1E1C4A);
  font-family: inherit;
  font-size: 13px;
  line-height: 1.5;
  resize: vertical;
  outline: none;
  box-sizing: border-box;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.ai-feedback-modal-input:focus {
  border-color: var(--ai-chat-color, #7C3BED);
  box-shadow: 0 0 0 3px rgba(124, 59, 237, 0.15);
}
.ai-feedback-modal-input::placeholder {
  color: var(--ai-chat-text-placeholder, #A68CFA);
}

.ai-feedback-modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 2px;
}
.ai-feedback-modal-count {
  font-size: 11px;
  color: var(--ai-chat-text-muted, #63738C);
  font-variant-numeric: tabular-nums;
}
.ai-feedback-modal-count-num {
  color: var(--ai-chat-text, #1E1C4A);
  font-weight: 600;
}
.ai-feedback-modal-actions {
  display: flex;
  gap: 8px;
}
.ai-feedback-modal-btn {
  font-family: inherit;
  font-size: 12px;
  line-height: 1;
  padding: 7px 14px;
  border-radius: 6px;
  border: 1px solid var(--ai-chat-border, #DED6FF);
  background: var(--ai-chat-bg-window, #fff);
  color: var(--ai-chat-text, #1E1C4A);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.ai-feedback-modal-btn:hover {
  background: var(--ai-chat-bg-bubble-ai, #F5F2FF);
}
.ai-feedback-modal-submit {
  background: var(--ai-chat-color, #7C3BED);
  border-color: var(--ai-chat-color, #7C3BED);
  color: #fff;
}
.ai-feedback-modal-submit:hover {
  filter: brightness(1.08);
  background: var(--ai-chat-color, #7C3BED);
}

/* 深色主题：弹窗内容自动跟随（CSS 变量切换） */
#ai-chat-window[data-theme="dark"] .ai-feedback-modal-backdrop {
  background: rgba(0, 0, 0, 0.6);
}
#ai-chat-window[data-theme="dark"] .ai-feedback-modal-input:focus {
  box-shadow: 0 0 0 3px rgba(196, 181, 253, 0.2);
}
@media (prefers-color-scheme: dark) {
  #ai-chat-window[data-theme="auto"] .ai-feedback-modal-backdrop {
    background: rgba(0, 0, 0, 0.6);
  }
  #ai-chat-window[data-theme="auto"] .ai-feedback-modal-input:focus {
    box-shadow: 0 0 0 3px rgba(196, 181, 253, 0.2);
  }
}

/* ===== AI 搜索结果页综合回答卡片（挂在博客正文顶部）=====
 * 与浮窗 (#ai-chat-window) 独立 — 卡片不在浮窗容器内, 必须自带 data-theme
 * 透传 + 自己的 token 副本覆盖深色模式.
 */

/* ===== 响应式：手机全屏 ===== */
@media (max-width: 480px) {
  #ai-chat-window {
    bottom: 0 !important;
    right: 0 !important;
    left: 0 !important;
    top: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    height: 100dvh !important;
    border-radius: 0;
  }
  /* 按钮位置继续使用配置变量与自动避让结果，不在手机端写死覆盖。 */
  /* 手机端隐藏拖拽 handle —— 已经全屏没法拖了 */
  .ai-chat-resize-handle { display: none; }
}

/* ===== AI 搜索弹框 ===== */

/* 遮罩层 — 降透明度 + 自身模糊，避免把背景"糊死" */
.ai-search-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 18, 30, 0.28);
  backdrop-filter: blur(6px) saturate(120%);
  -webkit-backdrop-filter: blur(6px) saturate(120%);
  z-index: 10000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 10vh;
  animation: ai-search-fadein 0.15s ease;
}
@keyframes ai-search-fadein {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* 弹框容器 — 毛玻璃：半透底 + 大模糊 + 细边 + 柔和阴影 */
.ai-search-modal {
  width: 580px;
  max-width: 92vw;
  max-height: 70vh;
  background: var(--ai-chat-bg-window, #fff);
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.55);
  box-shadow:
    0 32px 100px rgba(0, 0, 0, 0.22),
    0 12px 32px rgba(0, 0, 0, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: ai-search-slideup 0.2s ease;
}
@keyframes ai-search-slideup {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* 搜索输入区 — 聚焦时底部紫色光晕（替代静态 line） */
.ai-search-input-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 48px;
  padding: 0 14px;
  border-bottom: 1px solid var(--ai-chat-border, rgba(0, 0, 0, 0.06));
  box-shadow: none;
  transition: border-color 0.2s ease, box-shadow 0.25s ease;
}
.ai-search-input-wrap:focus-within {
  border-bottom-color: transparent;
  box-shadow:
    inset 0 -1.5px 0 0 var(--ai-chat-color, #7C3BED),
    0 6px 20px -8px var(--ai-chat-color, #7C3BED);
}
.ai-search-icon {
  width: 24px;
  height: 24px;
  color: var(--ai-chat-color, #7C3BED);
  flex-shrink: 0;
}
.ai-search-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 15px;
  color: var(--ai-chat-text, #1a1a1a);
  line-height: 1.5;
  min-width: 0;
}
.ai-search-input::placeholder {
  color: var(--ai-chat-text-placeholder, #aaa);
}
.ai-search-clear {
  border: none;
  background: transparent;
  color: var(--ai-chat-text-muted, #999);
  font-size: 16px;
  cursor: pointer;
  width: 24px;
  height: 24px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: color 0.12s;
}
.ai-search-clear:hover { color: var(--ai-chat-text, #333); }
/* 关闭按钮 — 桌面端低调（移动端在下方 media query 里放大，确保可触摸退出全屏弹窗） */
.ai-search-close {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  border-radius: 8px;
  color: var(--ai-chat-text-muted, #6b7280);
  cursor: pointer;
  transition: color 0.12s, background-color 0.12s;
}
.ai-search-close svg { width: 18px; height: 18px; display: block; }
.ai-search-close:hover {
  color: var(--ai-chat-text, #333);
  background: rgba(0, 0, 0, 0.05);
}

/* 结果滚动区 */
.ai-search-results {
  flex: 1;
  overflow-y: auto;
  padding: 0;
}

/* 空状态 */
.ai-search-empty {
  padding: 48px 20px;
  text-align: center;
  color: var(--ai-chat-text-muted, #999);
  font-size: 14px;
}

/* AI 回答区 — 渐变背景 + 顶部紫色装饰线，强调"AI 直接答案" */
.ai-search-ai-section {
  padding: 18px 20px 20px;
  border-bottom: 1px solid var(--ai-chat-border, rgba(0, 0, 0, 0.06));
  position: relative;
  background: linear-gradient(180deg,
    rgba(var(--ai-search-color-rgb, 124, 59, 237), 0.08) 0%,
    rgba(var(--ai-search-color-rgb, 124, 59, 237), 0.03) 50%,
    transparent 100%);
}
.ai-search-ai-section::before {
  content: "";
  position: absolute;
  top: 0;
  left: 16px;
  right: 16px;
  height: 1px;
  background: linear-gradient(90deg,
    transparent 0%,
    rgba(var(--ai-search-color-rgb, 124, 59, 237), 0.5) 50%,
    transparent 100%);
}
.ai-search-ai-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.ai-search-ai-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--ai-chat-text, #1a1a1a);
}
.ai-search-ai-badge {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 4px;
  background: linear-gradient(135deg,
    var(--ai-search-color, var(--ai-chat-color, #7C3BED)),
    color-mix(in srgb, var(--ai-search-color, var(--ai-chat-color, #7C3BED)) 72%, white));
  color: #fff;
  font-weight: 600;
  letter-spacing: 0.5px;
}
.ai-search-ai-body {
  font-size: 14px;
  line-height: 1.7;
  color: var(--ai-chat-text, #1a1a1a);
  word-break: break-word;
}
.ai-search-ai-body p { margin: 6px 0; }
.ai-search-ai-body p:first-child { margin-top: 0; }
.ai-search-ai-body p:last-child { margin-bottom: 0; }
.ai-search-ai-body h1,
.ai-search-ai-body h2,
.ai-search-ai-body h3 { margin: 10px 0 6px; font-weight: 600; }
.ai-search-ai-body h1 { font-size: 16px; }
.ai-search-ai-body h2 { font-size: 15px; }
.ai-search-ai-body h3 { font-size: 14px; }
.ai-search-ai-body ul,
.ai-search-ai-body ol { margin: 6px 0; padding-left: 22px; }
.ai-search-ai-body li { margin: 2px 0; }
.ai-search-ai-body code {
  background: var(--ai-chat-bg-bubble-ai, #f5f2ff);
  color: var(--ai-chat-text-accent, #7C3BED);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 12px;
}
.ai-search-ai-body pre {
  background: var(--ai-chat-bg-bubble-ai, #f5f2ff);
  padding: 10px 14px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 8px 0;
}
.ai-search-ai-body pre code {
  background: transparent;
  padding: 0;
}
.ai-search-ai-body a {
  color: var(--ai-chat-text-accent, #7C3BED);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.ai-search-ai-body .ai-cite-inline {
  font-size: 10px;
  background: var(--ai-chat-color, #7C3BED);
  color: #fff;
  padding: 0 4px;
  border-radius: 3px;
  cursor: default;
  vertical-align: super;
  font-weight: 600;
}
.ai-search-ai-loading {
  color: var(--ai-chat-text-muted, #999);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.ai-search-ai-loading::before {
  content: "";
  width: 14px; height: 14px;
  border: 2px solid var(--ai-chat-border, #ddd);
  border-top-color: var(--ai-chat-color, #7C3BED);
  border-radius: 50%;
  animation: ai-spin 0.8s linear infinite;
}
.ai-search-ai-error {
  color: #e74c3c;
  font-size: 13px;
}
.ai-search-ai-cites {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--ai-chat-border, #eee);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.ai-search-ai-cite {
  font-size: 12px;
  color: var(--ai-chat-text-accent, #7C3BED);
  background: var(--ai-chat-bg-bubble-ai, #f5f2ff);
  padding: 3px 8px;
  border-radius: 6px;
  text-decoration: none;
  transition: background 0.15s;
}
.ai-search-ai-cite:hover {
  background: var(--ai-chat-border, #e0d6ff);
}

/* 关键词结果区 */
.ai-search-kw-section {
  padding: 14px 18px 16px;
}
.ai-search-kw-header {
  font-size: 11px;
  font-weight: 700;
  color: var(--ai-chat-text-muted, #999);
  margin-bottom: 12px;
  letter-spacing: 1px;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 8px;
}
.ai-search-kw-count {
  font-weight: 500;
  color: var(--ai-chat-text-muted, #999);
  letter-spacing: 0.5px;
}
.ai-search-kw-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.ai-search-kw-item {
  display: block;
  padding: 12px 14px;
  border-radius: 10px;
  text-decoration: none;
  color: inherit;
  position: relative;
  border-left: 2px solid transparent;
  transition: background 0.15s, transform 0.15s, border-color 0.15s, padding-left 0.15s;
}
.ai-search-kw-item:hover {
  background: var(--ai-chat-bg-bubble-ai, rgba(124, 59, 237, 0.08));
  border-left-color: var(--ai-chat-color, #7C3BED);
  padding-left: 16px;
}
.ai-search-kw-item:hover .ai-search-kw-title {
  color: var(--ai-chat-color, #7C3BED);
}
.ai-search-kw-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--ai-chat-text-accent, #7C3BED);
  margin-bottom: 6px;
  line-height: 1.4;
  transition: color 0.15s;
}
.ai-search-kw-snippet {
  font-size: 13px;
  color: var(--ai-chat-text-muted, #666);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.ai-search-kw-snippet mark {
  background: rgba(var(--ai-search-color-rgb, 124, 59, 237), 0.08);
  color: var(--ai-chat-text-accent, #7C3BED);
  padding: 0 2px;
  border-radius: 2px;
  font-weight: 600;
  border-bottom: 1.5px solid rgba(var(--ai-search-color-rgb, 124, 59, 237), 0.45);
}

/* 搜索弹框暗色主题 — 毛玻璃：背景半透明 + 细边透光 */
.ai-search-overlay[data-theme="dark"] {
  background: rgba(8, 10, 18, 0.45);
}
.ai-search-modal[data-theme="dark"],
.ai-search-overlay[data-theme="dark"] .ai-search-modal {
  --ai-chat-bg-window: rgba(30, 32, 48, 0.55);
  --ai-chat-bg-bubble-ai: rgba(53, 53, 72, 0.7);
  --ai-chat-bg-input: rgba(53, 53, 72, 0.55);
  --ai-chat-text: #f0f0f5;
  --ai-chat-text-muted: #b8b8ce;
  --ai-chat-text-placeholder: #8a8aa8;
  --ai-chat-text-accent: #c4b5fd;
  --ai-chat-border: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.14);
  box-shadow:
    0 32px 100px rgba(0, 0, 0, 0.6),
    0 12px 32px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(32px) saturate(180%);
  -webkit-backdrop-filter: blur(32px) saturate(180%);
  background: var(--ai-chat-bg-window);
}
/* 自动暗色：跟随系统 — 同步半透明 */
@media (prefers-color-scheme: dark) {
  .ai-search-overlay[data-theme="auto"] { background: rgba(8, 10, 18, 0.45); }
  .ai-search-modal[data-theme="auto"] {
    --ai-chat-bg-window: rgba(30, 32, 48, 0.55);
    --ai-chat-bg-bubble-ai: rgba(53, 53, 72, 0.7);
    --ai-chat-bg-input: rgba(53, 53, 72, 0.55);
    --ai-chat-text: #f0f0f5;
    --ai-chat-text-muted: #b8b8ce;
    --ai-chat-text-placeholder: #8a8aa8;
    --ai-chat-text-accent: #c4b5fd;
    --ai-chat-border: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.14);
    box-shadow:
      0 32px 100px rgba(0, 0, 0, 0.6),
      0 12px 32px rgba(0, 0, 0, 0.4),
      inset 0 1px 0 rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(32px) saturate(180%);
    -webkit-backdrop-filter: blur(32px) saturate(180%);
    background: var(--ai-chat-bg-window);
  }
}

/* 手机端搜索弹框全屏 */
@media (max-width: 480px) {
  .ai-search-overlay { padding-top: 0; }
  .ai-search-modal {
    width: 100vw;
    max-width: 100vw;
    max-height: 100vh;
    max-height: 100dvh;
    border-radius: 0;
    height: 100vh;
    height: 100dvh;
  }
  /* 全屏弹窗无遮罩可点，关闭按钮需放大到触摸友好尺寸 */
  .ai-search-close {
    width: 40px;
    height: 40px;
    border-radius: 10px;
  }
  .ai-search-close svg { width: 22px; height: 22px; }
  .ai-search-input-wrap { height: 56px; }
}
