/* ============================================================
   阅读助手 · 学术纸感主题
   纸白 / 墨色 / 朱红 · 衬线标题 · 9:16 手机版式
   ============================================================ */
:root {
  --paper: #F6F1E7;
  --paper-2: #FBF8F1;
  --card: #FFFDF8;
  --ink: #26201A;
  --ink-2: #6B6156;
  --ink-3: #9A9083;
  --line: #DFD6C4;
  --line-2: #EAE3D3;
  --accent: #B23A2E;
  --accent-2: #8C2D24;
  --gold: #A98A4B;
  --serif: "Songti SC", "Noto Serif SC", "Noto Serif CJK SC", "Source Han Serif SC", "STSong", "SimSun", serif;
  --sans: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  --mono: "SF Mono", ui-monospace, "Menlo", monospace;
  --r: 12px;
  --fs: 1;   /* 用户字号缩放（0.8–1.4） */
  --sp: 1;   /* 间距缩放因子，移动端自动缩小 */
}
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { height: 100%; width: 100%; overflow: hidden; touch-action: manipulation; }
*, *::before, *::after { box-sizing: border-box; }
body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--paper);
  /* 流体排版：基准14px，随屏幕宽度在12.5px~16px间流动，再乘用户--fs */
  font-size: clamp(12.5px, calc(3.73vw * var(--fs)), calc(16px * var(--fs)));
  line-height: 1.6;
  height: 100%; width: 100%; overflow: hidden;
  margin: 0; padding: 0;
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
}
button { font-family: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input { font-family: inherit; color: inherit; }
::selection { background: rgba(178, 58, 46, .18); }

/* ---------- 桌面端：居中 9:16 手机框 ---------- */
.desk { height: 100dvh; max-height: 100dvh; display: flex; overflow: hidden; width: 100%; }
.phone {
  position: relative;
  width: 100%;
  max-width: 100%;
  height: 100dvh;
  max-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  overflow: hidden;
  box-sizing: border-box;
}
/* phone 模式：移动端全屏铺满，无边框无黑边 */
html:not(.mode-desktop) .desk {
  background: var(--paper);
  height: 100dvh; max-height: 100dvh;
  width: 100%; max-width: 100%;
  overflow: hidden;
}
html:not(.mode-desktop) .desk::after { display: none; }
html:not(.mode-desktop) .phone {
  width: 100%; max-width: 100%; height: 100dvh; max-height: 100dvh; aspect-ratio: auto;
  border-radius: 0; border: 0; box-shadow: none;
  overflow: hidden;
}

/* phone 模式在宽屏桌面端才显示手机外框（仅非触屏设备） */
@media (min-width: 900px) and (pointer: fine) {
  html:not(.mode-desktop) .desk {
    align-items: center; justify-content: center;
    background:
      radial-gradient(1200px 600px at 50% -10%, #3a332b 0%, #2a251f 55%, #221e19 100%);
    padding: 18px;
  }
  html:not(.mode-desktop) .desk::after {
    content: "知源阅读 · Wisdom Reading";
    position: fixed; bottom: 10px; left: 0; right: 0; text-align: center;
    font-size: calc(10px * var(--fs)); letter-spacing: .3em; color: rgba(246,241,231,.28);
  }
  html[lang="en"]:not(.mode-desktop) .desk::after {
    content: "Wisdom Reading";
    letter-spacing: .42em;
    font-family: "Playfair Display", Georgia, serif;
  }
  html:not(.mode-desktop) .phone {
    width: auto; aspect-ratio: 9 / 16;
    height: min(92vh, 860px);
    border-radius: 28px;
    border: 1px solid rgba(255,255,255,.10);
    box-shadow:
      0 0 0 10px #14110e,
      0 30px 80px -20px rgba(0,0,0,.75),
      0 0 120px -30px rgba(178,58,46,.28);
  }
}

/* 纸面噪点（极淡） */
.phone::before {
  content: ""; position: absolute; inset: 0; z-index: 0; pointer-events: none; opacity: .5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 0.16 0 0 0 0 0.13 0 0 0 0 0.09 0 0 0 0.035 0'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------- 报头 ---------- */
.masthead {
  position: relative; z-index: 2;
  padding: 16px 18px 0;
  background: linear-gradient(180deg, var(--paper-2) 0%, var(--paper) 100%);
}
.kicker {
  display: flex; align-items: center; gap: 7px;
  font-size: calc(10px * var(--fs)); letter-spacing: .1em; color: var(--ink-3);
  white-space: nowrap;
}
.kicker #kicker-doc { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.kdot { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); display: inline-block; }
.masthead h1 {
  font-family: var(--serif); font-size: calc(21px * var(--fs)); font-weight: 600;
  letter-spacing: .01em; margin-top: 4px; line-height: 1.25;
}
.masthead h1.brand { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; row-gap: 10px; padding-bottom: 12px; }
.logo-mark { width: 30px; height: 30px; flex: 0 0 auto; }
.brand-en { display: none; }
html[lang="en"] .brand-name { display: none; }
html[lang="en"] .brand-en {
  display: inline-block;
  font-family: "Playfair Display", "Songti SC", Georgia, "Times New Roman", serif;
  font-weight: 600;
  font-size: calc(11px * var(--fs));   /* 非首字母缩小 */
  letter-spacing: .015em;
  line-height: 1.3;
  padding-bottom: 1px;
  white-space: nowrap;   /* 品牌名永不内部断行 */
}
.brand-en .br-red {
  color: var(--accent-2);                /* W / R 暗红 */
  font-size: calc(14px * var(--fs));     /* W / R 保持大号（艺术对比） */
}

/* ---------- 品牌行工具（字号 + 版式开关） ---------- */
.brand-tools { display: flex; align-items: center; gap: 8px; margin-left: auto; flex: 0 0 auto; }
.font-ctl { display: flex; align-items: center; gap: 4px; }
.font-btn {
  width: 26px; height: 24px; border-radius: 7px; padding: 0;
  border: 1px solid var(--line); background: var(--paper-2);
  font-family: var(--serif); font-size: calc(12px * var(--fs)); color: var(--ink-2);
  display: grid; place-items: center; line-height: 1;
}
.font-btn:active { transform: scale(.94); }
.font-btn:disabled { opacity: .35; }

/* ---------- 语言切换（中文 / English） ---------- */
.lang-btn {
  height: 24px; padding: 0 6px; border-radius: 7px;
  border: 1px solid var(--line); background: var(--paper-2);
  font-size: calc(11px * var(--fs)); color: var(--ink-2);
  display: grid; place-items: center; line-height: 1; font-weight: 600;
  letter-spacing: .04em;
}
.lang-btn:active { transform: scale(.94); }
.lang-btn.on { border-color: var(--accent); color: var(--accent); }

/* 窄屏：隐藏版式开关文字标签（仅留开关本体，悬停/长按有 title） */
@media (max-width: 399px) {
  .vt-text { display: none; }
  .brand-tools { gap: 6px; }
}

/* ---------- 版式开关（手机 / 电脑） ---------- */
.view-toggle {
  display: flex; align-items: center; gap: 7px;
  flex: 0 0 auto;
  padding: 2px 0 2px 4px;
}
.view-toggle .vt-text {
  font-size: calc(10px * var(--fs)); letter-spacing: .18em; color: var(--ink-3);
  transition: color .2s;
}
.view-toggle .vt-track {
  position: relative; width: 34px; height: 19px; border-radius: 99px;
  background: var(--line-2); border: 1px solid var(--line);
  transition: background .22s, border-color .22s;
}
.view-toggle .vt-knob {
  position: absolute; top: 2px; left: 2px; width: 13px; height: 13px;
  border-radius: 50%; background: var(--card);
  box-shadow: 0 1px 3px rgba(38,32,26,.4);
  transition: left .22s cubic-bezier(.3,.8,.3,1);
}
.view-toggle:active .vt-track { transform: scale(.96); }
.view-toggle[aria-checked="true"] .vt-text { color: var(--accent); }
.view-toggle[aria-checked="true"] .vt-track { background: var(--accent); border-color: var(--accent-2); }
.view-toggle[aria-checked="true"] .vt-knob { left: 17px; background: #FFFDF8; }


/* ---------- 视图容器 ---------- */
.views { position: relative; z-index: 1; flex: 1; overflow: hidden; width: 100%; }
.view { position: absolute; inset: 0; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; display: none; max-width: 100%; }
.view.active { display: block; animation: viewIn .35s cubic-bezier(.2,.7,.2,1); }
#view-ask.active { display: flex; flex-direction: column; }

/* ---------- 阅读页：左目录 + 右内容 ---------- */
#view-read { flex-direction: row; overflow: hidden; }
#view-read.active { display: flex; overflow: hidden; }
.read-sidebar {
  width: 200px; min-width: 0; max-width: 200px;
  background: var(--paper-2); border-right: 1px solid var(--line);
  overflow-y: auto; overflow-x: hidden;
  padding: 10px 0; flex-shrink: 0;
  transition: width .25s ease, max-width .25s ease, padding .25s ease, opacity .25s ease;
}
.read-sidebar.collapsed { width: 0; max-width: 0; padding: 0; opacity: 0; overflow: hidden; }
.sidebar-title {
  font-size: calc(12px * var(--fs)); letter-spacing: .18em; color: var(--ink-3);
  padding: 4px 14px 8px; font-weight: 600;
}
.sidebar-list { display: flex; flex-direction: column; gap: 0; }
.sidebar-list .chip {
  display: block; text-align: left; white-space: normal;
  padding: 7px 14px; border-radius: 0; font-size: calc(12px * var(--fs));
  color: var(--ink); background: none; border: 0;
  border-left: 3px solid transparent;
  cursor: pointer; line-height: 1.4;
}
.sidebar-list .chip:hover { background: rgba(178,58,46,.05); }
.sidebar-list .chip.active { background: rgba(178,58,46,.08); border-left-color: var(--accent); color: var(--accent); font-weight: 600; }
.read-main { flex: 1; min-width: 0; overflow-y: auto; overflow-x: hidden; }
.sidebar-toggle {
  position: absolute; z-index: 20; top: 8px; left: 8px;
  width: auto; height: 32px; border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--card); cursor: pointer; font-size: calc(12px * var(--fs));
  color: var(--ink); padding: 0 10px; line-height: 32px; text-align: center;
  transition: left .25s ease; box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.sidebar-toggle.shifted { left: 168px; }
/* 折叠时toggle回到左0 */
.read-sidebar.collapsed ~ .read-main .sidebar-toggle,
#view-read .sidebar-toggle:not(.shifted) { left: 0; }
@media (max-width: 768px) {
  .read-sidebar { width: 0; max-width: 0; padding: 0; opacity: 0; overflow: hidden; }
  .read-sidebar:not(.collapsed) { width: 180px; max-width: 180px; padding: 10px 0; opacity: 1; overflow-y: auto; }
  .sidebar-toggle.shifted { left: 180px; }
}
@keyframes viewIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.loading { padding: 40px 20px; text-align: center; color: var(--ink-3); font-size: calc(12.5px * var(--fs)); letter-spacing: .1em; }

/* ---------- 章节 chips ---------- */
.chips {
  display: flex; gap: calc(8px * var(--sp)); overflow-x: auto; padding: calc(10px * var(--sp)) calc(18px * var(--sp));
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 11px 5px 6px;
  border: 1px solid var(--line); border-radius: 9px;
  background: var(--paper-2);
  font-size: calc(12px * var(--fs)); color: var(--ink-2);
  transition: border-color .18s, color .18s, background .18s;
}
.chip .n {
  width: 20px; height: 20px; display: grid; place-items: center;
  font-family: var(--serif); font-size: calc(12px * var(--fs));
  border: 1px solid var(--line); border-radius: 5px; color: var(--ink-2);
  transition: all .18s;
}
.chip.active { border-color: var(--accent); color: var(--ink); background: #FFFCF6; }
.chip.active .n { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip:active { transform: scale(.97); }

/* ---------- 阅读卡 ---------- */
.rcard {
  margin: calc(4px * var(--sp)) calc(18px * var(--sp)) calc(22px * var(--sp));
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: calc(16px * var(--sp)) calc(16px * var(--sp)) calc(8px * var(--sp));
  max-width: 100%;
  overflow-wrap: break-word;
  word-break: break-word;
  box-shadow: 0 1px 0 rgba(38,32,26,.03), 0 14px 30px -24px rgba(38,32,26,.35);
  animation: rise .5s cubic-bezier(.2,.7,.2,1) backwards;
}
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.rcard-title {
  font-family: var(--serif); font-size: calc(17px * var(--fs)); font-weight: 600;
  padding-bottom: 9px; border-bottom: 3px double var(--line);
  display: flex; align-items: baseline; gap: 10px;
}
.rcard-title .tag {
  font-family: var(--sans); font-size: calc(10px * var(--fs)); letter-spacing: .2em;
  color: var(--accent); border: 1px solid rgba(178,58,46,.4);
  padding: 2px 7px; border-radius: 4px; flex: 0 0 auto;
}
.sec { margin: 14px 0; overflow-wrap: break-word; word-break: break-word; }
.sec-h {
  display: flex; align-items: center; gap: 8px;
  font-size: calc(11px * var(--fs)); letter-spacing: .24em; color: var(--accent);
  margin-bottom: 7px;
}
.sec-h::before { content: ""; width: 3px; height: 12px; background: var(--accent); border-radius: 2px; }
.sec p { font-size: calc(13.5px * var(--fs)); line-height: 1.9; color: var(--ink); text-align: justify; }
.sec ol { list-style: none; counter-reset: kf; }
.sec ol li {
  counter-increment: kf; position: relative;
  padding: 6px 0 6px 30px; font-size: calc(13.5px * var(--fs)); line-height: 1.85;
  border-top: 1px dashed var(--line-2);
}
.sec ol li:first-child { border-top: 0; }
.sec ol li::before {
  content: counter(kf);
  position: absolute; left: 0; top: 7px;
  width: 20px; height: 20px; display: grid; place-items: center;
  font-family: var(--serif); font-size: calc(12px * var(--fs)); color: var(--accent);
  border: 1px solid rgba(178,58,46,.35); border-radius: 50%;
}

/* ---------- 公式 ---------- */
.toolbar { position: sticky; top: 0; z-index: 3; background: var(--paper); border-bottom: 1px solid var(--line-2); }
.searchbox {
  display: flex; align-items: center; gap: 8px;
  margin: 10px 18px 0; padding: 0 12px;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
}
.searchbox .ico { width: 16px; height: 16px; stroke: var(--ink-3); fill: none; stroke-width: 1.7; flex: 0 0 auto; }
.searchbox input {
  flex: 1; border: 0; outline: 0; background: transparent;
  padding: 10px 0; font-size: calc(13.5px * var(--fs));
}
.searchbox input::placeholder { color: var(--ink-3); }
.fcount { padding: 8px 18px 2px; font-size: calc(10.5px * var(--fs)); letter-spacing: .16em; color: var(--ink-3); }

.fcard {
  margin: 8px 18px 0; padding: 12px 14px 13px;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  animation: rise .4s cubic-bezier(.2,.7,.2,1) backwards;
}
.fcard .top {
  display: flex; justify-content: space-between; align-items: baseline; gap: 10px;
  font-size: calc(10.5px * var(--fs)); color: var(--ink-3); letter-spacing: .05em;
}
.fcard .top span:last-child {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 62%;
}
.ai-body blockquote {
  margin: 8px 0; padding: 7px 12px;
  border-left: 3px solid rgba(178,58,46,.5);
  background: var(--paper); border-radius: 0 6px 6px 0;
  color: var(--ink-2);
}
.ai-body blockquote p { margin: 3px 0; font-size: calc(12.5px * var(--fs)); }
.fcard .top .lab { font-family: var(--mono); color: var(--accent); }
.fcard .tex { margin: 9px 2px; overflow-x: auto; padding-bottom: 2px; }
.fcard .tex .katex { font-size: calc(15px * var(--fs)); }
.fcard .exp { font-size: calc(12.5px * var(--fs)); color: var(--ink-2); line-height: 1.75; }
.fcard .syms { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.sym {
  font-size: calc(10.5px * var(--fs)); color: var(--ink-2);
  border: 1px dashed var(--line); border-radius: 6px; padding: 2px 8px;
  background: var(--paper-2);
}
.sym b { font-weight: 600; color: var(--ink); margin-right: 4px; }
.sym b .katex { font-size: 1.02em; }
.sym b:not(:has(.katex)) { font-family: var(--mono); }
.fcard .foot {
  margin-top: 9px; padding-top: 8px; border-top: 1px dashed var(--line-2);
  display: flex; justify-content: space-between; align-items: center;
  font-size: calc(10.5px * var(--fs)); color: var(--ink-3);
}
.copybtn { font-size: calc(10.5px * var(--fs)); color: var(--ink-3); border: 1px solid var(--line); border-radius: 6px; padding: 2px 8px; }
.copybtn:active { color: var(--accent); border-color: var(--accent); }
.loadmore {
  display: block; margin: 14px auto 24px; padding: 8px 22px;
  font-size: calc(12px * var(--fs)); letter-spacing: .12em;
  border: 1px solid var(--line); border-radius: 99px; color: var(--ink-2);
  background: var(--paper-2);
}
.emptyhint { padding: 40px 20px; text-align: center; color: var(--ink-3); font-size: calc(12.5px * var(--fs)); }

/* ---------- 问答 ---------- */
#view-ask { background: var(--paper); }
.chat-scroll { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 14px 0 8px; }
.empty { padding: 26px 24px 8px; text-align: center; }
.empty-seal {
  width: 46px; height: 46px; margin: 0 auto 12px;
  display: grid; place-items: center;
  font-family: var(--serif); font-size: calc(22px * var(--fs)); color: #fff;
  background: var(--accent); border-radius: 9px;
  box-shadow: 0 10px 24px -12px rgba(178,58,46,.65);
}
.empty-t { font-family: var(--serif); font-size: calc(17px * var(--fs)); }
.empty-d { font-size: calc(11.5px * var(--fs)); color: var(--ink-3); margin-top: 5px; }
.sugs { margin-top: 18px; display: grid; gap: 8px; }
.sug {
  text-align: left; font-size: calc(12.5px * var(--fs)); color: var(--ink-2);
  padding: 11px 13px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--card);
  display: flex; gap: 9px; align-items: center;
}
.sug::before { content: "§"; font-family: var(--serif); color: var(--accent); flex: 0 0 auto; }
.sug:active { border-color: var(--accent); color: var(--ink); }

.msg-user {
  margin: 6px 14px 14px auto; max-width: 82%;
  background: #ECE4D2; border: 1px solid #E2D8C2;
  border-radius: 13px 13px 3px 13px;
  padding: 9px 13px; font-size: calc(13.5px * var(--fs)); line-height: 1.65;
  width: fit-content;
  animation: rise .35s cubic-bezier(.2,.7,.2,1) backwards;
}
.msg-ai { margin: 0 14px 16px; animation: rise .35s cubic-bezier(.2,.7,.2,1) backwards; }
.ai-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.seal {
  width: 21px; height: 21px; display: grid; place-items: center;
  font-family: var(--serif); font-size: calc(11.5px * var(--fs)); color: #fff;
  background: var(--accent); border-radius: 4px; flex: 0 0 auto;
}
.route-chip {
  font-size: calc(10px * var(--fs)); color: var(--ink-2); letter-spacing: .05em;
  border: 1px solid var(--line); border-radius: 99px; padding: 2px 9px;
  background: var(--paper-2);
}
.ai-body {
  background: var(--card); border: 1px solid var(--line); border-radius: 3px 12px 12px 12px;
  padding: 12px 14px; font-size: calc(13.5px * var(--fs)); line-height: 1.85;
  box-shadow: 0 12px 26px -24px rgba(38,32,26,.5);
}
.ai-body p { margin: 7px 0; text-align: justify; }
.ai-body p:first-child { margin-top: 0; }
.ai-body ul, .ai-body ol { margin: 7px 0; padding-left: 19px; }
.ai-body li { margin: 3px 0; }
.ai-body strong { color: var(--accent-2); }
.ai-body .msg-h {
  font-family: var(--serif); font-size: calc(14.5px * var(--fs)); color: var(--ink);
  margin: 13px 0 5px; padding-bottom: 4px; border-bottom: 1px solid var(--line-2);
}
.ai-body .math-block { margin: 9px 0; overflow-x: auto; }
.ai-body .math-block .katex { font-size: calc(14.5px * var(--fs)); }
.caret { display: inline-block; width: 7px; height: 15px; margin-left: 3px; vertical-align: -2px; background: var(--accent); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.ai-error { color: var(--accent); font-size: calc(12.5px * var(--fs)); }
.src-wrap { margin-top: 10px; }
.src-title { font-size: calc(10px * var(--fs)); letter-spacing: .2em; color: var(--ink-3); margin-bottom: 6px; }
.src-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.src-chip {
  font-size: calc(10.5px * var(--fs)); color: var(--ink-2);
  border: 1px solid var(--line); border-radius: 99px;
  padding: 3px 10px; background: var(--paper-2);
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.src-chip.eq { border-color: rgba(178,58,46,.45); color: var(--accent); }
.src-chip:active { transform: scale(.97); }

.composer {
  display: flex; gap: 8px; align-items: center;
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--line);
  background: linear-gradient(180deg, var(--paper-2), var(--paper));
}
.composer input {
  flex: 1; border: 1px solid var(--line); border-radius: 11px;
  background: var(--card); padding: 11px 13px; font-size: calc(14px * var(--fs)); outline: 0;
}
.composer input:focus { border-color: var(--accent); }
.composer #ask-send {
  width: 42px; height: 42px; flex: 0 0 auto;
  display: grid; place-items: center;
  background: var(--accent); border-radius: 11px;
  box-shadow: 0 8px 18px -10px rgba(178,58,46,.8);
}
.composer #ask-send svg { width: 19px; height: 19px; stroke: #fff; fill: none; stroke-width: 2; }
.composer #ask-send:disabled { opacity: .45; box-shadow: none; }
.composer .scope-mini {
  height: 42px; display: flex; align-items: center;
  padding: 0 13px; font-size: calc(13px * var(--fs)); border-radius: 11px;
  max-width: none; flex: 0 0 auto;
}

/* ---------- Tab 栏 ---------- */
.tabbar {
  position: relative; z-index: 2;
  display: flex;
  border-top: 1px solid var(--line);
  background: var(--paper-2);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.tab {
  flex: 1; display: grid; place-items: center; gap: 2px;
  padding: 6px 0 5px;
  font-size: calc(9px * var(--fs)); letter-spacing: .05em; color: var(--ink-3);
  position: relative; transition: color .2s;
}
.tab svg { width: 17px; height: 17px; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.tab.active { color: var(--accent); }
.tab.active::after {
  content: ""; position: absolute; top: 0; left: 50%; translate: -50% 0;
  width: 18px; height: 2px; background: var(--accent); border-radius: 2px;
}

/* ---------- 底部抽屉 ---------- */
.sheet-wrap { position: absolute; inset: 0; z-index: 20; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(38,32,26,.4); backdrop-filter: blur(2px); animation: fade .25s; }
@keyframes fade { from { opacity: 0; } }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0;
  max-height: 62%;
  background: var(--paper-2);
  border-radius: 16px 16px 0 0;
  border-top: 1px solid var(--line);
  box-shadow: 0 -20px 50px -20px rgba(38,32,26,.5);
  display: flex; flex-direction: column;
  animation: up .3s cubic-bezier(.2,.8,.25,1);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
@keyframes up { from { transform: translateY(30px); opacity: .6; } to { transform: none; opacity: 1; } }
.sheet-grip { width: 36px; height: 4px; border-radius: 99px; background: var(--line); margin: 8px auto 2px; flex: 0 0 auto; }
.sheet-title { font-size: calc(16px * var(--fs)); font-weight: 600; padding: 4px 18px 0; }
.sheet-body { padding: 8px 18px; }
.sheet-content { overflow-y: auto; padding: 10px 18px 18px; }
.sheet-content .lab { font-family: var(--mono); font-size: calc(11px * var(--fs)); color: var(--accent); }
.sheet-content .st { font-size: calc(13.5px * var(--fs)); margin-top: 6px; line-height: 1.8; }
.sheet-content .meta { font-size: calc(11px * var(--fs)); color: var(--ink-3); margin-top: 6px; }
.sheet-content .quote {
  margin-top: 10px; padding: 10px 12px;
  background: var(--paper); border-left: 3px solid var(--accent);
  border-radius: 4px; font-size: calc(12px * var(--fs)); line-height: 1.8; color: var(--ink-2);
  white-space: pre-wrap;
}

/* ---------- 公式解释面板 ---------- */
.sheet.tall { max-height: 84%; }
.fp-head { padding-bottom: 10px; border-bottom: 1px dashed var(--line-2); }
.fp-tex { margin: 9px 0 4px; overflow-x: auto; }
.fp-tex .katex { font-size: calc(16px * var(--fs)); }
.fp-meta { font-size: calc(10.5px * var(--fs)); color: var(--ink-3); }
.fp-body { font-size: calc(13px * var(--fs)); line-height: 1.85; padding: 10px 0 2px; }
.fp-body p { margin: 6px 0; text-align: justify; }
.fp-body ul, .fp-body ol { margin: 6px 0; padding-left: 19px; }
.fp-body strong { color: var(--accent-2); }
.fp-body .msg-h, .fp-example .msg-h {
  font-family: var(--serif); font-size: calc(14px * var(--fs)); color: var(--ink);
  margin: 12px 0 5px; padding-bottom: 4px; border-bottom: 1px solid var(--line-2);
}
.fp-body .math-block { margin: 8px 0; overflow-x: auto; }
.table-wrap {
  width: 100%; max-width: 100%;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  margin: 9px 0;
}
.ai-body table.md-table, .fp-body table.md-table {
  border-collapse: collapse; margin: 0; font-size: calc(12px * var(--fs));
  width: 100%; min-width: max-content; max-width: none;
}
.md-table th, .md-table td {
  border: 1px solid var(--line-2); padding: 4px 7px;
  text-align: left; vertical-align: top;
  min-width: 56px; max-width: 220px; word-break: break-word;
}
.md-table th { background: var(--paper); font-weight: 600; color: var(--ink); white-space: normal; }
.md-table td { color: var(--ink-2); }
/* 抽屉内容禁止横向溢出（宽表由 .table-wrap 内部滚动） */
.sheet-content { overflow-x: hidden; }
.fp-actions {
  position: sticky; bottom: 0; padding: 10px 0 calc(6px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(180deg, rgba(251,248,241,0), var(--paper-2) 40%);
  display: flex; gap: 8px;
}
.fp-btn {
  flex: 1; padding: 11px 0;
  background: var(--accent); color: #fff;
  font-size: calc(13px * var(--fs)); letter-spacing: .14em; border-radius: 10px;
  box-shadow: 0 10px 22px -12px rgba(178,58,46,.75);
}
.fp-btn.ghost {
  background: transparent; color: var(--accent);
  border: 1px solid var(--accent); box-shadow: none;
}
.fp-btn.ghost:active { background: rgba(178,58,46,.08); }
.fp-btn:disabled { opacity: .5; box-shadow: none; }
.fp-extra { border-top: 1px dashed var(--line); margin-top: 8px; padding-top: 4px; }
.footbtns { display: inline-flex; gap: 6px; }
.explbtn {
  font-size: calc(10.5px * var(--fs)); color: #fff; background: var(--accent);
  border: 1px solid var(--accent); border-radius: 6px; padding: 2px 9px;
}
.explbtn:active { background: var(--accent-2); }

/* ---------- 书库 ---------- */
.lib-actions { display: flex; gap: 8px; padding: 12px 18px 4px; }
.lib-seg { display: flex; gap: 6px; padding: 10px 18px 2px; }
.seg-btn {
  flex: 0 0 auto; padding: 6px 14px; border: 1px solid var(--line);
  border-radius: 999px; background: var(--card); color: var(--ink-2, #555);
  font-size: calc(12.5px * var(--fs)); cursor: pointer;
}
.seg-btn.active { border-color: var(--accent); color: var(--accent); }
.upload-btn {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 11px 0; background: var(--accent); color: #fff; border-radius: 10px;
  font-size: calc(13.5px * var(--fs)); letter-spacing: .1em; cursor: pointer;
  box-shadow: 0 10px 22px -12px rgba(178,58,46,.75);
}
.upload-btn svg { width: 16px; height: 16px; stroke: #fff; fill: none; stroke-width: 2; }
.ghost-btn {
  padding: 11px 16px; border: 1px solid var(--accent); color: var(--accent);
  border-radius: 10px; font-size: calc(13px * var(--fs)); background: transparent; letter-spacing: .06em;
}
.ghost-btn.active { background: var(--accent); color: #fff; }


.dcard {
  margin: 8px 18px 0; padding: 12px 14px; background: var(--card);
  border: 1px solid var(--line); border-radius: 10px; position: relative;
  animation: rise .4s cubic-bezier(.2,.7,.2,1) backwards;
  cursor: pointer;
}
.dcard-top { padding-right: 28px; }
.dcard.sel { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.dcard-top { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.dcard-top b { font-size: calc(13.5px * var(--fs)); line-height: 1.45; padding-right: 4px; }
.badge {
  font-size: calc(9.5px * var(--fs)); letter-spacing: .16em; color: var(--accent); flex: 0 0 auto;
  border: 1px solid rgba(178,58,46,.4); padding: 2px 6px; border-radius: 4px;
}
.dcard-meta { font-size: calc(11px * var(--fs)); color: var(--ink-3); margin-top: 4px; }
.dcard-cats { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 7px; }
.cat-chip {
  font-size: calc(10.5px * var(--fs)); color: var(--ink-2); border: 1px dashed var(--line);
  border-radius: 99px; padding: 2px 8px; background: var(--paper-2);
}
.cat-chip-suggested {
  border-style: dashed; border-color: var(--accent); color: var(--accent);
  background: rgba(178, 58, 46, .05); cursor: pointer; opacity: .82;
  transition: opacity .15s ease, border-style .15s ease, background .15s ease;
}
.cat-chip-suggested:hover {
  border-style: solid; opacity: 1; background: rgba(178, 58, 46, .1);
}
.cat-chip-suggested .acc { margin-left: 5px; font-weight: 700; }
.dcard-suggested { align-items: center; }
.dcard-suggested .sug-accept-all {
  font-size: calc(10px * var(--fs)); padding: 3px 9px; border-radius: 99px;
  border-color: var(--accent); color: var(--accent); background: transparent;
}
.dcard-stats { margin-top: 8px; font-size: calc(10.5px * var(--fs)); color: var(--ink-3); letter-spacing: .04em; }
.dcard-actions { margin-top: 9px; display: flex; gap: 6px; flex-wrap: wrap; }
.mini-btn {
  font-size: calc(11px * var(--fs)); padding: 5px 12px; border-radius: 8px;
  border: 1px solid var(--line); color: var(--ink-2); background: var(--paper-2);
}
.mini-btn.accent { border-color: var(--accent); color: var(--accent); }
.mini-btn.danger { border-color: rgba(178,58,46,.55); color: var(--accent); }
.mini-btn:disabled { opacity: .4; }
.pbar { height: 5px; border-radius: 99px; background: var(--line-2); overflow: hidden; margin-top: 9px; }
.pbar i { display: block; height: 100%; background: var(--accent); width: 0%; transition: width .6s ease; }
.pstage { font-size: calc(10.5px * var(--fs)); color: var(--ink-2); margin-top: 5px; }
.dcard-check {
  position: absolute; top: 12px; right: 12px; width: 20px; height: 20px;
  border: 1.5px solid var(--line); border-radius: 6px; display: grid; place-items: center;
  background: var(--card);
}
.dcard-check::after { content: ""; position: absolute; inset: -9px; }   /* 扩展点击热区 */
.dcard.sel .dcard-check { background: var(--accent); border-color: var(--accent); }
.dcard-check svg { width: 12px; height: 12px; stroke: #fff; fill: none; stroke-width: 2.6; display: none; }
.dcard.sel .dcard-check svg { display: block; }
/* ---------- 图表页签 ---------- */
.figcard {
  margin: 8px 18px 0; background: var(--card);
  border: 1px solid var(--line); border-radius: 10px; overflow: hidden;
  animation: rise .4s cubic-bezier(.2,.7,.2,1) backwards;
}
.figcard .figimg {
  display: block; width: 100%; max-height: 210px; object-fit: contain;
  background: var(--paper-2); padding: 8px; box-sizing: border-box;
  border-bottom: 1px dashed var(--line-2);
}
.figcard .figbody { padding: 10px 12px 12px; }
.figcard .top {
  display: flex; justify-content: space-between; gap: 10px; align-items: baseline;
  font-size: calc(10.5px * var(--fs)); color: var(--ink-3); letter-spacing: .04em;
}
.figcard .top .lab { font-family: var(--mono); color: var(--accent); flex: 0 0 auto; }
.figcard .top span:last-child {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 62%;
}
.figcard .cap { margin-top: 6px; font-size: calc(12.5px * var(--fs)); color: var(--ink-2); line-height: 1.7; }
.figcard .foot {
  margin-top: 9px; padding-top: 8px; border-top: 1px dashed var(--line-2);
  display: flex; justify-content: space-between; align-items: center;
  font-size: calc(10.5px * var(--fs)); color: var(--ink-3);
}
.figexpl {
  font-size: calc(10.5px * var(--fs)); color: #fff; background: var(--accent);
  border: 1px solid var(--accent); border-radius: 6px; padding: 3px 10px;
}
.fp-figimg {
  width: 100%; max-height: 230px; object-fit: contain;
  background: var(--paper-2); border: 1px solid var(--line-2);
  border-radius: 8px; margin: 8px 0 6px;
}

/* ---------- 图谱页签 ---------- */
#view-graph { overflow: hidden; }
#graph-canvas {
  position: absolute; inset: 0; width: 100%; height: 100%;
  display: block; touch-action: none; cursor: grab;
}
.graph-top {
  position: absolute; top: 0; left: 0; right: 0; z-index: 4;
  padding: 10px 14px 6px;
  background: linear-gradient(180deg, var(--paper) 72%, rgba(246, 241, 231, 0));
}
.graph-top .searchbox { margin: 0; }
.graph-legend {
  display: flex; gap: 6px; overflow-x: auto; padding: 8px 0 2px;
  scrollbar-width: none;
}
.graph-legend::-webkit-scrollbar { display: none; }
.relchip {
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: 5px;
  font-size: calc(10px * var(--fs)); color: var(--ink-2);
  border: 1px solid var(--line); border-radius: 99px; padding: 3px 9px;
  background: var(--paper-2);
}
.relchip i { width: 9px; height: 2.5px; border-radius: 2px; display: inline-block; }
/* S2-2：前置概念图例（蓝色环，不可切换） */
.relchip.static { cursor: default; color: #2F6E9A; }
.relchip i.ring { width: 9px; height: 9px; border-radius: 50%; background: transparent; border: 1.8px solid #2F6E9A; }
.relchip.off { opacity: .32; }
.graph-tools {
  position: absolute; right: 12px; bottom: 20px; z-index: 4;
  display: flex; flex-direction: column; gap: 8px; align-items: flex-end;
  transition: bottom .22s ease;
}
#view-graph.card-open .graph-tools { bottom: calc(48% + 18px); }
.graph-tools .ghost-btn { padding: 8px 12px; font-size: calc(11.5px * var(--fs)); background: var(--paper-2); }
.graph-card {
  position: absolute; left: 12px; right: 12px; bottom: 12px; z-index: 5;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 18px 40px -22px rgba(38, 32, 26, .55);
  padding: 12px 14px; max-height: 46%; overflow-y: auto;
}
.graph-card .gc-head { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.graph-card .gc-title { font-family: var(--serif); font-size: calc(16px * var(--fs)); font-weight: 600; }
.graph-card .gc-def { margin-top: 6px; font-size: calc(12.5px * var(--fs)); line-height: 1.75; color: var(--ink-2); }
/* S2-2 前置概念标记 */
.graph-card .gc-prereq { margin-top: 7px; display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.graph-card .prereq-tag {
  display: inline-block; padding: 1px 7px; border-radius: 3px;
  font-size: calc(11px * var(--fs)); font-weight: 600; letter-spacing: .06em;
  color: #2F6E9A; background: rgba(47,110,154,.10); border: 1px solid rgba(47,110,154,.45);
}
.graph-card .prereq-note { font-size: calc(11.5px * var(--fs)); color: #2F6E9A; opacity: .85; }
.graph-card .gc-chips { margin-top: 7px; display: flex; flex-wrap: wrap; gap: 5px; }
.graph-card .gc-actions { margin-top: 10px; display: flex; flex-wrap: nowrap; gap: 6px; }
.graph-card .gc-actions .mini-btn {
  flex: 1; min-width: 0; padding: 5px 2px; text-align: center;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.graph-path { margin-top: 8px; font-size: calc(12px * var(--fs)); line-height: 1.95; color: var(--ink-2); }
.graph-path .pt { color: #8A6A1F; border-bottom: 1px dotted rgba(169, 138, 75, .7); cursor: pointer; }
.graph-loading {
  position: absolute; inset: 0; z-index: 6; display: grid; place-items: center;
  color: var(--ink-3); font-size: calc(13px * var(--fs)); letter-spacing: .1em; background: var(--paper);
}

.graph-empty {
  position: absolute; inset: 0; z-index: 5; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 10px; padding: 0 46px;
  text-align: center; background: var(--paper);
}
.graph-empty .ge-glyph {
  font-size: calc(34px * var(--fs)); color: var(--gold); opacity: .75; line-height: 1;
}
.graph-empty b { font-size: calc(14px * var(--fs)); color: var(--ink); }
.graph-empty p {
  margin: 0; font-size: calc(12px * var(--fs)); line-height: 1.9; color: var(--ink-3);
  max-width: 260px; letter-spacing: .02em;
}
.graph-empty #graph-rebuild { margin-top: 4px; }
.graph-empty #graph-rebuild[disabled] { opacity: .55; }

/* ---------- 术语高亮与解释 ---------- */
.term {
  color: #8A6A1F;
  border-bottom: 1px dotted rgba(169, 138, 75, .75);
  cursor: pointer;
}
.term:active { background: rgba(169, 138, 75, .16); }
.term-title {
  font-family: var(--serif); font-size: calc(19px * var(--fs)); font-weight: 600;
  color: var(--ink); margin-top: 4px;
}
.term-def {
  margin-top: 10px; padding: 10px 12px;
  background: var(--paper); border-left: 3px solid var(--gold);
  border-radius: 4px; font-size: calc(13px * var(--fs)); line-height: 1.8; color: var(--ink);
}
.term-back {
  display: inline-block; margin-bottom: 10px;
  padding: 5px 12px; font-size: calc(12px * var(--fs)); letter-spacing: .06em;
}

/* ---------- 对比页签 ---------- */
.cmp-actions {
  position: sticky; bottom: 0; display: flex; align-items: center; gap: 10px;
  padding: 12px 18px calc(12px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(180deg, rgba(246,241,231,0), var(--paper) 45%);
}
.cmp-actions span { flex: 1; font-size: calc(12.5px * var(--fs)); color: var(--ink-2); }
.cmp-actions button {
  padding: 10px 20px; border-radius: 10px; background: var(--accent);
  color: #fff; font-size: calc(13px * var(--fs)); letter-spacing: .1em;
}
.cmp-actions button:disabled { opacity: .45; }
.cmp-report-head {
  position: sticky; top: 0; z-index: 3;
  display: flex; align-items: center; gap: 10px;
  padding: 12px 18px; background: var(--paper);
  border-bottom: 1px solid var(--line-2);
}
.cmp-report-head .lab { flex: 1; font-size: calc(12px * var(--fs)); letter-spacing: .16em; color: var(--accent); }
.cmp-report-head .ghost-btn { padding: 7px 12px; font-size: calc(12px * var(--fs)); }

/* ---------- 范围选择 ---------- */
.scope-mini {
  flex: 0 0 auto; font-size: calc(11px * var(--fs)); color: var(--ink-2);
  border: 1px solid var(--line); border-radius: 8px; padding: 9px 9px;
  background: var(--paper-2); max-width: 96px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.searchbox .scope-mini { margin: 6px 0 6px 4px; padding: 7px 13px; font-size: calc(13px * var(--fs)); }
.scope-mini.on { border-color: var(--accent); color: var(--accent); }
.scope-list { display: grid; gap: 6px; margin-top: 8px; }
.scope-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 9px; background: var(--card);
  font-size: calc(13px * var(--fs)); text-align: left;
}
.scope-item .box {
  width: 18px; height: 18px; border: 1.5px solid var(--line); border-radius: 5px;
  display: grid; place-items: center; flex: 0 0 auto; font-size: calc(11px * var(--fs)); color: #fff;
}
.scope-item.on { border-color: var(--accent); }
.scope-item.on .box { background: var(--accent); border-color: var(--accent); }
.scope-item.on .box::after { content: "✓"; }
.scope-title { font-size: calc(10px * var(--fs)); letter-spacing: .2em; color: var(--ink-3); margin: 14px 0 2px; }

/* ---------- 文档编辑 ---------- */
.edit-field { margin-top: 10px; }
.edit-field label { font-size: calc(10.5px * var(--fs)); letter-spacing: .12em; color: var(--ink-3); display: block; margin-bottom: 4px; }
.edit-field input {
  width: 100%; border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px;
  font-size: calc(13px * var(--fs)); background: var(--card); outline: 0;
}
.edit-field input:focus { border-color: var(--accent); }
.cat-edit { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; align-items: center; }
.cat-edit .cat-chip .x { margin-left: 6px; color: var(--accent); cursor: pointer; }
.cat-edit input { flex: 1; min-width: 90px; border: 1px dashed var(--line); border-radius: 99px;
  padding: 4px 10px; font-size: calc(11px * var(--fs)); background: transparent; outline: 0; }
.sheet-actions { display: flex; gap: 8px; margin-top: 18px; }
.sheet-actions .fp-btn { flex: 1; padding: 11px 0; }
.sheet-actions .fp-btn.danger { background: transparent; border: 1px solid var(--accent); color: var(--accent); box-shadow: none; }

/* ---------- Toast ---------- */
.toast {
  position: absolute; left: 50%; bottom: 86px; translate: -50% 0; z-index: 60;
  background: var(--ink); color: var(--paper);
  font-size: calc(12px * var(--fs)); padding: 9px 16px; border-radius: 9px;
  max-width: 84%; text-align: center;
  animation: rise .3s cubic-bezier(.2,.7,.2,1);
}
.toast-retry {
  margin-left: 10px; padding: 4px 12px; border: 1px solid var(--paper); border-radius: 6px;
  background: transparent; color: var(--paper); font-size: inherit; cursor: pointer;
}
.toast-retry:hover { background: rgba(255,255,255,.15); }
.inline-retry {
  display: inline-block; margin-left: 8px; padding: 2px 10px;
  border: 1px solid var(--accent); border-radius: 5px;
  background: var(--accent); color: #fff; font-size: calc(11px * var(--fs));
  cursor: pointer; letter-spacing: .05em;
}
.inline-retry:hover { opacity: .85; }

/* ---------- 品牌艺术字体（Wisdom Reading） ---------- */
@font-face {
  font-family: "Playfair Display";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/static/vendor/fonts/playfair-display-600.woff2") format("woff2");
}

/* KaTeX 在深色注释里的微调 */
.katex { color: var(--ink); max-width: 100%; overflow-x: auto; overflow-y: hidden; }
.math-inline .katex { font-size: 1em; }

/* 修复：CSS display 覆盖 hidden 属性（对比栏/加载更多等） */
[hidden] { display: none !important; }

/* ============================================================
   移动端响应式适配：流体根字号 + 间距收紧
   html根字号随屏幕宽度自动缩放 → 所有calc(Xpx*var(--fs))跟随
   ============================================================ */
@media (max-width: 768px) and (pointer: coarse) {
  html { font-size: clamp(12px, 3.5vw, 16px); }
  :root { --sp: clamp(0.65, 100vw / 580, 1); --r: 10px; }
  .rcard { margin: calc(4px * var(--sp)) calc(10px * var(--sp)) calc(16px * var(--sp)); padding: calc(12px * var(--sp)) calc(12px * var(--sp)) calc(6px * var(--sp)); }
  .rcard-title { padding-bottom: 7px; }
  .fcard { margin: calc(4px * var(--sp)) calc(10px * var(--sp)) calc(14px * var(--sp)); padding: calc(10px * var(--sp)); }
  .sheet { width: 100% !important; max-width: 100% !important; left: 0 !important; right: 0 !important; border-radius: 14px 14px 0 0 !important; }
  .sheet .sheet-body { padding: calc(12px * var(--sp)) calc(14px * var(--sp)) calc(20px * var(--sp)); }
  .empty { padding: calc(18px * var(--sp)) calc(14px * var(--sp)) calc(6px * var(--sp)); }
  .ai-body, .user-body { padding: calc(8px * var(--sp)) calc(10px * var(--sp)); }
  #view-read .chips { padding-inline: calc(10px * var(--sp)); }
  #view-read .rcard { margin: calc(4px * var(--sp)) calc(10px * var(--sp)) calc(18px * var(--sp)); }
  .read-sidebar { width: 160px; max-width: 160px; }
  .sidebar-toggle.shifted { left: 160px; }
  #view-library .chips { padding-inline: calc(10px * var(--sp)); }
  #view-formulas .chips, #view-figures .chips { padding-inline: calc(10px * var(--sp)); }
  #messages { padding-inline: calc(6px * var(--sp)); }
  .composer { padding: calc(6px * var(--sp)) calc(10px * var(--sp)); }
  .composer #ask-input { padding: calc(7px * var(--sp)) calc(10px * var(--sp)); }
  .brand { padding: 0 calc(10px * var(--sp)); }
  .chips { padding: calc(10px * var(--sp)) calc(18px * var(--sp)); gap: calc(8px * var(--sp)); }
  .modal-body { width: 96% !important; max-width: 96% !important; padding: calc(14px * var(--sp)); }
}

@media (max-width: 430px) and (pointer: coarse) {
  html { font-size: clamp(11px, 3.2vw, 14px); }
  :root { --sp: clamp(0.55, 100vw / 680, 0.85); --r: 9px; }
  .rcard { margin: calc(2px * var(--sp)) calc(8px * var(--sp)) calc(12px * var(--sp)); padding: calc(10px * var(--sp)); }
  .fcard { margin: calc(2px * var(--sp)) calc(8px * var(--sp)) calc(12px * var(--sp)); padding: calc(8px * var(--sp)); }
  .chip { padding: calc(2px * var(--sp)) calc(7px * var(--sp)); }
  .composer { padding: calc(5px * var(--sp)) calc(8px * var(--sp)); }
  .brand { padding: 0 calc(8px * var(--sp)); }
  #messages { padding-inline: calc(4px * var(--sp)); }
}

/* ============================================================
   电脑版（开关切换）：16:9 桌面布局
   左侧栏（品牌 / 导航 / 库统计） + 右侧内容区 · 宽屏重排
   ============================================================ */

  /* ---- 桌面外壳：去掉手机框，铺满视口 ---- */
  html.mode-desktop .desk { display: block; padding: 0; background: var(--paper); }
  html.mode-desktop .desk::after { display: none; }
  html.mode-desktop .phone {
    width: 100%; height: 100dvh; aspect-ratio: auto;
    border-radius: 0; border: 0; box-shadow: none;
    display: grid;
    grid-template-columns: minmax(160px, 236px) minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas: "brand main" "nav main";
  }

  /* 移动端横屏 desktop：侧栏更窄，字号适配 */
  @media (max-width: 900px) {
    html.mode-desktop .phone {
      grid-template-columns: minmax(120px, 180px) minmax(0, 1fr);
    }
    html.mode-desktop .masthead h1.brand { font-size: calc(15px * var(--fs)); }
    html.mode-desktop .tab { font-size: calc(11.5px * var(--fs)); padding: 8px 10px; gap: 8px; }
    html.mode-desktop .tab svg { width: 15px; height: 15px; }
  }

  /* ---- 左侧栏：品牌 ---- */
  html.mode-desktop .masthead {
    grid-area: brand; position: static; z-index: 3;
    padding: 20px 20px 14px;
    background: var(--paper-2);
    border-right: 1px solid var(--line);
  }
  html.mode-desktop .masthead h1.brand { font-size: calc(19px * var(--fs)); padding-bottom: 0; flex-wrap: wrap; row-gap: 12px; }
  html.mode-desktop .brand-en { font-size: calc(10.5px * var(--fs)); }
  html.mode-desktop .brand-en .br-red { font-size: calc(13px * var(--fs)); }
  html.mode-desktop .logo-mark { width: 26px; height: 26px; }
  html.mode-desktop .kicker {
    position: absolute; left: 20px; bottom: 18px; width: 196px;
    display: block; white-space: normal; line-height: 1.9;
    letter-spacing: .08em;
  }
  html.mode-desktop .kicker > span:first-child, html.mode-desktop .kicker .kdot { display: none; }

  /* ---- 左侧栏：垂直导航 ---- */
  html.mode-desktop .tabbar {
    grid-area: nav; align-self: stretch;
    flex-direction: column; align-items: stretch;
    gap: 2px; padding: 10px 12px 14px;
    border-top: 0; border-right: 1px solid var(--line);
    background: var(--paper-2);
  }
  html.mode-desktop .tab {
    flex: 0 0 auto;
    display: flex; flex-direction: row; justify-content: flex-start;
    gap: 11px; padding: 10px 13px; border-radius: 9px;
    font-size: calc(13px * var(--fs)); letter-spacing: .04em; color: var(--ink-2);
    transition: background .15s, color .15s;
  }
  html.mode-desktop .tab svg { width: 18px; height: 18px; }
  html.mode-desktop .tab:hover { background: rgba(38,32,26,.05); color: var(--ink); }
  html.mode-desktop .tab.active { background: rgba(178,58,46,.09); color: var(--accent); }
  html.mode-desktop .tab.active::after { display: none; }

  html.mode-desktop .views { grid-area: main; }

  /* ---- 抽屉 → 居中模态 ---- */
  html.mode-desktop .sheet {
    left: 50%; right: auto; bottom: auto; top: 50%;
    width: min(680px, 94%); max-height: 84%;
    border-radius: 14px; border: 1px solid var(--line);
    box-shadow: 0 30px 80px -30px rgba(38,32,26,.65);
    transform: translate(-50%, -50%);
    animation: sheetIn .28s cubic-bezier(.2,.8,.25,1);
    padding-bottom: 0;
  }
  @keyframes sheetIn {
    from { transform: translate(-50%, -47%); opacity: .5; }
    to { transform: translate(-50%, -50%); opacity: 1; }
  }
  html.mode-desktop .sheet.tall { max-height: 88%; width: min(760px, 94%); }
  html.mode-desktop .sheet-grip { display: none; }
  html.mode-desktop .sheet-content { padding: 12px 24px 20px; }
  html.mode-desktop .fp-actions { padding: 10px 0 4px; background: linear-gradient(180deg, rgba(251,248,241,0), var(--paper-2) 40%); }
  html.mode-desktop .toast { bottom: 30px; }

  /* ---- 速读：单栏阅读宽度收敛 ---- */
  html.mode-desktop #view-read .chips { max-width: 920px; margin-inline: auto; width: 100%; }
  html.mode-desktop #view-read .rcard { max-width: 880px; margin: 4px auto 22px; }

  /* ---- 书库：卡片网格 ---- */
  html.mode-desktop #view-library .lib-actions { max-width: 1360px; margin-inline: auto; width: 100%; padding: 16px 24px 6px; }
  html.mode-desktop #view-library .chips { max-width: 1360px; margin-inline: auto; width: 100%; padding-inline: 24px; }
  html.mode-desktop #lib-body {
    display: grid; gap: 12px;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    max-width: 1360px; margin-inline: auto; width: 100%;
    padding: 4px 24px 28px;
  }
  html.mode-desktop #lib-body .dcard { margin: 0; }
  html.mode-desktop #lib-body .emptyhint, html.mode-desktop #lib-body .loading { grid-column: 1 / -1; }

  /* ---- 公式：双/三栏网格 ---- */
  html.mode-desktop #view-formulas .toolbar, html.mode-desktop #view-figures .toolbar { padding-bottom: 10px; }
  html.mode-desktop #view-formulas .searchbox, html.mode-desktop #view-figures .searchbox { max-width: 1312px; margin: 12px auto 0; }
  html.mode-desktop #view-formulas .chips { max-width: 1312px; margin-inline: auto; width: 100%; }
  html.mode-desktop #view-formulas .fcount, html.mode-desktop #view-figures .fcount {
    max-width: 1312px; margin-inline: auto; width: 100%; padding: 9px 24px 2px;
  }
  html.mode-desktop #formula-body {
    display: grid; gap: 12px;
    grid-template-columns: repeat(auto-fill, minmax(430px, 1fr));
    max-width: 1360px; margin-inline: auto; width: 100%;
    padding: 10px 24px 0;
  }
  html.mode-desktop #formula-body .fcard { margin: 0; }
  html.mode-desktop #formula-body .emptyhint, html.mode-desktop #formula-body .loading { grid-column: 1 / -1; }
  html.mode-desktop #view-formulas .loadmore, html.mode-desktop #view-figures .loadmore { margin: 18px auto 28px; }

  /* ---- 图表：网格 + 等高卡片 ---- */
  html.mode-desktop #figure-body {
    display: grid; gap: 12px;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    max-width: 1360px; margin-inline: auto; width: 100%;
    padding: 10px 24px 0;
  }
  html.mode-desktop #figure-body .figcard { margin: 0; display: flex; flex-direction: column; }
  html.mode-desktop #figure-body .figcard .figbody { flex: 1; display: flex; flex-direction: column; justify-content: flex-start; }
  html.mode-desktop #figure-body .figcard .cap { flex: 1; }
  html.mode-desktop #figure-body .figcard .foot { margin-top: auto; }
  html.mode-desktop #figure-body .emptyhint, html.mode-desktop #figure-body .loading { grid-column: 1 / -1; }

  /* ---- 问答：居中阅读栏 ---- */
  html.mode-desktop #messages, html.mode-desktop #ask-empty { max-width: 860px; margin-inline: auto; width: 100%; }
  html.mode-desktop .msg-user { margin: 6px 0 14px auto; }
  html.mode-desktop .msg-ai { margin: 0 0 16px; }
  html.mode-desktop .composer { padding-inline: max(14px, calc(50% - 430px)); }
  html.mode-desktop .sugs { grid-template-columns: 1fr 1fr; }

  /* ---- 对比：列表与报告居中 ---- */
  html.mode-desktop #cmp-pick { max-width: 860px; margin-inline: auto; width: 100%; padding-top: 6px; }
  html.mode-desktop #cmp-pick .fp-head { padding: 12px 0 8px !important; }
  html.mode-desktop #cmp-list { padding: 0 !important; grid-template-columns: repeat(2, 1fr); }
  html.mode-desktop .cmp-actions { padding: 16px 0 20px; background: none; }
  html.mode-desktop #cmp-report { max-width: 900px; margin-inline: auto; width: 100%; }
  html.mode-desktop .cmp-report-head { padding: 12px 0; }
  html.mode-desktop #cmp-body { padding: 0 0 28px !important; }

  /* ---- 图谱：工具条居中 + 节点卡右侧面板 ---- */
  html.mode-desktop #view-graph .graph-top { padding: 12px 20px 8px; }
  html.mode-desktop #view-graph .graph-top .searchbox { max-width: 860px; margin: 0 auto; }
  html.mode-desktop .graph-legend { justify-content: center; }
  html.mode-desktop .graph-card {
    left: auto; right: 16px; top: 96px; bottom: auto;
    width: 380px; max-height: calc(100% - 120px);
  }
  html.mode-desktop #view-graph.card-open .graph-tools { bottom: 20px; }
  html.mode-desktop .graph-tools { right: 16px; bottom: 20px; }


/* ============================================================
   M1：登录 / 注册浮层 + 用户信息页 + 头像入口
   ============================================================ */
.user-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: grid; place-items: center;
  font-family: var(--serif); font-size: calc(13px * var(--fs));
  border: 0; flex: 0 0 auto; cursor: pointer;
  box-shadow: 0 6px 14px -8px rgba(178,58,46,.8);
}
.user-avatar:active { transform: scale(.94); }
.user-avatar[hidden] { display: none; }

.auth-overlay {
  position: absolute; inset: 0; z-index: 40;
  background: linear-gradient(135deg, #FFF8F0 0%, #FDF5EC 55%, #FAF0E4 100%);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  overflow: hidden;
}
/* —— 知识网络动态背景 —— */
.auth-canvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  z-index: 0; pointer-events: none; display: block;
}
.auth-card {
  position: relative; z-index: 1;
  width: min(340px, 100%);
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 24px 60px -30px rgba(38,32,26,.5);
  padding: 22px 20px 16px;
  transition: opacity .18s ease, transform .18s ease;
}
/* —— 品牌头（注册/登录页） —— */
.auth-head { text-align: center; }
.auth-logo { width: 40px; height: 40px; display: block; margin: 2px auto 8px; border-radius: 9px; }
.auth-brand { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.auth-brand-name {
  font-family: var(--serif); font-size: calc(22px * var(--fs));
  letter-spacing: .12em; color: var(--ink); line-height: 1.2;
}
.auth-brand-en {
  font-family: var(--serif); font-size: calc(11px * var(--fs));
  letter-spacing: .22em; color: var(--ink-3); text-transform: uppercase;
}
.auth-tagline {
  margin: 7px 0 0; font-size: calc(11.5px * var(--fs));
  color: var(--ink-3); letter-spacing: .02em;
}
.auth-title { text-align: center; font-family: var(--serif); font-size: calc(17px * var(--fs)); }

/* —— 登录页语言切换（右上角） —— */
.auth-lang {
  position: absolute; top: 10px; right: 10px; z-index: 2;
  height: 24px; min-width: 26px; padding: 0 7px; border-radius: 7px;
  border: 1px solid var(--line); background: var(--paper-2);
  font-size: calc(11px * var(--fs)); color: var(--ink-2); font-weight: 600;
  display: grid; place-items: center; line-height: 1; letter-spacing: .04em;
}
.auth-lang:active { transform: scale(.94); }
.auth-lang.on { border-color: var(--accent); color: var(--accent); }

/* —— 登录方式图标 tab —— */
.auth-method-tabs {
  display: flex; justify-content: center; gap: 34px;
  margin: 18px 0 6px;
}
.auth-method {
  position: relative; display: flex; flex-direction: column;
  align-items: center; gap: 5px; padding: 4px 6px 8px;
  border: 0; background: none; cursor: pointer;
  color: #999; transition: color .15s ease;
}
.auth-method-ico { display: block; transition: color .15s ease, transform .15s ease; }
.auth-method-label {
  font-size: calc(11px * var(--fs)); letter-spacing: .04em; color: currentColor;
}
.auth-method-badge {
  position: absolute; top: -2px; right: -14px;
  font-size: calc(9px * var(--fs)); line-height: 1; letter-spacing: .02em;
  padding: 2px 4px; border-radius: 7px; white-space: nowrap;
  color: #b26a00; background: #fff2d6; border: 1px solid #ffd98a;
}
.auth-method:hover { color: #6b6b6b; }
.auth-method::after {
  content: ""; position: absolute; left: 50%; bottom: 0; transform: translateX(-50%) scaleX(0);
  width: 32px; height: 2px; border-radius: 2px; background: var(--accent);
  transition: transform .16s ease;
}
.auth-method.active { color: var(--accent); }
.auth-method.active .auth-method-ico { transform: translateY(-1px); }
.auth-method.active::after { transform: translateX(-50%) scaleX(1); }

/* —— 表单面板 —— */
.auth-panels { margin-top: 10px; }
.auth-panel[hidden] { display: none; }
.auth-panel-wechat { text-align: center; }
.auth-wechat-box { padding: 14px 0 6px; }
.auth-wechat-ico { display: block; margin: 0 auto 10px; }
.auth-wechat-title {
  font-size: calc(14px * var(--fs)); color: var(--ink-2); font-weight: 600;
}
.auth-wechat-hint {
  margin-top: 4px; font-size: calc(11.5px * var(--fs)); color: var(--ink-3);
}

/* —— 登录/注册底部切换 —— */
.auth-switch-line {
  margin: 12px 0 0; text-align: center;
  font-size: calc(11.5px * var(--fs)); color: var(--ink-3);
}
.auth-switch-line a { color: var(--accent); text-decoration: none; font-weight: 600; }
.auth-switch-line a:hover { text-decoration: underline; }
.auth-note .legal-link { color: var(--ink-2); text-decoration: underline; text-underline-offset: 2px; }
.auth-note .legal-link:hover { color: var(--accent); }

/* —— 带图标的输入框 —— */
.auth-field { position: relative; }
.auth-field-ico {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--ink-3); pointer-events: none; z-index: 1;
}
.auth-field input { margin-top: 8px; padding-left: 38px !important; }
.auth-field-otp input,
.auth-field-ecode input { padding-right: 112px !important; }
.auth-otp-btn {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  height: 28px; padding: 0 10px; border-radius: 7px;
  border: 1px solid var(--accent); background: transparent; color: var(--accent);
  font-size: calc(11px * var(--fs)); font-weight: 600; white-space: nowrap;
  line-height: 1;
}
.auth-otp-btn:active { transform: translateY(-50%) scale(.95); }
.auth-otp-btn:disabled { opacity: .5; }
.auth-card input {
  width: 100%; margin-top: 8px; padding: 11px 12px;
  border: 1px solid var(--line); border-radius: 10px; outline: 0;
  font-size: calc(14px * var(--fs)); background: var(--paper-2);
}
.auth-card input:focus { border-color: var(--accent); background: var(--card); }
.auth-err {
  margin-top: 8px; font-size: calc(12px * var(--fs)); color: var(--accent);
  background: rgba(178,58,46,.07); border-radius: 8px; padding: 7px 10px;
}
.auth-submit {
  width: 100%; margin-top: 12px; padding: 11px 0;
  background: var(--accent); color: #fff; border-radius: 10px;
  font-size: calc(14px * var(--fs)); letter-spacing: .1em;
  box-shadow: 0 10px 22px -12px rgba(178,58,46,.75);
}
.auth-submit:disabled { opacity: .5; box-shadow: none; }
.auth-note {
  margin-top: 10px; font-size: calc(10.5px * var(--fs));
  color: var(--ink-3); text-align: center; line-height: 1.7;
}
.auth-icp {
  margin-top: 2px; font-size: calc(10px * var(--fs));
  color: var(--ink-3); text-align: center; line-height: 1.7;
}
.auth-icp a { color: var(--ink-3); text-decoration: none; }
.auth-icp a:hover { color: var(--accent); }
.auth-soon { color: var(--accent); font-weight: 500; margin-left: 4px; }

/* 用户信息页 */
.acct { max-width: 560px; margin: 0 auto; padding: 4px 18px 30px; }
.acct-back-row { padding: 6px 0 2px; }
.acct-back { padding: 6px 12px; font-size: calc(12px * var(--fs)); }
.acct-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 14px; margin-top: 10px;
}
.acct-user { display: flex; align-items: center; gap: 12px; }
.acct-avatar {
  width: 46px; height: 46px; border-radius: 50%; flex: 0 0 auto;
  background: var(--accent); color: #fff; display: grid; place-items: center;
  font-family: var(--serif); font-size: calc(19px * var(--fs));
}
.acct-id { flex: 1; min-width: 0; }
.acct-id b { display: block; font-size: calc(15px * var(--fs)); }
.acct-id span { display: block; font-size: calc(11.5px * var(--fs)); color: var(--ink-3);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct-badge {
  flex: 0 0 auto; font-size: calc(10.5px * var(--fs)); color: #8A6A1F;
  border: 1px solid rgba(169,138,75,.5); border-radius: 4px; padding: 2px 7px;
}
.acct-assets { display: grid; gap: 10px; }
.acct-asset { display: flex; align-items: center; gap: 10px; }
.acct-asset .lab { font-size: calc(11px * var(--fs)); color: var(--ink-3);
  letter-spacing: .16em; flex: 0 0 auto; }
.acct-asset b { flex: 1; font-family: var(--serif); font-size: calc(17px * var(--fs)); }
.acct-data { display: grid; grid-template-columns: 1fr 1fr 1fr; text-align: center; gap: 6px; }
.acct-data b { display: block; font-family: var(--serif); font-size: calc(17px * var(--fs)); }
.acct-data span { font-size: calc(10.5px * var(--fs)); color: var(--ink-3); }
.acct-list { margin-top: 10px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--card); overflow: hidden; }
.acct-item {
  width: 100%; display: flex; justify-content: space-between; align-items: center;
  padding: 13px 14px; font-size: calc(13.5px * var(--fs));
  border-bottom: 1px solid var(--line-2); background: transparent; text-align: left;
}
.acct-item:last-child { border-bottom: 0; }
.acct-item span { font-size: calc(11px * var(--fs)); color: var(--ink-3); }
.acct-item:disabled { opacity: .55; }
.acct-item:not(:disabled):active { background: var(--paper); }
.acct-logout {
  width: 100%; margin-top: 14px; padding: 12px 0;
  border: 1px solid rgba(178,58,46,.5); border-radius: 10px;
  color: var(--accent); font-size: calc(13.5px * var(--fs)); letter-spacing: .1em;
  background: transparent;
}

/* 管理员入口（用户弹层内，仅 role=admin/owner 显示）
 * 沿用 acct-item 的行内列表风格，整体作为独立卡片置于用户卡下方。 */
.acct-admin-link {
  width: 100%; margin-top: 10px;
  display: flex; justify-content: space-between; align-items: center;
  padding: 13px 14px; text-align: left;
  font-size: calc(13.5px * var(--fs));
  border: 1px solid rgba(26,107,79,.4); border-radius: 12px;
  background: rgba(26,107,79,.06); color: #1a6b4f;
}
.acct-admin-link span { font-size: calc(11px * var(--fs)); color: #1a6b4f; opacity: .75; }
.acct-admin-link:active { background: rgba(26,107,79,.12); }

/* ============================================================
   M2：定价 / 兑换面板 + 账户待支付行
   ============================================================ */
.acct-tail {
  margin-top: 6px; font-size: calc(11.5px * var(--fs)); color: var(--accent);
  background: rgba(178,58,46,.06); border-radius: 8px; padding: 7px 10px;
}
.price-plans { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.price-plan {
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 11px;
  background: var(--card);
}
.price-plan.on { border-color: var(--accent); box-shadow: 0 0 0 1px rgba(178,58,46,.25) inset; }
.pp-top { display: flex; justify-content: space-between; align-items: baseline; }
.pp-top b { font-size: calc(13.5px * var(--fs)); }
.pp-cur { font-size: calc(10px * var(--fs)); color: var(--accent);
  border: 1px solid rgba(178,58,46,.4); border-radius: 4px; padding: 1px 5px; }
.pp-price { font-family: var(--serif); font-size: calc(14px * var(--fs)); margin: 5px 0 6px; }
.pp-badge {
  font-size: calc(9.5px * var(--fs)); color: var(--accent); font-weight: 600;
  background: rgba(178,58,46,.08); border-radius: 4px; padding: 1px 5px;
  margin-left: auto; margin-right: 4px; white-space: nowrap;
}
.pp-note { font-size: calc(10px * var(--fs)); color: var(--ink-3); margin-top: 5px; }
.pp-rows { display: grid; grid-template-columns: 1fr auto; gap: 3px 8px;
  font-size: calc(11px * var(--fs)); color: var(--ink-2); }
.pp-rows span { color: var(--ink-3); }
.pp-buy { width: 100%; margin-top: 8px; }
.price-packs { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-top: 10px; }
.price-pack {
  border: 1px solid var(--line); border-radius: 10px; padding: 9px 8px;
  background: var(--paper-2); text-align: center;
}
.price-pack b { display: block; font-size: calc(12.5px * var(--fs)); }
.price-pack span { display: block; font-size: calc(11px * var(--fs)); color: var(--ink-3); margin: 2px 0; }
.price-pack em { font-style: normal; font-family: var(--serif);
  font-size: calc(13.5px * var(--fs)); display: block; margin-bottom: 6px; }
.redeem-row { display: flex; gap: 8px; margin-top: 12px; align-items: center; }
.redeem-row input {
  flex: 1; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--card); outline: 0; font-size: calc(13.5px * var(--fs));
}
.redeem-row input:focus { border-color: var(--accent); }

/* 学期包卡（M2 定价面板） */
.price-semester {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  margin-top: 10px; padding: 11px 12px;
  border: 1px dashed rgba(169,138,75,.65); border-radius: 10px;
  background: rgba(169,138,75,.06);
}
.price-semester b { font-size: calc(13.5px * var(--fs)); color: #8A6A1F; }
.price-semester span { display: block; font-size: calc(11.5px * var(--fs)); color: var(--ink-2);
  margin-top: 3px; }
.price-semester em { font-style: normal; font-size: calc(10.5px * var(--fs));
  color: var(--ink-3); flex: 0 0 auto; }

/* ============================================================
   M3：合规浮层（用户协议/隐私政策）+ AI 生成标识
   ============================================================ */
.legal-overlay {
  position: absolute; inset: 0; z-index: 50;
  background: rgba(38,32,26,.45); backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center; padding: 18px;
}
.legal-card {
  width: min(640px, 100%); max-height: 86%;
  background: var(--paper-2); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 30px 80px -30px rgba(38,32,26,.65);
  display: flex; flex-direction: column; overflow: hidden;
}
.legal-tabs {
  display: flex; gap: 6px; align-items: center;
  padding: 10px 14px; border-bottom: 1px solid var(--line-2);
  background: var(--card);
}
.legal-tab {
  padding: 6px 12px; border-radius: 8px; font-size: calc(12.5px * var(--fs));
  border: 1px solid var(--line); background: var(--paper-2); color: var(--ink-2);
}
.legal-tab.active { border-color: var(--accent); color: var(--accent); background: #FFFCF6; }
.legal-close { margin-left: auto; font-size: calc(14px * var(--fs)); color: var(--ink-3);
  padding: 4px 8px; }
.legal-body { overflow-y: auto; padding: 14px 18px 20px; font-size: calc(12.5px * var(--fs)); }
.legal-body h1 { font-family: var(--serif); font-size: calc(17px * var(--fs));
  margin: 6px 0 10px; }
.legal-body .msg-h { margin-top: 14px; }

/* 帮助中心浮层 */
.help-overlay {
  position: absolute; inset: 0; z-index: 55;
  background: rgba(38,32,26,.45); backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center; padding: 18px;
}
.help-card {
  width: min(640px, 100%); max-height: 86%;
  background: var(--paper-2); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 30px 80px -30px rgba(38,32,26,.65);
  display: flex; flex-direction: column; overflow: hidden;
}
.help-head {
  display: flex; gap: 8px; align-items: center;
  padding: 10px 14px; border-bottom: 1px solid var(--line-2);
  background: var(--card);
}
.help-head-icon { font-size: calc(15px * var(--fs)); }
.help-title {
  font-family: var(--serif); font-size: calc(15px * var(--fs));
  margin: 0; color: var(--ink);
}
.help-close { margin-left: auto; font-size: calc(14px * var(--fs)); color: var(--ink-3);
  padding: 4px 8px; background: none; border: 0; cursor: pointer; }
.help-close:hover { color: var(--accent); }
.help-body { overflow-y: auto; padding: 12px 16px 20px; font-size: calc(12.5px * var(--fs)); }
.help-sec {
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--card); padding: 12px 14px; margin-bottom: 10px;
}
.help-sec-head { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.help-sec-icon { font-size: calc(16px * var(--fs)); line-height: 1; }
.help-sec-head b {
  font-family: var(--serif); font-size: calc(13.5px * var(--fs)); color: var(--ink);
}
.help-sec ul { margin: 4px 0 0; padding-left: 19px; }
.help-sec li { margin: 4px 0; line-height: 1.7; color: var(--ink-2); }
.help-sec p { margin: 4px 0; line-height: 1.7; color: var(--ink-2); }
.help-sec b { color: var(--accent-2); }
.help-sec .help-warn { color: var(--accent); }
.help-mail { color: var(--accent); text-decoration: none; }
.help-mail:hover { text-decoration: underline; }

.ai-gen {
  display: inline-block; margin-left: 6px; font-size: calc(11px * var(--fs));
  opacity: .75; cursor: help; vertical-align: baseline;
}

/* 速读 · 主题关联输入行 */
.theme-row { display: flex; gap: 8px; margin-top: 2px; }
.theme-row input {
  flex: 1; min-width: 0; padding: 8px 11px;
  border: 1px solid var(--line); border-radius: 9px;
  background: var(--paper-2); outline: 0;
  font-size: calc(12.5px * var(--fs));
}
.theme-row input:focus { border-color: var(--accent); background: var(--card); }
.theme-row .mini-btn { flex: 0 0 auto; padding: 8px 12px; }
#theme-body .ai-error { color: var(--accent); }

/* 速读 · 主题追问对话 */
#theme-discuss-body:empty { display: none; }
#theme-discuss-body { margin-top: 8px; }
.discuss-ask {
  margin: 10px 0 6px; padding: 7px 11px;
  background: var(--paper-2); border-left: 3px solid var(--accent);
  border-radius: 0 8px 8px 0; font-size: calc(12.5px * var(--fs));
  color: var(--ink); white-space: pre-wrap; word-break: break-word;
}
.discuss-ans {
  padding: 2px 0 9px; border-bottom: 1px dashed var(--line);
}
.discuss-ans:last-child { border-bottom: 0; }

/* 组织（Phase 1） */
.org-list { padding: 4px 18px 24px; display: flex; flex-direction: column; gap: 10px; }
.org-card {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--card); cursor: pointer;
}
.org-card-main { display: flex; flex-direction: column; gap: 2px; }
.org-card-main b { font-size: calc(14px * var(--fs)); }
.org-role {
  display: inline-block; font-size: calc(10.5px * var(--fs)); color: var(--muted, #8a8a8a);
  border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; margin-left: 6px;
}
.org-go { color: var(--muted, #8a8a8a); font-size: 18px; }
.org-head { display: flex; flex-direction: column; gap: 4px; }
.org-head b { font-size: calc(16px * var(--fs)); }
.org-pages { font-size: calc(12px * var(--fs)); color: var(--muted, #8a8a8a); }
.org-invite-row { display: flex; gap: 8px; padding: 10px 18px; }
.org-sec-t { font-size: calc(12.5px * var(--fs)); color: var(--muted, #8a8a8a); margin-bottom: 8px; }
.org-member, .org-doc {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 0; border-bottom: 1px solid var(--line);
}
.org-member-main { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.org-member-main span { font-size: calc(11px * var(--fs)); color: var(--muted, #8a8a8a); }
.org-vis { font-size: calc(10.5px * var(--fs)); color: var(--muted, #8a8a8a); }

/* 组织管理员监控审核（PRJ-2628） */
.org-usage { font-size: calc(10.5px * var(--fs)); color: var(--muted, #8a8a8a); }
.org-counts { font-size: calc(10.5px * var(--fs)); color: var(--muted, #8a8a8a); margin-left: 6px; }
.org-rev { border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; margin-left: 6px; }
.org-rev-pending { color: #b26a00; border-color: rgba(178,106,0,.5); }
.org-rev-approved { color: #2e7d32; border-color: rgba(46,125,50,.5); }
.org-rev-takedown { color: var(--accent); border-color: rgba(178,58,46,.55); }
.org-doc .org-review { margin-left: 6px; }

/* 馆藏（M5.3） */
.col-list { padding: 4px 18px 24px; display: flex; flex-direction: column; gap: 10px; }
.col-card {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--card); cursor: pointer;
}
.col-card-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.col-card-main b { font-size: calc(14px * var(--fs)); }
.col-card-main span { font-size: calc(11px * var(--fs)); color: var(--muted, #8a8a8a); }
.col-vis {
  font-size: calc(10.5px * var(--fs)); color: var(--muted, #8a8a8a);
  border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; margin-left: 6px;
}
.col-actions { display: flex; gap: 8px; padding: 10px 18px; flex-wrap: wrap; }
.col-item, .col-doc {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 0; border-bottom: 1px solid var(--line);
}
.col-doc-main { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.col-doc-main span { font-size: calc(11px * var(--fs)); color: var(--muted, #8a8a8a); }

/* 组队（M5.4） */
.team-card {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--card); cursor: pointer;
}
.team-card-main { display: flex; flex-direction: column; gap: 2px; }
.team-card-main b { font-size: calc(14px * var(--fs)); }
.team-badge {
  font-size: calc(10.5px * var(--fs)); color: var(--accent);
  border: 1px solid var(--accent); border-radius: 6px; padding: 1px 6px; margin-left: 6px;
}

/* 注册/登录页 · 小屏适配 */
@media (max-width: 380px) {
  .auth-method-tabs { gap: 22px; }
  .auth-method-ico { width: 26px; height: 26px; }
  .auth-brand-name { font-size: calc(20px * var(--fs)); }
}

/* —— P0 注册协议勾选 —— */
.auth-consent { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.auth-consent-row {
  display: flex; align-items: flex-start; gap: 8px;
  font-size: calc(11.5px * var(--fs)); color: var(--ink-2); line-height: 1.55;
  cursor: pointer; user-select: none;
}
.auth-consent-row input[type="checkbox"] {
  width: 15px; height: 15px; margin: 1px 0 0; flex: 0 0 auto;
  accent-color: var(--accent); cursor: pointer;
}
.auth-consent-row .legal-link { color: var(--accent); text-decoration: none; font-weight: 600; }
.auth-consent-row .legal-link:hover { text-decoration: underline; }

/* —— 页脚法务链接 —— */
.site-footer {
  padding: 18px 16px 26px; margin-top: 8px;
  text-align: center; border-top: 1px solid var(--line);
}
.footer-links {
  display: flex; align-items: center; justify-content: center; flex-wrap: wrap;
  gap: 6px; font-size: calc(11.5px * var(--fs));
}
.footer-links a { color: var(--ink-2); text-decoration: none; }
.footer-links a:hover { color: var(--accent); text-decoration: underline; }
.footer-sep { color: var(--line); }
.footer-meta {
  margin-top: 7px; font-size: calc(10.5px * var(--fs)); color: var(--ink-3);
  display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 6px;
}
.footer-meta a { color: var(--ink-3); text-decoration: none; }
.footer-meta a:hover { color: var(--accent); text-decoration: underline; }
.footer-icp { color: var(--ink-3); }
.footer-copy {
  margin-top: 8px; font-size: calc(10.5px * var(--fs)); color: var(--ink-3);
}
.legal-open-page {
  margin-left: auto; margin-right: 8px; font-size: 12px;
  text-decoration: none; color: var(--accent); border: 1px solid var(--line);
  border-radius: 7px; padding: 4px 10px; background: #fff;
}
.legal-open-page:hover { border-color: var(--accent); }

/* —— P0 上传区非 OCR 提示 —— */
.upload-hint {
  margin: 6px 18px 4px;
  padding: 8px 11px;
  font-size: calc(11px * var(--fs));
  line-height: 1.6;
  color: #8a5a12;
  background: rgba(191, 141, 32, .10);
  border: 1px solid rgba(191, 141, 32, .28);
  border-radius: 9px;
}
