/* ==========================================================================
   HappyReading — 设计基线
   颜色 / 圆角 / 阴影 / 间距统一走变量，组件只引用变量，不写死色值。
   ========================================================================== */
:root {
  /* 表面与文字 */
  --bg: #eef1f6;
  --panel: #ffffff;
  --surface-2: #f7f9fc;
  --border: #e4e8ef;
  --border-strong: #cdd5e1;
  --text: #172033;
  --text-2: #475467;
  --muted: #8b95a7;

  /* 主色与语义色 */
  --accent: #2f6bed;
  --accent-dark: #1f52c9;
  --accent-soft: #eaf0ff;
  --accent-2: #0f9b8e;          /* 「我的文献」——与主色同族的第二入口色 */
  --accent-2-dark: #0b7d72;
  --ok: #15883f;
  --ok-soft: #e7f6ec;
  --warn: #b7791f;
  --warn-soft: #fdf3e2;
  --danger: #c9372c;
  --danger-soft: #fdeceb;
  --danger-border: #f4c7c3;

  /* 阅读区：比页面底色略深，让白色书页浮起来 */
  --reader-bg: #dde3ec;

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

  /* 阴影：1 贴地 / 2 悬浮 / 3 弹层 */
  --sh-1: 0 1px 2px rgba(16,24,40,.05);
  --sh-2: 0 4px 14px rgba(16,24,40,.09);
  --sh-3: 0 18px 48px rgba(16,24,40,.20);
  --shadow: var(--sh-1);

  --ring: 0 0 0 3px rgba(47,107,237,.16);
}

* { 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); }

/* 细滚动条：整站统一 */
* { 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. 顶部品牌栏
   ========================================================================== */
#topBar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 0 18px; height: 52px; flex: 0 0 auto;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  z-index: 9; font-size: 14px;
}
.top-title {
  display: inline-flex; align-items: center; gap: 8px;
  font-weight: 700; font-size: 16px; letter-spacing: .2px; white-space: nowrap;
}
.top-sub {
  color: var(--muted); font-size: 12px; font-weight: 400;
  padding-left: 10px; margin-left: 2px; border-left: 1px solid var(--border);
}
.top-right { display: flex; align-items: center; gap: 8px; }
.top-btn {
  background: var(--panel); color: var(--text-2); border: 1px solid var(--border);
  padding: 6px 13px; border-radius: var(--r-sm); font-size: 13px; cursor: pointer;
  white-space: nowrap; transition: background .15s, border-color .15s, color .15s;
}
.top-btn:hover { background: var(--surface-2); border-color: var(--border-strong); color: var(--text); }
#loginBtn { background: var(--accent); color: #fff; border-color: transparent; font-weight: 600; }
#loginBtn:hover { background: var(--accent-dark); color: #fff; }
.top-email {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--text-2); font-size: 13px; max-width: 200px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.quota-badge {
  padding: 4px 11px; border-radius: var(--r-pill);
  background: var(--warn-soft); border: 1px solid #f0dcb4; color: var(--warn);
  font-size: 12px; white-space: nowrap;
}
.quota-badge.warn { background: var(--danger-soft); border-color: var(--danger-border); color: var(--danger); }

/* ==========================================================================
   2. 工具栏：按功能分组，组间用分隔线
   ========================================================================== */
.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; }

/* 入口按钮（公共文献 / 我的文献）：实心，视觉权重最高 */
.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); }
.file-btn:active { transform: translateY(1px); }
.space-btn { background: var(--accent-2); }
.space-btn:hover { background: var(--accent-2-dark); }

/* 次级按钮：白底描边 */
.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; }
.upload-btn { display: inline-flex; align-items: center; gap: 5px; }
.ctrl-btn:disabled, .file-btn:disabled, .top-btn:disabled { opacity: .42; cursor: default; box-shadow: none; }
.file-btn:disabled:hover { background: var(--accent); }
.space-btn:disabled:hover { background: var(--accent-2); }
.top-btn:disabled:hover, .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;
}

/* 工具栏上传进度条 */
.tb-prog { display: inline-flex; align-items: center; }
.tb-prog-track {
  width: 110px; height: 7px; background: var(--bg); border: 1px solid 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), #5a8bff); transition: width .4s ease;
}

/* 翻页 / 缩放 / 对照滚动 */
.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(--warn); 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; }

/* ==========================================================================
   3. 阅读区：左原文 PDF / 右中文版
   ========================================================================== */
