/* ClinMedAgent Lite — 界面样式（无外部依赖，纯 CSS）
   设计目标：学术/医学工具的清爽专业感 + 长文阅读舒适度 + 响应式。 */

/* ============ 设计令牌 ============ */
:root {
  /* 中性色阶 */
  --bg: #f2f5f9;
  --bg-soft: #e9eef6;
  --bg-card: #ffffff;
  --bg-inset: #f7f9fc;
  --border: #e3e9f2;
  --border-strong: #cfd8e6;

  /* 文字 */
  --text: #1a2433;
  --text-soft: #475569;
  --text-muted: #6b7a90;

  /* 主色（医学青蓝） */
  --primary: #0f6fd6;
  --primary-dark: #0a56a8;
  --primary-soft: #e7f1fd;
  --primary-line: #bcd8f6;
  --accent: #0d9bb8;
  --accent-soft: #e2f6fa;

  /* 语义色 */
  --ok: #0f9d58;
  --ok-soft: #e6f6ed;
  --warn: #c77700;
  --warn-soft: #fdf3e3;
  --err: #d92d20;
  --err-soft: #fdecea;

  /* 形状与阴影 */
  --radius-lg: 16px;
  --radius: 12px;
  --radius-sm: 9px;
  --shadow-sm: 0 1px 2px rgba(16, 30, 54, .06);
  --shadow: 0 1px 3px rgba(16, 30, 54, .07), 0 8px 24px -12px rgba(16, 30, 54, .12);
  --shadow-lg: 0 2px 6px rgba(16, 30, 54, .06), 0 24px 48px -24px rgba(16, 30, 54, .22);
  --ring: 0 0 0 3px rgba(15, 111, 214, .16);

  /* 字体：中文优先，英文/数字跟随系统；正文追求长时间阅读舒适 */
  --font: "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei UI", "Microsoft YaHei",
          "Source Han Sans SC", "Noto Sans SC", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", "Cascadia Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --fs-body: 15px;
  --lh-body: 1.75;
  --tr: .18s cubic-bezier(.4, 0, .2, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c1420;
    --bg-soft: #121c2b;
    --bg-card: #16202e;
    --bg-inset: #111a26;
    --border: #253345;
    --border-strong: #33455c;
    --text: #e8eef6;
    --text-soft: #c3cedd;
    --text-muted: #92a1b6;
    --primary: #4b9ef0;
    --primary-dark: #2b7fd0;
    --primary-soft: #14283f;
    --primary-line: #24486d;
    --accent: #35bdd6;
    --accent-soft: #102b31;
    --ok: #35c07a;
    --ok-soft: #102a1e;
    --warn: #e0a13a;
    --warn-soft: #2c2415;
    --err: #f27269;
    --err-soft: #2e1a19;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow: 0 1px 3px rgba(0, 0, 0, .45), 0 10px 30px -14px rgba(0, 0, 0, .6);
    --shadow-lg: 0 30px 60px -28px rgba(0, 0, 0, .7);
    --ring: 0 0 0 3px rgba(75, 158, 240, .22);
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4 { line-height: 1.35; font-weight: 700; letter-spacing: -.01em; }
b, strong { font-weight: 600; }
code, pre, .mono { font-family: var(--font-mono); font-size: .92em; }
button, input, select, textarea { font-family: inherit; font-size: inherit; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--radius-sm); }

#app { min-height: 100vh; display: flex; flex-direction: column; }

/* ============ 顶栏 ============ */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  background: color-mix(in srgb, var(--bg-card) 88%, transparent);
  backdrop-filter: saturate(150%) blur(10px);
  border-bottom: 1px solid var(--border);
  padding: 11px 24px;
  box-shadow: var(--shadow-sm);
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-logo {
  width: 42px; height: 42px; border-radius: 12px; flex: none;
  display: grid; place-items: center;
  background: linear-gradient(140deg, var(--primary), var(--accent));
  color: #fff; font-weight: 700; font-size: 19px; letter-spacing: .02em;
  box-shadow: 0 6px 16px -6px color-mix(in srgb, var(--primary) 65%, transparent);
}
.brand-text h1 { font-size: 17.5px; font-weight: 700; white-space: nowrap; }
.brand-sub { font-size: 12px; color: var(--text-muted); white-space: nowrap; }

.tabs { display: flex; gap: 4px; margin-left: auto; flex-wrap: wrap; }
.tab {
  border: 1px solid transparent; background: transparent; color: var(--text-soft);
  font-size: 14px; padding: 8px 15px; border-radius: 999px; cursor: pointer;
  transition: all var(--tr); white-space: nowrap;
}
.tab:hover { background: var(--primary-soft); color: var(--primary); }
.tab.active {
  background: var(--primary); color: #fff; font-weight: 600;
  box-shadow: 0 4px 14px -6px color-mix(in srgb, var(--primary) 70%, transparent);
}

.top-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.status-pill {
  display: flex; align-items: center; gap: 7px;
  background: var(--bg-inset); border: 1px solid var(--border);
  padding: 5px 12px; border-radius: 999px; font-size: 12.5px; color: var(--text-muted);
  white-space: nowrap;
}
.status-pill .dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--warn);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--warn) 18%, transparent);
}
.status-pill.ok .dot { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.status-pill.err .dot { background: var(--err); box-shadow: 0 0 0 3px var(--err-soft); }
.user-badge {
  font-size: 12.5px; color: var(--primary); background: var(--primary-soft);
  border: 1px solid var(--primary-line); border-radius: 999px; padding: 4px 13px;
  white-space: nowrap; font-weight: 500;
}
.user-badge .admin { color: var(--warn); font-weight: 700; }
.btn-ghost {
  border: 1px solid var(--border-strong); background: transparent; color: var(--text-soft);
  border-radius: var(--radius-sm); padding: 6px 13px; font-size: 13px; cursor: pointer;
  transition: all var(--tr);
}
.btn-ghost:hover { color: var(--err); border-color: var(--err); background: var(--err-soft); }

/* ============ 主体 ============ */
.content { flex: 1; width: 100%; max-width: 1180px; margin: 0 auto; padding: 26px 24px 56px; }
.panel { display: none; animation: fade .22s ease; }
.panel.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ============ 登录/注册 ============ */
.auth-screen {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(1100px 620px at 12% -8%, var(--primary-soft), transparent 60%),
    radial-gradient(900px 560px at 104% 6%, var(--accent-soft), transparent 58%),
    var(--bg);
  padding: 24px; overflow: auto;
}
.auth-card {
  width: 400px; max-width: 100%; background: var(--bg-card);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); padding: 30px 32px 26px;
  display: flex; flex-direction: column; gap: 15px;
}
.auth-brand { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.auth-brand h1 { font-size: 21px; margin-top: 10px; }
.auth-brand .brand-sub { font-size: 12.5px; }
.auth-tabs {
  display: flex; gap: 4px; border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; background: var(--bg-inset); padding: 4px;
}
.auth-tab {
  flex: 1; padding: 9px 0; border: none; background: transparent; cursor: pointer;
  font-size: 14px; color: var(--text-muted); border-radius: var(--radius-sm); transition: all var(--tr);
}
.auth-tab.active { background: var(--bg-card); color: var(--primary); font-weight: 600; box-shadow: var(--shadow-sm); }
.auth-form { display: flex; flex-direction: column; gap: 13px; }
.auth-form label {
  font-size: 13px; display: flex; flex-direction: column; gap: 7px; color: var(--text-soft); font-weight: 500;
}
.auth-form input {
  border: 1px solid var(--border-strong); background: var(--bg-card); color: var(--text);
  border-radius: var(--radius-sm); padding: 11px 13px; font-size: 14.5px; transition: all var(--tr);
}
.auth-form input:focus { border-color: var(--primary); box-shadow: var(--ring); }
.auth-msg { font-size: 13px; min-height: 19px; color: var(--err); }
.auth-msg.ok { color: var(--ok); }

/* ============ 按钮 ============ */
.btn-primary {
  border: none; cursor: pointer; color: #fff; font-weight: 600; font-size: 14.5px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-radius: var(--radius-sm); padding: 10px 22px; transition: all var(--tr);
  box-shadow: 0 6px 18px -8px color-mix(in srgb, var(--primary) 75%, transparent);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 10px 22px -8px color-mix(in srgb, var(--primary) 80%, transparent); }
.btn-primary:disabled { opacity: .55; cursor: not-allowed; transform: none; }

/* ============ 检索 / 名词解释 ============ */
.search-hero { text-align: center; padding: 26px 0 18px; }
.search-hero h2 { font-size: 26px; margin-bottom: 8px; }
.hero-sub { color: var(--text-muted); font-size: 14.5px; max-width: 640px; margin: 0 auto 22px; }
.search-box {
  display: flex; gap: 10px; max-width: 780px; margin: 0 auto; align-items: stretch;
  flex-wrap: wrap;
}
.search-box input[type="text"] {
  flex: 1 1 300px; min-width: 0;
  border: 1px solid var(--border-strong); background: var(--bg-card); color: var(--text);
  border-radius: var(--radius); padding: 13px 16px; font-size: 15px; transition: all var(--tr);
  box-shadow: var(--shadow-sm);
}
.search-box input[type="text"]:focus { border-color: var(--primary); box-shadow: var(--ring); }
.book-select {
  border: 1px solid var(--border-strong); background: var(--bg-card); color: var(--text-soft);
  border-radius: var(--radius); padding: 0 12px; font-size: 14px; max-width: 260px; cursor: pointer;
  transition: all var(--tr);
}
.book-select:focus { border-color: var(--primary); box-shadow: var(--ring); }

.results { max-width: 900px; margin: 16px auto 0; display: flex; flex-direction: column; gap: 12px; }
.result-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 15px 18px; box-shadow: var(--shadow-sm); transition: all var(--tr);
}
.result-card:hover { border-color: var(--primary-line); box-shadow: var(--shadow); transform: translateY(-1px); }
.result-head { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; margin-bottom: 9px; font-size: 12.5px; }
.result-book { color: var(--primary); background: var(--primary-soft); border-radius: 6px; padding: 2px 9px; font-weight: 600; }
.result-page { color: var(--text-muted); }
.result-section { color: var(--text-muted); border-left: 1px solid var(--border-strong); padding-left: 9px; }
.result-text { font-size: 14.5px; color: var(--text-soft); line-height: 1.8; }
.result-text mark, mark { background: #fff3bf; color: inherit; border-radius: 3px; padding: 0 2px; }
@media (prefers-color-scheme: dark) { mark { background: #4a3c14; color: #ffe9a8; } }
.empty-state { text-align: center; color: var(--text-muted); padding: 26px; font-size: 14px; }
.empty { color: var(--text-muted); }

/* ============ 名词解释卡片 ============ */
.term-card {
  background: var(--bg-card); border: 1px solid var(--border); border-left: 4px solid var(--primary);
  border-radius: var(--radius); padding: 20px 22px; box-shadow: var(--shadow);
}
.term-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.term-name {
  font-size: 19px; font-weight: 700; color: var(--primary);
  background: var(--primary-soft); border-radius: 9px; padding: 4px 14px;
}
.term-note { font-size: 12.5px; color: var(--text-muted); }
.term-body {
  font-size: 15px; line-height: 1.85; color: var(--text); white-space: pre-wrap;
  font-feature-settings: "palt" 1;
}

/* ============ 问答 ============ */
/* 用 flex + min-height:0 让聊天区自适应容器，避免 calc(100vh - N) 这类
   魔法数字在手机端（顶栏换行、地址栏伸缩）被算错，导致输入框压住消息。 */
.chat-wrap {
  display: flex; flex-direction: column;
  height: calc(100vh - 210px);                 /* 旧浏览器回退 */
  height: min(720px, calc(100dvh - 200px));    /* 支持 dvh 时更准（手机地址栏伸缩） */
  min-height: 380px;
  max-width: 900px; margin: 0 auto;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow); overflow: hidden;
}
.chat-log {
  flex: 1 1 auto; min-height: 0;                /* 关键：允许收缩，内容才在框内滚动 */
  overflow-y: auto; padding: 20px 22px;
  display: flex; flex-direction: column; gap: 16px;
}
.chat-hint {
  background: var(--bg-inset); border: 1px dashed var(--border-strong);
  border-radius: var(--radius); padding: 15px 18px; color: var(--text-soft); font-size: 13.5px;
}
.chat-hint p { font-weight: 600; margin-bottom: 7px; }
.chat-hint ul { padding-left: 20px; display: flex; flex-direction: column; gap: 4px; }
.chat-hint li { color: var(--text-muted); }

.msg { display: flex; flex-direction: column; gap: 6px; max-width: 88%; }
.msg-user { align-self: flex-end; align-items: flex-end; }
.msg-assistant { align-self: flex-start; }
.msg-label { font-size: 12px; color: var(--text-muted); font-weight: 600; padding-left: 2px; }
.msg-body {
  padding: 12px 16px; border-radius: var(--radius); font-size: 14.8px; line-height: 1.8;
  white-space: pre-wrap; word-break: break-word;
}
.msg-user .msg-body {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: #fff;
  border-bottom-right-radius: 4px; box-shadow: 0 6px 16px -10px color-mix(in srgb, var(--primary) 80%, transparent);
}
.msg-assistant .msg-body {
  background: var(--bg-inset); border: 1px solid var(--border); border-bottom-left-radius: 4px;
}
.thinking .msg-body { color: var(--text-muted); }
.typing-dots::after {
  content: ""; display: inline-block; width: 1em; text-align: left;
  animation: dots 1.4s steps(4, end) infinite;
}
@keyframes dots { 0% { content: ""; } 25% { content: "·"; } 50% { content: "··"; } 75% { content: "···"; } }

.cite {
  color: var(--primary); background: var(--primary-soft); border-radius: 5px;
  padding: 1px 6px; font-size: .92em; font-weight: 600; white-space: nowrap;
}
.evidence-block {
  margin-top: 10px; background: var(--bg-inset); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 13px 15px;
}
.evidence-block .msg-label { margin-bottom: 8px; }
.evidence-item {
  font-size: 13.2px; color: var(--text-soft); line-height: 1.7;
  padding: 9px 0; border-top: 1px solid var(--border);
}
.evidence-item:first-of-type { border-top: none; }
.evidence-item b { color: var(--primary); font-weight: 600; }

.ask-box {
  display: flex; gap: 10px; padding: 14px 16px; border-top: 1px solid var(--border);
  background: var(--bg-card); align-items: flex-end;
}
.ask-box textarea {
  flex: 1; resize: none; border: 1px solid var(--border-strong); background: var(--bg-inset);
  color: var(--text); border-radius: var(--radius); padding: 11px 14px; font-size: 14.5px;
  line-height: 1.6; max-height: 160px; transition: all var(--tr);
}
.ask-box textarea:focus { border-color: var(--primary); background: var(--bg-card); box-shadow: var(--ring); }

/* ============ 卡片与教材库 ============ */
.card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 20px 22px; box-shadow: var(--shadow-sm); transition: box-shadow var(--tr);
}
.card:hover { box-shadow: var(--shadow); }
.card h3 { font-size: 15.5px; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.card.full { grid-column: 1 / -1; }
.lib-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.muted { color: var(--text-muted); }
.muted.small, .small { font-size: 12.5px; line-height: 1.6; }
.card > .muted { font-size: 13.5px; }

.tool-download {
  margin-left: auto; font-size: 12.5px; font-weight: 600; text-decoration: none;
  color: var(--ok); background: var(--ok-soft); border: 1px solid color-mix(in srgb, var(--ok) 30%, transparent);
  border-radius: 999px; padding: 4px 12px; transition: all var(--tr); white-space: nowrap;
}
.tool-download:hover { background: var(--ok); color: #fff; }

.drop-zone {
  border: 1.5px dashed var(--border-strong); border-radius: var(--radius);
  background: var(--bg-inset); padding: 22px 16px; text-align: center; cursor: pointer;
  transition: all var(--tr);
}
.drop-zone:hover { border-color: var(--primary); background: var(--primary-soft); }
.drop-zone.dragover { border-color: var(--primary); background: var(--primary-soft); box-shadow: var(--ring); }
.drop-inner { display: flex; flex-direction: column; align-items: center; gap: 7px; color: var(--text-soft); }
.drop-icon { font-size: 30px; }
.upload-meta { margin-top: 14px; display: flex; flex-direction: column; gap: 9px; }

/* 选择文件 / 上传并识别：并排两个按钮 */
.upload-steps { display: grid; grid-template-columns: auto 1fr; gap: 9px; align-items: center; }
.upload-steps .btn-primary { width: 100%; }
.upload-steps .btn-ghost { white-space: nowrap; }
.upload-meta .btn-primary:disabled { opacity: .45; cursor: not-allowed; }
/* 拖放区不再响应点击，去掉手型光标 */
.drop-zone { cursor: default; }
.upload-actions { margin-top: 10px; }
.btn-ghost {
  border: 1px solid var(--border-strong); background: transparent; color: var(--ink-soft);
  border-radius: var(--radius-sm); padding: 9px 15px; font-size: 13px; cursor: pointer;
  transition: var(--tr);
}
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); }

/* 进度行：标签 + 进度条 + 百分比 */
.prog-row { display: grid; grid-template-columns: 46px 1fr 48px; align-items: center; gap: 9px; }
.prog-label { font-size: 12px; color: var(--ink-soft); letter-spacing: .04em; }
.prog-pct { font-size: 12px; color: var(--ink-soft); text-align: right; font-variant-numeric: tabular-nums; }
.progress-bar-ocr { background: linear-gradient(90deg, #4a8ab5, #6fb0d0); }
.upload-meta input[type="text"] {
  border: 1px solid var(--border-strong); background: var(--bg-card); color: var(--text);
  border-radius: var(--radius-sm); padding: 10px 13px; font-size: 14px;
}
.upload-progress { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.progress-track {
  height: 8px; background: var(--bg-soft); border-radius: 999px; overflow: hidden;
  border: 1px solid var(--border);
}
.progress-bar {
  height: 100%; width: 0; border-radius: 999px; transition: width .35s ease;
  background: linear-gradient(90deg, var(--primary), var(--accent));
}

.job-list, .book-list { display: flex; flex-direction: column; gap: 10px; max-height: 420px; overflow-y: auto; }
.job-item {
  border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px;
  background: var(--bg-inset); display: flex; flex-direction: column; gap: 8px;
}
.job-head { display: flex; align-items: center; gap: 9px; justify-content: space-between; }
.job-title { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 46%; }
.job-badge {
  font-size: 11.5px; border-radius: 999px; padding: 2px 9px; font-weight: 600;
  background: var(--bg-soft); color: var(--text-muted); white-space: nowrap;
}
.job-badge.queued { background: var(--warn-soft); color: var(--warn); }
.job-badge.ocr, .job-badge.indexing { background: var(--primary-soft); color: var(--primary); }
.job-badge.done { background: var(--ok-soft); color: var(--ok); }
.job-badge.error, .job-badge.cancelled { background: var(--err-soft); color: var(--err); }
.job-badge.text { background: var(--accent-soft); color: var(--accent); }
.job-meta { font-size: 12.2px; color: var(--text-muted); }

.book-item {
  display: flex; align-items: center; gap: 14px;
  border: 1px solid var(--border); border-radius: var(--radius); padding: 13px 16px;
  background: var(--bg-inset); transition: all var(--tr);
}
.book-item:hover { border-color: var(--primary-line); background: var(--bg-card); box-shadow: var(--shadow-sm); }
.b-main { min-width: 0; flex: 1; }
.b-title { font-size: 14.8px; font-weight: 600; margin-bottom: 3px; overflow-wrap: anywhere; }
.b-meta { font-size: 12.3px; color: var(--text-muted); }
.book-del {
  flex: none; border: 1px solid var(--border-strong); background: transparent; color: var(--text-muted);
  border-radius: var(--radius-sm); padding: 6px 14px; font-size: 13px; cursor: pointer; transition: all var(--tr);
}
.book-del:hover { color: #fff; background: var(--err); border-color: var(--err); }
.book-del:disabled { opacity: .6; cursor: progress; }

/* ============ 设置 ============ */
.settings-wrap { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; align-items: start; }
.key-form { display: flex; flex-direction: column; gap: 14px; margin-top: 6px; }
.key-form label {
  font-size: 13.2px; color: var(--text-soft); display: flex; flex-direction: column; gap: 7px; font-weight: 500;
}
.key-form input {
  border: 1px solid var(--border-strong); background: var(--bg-inset); color: var(--text);
  border-radius: var(--radius-sm); padding: 10px 13px; font-size: 14px; font-family: var(--font-mono);
  transition: all var(--tr);
}
.key-form input:focus { border-color: var(--primary); background: var(--bg-card); box-shadow: var(--ring); }
.sys-status { display: flex; flex-direction: column; gap: 2px; margin-top: 6px; }
.sys-status .row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  font-size: 13.6px; padding: 9px 12px; border-radius: var(--radius-sm); border: 1px solid transparent;
}
.sys-status .row:nth-child(odd) { background: var(--bg-inset); }
.sys-status .row > span { color: var(--text-muted); }
.sys-status .row > b { font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; overflow-wrap: anywhere; }
.v-ok { color: var(--ok); }
.v-err { color: var(--err); }

/* [hidden] 必须真的隐藏：作者样式里的 display 会覆盖浏览器默认的 display:none */
[hidden] { display: none !important; }

/* ---------- 版本标记（用于判断浏览器是否在用旧页面） ---------- */
.build-tag {
  text-align: center; font-size: 11.5px; color: var(--text-muted);
  margin: 6px 0 0; letter-spacing: .3px;
}
.build-tag span { font-family: var(--mono); color: var(--text-soft); }

/* ---------- 问答配图（多模态） ---------- */
.btn-icon {
  flex: none; width: 42px; height: 42px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--bg-inset); color: var(--text-soft);
  font-size: 18px; cursor: pointer; transition: all var(--tr); display: grid; place-items: center;
}
.btn-icon:hover { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }

.ask-images {
  display: flex; gap: 10px; flex-wrap: wrap; padding: 12px 16px 0;
  border-top: 1px solid var(--border); background: var(--bg-card);
}
.ask-thumb {
  position: relative; width: 74px; height: 74px; border-radius: var(--radius-sm);
  overflow: hidden; border: 1px solid var(--border-strong); background: var(--bg-inset);
}
.ask-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb-del {
  position: absolute; top: 2px; right: 2px; width: 20px; height: 20px; border-radius: 50%;
  border: none; background: rgba(15, 23, 42, .72); color: #fff; font-size: 14px; line-height: 1;
  cursor: pointer; display: grid; place-items: center; transition: background var(--tr);
}
.thumb-del:hover { background: var(--err); }

.msg-images { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 9px; }
.msg-images img {
  max-width: 190px; max-height: 190px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); display: block; background: #fff;
}
.msg-note {
  display: block; margin-top: 10px; padding: 7px 11px;
  font-size: 12.4px; line-height: 1.5; color: var(--text-muted);
  background: color-mix(in srgb, var(--primary) 7%, transparent);
  border-left: 3px solid var(--primary-line); border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
/* 注入的块级内容（提示 / 证据）不要继承气泡的 pre-wrap，否则会多出空行 */
.msg-body > .msg-note,
.msg-body > .evidence-block { white-space: normal; }
.msg-body > .msg-note { margin-top: 12px; }

/* ============ 轻提示 ============ */
.toast {
  position: fixed; left: 50%; bottom: 34px; transform: translateX(-50%);
  background: var(--text); color: var(--bg-card); font-size: 13.6px; font-weight: 500;
  padding: 10px 20px; border-radius: 999px; box-shadow: var(--shadow-lg); z-index: 200;
  animation: toast-in .24s ease;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ============ 响应式 ============ */
@media (max-width: 900px) {
  .lib-grid, .settings-wrap { grid-template-columns: 1fr; }
  .content { padding: 20px 16px 44px; }
  .search-hero { padding: 18px 0 12px; }
  .search-hero h2 { font-size: 22px; }
}
@media (max-width: 720px) {
  .topbar { gap: 10px; padding: 10px 14px; }
  .brand-text h1 { font-size: 15.5px; }
  .brand-sub { display: none; }
  .tabs { width: 100%; margin-left: 0; overflow-x: auto; padding-bottom: 2px; }
  .tab { font-size: 13px; padding: 7px 12px; }
  .top-right { width: 100%; justify-content: space-between; }
  .chat-wrap { height: calc(100vh - 268px); height: min(660px, calc(100dvh - 268px)); min-height: 340px; }
  .chat-log { padding: 15px 14px; gap: 13px; }
  .msg { max-width: 96%; }
  .msg-note { margin-top: 10px; padding: 6px 10px; }
  .search-box input[type="text"] { flex: 1 1 100%; }
  .book-select { max-width: none; width: 100%; padding: 10px 12px; }
  .search-box .btn-primary { width: 100%; }
}

/* 滚动条（WebKit） */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* 打印：去掉交互外壳，便于导出教材证据 */
@media print {
  .topbar, .ask-box, .drop-zone, .tool-download, .book-del, .toast { display: none !important; }
  .content { max-width: none; padding: 0; }
  .chat-wrap, .card, .result-card, .term-card { box-shadow: none; border-color: #ccc; }
}