/* PaperDesk —— 文献工作台样式 */

:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #eef2f7;
  --surface-3: #e3e9f1;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --accent: #2563eb;
  --accent-strong: #1d4ed8;
  --accent-soft: #dbeafe;
  --green: #059669;
  --green-soft: #d1fae5;
  --amber: #b45309;
  --amber-soft: #fef3c7;
  --red: #dc2626;
  --red-soft: #fee2e2;
  --violet: #7c3aed;
  --violet-soft: #ede9fe;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 12px 30px rgba(15, 23, 42, .07);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
  --radius: 14px;
  --radius-sm: 9px;
  --pdf-bg: #525659;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans CJK SC",
          "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --mono: "JetBrains Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1120;
    --surface: #111827;
    --surface-2: #1a2332;
    --surface-3: #233044;
    --text: #e5e7eb;
    --muted: #94a3b8;
    --line: #263244;
    --accent: #60a5fa;
    --accent-strong: #93c5fd;
    --accent-soft: #1e3a8a;
    --green: #34d399;
    --green-soft: #064e3b;
    --amber: #fbbf24;
    --amber-soft: #78350f;
    --red: #f87171;
    --red-soft: #7f1d1d;
    --violet: #a78bfa;
    --violet-soft: #4c1d95;
    --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 16px 36px rgba(0, 0, 0, .28);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35);
    --pdf-bg: #1f2937;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.3; letter-spacing: -.01em; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a:focus-visible, button:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
code, .mono { font-family: var(--mono); font-size: .9em; }
.break { word-break: break-all; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 12px; }
.footnote { color: var(--muted); font-size: 12px; margin-top: 12px; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
/* 论文详情页：顶栏作为页面普通头部，随页面滚动离开，不悬浮遮挡正文 */
body.paper-detail .topbar { position: static; }
body.paper-detail .detail-side { top: 16px; }
.topbar-inner {
  max-width: 1440px;
  margin: 0 auto;
  padding: 10px 24px;
  display: flex;
  align-items: center;
  gap: 26px;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; flex: 0 0 auto; }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 11px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--violet));
  color: #fff; font-weight: 800; font-size: 18px;
  box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 32%, transparent);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 16px; letter-spacing: -.02em; }
.brand-text small { color: var(--muted); font-size: 11px; letter-spacing: .08em; }
.nav { display: flex; gap: 4px; flex: 1 1 auto; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a {
  color: var(--muted); padding: 9px 14px; border-radius: 9px;
  font-size: 14px; white-space: nowrap; text-decoration: none;
}
.nav a:hover { color: var(--text); background: var(--surface-2); }
.nav a.active { color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.top-search { display: flex; align-items: center; flex: 0 1 320px; position: relative; }
.top-search input {
  width: 100%; border: 1px solid var(--line); background: var(--surface-2);
  border-radius: 10px; padding: 8px 38px 8px 12px; outline: none; font-size: 13px;
}
.top-search input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent); }
.top-search button {
  position: absolute; right: 3px; width: 34px; height: 34px;
  border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-size: 18px;
}
.top-search button:hover { background: var(--surface-3); color: var(--text); }