.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(23,32,51,.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(23,32,51,.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; }

/* 中文就地覆盖层：白底盖住英文，中文按原文 bbox 定位 */
.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(47,107,237,.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(23,32,51,.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. 文献列表：公共文献与我的文献共用同一套卡片
   ========================================================================== */
/* 弹层外壳 —— 公共文献弹窗与个人中心弹窗同尺寸同圆角 */
.lib-overlay {
  position: fixed; inset: 0; background: rgba(16,24,40,.42); backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center; z-index: 50;
}
.lib-box {
  background: var(--panel); border-radius: var(--r-lg);
  width: min(920px, 95vw); height: min(86vh, 760px);
  display: flex; flex-direction: column; overflow: hidden; box-shadow: var(--sh-3);
}
.lib-head {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 16px 20px; border-bottom: 1px solid var(--border); flex: 0 0 auto;
}
.lib-head b { font-size: 16px; }
.lib-note { color: var(--muted); font-size: 12.5px; padding: 12px 20px 0; line-height: 1.7; }
.lib-search { padding: 12px 20px 0; flex: 0 0 auto; }
.lib-search input {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: var(--r-md);
  background: var(--surface-2); color: inherit; font-size: 13.5px;
}
.lib-search input:focus { outline: none; border-color: var(--accent); background: var(--panel); box-shadow: var(--ring); }
.lib-cats { display: flex; flex-wrap: wrap; gap: 6px; padding: 12px 20px 4px; flex: 0 0 auto; }
.lib-cat {
  font-size: 12px; padding: 4px 12px; border-radius: var(--r-pill);
  border: 1px solid var(--border); background: var(--panel); 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; font-weight: 600; }
.lib-list, .space-list { flex: 1; overflow-y: auto; padding: 12px 20px 20px; }

/* 文献卡 —— 公共文献与我的文献完全同款 */
.lib-row {
  position: relative; background: var(--panel);
  border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 15px 17px; margin-bottom: 11px; cursor: pointer;
  box-shadow: var(--sh-1);
  transition: border-color .16s, box-shadow .16s, transform .12s;
}
.lib-row:hover { border-color: var(--accent); box-shadow: var(--sh-2); transform: translateY(-1px); }
.lib-row:last-child { margin-bottom: 0; }
.lib-name {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font-weight: 600; font-size: 14.5px; line-height: 1.5; word-break: break-word; color: var(--text);
}
.lib-badge {
  display: inline-block; margin-top: 8px; font-size: 11.5px; padding: 2px 10px;
  border-radius: var(--r-pill); background: var(--accent-soft); color: var(--accent); font-weight: 600;
}
.lib-summary {
  color: var(--text-2); font-size: 13px; line-height: 1.7; margin-top: 8px;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.lib-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }
.lib-tag {
  font-size: 11.5px; padding: 2px 9px; border-radius: var(--r-sm);
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2);
}
.lib-meta {
  color: var(--muted); font-size: 12px; margin-top: 9px; line-height: 1.7;
  padding-top: 9px; border-top: 1px dashed var(--border); word-break: break-word;
}
.lib-empty { color: var(--muted); text-align: center; padding: 46px 20px; font-size: 13.5px; line-height: 1.8; }

/* 阅读进度 */
.lib-prog { display: flex; align-items: center; gap: 9px; margin-top: 10px; }
.lib-prog-bar {
  flex: 0 0 130px; height: 6px; border-radius: var(--r-pill); background: var(--bg);
  border: 1px solid var(--border); overflow: hidden; display: inline-block;
}
.lib-prog-bar i {
  display: block; height: 100%; border-radius: var(--r-pill);
  background: linear-gradient(90deg, var(--accent), #5a8bff);
}
.lib-prog-txt { font-size: 12px; color: var(--muted); }
.lib-prog.done .lib-prog-txt { color: var(--ok); font-weight: 600; }

/* 卡内操作按钮行（两处共用） */
.sp-actions, .lib-actions {
  display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap;
  padding-top: 11px; border-top: 1px solid var(--border);
}
.sp-actions .ctrl-btn, .lib-actions .ctrl-btn { padding: 5px 13px; font-size: 12.5px; }
.sp-del { color: var(--danger); }
.sp-del:hover { background: var(--danger-soft); border-color: var(--danger-border); color: var(--danger); }
.lib-link { color: var(--accent); }
.lib-link:hover { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

/* 状态徽章 */
.sp-badge { font-size: 11.5px; padding: 2px 10px; border-radius: var(--r-pill); white-space: nowrap; font-weight: 600; }
.sp-ok { background: var(--ok-soft); color: var(--ok); }
.sp-run { background: var(--warn-soft); color: var(--warn); }
.sp-fail { background: var(--danger-soft); color: var(--danger); }
.sp-pub { background: var(--accent-soft); color: var(--accent); }

/* 翻译中 / 失败 */
.sp-prog { display: flex; align-items: center; gap: 9px; margin-top: 10px; }
.sp-prog-bar {
  flex: 0 0 150px; height: 6px; border-radius: var(--r-pill); background: var(--bg);
  border: 1px solid var(--border); overflow: hidden; display: inline-block;
}
.sp-prog-bar i {
  display: block; height: 100%; border-radius: var(--r-pill);
  background: linear-gradient(90deg, var(--accent), #5a8bff); transition: width .4s ease;
}
.sp-prog-txt { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sp-err {
  margin-top: 10px; font-size: 12.5px; color: var(--danger); line-height: 1.7; word-break: break-word;
  background: var(--danger-soft); border: 1px solid var(--danger-border);
  border-radius: var(--r-md); padding: 8px 11px;
}
.sp-card-todo { cursor: default; }
.sp-card-todo:hover { border-color: var(--border-strong); transform: none; box-shadow: var(--sh-1); }
.sp-empty { color: var(--muted); text-align: center; padding: 46px 20px; font-size: 13.5px; }

/* ==========================================================================
   5. 弹窗通用
   ========================================================================== */
.modal-mask {
  position: fixed; inset: 0; background: rgba(16,24,40,.48); 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: 18px; }
.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(--surface-2); 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-progress { margin-top: 8px; }
.progress-track { height: 9px; background: var(--bg); border: 1px solid 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), #5a8bff); transition: width .4s ease;
}

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

/* 登录 / 注册 / 找回密码 */
.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(--surface-2); 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: 580px; }
.help-body { max-height: 62vh; overflow-y: auto; font-size: 14px; line-height: 1.75; padding-right: 4px; }
.help-body h3 {
  margin: 18px 0 5px; font-size: 13.5px; color: var(--accent);
  display: flex; align-items: center; gap: 7px;
}
.help-body h3::before { content: ""; width: 3px; height: 13px; border-radius: 2px; background: var(--accent); }
.help-body h3:first-child { margin-top: 0; }
.help-body p { margin: 0 0 4px; color: var(--text-2); font-size: 13.5px; }

/* 头像 */
.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; }

/* ==========================================================================
   6. 个人中心（弹窗：左导航 + 右内容）
   ========================================================================== */
.profile-overlay {
  position: fixed; inset: 0; background: rgba(16,24,40,.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: 232px; min-width: 232px; background: var(--surface-2);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 18px 12px;
}
.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: 15.5px; }
.profile-name-line b { word-break: break-word; }
.profile-admin {
  font-size: 11px; color: var(--warn); background: var(--warn-soft); border: 1px solid #f0dcb4;
  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: 16px; 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: 14px; }
.profile-quota { font-size: 12.5px; color: var(--muted); margin: 0 6px 12px; line-height: 1.6; }
.profile-quota b { color: var(--accent); }
.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: 16.5px; }
.pnote { color: var(--muted); font-size: 12px; }
/* 个人中心内的搜索/分类与公共文献弹窗对齐 */
.ptab .lib-search { padding: 14px 22px 0; }
.ptab .lib-cats { padding: 12px 22px 4px; }
.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; }
.profile-card {
  border: 1px solid var(--border); border-radius: var(--r-lg); padding: 16px 18px;
  max-width: 560px; background: var(--panel);
}
.profile-card h3 { margin: 0 0 12px; font-size: 14px; }
.profile-card .form-row { margin-bottom: 9px; }
.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(--surface-2); 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: #172033; 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: 11px; }
.hl-group {
  border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--panel);
  padding: 14px 16px; cursor: pointer; box-shadow: var(--sh-1);
  transition: border-color .16s, box-shadow .16s, transform .12s;
}
.hl-group:hover { border-color: var(--accent); box-shadow: var(--sh-2); transform: translateY(-1px); }
.hl-group-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.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; }

