* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* hidden 属性兜底: 元素自身的 display 规则(如 #btn-mic 的 flex)优先级高于
   UA 样式表的 display:none, 会令 hidden 失效——此规则保证 hidden 必然隐藏 */
[hidden] {
  display: none !important;
}

:root {
  --primary: #1e3a5f;
  --primary-light: #2d5a8e;
  --bg: #f5f5f5;
  --bubble-user: #1e3a5f;
  --bubble-bot: #ffffff;
  --text-dark: #1f2937;
  --text-light: #ffffff;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  --think-bg: #f8fafc;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text-dark);
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 860px;
  margin: 0 auto;
  background: var(--bg);
}

/* Header */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: white;
  flex-shrink: 0;
  gap: 12px;
}

.header-icon {
  font-size: 24px;
  flex-shrink: 0;
}

/* "锦"字圆形徽章 (header 小号 + welcome 大号) */
.logo-badge {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #c1272d;
  color: #fff;
  font-size: 20px;
  font-weight: 700;
  font-family: "Songti SC", "STSong", "SimSun", serif;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.header-title {
  flex: 1;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-reset {
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: white;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
  flex-shrink: 0;
}

.btn-reset:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* Chat area */
.chat-area {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px 8px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

/* Welcome */
.welcome {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}

.welcome-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.welcome p {
  font-size: 15px;
}

/* bot 消息内的 markdown 渲染 (marked 输出, GFM) */
.msg-bubble h1, .msg-bubble h2, .msg-bubble h3, .msg-bubble h4 {
  margin: 6px 0 2px;
  line-height: 1.3;
}
.msg-bubble h1 { font-size: 17px; }
.msg-bubble h2 { font-size: 16px; }
.msg-bubble h3 { font-size: 15px; font-weight: 700; }
.msg-bubble h4 { font-size: 14px; }
.msg-bubble h1:first-child, .msg-bubble h2:first-child, .msg-bubble h3:first-child, .msg-bubble h4:first-child { margin-top: 0; }
.msg-bubble ul, .msg-bubble ol { margin: 2px 0; padding-left: 20px; }
.msg-bubble li { margin: 0; }
.msg-bubble p { margin: 2px 0; }
.msg-bubble p:first-child { margin-top: 0; }
.msg-bubble p:last-child { margin-bottom: 0; }
.msg-bubble strong { font-weight: 700; }
.msg-bubble blockquote {
  margin: 4px 0;
  padding: 2px 10px;
  border-left: 3px solid #c1272d;
  background: #fff7f7;
  color: #555;
}
.msg-bubble hr { border: none; border-top: 1px dashed #ccc; margin: 6px 0; }
.msg-bubble code { background: #f0f0f0; padding: 1px 5px; border-radius: 3px; font-size: 13px; }

/* GFM 表格 */
.msg-bubble table {
  border-collapse: collapse;
  width: 100%;
  margin: 5px 0;
  font-size: 13px;
}
.msg-bubble th, .msg-bubble td {
  border: 1px solid #e0e3e8;
  padding: 4px 8px;
  text-align: left;
  vertical-align: top;
}
.msg-bubble th { background: #f5f7fa; font-weight: 600; }
.msg-bubble td p, .msg-bubble th p { margin: 0; }

/* 结构化追问表单 */
.q-form {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.q-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.q-option {
  padding: 8px 14px;
  border: 1.5px solid #d0d4da;
  background: #fff;
  border-radius: 18px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s;
  color: #333;
}
.q-option:hover { border-color: #c1272d; }
.q-option.selected {
  background: #c1272d;
  border-color: #c1272d;
  color: #fff;
}
.q-submit {
  align-self: flex-start;
  padding: 8px 22px;
  background: #c1272d;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
}
.q-submit:hover { background: #a01e23; }
.q-submit.shake { animation: shake 0.3s; }
@keyframes shake {
  0%,100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

/* Messages */
.msg {
  display: flex;
  flex-direction: column;
  max-width: 80%;
  animation: fadeIn 0.2s ease;
}

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

.msg-user {
  align-self: flex-end;
}

.msg-bot {
  align-self: flex-start;
}

.msg-bubble {
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 15px;
  line-height: 1.55;
  word-break: break-word;
}

.msg-user .msg-bubble {
  background: var(--bubble-user);
  color: var(--text-light);
  border-bottom-right-radius: 4px;
}

.msg-bot .msg-bubble {
  background: var(--bubble-bot);
  color: var(--text-dark);
  box-shadow: var(--shadow);
  border-bottom-left-radius: 4px;
}

/* Think — HTML5 <details> matching RAGFlow's rendering */
details.think {
  margin: 6px 0;
  padding: 8px 12px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-left: 3px solid #94a3b8;
  border-radius: 6px;
  font-size: 12px;
  color: #64748b;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

details.think summary {
  cursor: pointer;
  font-weight: 500;
  color: #475569;
  user-select: none;
  padding: 2px 0;
}

details.think[open] summary {
  margin-bottom: 6px;
  padding-bottom: 6px;
  border-bottom: 1px solid #e2e8f0;
}

/* Citation badge — inline Fig.N marker */
.citation-badge {
  display: inline-block;
  background: #e0e7ff;
  color: #4338ca;
  border-radius: 10px;
  padding: 1px 6px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  margin: 0 2px;
  vertical-align: middle;
  transition: background 0.15s;
}

.citation-badge:hover {
  background: #c7d2fe;
}

/* Reference Fig label */
.ref-fig-label {
  display: inline-block;
  background: #dbeafe;
  color: #1e40af;
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 11px;
  font-weight: 600;
  margin-right: 6px;
  vertical-align: middle;
}

/* Typing indicator */
.typing-dots {
  display: inline-flex;
  gap: 4px;
  padding: 4px 0;
}

.typing-dots span {
  width: 6px;
  height: 6px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: bounce 1.2s infinite;
}

.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
}

/* Reference section */
.msg-reference {
  margin-top: 6px;
  padding: 8px 12px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

.ref-toggle {
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  font-weight: 500;
  color: #15803d;
  margin-bottom: 4px;
  user-select: none;
}

.ref-toggle::before {
  content: "▶";
  font-size: 10px;
  transition: transform 0.2s;
}

.ref-toggle.open::before {
  transform: rotate(90deg);
}

.ref-content {
  display: none;
  margin-top: 6px;
  max-height: 400px;
  overflow-y: auto;
}

.ref-content.open {
  display: block;
}

/* Document cards — mimics RAGFlow's ReferenceDocumentList */
.ref-doc-card {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  margin: 4px 0;
  background: white;
  border-radius: 6px;
  border: 1px solid #e5e7eb;
  font-size: 12px;
  cursor: default;
}

.ref-doc-card-icon {
  font-size: 16px;
  flex-shrink: 0;
}

.ref-doc-card-name {
  color: #166534;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Chunk image in reference */
.ref-chunk-image {
  margin: 8px 0;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid #e5e7eb;
}

.ref-chunk-image .ref-fig-label {
  margin: 0 0 4px 0;
}

.ref-chunk-image .ref-image {
  width: 100%;
  max-height: 160px;
  object-fit: contain;
  cursor: pointer;
  background: #fafafa;
}

.ref-chunk {
  padding: 8px 10px;
  margin: 6px 0;
  background: white;
  border-radius: 6px;
  border-left: 3px solid #86efac;
  font-size: 12px;
  line-height: 1.5;
}

.ref-doc {
  font-weight: 500;
  color: #166534;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.ref-doc-icon {
  font-size: 14px;
}

.ref-similarity {
  color: #9ca3af;
  font-size: 11px;
  margin-left: auto;
}

.ref-text {
  color: #374151;
  line-height: 1.6;
  word-break: break-word;
  white-space: pre-wrap;
}

.ref-image-wrapper {
  margin-top: 6px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid #e5e7eb;
  background: #fafafa;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ref-image {
  width: 100%;
  max-height: 200px;
  object-fit: contain;
  cursor: pointer;
  transition: max-height 0.3s ease;
}

.ref-image.ref-image-zoomed {
  max-height: 600px;
}

/* Input area */
.input-area {
  flex-shrink: 0;
  padding: 12px 16px;
  background: white;
  border-top: 1px solid var(--border);
}

.input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 860px;
  margin: 0 auto;
  position: relative;
}

#msg-input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  resize: none;
  max-height: 120px;
  line-height: 1.5;
  outline: none;
  transition: border-color 0.2s;
}

#msg-input:focus {
  border-color: var(--primary-light);
}

#msg-input:disabled {
  background: #f9fafb;
  opacity: 0.7;
}

#btn-send {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: none;
  background: var(--primary);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

#btn-send:hover:not(:disabled) {
  background: var(--primary-light);
}

#btn-send:disabled {
  background: #d1d5db;
  cursor: not-allowed;
}

/* 语音输入麦克风按钮(默认 hidden, JS 探测 HTTPS+接口可用后展示) */
#btn-mic {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  color: #64748b;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
  /* 长按说话: 防触摸滚动/长按弹菜单/选中文本 */
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

#btn-mic:hover {
  color: var(--primary);
  border-color: var(--primary-light);
  background: #f0f6ff;
}

/* 录音中: 红底脉冲, 提示正在聆听 */
#btn-mic.recording {
  background: #fee2e2;
  border-color: #f87171;
  color: #dc2626;
  animation: mic-pulse 1.2s ease-in-out infinite;
}

#btn-mic:disabled {
  opacity: 0.6;
  cursor: wait;
  animation: none;
}

@keyframes mic-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.35); }
  50% { box-shadow: 0 0 0 8px rgba(220, 38, 38, 0); }
}