/* ---------- 页面骨架 ---------- */
.page { max-width: 1440px; margin: 0 auto; padding: 34px 30px 80px; }
.footer {
  border-top: 1px solid var(--line);
  color: var(--muted); font-size: 12px;
  max-width: 1440px; margin: 0 auto; padding: 20px 24px 34px;
  display: flex; gap: 18px; flex-wrap: wrap; justify-content: space-between;
}
.eyebrow {
  color: var(--accent); font-size: 12px; font-weight: 700;
  letter-spacing: .14em; text-transform: uppercase; margin-bottom: 8px;
}
.lede { color: var(--muted); font-size: 15px; margin-top: 8px; max-width: 70ch; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head h1 { font-size: 30px; }
.head-stats { display: flex; gap: 22px; color: var(--muted); font-size: 13px; }
.head-stats strong { color: var(--text); font-size: 20px; margin-right: 4px; }

/* ---------- 按钮 / 徽标 / 标签 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border-radius: 9px; border: 1px solid transparent;
  font-size: 13.5px; font-weight: 600; text-decoration: none; line-height: 1.4;
  transition: .15s ease; white-space: nowrap;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn.primary { background: var(--accent); color: #fff; box-shadow: 0 4px 12px color-mix(in srgb, var(--accent) 30%, transparent); }
.btn.primary:hover { background: var(--accent-strong); }
.btn.ghost { background: var(--surface); border-color: var(--line); color: var(--text); }
.btn.ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn.small { padding: 7px 13px; font-size: 12.5px; }
.link { background: none; border: 0; padding: 5px 8px; border-radius: 7px; color: var(--accent); font-size: 13px; }
.link:hover { background: var(--surface-2); text-decoration: none; }
.link.danger { color: var(--red); }
.text-link { color: var(--accent); font-size: 13px; font-weight: 600; white-space: nowrap; padding: 4px 6px; border-radius: 6px; }
.text-link:hover { background: var(--surface-2); text-decoration: none; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--surface); display: inline-grid; place-items: center; font-size: 19px; line-height: 1;
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }

.badge {
  display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; line-height: 1.7; white-space: nowrap;
}
.badge.paper { background: var(--accent-soft); color: var(--accent-strong); }
.badge.patent { background: var(--amber-soft); color: var(--amber); }
.badge.done { background: var(--green-soft); color: var(--green); }
.badge.relevant { background: var(--violet-soft); color: var(--violet); }
.badge.muted { background: var(--surface-2); color: var(--muted); }
.badge.read { background: var(--green-soft); color: var(--green); }
.paper-row.is-read .paper-row-title { color: var(--muted); }
.paper-row.is-read:hover .paper-row-title { color: var(--accent); }

.score {
  display: inline-flex; align-items: baseline; gap: 2px;
  min-width: 44px; justify-content: center;
  padding: 4px 8px; border-radius: 9px; font-weight: 800; font-size: 16px;
  background: var(--surface-2); color: var(--muted);
  transition: transform .15s ease;
}
.paper-row:hover .score { transform: translateY(-1px); }
.score small { font-size: 10px; font-weight: 600; opacity: .7; }
.score.great { background: var(--green-soft); color: var(--green); }
.score.good { background: var(--accent-soft); color: var(--accent-strong); }
.score.mid { background: var(--amber-soft); color: var(--amber); }
.score.low { background: var(--surface-2); color: var(--muted); }

.chips { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.chips.vertical { flex-direction: column; align-items: flex-start; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 11px; border-radius: 999px; font-size: 12px;
  background: var(--surface-2); color: var(--muted); border: 1px solid transparent;
  text-decoration: none; transition: background .15s ease, border-color .15s ease;
}
.chip::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: var(--chip-color, var(--accent)); opacity: .9;
}
.chip:hover { border-color: var(--chip-color, var(--accent)); color: var(--text); text-decoration: none; }
.chip.static { cursor: default; }
.chip.static:hover { border-color: transparent; }
.chip.level2 {
  font-size: 11px; padding: 3px 8px; background: transparent;
  border: 1px dashed color-mix(in srgb, var(--chip-color, var(--accent)) 45%, var(--line));
}
.chip.level2:hover { border-style: solid; background: var(--surface-2); }
.chips.children { margin: 7px 0 0 12px; }
.topic-groups { display: grid; gap: 12px; }
.topic-group { display: grid; gap: 2px; }
.tag-editor {
  margin-top: 14px; padding-top: 11px;
  border-top: 1px dashed var(--line);
}
.tag-editor > summary {
  list-style: none; cursor: pointer; color: var(--accent);
  font-size: 12.5px; font-weight: 650;
}
.tag-editor > summary::-webkit-details-marker { display: none; }
.tag-editor > summary::before {
  content: "＋"; margin-right: 4px; font-weight: 700;
}
.tag-editor[open] > summary::before { content: "－"; }
.tag-add-form {
  display: grid; grid-template-columns: 1fr; gap: 7px;
  margin: 11px 0 8px;
}
.tag-add-form input[type="text"],
.tag-add-form select {
  width: 100%; min-width: 0; padding: 8px 10px;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px;
  font-size: 12.5px;
}
.tag-add-form input[type="text"]:focus,
.tag-add-form select:focus { border-color: var(--accent); outline: none; }
.tag-add-form .btn { justify-self: start; }
.tag-editor .hint { margin: 0 0 10px; line-height: 1.6; }
.manual-tag-list {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  margin-top: 8px;
}
.manual-tag-form { display: inline-flex; margin: 0; }
.chip.manual.removable {
  border-style: dashed; cursor: pointer;
  background: color-mix(in srgb, var(--chip-color, var(--accent)) 12%, var(--surface));
}
.chip.manual.removable:hover {
  color: var(--red); border-color: var(--red);
  background: var(--red-soft);
}
.inline-form { display: inline-flex; margin: 0; align-items: center; }
.chip.primary { background: color-mix(in srgb, var(--chip-color, var(--accent)) 12%, var(--surface)); color: var(--text); font-weight: 600; }
.chip.active {
  background: color-mix(in srgb, var(--chip-color, var(--accent)) 16%, var(--surface));
  color: var(--text); font-weight: 600;
  border-color: color-mix(in srgb, var(--chip-color, var(--accent)) 55%, var(--line));
}
.keyword-list { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }

/* ---------- 标签筛选树（一级标签本身可点击） ---------- */
.tag-filter { padding: 12px 14px; margin: -4px 0 16px; }
.tag-filter-head { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; }
.tag-filter-title { font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: .04em; }
.tag-path { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.tag-path a { color: var(--accent); text-decoration: none; }
.tag-path a:hover { text-decoration: underline; }
.tag-tree { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: flex-start; margin-top: 10px; }
.tag-branch { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.tag-branch.has-active { flex-basis: 100%; }
.tag-children {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  margin-left: 4px; padding-left: 10px;
  border-left: 2px solid var(--line);
}
@media (max-width: 720px) {
  .tag-filter { padding: 10px 11px; }
  .tag-tree { gap: 7px 10px; }
  .tag-children { flex-basis: 100%; margin-left: 0; }
}
.keyword { font-size: 11px; background: var(--surface-2); color: var(--muted); border-radius: 6px; padding: 2px 7px; }

/* ---------- 面板 / 首页 ---------- */
.panel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.panel.compact { padding: 18px; }
.panel h2 { font-size: 17px; }
.panel h3 { font-size: 14px; margin-bottom: 12px; }
.panel-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px; padding: 18px 20px 0;
}
.panel-head p { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.panel.compact .panel-head { padding: 0 0 10px; }

.hero {
  display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(320px, .65fr);
  gap: 30px; align-items: center;
  padding: 38px 40px; margin-bottom: 26px;
  border: 1px solid var(--line); border-radius: 22px;
  background:
    radial-gradient(800px 240px at 0% 0%, color-mix(in srgb, var(--accent) 12%, transparent), transparent 70%),
    radial-gradient(600px 240px at 100% 100%, color-mix(in srgb, var(--violet) 10%, transparent), transparent 70%),
    var(--surface);
  box-shadow: var(--shadow);
}
.hero h1 { font-size: clamp(26px, 3.4vw, 42px); letter-spacing: -.035em; max-width: 24ch; line-height: 1.28; }
.hero .lede { font-size: 16px; }
.hero-actions { display: flex; gap: 10px; margin-top: 22px; flex-wrap: wrap; }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.stat {
  background: color-mix(in srgb, var(--surface) 70%, var(--surface-2));
  border: 1px solid var(--line); border-radius: 13px; padding: 15px;
  display: flex; flex-direction: column; gap: 2px;
  color: inherit; text-decoration: none;
  transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease;
}
.stat:hover { transform: translateY(-2px); border-color: var(--accent); box-shadow: var(--shadow-sm); }
.stat strong { font-size: 25px; letter-spacing: -.03em; }
.stat span { color: var(--muted); font-size: 12px; }

.home-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 22px; align-items: start; }
.home-side { display: grid; gap: 16px; }

.paper-list { overflow: hidden; }
.paper-row {
  position: relative;
  display: flex; gap: 18px; align-items: flex-start;
  padding: 22px 30px; border-bottom: 1px solid var(--line);
  color: inherit; text-decoration: none;
  transition: background .16s ease, box-shadow .16s ease;
}
.paper-row::before {
  content: ""; position: absolute; left: 0; top: 13px; bottom: 13px;
  width: 3px; border-radius: 3px; background: transparent;
  transition: background .16s ease;
}
.paper-row:last-child { border-bottom: 0; }
.paper-row:hover {
  background: color-mix(in srgb, var(--accent) 5%, var(--surface));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 12%, transparent);
  text-decoration: none;
}
.paper-row:hover::before { background: var(--accent); }
.paper-row-main { flex: 1 1 auto; min-width: 0; }
.paper-row-top { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.paper-row-title { font-size: 16.5px; font-weight: 650; color: var(--text); letter-spacing: -.015em; transition: color .15s ease; }
.paper-row:hover .paper-row-title { color: var(--accent); }
.paper-row-meta { color: var(--muted); font-size: 12.5px; margin-top: 5px; display: flex; gap: 6px; flex-wrap: wrap; }
.paper-row-meta .dot { opacity: .5; }
.paper-row-summary {
  color: var(--muted); font-size: 13px; margin-top: 7px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.paper-row-side { flex: 0 0 auto; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.paper-row-date { color: var(--muted); font-size: 11.5px; white-space: nowrap; }

.topic-list { display: grid; }
.topic-row {
  display: grid; grid-template-columns: 10px 1fr auto; gap: 9px; align-items: center;
  padding: 10px 9px; color: var(--text); text-decoration: none;
  border-bottom: 1px dashed var(--line); font-size: 13.5px;
  border-radius: 8px; transition: background .15s ease;
}
.topic-row:last-child { border-bottom: 0; }
.topic-row:hover { color: var(--accent); background: var(--surface-2); text-decoration: none; }
.topic-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.topic-count { color: var(--muted); font-size: 12px; background: var(--surface-2); border-radius: 999px; padding: 1px 8px; }

.mini-list { display: grid; }
.mini-row { padding: 10px 9px; border-bottom: 1px dashed var(--line); color: var(--text); text-decoration: none; display: grid; gap: 3px; border-radius: 8px; transition: background .15s ease; }
.mini-row:last-child { border-bottom: 0; }
.mini-row:hover { color: var(--accent); background: var(--surface-2); text-decoration: none; }
.mini-title { font-size: 13px; line-height: 1.45; }
.mini-meta { color: var(--muted); font-size: 11.5px; display: flex; align-items: center; gap: 6px; }
.mini-meta .score { font-size: 11px; min-width: 0; padding: 1px 6px; }

/* ---------- 筛选 ---------- */
.filter-bar {
  display: flex; flex-wrap: wrap; gap: 9px; align-items: center;
  padding: 14px; margin-bottom: 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
.filter-bar.simple { max-width: 760px; }
.filter-search { flex: 1 1 260px; min-width: 180px; }
.filter-bar input[type="search"], .filter-bar select {
  width: 100%; border: 1px solid var(--line); background: var(--surface-2);
  border-radius: 9px; padding: 8px 10px; font-size: 13px; outline: none;
}
.filter-bar select { width: auto; max-width: 220px; }
.filter-bar input:focus, .filter-bar select:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent);
}
.check { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
.result-head { display: flex; justify-content: space-between; gap: 12px; margin: 0 4px 10px; color: var(--muted); font-size: 12.5px; flex-wrap: wrap; }
.result-head strong { color: var(--text); }
.pagination { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 22px; color: var(--muted); font-size: 13px; }

/* ---------- 详情 ---------- */
.breadcrumb { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 12.5px; margin-bottom: 14px; flex-wrap: wrap; }
.breadcrumb .current { color: var(--muted); }
.detail-head { display: flex; justify-content: space-between; gap: 24px; align-items: flex-start; margin-bottom: 24px; }
.detail-title { min-width: 0; }
.detail-badges { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.detail-head h1 { font-size: clamp(23px, 2.6vw, 34px); letter-spacing: -.03em; max-width: 34ch; }
.detail-meta { color: var(--muted); font-size: 13px; margin-top: 10px; display: flex; gap: 7px; flex-wrap: wrap; }
.detail-topics { margin-top: 10px; }
.detail-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; flex: 0 0 auto; max-width: 420px; }

.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 22px; align-items: start; }
.detail-main { min-width: 0; }
.detail-side { display: grid; gap: 14px; position: sticky; top: 76px; }
/* PDF 阅读、笔记编辑时隐藏右侧元数据栏，主内容独占整行 */
.detail-grid.pdf-wide,
.detail-grid.notes-wide { grid-template-columns: minmax(0, 1fr); }
.detail-grid.pdf-wide .detail-side,
.detail-grid.notes-wide .detail-side { display: none; }
.detail-side .panel h3 { margin-bottom: 10px; }
.score-panel { display: flex; align-items: center; gap: 14px; }
.big-score { font-size: 36px; font-weight: 850; letter-spacing: -.04em; line-height: 1; }
.big-score small { font-size: 12px; font-weight: 600; color: var(--muted); }
.big-score.great { color: var(--green); }
.big-score.good { color: var(--accent); }
.big-score.mid { color: var(--amber); }
.big-score.low { color: var(--muted); }
.side-block { margin-bottom: 12px; }
.side-block:last-child { margin-bottom: 0; }
.side-label { display: block; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; margin-bottom: 4px; }
.side-block p { font-size: 13px; line-height: 1.7; }
.side-block summary { cursor: pointer; color: var(--muted); font-size: 12.5px; }
.side-subhead { margin: 14px 0 0; font-size: 12px; color: var(--muted); }
.meta-list { display: grid; grid-template-columns: 76px 1fr; gap: 6px 10px; margin: 0; font-size: 12.5px; }
.meta-list dt { color: var(--muted); }
.meta-list dd { margin: 0; min-width: 0; word-break: break-word; }
.status-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 7px; font-size: 13px; }
.status-list li { display: flex; justify-content: space-between; gap: 10px; }
.status-list span { color: var(--muted); }

/* ---------- Tabs / Markdown ---------- */
.tabs {
  display: flex; gap: 2px; border-bottom: 1px solid var(--line);
  margin-bottom: 18px; overflow-x: auto; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  border: 0; background: transparent; color: var(--muted);
  padding: 12px 18px; font-size: 14px; font-weight: 600;
  border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
  border-radius: 9px 9px 0 0; transition: color .15s ease, background .15s ease;
}
.tab:hover { color: var(--text); background: var(--surface-2); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-count { background: var(--surface-2); color: var(--muted); font-size: 11px; border-radius: 999px; padding: 0 7px; margin-left: 3px; }
.tab-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--green); margin-left: 5px; vertical-align: middle; }
.tab-panel { animation: fadeIn .18s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }

/* ---------- 引用关系（被引 / 参考文献） ---------- */
.citation-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-bottom: 12px;
}
.citation-list {
  display: grid; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden;
}
.citation-item {
  display: flex; gap: 14px; align-items: flex-start;
  padding: 15px 18px; border-bottom: 1px solid var(--line);
}
.citation-item:last-child { border-bottom: 0; }
.citation-main { flex: 1 1 auto; min-width: 0; }
.citation-title {
  font-weight: 650; font-size: 14.5px; color: var(--text);
  letter-spacing: -.01em; word-break: break-word;
}
.citation-title:hover { color: var(--accent); }
.citation-meta {
  color: var(--muted); font-size: 12.5px; margin-top: 4px;
  display: flex; gap: 6px; flex-wrap: wrap;
}
.citation-side {
  flex: 0 0 auto; display: flex; align-items: center; gap: 8px;
}
.citation-badge {
  font-size: 11px; font-weight: 700; padding: 2px 8px;
  border-radius: 999px; white-space: nowrap;
}
.citation-badge.library { color: var(--green); background: var(--green-soft); }
.citation-badge.search { color: var(--amber); background: var(--amber-soft); }
.citation-ext { font-size: 12px; white-space: nowrap; }
.citation-list .empty { border: 0; }