/* ==========================================================================
   7. 高亮标注与摘录抽屉
   ========================================================================== */
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(16,24,40,.16);
  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; }

/* ==========================================================================
   8. 窄屏 / 平板
   ========================================================================== */
#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; }
  .topbar { padding: 8px 12px; }
  .topbar-controls { flex-wrap: wrap; gap: 8px; }
  .tb-sep { display: none; }
  .ctrl-btn, .file-btn, .mini { min-height: 40px; }
  #topBar { height: auto; flex-wrap: wrap; gap: 8px; padding: 8px 12px; }
  .top-sub { display: none; }
  .top-btn { min-height: 40px; }
  .top-email { display: none; }
  .profile-side { width: 88px; min-width: 88px; padding: 14px 8px; }
  .profile-side .profile-info { display: none; }
  .pnav-item { text-align: center; padding: 10px 4px; font-size: 13px; }
  .profile-quota { display: none; }
  .ptab-head, .ptab .lib-search, .ptab .lib-cats { padding-left: 14px; padding-right: 14px; }
  .ptab .space-list, .ptab-body { padding-left: 14px; padding-right: 14px; }
  .lib-head, .lib-note, .lib-search, .lib-cats, .lib-list { padding-left: 14px; padding-right: 14px; }
}

/* ============ 每日翻译额度：不向用户展示 ============
   承载额度文案的元素已从 index.html 移除（顶栏角标、使用指南两节、个人中心侧栏额度行）。
   后端限额（lib/translate.js 的 QUOTA_LIMIT）与前端 setQuotaBadge / renderQuotaBadge /
   refreshQuotaBadge 全部保留，取不到元素即跳过；恢复展示只需把元素放回 index.html。
   .quota-badge 样式保留在第 1 节，供恢复时直接复用。 */