/* 录音中央浮层: 全屏遮罩 + 麦克风徽章 + 真实音量音波 */
#rec-overlay {
  position: fixed;
  inset: 0;
  z-index: 1500;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s;
}

#rec-overlay.show {
  opacity: 1;
}

.rec-panel {
  background: #fff;
  border-radius: 20px;
  padding: 26px 44px 22px;
  text-align: center;
  box-shadow: 0 12px 48px rgba(15, 23, 42, 0.35);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.rec-mic-badge {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: #fee2e2;
  color: #dc2626;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: mic-pulse 1.2s ease-in-out infinite;
}

.rec-wave {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 36px;
}

.rec-wave span {
  width: 4px;
  height: 4px;
  border-radius: 2px;
  background: var(--primary);
  transition: height 0.08s linear;
}

.rec-text {
  font-size: 14px;
  color: #475569;
}

/* Error message */
.msg-error {
  align-self: center;
  padding: 8px 16px;
  background: #fef2f2;
  color: #dc2626;
  border-radius: 8px;
  font-size: 13px;
  border: 1px solid #fecaca;
}

/* Tablet */
@media (max-width: 768px) {
  .msg {
    max-width: 85%;
  }
  .header {
    padding: 12px 16px;
  }
  .header-title {
    font-size: 14px;
  }
  .chat-area {
    padding: 12px 14px;
  }
}

/* Mobile */
@media (max-width: 480px) {
  #app {
    max-width: 100%;
  }

  .header {
    padding: 10px 12px;
    gap: 8px;
  }

  .header-icon {
    font-size: 20px;
  }

  .header-title {
    font-size: 13px;
  }

  .btn-reset {
    font-size: 12px;
    padding: 5px 10px;
  }

  .msg {
    max-width: 90%;
  }

  .chat-area {
    padding: 10px 8px;
    gap: 8px;
  }

  .input-area {
    padding: 10px 10px;
  }

  .msg-bubble {
    font-size: 14px;
  }


  .welcome-icon {
    font-size: 36px;
  }

  .welcome p {
    font-size: 13px;
  }
}