/* ---------- 专利同族/相关 ---------- */
.patent-rel-group { margin-bottom: 18px; }
.patent-rel-group:last-child { margin-bottom: 0; }
.patent-rel-group h3 {
  font-size: 15px; margin: 0 0 8px;
  display: flex; align-items: center; gap: 8px;
}
.patent-rel-count {
  background: var(--surface-2); color: var(--muted); font-size: 11px;
  border-radius: 999px; padding: 0 7px;
}

.markdown-body { font-size: 15px; line-height: 1.82; word-break: break-word; }
.markdown-body > :first-child { margin-top: 0; }
.markdown-body h1 { font-size: 25px; margin: 26px 0 12px; }
.markdown-body h2 {
  font-size: 20px; margin: 30px 0 12px; padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
}
.markdown-body h3 { font-size: 16.5px; margin: 24px 0 10px; }
.markdown-body h4 { font-size: 15px; margin: 18px 0 8px; }
.markdown-body p { margin: 10px 0; }
.markdown-body ul, .markdown-body ol { padding-left: 22px; margin: 10px 0; }
.markdown-body li { margin: 4px 0; }
.markdown-body li > p { margin: 4px 0; }
.markdown-body blockquote {
  margin: 14px 0; padding: 9px 16px; color: var(--muted);
  border-left: 3px solid var(--accent); background: var(--surface-2);
  border-radius: 0 8px 8px 0;
}
.markdown-body code {
  background: var(--surface-2); border: 1px solid var(--line);
  padding: 1px 5px; border-radius: 5px; font-size: .88em;
}
.markdown-body pre {
  background: #0f172a; color: #e2e8f0; padding: 15px 17px;
  border-radius: 11px; overflow: auto; margin: 14px 0; font-size: 12.8px;
}
.markdown-body pre code { background: none; border: 0; padding: 0; color: inherit; }
.markdown-body table {
  border-collapse: collapse; width: 100%; margin: 14px 0;
  font-size: 13.5px; display: block; overflow-x: auto;
}
.markdown-body th, .markdown-body td { border: 1px solid var(--line); padding: 7px 10px; text-align: left; vertical-align: top; }
.markdown-body th { background: var(--surface-2); font-weight: 650; }
.markdown-body tr:nth-child(even) td { background: color-mix(in srgb, var(--surface-2) 45%, transparent); }
.markdown-body hr { border: 0; border-top: 1px solid var(--line); margin: 24px 0; }
.markdown-body img { max-width: 100%; }
/* LaTeX：独立公式居中并允许横向滚动，避免宽公式撑破版面。 */
.markdown-body .math-display {
  display: block; margin: 16px 0; text-align: center;
  overflow-x: auto; overflow-y: hidden;
}
/* 行内公式跟随正文流。默认不建立横向滚动容器：KaTeX 的盒宽常有不到 1px 的
 * 取整差，一旦写上 overflow-x:auto，几乎每个行内公式下面都会多出一条横条。
 * 只有真正超出行宽时，math.js 才会加上 math-inline-scroll 开启滚动。 */
.markdown-body .math-inline {
  display: inline-block; max-width: 100%; vertical-align: bottom;
  overflow-x: visible; white-space: nowrap;
}
.markdown-body .math-inline.math-inline-scroll {
  overflow-x: auto; overflow-y: hidden;
}
.katex-display { margin: 0.6em 0; }
.katex { font-size: 1.05em; }
/* Toast UI 实时预览里的公式同样居中显示。 */
.toastui-editor-contents .katex-display { overflow-x: auto; overflow-y: hidden; }
.summary-toolbar { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 14px; font-size: 12px; align-items: center; }
.summary-toolbar-actions { display: inline-flex; align-items: center; gap: 10px; }
.summary-tags {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  margin-bottom: 14px; padding: 10px 12px;
  background: var(--surface); border: 1px dashed var(--line); border-radius: 10px;
}
.summary-tags-label { color: var(--muted); font-size: 11.5px; font-weight: 700; margin-right: 2px; }
.summary-body { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 38px 48px; box-shadow: var(--shadow-sm); }

/* 原始摘要：默认折叠，展开后保留原始换行 */
.abstract-fold {
  margin-bottom: 16px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); overflow: hidden;
}
.abstract-fold > summary {
  list-style: none; cursor: pointer; padding: 12px 16px;
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 650; color: var(--text);
}
.abstract-fold > summary::-webkit-details-marker { display: none; }
.abstract-fold > summary::before {
  content: "▸"; color: var(--muted); font-size: 12px;
  transition: transform .15s ease;
}
.abstract-fold[open] > summary::before { transform: rotate(90deg); }
.abstract-fold > summary:hover { background: var(--surface-2); }
.abstract-fold-title { margin-right: 2px; }
.abstract-text {
  padding: 0 18px 16px; color: var(--muted);
  font-size: 13.5px; line-height: 1.75;
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.abstract-missing { padding: 0 18px 14px; margin: 0; }

/* ---------- 空状态 / 状态 ---------- */
.empty { padding: 30px 18px; text-align: center; color: var(--muted); font-size: 13.5px; }
.empty.small { padding: 12px 8px; font-size: 12.5px; }
.empty-state { padding: 44px 24px; text-align: center; background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); }
.empty-state.standalone { max-width: 680px; margin: 40px auto; }
.empty-state h1, .empty-state h3 { margin-bottom: 8px; }
.empty-state p { color: var(--muted); margin: 4px 0; }
.empty-state .btn { margin-top: 16px; }
.empty-state .job-log-wrap { margin-top: 18px; text-align: left; }
.job-status { font-size: 12px; font-weight: 700; color: var(--accent); margin-bottom: 6px; }
.job-log {
  max-height: 240px; overflow: auto; background: #0f172a; color: #cbd5e1;
  border-radius: 10px; padding: 12px; font-family: var(--mono); font-size: 11.5px;
  white-space: pre-wrap; word-break: break-word;
}
.spinner {
  width: 30px; height: 30px; margin: 0 auto 14px;
  border: 3px solid var(--surface-3); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.flash-stack { max-width: 1440px; margin: 14px auto 0; padding: 0 24px; display: grid; gap: 8px; }
.flash { padding: 10px 14px; border-radius: 10px; font-size: 13px; border: 1px solid var(--line); background: var(--surface); }
.flash.ok { background: var(--green-soft); color: var(--green); border-color: transparent; }
.flash.error { background: var(--red-soft); color: var(--red); border-color: transparent; }

/* ---------- 主题页 ---------- */
.topic-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.topic-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px 20px 15px; box-shadow: var(--shadow-sm);
  border-top: 3px solid var(--topic-color, var(--accent));
  display: flex; flex-direction: column; gap: 10px;
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}
.topic-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
  border-color: color-mix(in srgb, var(--topic-color, var(--accent)) 45%, var(--line));
}
.topic-card header { display: flex; align-items: center; gap: 9px; }
.topic-card h2 { font-size: 17px; flex: 1 1 auto; }
.topic-card h2 a { color: var(--text); }
.topic-total { background: var(--surface-2); color: var(--muted); border-radius: 999px; font-size: 12px; padding: 1px 9px; }
.topic-children { display: flex; flex-wrap: wrap; gap: 6px; }
.topic-children .chip { font-size: 11px; }
.topic-papers { display: grid; gap: 7px; flex: 1 1 auto; }
.topic-paper { display: grid; gap: 2px; padding: 8px 8px; border-bottom: 1px dashed var(--line); color: var(--text); text-decoration: none; font-size: 12.8px; border-radius: 8px; transition: background .15s ease; }
.topic-paper:last-child { border-bottom: 0; }
.topic-paper small { color: var(--muted); font-size: 11.5px; }
.topic-paper:hover { color: var(--accent); background: var(--surface-2); text-decoration: none; }

/* ---------- 笔记 ---------- */
.note-composer {
  position: relative; padding: 22px 26px 24px; margin-bottom: 22px;
  background:
    radial-gradient(130% 150% at 100% 0%,
      color-mix(in srgb, var(--accent) 8%, transparent), transparent 58%),
    var(--surface);
}
/* 顶部渐变色条；不完全铺满，避开圆角 */
.note-composer::before {
  content: ""; position: absolute; top: 0; left: 0; width: 46%; height: 3px;
  border-radius: var(--radius) 3px 3px 0;
  background: linear-gradient(90deg, var(--accent), var(--violet));
}
.note-composer-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; margin-bottom: 16px;
}
.note-composer h3 { margin-bottom: 0; font-size: 17px; letter-spacing: -.02em; }
.note-kicker {
  color: var(--accent); font-size: 11px; font-weight: 700;
  letter-spacing: .14em; text-transform: uppercase; margin-bottom: 5px;
}
.note-composer-tip {
  flex: none; margin-top: 2px; padding: 4px 11px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface-2); color: var(--muted);
  font-size: 11.5px; white-space: nowrap;
}
.note-composer form { display: grid; gap: 12px; }
.note-title-input,
.note-composer textarea {
  width: 100%; border: 1px solid var(--line); background: var(--surface);
  border-radius: 11px; padding: 11px 13px; outline: none; font-size: 13.5px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.note-title-input {
  font-size: 15px; font-weight: 650; letter-spacing: -.01em;
}
.note-title-input::placeholder { font-weight: 500; color: var(--muted); }
.note-composer textarea { resize: vertical; min-height: 130px; line-height: 1.7; }
.note-title-input:focus,
.note-composer textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent);
}
.note-composer .form-actions { justify-content: flex-end; padding-top: 2px; }
.form-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.md-preview { background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }

.note-section-head {
  display: flex; align-items: baseline; gap: 10px; margin: 4px 2px 12px;
}
.note-section-head h3 { font-size: 15px; letter-spacing: -.01em; }
.note-section-head span { color: var(--muted); font-size: 12px; }

.note-list { display: grid; gap: 14px; }
.note-list.wide { max-width: 1040px; }
.note-card {
  position: relative;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px 24px 18px 27px; box-shadow: var(--shadow-sm);
  transition: box-shadow .16s ease, border-color .16s ease;
}
/* 左侧作者色条：颜色跟随笔记作者头像 */
.note-card::before {
  content: ""; position: absolute; left: 0; top: 17px; bottom: 17px; width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--note-accent, var(--accent)); opacity: .5;
  transition: opacity .16s ease;
}
.note-card:hover {
  border-color: color-mix(in srgb, var(--accent) 35%, var(--line));
  box-shadow: var(--shadow);
}
.note-card:hover::before { opacity: .9; }
.note-card header {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 14px; margin-bottom: 12px;
}
.note-card header strong { font-size: 15px; letter-spacing: -.01em; }
.note-card header time {
  color: var(--muted); font-size: 11.5px; white-space: nowrap;
  padding: 2px 9px; border-radius: 999px; background: var(--surface-2);
}
.note-paper-link {
  display: block; color: var(--muted); font-size: 12px; margin-top: 6px;
  transition: color .15s ease;
}
.note-paper-link:hover { color: var(--accent); }
.note-card footer {
  display: flex; justify-content: flex-end; gap: 6px; align-items: center;
  margin-top: 16px; padding-top: 10px; border-top: 1px dashed var(--line);
}
.note-card footer form { display: inline; }
.note-card footer .text-link,
.note-card footer .link { padding: 5px 10px; border-radius: 7px; }
.note-card footer .text-link:hover,
.note-card footer .link:hover { background: var(--surface-2); text-decoration: none; }

/* ---------- 专利全文 ---------- */
.patent-toolbar { margin-bottom: 10px; font-size: 12px; }
.patent-text {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 32px 40px; max-height: 78vh; overflow: auto;
  white-space: pre-wrap; word-break: break-word;
  font-family: var(--font); font-size: 14px; line-height: 1.85;
}

/* ---------- PDF 阅读器 ---------- */
/* 侧边栏宽度由 --pdf-side-w 控制（拖动分隔条时由 JS 更新） */
.pdf-layout {
  display: grid; align-items: start; gap: 16px;
  grid-template-columns: min(var(--pdf-side-w, 300px), 50vw) minmax(0, 1fr);
}
.pdf-layout.sidebar-off { grid-template-columns: minmax(0, 1fr); }
.pdf-layout.sidebar-off .pdf-sidebar { display: none; }
/* 隐藏标注时连同 PDF 内的高亮一起收起 */
.pdf-layout.annotations-off .pdf-highlights { display: none; }
/* 全屏阅读：PDF 与侧边栏撑满整个屏幕 */
.pdf-layout:fullscreen,
.pdf-layout:-webkit-full-screen {
  width: 100vw; height: 100vh; max-height: none;
  padding: 0; gap: 0; align-items: stretch;
  grid-template-rows: minmax(0, 1fr);
  background: var(--pdf-bg);
}
.pdf-layout:fullscreen .pdf-main,
.pdf-layout:-webkit-full-screen .pdf-main {
  display: flex; flex-direction: column;
  height: 100%; border: 0; border-radius: 0; box-shadow: none;
}
.pdf-layout:fullscreen .pdf-toolbar,
.pdf-layout:-webkit-full-screen .pdf-toolbar { flex: 0 0 auto; }
.pdf-layout:fullscreen .pdf-viewer,
.pdf-layout:-webkit-full-screen .pdf-viewer {
  flex: 1 1 auto; height: auto; min-height: 0; max-height: none;
}
.pdf-layout:fullscreen .pdf-sidebar,
.pdf-layout:-webkit-full-screen .pdf-sidebar {
  height: 100vh; max-height: none; border: 0; border-radius: 0; box-shadow: none;
}
.pdf-layout:fullscreen .pdf-sidebar-rail,
.pdf-layout:-webkit-full-screen .pdf-sidebar-rail,
.pdf-layout:fullscreen .pdf-sidebar-panels,
.pdf-layout:-webkit-full-screen .pdf-sidebar-panels { border-radius: 0; }
.pdf-main { min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); }
.pdf-toolbar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 11px 14px; border-bottom: 1px solid var(--line); background: var(--surface);
}
.pdf-nav, .pdf-zoom { display: flex; align-items: center; gap: 7px; }
.pdf-nav input {
  width: 58px; text-align: center; border: 1px solid var(--line);
  background: var(--surface-2); border-radius: 8px; padding: 6px 5px; font-size: 13px;
}
#zoomLabel { color: var(--muted); font-size: 12px; min-width: 46px; text-align: center; }
/* 导出时按钮文字会变成“生成中 3/20”，固定最小宽度避免工具栏抖动 */
#downloadPdf { min-width: 96px; }
#downloadPdf:disabled { opacity: .6; cursor: progress; }
.pdf-hint { margin-left: auto; color: var(--muted); font-size: 11.5px; }
.pdf-toolbar .btn.active { color: var(--accent); border-color: var(--accent); background: var(--surface-2); }

