/* ==========================================================================
   HappyReading — 设计基线（2026-08 v2：蓝白清爽风，对齐本地版观感）
   白底 + 单一蓝色强调（#3b6cf6）+ 大量留白；文献条目为扁平行（悬停浮起），
   不做深色块 / 金色 / 衬线。颜色 / 圆角 / 阴影统一走变量。
   ========================================================================== */
:root {
  /* 主色（与本地版一致） */
  --accent: #3b6cf6;
  --accent-dark: #2a55d8;
  --accent-soft: #e8efff;
  --accent-border: #c9d9ff;
  --accent-2: #0f9b8e;

  /* 表面与文字 */
  --bg: #f5f7fb;
  --panel: #ffffff;
  --surface-2: #f7f9fc;
  --border: #e3e8f0;
  --border-strong: #cbd4e1;
  --text: #1f2937;
  --text-2: #5b6472;
  --muted: #94a0b3;

  /* 语义色 */
  --ok: #2e9e44;
  --ok-soft: #e7f6ec;
  --warn: #b7791f;
  --warn-soft: #fdf3e2;
  --danger: #c9372c;
  --danger-soft: #fdeceb;
  --danger-border: #f4c7c3;

  /* 阅读区：中性冷灰，保证 PDF 底图观感 */
  --reader-bg: #dde1e8;

  /* 圆角 */
  --r-sm: 7px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-pill: 999px;

  /* 阴影：1 贴地 / 2 悬浮 / 3 弹层 */
  --sh-1: 0 1px 3px rgba(23, 32, 60, .05);
  --sh-2: 0 4px 14px rgba(23, 32, 60, .08);
  --sh-3: 0 18px 48px rgba(23, 32, 60, .18);
  --shadow: var(--sh-1);

  --ring: 0 0 0 3px rgba(59, 108, 246, .15);
}

* { box-sizing: border-box; }
/* hidden 属性优先于任何 display：组件用 display:flex/inline-flex 时，UA 默认的 [hidden]
   会被覆盖。这里统一兜底一次。 */
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  font-family: "Segoe UI", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea { font-family: inherit; }
:focus-visible { outline: none; box-shadow: var(--ring); }

/* 首页可整页滚动；阅读页锁定高度由内部滚动 */
body[data-page="home"] { overflow: auto; }
body[data-page="reader"] { overflow: hidden; }

/* 细滚动条：整站统一 */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border: 3px solid transparent; background-clip: content-box; border-radius: var(--r-pill); }
*::-webkit-scrollbar-thumb:hover { background: var(--muted); background-clip: content-box; }

/* ==========================================================================
   1. 站点顶栏（白底，两个视图共用）
   ========================================================================== */
#siteHeader {
  display: flex; align-items: center; gap: 20px;
  padding: 0 24px; height: 56px; flex: 0 0 auto;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  z-index: 20;
}
.brand {
  display: inline-flex; align-items: center; gap: 8px;
  color: var(--text); text-decoration: none; white-space: nowrap;
}
.brand-mark { font-size: 19px; }
.brand-text {
  font-weight: 700; font-size: 16.5px; letter-spacing: .2px;
  display: inline-flex; align-items: baseline; gap: 10px;
}
.brand-sub {
  font-weight: 400; font-size: 12px; color: var(--muted); letter-spacing: .5px;
  border-left: 1px solid var(--border); padding-left: 10px;
}
.site-nav { display: flex; align-items: center; gap: 2px; }
.nav-link {
  background: none; border: none; cursor: pointer;
  color: var(--text-2); font-size: 13.5px; padding: 8px 13px;
  border-radius: var(--r-sm); transition: color .15s, background .15s;
  position: relative;
}
.nav-link:hover { color: var(--text); background: var(--surface-2); }
.nav-link.active { color: var(--accent); font-weight: 600; }
.nav-link.active::after {
  content: ""; position: absolute; left: 13px; right: 13px; bottom: 2px;
  height: 2px; border-radius: 2px; background: var(--accent);
}
.head-right { margin-left: auto; display: flex; align-items: center; gap: 9px; }
.head-btn {
  padding: 6px 16px; border-radius: var(--r-sm); font-size: 13px; cursor: pointer;
  white-space: nowrap; transition: background .15s, border-color .15s, color .15s;
}
.head-btn-ghost {
  background: var(--panel); color: var(--text-2); border: 1px solid var(--border);
}
.head-btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.head-btn-gold {
  background: var(--accent); color: #fff; border: 1px solid transparent; font-weight: 600;
}
.head-btn-gold:hover { background: var(--accent-dark); }
.user-chip {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text); padding: 4px 12px 4px 5px; border-radius: var(--r-pill);
  font-size: 13px; cursor: pointer; transition: border-color .15s, background .15s;
}
.user-chip:hover { border-color: var(--accent); background: var(--accent-soft); }

