/* ==========================================================================
   榴莲社区 · 榴莲AI 对话界面（ChatGPT 风格）
   布局：社区侧栏 | 历史会话栏 | 对话舞台
   ========================================================================== */

/* AI 页主区域：占满容器剩余宽度，不受 --content-w 限制 */
.ai-main {
  display: grid !important;
  grid-template-columns: 244px minmax(0, 1fr);
  height: calc(100vh - var(--header-h));
  overflow: hidden;
  padding: 0 !important;
  max-width: none !important;
  width: auto !important;
  position: relative;
}

/* ==========================================================================
   历史会话栏
   ========================================================================== */
.ai-convbar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-right: 1px solid var(--border);
  background: var(--secondary);
  padding: 10px 8px 0;
}

.cb-top {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 2px 10px;
}

.cb-new {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--secondary);
  color: var(--text);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background .12s, border-color .12s;
}
.cb-new:hover { background: var(--hover); border-color: #d3d3d3; }

.cb-new-ic { display: flex; color: var(--muted); }
.cb-new-ic svg { width: 15px; height: 15px; }

.cb-close {
  display: none;
  width: 30px;
  height: 30px;
  border: none;
  background: transparent;
  color: var(--faint);
  cursor: pointer;
  border-radius: var(--radius);
  align-items: center;
  justify-content: center;
}
.cb-close:hover { background: var(--hover); color: var(--text); }
.cb-close svg { width: 16px; height: 16px; }

.cb-search {
  position: relative;
  display: flex;
  align-items: center;
  margin-bottom: 10px;
}
.cb-search-ic {
  position: absolute;
  left: 9px;
  display: flex;
  color: var(--faint);
  pointer-events: none;
}
.cb-search-ic svg { width: 13px; height: 13px; }
.cb-search input {
  width: 100%;
  height: 32px;
  padding: 0 10px 0 28px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--secondary);
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
  outline: none;
  transition: border-color .12s;
}
.cb-search input:focus { border-color: var(--tertiary); }
.cb-search input::placeholder { color: var(--faint); }

.cb-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--faint);
  letter-spacing: .6px;
  text-transform: uppercase;
  padding: 4px 8px 6px;
}

.cb-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-bottom: 8px;
}

.cb-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--text2);
  font-size: 13px;
  transition: background .12s;
  position: relative;
}
.cb-item:hover { background: var(--hover); color: var(--text); }
.cb-item.active { background: var(--hover); color: var(--text); font-weight: 500; }

.cb-ic { display: flex; color: var(--faint); flex-shrink: 0; }
.cb-ic svg { width: 14px; height: 14px; }

.cb-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cb-time {
  font-size: 10.5px;
  color: var(--faint);
  flex-shrink: 0;
  opacity: 0;
  transition: opacity .12s;
}
.cb-item:hover .cb-time { opacity: 1; }

