:root {
  --paper: #F2F1F7;
  --panel: #FFFFFF;
  --ink: #211C2B;
  --ink-soft: #6B6379;
  --line: #E5E1ED;
  --line-2: #D3CDE0;
  --accent: #4A32B0;
  --accent-deep: #38238C;
  --accent-tint: #EFEBFB;
  --err: #C0392B;
  --err-deep: #A12C20;
  --ok: #2E7D55;
  --mono: ui-monospace, 'SF Mono', 'JetBrains Mono', 'Cascadia Mono', Consolas, monospace;
  --sans: system-ui, -apple-system, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  /* 取色盘色域的右端色相，脚本按当前颜色覆盖 */
  --hue-color: #FF0000;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

body {
  margin: 0;
  padding: 26px 20px 20px;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.55;
  background:
    radial-gradient(1100px 380px at 50% -200px, #E5DFF9 0%, rgba(229, 223, 249, 0) 72%),
    var(--paper);
}

.app { max-width: 1180px; margin: 0 auto; }

/* ---------- 顶栏（放在左栏顶部，不再单独占一整行） ---------- */
.top {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  padding: 0 2px;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.logo {
  flex: none;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(155deg, #6B4BF0, var(--accent));
  color: #fff;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .3px;
  box-shadow: 0 10px 20px -12px rgba(74, 50, 176, .95);
}
.brand h1 { margin: 0; font-size: 19px; font-weight: 600; letter-spacing: -.2px; }
.tagline { margin: 2px 0 0; font-size: 12.5px; color: var(--ink-soft); }

.top-side { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex: none; }
/* 顶栏跳转子工具的入口，窄屏自动换行 */
.top-links { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.stat { display: flex; align-items: baseline; gap: 3px; font-size: 12px; color: var(--ink-soft); }
.stat b {
  font-family: var(--mono);
  font-size: 19px;
  font-weight: 600;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.ghost-btn {
  display: inline-block;
  padding: 7px 12px;
  border: 1px solid #DACEED;
  border-radius: 8px;
  background: var(--accent-tint);
  color: var(--accent);
  font-size: 12.5px;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  transition: background .15s, border-color .15s;
}
.ghost-btn:hover { background: #E6DEFA; border-color: #C9B8E8; }

/* ---------- 布局 ---------- */
.workspace {
  display: grid;
  grid-template-columns: 352px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}
.col-left { display: flex; flex-direction: column; gap: 14px; min-width: 0; }

.card {
  padding: 14px 16px 16px;
  background: var(--panel);
  border: 1px solid var(--line-2);
  border-radius: 10px;
  box-shadow: 0 16px 34px -30px rgba(33, 28, 43, .6);
  min-width: 0;
}
.card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
}
.card-title i {
  flex: none;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 6px;
  background: var(--accent-tint);
  color: var(--accent);
  font-family: var(--mono);
  font-size: 11px;
  font-style: normal;
  font-weight: 700;
}

/* ---------- 拖放上传 ---------- */
.drop {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 20px 14px;
  text-align: center;
  border: 1.5px dashed var(--line-2);
  border-radius: 9px;
  background: #FAF9FD;
  cursor: pointer;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.drop:hover,
.drop.is-over,
.drop:focus-within {
  border-color: var(--accent);
  background: var(--accent-tint);
}
.drop:focus-within { box-shadow: 0 0 0 3px var(--accent-tint); }
.drop.is-loaded { border-style: solid; border-color: #BFD9CB; background: #F4FBF7; }
.drop-icon { width: 26px; height: 26px; color: var(--accent); margin-bottom: 2px; }
.drop.is-loaded .drop-icon { color: var(--ok); }
.drop-title {
  max-width: 100%;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
  overflow-wrap: anywhere;
}
.drop-sub { font-size: 11.5px; color: var(--ink-soft); overflow-wrap: anywhere; }

/* ---------- 操作切换 ---------- */
.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  margin-bottom: 14px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #F4F2F9;
}
.tab {
  padding: 8px 2px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink-soft);
  font: inherit;
  font-size: 12.5px;
  white-space: nowrap;
  cursor: pointer;
  transition: background .15s, color .15s, box-shadow .15s;
}
.tab:hover { color: var(--ink); }
.tab.is-active {
  background: #fff;
  color: var(--accent);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(33, 28, 43, .13);
}

.pane { animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(-2px); } to { opacity: 1; transform: none; } }

/* ---------- 表单元素 ---------- */
.field { display: block; margin-bottom: 12px; }
.label {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  color: var(--ink-soft);
}
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

input[type="text"],
input[type="number"],
select {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  background: #FCFBFE;
  color: var(--ink);
  font: inherit;
  font-size: 13.5px;
  outline: none;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
input[type="text"]:focus,
input[type="number"]:focus,
select:focus {
  background: #fff;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}
input::placeholder { color: #A9A2B8; }

input[type="file"] {
  width: 100%;
  padding: 9px 10px;
  border: 1px dashed var(--line-2);
  border-radius: 8px;
  background: #FAF9FD;
  color: var(--ink-soft);
  font: inherit;
  font-size: 12px;
}
input[type="file"]::file-selector-button {
  margin-right: 10px;
  padding: 5px 11px;
  border: 1px solid var(--line-2);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  transition: border-color .15s, color .15s;
}
input[type="file"]::file-selector-button:hover { border-color: var(--accent); color: var(--accent); }

.hint {
  margin: -2px 0 12px;
  color: var(--ink-soft);
  font-size: 11.5px;
  line-height: 1.7;
}
.hint code {
  padding: 1px 4px;
  border: 1px solid #E1DBEF;
  border-radius: 4px;
  background: #F4F1FB;
  color: #4B3FA0;
  font-family: var(--mono);
  font-size: 11px;
}

/* ---------- 按钮 ---------- */
.btn {
  padding: 9px 16px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, border-color .15s, opacity .15s, transform .06s;
}
.btn:hover { background: var(--accent-deep); border-color: var(--accent-deep); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; background: var(--accent); border-color: var(--accent); }
.btn-danger { background: var(--err); border-color: var(--err); }
.btn-danger:hover { background: var(--err-deep); border-color: var(--err-deep); }
.btn-quiet { background: #fff; border-color: var(--line-2); color: var(--ink-soft); font-weight: 500; }
.btn-quiet:hover { background: #F7F6FB; border-color: var(--line-2); color: var(--ink); }
.btn-block { display: block; width: 100%; }

/* ---------- 预览 ---------- */
/* 卡片按视口高度铺满：上方留 body 的 26px，下方留 20px，
   预览区用 flex 吃掉剩余空间，底部不会再空一块，也不会顶出窗口 */
.preview-card {
  position: sticky;
  top: 20px;
  display: flex;
  flex-direction: column;
  height: calc(100vh - 46px);
  height: calc(100dvh - 46px);
}
.card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: none;
  margin-bottom: 12px;
}
.card-head .card-title { margin: 0; flex: none; }
.head-actions { display: flex; gap: 8px; flex: none; margin-left: auto; }

.hist-step {
  min-width: 0;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--ink-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.icon-btn {
  flex: none;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  background: #fff;
  color: var(--ink-soft);
  cursor: pointer;
  transition: color .15s, border-color .15s, background .15s;
}
.icon-btn svg { width: 17px; height: 17px; }
.icon-btn:hover:not(:disabled) { color: var(--accent); border-color: #C6AEE2; background: var(--accent-tint); }
.icon-btn:disabled { opacity: .38; cursor: not-allowed; }

.preview {
  position: relative;
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 120px;
  border: 1px solid var(--line-2);
  border-radius: 9px;
  overflow: hidden;
  background: #EFEDF5;
}

/* ---------- 预览工具栏（自绘，全部中文） ---------- */
.viewer-bar {
  flex: none;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  padding: 7px 10px;
  border-bottom: 1px solid var(--line-2);
  background: #FBFAFE;
}
.viewer-group { display: flex; align-items: center; gap: 2px; }
.viewer-group-end { margin-left: auto; }
.viewer-sep { flex: none; width: 1px; height: 16px; background: var(--line-2); }
.viewer-btn {
  display: grid;
  place-items: center;
  min-width: 28px;
  height: 28px;
  padding: 0 6px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--ink-soft);
  font: inherit;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.viewer-btn svg { width: 15px; height: 15px; }
.viewer-btn:hover:not(:disabled) { background: var(--accent-tint); color: var(--accent); }
.viewer-btn:disabled { opacity: .38; cursor: not-allowed; }
.viewer-btn[aria-pressed="false"] { color: #A9A2B8; }
.viewer-btn-wide { padding: 0 9px; font-size: 12.5px; border-color: var(--line-2); background: #fff; }
.viewer-btn-wide:hover:not(:disabled) { border-color: #C6AEE2; }

.viewer-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-soft);
}
.viewer-nav input {
  width: 44px;
  padding: 3px 4px;
  border: 1px solid var(--line-2);
  border-radius: 5px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-family: var(--mono);
  font-size: 12px;
  text-align: center;
  outline: none;
  appearance: textfield;
}
.viewer-nav input::-webkit-outer-spin-button,
.viewer-nav input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.viewer-nav input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint); }
.viewer-nav b { font-weight: 600; color: var(--ink); margin-left: 3px; }
.viewer-zoom {
  min-width: 44px;
  text-align: center;
  font-family: var(--mono);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--ink-soft);
}

.viewer-body {
  flex: 1;
  display: flex;
  min-height: 0;
}

/* ---------- 标注工具条 ---------- */
.annot-bar {
  flex: none;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--line-2);
  background: #FBF8FF;
}
.annot-tools,
.annot-widths,
.annot-actions { display: flex; align-items: center; gap: 4px; }
/* 窄屏放不下就换行，按钮本身不许被压得文字折行 */
.annot-tools { flex-wrap: wrap; min-width: 0; }
/* 颜色与粗细合成一组，换行时整体挪到下一行，不会被拆散 */
.annot-style {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 0 0 auto;
}
.annot-style .annot-colors { flex: none; }
.annot-style .annot-widths { flex: none; }
.annot-tool,
.annot-actions button {
  padding: 4px 9px;
  border: 1px solid var(--line-2);
  border-radius: 6px;
  background: #fff;
  color: var(--ink-soft);
  font: inherit;
  font-size: 12px;
  white-space: nowrap;
  cursor: pointer;
  transition: border-color .15s, color .15s, background .15s;
}
.annot-tool:hover,
.annot-actions button:hover:not(:disabled) { border-color: #C6AEE2; color: var(--accent); }
.annot-tool.is-active {
  border-color: var(--accent);
  background: var(--accent-tint);
  color: var(--accent);
  font-weight: 600;
}
.annot-actions { margin-left: auto; gap: 5px; }
.annot-actions button.annot-icon {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  padding: 0;
}
.annot-icon svg { width: 15px; height: 15px; }
.annot-actions button:disabled { opacity: .38; cursor: not-allowed; }
.annot-widths { gap: 7px; }
.annot-size {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
  min-width: 50px;
  color: var(--ink-soft);
  font-family: var(--mono);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

/* 按当前粗细缩放的小圆点，直观看出笔头多大 */
.annot-dot { flex: none; border-radius: 50%; background: currentColor; }
.annot-range {
  width: 96px;
  height: 20px;
  accent-color: var(--accent);
  cursor: pointer;
}
.annot-colors { display: flex; align-items: center; gap: 7px; }
/* 橡皮不落色，整排调淡并且不可点 */
.annot-colors.is-muted { opacity: .4; pointer-events: none; }
.annot-color {
  width: 18px;
  height: 18px;
  padding: 0;
  border: 1px solid rgba(33, 28, 43, .18);
  border-radius: 50%;
  background: var(--c);
  cursor: pointer;
}
.annot-color.is-active { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--accent); }

/* 取色盘入口：外圈彩虹，内点显示最近使用的自定义色 */
.annot-color-custom {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  padding: 0;
  border: 1px solid rgba(33, 28, 43, .18);
  border-radius: 50%;
  background: conic-gradient(#E5484D, #F5A524, #2F9E44, #2F6FEB, #7048E8, #E5484D);
  cursor: pointer;
}
.annot-custom-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .75);
}
.annot-color-custom.is-active { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--accent); }

/* ---------- 自定义取色盘 ---------- */
.color-pop {
  position: fixed;
  z-index: 58;
  display: grid;
  gap: 8px;
  width: 212px;
  padding: 10px;
  border: 1px solid var(--line-2);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 20px 44px -20px rgba(33, 28, 43, .5);
}
.color-pop[hidden] { display: none; }
.cp-sv {
  position: relative;
  height: 118px;
  border-radius: 8px;
  cursor: crosshair;
  overflow: hidden;
  background:
    linear-gradient(to top, #000, rgba(0, 0, 0, 0)),
    linear-gradient(to right, #fff, var(--hue-color, #FF0000));
}
.cp-thumb {
  position: absolute;
  width: 12px;
  height: 12px;
  margin: -6px 0 0 -6px;
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .45);
  pointer-events: none;
}
.cp-line { position: relative; height: 12px; }
.cp-hue-track,
.cp-alpha-track {
  position: absolute;
  inset: 1px 0;
  border-radius: 6px;
}
.cp-hue-track {
  background: linear-gradient(to right, #FF0000, #FFFF00 17%, #00FF00 33%, #00FFFF 50%, #0000FF 67%, #FF00FF 83%, #FF0000);
}
.cp-alpha-track {
  background-color: #fff;
  background-image:
    linear-gradient(to right, rgba(255, 255, 255, 0), var(--c, #E5484D)),
    repeating-conic-gradient(#D9D4E4 0% 25%, #fff 0% 50%);
  background-size: auto, 10px 10px;
}
.cp-range {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  background: transparent;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}
.cp-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  border: 1px solid rgba(33, 28, 43, .4);
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(33, 28, 43, .35);
}
.cp-range::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border: 1px solid rgba(33, 28, 43, .4);
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(33, 28, 43, .35);
}
.cp-foot { display: flex; align-items: center; gap: 6px; }
.cp-hex {
  flex: 1;
  min-width: 0;
  height: 24px;
  padding: 0 7px;
  border: 1px solid var(--line-2);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 12px;
  text-transform: uppercase;
  outline: none;
}
.cp-hex:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint); }
.cp-alpha-text {
  font-family: var(--mono);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  color: var(--ink-soft);
}
.cp-done {
  padding: 4px 9px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}
.cp-done:hover { background: var(--accent-deep); }

/* ---------- 注释 / 文字编辑 ---------- */
.note-editor {
  position: fixed;
  z-index: 58;
  display: grid;
  gap: 8px;
  width: 264px;
  padding: 10px;
  border: 1px solid var(--line-2);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 20px 44px -20px rgba(33, 28, 43, .5);
}
.note-editor[hidden] { display: none; }
.ne-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ne-title { font-size: 12.5px; font-weight: 600; color: var(--ink); }
.ne-sizes { display: flex; gap: 3px; }
.ne-sizes[hidden] { display: none; }
.ne-size {
  min-width: 26px;
  padding: 2px 6px;
  border: 1px solid var(--line-2);
  border-radius: 5px;
  background: #fff;
  color: var(--ink-soft);
  font: inherit;
  font-size: 11.5px;
  cursor: pointer;
}
.ne-size:hover { border-color: #C6AEE2; color: var(--accent); }
.ne-size.is-active { border-color: var(--accent); background: var(--accent-tint); color: var(--accent); font-weight: 600; }
#neText {
  width: 100%;
  min-height: 62px;
  max-height: 180px;
  padding: 7px 8px;
  border: 1px solid var(--line-2);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 12.5px;
  line-height: 1.55;
  resize: vertical;
  outline: none;
}
#neText:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint); }
.ne-foot { display: flex; align-items: center; gap: 6px; }
.ne-hint { flex: 1; min-width: 0; font-size: 11px; color: var(--ink-soft); }
.ne-foot button {
  padding: 4px 10px;
  border-radius: 6px;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}
.ne-del { border: 1px solid #E7C4C1; background: #fff; color: #B03024; }
.ne-del:hover { background: #FBEDEC; }
.ne-del[hidden] { display: none; }
.ne-cancel { border: 1px solid var(--line-2); background: #fff; color: var(--ink-soft); }
.ne-cancel:hover { border-color: #C6AEE2; color: var(--accent); }
.ne-save { border: 1px solid var(--accent); background: var(--accent); color: #fff; }
.ne-save:hover { background: var(--accent-deep); }

/* ---------- 注释列表 ---------- */
.note-panel {
  position: fixed;
  inset: 0;
  z-index: 56;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(33, 28, 43, .34);
}
.note-panel[hidden] { display: none; }
.note-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(100%, 420px);
  max-height: min(70vh, 520px);
  padding: 14px 16px 16px;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 24px 60px -30px rgba(20, 16, 30, .85);
}
.note-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.note-head h3 { margin: 0; font-size: 14px; font-weight: 600; }
.note-list { display: flex; flex-direction: column; gap: 6px; overflow-y: auto; }
.note-item { display: flex; align-items: stretch; gap: 4px; }
.note-jump {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 7px 9px;
  border: 1px solid var(--line-2);
  border-radius: 7px;
  background: #fff;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.note-jump:hover { border-color: #C6AEE2; background: #FBF8FF; }
.note-badge {
  flex: none;
  min-width: 30px;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--accent-tint);
  color: var(--accent);
  font-family: var(--mono);
  font-size: 11px;
  text-align: center;
}
.note-kind { flex: none; font-size: 11px; color: var(--ink-soft); }
.note-text {
  flex: 1;
  min-width: 0;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--ink);
  overflow-wrap: anywhere;
}
.note-del {
  flex: none;
  display: grid;
  place-items: center;
  width: 28px;
  border: 1px solid var(--line-2);
  border-radius: 7px;
  background: #fff;
  color: var(--ink-soft);
  cursor: pointer;
}
.note-del:hover { border-color: #E7C4C1; background: #FBEDEC; color: #B03024; }
.note-del svg { width: 14px; height: 14px; }
.note-empty { padding: 18px 10px; color: var(--ink-soft); font-size: 12.5px; text-align: center; }

/* ---------- 左侧页面缩略图 ---------- */
.viewer-thumbs {
  flex: none;
  width: 116px;
  padding: 10px 6px;
  border-right: 1px solid var(--line-2);
  background: #F7F5FB;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.viewer-body.thumbs-off .viewer-thumbs { display: none; }
.viewer-thumb-list {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.viewer-thumb {
  position: relative;
  flex: none;
  padding: 0;
  border: 1px solid var(--line-2);
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
  line-height: 0;
  overflow: hidden;
  transition: border-color .15s, box-shadow .15s;
}
.viewer-thumb:hover { border-color: #C6AEE2; }
.viewer-thumb.is-active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-tint); }
.viewer-thumb canvas { display: block; max-width: 100%; height: auto; }
.viewer-thumb-no {
  position: absolute;
  right: 3px;
  bottom: 3px;
  padding: 0 4px;
  border-radius: 3px;
  background: rgba(36, 31, 49, .62);
  color: #fff;
  font-family: var(--mono);
  font-size: 10px;
  line-height: 15px;
}

.viewer-scroll {
  flex: 1;
  min-width: 0;
  min-height: 0;
  overflow: auto;
  padding: 12px;
  background: #E9E6F1;
  overscroll-behavior: contain;
}
.viewer-pages {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.viewer-pages.two-up {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: center;
}
.viewer-page {
  position: relative;
  flex: none;
  max-width: 100%;
  overflow: hidden;
  border-radius: 2px;
  background: #fff;
  box-shadow: 0 8px 20px -12px rgba(33, 28, 43, .6);
}
.viewer-page canvas { display: block; width: 100%; height: 100%; }

/* 透明文字层：字本身是画在位图上的，这层只负责选中和复制 */
.text-layer {
  position: absolute;
  top: 0;
  left: 0;
  overflow: clip;
  line-height: 1;
  text-align: initial;
  text-size-adjust: none;
  forced-color-adjust: none;
  transform-origin: 0 0;
  z-index: 0;
  cursor: text;
  user-select: text;
}
/* pdf.js 的文字层按未旋转的页面坐标摆放，页面转了这里跟着转回来 */
.text-layer[data-rotate="90"] { transform: rotate(90deg) translateY(-100%); }
.text-layer[data-rotate="180"] { transform: rotate(180deg) translate(-100%, -100%); }
.text-layer[data-rotate="270"] { transform: rotate(270deg) translate(-100%, 0); }
.text-layer span,
.text-layer br {
  position: absolute;
  white-space: pre;
  color: transparent;
  transform-origin: 0% 0%;
  cursor: text;
}
.text-layer span.markedContent { top: 0; height: 0; }
.text-layer ::selection { background: rgba(47, 111, 235, .28); }
.text-layer br::selection { background: transparent; }

.annot-canvas { position: absolute; inset: 0; pointer-events: none; }
.viewer-scroll.is-annotating .annot-canvas { pointer-events: auto; cursor: crosshair; }
/* 画笔/荧光笔用自绘的笔头预览代替系统光标 */
.viewer-scroll.is-annotating.is-freetool .annot-canvas { cursor: none; }
.viewer-scroll.is-annotating.is-erasertool .annot-canvas { cursor: none; }
.viewer-scroll.is-annotating.is-texttool .annot-canvas { cursor: text; }
/* 划线 / 高亮靠拖选文字触发，标注画布这时候不拦指针 */
.viewer-scroll.is-annotating.is-textmarktool .annot-canvas { pointer-events: none; cursor: text; }
/* 标注模式下系统滚动和缩放交给脚本处理 */
.viewer-scroll.is-annotating .viewer-page { touch-action: none; }
/* 选字要交给浏览器，触屏上不能禁用默认手势 */
.viewer-scroll.is-annotating.is-textmarktool .viewer-page { touch-action: auto; }

/* 跟随鼠标的笔头预览，大小就是实际落笔的粗细 */
.annot-cursor {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 40;
  border: 1px solid currentColor;
  border-radius: 50%;
  /* 白色外圈让细笔头在深色/浅色页面上都能看清 */
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .9);
  pointer-events: none;
  transform: translate(-50%, -50%);
}

/* 正中心的落笔点，笔头很细时也能看到位置 */
.annot-cursor::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: 2px;
  height: 2px;
  margin: -1px 0 0 -1px;
  border-radius: 50%;
  background: currentColor;
}

.viewer-page[data-state="error"] {
  display: grid;
  place-items: center;
  padding: 12px;
  color: var(--err);
  font-size: 12px;
}

.viewer-status {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  text-align: center;
  font-size: 13px;
  color: var(--ink-soft);
  background: rgba(243, 241, 249, .88);
}

/* ---------- 全屏演示 ---------- */
.preview:fullscreen {
  height: 100%;
  max-height: none;
  border: 0;
  border-radius: 0;
}
.preview.is-presenting .viewer-bar,
.preview.is-presenting .annot-bar,
.preview.is-presenting .viewer-body { display: none; }
.present-stage {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #17151F;
}
.present-stage canvas {
  background: #fff;
  box-shadow: 0 24px 60px -30px #000;
}
.present-bar {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 14px;
  color: #C9C4D8;
  font-family: var(--mono);
  font-size: 12px;
  white-space: nowrap;
}

/* ---------- 文档属性 ---------- */
.info-panel {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 14px;
  background: rgba(33, 28, 43, .34);
}
.info-card {
  width: min(100%, 420px);
  max-height: 100%;
  overflow: auto;
  padding: 14px 16px 16px;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 24px 60px -30px rgba(20, 16, 30, .85);
}
.info-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.info-head h3 { margin: 0; font-size: 14px; font-weight: 600; }
.info-list {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 7px 10px;
  margin: 0;
  font-size: 12.5px;
}
.info-list dt { color: var(--ink-soft); }
.info-list dd { margin: 0; overflow-wrap: anywhere; }

.preview-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 24px;
  text-align: center;
  color: var(--ink-soft);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .75), rgba(255, 255, 255, .75)),
    repeating-linear-gradient(45deg, #EDEAF4 0 12px, #F5F3F9 12px 24px);
}
.preview-empty svg { width: 34px; height: 34px; color: #BCB4CC; }
.preview-empty p { margin: 0; font-size: 13.5px; font-weight: 600; color: #5F5870; }
.preview-empty span { font-size: 12px; max-width: 260px; }

/* ---------- 提示条 ---------- */
.toasts {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 50;
  pointer-events: none;
}
.toast {
  max-width: min(90vw, 460px);
  padding: 10px 16px;
  border-radius: 8px;
  background: #241F31;
  color: #fff;
  font-size: 13px;
  line-height: 1.5;
  box-shadow: 0 14px 30px -18px rgba(20, 16, 30, .9);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .18s, transform .18s;
}
.toast.is-in { opacity: 1; transform: none; }
.toast-ok { background: #26694A; }
.toast-err { background: #B03024; }

/* ---------- 载入遮罩 ---------- */
.busy {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  background: rgba(240, 237, 247, .66);
  backdrop-filter: blur(2px);
}
.busy-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
  min-width: 230px;
  padding: 22px 28px;
  border-radius: 14px;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: 0 22px 46px -22px rgba(33, 28, 43, .5);
}
.busy-spinner {
  width: 26px;
  height: 26px;
  border: 3px solid var(--accent-tint);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: busy-spin .8s linear infinite;
}
@keyframes busy-spin {
  to { transform: rotate(360deg); }
}
.busy-text { margin: 0; font-size: 13.5px; font-weight: 600; color: var(--ink); }
.busy-sub {
  margin: 0;
  max-width: 260px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--ink-soft);
  text-align: center;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
  .workspace { grid-template-columns: 1fr; }
  /* 单列时预览不再跟窗口绑定，按固定比例给一块高度 */
  .preview-card {
    position: static;
    display: block;
    height: auto;
  }
  .preview { height: 64vh; height: 64dvh; min-height: 360px; }
}
@media (max-width: 560px) {
  body { padding: 18px 12px 36px; }
  .top { gap: 12px; }
  .top-side { width: 100%; justify-content: space-between; }
  .brand h1 { font-size: 17px; }
  .card { padding: 12px 13px 14px; }
  .card-head { flex-wrap: wrap; }
  .hist-step { order: 3; flex: 1 0 100%; }
  .head-actions { width: 100%; margin-left: 0; }
  .head-actions .btn { flex: 1; }
  .row-2 { grid-template-columns: 1fr; gap: 0; }
  .tab { font-size: 11.5px; }
  .viewer-bar { flex-wrap: wrap; gap: 6px; }
  .viewer-group-end { margin-left: 0; }
  .viewer-sep { display: none; }
  .viewer-thumbs { width: 100px; padding: 8px 4px; }
  .viewer-scroll { padding: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