/* 顶栏翻译进度胶囊 */
.head-prog {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--surface-2); border: 1px solid var(--border);
  padding: 5px 12px; border-radius: var(--r-pill); font-size: 12px; color: var(--text-2);
}
.head-prog-label { white-space: nowrap; }
.tb-prog-track {
  width: 90px; height: 6px; background: var(--border);
  border-radius: var(--r-pill); overflow: hidden; display: inline-block;
}
.tb-prog-track i {
  display: block; height: 100%; width: 0; border-radius: var(--r-pill);
  background: linear-gradient(90deg, var(--accent), #6f95ff); transition: width .4s ease;
}

/* ==========================================================================
   2. 文献库浮层框（方案 A：阅读器是唯一视图，文献列表收进浮层）
   ========================================================================== */
.quota-badge {
  padding: 4px 12px; border-radius: var(--r-pill);
  background: var(--accent-soft); border: 1px solid var(--accent-border); color: var(--accent-dark);
  font-size: 12px; white-space: nowrap;
}
.quota-badge.warn { background: var(--danger-soft); border-color: var(--danger-border); color: var(--danger); }

/* ---- 文献库浮层框 ---- */
/* 层级排在顶栏(20)/工具栏(10)之上、个人中心(70)与登录/上传弹窗(1000)之下：
   从框里点「我的文献」（未登录弹登录框）或「⬆ 上传 PDF 翻译」时，弹窗必须盖在框上面。 */
#libSheet { z-index: 50; }
.sheet-card {
  width: min(760px, 100%); max-height: 84vh; background: var(--panel);
  border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--sh-3);
  display: flex; flex-direction: column; overflow: hidden;
}
.sheet-head {
  display: flex; align-items: center; gap: 14px; padding: 0 18px;
  border-bottom: 1px solid var(--border);
}
.sheet-tabs { display: flex; gap: 22px; }
.sheet-tab {
  background: none; border: none; cursor: pointer; padding: 15px 2px 13px;
  font-size: 15px; font-weight: 600; color: var(--muted);
  position: relative; transition: color .15s;
}
.sheet-tab:hover { color: var(--text-2); }
.sheet-tab.active { color: var(--accent); }
.sheet-tab.active::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px;
  height: 2px; border-radius: 2px; background: var(--accent);
}
.sheet-head-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.sheet-head-right .modal-close { position: static; }
.sheet-search { padding: 12px 18px 0; }
.sheet-search input {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border);
  border-radius: var(--r-md); font: inherit; font-size: 13.5px; color: var(--text);
  background: var(--panel); outline: none;
}
.sheet-search input:focus { border-color: var(--accent); box-shadow: var(--ring); }
.sheet-cats { display: flex; flex-wrap: wrap; gap: 6px; padding: 12px 18px 0; }
.sheet-list { padding: 8px 10px 16px; overflow-y: auto; flex: 1; }