.cb-del {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--faint);
  border-radius: 4px;
  cursor: pointer;
  opacity: 0;
  transition: opacity .12s, background .12s, color .12s;
}
.cb-item:hover .cb-del { opacity: 1; }
.cb-del:hover { background: var(--border); color: #e03131; }
.cb-del svg { width: 13px; height: 13px; }

.cb-empty {
  font-size: 12.5px;
  color: var(--faint);
  text-align: center;
  padding: 24px 12px;
  line-height: 1.7;
}

/* 与站点侧栏 .sb-bottom 保持等高（1px 边框 + 8px 上边距 + 32px 内容 + 10px 下边距 = 51px），
   否则两个并排面板的底部分隔线会错开 4px，看着没对齐 */
.cb-foot {
  border-top: 1px solid var(--border);
  padding: 8px 4px 10px;
  margin: 0 -8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cb-clear {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  padding: 0 10px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 12.5px;
  border-radius: var(--radius);
  cursor: pointer;
}
.cb-clear:hover { background: var(--hover); color: #e03131; }
.cb-clear svg { width: 14px; height: 14px; }

/* ==========================================================================
   对话舞台
   ========================================================================== */
.ai-stage {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  position: relative;
}

.ai-stage-top {
  height: 46px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  background: var(--secondary);
}

.ai-conv-toggle {
  display: none;
  width: 30px;
  height: 30px;
  border: none;
  background: transparent;
  color: var(--muted);
  border-radius: var(--radius);
  cursor: pointer;
  align-items: center;
  justify-content: center;
}
.ai-conv-toggle:hover { background: var(--hover); color: var(--text); }
.ai-conv-toggle svg { width: 17px; height: 17px; }

.ai-stage-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai-stage-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.ai-kb-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  color: var(--muted);
  background: var(--hover);
  border-radius: 999px;
  padding: 4px 10px;
}
.ai-kb-badge svg { width: 12px; height: 12px; }

/* ---------- 欢迎屏 ---------- */
.ai-center {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 20px;
  overflow-y: auto;
  position: relative;
}

/* 背景光晕 */
.ai-center::before {
  content: '';
  position: absolute;
  top: -180px;
  left: 50%;
  transform: translateX(-50%);
  width: 720px;
  height: 480px;
  background: radial-gradient(ellipse at center, rgba(0, 136, 204, .09), transparent 70%);
  pointer-events: none;
}

.ai-center.hidden { display: none; }

.ai-brand {
  text-align: center;
  margin-bottom: 36px;
  position: relative;
  z-index: 1;
}

.ai-brand-logo {
  margin-bottom: 14px;
  animation: floatIn .6s ease;
  display: flex;
  justify-content: center;
}

@keyframes floatIn {
  from { opacity: 0; transform: translateY(12px) scale(.92); }
  to { opacity: 1; transform: none; }
}

.ai-brand-name {
  font-family: 'Ma Shan Zheng', 'ZCOOL XiaoWei', 'Noto Serif SC', 'Songti SC', serif;
  font-size: 64px;
  font-weight: 400;
  letter-spacing: 7px;
  background: linear-gradient(100deg, #00a878 0%, #0088cc 48%, #6c5ce7 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin: 0;
  line-height: 1.25;
  text-indent: 7px;
}

.ai-brand-ai {
  font-family: 'Inter', 'Noto Serif SC', sans-serif;
  font-weight: 800;
  font-size: 34px;
  letter-spacing: 5px;
  background: linear-gradient(100deg, #0088cc, #6c5ce7);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-left: 9px;
  vertical-align: 9px;
}

.ai-brand-tagline {
  font-size: 14.5px;
  color: var(--muted);
  margin: 10px 0 0;
  letter-spacing: 1px;
}

/* ---------- 建议卡片 ---------- */
.ai-suggestions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  max-width: 720px;
  width: 100%;
  animation: fadeUp .5s ease .2s both;
  position: relative;
  z-index: 1;
}

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

.ai-sug-card {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 12px 14px;
  background: var(--secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  font-family: inherit;
  font-size: 13.5px;
  color: var(--text);
  text-align: left;
  transition: background .12s, border-color .12s;
  min-height: 52px;
}

.ai-sug-card:hover {
  border-color: var(--tertiary);
  background: var(--hover);
}

.sug-icon {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--hover);
  border-radius: var(--radius);
  color: var(--muted);
}
.sug-icon svg { width: 16px; height: 16px; }

.sug-text {
  line-height: 1.45;
  font-weight: 500;
}

.ai-center-note {
  font-size: 12px;
  color: var(--faint);
  margin: 20px 0 0;
  text-align: center;
  max-width: 560px;
  line-height: 1.7;
  position: relative;
  z-index: 1;
}

/* ==========================================================================
   消息流
   ========================================================================== */
.ai-chat {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 22px 0 8px;
  display: none;
  scroll-behavior: smooth;
}

.ai-chat.active { display: block; }

.ai-thread {
  max-width: 780px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  flex-direction: column;
  gap: 26px;
}

.msg { animation: msgIn .26s ease; }

@keyframes msgIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* 用户消息：右对齐气泡 */
.msg-user {
  display: flex;
  justify-content: flex-end;
}

.msg-bubble {
  max-width: 82%;
  background: var(--hover);
  color: var(--text);
  border-radius: 18px;
  padding: 10px 16px;
  font-size: 14.5px;
  line-height: 1.7;
  word-break: break-word;
  white-space: pre-wrap;
}

/* AI 消息：头像 + 正文 */
.msg-bot {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
  background: linear-gradient(135deg, #00c48c, #0088cc 60%, #6c5ce7);
  color: #fff;
}
.msg-avatar svg { width: 16px; height: 16px; }

.msg-main { flex: 1; min-width: 0; }

.msg-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--faint);
  margin-bottom: 5px;
  letter-spacing: .2px;
}

.msg-body {
  font-size: 14.5px;
  line-height: 1.78;
  color: var(--text);
  word-break: break-word;
}

.msg-body.typing {
  white-space: pre-wrap;
  color: var(--text2);
}

.msg-body.typing::after {
  content: '';
  display: inline-block;
  width: 7px;
  height: 15px;
  margin-left: 2px;
  vertical-align: -2px;
  background: var(--tertiary);
  animation: caret .8s steps(1) infinite;
}

@keyframes caret { 0%, 50% { opacity: 1; } 50.01%, 100% { opacity: 0; } }

.msg-error {
  color: var(--danger);
  background: var(--danger-bg);
  border: 1px solid var(--danger-border);
  border-radius: var(--radius);
  padding: 9px 12px;
  font-size: 13.5px;
}

/* AI 消息内的 Markdown 排版 */
.msg-body.md-content > *:first-child { margin-top: 0; }
.msg-body.md-content > *:last-child { margin-bottom: 0; }
.msg-body.md-content p { margin: 0 0 12px; }
.msg-body.md-content h1,
.msg-body.md-content h2,
.msg-body.md-content h3,
.msg-body.md-content h4 {
  margin: 22px 0 10px;
  font-weight: 700;
  line-height: 1.4;
  color: var(--text);
}
.msg-body.md-content h1 { font-size: 19px; }
.msg-body.md-content h2 { font-size: 17px; }
.msg-body.md-content h3 { font-size: 15.5px; }
.msg-body.md-content h4 { font-size: 14.5px; }
.msg-body.md-content ul,
.msg-body.md-content ol { margin: 0 0 12px; padding-left: 22px; }
.msg-body.md-content li { margin: 4px 0; }
.msg-body.md-content li::marker { color: var(--faint); }
.msg-body.md-content a { color: var(--primary); text-decoration: none; }
.msg-body.md-content a:hover { text-decoration: underline; }
.msg-body.md-content strong { font-weight: 600; color: var(--text); }
.msg-body.md-content blockquote {
  margin: 12px 0;
  padding: 10px 14px;
  background: var(--hover);
  border-left: 3px solid var(--tertiary);
  border-radius: 0 8px 8px 0;
  color: var(--text2);
  font-size: 13.5px;
}
.msg-body.md-content code {
  background: var(--hover);
  padding: 1.5px 6px;
  border-radius: 4px;
  font-size: 12.5px;
  font-family: 'Consolas', 'Monaco', monospace;
  color: #c2255c;
}
body.dark .msg-body.md-content code { color: #ff8fa3; }
.msg-body.md-content pre {
  margin: 12px 0;
  padding: 12px 14px;
  background: var(--hover);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
}
.msg-body.md-content pre code {
  background: none;
  padding: 0;
  color: var(--text);
  font-size: 12.5px;
  line-height: 1.7;
}
.msg-body.md-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 13.5px;
}
.msg-body.md-content th,
.msg-body.md-content td {
  border: 1px solid var(--border);
  padding: 7px 10px;
  text-align: left;
}
.msg-body.md-content th { background: var(--hover); font-weight: 600; }
.msg-body.md-content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 18px 0;
}
.msg-body.md-content mark {
  background: #fff3c4;
  padding: 0 3px;
  border-radius: 3px;
}
body.dark .msg-body.md-content mark { background: rgba(255, 243, 196, .18); }

/* ---------- 来源折叠 ---------- */
.ai-sources {
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--secondary);
}

