/* ============================================================
 * AI 搭配助手 · 浮窗样式（结构部分，主题变量由各主题 ai.css 定义）
 * 标准断点 1024 / 768 / 480，触控热区 ≥44px
 * ============================================================ */
.ai-root {
  --ai-primary: #e1251b;
  --ai-primary-d: #c81623;
  --ai-primary-l: #fdeceb;
  --ai-ink: #1e293b;
  --ai-body: #475569;
  --ai-muted: #94a3b8;
  --ai-line: #e2e8f0;
  --ai-bg: #f1f5f9;
  --ai-panel: #ffffff;
  --ai-bot-bubble: #f1f5f9;
  --ai-user-bubble: #e1251b;
  --ai-user-ink: #ffffff;
  --ai-radius: 14px;
  position: fixed;
  inset: auto 20px 20px auto;
  z-index: 9998;
  font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
  color: var(--ai-ink);
}

/* ---------- 悬浮按钮 ---------- */
.ai-fab {
  width: 58px; height: 58px; border-radius: 50%;
  border: none; cursor: pointer;
  background: linear-gradient(135deg, var(--ai-primary), var(--ai-primary-d));
  color: #fff; box-shadow: 0 8px 22px rgba(15, 23, 42, .28);
  display: flex; align-items: center; justify-content: center;
  transition: transform .18s ease, box-shadow .18s ease;
}
.ai-fab:hover { transform: translateY(-2px); box-shadow: 0 12px 28px rgba(15, 23, 42, .34); }
.ai-fab svg { width: 28px; height: 28px; }
.ai-root.ai-active .ai-fab { transform: scale(.92); }

/* ---------- 面板 ---------- */
.ai-panel {
  position: fixed; right: 20px; bottom: 92px;
  width: 380px; max-width: calc(100vw - 40px);
  max-height: 72vh;
  background: var(--ai-panel); border-radius: var(--ai-radius);
  box-shadow: 0 18px 48px rgba(15, 23, 42, .24);
  display: none; flex-direction: column; overflow: hidden;
  border: 1px solid var(--ai-line);
}
.ai-panel.ai-open { display: flex; }

.ai-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  background: linear-gradient(135deg, var(--ai-primary), var(--ai-primary-d));
  color: #fff;
}
.ai-head-t { display: flex; align-items: center; gap: 10px; }
.ai-head-ico {
  width: 38px; height: 38px; border-radius: 10px;
  background: rgba(255, 255, 255, .18);
  display: flex; align-items: center; justify-content: center;
}
.ai-head-ico svg { width: 22px; height: 22px; }
.ai-head b { font-size: 15px; display: block; }
.ai-head small { font-size: 11px; opacity: .9; }
.ai-close {
  width: 34px; height: 34px; border-radius: 50%;
  border: none; background: rgba(255, 255, 255, .16);
  color: #fff; font-size: 20px; line-height: 1; cursor: pointer;
}
.ai-close:hover { background: rgba(255, 255, 255, .3); }

/* ---------- 消息区 ---------- */
.ai-messages {
  padding: 16px; flex: 1; overflow-y: auto;
  background: var(--ai-panel);
  display: flex; flex-direction: column; gap: 14px;
}
.ai-msg { display: flex; gap: 8px; align-items: flex-start; }
.ai-msg-user { justify-content: flex-end; }
.ai-avatar {
  flex: 0 0 32px; width: 32px; height: 32px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
}
.ai-avatar-bot { background: var(--ai-primary-l); color: var(--ai-primary-d); }
.ai-bubble {
  max-width: 76%; padding: 10px 13px; border-radius: 12px;
  font-size: 13.5px; line-height: 1.6; word-break: break-word;
  background: var(--ai-bot-bubble); color: var(--ai-ink);
}
.ai-bubble-user {
  background: var(--ai-user-bubble); color: var(--ai-user-ink);
  border-bottom-right-radius: 4px;
}
.ai-msg-bot .ai-bubble { border-bottom-left-radius: 4px; }

/* 打字指示 */
.ai-typing { display: flex; gap: 5px; align-items: center; }
.ai-typing span {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--ai-muted);
  animation: ai-blink 1.2s infinite both;
}
.ai-typing span:nth-child(2) { animation-delay: .2s; }
.ai-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes ai-blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

