/* 论文阅读 · 页面样式（基于 tokens.css 的苹果式简约设计语言） */
:root {
  --sidebar: #fbfbfd;
  --ai-w: 460px;
  --read-font: 15.5px;
}
:root[data-theme='dark'] { --sidebar: #111113; }

body { font-size: 14px; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.02em; }
p { margin: 0; }
.hidden { display: none !important; }
.grow { flex: 1; min-width: 0; }
.row-flex { display: flex; align-items: center; gap: 8px; }
.wrap { flex-wrap: wrap; }
.sep-dot::before { content: '·'; margin: 0 6px; color: var(--text-4); }
.btn-ghost { background: transparent; color: var(--primary); }
.btn-ghost:hover { background: var(--primary-soft); }
.btn-danger { background: transparent; color: var(--danger); }
.btn-danger:hover { background: var(--danger-bg); }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn-lg { height: 40px; padding: 0 22px; font-size: 14.5px; }
.ico-14 { width: 14px; height: 14px; }
.ico-16 { width: 16px; height: 16px; }
.ico-18 { width: 18px; height: 18px; }
.ico-20 { width: 20px; height: 20px; }
.kbd { font: 500 11px var(--mono); color: var(--text-3); border: 1px solid var(--line-strong); border-radius: 6px; padding: 1px 6px; }

/* ---------- 骨架 ---------- */
#app.shell { display: flex; flex-direction: row; height: 100%; }
.sidebar { width: 224px; flex: none; background: var(--sidebar); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 16px 12px 12px; gap: 2px; transition: width .25s var(--ease-out); }
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px 18px; }
.logo-mark { width: 30px; height: 30px; border-radius: 9px; background: var(--ink); color: var(--ink-text); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 16px; letter-spacing: -.04em; flex: none; }
.brand-name { font-size: 15px; font-weight: 600; letter-spacing: -.02em; line-height: 1.2; }
.brand-sub { font-size: 11px; color: var(--text-3); }
.nav-group { font-size: 12px; font-weight: 500; color: var(--text-3); padding: 14px 10px 6px; }
.nav-item { display: flex; align-items: center; gap: 10px; height: 38px; padding: 0 10px; border-radius: 10px; color: var(--text); font-size: 14px; border: 0; background: transparent; width: 100%; text-align: left; transition: background .15s; white-space: nowrap; overflow: hidden; }
.nav-item:hover { background: var(--hover); text-decoration: none; }
.nav-item.active { background: var(--primary-soft); color: var(--primary); font-weight: 500; }
.nav-item .ico { color: var(--text-2); }
.nav-item.active .ico { color: var(--primary); }
.nav-item .count { margin-left: auto; font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.sidebar-bottom { margin-top: auto; display: flex; flex-direction: column; gap: 2px; }
.view { flex: 1; min-width: 0; overflow: auto; position: relative; }
.page { max-width: 1120px; margin: 0 auto; padding: 32px 36px 72px; animation: riseIn .35s var(--ease-out); }

body.reader-mode .sidebar { width: 64px; padding: 16px 10px 12px; }
body.reader-mode .sidebar .brand-text, body.reader-mode .sidebar .nav-label, body.reader-mode .sidebar .nav-group, body.reader-mode .sidebar .count { display: none; }
body.reader-mode .sidebar .brand { padding: 2px 7px 18px; }
body.reader-mode .sidebar .nav-item { justify-content: center; padding: 0; }

/* ---------- 页面标题 ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.eyebrow { font-size: 11px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--text-3); margin-bottom: 6px; }
.page-title { font-size: 32px; font-weight: 600; letter-spacing: -.03em; line-height: 1.15; }
.page-desc { font-size: 15px; color: var(--text-2); margin-top: 8px; line-height: 1.5; }
.section { margin-top: 40px; }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.section-title { font-size: 22px; font-weight: 600; letter-spacing: -.02em; }

/* ---------- 首页 ---------- */
.hero { padding: 26px 0 8px; position: relative; }
.hero-hello { font-size: 18px; font-weight: 500; color: var(--text-2); margin-bottom: 8px; }
.hero-title { font-size: clamp(32px, 4.6vw, 48px); font-weight: 600; letter-spacing: -.03em; line-height: 1.1; }
.hero-title em { font-style: normal; color: var(--primary); }
.search-pill { display: flex; align-items: center; gap: 10px; max-width: 660px; height: 54px; margin-top: 24px; padding: 0 8px 0 20px; background: var(--panel); border-radius: 99px; box-shadow: var(--shadow-card); transition: box-shadow .2s; }
.search-pill:focus-within { box-shadow: var(--shadow-lift), 0 0 0 4px rgba(0, 113, 227, .12); }
.search-pill input { flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: transparent; font-size: 16px; }
.search-pill .ico { color: var(--text-3); }
.interest { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 18px; }
.interest-label { font-size: 12.5px; color: var(--text-3); margin-right: 4px; }

/* ---------- 分段控件 / 芯片 ---------- */
.seg { display: inline-flex; padding: 3px; border-radius: 99px; background: var(--fill); gap: 2px; flex: none; }
.seg button { height: 28px; padding: 0 14px; border: 0; border-radius: 99px; background: transparent; color: var(--text-2); font-weight: 500; font-size: 13px; white-space: nowrap; transition: background .15s, color .15s; }
.seg button:hover { color: var(--text); }
.seg button.active { background: var(--panel); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; }
.chip .n { font-size: 11.5px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.chip.active .n { color: var(--primary); }
.chip.off { opacity: .55; }
.chip-sm { height: 24px; padding: 0 10px; font-size: 12px; }
.tag { display: inline-flex; align-items: center; height: 22px; padding: 0 9px; border-radius: 99px; background: var(--fill); color: var(--text-2); font-size: 12px; white-space: nowrap; }
.tag-blue { background: var(--primary-soft); color: var(--primary); }
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.check { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); font-size: 13px; cursor: pointer; user-select: none; }

/* ---------- 论文卡片 ---------- */
.plist { display: flex; flex-direction: column; gap: 12px; }
.pgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.pcard { position: relative; background: var(--panel); border-radius: var(--r-lg); box-shadow: var(--shadow-card); padding: 18px 22px 16px; cursor: pointer; transition: transform .25s var(--ease-out), box-shadow .25s var(--ease-out); display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.pcard:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); }
.pc-meta { display: flex; align-items: center; flex-wrap: wrap; font-size: 12.5px; color: var(--text-3); gap: 0; min-width: 0; }
.pc-src { font-weight: 600; color: var(--text-2); }
.pc-venue { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 340px; }
.pc-title { font-size: 16.5px; font-weight: 600; line-height: 1.4; letter-spacing: -.015em; color: var(--text); }
.pcard:hover .pc-title { color: var(--primary); }
.pc-authors { font-size: 13px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pc-tldr { font-size: 14px; color: var(--text); line-height: 1.6; }
.pc-abs { font-size: 13.5px; color: var(--text-2); line-height: 1.6; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.pc-points { margin: 0; padding-left: 18px; font-size: 13.5px; color: var(--text-2); line-height: 1.65; }
.pc-foot { display: flex; align-items: center; gap: 6px; margin-top: 4px; flex-wrap: wrap; }
.pc-actions { margin-left: auto; display: flex; gap: 2px; opacity: 0; transition: opacity .15s; }
.pcard:hover .pc-actions, .pc-actions.show { opacity: 1; }
.fav-on { color: var(--warning) !important; }
.fav-on svg { fill: currentColor; }
.state { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 500; color: var(--text-3); }
.state::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.state.ok { color: var(--success); }
.state.warn { color: var(--warning); }
.state.err { color: var(--danger); }
.state.blue { color: var(--primary); }
.reason { font-size: 12.5px; color: var(--text-3); line-height: 1.5; }
.reason b { color: var(--text-2); font-weight: 500; }
.pgrid .pcard { padding: 16px 18px 14px; }
.pgrid .pc-title { font-size: 15px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.pgrid .pc-tldr { font-size: 13.5px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* ---------- 空 / 加载 ---------- */
.empty { text-align: center; color: var(--text-3); padding: 56px 20px; font-size: 14px; line-height: 1.7; }
.empty .ico { width: 34px; height: 34px; margin: 0 auto 10px; opacity: .6; stroke-width: 1.4; }
.loading { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 48px 20px; color: var(--text-3); font-size: 13.5px; }
.skeleton { background: var(--panel); border-radius: var(--r-lg); box-shadow: var(--shadow-card); height: 132px; position: relative; overflow: hidden; }
.skeleton::after { content: ''; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, var(--hover), transparent); animation: shimmer 1.3s infinite; }
@keyframes shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
.notice { display: flex; gap: 10px; align-items: flex-start; background: var(--panel-2); border-radius: 14px; padding: 12px 14px; font-size: 13px; color: var(--text-2); line-height: 1.6; }

/* ---------- 搜索页 ---------- */
.search-top { display: flex; gap: 10px; align-items: center; }
.search-top .search-pill { margin-top: 0; flex: 1; max-width: none; height: 48px; }
.src-status { display: flex; flex-wrap: wrap; gap: 14px; margin: 14px 2px 18px; }
.linkouts { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 8px; font-size: 13px; color: var(--text-3); }

/* ---------- 统计卡 ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 28px; }
.stat { background: var(--panel); border-radius: var(--r-lg); box-shadow: var(--shadow-card); padding: 16px 20px; }
.stat-label { font-size: 13px; font-weight: 500; color: var(--text-3); }
.stat-num { font-size: 28px; font-weight: 600; letter-spacing: -.03em; font-variant-numeric: tabular-nums; margin-top: 4px; }
.stat-sub { font-size: 12.5px; color: var(--text-3); }

/* ---------- 列表行（历史） ---------- */
.card { background: var(--panel); border-radius: var(--r-lg); box-shadow: var(--shadow-card); }
.day-title { font-size: 13px; font-weight: 600; color: var(--text-3); margin: 22px 4px 8px; }
.rows { padding: 6px; }
.hrow { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 16px; min-height: 58px; padding: 8px 14px; border-radius: 12px; cursor: pointer; transition: background .12s; }
.hrow:hover { background: var(--panel-2); }
.hrow-title { font-size: 14.5px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hrow-sub { font-size: 12.5px; color: var(--text-3); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hrow-num { font-size: 12.5px; color: var(--text-3); text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.hrow .actions { opacity: 0; transition: opacity .12s; }
.hrow:hover .actions { opacity: 1; }

/* ---------- 收藏 ---------- */
.lib { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 24px; align-items: start; }
.lib-side { position: sticky; top: 24px; display: flex; flex-direction: column; gap: 2px; }
.folder-item { position: relative; }
.folder-item .f-actions { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); display: none; gap: 0; }
.folder-item:hover .f-actions { display: flex; }
.folder-item:hover .count { visibility: hidden; }
.fav-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.fav-note { font-size: 13px; color: var(--text-2); background: var(--panel-2); border-radius: 10px; padding: 8px 12px; line-height: 1.6; white-space: pre-wrap; }

/* ---------- 阅读器 ---------- */
.reader { display: flex; flex-direction: column; height: 100%; }
.reader-top { height: 58px; flex: none; display: flex; align-items: center; gap: 10px; padding: 0 16px 0 12px; }
.reader-title { font-size: 15px; font-weight: 600; letter-spacing: -.015em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reader-sub { font-size: 12px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.round { width: 36px; height: 36px; border: 0; border-radius: 50%; background: var(--panel); box-shadow: var(--shadow-card); display: inline-flex; align-items: center; justify-content: center; color: var(--text-2); flex: none; transition: box-shadow .2s, color .15s, transform .15s; }
.round:hover { box-shadow: var(--shadow-lift); color: var(--text); }
.round:active { transform: scale(.94); }
.reader-body { flex: 1; min-height: 0; display: flex; padding: 0 12px 12px; }
.pane { background: var(--panel); border-radius: var(--r-lg); box-shadow: var(--shadow-card); display: flex; flex-direction: column; overflow: hidden; min-width: 0; }
.read-pane { flex: 1; container-type: inline-size; }
.ai-pane { width: var(--ai-w); flex: none; }
.resizer { width: 12px; flex: none; cursor: col-resize; position: relative; }
.resizer::after { content: ''; position: absolute; left: 5px; top: 50%; width: 2px; height: 36px; margin-top: -18px; border-radius: 2px; background: var(--line-strong); opacity: 0; transition: opacity .2s; }
.resizer:hover::after, .resizer.drag::after { opacity: 1; }
.pane-head { flex: none; display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.pane-body { flex: 1; min-height: 0; overflow: auto; position: relative; }
body.ai-collapsed .ai-pane, body.ai-collapsed .resizer { display: none; }

/* 全文 */
.ft { display: grid; grid-template-columns: minmax(0, 1fr); }
@container (min-width: 820px) { .ft { grid-template-columns: 210px minmax(0, 1fr); } .toc { display: block !important; } }
.toc { display: none; position: sticky; top: 0; align-self: start; max-height: calc(100vh - 140px); overflow: auto; padding: 26px 8px 26px 18px; }
.toc-title { font-size: 11px; font-weight: 600; letter-spacing: .12em; color: var(--text-3); text-transform: uppercase; margin: 0 8px 8px; }
.toc a { display: block; padding: 5px 8px; border-radius: 8px; color: var(--text-2); font-size: 12.5px; line-height: 1.4; text-decoration: none; }
.toc a:hover { background: var(--hover); color: var(--text); }
.toc a.lv2 { padding-left: 18px; font-size: 12px; }
.toc a.lv3 { padding-left: 28px; font-size: 12px; color: var(--text-3); }
.toc a.on { color: var(--primary); background: var(--primary-soft); }
.ft-body { padding: 30px 40px 80px; max-width: 800px; width: 100%; margin: 0 auto; font-size: var(--read-font); line-height: 1.85; color: var(--text); }
.ft-body h2, .ft-body h3, .ft-body h4 { scroll-margin-top: 16px; }
.ft-body h2 { font-size: 21px; margin: 34px 0 12px; }
.ft-body h3 { font-size: 17.5px; margin: 26px 0 10px; }
.ft-body h4 { font-size: 15.5px; margin: 20px 0 8px; color: var(--text-2); }
.ft-body p { margin: 0 0 14px; text-align: justify; }
/* 屏幕外的段落不排版、不绘制：上千个公式的论文也不卡 */
.ft-body > p, .ft-body > h2, .ft-body > h3, .ft-body > h4, .ft-body > .eq { content-visibility: auto; contain-intrinsic-size: auto 90px; }
.ft-body .eq { position: relative; margin: 6px 0 16px; padding: 0 44px; overflow-x: auto; overflow-y: hidden; text-align: center; }
.ft-body .eq-n { position: absolute; right: 0; top: 50%; transform: translateY(-50%); color: var(--text-3); font-size: 0.92em; }
.ft-body .pg { display: flex; align-items: center; gap: 10px; color: var(--text-4); font-size: 11.5px; margin: 18px 0; }
.ft-body .pg::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.ft-body .hl { background: var(--primary-soft); border-radius: 4px; transition: background 1.5s; }
.ft-head { margin-bottom: 24px; }
.ft-head h1 { font-size: 26px; line-height: 1.3; letter-spacing: -.025em; }
.ft-src { margin-top: 12px; }
.pdf-frame { width: 100%; height: 100%; border: 0; display: block; background: var(--canvas); }
.info { padding: 30px 40px 60px; max-width: 820px; margin: 0 auto; }
.info h1 { font-size: 26px; line-height: 1.3; letter-spacing: -.025em; }
.kv { display: grid; grid-template-columns: 80px 1fr; gap: 10px 14px; font-size: 13.5px; margin: 20px 0; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; color: var(--text); word-break: break-word; }
.abs-block { font-size: 15px; line-height: 1.85; }

/* 选区浮动工具条 */
.sel-bar { position: fixed; z-index: 3000; display: flex; gap: 2px; padding: 4px; background: rgba(29, 29, 31, .94); border-radius: 99px; box-shadow: 0 10px 30px rgba(0, 0, 0, .25); animation: popIn .15s ease-out; }
.sel-bar button { display: inline-flex; align-items: center; gap: 5px; height: 30px; padding: 0 12px; border: 0; border-radius: 99px; background: transparent; color: #fff; font-size: 12.5px; font-weight: 500; }
.sel-bar button:hover { background: rgba(255, 255, 255, .14); }

/* AI 面板 */
.ai-body { padding: 18px 20px 28px; }
.ai-hero { text-align: center; padding: 34px 16px 20px; }
.ai-hero .ico-badge { width: 52px; height: 52px; border-radius: 16px; background: var(--primary-soft); color: var(--primary); display: flex; align-items: center; justify-content: center; margin: 0 auto 14px; }
.ai-hero h3 { font-size: 18px; margin-bottom: 8px; }
.ai-hero p { color: var(--text-2); font-size: 13.5px; line-height: 1.65; margin-bottom: 18px; }
.ana-one { font-size: 17px; font-weight: 600; line-height: 1.5; letter-spacing: -.015em; }
.ana-block { margin-top: 22px; }
.ana-h { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--text-3); margin-bottom: 10px; }
.ana-h .ico { color: var(--primary); }
.ana-p { font-size: 14px; line-height: 1.75; color: var(--text); }
.ana-list { margin: 0; padding-left: 18px; font-size: 14px; line-height: 1.75; }
.ana-list li { margin-bottom: 4px; }
.chain { display: flex; flex-direction: column; gap: 0; }
.chain-step { display: flex; gap: 12px; }
.chain-rail { display: flex; flex-direction: column; align-items: center; width: 14px; flex: none; }
.chain-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--primary); margin-top: 7px; flex: none; }
.chain-line { flex: 1; width: 2px; background: var(--primary-soft); margin: 4px 0; }
.chain-text { font-size: 14px; line-height: 1.65; padding-bottom: 12px; }
.tree { display: flex; flex-direction: column; gap: 8px; }
.tree-node { background: var(--panel-2); border-radius: 14px; padding: 11px 14px; cursor: pointer; transition: background .15s; }
.tree-node:hover { background: var(--primary-soft); }
.tree-sec { font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.tree-sec .go { margin-left: auto; color: var(--text-4); }
.tree-node:hover .go { color: var(--primary); }
.tree-role { font-size: 12px; color: var(--primary); margin-top: 3px; font-weight: 500; }
.tree-sum { font-size: 13px; color: var(--text-2); line-height: 1.65; margin-top: 4px; }
.tree-kids { margin: 8px 0 0 4px; padding-left: 12px; border-left: 2px solid var(--line); display: flex; flex-direction: column; gap: 6px; }
.tree-kid { font-size: 13px; line-height: 1.6; color: var(--text-2); cursor: pointer; border-radius: 8px; padding: 2px 6px; }
.tree-kid b { color: var(--text); font-weight: 500; }
.tree-kid:hover { background: var(--panel); }
.focus-card { border-radius: 14px; background: var(--panel-2); padding: 12px 14px; margin-bottom: 8px; }
.focus-point { font-size: 14px; font-weight: 600; line-height: 1.5; }
.focus-why { font-size: 13px; color: var(--text-2); line-height: 1.65; margin-top: 4px; }
.focus-where { font-size: 12px; color: var(--primary); margin-top: 6px; cursor: pointer; display: inline-flex; gap: 4px; align-items: center; }
.module { padding: 10px 0; border-bottom: 1px solid var(--line); }
.module:last-child { border-bottom: 0; }
.module-name { font-size: 14px; font-weight: 600; }
.module-desc { font-size: 13.5px; color: var(--text-2); line-height: 1.7; margin-top: 3px; }
.module-f { font-size: 13px; color: var(--text); margin-top: 6px; background: var(--panel-2); border-radius: 10px; padding: 8px 10px; overflow-x: auto; }
.terms { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; font-size: 13px; line-height: 1.6; }
.terms dt { font-weight: 600; color: var(--text); }
.terms dd { margin: 0; color: var(--text-2); }
.ana-foot { margin-top: 26px; padding-top: 14px; border-top: 1px solid var(--line); display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-3); }

/* 对话 */
.chat { display: flex; flex-direction: column; height: 100%; }
.chat-list { flex: 1; min-height: 0; overflow: auto; padding: 18px 18px 8px; display: flex; flex-direction: column; gap: 14px; }
.msg { max-width: 100%; font-size: 14px; line-height: 1.75; }
.msg-user { align-self: flex-end; max-width: 88%; background: var(--primary); color: #fff; border-radius: 18px 18px 6px 18px; padding: 9px 14px; white-space: pre-wrap; word-break: break-word; }
.msg-user blockquote { margin: 0 0 6px; padding: 6px 10px; border-radius: 10px; background: rgba(255, 255, 255, .16); font-size: 12.5px; white-space: pre-wrap; max-height: 120px; overflow: hidden; }
.msg-ai { align-self: stretch; color: var(--text); word-break: break-word; }
.msg-ai.err { color: var(--danger); }
.msg-tools { display: flex; gap: 2px; margin-top: 4px; opacity: 0; transition: opacity .15s; }
.msg-ai:hover .msg-tools { opacity: 1; }
.typing { display: inline-flex; gap: 4px; padding: 6px 0; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--text-4); animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; }
.typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
.quick { display: flex; gap: 6px; overflow-x: auto; padding: 4px 16px 10px; scrollbar-width: none; flex: none; }
.quick::-webkit-scrollbar { display: none; }
.quick .chip { flex: none; height: 28px; font-size: 12.5px; }
.composer { flex: none; margin: 0 12px 12px; border: 1px solid var(--line-strong); border-radius: 18px; background: var(--panel); padding: 8px 8px 8px 14px; transition: border-color .15s, box-shadow .15s; }
.composer:focus-within { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(0, 113, 227, .12); }
.composer textarea { width: 100%; border: 0; outline: 0; resize: none; background: transparent; font-size: 14px; line-height: 1.6; max-height: 160px; min-height: 24px; padding: 2px 0; display: block; }
.composer-row { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.sel-quote { display: flex; align-items: flex-start; gap: 8px; font-size: 12.5px; color: var(--text-2); background: var(--panel-2); border-radius: 10px; padding: 6px 8px 6px 10px; margin-bottom: 8px; line-height: 1.5; }
.sel-quote span { flex: 1; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.send { width: 32px; height: 32px; border-radius: 50%; border: 0; background: var(--primary); color: #fff; display: inline-flex; align-items: center; justify-content: center; flex: none; transition: background .15s, transform .15s; }
.send:hover { background: var(--primary-hover); }
.send:active { transform: scale(.92); }
.send[disabled] { background: var(--fill); color: var(--text-4); }

/* Markdown */
.md > :first-child { margin-top: 0; }
.md p { margin: 0 0 10px; }
.md h1, .md h2, .md h3, .md h4 { font-size: 15px; margin: 16px 0 8px; }
.md h1, .md h2 { font-size: 16px; }
.md ul, .md ol { margin: 0 0 10px; padding-left: 20px; }
.md li { margin-bottom: 3px; }
.md code { font-family: var(--mono); font-size: .88em; background: var(--fill); border-radius: 5px; padding: 1px 5px; }
.md pre { background: var(--panel-2); border-radius: 12px; padding: 12px 14px; overflow-x: auto; margin: 0 0 10px; }
.md pre code { background: none; padding: 0; font-size: 12.5px; }
.md blockquote { margin: 0 0 10px; padding: 2px 12px; border-left: 3px solid var(--line-strong); color: var(--text-2); }
.md table { border-collapse: collapse; margin: 0 0 10px; font-size: 13px; display: block; overflow-x: auto; }
.md th, .md td { border-bottom: 1px solid var(--line); padding: 6px 10px; text-align: left; }
.md th { color: var(--text-3); font-weight: 500; }
.md hr { border: 0; height: 1px; background: var(--line); margin: 14px 0; }
.katex-display { overflow-x: auto; overflow-y: hidden; padding: 4px 0; }

/* 相关 */
.mini { padding: 12px 14px; border-radius: 14px; cursor: pointer; transition: background .12s; }
.mini:hover { background: var(--panel-2); }
.mini-title { font-size: 13.5px; font-weight: 600; line-height: 1.45; }
.mini:hover .mini-title { color: var(--primary); }
.mini-meta { font-size: 12px; color: var(--text-3); margin-top: 3px; }

/* 收藏弹窗 */
.fav-folders { display: flex; flex-direction: column; gap: 2px; max-height: 210px; overflow: auto; margin: -4px -6px 0; }
.fav-folder { display: flex; align-items: center; gap: 10px; height: 36px; padding: 0 8px; border-radius: 10px; cursor: pointer; font-size: 14px; }
.fav-folder:hover { background: var(--hover); }
.fav-folder input { width: 16px; height: 16px; }
.fav-folder .hint { margin-left: auto; font-size: 12px; color: var(--primary); }
.field-label { font-size: 12.5px; font-weight: 500; color: var(--text-3); margin: 16px 0 8px; }

/* 更新面板 */
.update-log { margin-top: 12px; background: var(--panel-2); border-radius: 14px; padding: 12px 14px; font: 12px/1.6 var(--mono); color: var(--text-2); max-height: 220px; overflow: auto; white-space: pre-wrap; }

/* 设置 */
.settings { width: 640px; }
.set-section { margin-top: 18px; }
.set-section:first-child { margin-top: 4px; }
.set-title { font-size: 13px; font-weight: 600; color: var(--text-3); margin-bottom: 10px; }
.set-hint { font-size: 12px; color: var(--text-3); margin: -4px 0 0 104px; line-height: 1.5; }
.eng-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.eng-row:last-child { border-bottom: 0; }

/* ---------- 窄屏 ---------- */
@media (max-width: 1100px) { :root { --ai-w: 400px; } }
@media (max-width: 760px) {
  #app.shell { flex-direction: column-reverse; }
  .sidebar, body.reader-mode .sidebar { width: 100%; flex-direction: row; padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); border-right: 0; border-top: 1px solid var(--line); gap: 0; justify-content: space-around; }
  .sidebar .brand, .sidebar .nav-group, .sidebar .count { display: none !important; }
  .sidebar-bottom { margin: 0; flex-direction: row; }
  .sidebar-bottom .nav-item.opt { display: none; }
  .sidebar .nav-item { flex-direction: column; height: 48px; gap: 2px; font-size: 10.5px; justify-content: center; padding: 0 8px; width: auto; }
  body.reader-mode .sidebar .nav-label { display: block; }
  .page { padding: 20px 16px 48px; }
  .page-title { font-size: 26px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .lib { grid-template-columns: minmax(0, 1fr); }
  .lib-side { position: static; flex-direction: row; overflow-x: auto; }
  .lib-side .nav-item { width: auto; flex: none; height: 34px; }
  .lib-side .nav-group { display: none; }
  .lib-side .folder-item .f-actions { display: none !important; }
  .lib-side .folder-item:hover .count { visibility: visible; }
  .reader-body { flex-direction: column; padding: 0 8px 8px; gap: 8px; }
  .ai-pane { width: 100%; height: 55%; }
  .resizer { display: none; }
  .ft-body, .info { padding: 20px 18px 60px; }
  .pgrid { grid-template-columns: 1fr; }
  .settings { width: auto; }
  .set-hint { margin-left: 0; }
  .form-row { flex-wrap: wrap; }
  .hrow { grid-template-columns: 1fr auto; }
  .hrow .hrow-num:first-of-type { display: none; }
}
.pgrid .pc-meta { flex-wrap: nowrap; white-space: nowrap; overflow: hidden; }
.pgrid .pc-venue { max-width: 170px; }
.nav-item .count.ai-on { color: var(--success); }

/* ---------- 外观：纸张颜色（只在浅色模式下生效）、阅读字号 ---------- */
:root[data-paper='sepia']:not([data-theme='dark']) {
  --bg: #ece4d4; --sidebar: #f3ecdf; --panel: #f8f2e6; --panel-2: #efe7d7; --canvas: #e9e1d1;
  --fill: #e7ddca; --fill-hover: #ded3bd; --text: #3b3125; --text-2: #6e604d; --text-3: #8c7d69; --text-4: #ad9f8b;
  --line: rgba(90, 65, 30, 0.12); --line-strong: #d3c6ae; --border: #e0d5c1; --hover: rgba(90, 65, 30, 0.06); --active: rgba(90, 65, 30, 0.1);
}
:root[data-paper='green']:not([data-theme='dark']) {
  --bg: #dde8d8; --sidebar: #e8f0e4; --panel: #eef5ea; --panel-2: #e3ecde; --canvas: #dbe5d6;
  --fill: #d9e4d3; --fill-hover: #cfdcc8; --text: #22301f; --text-2: #4f5e4b; --text-3: #6d7c69; --text-4: #95a391;
  --line: rgba(40, 70, 35, 0.12); --line-strong: #c3d1bd; --border: #d3dfcd; --hover: rgba(40, 70, 35, 0.06); --active: rgba(40, 70, 35, 0.1);
}
:root[data-paper='gray']:not([data-theme='dark']) {
  --bg: #e4e4e7; --sidebar: #ececef; --panel: #f1f1f3; --panel-2: #e8e8eb; --canvas: #e2e2e5;
  --fill: #dedee2; --fill-hover: #d5d5da; --border: #dcdce0;
}
:root[data-paper]:not([data-paper='white']):not([data-theme='dark']) .search-pill input,
:root[data-paper]:not([data-paper='white']):not([data-theme='dark']) .input { background: var(--panel); }
:root[data-fs='s'] { --read-font: 14.5px; }
:root[data-fs='l'] { --read-font: 17px; }
:root[data-fs='xl'] { --read-font: 18.5px; }

.look-pop { width: 272px; padding: 6px 12px 14px; }
.look-pop .menu-header { padding: 10px 0 8px; }
.look-swatches { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.look-swatches button { display: flex; flex-direction: column; align-items: center; gap: 6px; border: 0; background: transparent; padding: 4px 0; border-radius: 10px; font-size: 12px; color: var(--text-2); }
.look-swatches button:hover { background: var(--hover); }
.look-swatches span { width: 34px; height: 34px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12); transition: box-shadow 0.15s; }
.look-swatches button.active { color: var(--primary); font-weight: 500; }
.look-swatches button.active span { box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12), 0 0 0 2px var(--panel), 0 0 0 4px var(--primary); }
.look-seg { display: flex; }
.look-seg button { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 4px; }
/* 超长的行内公式不撑破版面：在段落里横向滚动 */
.ft-body { min-width: 0; }
.ft-body p { overflow-wrap: break-word; }
.ft-body p .katex { white-space: nowrap; }
.ft-body p .katex-display, .ft-body .eq { max-width: 100%; }