.src-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 7px 12px;
  background: var(--hover);
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  color: var(--text2);
  font-family: inherit;
  border: none;
  text-align: left;
}
.src-toggle:hover { background: var(--border); }
.src-toggle svg { transition: transform .18s; flex-shrink: 0; }
.src-toggle.open svg { transform: rotate(90deg); }

.src-list {
  display: none;
  padding: 5px;
  flex-direction: column;
  gap: 1px;
}
.src-list.open { display: flex; }

.src-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 8px;
  border-radius: var(--radius);
  text-decoration: none;
  transition: background .12s;
}
.src-card:hover { background: var(--hover); }

.src-num {
  width: 19px;
  height: 19px;
  border-radius: 4px;
  background: var(--pill-bg);
  color: var(--tertiary);
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.src-info { flex: 1; min-width: 0; }

.src-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}
.src-card:hover .src-title { color: var(--tertiary); }

.src-meta {
  font-size: 11.5px;
  color: var(--faint);
  margin-top: 1px;
  display: block;
}

.src-arrow { color: var(--faint); flex-shrink: 0; display: flex; }

/* ---------- 消息工具条 ---------- */
.msg-tools {
  display: flex;
  gap: 4px;
  margin-top: 8px;
  opacity: 0;
  transition: opacity .14s;
}
.msg-bot:hover .msg-tools { opacity: 1; }