/* ---------- Foxit 风格左侧边栏 ---------- */
.pdf-sidebar {
  position: relative; display: flex; align-items: stretch; min-width: 0;
  height: calc(100vh - 72px); max-height: calc(100vh - 72px);
  background: var(--surface); border: 1px solid var(--line);
  /* overflow 必须可见：拖动分隔条位于右侧间隙里，不能被裁剪 */
  border-radius: var(--radius); overflow: visible; box-shadow: var(--shadow-sm);
}
/* 竖向图标栏 */
.pdf-sidebar-rail {
  flex: 0 0 44px; display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 8px 0; border-right: 1px solid var(--line); background: var(--surface-2);
  border-radius: var(--radius) 0 0 var(--radius);
}
.rail-btn {
  position: relative; width: 32px; height: 32px; border-radius: 8px;
  border: 1px solid transparent; background: transparent; color: var(--muted);
  display: grid; place-items: center; transition: color .12s ease, background .12s ease;
}
.rail-btn:hover { color: var(--text); background: var(--surface); }
.rail-btn[aria-selected="true"] {
  color: var(--accent); background: var(--surface); border-color: var(--line);
}
.rail-btn:disabled { opacity: .35; cursor: default; }
.rail-btn svg { width: 17px; height: 17px; }
.rail-badge {
  position: absolute; top: -4px; right: -4px; min-width: 15px; height: 15px;
  padding: 0 4px; border-radius: 999px; background: var(--accent); color: #fff;
  font-size: 9.5px; font-weight: 600; line-height: 15px; text-align: center;
}
/* 面板容器：每个标签一个 section，内部各自滚动 */
.pdf-sidebar-panels {
  flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column;
  overflow: hidden; border-radius: 0 var(--radius) var(--radius) 0;
}
.pdf-side-panel { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.pdf-side-panel[hidden] { display: none; }
.pdf-side-head {
  flex: 0 0 auto; display: flex; justify-content: space-between; align-items: baseline;
  padding: 12px 14px 10px; border-bottom: 1px solid var(--line);
}
.pdf-side-head h3 { font-size: 13.5px; }
.pdf-outline-list { flex: 1 1 auto; min-height: 0; overflow: auto; padding: 8px 8px 14px; }
.pdf-sidebar .annotation-tip { margin: 10px 12px 0; }
.pdf-sidebar .annotation-list {
  flex: 1 1 auto; min-height: 0; overflow: auto; padding: 10px 12px 14px;
}
/* 拖动分隔条：放在侧边栏右侧的间隙里，不压住面板滚动条 */
.pdf-sidebar-resizer {
  position: absolute; top: 0; right: -10px; bottom: 0; width: 16px;
  cursor: col-resize; z-index: 5; touch-action: none;
}
.pdf-sidebar-resizer::after {
  content: ""; position: absolute; top: 0; bottom: 0; right: 9px;
  width: 2px; background: transparent; transition: background .12s ease;
}
.pdf-sidebar-resizer:hover::after,
body.pdf-resizing .pdf-sidebar-resizer::after { background: var(--accent); }
body.pdf-resizing, body.pdf-resizing * { cursor: col-resize !important; user-select: none !important; }
.pdf-outline-group { display: block; }
.pdf-outline-row {
  display: flex; align-items: baseline; gap: 6px; width: 100%;
  padding: 5px 8px 5px calc(8px + var(--depth, 0) * 14px);
  border: 0; background: transparent; color: var(--text);
  font-size: 12.5px; line-height: 1.45; text-align: left; cursor: pointer;
  border-radius: 7px;
}
.pdf-outline-row:hover { background: var(--surface-2); }
.pdf-outline-row.active { background: var(--surface-2); color: var(--accent); font-weight: 600; }
.pdf-outline-caret {
  flex: 0 0 auto; width: 13px; color: var(--muted); font-size: 11px;
  transition: transform .15s ease; transform: rotate(90deg);
}
.pdf-outline-group.collapsed > .pdf-outline-row .pdf-outline-caret { transform: rotate(0deg); }
.pdf-outline-group.collapsed > .pdf-outline-children { display: none; }
.pdf-outline-title { flex: 1 1 auto; min-width: 0; word-break: break-word; }
.pdf-outline-page { flex: 0 0 auto; color: var(--muted); font-size: 11px; }
.pdf-outline-empty { padding: 12px 14px; }
.pdf-viewer {
  /* 阅读区高度略小于浏览器高度，避免底边贴住窗口 */
  position: relative; min-height: 60vh;
  height: calc(100vh - 72px); max-height: calc(100vh - 72px);
  overflow: auto;
  background: var(--pdf-bg); padding: 30px 42px 46px; scroll-padding: 16px;
}
.pdf-pages { display: grid; gap: 26px; justify-items: center; }
.pdf-page {
  position: relative; background: #fff; box-shadow: 0 3px 16px rgba(0,0,0,.38);
  flex: 0 0 auto; overflow: hidden; border-radius: 2px;
  transition: box-shadow .2s ease;
}
.pdf-page:hover { box-shadow: 0 5px 24px rgba(0,0,0,.46); }
.pdf-page canvas { position: absolute; inset: 0; display: block; }
.pdf-page-placeholder {
  position: absolute; inset: 0; display: grid; place-items: center;
  background: #fff; color: #94a3b8; font-size: 12px; user-select: none;
}
.pdf-highlights { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
.pdf-highlight {
  position: absolute; border-radius: 2px; mix-blend-mode: multiply;
  transition: filter .12s ease, outline-color .12s ease;
}
.pdf-highlight.yellow { background: rgba(250, 204, 21, .42); }
.pdf-highlight.green { background: rgba(34, 197, 94, .36); }
.pdf-highlight.blue { background: rgba(59, 130, 246, .32); }
.pdf-highlight.pink { background: rgba(236, 72, 153, .32); }
.pdf-highlight.hover {
  filter: saturate(1.45) brightness(.94);
  outline: 2px solid rgba(37, 99, 235, .72);
  outline-offset: 1px;
}
#pdfViewer .pdf-page.hover-annotation .textLayer span { cursor: pointer; }
.pdf-highlight.flash { animation: highlightFlash 1.1s ease; }
@keyframes highlightFlash { 0%, 100% { outline: 0 solid transparent; } 35% { outline: 3px solid rgba(37,99,235,.85); } }
.pdf-page .textLayer { z-index: 3; }
.pdf-loading {
  position: absolute; inset: 0; z-index: 20; display: grid; place-content: center;
  text-align: center; background: color-mix(in srgb, var(--surface) 94%, transparent);
  color: var(--muted); font-size: 13px;
}
.pdf-loading[hidden] { display: none; }
.pdf-error {
  position: absolute; inset: 0; z-index: 21; display: grid; place-content: center;
  text-align: center; padding: 30px; background: var(--surface);
}
.pdf-error[hidden] { display: none; }
.pdf-error h3 { margin-bottom: 8px; }
.error-actions { display: flex; gap: 8px; justify-content: center; margin-top: 16px; flex-wrap: wrap; }
.upload-label { cursor: pointer; }
.pdf-upload-hint { margin-top: 10px; }

.annotation-tip {
  color: var(--muted); font-size: 11.5px; line-height: 1.6;
  background: var(--surface-2); border-radius: 8px; padding: 8px 10px; margin-bottom: 12px;
}
.annotation-list { display: grid; gap: 9px; }
.annotation-item {
  display: flex; gap: 9px; padding: 12px 13px; border-radius: 10px;
  background: var(--surface-2); cursor: pointer; border: 1px solid transparent;
  transition: border-color .15s ease, background .15s ease, transform .15s ease;
}
.annotation-item:hover { border-color: var(--accent); background: var(--surface); transform: translateY(-1px); }
.annotation-color { width: 4px; border-radius: 4px; flex: 0 0 auto; background: #facc15; }
.annotation-color.green { background: #22c55e; }
.annotation-color.blue { background: #3b82f6; }
.annotation-color.pink { background: #ec4899; }
.annotation-body { min-width: 0; }
.annotation-page { color: var(--muted); font-size: 10.5px; margin-bottom: 2px; }
.annotation-text { font-size: 12px; line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.annotation-comment { color: var(--muted); font-size: 11.5px; margin-top: 4px; font-style: italic; }

/* 划选后浮出的颜色工具条 / 标注编辑框 */
.selection-toolbar, .annotation-editor {
  position: fixed; z-index: 1000; background: var(--surface);
  border: 1px solid var(--line); border-radius: 11px; box-shadow: var(--shadow);
}
.selection-toolbar { display: flex; align-items: center; gap: 9px; padding: 9px 12px; }
.selection-toolbar .swatch {
  width: 28px; height: 28px; border-radius: 50%; border: 2px solid rgba(255,255,255,.7);
  box-shadow: 0 0 0 1px var(--line); padding: 0; transition: transform .12s ease;
}
.selection-toolbar .swatch:hover { transform: scale(1.12); }
.selection-toolbar .swatch.yellow { background: #facc15; }
.selection-toolbar .swatch.green { background: #22c55e; }
.selection-toolbar .swatch.blue { background: #3b82f6; }
.selection-toolbar .swatch.pink { background: #ec4899; }
.selection-toolbar .toolbar-cancel { border: 0; background: none; color: var(--muted); font-size: 12px; }
.selection-toolbar .toolbar-translate {
  border: 1px solid var(--accent); border-radius: 7px; background: var(--accent-soft);
  color: var(--accent-strong); font-size: 12.5px; font-weight: 600;
  line-height: 1.2; padding: 5px 11px;
}
.selection-toolbar .toolbar-translate:hover { background: var(--accent); color: #fff; }

/* 划词翻译：选区气泡 + 流式译文浮层 */
.translate-bubble {
  position: fixed; z-index: 1101; display: inline-flex; align-items: center;
  justify-content: center; min-width: 30px; height: 28px; padding: 0 9px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); color: var(--text);
  box-shadow: var(--shadow-sm); font-size: 12.5px; font-weight: 600;
  line-height: 1;
}
.translate-bubble:hover { border-color: var(--accent); color: var(--accent); }
.translate-card {
  position: fixed; z-index: 1200; display: flex; flex-direction: column;
  width: min(400px, calc(100vw - 20px)); max-height: calc(100vh - 20px);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; box-shadow: var(--shadow); overflow: hidden;
}
.translate-card > header {
  display: flex; align-items: center; gap: 6px; padding: 3px 6px 3px 10px;
  border-bottom: 1px solid var(--line); background: var(--surface-2);
  cursor: grab; user-select: none; touch-action: none;
}
.translate-card > header.dragging { cursor: grabbing; }
.translate-card > header h4 {
  margin: 0; color: var(--muted); font-size: 11.5px; font-weight: 600;
  letter-spacing: .02em;
}
.translate-card .translate-target {
  overflow: hidden; color: var(--muted); font-size: 11px; opacity: .85;
  text-overflow: ellipsis; white-space: nowrap;
}
.translate-card .translate-actions {
  display: flex; align-items: center; gap: 3px; margin-left: auto;
}
.translate-card .translate-actions .icon-btn {
  width: 22px; height: 22px; min-height: 22px; padding: 0;
  border: 0; border-radius: 5px; background: none; font-size: 14px; line-height: 1;
}
.translate-copy {
  border: 1px solid var(--line); border-radius: 5px; background: transparent;
  color: var(--muted); font-size: 11px; line-height: 1.4; padding: 1px 7px;
}
.translate-copy:hover:enabled { border-color: var(--accent); color: var(--accent); }
.translate-copy:disabled { cursor: not-allowed; opacity: .5; }
.translate-body {
  flex: 1 1 auto; min-height: 0; display: grid; gap: 8px;
  padding: 9px 11px; overflow: auto; overscroll-behavior: contain;
}
.translate-source {
  max-height: 64px; overflow: auto; padding: 6px 8px; border-radius: 6px;
  background: var(--surface-2); color: var(--muted); font-size: 11.5px;
  line-height: 1.5; white-space: pre-wrap; word-break: break-word;
  overscroll-behavior: contain;
}
.translate-result {
  font-size: 13.5px; line-height: 1.7; white-space: pre-wrap;
  word-break: break-word;
}
.translate-result.loading { color: var(--muted); }
.translate-result.translate-error,
.translate-foot.translate-error { color: var(--red); }
.translate-foot {
  padding: 0 11px 7px; color: var(--muted); font-size: 10.5px;
}
.translate-foot[hidden] { display: none; }
@media (max-width: 640px) {
  .translate-card { width: calc(100vw - 16px); }
  .translate-card > header { padding: 3px 6px 3px 8px; }
}

.annotation-editor { width: 330px; padding: 14px; display: grid; gap: 9px; }
.annotation-editor .quote {
  font-size: 11.5px; color: var(--muted); max-height: 68px; overflow: auto;
  background: var(--surface-2); border-radius: 7px; padding: 7px 9px; line-height: 1.5;
}
.annotation-editor textarea {
  width: 100%; min-height: 76px; resize: vertical; border: 1px solid var(--line);
  background: var(--surface-2); border-radius: 8px; padding: 8px 9px; font-size: 12.5px; outline: none;
}
.annotation-editor textarea:focus { border-color: var(--accent); }
.annotation-editor .editor-actions { display: flex; gap: 6px; align-items: center; }
.annotation-editor .editor-actions .spacer { flex: 1 1 auto; }
.annotation-editor select { border: 1px solid var(--line); background: var(--surface-2); border-radius: 7px; padding: 4px 6px; font-size: 12px; }
.annotation-editor .btn { padding: 5px 10px; font-size: 12px; }

/* ---------- 响应式 ---------- */
@media (max-width: 1120px) {
  .detail-grid { grid-template-columns: minmax(0, 1fr); }
  .detail-side { position: static; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .home-grid { grid-template-columns: minmax(0, 1fr) 310px; }
}
@media (max-width: 960px) {
  .hero { grid-template-columns: 1fr; padding: 30px; }
  .home-grid { grid-template-columns: 1fr; }
  .home-side { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pdf-layout { grid-template-columns: 1fr; position: relative; }
  .pdf-main { order: 1; }
  /* 窄屏侧边栏改为覆盖层，避免挤压 PDF 阅读宽度 */
  .pdf-sidebar {
    position: absolute; inset: 0 auto 0 0; z-index: 30;
    width: min(var(--pdf-side-w, 300px), 84%); height: auto; max-height: none;
    border-radius: 0 var(--radius) var(--radius) 0;
    box-shadow: 0 12px 32px rgba(0, 0, 0, .32);
  }
  .pdf-sidebar-rail,
  .pdf-sidebar-panels { border-radius: 0; }
  .topbar-inner { flex-wrap: wrap; gap: 10px 18px; }
  .top-search { flex: 1 1 100%; }
}
@media (max-width: 720px) {
  .page { padding: 24px 16px 64px; }
  .topbar-inner { padding: 10px 16px; }
  .nav { order: 3; flex-basis: 100%; }
  .detail-head { flex-direction: column; }
  .detail-actions { justify-content: flex-start; max-width: none; }
  .detail-side { grid-template-columns: 1fr; }
  .home-side { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .filter-bar select { max-width: none; flex: 1 1 45%; }
  .summary-body { padding: 24px 20px; }
  .note-card { padding: 17px 17px 15px 21px; }
  .note-card::before { top: 13px; bottom: 13px; }
  .note-card header { flex-direction: column; gap: 6px; }
  .note-card header time { align-self: flex-start; }
  .note-composer { padding: 19px 18px 20px; }
  .note-composer-head { flex-direction: column; gap: 7px; }
  .note-composer-tip { display: none; }
  .note-composer .form-actions { justify-content: stretch; }
  .note-composer .form-actions .btn { flex: 1 1 auto; }
  .paper-row { padding: 18px 20px; gap: 12px; }
  .paper-row-side { flex-direction: row; align-items: center; }
  .paper-row-date { display: none; }
  .citation-item { flex-wrap: wrap; }
  .citation-side { width: 100%; justify-content: flex-end; }
  .pdf-hint { display: none; }
  .pdf-viewer { padding: 16px 12px 26px; }
  .patent-text { padding: 22px 20px; }
}

/* pdf_viewer.css 在论文页后加载；这里用更高优先级覆盖文本层行为 */
#pdfViewer .pdf-page .textLayer {
  opacity: 1;
  z-index: 3;
}
#pdfViewer .pdf-page .textLayer ::selection {
  background: rgba(37, 99, 235, .38);
}
#pdfViewer .pdf-page .textLayer .endOfContent {
  z-index: -1;
}

/* ---------- 账户 / 登录 ---------- */
.user-menu {
  display: flex; align-items: center; gap: 8px; margin-left: 14px;
  padding-left: 14px; border-left: 1px solid var(--border, #e2e8f0);
  white-space: nowrap;
}
.user-name { font-size: 13px; font-weight: 600; color: var(--text, #0f172a); }
.logout-form { display: inline; }
.role-badge {
  font-size: 11px; padding: 2px 7px; border-radius: 999px;
  background: #eef2ff; color: #4338ca; font-weight: 600;
}
.role-badge.admin { background: #fee2e2; color: #b91c1c; }
.role-badge.write { background: #dcfce7; color: #15803d; }
.role-badge.read { background: #f1f5f9; color: #475569; }
.nav-badge {
  display: inline-block; min-width: 16px; margin-left: 4px; padding: 0 5px;
  border-radius: 999px; background: #dc2626; color: #fff;
  font-size: 10px; line-height: 16px; text-align: center;
}
.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 50%; flex: none;
  background: var(--avatar-color, #64748b); color: #fff;
  font-size: 13px; font-weight: 700;
}
.avatar.small { width: 22px; height: 22px; font-size: 11px; }
.avatar.tiny { width: 18px; height: 18px; font-size: 10px; margin-right: 4px; }

.login-wrap { display: flex; justify-content: center; padding: 48px 16px; }
.login-card { width: min(430px, 100%); padding: 28px; }
.login-brand { display: flex; gap: 14px; align-items: center; margin-bottom: 22px; }
.login-brand h1 { margin: 0; font-size: 24px; }
.login-brand p { margin: 2px 0 0; font-size: 13px; }
.login-form { display: grid; gap: 15px; }
.login-form label { display: grid; gap: 6px; font-size: 13px; font-weight: 600; }
.login-form input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border, #cbd5e1);
  border-radius: 8px; font-size: 14px; background: #fff;
}
.captcha-row { display: flex; gap: 10px; align-items: center; }
.captcha-row input { flex: 1; }
.captcha-row img {
  width: 150px; height: 47px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--border, #cbd5e1); background: #eff6ff;
}
.login-submit { width: 100%; padding: 11px; font-size: 15px; }
.login-hint { margin: 18px 0 0; font-size: 12px; line-height: 1.6; }

/* ---------- 管理后台 ---------- */
.admin-table-wrap { overflow-x: auto; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.admin-table th, .admin-table td {
  padding: 10px 12px; border-bottom: 1px solid var(--border, #e2e8f0);
  text-align: left; vertical-align: middle;
}
.admin-table th { color: var(--muted, #64748b); font-weight: 600; white-space: nowrap; }
.admin-table tr:last-child td { border-bottom: none; }
.admin-table .inline-form { display: inline-flex; align-items: center; gap: 8px; margin: 0; }
.btn.danger, .link.danger { color: #b91c1c; }

.tag-admin-form {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px;
  padding: 4px 0 18px;
}
.tag-admin-form label {
  display: grid; gap: 4px; color: var(--muted);
  font-size: 12px; font-weight: 650;
}
.tag-admin-form input, .tag-admin-form select,
.tag-admin-table input[type="text"], .tag-admin-table select {
  padding: 7px 9px; background: var(--surface-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px; font-size: 12.5px;
}
.tag-admin-form input[name="name"] { min-width: 170px; }
.tag-admin-form input[name="keywords"] { min-width: 300px; }
.tag-admin-table input[type="text"] { min-width: 128px; }
.tag-admin-table .tag-keywords-input { min-width: 230px; }
.tag-admin-table select { min-width: 150px; }
.admin-tag-actions { display: flex; align-items: center; gap: 6px; }

/* ---------- 笔记作者 / 批注线程 ---------- */
.note-title-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.note-author {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 9px 2px 3px; border-radius: 999px;
  background: var(--surface-2); font-size: 12px; color: var(--muted, #64748b);
}
.annotation-meta {
  display: flex; align-items: center; gap: 4px; margin-bottom: 3px;
  font-size: 12px; color: var(--muted, #64748b);
}
.annotation-meta strong { color: var(--text, #0f172a); font-weight: 600; }
.annotation-reply {
  display: flex; align-items: flex-start; gap: 5px; flex-wrap: wrap;
  margin: 6px 0 0 10px; padding: 6px 8px; border-left: 2px solid #c7d2fe;
  background: #f8fafc; border-radius: 0 6px 6px 0; font-size: 12px;
}
.annotation-reply-text { flex: 1; min-width: 120px; color: #334155; }
.annotation-item-actions { display: flex; gap: 12px; margin-top: 6px; }
.annotation-item-actions .link { font-size: 12px; }
.reply-form { margin-top: 8px; display: grid; gap: 6px; }
.reply-form textarea {
  width: 100%; min-height: 60px; padding: 8px; border-radius: 8px;
  border: 1px solid var(--border, #cbd5e1); font: inherit; font-size: 13px;
  resize: vertical;
}
.reply-form .editor-actions { display: flex; align-items: center; gap: 8px; }
.reply-form .editor-actions .spacer { flex: 1; }

@media (max-width: 900px) {
  .user-menu { margin-left: 6px; padding-left: 8px; gap: 6px; }
  .user-name { display: none; }
}
.inline-actions { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ---------- 手动发现 / 上传 ---------- */
.notice {
  padding: 10px 14px; margin-bottom: 14px; border-radius: 9px;
  background: color-mix(in srgb, #f59e0b 10%, var(--surface));
  border: 1px solid color-mix(in srgb, #f59e0b 35%, var(--line));
  color: var(--text); font-size: 13px;
}
.discover-modes { display: flex; gap: 8px; margin-bottom: 14px; }
.discover-results { display: grid; gap: 12px; margin-bottom: 18px; }
.discover-card {
  display: flex; gap: 18px; align-items: flex-start; justify-content: space-between;
  padding: 16px 18px;
}
.discover-card-main { min-width: 0; flex: 1; }
.discover-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.discover-card h3 { margin: 0 0 6px; font-size: 15px; line-height: 1.45; }
.discover-meta { margin: 0 0 6px; font-size: 12px; color: var(--muted); }
.discover-abstract { margin: 0 0 8px; font-size: 13px; color: var(--muted); line-height: 1.6; }
.discover-links { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; }
.discover-card-actions { flex: 0 0 auto; display: flex; align-items: center; }
.upload-panel { padding: 18px; margin-top: 18px; }
.upload-form {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px; margin-top: 12px;
}
.upload-form .field { display: grid; gap: 5px; font-size: 12px; color: var(--muted); }
.upload-form .field input {
  border: 1px solid var(--line); background: var(--surface-2);
  border-radius: 8px; padding: 8px 10px; font: inherit; font-size: 13px;
  color: var(--text); min-width: 0;
}
.upload-form button { align-self: end; justify-self: start; }

/* ---------- 收藏夹 ---------- */
.paper-row-wrap { position: relative; }
.paper-row-wrap .paper-row { padding-right: 64px; }
.row-star { position: absolute; right: 12px; top: 12px; margin: 0; z-index: 2; }
.star-btn {
  position: relative; border: 0; background: transparent; cursor: pointer;
  padding: 2px 6px; font-size: 19px; line-height: 1; color: var(--muted);
  border-radius: 6px;
}
.star-btn:hover { background: var(--surface-2); color: #ca8a04; }
.star-btn.on { color: #eab308; }
.star-glyph { font-size: 19px; line-height: 1; }
.star-count {
  position: absolute; top: -3px; right: -1px;
  min-width: 15px; height: 15px; padding: 0 3px;
  border-radius: 999px; background: var(--accent); color: #fff;
  font-size: 9px; font-weight: 800; line-height: 15px;
  display: grid; place-items: center;
}

/* 无 JS fallback / 详情页旧表单 */
.collect-menu { position: relative; }
.collect-menu > summary { list-style: none; cursor: pointer; display: inline-flex; }
.collect-menu > summary::-webkit-details-marker { display: none; }
.collect-form {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 20;
  width: min(300px, 82vw); padding: 12px; display: grid; gap: 7px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; box-shadow: 0 14px 36px rgba(15, 23, 42, .16);
}
.collect-option {
  display: flex; align-items: center; gap: 8px; font-size: 13px;
  padding: 4px 2px; cursor: pointer;
}
.collect-option input { accent-color: var(--accent); flex: 0 0 auto; }
.collect-option .collect-name {
  min-width: 0; flex: 1 1 auto; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}
.collect-option .topic-count { margin-left: auto; flex: 0 0 auto; }
.collect-option.is-default {
  background: color-mix(in srgb, var(--amber) 10%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--amber) 28%, var(--line));
  border-radius: 8px;
  padding: 7px 8px;
}
.collect-new {
  display: flex; gap: 6px; padding-top: 7px;
  border-top: 1px dashed var(--line);
}
.collect-new input {
  flex: 1; min-width: 0; border: 1px solid var(--line);
  background: var(--surface-2); border-radius: 7px; padding: 6px 8px;
  font: inherit; font-size: 12px; color: var(--text);
}

/* 星标选择器（全局弹层） */
.collect-popover {
  position: fixed; z-index: 120;
  width: min(330px, calc(100vw - 24px));
  max-height: min(70vh, 540px);
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; box-shadow: 0 20px 50px rgba(15, 23, 42, .22);
  overflow: hidden;
}
.collect-popover[aria-busy="true"] { opacity: .82; }
.collect-popover-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.collect-popover-head strong { font-size: 14px; }
.collect-close {
  border: 0; background: transparent; color: var(--muted);
  font-size: 18px; line-height: 1; padding: 4px 6px; border-radius: 6px;
}
.collect-close:hover { background: var(--surface-2); color: var(--text); }
.collect-popover-body {
  padding: 10px 12px 12px; overflow: auto;
  display: grid; gap: 8px;
}
.collect-list { display: grid; gap: 2px; }
.collect-list .collect-option { padding: 7px 8px; border-radius: 8px; }
.collect-list .collect-option:hover { background: var(--surface-2); }
.collect-loading { padding: 18px 8px; text-align: center; color: var(--muted); font-size: 13px; }
.collect-save-state { font-size: 11.5px; color: var(--muted); min-height: 17px; }
.collect-save-state.is-error, .collect-error { color: var(--red); }
.collect-error { font-size: 12px; }
.collect-error-actions { display: flex; gap: 6px; justify-content: center; margin-top: 8px; }

/* 收藏夹首页 */
.collection-create { margin-bottom: 18px; padding: 0; overflow: hidden; }
.collection-create-summary {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 18px; cursor: pointer; font-weight: 650;
  list-style: none;
}
.collection-create-summary::-webkit-details-marker { display: none; }
.collection-create-plus {
  width: 24px; height: 24px; border-radius: 8px; display: grid;
  place-items: center; background: var(--accent-soft); color: var(--accent);
  font-size: 17px; line-height: 1;
}
.collection-create-form {
  display: grid; gap: 10px; padding: 0 18px 18px;
  grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr) auto;
  align-items: end;
}
.collection-create-form .field { display: grid; gap: 5px; font-size: 12px; color: var(--muted); }
.collection-create-form input,
.collection-edit input,
.collection-edit textarea {
  width: 100%; border: 1px solid var(--line); background: var(--surface-2);
  border-radius: 8px; padding: 8px 10px; font: inherit; font-size: 13px;
  color: var(--text); resize: vertical;
}
.collection-grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
}
.collection-card {
  padding: 18px; display: flex; flex-direction: column; gap: 10px;
  border-top: 3px solid var(--collection-color, var(--accent));
  transition: transform .16s ease, box-shadow .16s ease;
}
.collection-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.collection-card.is-default {
  background:
    linear-gradient(180deg,
      color-mix(in srgb, var(--collection-color) 7%, transparent),
      transparent 42%),
    var(--surface);
}
.collection-card-head { display: flex; align-items: flex-start; gap: 11px; }
.collection-icon {
  width: 38px; height: 38px; flex: 0 0 auto;
  border-radius: 11px; display: grid; place-items: center;
  background: color-mix(in srgb, var(--collection-color) 14%, var(--surface));
  color: var(--collection-color); font-size: 17px; font-weight: 800;
  border: 1px solid color-mix(in srgb, var(--collection-color) 26%, var(--line));
}
.collection-title { min-width: 0; flex: 1 1 auto; }
.collection-title h2 {
  font-size: 17px; line-height: 1.35;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.collection-title h2 a { color: var(--text); }
.collection-title h2 a:hover { color: var(--accent); text-decoration: none; }
.collection-meta { margin: 0; font-size: 12px; color: var(--muted); }
.collection-title .collection-meta { margin-top: 3px; }
.default-badge { background: var(--amber-soft); color: var(--amber); }
.collection-desc {
  margin: 0; color: var(--muted); font-size: 13px; line-height: 1.6;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.collection-preview {
  display: grid; gap: 2px; flex: 1 1 auto;
  border-top: 1px dashed var(--line); padding-top: 8px;
}
.collection-preview-row {
  display: block; padding: 7px 8px; border-radius: 8px;
  color: var(--text); text-decoration: none; font-size: 12.8px;
}
.collection-preview-row:hover {
  background: var(--surface-2); color: var(--accent); text-decoration: none;
}
.collection-preview-title {
  display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical;
  overflow: hidden; line-height: 1.45;
}
.collection-preview-empty { color: var(--muted); font-size: 12.5px; padding: 5px 8px; }
.collection-card-foot {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; flex-wrap: wrap; border-top: 1px solid var(--line);
  padding-top: 10px; margin-top: auto;
}
.collection-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.collection-actions form { margin: 0; }

/* 收藏夹详情 */
.collection-detail-head h1 { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.collection-head-icon {
  width: 38px; height: 38px; border-radius: 11px; display: inline-grid;
  place-items: center; flex: 0 0 auto;
  background: color-mix(in srgb, var(--collection-color) 14%, var(--surface));
  color: var(--collection-color); font-size: 18px; font-weight: 800;
  border: 1px solid color-mix(in srgb, var(--collection-color) 26%, var(--line));
}
.collection-detail-head .lede { white-space: pre-line; }
.collection-detail-head .collection-meta { margin-top: 8px; }
.collection-detail-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.collection-edit { position: relative; }
.collection-edit > summary {
  list-style: none; cursor: pointer; display: inline-flex; align-items: center;
}
.collection-edit > summary::-webkit-details-marker { display: none; }
.collection-edit form {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 30;
  width: min(340px, 86vw); padding: 12px; display: grid; gap: 8px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; box-shadow: 0 14px 36px rgba(15, 23, 42, .18);
}
.collection-edit label { display: grid; gap: 4px; font-size: 12px; color: var(--muted); }
.collection-filter { margin-bottom: 14px; }

.batch-bar {
  position: sticky; top: 68px; z-index: 8;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 10px 12px; margin-bottom: 10px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.batch-check { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; cursor: pointer; }
.batch-count { font-size: 12.5px; color: var(--muted); font-weight: 650; }
.batch-spacer { flex: 1 1 auto; }
.batch-bar select {
  border: 1px solid var(--line); background: var(--surface-2);
  border-radius: 8px; padding: 7px 9px; font-size: 12.5px; max-width: 190px;
}
.batch-bar .btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }

.collection-paper-list { position: relative; }
.collection-item { position: relative; border-bottom: 1px solid var(--line); }
.collection-item:last-child { border-bottom: 0; }
.collection-item.is-selected { background: color-mix(in srgb, var(--accent) 5%, var(--surface)); }
.collection-select {
  position: absolute; left: 12px; top: 16px; z-index: 3;
  display: grid; place-items: center; cursor: pointer;
}
.collection-select input { width: 16px; height: 16px; accent-color: var(--accent); }
.collection-item .paper-row { border-bottom: 0; padding-left: 36px; }
.collection-item .paper-row-wrap:last-child .paper-row { border-bottom: 0; }
.collection-item-tools {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 0 18px 12px 48px; margin-top: -4px;
  color: var(--muted); font-size: 12px;
}
.collection-item-tools form { margin: 0; }
.collection-item-tools .text-link { font-size: 12px; }
.row-move { position: relative; }
.row-move > summary { list-style: none; cursor: pointer; }
.row-move > summary::-webkit-details-marker { display: none; }
/* fixed 定位由 collections.js 根据 summary 位置计算：
   .paper-list 自带 overflow:hidden，absolute 弹层会被裁掉。 */
.row-move-form {
  position: fixed; left: 0; top: 0; z-index: 110;
  visibility: hidden;
  display: flex; align-items: center; gap: 6px;
  padding: 9px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 14px 36px rgba(15, 23, 42, .16);
}
.row-move-form select {
  border: 1px solid var(--line); background: var(--surface-2);
  border-radius: 7px; padding: 6px 8px; font-size: 12px; max-width: 180px;
}
.paper-row-wrap:last-child .paper-row { border-bottom: 0; }

/* ---------- 笔记可视化编辑器 ---------- */
.js-only { display: none; }
.js .js-only { display: block; }
.js .note-legacy-preview { display: none !important; }

.note-editor-field { display: grid; gap: 8px; min-width: 0; }
.note-editor { min-width: 0; }
.note-editor-hint {
  margin: 0; color: var(--muted); font-size: 12px; line-height: 1.6;
}
.note-editor-status {
  margin: 0; padding: 7px 10px; border-radius: 8px;
  background: var(--green-soft); color: var(--green);
  font-size: 12px; word-break: break-word;
}
.note-editor-status.is-error {
  background: var(--red-soft); color: var(--red);
}
.note-editor-fallback-hidden { display: none !important; }

.note-editor .toastui-editor-defaultUI {
  border-color: var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.note-editor .toastui-editor-defaultUI:focus-within {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 12%, transparent);
}
.note-editor .toastui-editor-defaultUI-toolbar {
  background: var(--surface-2);
  border-bottom-color: var(--line);
  flex-wrap: wrap;
  height: auto;
  min-height: 46px;
  padding: 5px 7px;
}
.note-editor .toastui-editor-toolbar {
  height: auto;
  min-height: 46px;
}
.note-editor .toastui-editor-toolbar-group {
  margin: 2px 3px 2px 0;
}
.note-editor .toastui-editor-main,
.note-editor .toastui-editor-ww-container,
.note-editor .toastui-editor-md-container {
  background: var(--surface);
}
.note-editor .toastui-editor-contents {
  font-family: var(--font);
  font-size: 14.5px;
  line-height: 1.78;
  color: var(--text);
}
.note-editor .toastui-editor-contents h1,
.note-editor .toastui-editor-contents h2,
.note-editor .toastui-editor-contents h3,
.note-editor .toastui-editor-contents h4 { color: var(--text); }
.note-editor .toastui-editor-contents table {
  border-color: var(--line);
}
.note-editor .toastui-editor-contents th,
.note-editor .toastui-editor-contents td {
  border-color: var(--line);
}
.note-editor .toastui-editor-contents th {
  background: var(--surface-2);
}
.note-editor .toastui-editor-contents img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
}
.note-editor .toastui-editor-mode-switch {
  background: var(--surface-2);
  border-top-color: var(--line);
}
.note-editor .toastui-editor-popup {
  border-color: var(--line);
  z-index: 60;
}
@media (prefers-color-scheme: dark) {
  .note-editor .toastui-editor-popup,
  .note-editor .toastui-editor-dropdown-toolbar {
    background: var(--surface);
    border-color: var(--line);
    color: var(--text);
  }
  .note-editor .toastui-editor-popup-body label { color: var(--muted); }
  .note-editor .toastui-editor-popup-body input[type=text] {
    background: var(--surface-2);
    border-color: var(--line);
    color: var(--text);
  }
}
.mode-switch-inner .tab-item {
  color: var(--muted);
}
.mode-switch-inner .tab-item.active {
  color: var(--accent);
}

.markdown-body img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
}

@media (max-width: 720px) {
  .discover-card { flex-direction: column; }
  .discover-card-actions { width: 100%; }
  .upload-form { grid-template-columns: 1fr; }
  .collect-form { right: auto; left: 0; }
  .collect-popover {
    left: 12px !important; right: 12px; bottom: 12px;
    top: auto !important; width: auto; max-height: 72vh;
  }
  .collection-create-form { grid-template-columns: 1fr; }
  .collection-grid { grid-template-columns: 1fr; }
  .batch-bar { top: 60px; }
  .collection-item-tools { padding-left: 42px; padding-right: 12px; }
  .row-move-form {
    position: fixed; left: 12px; right: 12px; top: auto; bottom: 12px;
    visibility: visible;
  }
}

/* ---- 深度总结对话 ---- */
.chat-panel {
  margin-top: 36px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 14px;
}
.chat-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.chat-head h3 { margin: 0; font-size: 16px; }
.chat-head p { margin: 4px 0 0; }
.chat-messages { display: grid; gap: 14px; }
.chat-empty {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  color: var(--muted);
}
.chat-empty p { margin: 0 0 6px; }
.chat-empty p:last-child { margin-bottom: 0; }
.chat-msg { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.chat-msg.user { align-items: flex-end; }
.chat-msg + .chat-msg { margin-top: 2px; }
.chat-bubble {
  max-width: 94%;
  padding: 11px 15px;
  border-radius: 14px;
  line-height: 1.75;
  word-break: break-word;
}
.chat-msg.user .chat-bubble {
  background: var(--accent-soft);
  color: var(--text);
  white-space: pre-wrap;
  border-bottom-right-radius: 5px;
}
.chat-msg.assistant .chat-bubble {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-bottom-left-radius: 5px;
  font-size: 14.5px;
}
.chat-msg.assistant .chat-bubble > :first-child { margin-top: 0; }
.chat-msg.assistant .chat-bubble > :last-child { margin-bottom: 0; }
.chat-msg.error .chat-bubble {
  background: var(--red-soft);
  border-color: color-mix(in srgb, var(--red) 35%, var(--line));
  color: var(--text);
}
.chat-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--muted);
  padding: 0 4px;
}
.chat-ref-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chat-ref-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 100%;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--accent);
  font-size: 11.5px;
  text-decoration: none;
}
.chat-ref-chip:hover { border-color: var(--accent); }
.chat-ref-chip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 260px;
}
.chat-form {
  display: grid;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.chat-form:focus-within { border-color: var(--accent); }
.chat-form textarea {
  width: 100%;
  min-height: 52px;
  max-height: 240px;
  padding: 4px 2px;
  border: 0;
  outline: none;
  resize: vertical;
  background: transparent;
  color: var(--text);
  font: inherit;
  line-height: 1.6;
}
.chat-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.chat-actions .chat-hint { margin-left: auto; }
.chat-typing { color: var(--muted); }
.chat-typing::after {
  content: "…";
  display: inline-block;
  animation: chat-dots 1.2s steps(4, end) infinite;
}
@keyframes chat-dots {
  0% { content: ""; }
  25% { content: "·"; }
  50% { content: "··"; }
  75% { content: "···"; }
}
.chat-picker {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(15, 23, 42, .52);
}
.chat-picker-card {
  width: min(720px, 100%);
  max-height: min(82vh, 760px);
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.chat-picker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.chat-picker-head h4 { margin: 0; font-size: 15px; }
.chat-picker-search {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
}
.chat-picker-search:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 15%, transparent);
}
.chat-picker-results {
  flex: 1;
  min-height: 120px;
  overflow-y: auto;
  display: grid;
  gap: 4px;
  align-content: start;
}
.chat-picker-result {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  width: 100%;
  padding: 9px 10px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: none;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  font: inherit;
}
.chat-picker-result:hover { background: var(--surface-2); }
.chat-picker-result.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.chat-picker-result .pick-mark {
  flex: 0 0 20px;
  height: 20px;
  margin-top: 2px;
  border: 1px solid var(--line);
  border-radius: 6px;
  display: grid;
  place-items: center;
  font-size: 12px;
  color: var(--accent);
  background: var(--surface);
}
.chat-picker-result.selected .pick-mark {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}
.chat-picker-result .pick-body { min-width: 0; display: grid; gap: 3px; }
.chat-picker-result .pick-title {
  font-size: 13.5px;
  line-height: 1.45;
  word-break: break-word;
}
.chat-picker-result .pick-meta { font-size: 11.5px; color: var(--muted); }
.chat-picker-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 4px;
  border-top: 1px solid var(--line);
}
@media (max-width: 720px) {
  .chat-bubble { max-width: 100%; }
  .chat-actions .chat-hint { display: none; }
  .chat-picker { padding: 0; align-items: flex-end; }
  .chat-picker-card {
    width: 100%;
    max-height: 88vh;
    border-radius: 16px 16px 0 0;
  }
}
.chat-msg.assistant .chat-bubble.streaming,
.chat-msg.assistant .chat-bubble.plain {
  white-space: pre-wrap;
}

/* ---- 对话：思考过程 / 编辑 / 作者 ---- */
.chat-thinking {
  width: 100%;
  margin-bottom: 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: color-mix(in srgb, var(--surface-2) 72%, transparent);
  overflow: hidden;
}
.chat-thinking summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  color: var(--muted);
  font-size: 12.5px;
  cursor: pointer;
  list-style: none;
}
.chat-thinking summary::-webkit-details-marker { display: none; }
.chat-thinking summary::before {
  content: "▸";
  display: inline-block;
  transition: transform .15s ease;
}
.chat-thinking[open] summary::before { transform: rotate(90deg); }
.thinking-state { margin-left: auto; font-size: 11.5px; }
.thinking-body {
  max-height: 220px;
  overflow-y: auto;
  padding: 8px 12px 10px;
  border-top: 1px dashed var(--line);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
}
.chat-author { font-weight: 600; color: var(--text); }
.chat-edit {
  border: 0;
  background: none;
  color: var(--accent);
  font-size: 11.5px;
  padding: 0 4px;
  cursor: pointer;
}
.chat-edit:hover { text-decoration: underline; }
.chat-edit-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--line));
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--text);
  font-size: 12.5px;
}
@media (max-width: 720px) {
  .chat-edit-bar { flex-direction: column; align-items: flex-start; }
}