/* === 引用标注([ID:N] 上标 + 卡片点击 + 截图弹窗) === */
.cite {
  color: #2563eb;
  cursor: pointer;
  font-size: 0.8em;
  font-weight: 600;
  vertical-align: super;
  line-height: 0;
  margin: 0 1px;
  user-select: none;
}
.cite:hover { text-decoration: underline; }

.ref-page { color: #999; font-size: 12px; margin-left: 4px; }
.ref-doc-hint { margin-left: auto; color: #2563eb; font-size: 12px; white-space: nowrap; }
.ref-doc-card.clickable { cursor: pointer; }
.ref-doc-card.clickable:hover { background: #eef4ff; border-color: #bcd3ff; }
.ref-doc-card.flash { background: #fff3cd !important; transition: background .3s; }

/* === 文档预览弹窗(引用【N】/文档卡片点击 → iframe 加载整个 PDF 跳对应页, 不开新窗口) === */
.doc-modal {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.6);
  z-index: 1000;
}
.doc-modal.open { display: flex; align-items: center; justify-content: center; padding: 24px; box-sizing: border-box; }
.doc-modal-box {
  position: relative;
  width: min(92vw, 1100px);
  height: min(88vh, 820px);
  background: #fff;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 8px 36px rgba(0,0,0,.35);
  display: flex; flex-direction: column;
}
.doc-modal-header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 14px;
  background: #f8fafc; border-bottom: 1px solid #e5e7eb;
  font-size: 13px; color: #334155;
}
.doc-modal-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-modal-close {
  width: 30px; height: 30px; border-radius: 6px;
  background: transparent; color: #64748b; border: none;
  font-size: 18px; cursor: pointer; line-height: 1;
}
.doc-modal-close:hover { background: #e2e8f0; color: #1e293b; }
.doc-modal-body {
  flex: 1; background: #525659; overflow: auto; padding: 16px; text-align: center;
}
.doc-page { margin: 0 auto 12px; display: block; }
.doc-page canvas { display: block; max-width: 100%; background: #fff; box-shadow: 0 2px 12px rgba(0,0,0,.3); }
.doc-modal-nav {
  flex-shrink: 0; display: flex; align-items: center; justify-content: center; gap: 14px;
  background: #1e293b; color: #fff; padding: 8px 16px; font-size: 13px;
  border-top: 1px solid #334155;
}
.doc-modal-nav button { background: transparent; color: #fff; border: none; font-size: 20px; cursor: pointer; line-height: 1; padding: 0 6px; border-radius: 4px; }
.doc-modal-nav button:hover { background: #334155; color: #93c5fd; }
.doc-modal-loading {
  display: flex; align-items: center; justify-content: center; min-height: 120px;
  color: #cbd5e1; font-size: 14px;
}

/* === 回答评价(准确/不准确) === */
.answer-feedback { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 8px 0 4px; margin-top: 8px; border-top: 1px dashed #e5e7eb; font-size: 13px; }
.fb-label { color: #64748b; }
.fb-btn { background: #fff; border: 1px solid #d1d5db; border-radius: 16px; padding: 4px 12px; font-size: 13px; cursor: pointer; color: #334155; }
.fb-btn:hover { border-color: #2563eb; color: #2563eb; }
.fb-btn.selected { background: #eff6ff; border-color: #2563eb; color: #2563eb; }
.fb-btn:disabled { opacity: 0.55; cursor: default; }
.fb-hint { color: #64748b; font-size: 12px; margin-left: 4px; }
/* 评价反馈输入框 */
.fb-modal { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 1100; }
.fb-modal.open { display: flex; align-items: center; justify-content: center; padding: 16px; }
.fb-modal-box { background: #fff; border-radius: 10px; padding: 20px; width: min(92vw, 460px); box-shadow: 0 8px 32px rgba(0,0,0,.25); }
.fb-modal-title { font-size: 15px; font-weight: 600; margin-bottom: 10px; color: #1e293b; }
.fb-modal-box textarea { width: 100%; box-sizing: border-box; border: 1px solid #d1d5db; border-radius: 6px; padding: 8px 10px; font-size: 13px; resize: vertical; font-family: inherit; }
.fb-modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.fb-modal-actions button { border: 1px solid #d1d5db; background: #fff; color: #334155; padding: 6px 16px; border-radius: 6px; font-size: 13px; cursor: pointer; }
.fb-modal-actions button.primary { background: #2563eb; color: #fff; border-color: #2563eb; }
.fb-modal-actions button.primary:hover { background: #1d4ed8; }

/* ===== law 法规问答界面(右侧复用 #app 食品样式, 仅左侧 sidebar 独立, 配色用 --primary 统一) ===== */
.law-name-mask{position:fixed;inset:0;background:rgba(0,0,0,.5);display:none;align-items:center;justify-content:center;z-index:1000}
.law-name-box{background:#fff;padding:28px 32px;border-radius:12px;text-align:center;max-width:360px;color:var(--text-dark)}
.law-name-box .logo-badge{margin:0 auto 12px}
.law-name-box h2{font-size:18px;margin-bottom:8px}
.law-name-box p{font-size:13px;color:var(--text-muted);margin-bottom:12px}
.law-name-box input{display:block;width:100%;padding:10px;margin:8px 0 14px;border:1px solid var(--border);border-radius:8px;font-size:15px}
.law-name-box button{padding:10px 24px;background:var(--primary);color:#fff;border:none;border-radius:8px;font-size:15px;cursor:pointer}
.law-layout{display:flex;height:100vh;height:100dvh;max-width:1200px;margin:0 auto}
.law-layout > #app{flex:1;min-width:0;max-width:none;margin:0}
.law-sidebar{width:240px;background:var(--primary);color:#fff;display:flex;flex-direction:column;padding:12px;flex-shrink:0}
.law-user{font-size:14px;padding:8px 6px;border-bottom:1px solid rgba(255,255,255,.2);margin-bottom:8px;opacity:.92}
.law-new{padding:8px 10px;background:rgba(255,255,255,.15);border:1px solid rgba(255,255,255,.25);color:#fff;border-radius:6px;cursor:pointer;margin-bottom:8px;font-size:13px;text-align:left}
.law-new:hover{background:rgba(255,255,255,.25)}
.law-list{list-style:none;margin:0;padding:0;overflow:auto;flex:1}
.law-item{display:flex;align-items:center;padding:8px 6px;border-radius:6px;margin-bottom:2px}
.law-item:hover{background:rgba(255,255,255,.12)}
.law-item.active{background:rgba(255,255,255,.22)}
.law-item-title{flex:1;font-size:13px;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;cursor:pointer;opacity:.92}
.law-item-del{border:none;background:none;color:rgba(255,255,255,.6);cursor:pointer;font-size:13px;padding:2px 4px}
.law-item-del:hover{color:#fff}
/* 重试(系统忙) */
.retry-box{display:flex;align-items:center;gap:10px;color:#666;font-size:14px}
.retry-btn{padding:5px 16px;background:var(--primary);color:#fff;border:none;border-radius:6px;cursor:pointer;font-size:13px}
.retry-btn:hover{background:var(--primary-light)}

/* ── 悬浮导航(consult/license 页): 右下角主钮, hover/点击向上浮出 首页+另一助手 ── */
.fab {
  position: absolute; right: -2px; bottom: calc(100% + 24px); z-index: 50; /* -2px: 44px圆钮与40px发送键中心对齐 */
  display: flex; flex-direction: column; align-items: flex-end; gap: 10px;
}
.fab-main {
  width: 44px; height: 44px; border-radius: 50%; border: none; cursor: pointer;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 14px rgba(30, 58, 95, 0.35);
  transition: transform 0.2s;
}
.fab-main:hover { transform: scale(1.06); }
.fab-item {
  display: flex; align-items: center; gap: 8px; text-decoration: none;
  opacity: 0; transform: translateY(12px); pointer-events: none;
  transition: opacity 0.18s, transform 0.18s;
}
.fab-item .fi-btn {
  width: 44px; height: 44px; border-radius: 50%; background: #fff;
  color: var(--primary); display: flex; align-items: center; justify-content: center;
  box-shadow: 0 3px 10px rgba(15, 23, 42, 0.18);
  transition: transform 0.18s, box-shadow 0.18s, background 0.18s, color 0.18s;
}
.fab-item:hover .fi-btn {
  transform: translateY(-3px) scale(1.08);
  box-shadow: 0 7px 16px rgba(30, 58, 95, 0.25);
  background: linear-gradient(135deg, #3a6ba3, #5c8bc2); /* 比主钮浅一档的品牌蓝, 保持层级区分 */
  color: #fff;
}
.fab-item .fi-label {
  background: linear-gradient(135deg, #3a6ba3, #5c8bc2); color: #fff; font-size: 12px;
  border-radius: 999px; white-space: nowrap; overflow: hidden;
  opacity: 0; max-width: 0; padding: 0;
  transition: opacity 0.2s, max-width 0.2s, padding 0.2s;
}
.fab-item:hover .fi-label {
  opacity: 1; max-width: 120px; padding: 3px 10px;
}
.fab:hover .fab-item, .fab.open .fab-item { opacity: 1; transform: translateY(0); pointer-events: auto; }
.fab:hover .fab-item:nth-of-type(2), .fab.open .fab-item:nth-of-type(2) { transition-delay: 0.04s; }

/* 同一问题反复追问的提示条 */
.q-repeat-tip {
  margin-top: 8px;
  padding: 8px 12px;
  border-radius: 8px;
  background: #fff7e6;
  border: 1px solid #ffd591;
  color: #874d00;
  font-size: 13px;
  line-height: 1.6;
}

/* ===== law 手机适配 + 移动端通用修补 ===== */
/* 桌面端汉堡钮不渲染(空元素), ≤768px 才显示 */
.law-menu-btn { display: none; }

@media (max-width: 768px) {
  /* iOS Safari: 输入框字号 <16px 聚焦时整页自动放大 */
  #msg-input { font-size: 16px; }
  /* iPhone 底部安全区(Home 条) */
  .input-area { padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
  /* 回答里的宽表格(法规条款对照)横向滚动, 不撑破气泡 */
  .msg-bubble table { display: block; overflow-x: auto; }
  /* 引用文档预览弹窗全屏(92vw 居中卡在手机上看不清 PDF) */
  .doc-modal.open { padding: 0; }
  .doc-modal-box { width: 100vw; height: 100dvh; border-radius: 0; }

  /* law 会话侧栏 → 抽屉 */
  .law-layout { position: relative; }
  .law-menu-btn {
    display: flex; align-items: center; justify-content: center;
    width: 34px; height: 34px; padding: 0;
    border: 1px solid rgba(255,255,255,.3); border-radius: 8px;
    background: rgba(255,255,255,.2); color: #fff; cursor: pointer; flex-shrink: 0;
  }
  .law-sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 1200;
    width: min(78vw, 300px);
    transform: translateX(-105%);
    transition: transform 0.25s ease;
    box-shadow: 0 0 24px rgba(0,0,0,.25);
  }
  .law-layout.sidebar-open .law-sidebar { transform: translateX(0); }
  .law-backdrop {
    position: fixed; inset: 0; z-index: 1100;
    background: rgba(0,0,0,.45);
    opacity: 0; pointer-events: none;
    transition: opacity 0.2s;
  }
  .law-layout.sidebar-open .law-backdrop { opacity: 1; pointer-events: auto; }
  /* 称呼弹窗小屏收窄 */
  .law-name-box { width: calc(100vw - 48px); max-width: 360px; padding: 22px 20px; }
}