.mt-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--faint);
  font-family: inherit;
  font-size: 11.5px;
  cursor: pointer;
  transition: background .12s, color .12s;
}
.mt-btn:hover { background: var(--hover); color: var(--text2); }
.mt-btn.done { color: var(--success); }
.mt-btn svg { width: 13px; height: 13px; }

/* ---------- 加载动画 ---------- */
.ai-loading {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 3px 0;
}

.ai-dots { display: flex; gap: 4px; }
.ai-dots i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--tertiary);
  animation: bounce 1.2s infinite;
  display: block;
}
.ai-dots i:nth-child(2) { animation-delay: .15s; }
.ai-dots i:nth-child(3) { animation-delay: .3s; }

@keyframes bounce {
  0%, 80%, 100% { opacity: .25; transform: scale(.75); }
  40% { opacity: 1; transform: scale(1.1); }
}

.ai-loading span { font-size: 13px; color: var(--muted); }

/* ==========================================================================
   输入区（ChatGPT 风格圆角输入框）
   ========================================================================== */
.ai-dock {
  padding: 0 24px 14px;
  background: linear-gradient(transparent, var(--secondary) 22%);
  flex-shrink: 0;
}

.ai-dock-inner {
  max-width: 780px;
  margin: 0 auto;
}

.ai-input-box {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--secondary);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 8px 8px 8px 16px;
  transition: border-color .14s, box-shadow .14s;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .04);
}

.ai-input-box:focus-within {
  border-color: var(--tertiary);
  box-shadow: 0 2px 14px rgba(0, 136, 204, .12);
}

.ai-input-box textarea {
  flex: 1;
  border: none;
  outline: none;
  resize: none;
  background: transparent;
  font-family: inherit;
  font-size: 14.5px;
  line-height: 1.65;
  color: var(--text);
  max-height: 180px;
  min-height: 26px;
  padding: 6px 0;
}

.ai-input-box textarea::placeholder { color: var(--faint); }

.ai-input-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  padding-bottom: 1px;
}

.ai-send,
.ai-stop {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: var(--tertiary);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .12s, opacity .12s;
}
.ai-send svg, .ai-stop svg { width: 16px; height: 16px; }
.ai-send:hover { background: var(--tertiary-hover); }
.ai-send:disabled { opacity: .45; cursor: not-allowed; }
.ai-stop { background: var(--text2); }
.ai-stop:hover { background: var(--text); }

.ai-dock-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 6px 0;
}

.ai-powered {
  font-size: 11.5px;
  color: var(--faint);
  letter-spacing: .3px;
}

.ai-hint {
  font-size: 11.5px;
  color: var(--faint);
}

/* ==========================================================================
   响应式
   ========================================================================== */
@media (max-width: 900px) {
  .ai-main { grid-template-columns: minmax(0, 1fr); }

  .ai-conv-toggle { display: flex; }

  .ai-convbar {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 258px;
    z-index: 60;
    transform: translateX(-100%);
    transition: transform .22s ease;
    box-shadow: 0 0 0 rgba(0, 0, 0, 0);
  }
  body.ai-conv-open .ai-convbar {
    transform: none;
    box-shadow: 6px 0 24px rgba(0, 0, 0, .16);
  }
  body.ai-conv-open::after {
    content: '';
    position: fixed;
    inset: var(--header-h) 0 0 0;
    background: rgba(0, 0, 0, .32);
    z-index: 55;
  }
  .cb-close { display: flex; }
  .cb-time { display: none; }
  .cb-del { opacity: 1; }
}

