/* ============================================================
 * PDF 工具 · 视觉系统 v4.1（对标 Smallpdf 蓝白简洁风）
 * 主色 #2563eb ｜ 背景 #f8fafc ｜ 正文 #0f172a ｜ 次要 #64748b
 * 圆角：卡片/容器 16px，按钮 10px
 * 阴影：0 1px 2px rgba(15,23,42,.04), 0 8px 24px rgba(15,23,42,.06)
 * ============================================================ */

/* ===== 基础 ===== */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: #f8fafc;
  color: #0f172a;
  display: flex;
  flex-direction: column;
}

/* ===== 顶部工具栏 ===== */
#toolbar {
  background: #ffffff;
  border-bottom: 1px solid #e2e8f0;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  box-shadow: 0 1px 2px rgba(15,23,42,.04), 0 8px 24px rgba(15,23,42,.06);
  position: sticky;
  top: 0;
  z-index: 50;
}
.brand { font-weight: 700; font-size: 17px; margin-right: 6px; color: #0f172a; }
.tool-group { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.btn {
  display: inline-block;
  padding: 8px 16px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #fff;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  color: #0f172a;
  transition: background .15s, border-color .15s, box-shadow .15s, transform .1s;
}
.btn:hover:not(:disabled) { background: #f1f5f9; border-color: #cbd5e1; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
  box-shadow: 0 1px 2px rgba(37,99,235,.3);
}
.btn-primary:hover:not(:disabled) { background: #1d4ed8; border-color: #1d4ed8; }
label.btn { display: inline-flex; align-items: center; gap: 6px; }
label.btn input[type="color"] { width: 26px; height: 22px; border: none; padding: 0; background: none; cursor: pointer; }
/* 语言入口已由顶栏原生下拉改为「设置面板」，此规则仅作遗留兼容 */
.lang-switch { margin-left: auto; padding: 6px 10px; font-size: 13px; }
@media (max-width: 720px) { .lang-switch { margin-left: 0; } }

/* ---------- 设置面板（2026-08-30） ---------- */
.btn-icon {
  padding: 7px 10px;
  font-size: 15px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.settings-box { max-width: 380px; }
.settings-section { margin: 4px 0 2px; }
.settings-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #334155;
  margin-bottom: 8px;
}
.settings-select {
  width: 100%;
  padding: 9px 11px;
  font-size: 14px;
  border: 1px solid #cbd5e1;
  border-radius: 9px;
  background: #fff;
  color: #0f172a;
  cursor: pointer;
}
.settings-select:focus { outline: 2px solid #2563eb; outline-offset: 1px; }
.settings-hint { margin: 8px 0 0; font-size: 12px; color: #64748b; line-height: 1.5; }

/* ===== 页面信息条 ===== */
#pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 10px 0;
  background: #fff;
  border-bottom: 1px solid #eef2f7;
}
#page-info { font-size: 13px; color: #64748b; min-width: 60px; text-align: center; }

/* ===== 工作区 ===== */
#workspace {
  flex: 1;
  overflow: auto;
  padding: 24px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

/* 空状态拖拽区 */
#drop-zone {
  width: 100%;
  max-width: 680px;
  min-height: 340px;
  border: 2px dashed #cbd5e1;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background: #fff;
  transition: border-color .2s, background .2s;
}
#drop-zone.dragover { border-color: #2563eb; background: #eff6ff; }
.drop-inner { text-align: center; padding: 32px; }
.drop-icon { font-size: 56px; margin-bottom: 14px; }
.drop-title { font-size: 17px; font-weight: 600; margin-bottom: 8px; color: #0f172a; }
.drop-hint { font-size: 13px; color: #64748b; }

/* 页面与文本层（连续滚动 · TICKET-009 窗口化：slot 绝对定位，容器总高占位） */
#page-container {
  position: relative;
  /* 关键：容器内子元素全部 position:absolute（不贡献父宽度），而本容器又是
     #workspace(flex) 的子项 —— 若不给确定宽度，flex item 宽度会缩到 0，
     导致 .page-wrap 的 left:50% 落在 0 处、canvas 的 max-width:100% 解析为 0，
     整页被压成「一条竖线」。width:100% 打破这个塌陷，同时保留窄屏自适应。 */
  width: 100%;
  min-width: 0;
  padding: 12px 0 48px;
}
.page-wrap {
  position: absolute;
  box-shadow: 0 1px 2px rgba(15,23,42,.04), 0 8px 24px rgba(15,23,42,.06);
  background: #fff;
  max-width: 100%;
  border-radius: 4px;
  overflow: hidden;
}
.page-wrap canvas { display: block; max-width: 100%; height: auto; }
.text-layer {
  position: absolute;
  inset: 0;
  overflow: hidden;
  line-height: 1;
}
.text-layer .tl-item {
  position: absolute;
  transform-origin: 0 0;
  cursor: default;
  padding: 1px;
  margin: -1px;
  border-radius: 2px;
  color: transparent;
  transition: background .12s, outline-color .12s;
  white-space: pre;
  overflow: hidden;
  /* TICKET-006A：默认浏览模式干净——无虚线框、不可点击 */
  outline: none;
  pointer-events: none;
}
/* TICKET-006A：仅编辑模式可点、可悬停，且只有 hover/聚焦/选中/已编辑项有边框 */
#workspace.edit-mode .text-layer .tl-item { pointer-events: auto; cursor: pointer; }
#workspace.edit-mode .text-layer .tl-item:hover { background: rgba(37,99,235,.10); color: transparent; outline: 1px solid rgba(37,99,235,.6); }
#workspace.edit-mode .text-layer .tl-item.editing { background: rgba(37,99,235,.32); color: #000; outline: 1px solid #2563eb; }
#workspace.edit-mode .text-layer .tl-item.edited { outline: 2px dashed #f59e0b; color: #000; background: transparent; overflow: visible; }
/* 旋转 / 竖排文字：预览可正常显示，但导出不支持旋转 → 禁止编辑并给出视觉提示 */
#workspace.edit-mode .text-layer .tl-item.rotated-unsupported { cursor: not-allowed; }
#workspace.edit-mode .text-layer .tl-item.rotated-unsupported:hover { background: rgba(220,38,38,.10); outline: 1px dashed rgba(220,38,38,.7); }

/* 页数徽标（浅灰胶囊） */
.page-count {
  font-size: 12px;
  color: #64748b;
  background: #f1f5f9;
  border-radius: 999px;
  padding: 4px 12px;
}

/* 无文字层提示（扫描件） */
.no-text-notice {
  background: #fff7e6;
  border: 1px solid #ffd591;
  color: #ad6800;
  border-radius: 16px;
  padding: 14px 20px;
  font-size: 14px;
  max-width: 640px;
  text-align: center;
}

/* ===== 编辑弹窗 ===== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
  backdrop-filter: blur(2px);
}
.modal[hidden] { display: none; }
.modal-box {
  background: #fff;
  border-radius: 16px;
  width: 100%;
  max-width: 400px;
  padding: 20px;
  box-shadow: 0 1px 2px rgba(15,23,42,.04), 0 24px 48px rgba(15,23,42,.16);
}
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
  font-size: 15px;
  margin-bottom: 14px;
  color: #0f172a;
}
.modal-close { border: none; background: none; font-size: 22px; cursor: pointer; color: #64748b; line-height: 1; }
#edit-text {
  width: 100%;
  font-size: 15px;
  padding: 10px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  resize: vertical;
  min-height: 64px;
  font-family: inherit;
}
.modal-row { display: flex; align-items: center; gap: 12px; margin-top: 12px; flex-wrap: wrap; }
.modal-row label { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: #334155; }
#edit-size { width: 110px; }
.chk input { margin-right: 2px; }
.modal-actions { display: flex; gap: 10px; margin-top: 16px; justify-content: flex-end; }
.modal-note { margin-top: 10px; font-size: 12px; color: #f59e0b; }

/* ===== v4 工具面板 ===== */
.tools-box { max-width: 640px; max-height: 90vh; overflow-y: auto; }

/* 卡片网格首页 */
.tools-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
.tool-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  padding: 24px 16px 20px;
  cursor: pointer;
  font-family: inherit;
  text-align: center;
  box-shadow: 0 1px 2px rgba(15,23,42,.04), 0 8px 24px rgba(15,23,42,.06);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.tool-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 2px 4px rgba(15,23,42,.06), 0 16px 32px rgba(15,23,42,.12);
  border-color: #2563eb;
}
.tool-card:active { transform: translateY(0); }
.tool-card-icon {
  width: 52px; height: 52px;
  display: flex; align-items: center; justify-content: center;
  background: #eff6ff;
  border-radius: 50%;
  font-size: 26px;
}
.tool-card-name { font-size: 15px; font-weight: 600; color: #0f172a; }
.tool-card-desc { font-size: 12px; color: #64748b; line-height: 1.5; }

/* Pro 门禁（P1）：角标 + 锁定态 + 升级弹窗 */
.tool-card { position: relative; }
.pro-badge {
  position: absolute; top: 10px; right: 10px;
  font-size: 10px; font-weight: 700; letter-spacing: .04em;
  color: #fff; background: linear-gradient(135deg,#7c3aed,#2563eb);
  padding: 2px 7px; border-radius: 999px; line-height: 1.5;
  box-shadow: 0 2px 6px rgba(37,99,235,.28);
}
.tool-card.locked { cursor: pointer; }
.tool-card.locked::after {
  content: "\1F512";
  position: absolute; top: 10px; left: 10px;
  font-size: 13px; opacity: .55;
}
.tool-card.locked .tool-card-icon { filter: grayscale(.35); opacity: .85; }
.tool-card.locked:hover { border-color: #c7b6f0; box-shadow: 0 2px 4px rgba(15,23,42,.06), 0 16px 32px rgba(124,58,237,.14); }
.upgrade-box { max-width: 440px; }
/* 恢复授权入口（升级弹窗底部） */
.upgrade-restore { margin: 10px 0 0; font-size: 12.5px; color: #64748b; text-align: right; }
.link-btn {
  border: none; background: none; padding: 0; margin-left: 4px;
  font: inherit; color: #2563eb; cursor: pointer; text-decoration: underline;
}
.link-btn:hover { color: #1d4ed8; }
.recover-box { max-width: 420px; }
.recover-desc { font-size: 13px; color: #64748b; line-height: 1.6; margin-bottom: 12px; }
.recover-input {
  width: 100%; font-size: 14px; padding: 10px 12px;
  border: 1px solid #e2e8f0; border-radius: 10px; font-family: inherit;
}
.recover-input:focus { outline: none; border-color: #2563eb; }
.recover-note { margin-top: 10px; font-size: 12.5px; color: #f59e0b; line-height: 1.5; }
.recover-note.ok { color: #0f766e; }

/* ===== 全局 toast（window.PDFbuffNotify）=====
   2026-09-02 补：此前 gate.js 调用 PDFbuffNotify 但从未有实现，
   支付成功 / 授权恢复等关键反馈一直静默丢失。 */
.toast-layer {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  max-width: 340px;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.5;
  color: #0f172a;
  background: #fff;
  border: 1px solid #e2e8f0;
  box-shadow: 0 4px 12px rgba(15, 23, 42, .12), 0 12px 32px rgba(15, 23, 42, .10);
  cursor: pointer;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity .2s ease, transform .2s ease;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-ok { border-color: #a7f3d0; background: #f0fdf9; color: #065f46; }
.toast-warn { border-color: #fde68a; background: #fffbeb; color: #92400e; }
.toast-error { border-color: #fecaca; background: #fef2f2; color: #991b1b; }
@media (max-width: 560px) {
  .toast-layer { left: 12px; right: 12px; align-items: stretch; }
  .toast { max-width: none; }
}
.upgrade-kicker { font-size: 11px; letter-spacing: .14em; font-weight: 700; color: #7c3aed; margin: 2px 0 6px; }
#upgrade-modal .upgrade-box { max-height: calc(100% - 2px); overflow-y: auto; }
.upgrade-feature-name { font-size: 20px; font-weight: 700; color: #0f172a; margin-bottom: 4px; }
.upgrade-feature-desc { font-size: 13px; color: #64748b; line-height: 1.6; margin-bottom: 14px; }
.upgrade-perks { list-style: none; padding: 0; margin: 0 0 16px; }
.upgrade-perks li { position: relative; padding: 7px 0 7px 24px; font-size: 13.5px; color: #0f172a; border-top: 1px solid #eef2f7; }
.upgrade-perks li:first-child { border-top: none; }
.upgrade-perks li::before { content: "\2713"; position: absolute; left: 0; top: 7px; color: #2563eb; font-weight: 700; }
.upgrade-price { font-size: 14px; color: #475569; margin-bottom: 18px; }
.upgrade-price b { color: #7c3aed; }

/* 工具操作区 */
.tools-back-row { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.tools-title { font-size: 15px; font-weight: 600; color: #0f172a; }
.tools-panel { min-height: 120px; }
.tools-hint { font-size: 12.5px; color: #64748b; margin-bottom: 12px; line-height: 1.6; }
.tools-hint code { background: #f1f5f9; padding: 1px 5px; border-radius: 5px; color: #334155; }
.tools-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  font-size: 14px;
  margin: 8px 0;
  font-family: inherit;
  transition: border-color .15s, box-shadow .15s;
}
.tools-input:focus { outline: none; border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.tools-row { display: flex; gap: 10px; flex-wrap: wrap; margin: 8px 0; }
.tools-list { list-style: none; margin: 10px 0; }
.tools-list li {
  display: flex; align-items: center; gap: 8px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 8px 12px;
  margin-bottom: 6px;
  font-size: 13px;
  cursor: grab;
}
.tools-list li.dragging { opacity: .5; }
.tools-list .file-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tools-list .file-pages { color: #64748b; font-size: 12px; }
.tools-list .file-rm { border: none; background: none; color: #ef4444; cursor: pointer; font-size: 16px; }
.sign-canvas {
  width: 100%;
  border: 1px dashed #cbd5e1;
  border-radius: 10px;
  background: #fff;
  touch-action: none;
  margin: 10px 0;
  display: block;
}

/* ===== v4 签名放置模式 ===== */
.sign-overlay {
  position: absolute;
  inset: 0;
  cursor: crosshair;
  z-index: 20;
}
.sign-item {
  position: absolute;
  cursor: move;
  touch-action: none;
  user-select: none;
  border: 1px dashed rgba(37,99,235,.6);
  background: rgba(37,99,235,.08);
}
.sign-item img { width: 100%; height: 100%; display: block; pointer-events: none; }
  .sign-mode-hint {
    position: fixed;
    bottom: 20px; left: 50%; transform: translateX(-50%);
    background: rgba(15,23,42,.88); color: #fff;
    padding: 10px 18px; border-radius: 12px; font-size: 13px;
    z-index: 90; text-align: center; max-width: 90vw;
  }

  /* ===== 阶段3 图片编辑层 ===== */
  .img-edit-overlay {
    position: absolute;
    inset: 0;
    cursor: crosshair;
    z-index: 20;
  }
  .img-edit-item {
    position: absolute;
    cursor: move;
    touch-action: none;
    user-select: none;
    border: 1px dashed rgba(37,99,235,.6);
    background: rgba(37,99,235,.06);
    box-sizing: border-box;
  }
  .img-edit-item img { width: 100%; height: 100%; display: block; pointer-events: none; object-fit: fill; }
  .img-edit-del {
    position: absolute; top: -10px; right: -10px;
    width: 22px; height: 22px; border-radius: 50%;
    border: none; background: #ef4444; color: #fff; cursor: pointer;
    font-size: 13px; line-height: 22px; padding: 0; z-index: 3;
  }
  .img-handle {
    position: absolute; width: 14px; height: 14px;
    background: #fff; border: 2px solid #2563eb; border-radius: 3px;
    z-index: 2; touch-action: none;
  }
  .img-handle-nw { top: -7px; left: -7px; cursor: nwse-resize; }
  .img-handle-ne { top: -7px; right: -7px; cursor: nesw-resize; }
  .img-handle-sw { bottom: -7px; left: -7px; cursor: nesw-resize; }
  .img-handle-se { bottom: -7px; right: -7px; cursor: nwse-resize; }
  .img-rotate-handle {
    position: absolute; top: -34px; left: 50%; transform: translateX(-50%);
    width: 16px; height: 16px; border-radius: 50%;
    background: #2563eb; border: 2px solid #fff; cursor: grab; z-index: 3;
    touch-action: none;
  }
  .img-rotate-handle::after {
    content: ''; position: absolute; left: 50%; top: 12px;
    width: 2px; height: 16px; background: #2563eb; transform: translateX(-50%);
  }
  .img-mode-hint {
    position: fixed;
    bottom: 20px; left: 50%; transform: translateX(-50%);
    background: rgba(15,23,42,.88); color: #fff;
    padding: 10px 18px; border-radius: 12px; font-size: 13px;
    z-index: 90; text-align: center; max-width: 90vw;
  }
  .img-edit-item.is-edit { cursor: default; border-color: rgba(100,116,139,.4); background: transparent; }

  /* ===== 阶段4：表单填写叠加层 ===== */
  .form-field {
    position: absolute;
    box-sizing: border-box;
    border: 2px dashed rgba(37, 99, 235, .55);
    background: rgba(37, 99, 235, .06);
    border-radius: 4px;
    z-index: 40;
    overflow: hidden;
  }
  .form-field.is-filled { border-style: solid; border-color: rgba(16, 185, 129, .7); background: rgba(16, 185, 129, .08); }
  .form-text .form-input {
    width: 100%; height: 100%; box-sizing: border-box; border: none; outline: none;
    /* Cover the PDF's original field appearance while editing or clearing it. */
    background: #fff; font-size: 13px; padding: 2px 4px; color: #0f172a;
  }
  .form-choice .form-select { width: 100%; height: 100%; box-sizing: border-box; border: none; outline: none; background: #fff; font-size: 12px; }
  .form-field.form-radio { border: none; border-radius: 0; background: #fff; }
  .form-radio input {
    appearance: none; display: block; box-sizing: border-box; width: 100%; height: 100%; margin: 0;
    border: 2px solid #2563eb; border-radius: 50%; background: #fff; cursor: pointer;
  }
  .form-radio input:checked { background: radial-gradient(circle, #2563eb 0 28%, #fff 32%); }
  .form-radio input:focus-visible { outline: 2px solid #0f172a; outline-offset: -5px; }
  .form-field.form-checkbox {
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    background: #fff;
  }
  .form-checkbox::after {
    content: ''; width: 60%; height: 60%; border-radius: 2px; box-sizing: border-box;
  }
  .form-checkbox.checked::after {
    content: '\2713'; color: #10b981; font-size: 16px; font-weight: 900; line-height: 1;
    border: none; display: flex; align-items: center; justify-content: center;
  }

/* ===== 保存提示 ===== */
.saving {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}
.saving[hidden] { display: none; }
.saving-box {
  background: #fff;
  padding: 20px 34px;
  border-radius: 16px;
  font-size: 15px;
  font-weight: 600;
}

/* ===== 提示 toast ===== */
.app-toast, .tools-toast {
  position: fixed;
  top: 64px; left: 50%; transform: translateX(-50%);
  background: #0f172a; color: #fff;
  padding: 10px 20px; border-radius: 12px;
  font-size: 14px; z-index: 400;
  box-shadow: 0 8px 24px rgba(15,23,42,.3);
  max-width: 90vw; text-align: center;
}
.app-toast--err, .tools-toast--err { background: #b91c1c; }

/* ===== 手机端适配 ===== */
@media (max-width: 720px) {
  #workspace { padding: 12px; }
  #toolbar { padding: 10px 14px; }
  .brand { width: 100%; }
  .tool-group { width: 100%; }
  .btn { flex: 1; text-align: center; padding: 10px 8px; font-size: 14px; }
  #toolbar-edit .btn { flex: 0 0 auto; }
  /* TICKET-003：手机端导出按钮独占一行，最多两行、高度 ≤72px，仍表达「保存覆盖版」语义 */
  #toolbar-actions { flex-wrap: wrap; gap: 8px; }
  #toolbar-actions #btn-download { flex: 0 0 100%; white-space: normal; min-height: 40px; }
  .drop-title { font-size: 15px; }
  /* 工具卡片：手机 2 列 */
  .tools-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .tool-card { padding: 18px 10px 16px; }
  .tool-card-icon { width: 44px; height: 44px; font-size: 22px; }
  .tool-card-desc { font-size: 11px; }
}

/* ============================================================
 * PDFbuff v1 · Precision Desk
 * A quiet, document-first workspace. The single bright color is reserved
 * for the action that changes a file; amber is reserved for limitations.
 * ============================================================ */
:root {
  --rx-ink: #0b1220;
  --rx-text: #172033;
  --rx-muted: #62708a;
  --rx-line: #dce3ef;
  --rx-paper: #f7f9fc;
  --rx-white: #ffffff;
  --rx-blue: #2563eb;
  --rx-blue-dark: #1647bb;
  --rx-blue-pale: #e8f0ff;
  --rx-amber: #b45309;
  --rx-amber-pale: #fff6e5;
  --rx-shadow: 0 18px 48px rgba(15, 31, 58, .10), 0 2px 6px rgba(15, 31, 58, .05);
}

body { background: var(--rx-paper); color: var(--rx-text); letter-spacing: .005em; }
#toolbar {
  min-height: 66px;
  padding: 11px clamp(16px, 3vw, 38px);
  gap: 12px;
  background: rgba(255,255,255,.96);
  border-bottom-color: var(--rx-line);
  box-shadow: 0 1px 0 rgba(11,18,32,.04);
  backdrop-filter: blur(18px);
}
.brand { display: inline-flex; align-items: center; gap: 7px; margin-right: 0; color: var(--rx-ink); font-size: 16px; letter-spacing: -.02em; }
.brand-mark {
  display: inline-grid; place-items: center; width: 28px; height: 28px;
  border-radius: 8px; color: #fff; background: var(--rx-ink);
  font-size: 13px; font-weight: 800; letter-spacing: -.08em;
  box-shadow: inset 0 -1px 0 rgba(255,255,255,.22);
}
.brand-product { color: var(--rx-muted); font-size: 12px; font-weight: 600; letter-spacing: .03em; text-transform: uppercase; }
.privacy-status, .file-status {
  display: inline-flex; align-items: center; gap: 6px; min-height: 28px;
  color: var(--rx-muted); font-size: 12px; font-weight: 600; white-space: nowrap;
}
.privacy-status span { color: #10b981; font-size: 10px; }
.file-status { max-width: 250px; overflow: hidden; text-overflow: ellipsis; }
#toolbar-actions { margin-left: auto; justify-content: flex-end; }
.btn {
  min-height: 36px; padding: 8px 13px; border-color: var(--rx-line); border-radius: 8px;
  color: var(--rx-text); background: var(--rx-white); box-shadow: none;
  font-size: 13px; font-weight: 650;
}
.btn:hover:not(:disabled) { border-color: #b7c6df; background: #f4f7fc; box-shadow: 0 2px 7px rgba(15,31,58,.06); }
.btn:focus-visible, .tool-card:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 3px solid rgba(37,99,235,.25); outline-offset: 2px;
}
.btn-primary { border-color: var(--rx-blue); background: var(--rx-blue); box-shadow: 0 2px 7px rgba(37,99,235,.22); }
.btn-primary:hover:not(:disabled) { border-color: var(--rx-blue-dark); background: var(--rx-blue-dark); }
.page-count { color: #3d4c65; background: #eef3fb; border: 1px solid #dce6f7; font-weight: 700; }

#pager { min-height: 36px; padding: 8px 16px; background: rgba(255,255,255,.82); border-bottom-color: #e7edf6; }
#page-info { color: var(--rx-muted); font-size: 12px; font-weight: 600; }
#workspace { padding: clamp(16px, 3vw, 32px); background: radial-gradient(circle at 50% -20%, #eef4ff 0, var(--rx-paper) 42%, var(--rx-paper) 100%); }
#drop-zone {
  position: relative; max-width: 760px; min-height: 410px; overflow: hidden;
  border: 1px solid #cfd9ea; border-radius: 20px; background: rgba(255,255,255,.9);
  box-shadow: var(--rx-shadow);
}
#drop-zone::before {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .72;
  background-image: linear-gradient(rgba(37,99,235,.045) 1px, transparent 1px), linear-gradient(90deg, rgba(37,99,235,.045) 1px, transparent 1px);
  background-size: 28px 28px; mask-image: linear-gradient(to bottom, #000, transparent 76%);
}
#drop-zone:hover, #drop-zone.dragover { border-color: var(--rx-blue); background: #f9fbff; }
.drop-inner { position: relative; z-index: 1; max-width: 510px; padding: 48px 30px; }
.drop-icon {
  display: grid; place-items: center; width: 64px; height: 76px; margin: 0 auto 22px;
  border: 1px solid #b9cdfa; border-radius: 10px 10px 18px 10px; background: #e8f0ff;
  color: var(--rx-blue); font-size: 15px; font-weight: 850; letter-spacing: .08em;
  box-shadow: 8px 8px 0 #d7e4ff;
}
.drop-kicker { margin-bottom: 12px; color: var(--rx-blue); font-size: 10px; font-weight: 800; letter-spacing: .13em; }
.drop-title { margin-bottom: 12px; color: var(--rx-ink); font-size: clamp(22px, 3vw, 30px); line-height: 1.18; letter-spacing: -.045em; }
.drop-hint { max-width: 460px; margin: 0 auto; color: var(--rx-muted); font-size: 14px; line-height: 1.8; }
.drop-features { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 24px; }
.drop-features span { padding: 5px 9px; border: 1px solid #dde5f3; border-radius: 999px; color: #53627a; background: rgba(255,255,255,.74); font-size: 11px; font-weight: 700; }

#page-container { padding-bottom: 64px; }
.page-wrap { border: 1px solid rgba(184,198,218,.68); border-radius: 7px; box-shadow: 0 12px 30px rgba(22,41,70,.12), 0 2px 4px rgba(22,41,70,.06); }

/* 删除页（像删 PPT）：每页右上角 × 按钮，hover 显示 */
.page-del-btn {
  position: absolute; top: 10px; right: 10px; z-index: 6;
  width: 30px; height: 30px; border-radius: 50%;
  border: none; background: rgba(220,38,38,.92); color: #fff;
  font-size: 20px; line-height: 1; font-weight: 700; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transform: scale(.85); transition: opacity .12s, transform .12s;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
}
.page-wrap:hover .page-del-btn { opacity: 1; transform: scale(1); }
.page-del-btn:hover { background: #dc2626; }
.page-del-btn:active { transform: scale(.9); }

/* 删除提示条（底部悬浮） */
.page-del-bar {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%);
  z-index: 50; display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: 12px;
  background: #1f2937; color: #f9fafb;
  box-shadow: 0 10px 30px rgba(0,0,0,.28); font-size: 14px;
}
.page-del-bar[hidden] { display: none; }
.page-del-bar .pd-text { margin-right: 4px; }
.page-del-bar .pd-text b { color: #fca5a5; }
#workspace.edit-mode .text-layer .tl-item:hover { background: rgba(37,99,235,.11); outline-color: var(--rx-blue); }
#workspace.edit-mode .text-layer .tl-item.editing { background: rgba(37,99,235,.18); color: var(--rx-text); outline-color: var(--rx-blue); }
#workspace.edit-mode .text-layer .tl-item.edited { color: var(--rx-text); outline-color: var(--rx-amber); background: transparent; }

.no-text-notice { max-width: 720px; border-color: #edcf94; color: #87510f; background: var(--rx-amber-pale); box-shadow: 0 4px 12px rgba(143,83,10,.08); }

.modal { background: rgba(6,14,29,.58); backdrop-filter: blur(5px); }
.modal-box { max-width: 470px; padding: 22px; border: 1px solid rgba(255,255,255,.64); border-radius: 15px; box-shadow: 0 26px 72px rgba(0,0,0,.28); }
.modal-head { margin-bottom: 10px; color: var(--rx-ink); font-size: 16px; letter-spacing: -.02em; }
.modal-close { border-radius: 6px; }
.modal-close:hover { background: #eef3fb; color: var(--rx-ink); }
#edit-text, .tools-input { border-color: #cfd9ea; border-radius: 8px; color: var(--rx-text); }
#edit-text:focus, .tools-input:focus { border-color: var(--rx-blue); outline: 3px solid rgba(37,99,235,.14); }
.modal-row { padding-top: 2px; }
.modal-row label { color: #4b5971; font-weight: 600; }
.modal-note { color: var(--rx-muted); }

.fidelity-panel { margin-top: 17px; padding: 14px; border: 1px solid #d8e1ef; border-radius: 10px; background: #f9fbfe; }
.fidelity-head { display: flex; flex-direction: column; gap: 3px; }
.fidelity-kicker { color: var(--rx-blue); font-size: 10px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.fidelity-head strong { color: var(--rx-ink); font-size: 13px; }
.font-upload-status { margin: 7px 0 0; color: var(--rx-muted); font-size: 12px; line-height: 1.55; }
.font-upload-status:empty { display: none; }
.fidelity-option { display: flex; align-items: flex-start; gap: 9px; margin-top: 8px; padding: 9px; border: 1px solid #dce5f2; border-radius: 8px; background: #fff; cursor: pointer; }
.fidelity-option:has(input:checked) { border-color: #9ebaf7; background: #f3f7ff; }
.fidelity-option:has(input:disabled) { opacity: .58; cursor: not-allowed; }
.fidelity-option input { margin-top: 3px; accent-color: var(--rx-blue); }
.fidelity-option span { display: flex; flex-direction: column; gap: 3px; }
.fidelity-option b { color: var(--rx-ink); font-size: 12px; }
.fidelity-option small { color: var(--rx-muted); font-size: 11px; line-height: 1.45; }
.font-upload { width: 100%; justify-content: center; margin-top: 10px; color: var(--rx-blue); background: #fff; }
.disclaimer-ack { display: flex; align-items: center; gap: 7px; margin-top: 12px; color: var(--rx-muted); font-size: 12px; }
.disclaimer-ack input { accent-color: var(--rx-blue); }
.disclaimer-open { padding: 0; border: 0; color: var(--rx-muted); background: transparent; font: inherit; text-decoration: underline; cursor: pointer; }
.disclaimer-open:hover { color: var(--rx-blue); }
.legal-disclaimer-box { max-width: 500px; }
.legal-disclaimer-body { color: var(--rx-text); font-size: 13px; line-height: 1.75; }
.legal-disclaimer-body p { margin: 0 0 12px; }

.tools-box { max-width: 720px; background: #fbfcff; }
.tools-grid { gap: 10px; }
.tool-card { min-height: 156px; gap: 8px; padding: 20px 13px 16px; border-color: #dce4f0; border-radius: 11px; background: #fff; box-shadow: none; }
.tool-card:hover { transform: translateY(-2px); border-color: #9ebbf5; box-shadow: 0 10px 22px rgba(23,50,93,.10); }
.tool-card-icon { width: 42px; height: 42px; border-radius: 9px; color: var(--rx-blue); background: #edf3ff; font-size: 20px; }
.tool-card-name { font-size: 13px; }
.tool-card-desc { color: var(--rx-muted); font-size: 11px; }
.tools-back-row { padding-bottom: 12px; border-bottom: 1px solid #e1e8f3; }
.tools-title { color: var(--rx-ink); }
.tools-hint { color: var(--rx-muted); line-height: 1.7; }
.tools-list { border-color: #dce4f0; border-radius: 8px; }

.saving { background: rgba(6,14,29,.58); backdrop-filter: blur(5px); }
.saving-box { color: var(--rx-ink); border: 1px solid #e2e8f2; border-radius: 12px; box-shadow: var(--rx-shadow); }
.app-toast, .tools-toast { top: 78px; border: 1px solid rgba(255,255,255,.13); border-radius: 9px; background: var(--rx-ink); box-shadow: 0 14px 32px rgba(6,14,29,.25); font-weight: 600; }
.app-toast--err, .tools-toast--err { background: #9f2c2c; }

@media (max-width: 920px) {
  .privacy-status { display: none; }
  #toolbar-actions { margin-left: 0; }
}
@media (max-width: 720px) {
  #toolbar { min-height: 0; padding: 10px 14px; gap: 9px; }
  .brand { width: auto; font-size: 15px; }
  .brand-product { display: none; }
  #toolbar-actions { width: 100%; justify-content: flex-start; gap: 7px; }
  #toolbar-actions .btn { flex: 1 1 auto; min-height: 38px; padding: 8px 9px; font-size: 12px; }
  #toolbar-actions #btn-download { flex-basis: 100%; }
  #toolbar-actions .page-count { margin-left: 0; }
  .file-status { display: none; }
  #workspace { padding: 13px; }
  #drop-zone { min-height: 360px; border-radius: 15px; }
  .drop-inner { padding: 36px 20px; }
  .drop-title { font-size: 23px; }
  .drop-hint { font-size: 13px; }
  .modal-box { padding: 17px; border-radius: 13px; }
  .fidelity-panel { padding: 11px; }
  .tools-grid { gap: 9px; }
  .tool-card { min-height: 134px; padding: 15px 8px 12px; }
  .tool-card-icon { width: 38px; height: 38px; }
  .tool-card-desc { line-height: 1.35; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

/* ============================================================
 * PDFbuff · 批注 / 学习子系统（Stage 1）
 * 非破坏性标注层：原文字层保持可选中 / 可搜索。
 * ============================================================ */
.annot-layer { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.annot-svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.annot-svg [data-id] { cursor: pointer; }

/* 批注模式：文字层可选中（用于高亮/划线选区），且取消编辑态边框 */
#workspace.annotate-mode .text-layer .tl-item { pointer-events: auto; cursor: text; }
#workspace.annotate-mode .text-layer .tl-item:hover { background: rgba(37,99,235,.08); outline: none; }
/* 绘制类工具：标注层接收指针（画形状/放笔记/擦除） */
.annot-draw .annot-layer { pointer-events: auto; }
.annot-draw .annot-svg { pointer-events: auto; }

.annot-note {
  position: absolute; width: 17px; height: 17px; border-radius: 50% 50% 50% 2px;
  background: #fff; border: 2px solid #F0C828; transform: translate(-3px, -15px);
  cursor: pointer; pointer-events: auto; box-shadow: 0 1px 3px rgba(15,23,42,.25); z-index: 5;
}
.annot-note:hover { transform: translate(-3px, -15px) scale(1.15); }

/* 浮动工具栏 */
.annot-toolbar {
  position: sticky; top: 64px; z-index: 45; display: flex; align-items: center; gap: 6px;
  flex-wrap: wrap; padding: 8px 14px; margin: 0 auto; max-width: 980px;
  background: rgba(255,255,255,.96); border: 1px solid var(--rx-line); border-radius: 12px;
  box-shadow: 0 8px 24px rgba(15,23,58,.08); backdrop-filter: blur(10px);
}
.annot-tool {
  padding: 6px 11px; border: 1px solid var(--rx-line); border-radius: 8px; background: #fff;
  font-size: 12.5px; font-weight: 650; color: var(--rx-text); cursor: pointer; user-select: none;
}
.annot-tool:hover { border-color: #b7c6df; background: #f4f7fc; }
.annot-tool.active { border-color: var(--rx-blue); background: var(--rx-blue); color: #fff; }
.annot-sep { width: 1px; height: 22px; background: var(--rx-line); margin: 0 2px; }
.annot-color {
  width: 20px; height: 20px; border-radius: 6px; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--rx-line);
  cursor: pointer; padding: 0;
}
.annot-color.active { box-shadow: 0 0 0 2px var(--rx-blue); transform: scale(1.12); }
.annot-color-label { font-size: 12px; color: var(--rx-muted); font-weight: 700; margin-left: 4px; }

/* 交互态与可达性：平滑过渡 + 可见键盘焦点（对齐全局 a11y 规范） */
.annot-tool, .annot-popup-tool, .annot-chip, .annot-btn, .annot-color, .annot-popup-color {
  transition: background .15s ease, border-color .15s ease, color .15s ease, box-shadow .15s ease, transform .12s ease;
}
.annot-tool:active, .annot-popup-tool:active, .annot-chip:active, .annot-btn:active { transform: translateY(1px); }
.annot-color:not(.active):hover, .annot-popup-color:not(.active):hover { transform: scale(1.08); }
.annot-note { transition: transform .15s ease; }
.annot-tool:focus-visible, .annot-popup-tool:focus-visible, .annot-chip:focus-visible,
.annot-btn:focus-visible, .annot-color:focus-visible, .annot-popup-color:focus-visible,
.annot-item-del:focus-visible, .annot-note:focus-visible, .annot-panel-close:focus-visible {
  outline: 3px solid rgba(37,99,235,.35); outline-offset: 2px;
}
.annot-item-del:focus-visible { color: #ef4444; }

/* 选区弹出 */
.annot-popup {
  position: fixed; z-index: 120; display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  background: #fff; border: 1px solid var(--rx-line); border-radius: 10px; padding: 7px 9px;
  box-shadow: 0 12px 32px rgba(15,23,58,.18); max-width: 320px;
}
.annot-popup-tool {
  padding: 5px 10px; border: 1px solid var(--rx-line); border-radius: 7px; background: #fff;
  font-size: 12px; font-weight: 650; color: var(--rx-text); cursor: pointer;
}
.annot-popup-tool:hover { border-color: var(--rx-blue); color: var(--rx-blue); }
.annot-popup-color { width: 18px; height: 18px; border-radius: 5px; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--rx-line); cursor: pointer; padding: 0; }

/* 右侧面板 */
.annot-panel {
  position: fixed; top: 0; right: 0; height: 100%; width: 320px; max-width: 88vw; z-index: 70;
  background: #fff; border-left: 1px solid var(--rx-line); box-shadow: -12px 0 32px rgba(15,23,58,.10);
  transform: translateX(100%); transition: transform .22s ease; display: flex; flex-direction: column;
}
.annot-panel.open { transform: translateX(0); }
.annot-panel-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid #eef2f7; font-weight: 700; font-size: 15px; color: var(--rx-ink); }
.annot-panel-close { border: none; background: none; font-size: 20px; cursor: pointer; color: var(--rx-muted); line-height: 1; }
.annot-count { font-size: 12px; font-weight: 700; color: var(--rx-blue-dark); background: var(--rx-blue-pale); border-radius: 999px; padding: 2px 9px; }
.annot-panel-close:hover { color: var(--rx-ink); }
.annot-filters { display: flex; gap: 6px; flex-wrap: wrap; padding: 10px 14px; border-bottom: 1px solid #f1f5f9; }
.annot-chip { padding: 4px 10px; border: 1px solid var(--rx-line); border-radius: 999px; background: #fff; font-size: 12px; color: var(--rx-text); cursor: pointer; font-weight: 600; }
.annot-chip.active { border-color: var(--rx-blue); background: var(--rx-blue-pale); color: var(--rx-blue-dark); }
.annot-panel-actions { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 14px; border-bottom: 1px solid #f1f5f9; }
.annot-btn { padding: 6px 10px; border: 1px solid var(--rx-line); border-radius: 8px; background: #fff; font-size: 12px; font-weight: 650; color: var(--rx-text); cursor: pointer; }
.annot-btn:hover { border-color: var(--rx-blue); color: var(--rx-blue); }
.annot-btn.active { border-color: var(--rx-blue); background: var(--rx-blue-pale); color: var(--rx-blue-dark); }
.annot-panel-list { flex: 1; overflow-y: auto; padding: 10px 12px; }
.annot-item { display: flex; align-items: flex-start; gap: 8px; padding: 9px 10px; border-radius: 9px; cursor: pointer; border: 1px solid transparent; }
.annot-item:hover { background: #f5f8fc; border-color: #e6edf7; }
.annot-dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 4px; flex: 0 0 auto; }
.annot-item-main { flex: 1; min-width: 0; }
.annot-item-meta { font-size: 11px; color: var(--rx-muted); font-weight: 700; }
.annot-item-body { font-size: 13px; color: var(--rx-text); line-height: 1.5; word-break: break-word; }
.annot-item-note { font-size: 12px; color: #475569; line-height: 1.5; margin-top: 2px; word-break: break-word; }
.annot-item-del { border: none; background: none; color: #cbd5e1; font-size: 18px; cursor: pointer; line-height: 1; }
.annot-item-del:hover { color: #ef4444; }
.annot-empty { font-size: 13px; color: var(--rx-muted); line-height: 1.7; padding: 8px 4px; }
.annot-review-item { padding: 11px 12px; border-radius: 10px; background: #f8fafc; border: 1px solid #eef2f7; margin-bottom: 8px; cursor: pointer; }
.annot-review-item:hover { border-color: var(--rx-blue); }
.annot-review-front { font-size: 13px; color: var(--rx-text); line-height: 1.5; font-weight: 600; }
.annot-review-back { font-size: 12.5px; color: #475569; line-height: 1.6; margin-top: 4px; }
.annot-flash { position: absolute; inset: 0; border: 2px solid var(--rx-blue); border-radius: 4px; animation: annotFlash .9s ease; pointer-events: none; }
@keyframes annotFlash { 0% { opacity: 0; } 20% { opacity: 1; } 100% { opacity: 0; } }

/* 笔记编辑浮层 */
.annot-note-popover {
  position: fixed; z-index: 130; width: 260px; background: #fff; border: 1px solid var(--rx-line);
  border-radius: 12px; padding: 12px; box-shadow: 0 16px 40px rgba(15,23,58,.20);
}
.annot-note-popover textarea { width: 100%; border: 1px solid var(--rx-line); border-radius: 8px; padding: 8px; font-family: inherit; font-size: 13px; resize: vertical; color: var(--rx-text); }
.annot-note-popover textarea:focus { outline: none; border-color: var(--rx-blue); box-shadow: 0 0 0 3px rgba(37,99,235,.14); }
.annot-note-actions { display: flex; gap: 6px; margin-top: 8px; }

/* 顶部批注切换按钮（激活态） */
#btn-annotate.active { border-color: var(--rx-blue); background: var(--rx-blue-pale); color: var(--rx-blue-dark); }

@media (max-width: 720px) {
  .annot-toolbar { top: 56px; padding: 6px 10px; gap: 5px; }
  .annot-tool { padding: 6px 9px; font-size: 11.5px; min-height: 38px; }
  .annot-color { width: 22px; height: 22px; }
  .annot-popup-color { width: 22px; height: 22px; }
  .annot-chip { padding: 6px 12px; min-height: 34px; }
  .annot-btn { padding: 8px 12px; min-height: 36px; }
  .annot-panel { width: 100%; max-width: 100%; }
}

/* ===== 底部合规入口 =====
   隐私政策与开源许可必须可直接访问（上架审核与许可合规要求），
   放在主工作区之后；body 是 flex column，这里不参与拉伸。 */
#site-footer {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px clamp(16px, 3vw, 24px);
  background: var(--rx-white);
  border-top: 1px solid var(--rx-line);
  font-size: 12px;
  color: var(--rx-muted);
}
#site-footer a { color: var(--rx-blue); text-decoration: none; }
#site-footer a:hover { text-decoration: underline; }
.footer-brand { font-weight: 600; color: var(--rx-text); }
.footer-sep { color: var(--rx-line); }
.footer-note { margin-left: auto; }