/* 分类芯片（浮层框内 #homeCats、个人中心复用） */
.lib-cat {
  font-size: 12px; padding: 3px 11px; border-radius: var(--r-pill);
  border: 1px solid var(--border); background: var(--bg); color: var(--text-2);
  cursor: pointer; transition: border-color .15s, background .15s, color .15s;
}
.lib-cat:hover { border-color: var(--accent); color: var(--accent); }
.lib-cat.active { background: var(--accent); color: #fff; border-color: transparent; }
.lib-empty { color: var(--muted); text-align: center; padding: 50px 20px; font-size: 13.5px; line-height: 1.9; }
.space-list { flex: 1; overflow-y: auto; padding: 12px 22px 22px; }
.sp-empty { color: var(--muted); text-align: center; padding: 46px 20px; font-size: 13.5px; }

/* ---- 文献条目：扁平行，公共文献与我的文献共用 ---- */
.doc-row {
  padding: 13px 12px; border-radius: var(--r-md); cursor: pointer;
  border: 1px solid transparent; transition: background .14s, border-color .14s;
}
.doc-row + .doc-row { border-top: 1px solid var(--border); border-radius: 0; }
.doc-row:hover { background: var(--bg); border-color: var(--border); border-radius: var(--r-md); }
.doc-row-todo { cursor: default; }
.doc-row-todo:hover { background: none; border-color: transparent; }

/* 中文题在上、英文题在下 */
.t-zh {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font-weight: 600; font-size: 15.5px; line-height: 1.55; color: var(--text); word-break: break-word;
}
.t-en {
  font-family: Georgia, "Times New Roman", serif; font-style: italic;
  font-size: 12.5px; line-height: 1.5; color: var(--muted); margin-top: 3px; word-break: break-word;
}
.doc-cat {
  display: inline-block; margin-top: 7px; font-size: 11.5px; padding: 1px 9px;
  border-radius: var(--r-pill); background: var(--accent-soft);
  border: 1px solid var(--accent-border); color: var(--accent-dark);
}
.doc-meta { margin-top: 7px; font-size: 12.5px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.doc-journal { font-family: Georgia, "Times New Roman", serif; }
.doc-sum { margin-top: 7px; font-size: 12.5px; line-height: 1.75; color: var(--text-2); }
.doc-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.doc-tag {
  font-size: 11.5px; padding: 2px 9px; border-radius: var(--r-pill);
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2);
}
.doc-prog { display: flex; align-items: center; gap: 9px; margin-top: 9px; font-size: 12px; color: var(--text-2); }
.doc-prog-track { flex: 1; max-width: 190px; height: 4px; background: var(--border); border-radius: var(--r-pill); overflow: hidden; }
.doc-prog-track i { display: block; height: 100%; background: var(--accent); }
.doc-prog.done .doc-prog-txt { color: var(--ok); }
.doc-err { margin-top: 7px; font-size: 12.5px; line-height: 1.7; color: var(--danger); }
.doc-acts { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 10px; }
.doc-acts .ctrl-btn { padding: 3px 11px; font-size: 12px; background: var(--bg); }
.doc-del { color: var(--danger); }
.doc-del:hover { background: var(--danger-soft); border-color: var(--danger-border); color: var(--danger); }
.st { font-size: 11.5px; padding: 1px 9px; border-radius: var(--r-pill); border: 1px solid; white-space: nowrap; font-weight: 500; }
.st-run { color: var(--warn); background: var(--warn-soft); border-color: var(--warn); }
.st-fail { color: var(--danger); background: var(--danger-soft); border-color: var(--danger-border); }
.st-pub { color: var(--ok); background: var(--ok-soft); border-color: var(--ok); }

@media (max-width: 560px) {
  .sheet-card { max-height: 92vh; }
  .sheet-head, .sheet-search, .sheet-cats { padding-left: 14px; padding-right: 14px; }
}

/* ==========================================================================
   3. 阅读视图：工具栏 + 左右分栏
   ========================================================================== */
.reader-view { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.topbar {
  display: flex; align-items: center; padding: 9px 18px; flex: 0 0 auto;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--sh-1);
  z-index: 10;
}
.topbar-controls { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.tb-group { display: flex; align-items: center; gap: 8px; }
.tb-sep { width: 1px; height: 22px; background: var(--border); flex: 0 0 auto; }
.spacer { flex: 1; min-width: 8px; }
.back-btn { font-weight: 600; color: var(--accent); }
.reader-title {
  font-weight: 600; font-size: 14px; color: var(--text);
  max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* 入口按钮（保留类名，供弹窗内复用） */
.file-btn {
  background: var(--accent); color: #fff; border: 1px solid transparent;
  padding: 7px 15px; border-radius: var(--r-sm); font-weight: 600;
  font-size: 13px; cursor: pointer; white-space: nowrap;
  box-shadow: var(--sh-1); transition: background .15s, box-shadow .15s, transform .1s;
}
.file-btn:hover { background: var(--accent-dark); box-shadow: var(--sh-2); }

/* 次级按钮：白底描边 */
.ctrl-btn {
  background: var(--panel); color: var(--text-2); border: 1px solid var(--border);
  padding: 6px 12px; border-radius: var(--r-sm); font-size: 13px; cursor: pointer;
  white-space: nowrap; transition: background .15s, border-color .15s, color .15s;
}
.ctrl-btn:hover { background: var(--surface-2); border-color: var(--border-strong); color: var(--text); }
.ctrl-btn.ctrl-accent { background: var(--accent); border-color: transparent; color: #fff; font-weight: 600; }
.ctrl-btn.ctrl-accent:hover { background: var(--accent-dark); color: #fff; }
.ctrl-btn:disabled, .file-btn:disabled { opacity: .42; cursor: default; box-shadow: none; }
.ctrl-btn:disabled:hover { background: var(--panel); border-color: var(--border); color: var(--text-2); }

.file-name {
  font-size: 12px; color: var(--muted); max-width: 190px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* 翻页 / 缩放 / 对照滚动 */
.pdf-toolbar {
  display: flex; align-items: center; gap: 6px; padding: 3px 8px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r-md); font-size: 13px;
}
.mini {
  border: 1px solid transparent; background: transparent; border-radius: var(--r-sm);
  width: 28px; height: 26px; cursor: pointer; font-size: 16px; line-height: 1; color: var(--text-2);
}
.mini:hover { background: var(--panel); border-color: var(--border); color: var(--text); }
.page-indicator { display: flex; align-items: center; gap: 4px; color: var(--muted); }
.page-indicator input {
  width: 46px; padding: 3px 4px; border: 1px solid var(--border); border-radius: var(--r-sm);
  text-align: center; background: var(--panel); color: var(--text);
}
.divider-v { width: 1px; height: 16px; background: var(--border-strong); margin: 0 3px; }
#zoomLabel { min-width: 42px; text-align: center; color: var(--muted); }
.ctx-toggle { font-size: 12px; color: var(--text-2); display: flex; align-items: center; gap: 5px; cursor: pointer; }

/* 作者背景下拉 */
.author-wrap { position: relative; display: inline-block; }
.author-panel {
  position: absolute; top: calc(100% + 8px); left: 0; z-index: 60;
  width: min(460px, 80vw); max-height: 60vh; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--sh-3); padding: 16px 20px;
}
.author-panel-h { font-weight: 700; color: var(--accent); margin-bottom: 10px; font-size: 14px; }
.author-panel p { font-size: 13.5px; line-height: 1.85; color: var(--text-2); margin: 0 0 10px; text-align: justify; }
.author-panel p:last-child { margin-bottom: 0; }

/* 左右分栏 */
.layout { flex: 1; display: flex; min-height: 0; }
.pane { display: flex; flex-direction: column; min-height: 0; min-width: 0; flex: 1 1 50%; }
.layout > .pane:first-of-type { border-right: 1px solid var(--border); }
.splitter { width: 6px; cursor: col-resize; background: transparent; flex: 0 0 auto; transition: background .15s; }
.splitter:hover { background: var(--accent); opacity: .28; }

.pane-head {
  display: flex; align-items: center; gap: 10px; padding: 8px 16px; flex: 0 0 auto;
  background: var(--panel); border-bottom: 1px solid var(--border); font-size: 13px;
}
.pane-title { font-weight: 600; color: var(--text); position: relative; padding-left: 11px; }
.pane-title::before {
  content: ""; position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  width: 3px; height: 13px; border-radius: 2px; background: var(--accent);
}
.pane:last-of-type .pane-title::before { background: var(--accent-2); }
.pane-tip { color: var(--muted); font-size: 12px; }
.gzh-link {
  margin-left: auto; color: #07a854; font-size: 12px; font-weight: 600;
  text-decoration: none; white-space: nowrap;
  background: #e9f9f0; border: 1px solid #bfe9d2; padding: 3px 10px; border-radius: var(--r-pill);
}
.gzh-link:hover { background: #d9f4e5; }

.pdf-scroll { flex: 1; overflow: auto; background: var(--reader-bg); padding: 20px 16px; }
.pages-wrap { display: flex; flex-direction: column; align-items: center; gap: 18px; }
.pdf-page {
  position: relative; background: #fff; border-radius: 3px;
  box-shadow: 0 1px 2px rgba(16,24,40,.10), 0 10px 28px rgba(16,24,40,.12);
}
.pdf-page canvas { display: block; border-radius: 3px; }
.pdf-page .page-label {
  position: absolute; top: 8px; right: 10px; z-index: 5; font-size: 11px; color: #fff;
  background: rgba(31,41,55,.55); padding: 2px 8px; border-radius: var(--r-pill); pointer-events: none;
}
.pdf-page .page-zoom {
  position: absolute; top: 8px; left: 10px; z-index: 6;
  border: none; background: rgba(31,41,55,.55); color: #fff; cursor: pointer;
  font-size: 12px; line-height: 1; padding: 4px 8px; border-radius: var(--r-pill);
  opacity: 0; transition: opacity .15s, background .15s;
}
.pdf-page:hover .page-zoom { opacity: 1; }
.pdf-page .page-zoom:hover { background: var(--accent); }

/* 空状态 */
.empty-hint {
  color: var(--text-2); text-align: center; margin: auto; padding: 30px 24px;
  max-width: 340px; line-height: 1.75;
}
.empty-icon { font-size: 46px; opacity: .45; margin-bottom: 6px; }
.empty-hint p { margin: 0; font-size: 13.5px; }

/* 中文就地覆盖层 */
.zh-layer { position: absolute; inset: 0; }
.zh-box {
  position: absolute; overflow: hidden; box-sizing: border-box;
  background: #fff; color: #111; line-height: 1.16; padding: 0 1px;
  font-family: "Microsoft YaHei","PingFang SC","Source Han Sans SC",sans-serif;
  word-break: break-word; white-space: normal; text-align: justify;
}
.zh-box.zh-head { font-weight: 700; color: #15428b; text-align: left; }

/* PDF.js 文本层（划词选择） */
.textLayer { position: absolute; inset: 0; overflow: hidden; opacity: 1; line-height: 1; }
.textLayer > span { color: transparent; position: absolute; white-space: pre; cursor: text; transform-origin: 0% 0%; }
.textLayer ::selection { background: rgba(59,108,246,.32); }

/* 放大查看弹窗 */
.zoom-modal { position: fixed; inset: 0; z-index: 100; background: rgba(16,24,40,.72); display: flex; flex-direction: column; }
.zoom-bar {
  display: flex; align-items: center; gap: 12px; padding: 9px 18px;
  background: var(--panel); border-bottom: 1px solid var(--border); font-size: 13px;
}
.zoom-bar button {
  border: 1px solid var(--border); background: var(--panel); border-radius: var(--r-sm);
  cursor: pointer; padding: 4px 11px; font-size: 14px; color: var(--text-2);
}
.zoom-bar button:hover { background: var(--surface-2); color: var(--text); }
.zoom-bar .zoom-pct { min-width: 50px; text-align: center; color: var(--muted); }
.zoom-bar .zoom-hint { color: var(--muted); font-size: 12px; }
.zoom-bar .zoom-close { margin-left: auto; }
.zoom-body { flex: 1; overflow: auto; padding: 20px; }
.zoom-list { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.zoom-stage { position: relative; background: #fff; border-radius: 3px; box-shadow: 0 6px 30px rgba(0,0,0,.4); }
.zoom-stage canvas { display: block; }
.zoom-overlay { position: absolute; inset: 0; }

/* 阅读进度恢复提示 */
.resume-toast {
  position: fixed; right: 20px; bottom: 20px; z-index: 200;
  background: rgba(31,41,55,.94); color: #fff; font-size: 13px;
  padding: 11px 15px; border-radius: var(--r-md); box-shadow: var(--sh-3);
  display: flex; align-items: center; gap: 6px;
}
.resume-toast button {
  border: 1px solid rgba(255,255,255,.35); background: transparent; color: #fff;
  border-radius: var(--r-sm); padding: 4px 11px; font-size: 12px; cursor: pointer;
}
.resume-toast button:hover { background: rgba(255,255,255,.16); }

/* ==========================================================================
   4. 弹窗通用
   ========================================================================== */
.modal-mask {
  position: fixed; inset: 0; background: rgba(23,32,60,.42); backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center; z-index: 1000;
}
.modal-mask[hidden] { display: none; }
.modal-card {
  position: relative; background: var(--panel); border-radius: var(--r-lg);
  padding: 24px 28px; max-width: 680px; width: calc(100% - 32px);
  max-height: calc(100% - 48px); overflow: auto; box-shadow: var(--sh-3);
}
.modal-card h2 { margin: 0 0 16px; font-size: 17.5px; }
.modal-close {
  position: absolute; top: 12px; right: 14px; border: none; background: none;
  font-size: 24px; line-height: 1; cursor: pointer; color: var(--muted);
  width: 30px; height: 30px; border-radius: var(--r-sm);
}
.modal-close:hover { background: var(--surface-2); color: var(--text); }
.modal-msg { font-size: 12.5px; color: var(--muted); margin: 6px 0 0; line-height: 1.7; word-break: break-word; }
.modal-msg.error { color: var(--danger); }

.form-row { display: flex; align-items: center; gap: 8px; margin-bottom: 11px; }
.form-row input[type="text"], .form-row input[type="email"] {
  flex: 1; min-width: 0; padding: 9px 11px; border: 1px solid var(--border); border-radius: var(--r-md);
  font-size: 13.5px; background: var(--bg); color: inherit;
}
.form-row input:focus { outline: none; border-color: var(--accent); background: var(--panel); box-shadow: var(--ring); }

button.primary {
  background: var(--accent); color: #fff; border: none; padding: 8px 16px;
  border-radius: var(--r-sm); font-size: 13px; font-weight: 600; cursor: pointer;
  transition: background .15s;
}
button.primary:hover { background: var(--accent-dark); }
button.primary:disabled { background: #b9c6ec; cursor: default; }
button.ghost {
  background: var(--panel); border: 1px solid var(--border); padding: 6px 12px;
  border-radius: var(--r-sm); font-size: 12.5px; cursor: pointer; color: var(--text-2);
  transition: background .15s, border-color .15s, color .15s;
}
button.ghost:hover { background: var(--surface-2); border-color: var(--border-strong); color: var(--text); }

.upload-note {
  margin-top: 18px; font-size: 12px; color: var(--text-2); line-height: 1.7;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 10px 13px;
}
.upload-quota { margin: -6px 0 12px; font-size: 12.5px; color: var(--accent-dark); }
.upload-quota.warn { color: var(--danger); }
.upload-progress { margin-top: 8px; }
.progress-track { height: 9px; background: var(--border); border-radius: var(--r-pill); overflow: hidden; }
.progress-track .progress-bar {
  height: 100%; width: 0; border-radius: var(--r-pill);
  background: linear-gradient(90deg, var(--accent), #6f95ff); transition: width .4s ease;
}

#loginModal .modal-card { max-width: 400px; }
#uploadModal .modal-card { max-width: 460px; }

/* 登录 / 注册 / 找回密码 */
.auth-card h2 { text-align: center; margin-bottom: 18px; }
.login-tabs { display: flex; gap: 6px; margin-bottom: 16px; background: var(--surface-2); padding: 4px; border-radius: var(--r-md); }
.login-tab {
  flex: 1; padding: 8px 0; border: none; background: transparent;
  border-radius: var(--r-sm); cursor: pointer; font-size: 13px; color: var(--text-2);
  transition: background .15s, color .15s;
}
.login-tab:hover { color: var(--text); }
.login-tab.active { background: var(--panel); color: var(--accent); font-weight: 600; box-shadow: var(--sh-1); }
.login-panel { display: flex; flex-direction: column; gap: 11px; }
.login-panel[hidden] { display: none; } /* display:flex 会覆盖 UA 的 [hidden]，需显式兜底 */
.login-panel input {
  padding: 10px 11px; border: 1px solid var(--border); border-radius: var(--r-md);
  font-size: 14px; background: var(--bg); color: inherit;
}
.login-panel input:focus { outline: none; border-color: var(--accent); background: var(--panel); box-shadow: var(--ring); }
.login-panel .form-row { margin-bottom: 0; }
.login-panel .primary { padding: 10px 16px; font-size: 14px; }
.pw-wrap { position: relative; }
.pw-wrap input { width: 100%; padding-right: 38px; }
.pw-toggle {
  position: absolute; right: 5px; top: 50%; transform: translateY(-50%);
  width: 28px; height: 28px; border: none; background: none; cursor: pointer;
  font-size: 15px; line-height: 1; padding: 0; border-radius: var(--r-sm);
}
.pw-toggle:hover { background: var(--bg); }
.pw-change-box {
  margin-top: 12px; padding: 12px 14px;
  border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface-2);
  display: flex; flex-direction: column; gap: 9px;
}
.login-tip { font-size: 12px; color: var(--muted); margin: 0; line-height: 1.7; }
.login-tip .go-reg { color: var(--accent); cursor: pointer; font-weight: 600; }
.avatar-row { display: flex; align-items: center; gap: 8px; }
.avatar-row .file-name { max-width: 180px; }

/* 使用指南：三步上手 + 功能卡片 */
.help-card { max-width: 660px; }
.help-body { max-height: 66vh; overflow-y: auto; padding-right: 4px; }
.help-steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.help-step {
  position: relative; background: var(--accent-soft); border: 1px solid var(--accent-border);
  border-radius: var(--r-md); padding: 12px 13px 11px;
}
.help-step-n {
  display: inline-flex; align-items: center; justify-content: center;
  width: 21px; height: 21px; border-radius: 50%; background: var(--accent); color: #fff;
  font-size: 12px; font-weight: 700; margin-bottom: 7px;
}
.help-step b { display: block; font-size: 13px; color: var(--text); }
.help-step p { margin: 5px 0 0; font-size: 12px; line-height: 1.7; color: var(--text-2); }
.help-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 12px; }
.help-item {
  border: 1px solid var(--border); border-radius: var(--r-md); padding: 11px 13px;
  background: var(--panel);
}
.help-item > b { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text); }
.help-item p { margin: 5px 0 0; font-size: 12.3px; line-height: 1.7; color: var(--text-2); }
.help-note {
  margin: 12px 0 0; font-size: 12.5px; line-height: 1.7; color: var(--text-2);
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 9px 13px;
}
@media (max-width: 560px) {
  .help-steps { grid-template-columns: 1fr; }
  .help-grid { grid-template-columns: 1fr; }
}

/* 头像 */
.avatar { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; vertical-align: middle; }
.avatar-fallback {
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-size: 13px; font-weight: 600; background: var(--accent-2);
}
.top-uname { margin-left: 2px; }

/* ==========================================================================
   5. 个人中心（弹窗：浅色左导航 + 右内容）
   ========================================================================== */
.profile-overlay {
  position: fixed; inset: 0; background: rgba(23,32,60,.42); backdrop-filter: blur(2px); z-index: 70;
  display: flex; align-items: center; justify-content: center;
}
.profile-overlay[hidden] { display: none; }
.profile-box {
  display: flex; width: min(920px, 95vw); height: min(86vh, 760px);
  background: var(--panel); border-radius: var(--r-lg); overflow: hidden; box-shadow: var(--sh-3);
}
.profile-side {
  width: 230px; min-width: 230px; background: var(--surface-2);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 18px 12px 14px;
}
.profile-side-head { display: flex; align-items: center; gap: 11px; padding: 0 6px 16px; border-bottom: 1px solid var(--border); }
.profile-avatar-box .avatar { width: 52px; height: 52px; font-size: 24px; }
.profile-info { flex: 1; min-width: 0; }
.profile-name-line { display: flex; align-items: center; gap: 8px; font-size: 15px; }
.profile-name-line b { word-break: break-word; }
.profile-admin {
  font-size: 11px; color: var(--accent-dark); background: var(--accent-soft); border: 1px solid var(--accent-border);
  padding: 1px 8px; border-radius: var(--r-pill); white-space: nowrap;
}
.profile-mail { color: var(--muted); font-size: 12px; margin-top: 4px; word-break: break-all; }
.profile-since { color: var(--muted); font-size: 11.5px; margin-top: 2px; }
.profile-nav { display: flex; flex-direction: column; gap: 3px; margin-top: 14px; flex: 1; }
.pnav-item {
  text-align: left; border: none; background: none; cursor: pointer;
  padding: 10px 13px; border-radius: var(--r-md); font-size: 13.5px; color: var(--text-2);
  transition: background .15s, color .15s;
}
.pnav-item:hover { background: var(--panel); color: var(--text); }
.pnav-item.active { background: var(--accent); color: #fff; font-weight: 600; box-shadow: var(--sh-1); }
.profile-side-foot { border-top: 1px solid var(--border); padding-top: 12px; display: flex; gap: 8px; }
.profile-side-foot .ghost { flex: 1; }
.logout-btn { color: var(--danger); }
.logout-btn:hover { background: var(--danger-soft); border-color: var(--danger-border); color: var(--danger); }
.profile-main { flex: 1; overflow: hidden; display: flex; flex-direction: column; min-width: 0; }
.ptab { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.ptab[hidden] { display: none; }
.ptab-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 18px 22px 0; flex-wrap: wrap; flex: 0 0 auto;
}
.ptab-head h3 { margin: 0; font-size: 16px; }
.pnote { color: var(--muted); font-size: 12px; }
.ptab .space-list { padding: 12px 22px 22px; }
.ptab-body { flex: 1; overflow-y: auto; padding: 16px 22px 22px; min-height: 0; }
.ptab-body.ptab-body-fill { display: flex; overflow: hidden; }

/* 账户总览 */
.pstat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 11px; }
.pstat-card {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 15px 10px; text-align: center; display: flex; flex-direction: column; gap: 4px;
}
.pstat-card b { font-size: 21px; color: var(--accent); line-height: 1.25; font-weight: 700; }
.pstat-card span { font-size: 12px; color: var(--muted); }
.pov-actions { display: flex; gap: 10px; margin-top: 15px; flex-wrap: wrap; }
.pov-recent-h { margin: 20px 0 9px; font-size: 13px; color: var(--text-2); font-weight: 600; }
.pov-recent { display: flex; flex-direction: column; gap: 7px; }
.pov-doc {
  display: flex; align-items: center; gap: 10px; padding: 10px 13px; cursor: pointer;
  border: 1px solid var(--border); border-radius: var(--r-md); background: var(--panel);
  transition: border-color .15s, background .15s;
}
.pov-doc:hover { border-color: var(--accent); background: var(--accent-soft); }
.pov-doc-title {
  flex: 1; min-width: 0; font-size: 13px; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.pov-doc-time { font-size: 11.5px; color: var(--muted); white-space: nowrap; }

.profile-card {
  border: 1px solid var(--border); border-radius: var(--r-lg); padding: 15px 17px;
  max-width: 560px; background: var(--panel); margin-bottom: 13px;
}
.pcard-h { margin: 0 0 12px; font-size: 13px; color: var(--text-2); font-weight: 600; }
.profile-card .form-row { margin-bottom: 9px; }
.profile-card .form-row:last-child { margin-bottom: 0; }
.profile-card input[type="text"], .profile-card input[type="password"] {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: var(--r-md);
  font-size: 13px; background: var(--bg); color: inherit;
}
.profile-card input:focus { outline: none; border-color: var(--accent); background: var(--panel); box-shadow: var(--ring); }

/* 文献关联图 */
.graph-wrap {
  width: 100%; flex: 1; min-height: 320px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-lg);
  overflow: hidden; position: relative;
}
.graph-svg { width: 100%; height: 100%; display: block; }
.g-edge { stroke: #c3cdda; stroke-width: 1.2; }
.g-edge.hot { stroke: var(--accent); stroke-width: 2.5; }
.g-node { cursor: pointer; }
.g-node circle { fill: var(--accent); stroke: #fff; stroke-width: 1.5; }
.g-node text { font-size: 11px; fill: var(--text-2); pointer-events: none; }
.g-node.hot circle { fill: #ff8c00; stroke-width: 2.5; }
.g-tip {
  position: absolute; background: #1f2937; color: #fff; font-size: 12px;
  padding: 7px 11px; border-radius: var(--r-md); pointer-events: none; z-index: 5;
  max-width: 300px; line-height: 1.55; box-shadow: var(--sh-2);
}

/* 摘录汇总 */
.hl-list { display: flex; flex-direction: column; gap: 10px; }
.hl-group {
  border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--panel);
  padding: 13px 15px; cursor: pointer;
  transition: border-color .15s, background .15s;
}
.hl-group:hover { border-color: var(--accent); background: var(--surface-2); }
.hl-group-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 9px; }
.hl-group-head b { font-size: 14px; word-break: break-word; }
.hl-group-count {
  font-size: 11.5px; color: var(--text-2); background: var(--surface-2);
  border: 1px solid var(--border); padding: 2px 9px; border-radius: var(--r-pill); white-space: nowrap;
}
.hl-row { display: flex; align-items: baseline; gap: 9px; font-size: 13px; padding: 4px 0; }
.hl-page { color: var(--muted); font-size: 11.5px; white-space: nowrap; }

/* ==========================================================================
   6. 高亮标注与摘录抽屉
   ========================================================================== */
mark.hl { background: transparent; color: inherit; border-radius: 2px; cursor: pointer; padding: 0; }
mark.hl.hl-yellow { background: rgba(255, 214, 0, .45); }
mark.hl.hl-green  { background: rgba(122, 210, 74, .40); }
mark.hl.hl-blue   { background: rgba(99, 179, 255, .40); }
mark.hl.hl-pink   { background: rgba(255, 158, 203, .45); }
.textLayer mark.hl { color: transparent; } /* 文字层文字保持透明，只显荧光底色 */
mark.hl.hl-flash { outline: 2px solid #ff6d00; }

.hl-bar {
  position: fixed; z-index: 300; display: flex; align-items: center; gap: 7px;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 7px 9px; box-shadow: var(--sh-3);
}
.hl-bar[hidden] { display: none; }
.hl-swatch {
  width: 26px; height: 26px; min-width: 26px; border-radius: 50%;
  border: 2px solid #fff; box-shadow: 0 0 0 1px var(--border-strong); cursor: pointer; padding: 0;
}
.hl-swatch.active { box-shadow: 0 0 0 2px var(--text); }
.hl-x { border: none; background: none; cursor: pointer; font-size: 15px; padding: 2px 6px; border-radius: var(--r-sm); }
.hl-x:hover { background: var(--surface-2); }
@media (pointer: coarse) { /* 平板：≥44px 触控目标 */
  .hl-bar { gap: 12px; padding: 10px 14px; }
  .hl-swatch { width: 40px; height: 40px; min-width: 40px; }
  .hl-x { font-size: 20px; padding: 6px 10px; }
}

.hl-drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 150;
  width: min(400px, 92vw); background: var(--panel);
  border-left: 1px solid var(--border); box-shadow: -10px 0 40px rgba(23,32,60,.14);
  display: flex; flex-direction: column;
}
.hl-drawer[hidden] { display: none; }
.hl-drawer-head {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
}
.hl-drawer-list { flex: 1; overflow-y: auto; padding: 10px 14px 18px; }
.hl-page-h { font-size: 12px; color: var(--muted); margin: 14px 2px 6px; font-weight: 600; }
.hl-item {
  position: relative; padding: 9px 30px 9px 11px; border-radius: var(--r-md); cursor: pointer;
  border: 1px solid transparent;
}
.hl-item:hover { background: var(--surface-2); border-color: var(--border); }
.hl-dot { display: inline-block; width: 10px; height: 10px; min-width: 10px; border-radius: 50%; margin-right: 6px; }
.hl-side-tag {
  font-size: 11px; color: var(--muted); border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: 0 5px; margin-right: 6px;
}
.hl-warn { font-size: 11px; color: var(--warn); }
.hl-text {
  font-size: 13px; line-height: 1.7; margin-top: 5px; color: var(--text); word-break: break-word;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.hl-item-del {
  position: absolute; top: 8px; right: 6px; border: none; background: none;
  cursor: pointer; font-size: 13px; opacity: 0; transition: opacity .15s;
}
.hl-item:hover .hl-item-del { opacity: .8; }
@media (pointer: coarse) { .hl-item-del { opacity: .6; } }
.hl-empty { color: var(--muted); text-align: center; padding: 34px 12px; font-size: 13px; line-height: 1.8; }

/* ==========================================================================
   7. 窄屏 / 平板
   ========================================================================== */
#mobileViewToggle { display: none; }
@media (max-width: 820px) {
  #mobileViewToggle { display: inline-flex; }
  .splitter { display: none !important; }
  .layout { flex-direction: column; }
  .layout > .pane { width: 100% !important; flex: 1 1 auto; }
  body[data-view="zh"] .layout > .pane:first-child { display: none; }
  body[data-view="pdf"] .layout > .pane:last-child { display: none; }

  #siteHeader { height: auto; flex-wrap: wrap; gap: 6px 12px; padding: 9px 14px; }
  .brand-sub { display: none; }
  body[data-page="reader"] .site-nav { display: none; } /* 手机阅读时省出竖向空间 */
  .site-nav { order: 3; width: 100%; justify-content: flex-start; gap: 0; }
  .nav-link { padding: 7px 10px; font-size: 13px; }
  .head-btn { min-height: 36px; padding: 6px 14px; }
  .head-prog .head-prog-label { display: none; }

  .sheet-tab { font-size: 14px; }
  .sheet-list { padding: 6px 6px 10px; }

  .topbar { padding: 8px 12px; }
  .topbar-controls { flex-wrap: wrap; gap: 8px; }
  .tb-sep { display: none; }
  .reader-title { max-width: 150px; }
  .ctrl-btn, .file-btn, .mini { min-height: 40px; }

  .profile-side { width: 90px; min-width: 90px; padding: 14px 8px 12px; }
  .profile-side .profile-info { display: none; }
  .pnav-item { text-align: center; padding: 10px 4px; font-size: 13px; }
  .profile-side-foot { flex-direction: column; }
  .pstat-grid { grid-template-columns: repeat(2, 1fr); }
  .ptab-head { padding-left: 14px; padding-right: 14px; }
  .ptab .space-list, .ptab-body { padding-left: 14px; padding-right: 14px; }
}

/* ============ 每日翻译额度展示 ============
   额度徽章 .quota-badge 显示在文献库面板「我的文献」页签工具区与上传弹窗（#uploadQuota）；
   后端限额逻辑在 lib/translate.js（QUOTA_LIMIT），管理员不受限。 */