@media (max-width: 720px) {
  .ai-brand-name { font-size: 40px; letter-spacing: 4px; }
  .ai-brand-ai { font-size: 24px; letter-spacing: 3px; vertical-align: 6px; }
  .ai-brand-logo svg { width: 52px; height: 52px; }
  .ai-brand-tagline { font-size: 13px; }
  .ai-suggestions { grid-template-columns: 1fr; gap: 8px; }
  .ai-sug-card { padding: 11px 13px; min-height: 48px; font-size: 13px; }
  .ai-dock { padding: 0 12px 10px; }
  .ai-thread { padding: 0 14px; gap: 20px; }
  .ai-dock-foot { flex-direction: column; gap: 2px; align-items: center; }
  .msg-bubble { max-width: 88%; }
  .ai-stage-top { padding: 0 10px; }
}

/* ---------- 深色模式微调 ---------- */
body.dark .ai-center::before { background: radial-gradient(ellipse at center, rgba(0, 136, 204, .14), transparent 70%); }
body.dark .sug-icon { background: #2c2e30; }
body.dark .ai-input-box { box-shadow: 0 2px 10px rgba(0, 0, 0, .3); }

/* ==========================================================================
   模型状态徽章 + 降级提示
   ========================================================================== */

.ai-model-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--muted);
  background: var(--hover);
  border-radius: 999px;
  padding: 4px 10px;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai-model-badge .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--faint);
  flex-shrink: 0;
}
.ai-model-badge .dot.ok { background: var(--success); }
.ai-model-badge .dot.warn { background: #f08c00; }
.ai-model-badge .dot.err { background: var(--danger); }
.ai-model-badge.err { color: var(--danger); background: var(--danger-bg); }

/* 降级提示条 */
.msg-warn {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  margin: 0 0 9px;
  padding: 8px 11px;
  border: 1px solid #ffd8a8;
  background: #fff8ec;
  border-radius: var(--radius);
  font-size: 12.5px;
  line-height: 1.6;
  color: #8a5300;
}

.msg-warn .mw-ic { display: flex; flex-shrink: 0; margin-top: 1px; }
.msg-warn .mw-ic svg { width: 15px; height: 15px; }

body.dark .msg-warn {
  border-color: rgba(240, 140, 0, .45);
  background: rgba(240, 140, 0, .12);
  color: #ffc078;
}

/* ==========================================================================
   引用角标（模型正文里的 [1] → 可点击跳转到来源卡片）
   ========================================================================== */
.msg-body .cite {
  display: inline-block;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  margin: 0 1px;
  border-radius: 4px;
  background: var(--pill-bg);
  color: var(--tertiary);
  font-size: 11px;
  font-weight: 700;
  line-height: 17px;
  text-align: center;
  vertical-align: 1px;
  text-decoration: none;
  cursor: pointer;
  transition: background .12s, color .12s;
}

.msg-body .cite:hover {
  background: var(--tertiary);
  color: #fff;
}

.src-card.flash {
  animation: srcFlash 1.4s ease;
}

@keyframes srcFlash {
  0%, 55% { background: var(--pill-bg); }
  100% { background: transparent; }
}

/* 截断提示 */
.msg-trunc {
  margin-top: 8px;
  font-size: 12px;
  color: var(--faint);
  border-top: 1px dashed var(--border);
  padding-top: 6px;
}

/* ==========================================================================
   思考过程（流式时实时展示 <think> 内容）
   ========================================================================== */
.msg-think {
  margin: 0 0 10px;
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--hover);
  font-size: 12.5px;
  line-height: 1.7;
  color: var(--text2);
  max-height: 220px;
  overflow-y: auto;
}

.msg-think[hidden] { display: none; }

.think-hd {
  display: inline-block;
  margin-right: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .5px;
  color: var(--faint);
  text-transform: uppercase;
}

.msg-think .md-content p { margin: 0 0 6px; }
.msg-think .md-content p:last-child { margin-bottom: 0; }

/* 外部网页来源（[W1] 角标与卡片） */
.msg-body .cite-web {
  background: #fff3c4;
  color: #8a5300;
}
.msg-body .cite-web:hover {
  background: #e8a33d;
  color: #fff;
}

.src-web .src-num {
  background: #fff3c4;
  color: #8a5300;
}
body.dark .src-web .src-num { background: rgba(240, 140, 0, .22); color: #ffc078; }
body.dark .msg-body .cite-web { background: rgba(240, 140, 0, .2); color: #ffc078; }

/* AI 消息头像：榴莲吉祥物（不再用渐变圆底） */
.msg-avatar {
  background: none;
  width: 26px;
  height: 26px;
}

.msg-avatar .mascot {
  width: 26px;
  height: 26px;
  display: block;
  object-fit: contain;
}