/* ---------- bundle 卡片 ---------- */
.ai-bundle {
  border: 1px solid var(--ai-line); border-radius: 12px;
  overflow: hidden; margin-top: 4px; min-width: 250px; max-width: 100%;
  background: #fff;
}
.ai-bundle-rat {
  font-size: 12.5px; color: var(--ai-body); padding: 10px 12px;
  background: var(--ai-primary-l); margin: 0;
}
.ai-bi { display: flex; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--ai-line); }
.ai-bi-img {
  flex: 0 0 56px; width: 56px; height: 56px; border-radius: 10px;
  background: var(--ai-bg); overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.ai-bi-img img { width: 100%; height: 100%; object-fit: cover; }
.ai-noimg { font-size: 11px; color: var(--ai-muted); }
.ai-bi-info { min-width: 0; flex: 1; }
.ai-bi-name {
  font-size: 13px; font-weight: 600; color: var(--ai-ink);
  display: block; line-height: 1.4;
}
.ai-bi-meta { font-size: 12px; color: var(--ai-primary-d); margin-top: 3px; font-weight: 600; }
.ai-bi-why { font-size: 11.5px; color: var(--ai-muted); margin-top: 3px; line-height: 1.5; }
.ai-bundle-total {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px; font-size: 13px; color: var(--ai-body);
}
.ai-bundle-total b { font-size: 18px; color: var(--ai-primary-d); }
.ai-bundle-btn {
  margin: 0 12px 12px; width: calc(100% - 24px);
  min-height: 44px; border: none; border-radius: 10px; cursor: pointer;
  background: linear-gradient(135deg, var(--ai-primary), var(--ai-primary-d));
  color: #fff; font-size: 14.5px; font-weight: 700;
}
.ai-bundle-btn:hover { filter: brightness(1.05); }

/* ---------- 输入区 ---------- */
.ai-inputbar { border-top: 1px solid var(--ai-line); padding: 10px 12px; background: var(--ai-panel); }
.ai-kbd { display: flex; align-items: flex-end; gap: 8px; }
.ai-text {
  flex: 1; resize: none; border: 1px solid var(--ai-line);
  border-radius: 10px; padding: 10px 12px; font-size: 13.5px;
  max-height: 120px; line-height: 1.5; outline: none;
  font-family: inherit; color: var(--ai-ink);
}
.ai-text:focus { border-color: var(--ai-primary); }
.ai-send, .ai-voice-toggle, .ai-kbd-toggle {
  flex: 0 0 auto; min-width: 44px; min-height: 44px;
  border-radius: 10px; border: 1px solid var(--ai-line);
  background: var(--ai-panel); color: var(--ai-primary-d);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.ai-send { background: var(--ai-primary); border-color: var(--ai-primary); color: #fff; }
.ai-send svg { width: 20px; height: 20px; }
.ai-voice-toggle svg, .ai-kbd-toggle svg { width: 22px; height: 22px; }

/* 语音模式 */
.ai-voice { display: flex; align-items: center; gap: 10px; }
.ai-mic {
  flex: 1; min-height: 48px; border-radius: 12px;
  border: 1.5px solid var(--ai-primary);
  background: var(--ai-primary-l); color: var(--ai-primary-d);
  display: flex; align-items: center; justify-content: center; gap: 8px;
  font-size: 14.5px; font-weight: 700; cursor: pointer;
  user-select: none; -webkit-user-select: none; touch-action: none;
}
.ai-mic svg { width: 22px; height: 22px; }
.ai-mic.ai-rec { background: var(--ai-primary); color: #fff; }
.ai-hide { display: none !important; }

/* ---------- 平板/移动适配 ---------- */
@media (max-width: 768px) {
  .ai-root { inset: auto 14px 14px auto; }
  .ai-panel {
    right: 0; bottom: 0; left: 0; top: 0;
    width: 100%; max-width: none; max-height: none; height: 100%;
    border-radius: 0; border: none;
  }
  .ai-bubble { max-width: 82%; }
  .ai-fab { width: 54px; height: 54px; }
}

@media (max-width: 480px) {
  .ai-head { padding: 12px 14px; }
  .ai-messages { padding: 14px; }
  .ai-bubble { max-width: 84%; font-size: 13px; }
}

/* 新 AI 浮窗接管旧规则版「在线客服」入口：旧 IIFE 代码保留在 main.js，仅隐藏其悬浮入口；
   如需两套并存，删除本条规则即可。 */
.cs-launcher { display: none; }
