:root {
  --bg: #f4f4f5;
  --surface: #ffffff;
  --surface-2: #ececee;
  --border: #dcdcdf;
  --text: #26262a;
  --text-dim: #8b8b92;
  --accent: #3b6ff5;
  --accent-soft: rgba(59, 111, 245, 0.12);
  --danger: #d43d3d;
  --shadow: 0 1px 3px rgba(0,0,0,0.10), 0 4px 16px rgba(0,0,0,0.06);
  --radius: 7px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1d1d20;
    --surface: #28282c;
    --surface-2: #232327;
    --border: #3a3a40;
    --text: #e7e7ea;
    --text-dim: #85858d;
    --accent: #6c93ff;
    --accent-soft: rgba(108, 147, 255, 0.16);
    --shadow: 0 1px 3px rgba(0,0,0,0.4), 0 4px 16px rgba(0,0,0,0.3);
  }
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; height: 100%;
  font: 13px/1.4 "Segoe UI", system-ui, sans-serif;
  color: var(--text);
  background: var(--bg);
  overflow: hidden;
  user-select: none;
}

body { display: flex; flex-direction: column; }

/* ---------- Tab bar ---------- */
#tabbar {
  display: flex; align-items: flex-end;
  background: var(--surface-2);
  padding: 6px 8px 0 8px;
  gap: 2px;
  flex: none;
}
#tabs { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; max-width: calc(100% - 40px); }
#tabs::-webkit-scrollbar { display: none; }
.tab {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px 7px 14px;
  max-width: 220px; min-width: 110px;
  border-radius: var(--radius) var(--radius) 0 0;
  color: var(--text-dim);
  cursor: default;
  white-space: nowrap;
  position: relative;
  flex: none;
}
.tab.active { background: var(--bg); color: var(--text); }
.tab:not(.active):hover { background: rgba(127,127,127,0.10); }
.tab .tab-title { overflow: hidden; text-overflow: ellipsis; flex: 1; }
.tab .tab-dirty { color: var(--accent); font-size: 15px; line-height: 0; }
.tab .tab-close {
  border: none; background: none; color: inherit;
  font-size: 13px; line-height: 1; padding: 3px 5px;
  border-radius: 4px; cursor: pointer; opacity: 0.55;
}
.tab .tab-close:hover { background: rgba(127,127,127,0.22); opacity: 1; }
#btn-newtab { font-size: 16px; margin-bottom: 4px; }

/* ---------- Toolbar ---------- */
#toolbar {
  display: flex; align-items: center; gap: 4px;
  padding: 6px 10px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  flex: none;
}
.tb-group { display: flex; align-items: center; gap: 2px; }
.tb-sep { width: 1px; height: 20px; background: var(--border); margin: 0 8px; }
.tb-spacer { flex: 1; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 28px;
  border: none; border-radius: 6px;
  background: transparent; color: var(--text);
  cursor: pointer; padding: 0;
}
.icon-btn:hover { background: rgba(127,127,127,0.14); }
.icon-btn:disabled { opacity: 0.35; cursor: default; background: transparent; }
.icon-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn.tool.active { background: var(--accent-soft); color: var(--accent); }

#page-input, #zoom-input {
  width: 38px; text-align: center;
  border: 1px solid transparent; border-radius: 5px;
  background: transparent; color: var(--text);
  padding: 3px 2px; font: inherit; font-variant-numeric: tabular-nums;
}
#zoom-input { width: 52px; color: var(--text-dim); }
#zoom-input:focus { color: var(--text); }
#page-input:hover, #page-input:focus, #zoom-input:hover, #zoom-input:focus {
  border-color: var(--border); background: var(--surface); outline: none;
}
.dim { color: var(--text-dim); }
.small { font-size: 11px; }

#text-size, #text-font {
  border: 1px solid var(--border); border-radius: 5px;
  background: var(--surface); color: var(--text);
  font: inherit; padding: 2px 3px; margin: 0 2px;
  display: none;
}
#text-font { max-width: 130px; }
#text-size.visible, #text-font.visible { display: inline-block; }

/* ---------- Search bar ---------- */
#searchbar {
  position: absolute; top: 84px; right: 24px; z-index: 40;
  display: flex; align-items: center; gap: 4px;
  background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 5px 6px;
  box-shadow: var(--shadow);
}
#searchbar.hidden { display: none; }
#search-input {
  border: none; outline: none; background: transparent; color: var(--text);
  font: inherit; width: 200px; padding: 2px 4px;
}
#search-status { font-size: 11px; min-width: 46px; text-align: right; }

/* ---------- Main row: sidebar + viewer panes ---------- */
#main-row { flex: 1; display: flex; overflow: hidden; position: relative; }

#sidebar {
  width: 172px; flex: none;
  overflow-y: auto; overflow-x: hidden;
  background: var(--surface-2);
  border-right: 1px solid var(--border);
  padding: 12px 0 24px 0;
}
#sidebar.hidden { display: none; }
.thumb {
  position: relative;
  width: 124px; margin: 0 auto 14px auto;
  cursor: pointer;
}
.thumb-canvas-box {
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.18);
  border: 2px solid transparent;
  border-radius: 3px;
  overflow: hidden;
  min-height: 60px;
}
.thumb.current .thumb-canvas-box { border-color: var(--accent); }
.thumb canvas { display: block; width: 100%; }
.thumb-num {
  text-align: center; font-size: 11px; color: var(--text-dim);
  margin-top: 3px;
}
.thumb-actions {
  position: absolute; top: 4px; right: 4px;
  display: none; gap: 2px;
}
.thumb:hover .thumb-actions { display: flex; }
.thumb-actions button {
  width: 24px; height: 24px;
  border: none; border-radius: 5px;
  background: rgba(28,28,32,0.78); color: #fff;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.thumb-actions button:hover { background: rgba(28,28,32,0.95); }
.thumb-actions button svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.thumb.drag-over-before::before, .thumb.drag-over-after::after {
  content: ""; position: absolute; left: -8px; right: -8px; height: 3px;
  background: var(--accent); border-radius: 2px;
}
.thumb.drag-over-before::before { top: -8px; }
.thumb.drag-over-after::after { bottom: 5px; }
.thumb.dragging { opacity: 0.4; }

/* ---------- Viewer ---------- */
#viewer-root { flex: 1; position: relative; overflow: hidden; display: flex; min-width: 0; }
.pane { flex: 1; position: relative; overflow: hidden; min-width: 0; }
.pane.hidden { display: none; }
.pane + .pane { border-left: 1px solid var(--border); }
.pane-close-btn {
  position: absolute; top: 10px; right: 12px; z-index: 35;
  width: 26px; height: 26px;
  border-radius: 5px;
  background: var(--surface); color: var(--text-dim);
  border: 1px solid var(--border);
  box-shadow: 0 1px 4px rgba(0,0,0,0.14);
  display: none;
  align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600; cursor: pointer;
  opacity: 0.75;
  transition: opacity 0.15s ease, background 0.15s ease, color 0.15s ease;
}
body.split .pane-close-btn { display: flex; }
.pane-close-btn:hover {
  opacity: 1; color: var(--text);
  background: var(--surface-2);
  border-color: var(--text-dim);
}
body.split .pane.focused::after {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: var(--accent); z-index: 30; pointer-events: none; opacity: 0.7;
}
.pane-empty {
  position: absolute; inset: 0; z-index: 5;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
}
.pane-empty.hidden { display: none; }
.pane-open-btn {
  font: inherit; padding: 8px 20px;
  border: 1px dashed var(--border); border-radius: var(--radius);
  background: transparent; color: var(--text-dim); cursor: pointer;
}
.pane-open-btn:hover { color: var(--accent); border-color: var(--accent); }
.doc-scroll {
  position: absolute; inset: 0;
  overflow: auto;
  padding: 24px 0 60px 0;
}
.doc-scroll.hidden { display: none; }

.page-holder {
  position: relative;
  margin: 0 auto 18px auto;
  background: #fff;
  box-shadow: var(--shadow);
}
.page-holder canvas { display: block; position: absolute; inset: 0; }

/* pdf.js layers */
.page-holder .textLayer { z-index: 2; user-select: text; -webkit-user-select: text; }
.page-holder .textLayer span { user-select: text; -webkit-user-select: text; }
.page-holder .textLayer span::selection { background: rgba(59, 111, 245, 0.35); }
.page-holder .annotationLayer { z-index: 3; }

/* edit overlay */
.edit-layer { position: absolute; inset: 0; z-index: 4; }
.edit-layer.tool-active { cursor: crosshair; }
.edit-layer:not(.tool-active) { pointer-events: none; }
.edit-layer .edit-item { pointer-events: auto; }

.edit-item { position: absolute; }
.edit-item.redact { background: #111; outline: 1px solid transparent; }
.edit-item.redact::after {
  content: "REDACT"; color: rgba(255,255,255,0.4);
  font-size: 9px; letter-spacing: 1px;
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.edit-item.whiteout { background: #fff; outline: 1px dashed rgba(0,0,0,0.25); }
.edit-item.highlight { background: rgba(255, 214, 51, 0.45); mix-blend-mode: multiply; }
.edit-item.noteedit { width: 22px; height: 22px; cursor: default; }
.edit-item.noteedit .note-icon {
  width: 22px; height: 22px; color: #e8a812;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,0.25));
}
.edit-item.noteedit .note-icon svg { width: 22px; height: 22px; fill: #ffd633; stroke: #b47d00; stroke-width: 1.2; }
.edit-item.noteedit .note-bubble {
  position: absolute; left: 26px; top: 0;
  min-width: 160px; max-width: 260px;
  background: #fff9df; color: #3a3010;
  border: 1px solid #e5cd6a; border-radius: 6px;
  padding: 7px 9px; font-size: 12px; line-height: 1.4;
  box-shadow: var(--shadow);
  white-space: pre-wrap; word-break: break-word;
  display: none; z-index: 20; cursor: text;
}
.edit-item.noteedit:hover .note-bubble,
.edit-item.noteedit.selected .note-bubble,
.edit-item.noteedit .note-bubble[contenteditable="true"] { display: block; }
.edit-item.textedit {
  color: #111; background: transparent;
  white-space: pre; outline: none; min-width: 8px;
  font-family: Helvetica, Arial, sans-serif; line-height: 1.15;
  cursor: text;
}
.edit-item.imgedit img { width: 100%; height: 100%; display: block; }
.edit-item.selected { outline: 1.5px solid var(--accent) !important; }
.edit-item .resize-handle {
  position: absolute; right: -5px; bottom: -5px;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent); cursor: nwse-resize;
  display: none;
}
.edit-item.selected .resize-handle { display: block; }
.drag-rect { position: absolute; background: rgba(59,111,245,0.15); outline: 1px solid var(--accent); }

/* search highlight */
.textLayer .search-hit { background: rgba(255, 200, 0, 0.45); border-radius: 2px; }
.textLayer .search-hit.current { background: rgba(255, 140, 0, 0.65); }

/* ---------- Empty state ---------- */
#empty-state {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
}
#empty-state.hidden { display: none; }
.empty-card { text-align: center; color: var(--text-dim); }
.empty-logo { font-size: 28px; font-weight: 600; letter-spacing: -0.5px; color: var(--text); margin-bottom: 12px; }
#btn-open-empty {
  font: inherit; padding: 8px 22px; margin: 6px 0;
  border: none; border-radius: var(--radius);
  background: var(--accent); color: #fff; cursor: pointer;
}
#btn-open-empty:hover { filter: brightness(1.08); }

/* drop hint */
body.dragging #viewer-root::after {
  content: "Drop to open";
  position: absolute; inset: 10px;
  border: 2px dashed var(--accent); border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; color: var(--accent);
  background: var(--accent-soft);
  z-index: 100; pointer-events: none;
}

/* ---------- Compare panel ---------- */
#compare-panel {
  flex: none; height: 220px;
  display: flex; flex-direction: column;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
}
#compare-panel.hidden { display: none; }
#compare-header {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px 4px 12px;
  font-weight: 600;
}
#compare-list { flex: 1; overflow-y: auto; padding: 0 8px 10px 8px; user-select: text; }
.hunk {
  display: flex; gap: 10px; align-items: baseline;
  padding: 6px 8px; margin: 2px 0;
  border-radius: 6px; cursor: pointer;
  font-size: 12px; line-height: 1.45;
}
.hunk:hover { background: rgba(127,127,127,0.12); }
.hunk .hunk-page {
  flex: none; width: 84px; color: var(--text-dim);
  font-variant-numeric: tabular-nums; font-size: 11px;
}
.hunk .hunk-body { flex: 1; min-width: 0; }
.hunk .ctx { color: var(--text-dim); }
.hunk del {
  background: rgba(220, 70, 70, 0.16); color: #c94f4f;
  text-decoration: line-through; border-radius: 3px; padding: 0 2px;
}
.hunk ins {
  background: rgba(60, 160, 90, 0.16); color: #3f9e63;
  text-decoration: none; border-radius: 3px; padding: 0 2px;
}
.compare-note { padding: 14px; color: var(--text-dim); }

/* ---------- Selection popup ---------- */
#selection-popup {
  position: fixed; z-index: 60;
  display: flex; align-items: center; gap: 2px;
  background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 3px 4px;
  box-shadow: var(--shadow);
}
#selection-popup.hidden { display: none; }
#selection-popup button {
  font: inherit; font-size: 12px;
  border: none; border-radius: 5px;
  background: transparent; color: var(--text);
  padding: 4px 9px; cursor: pointer; white-space: nowrap;
}
#selection-popup button:hover { background: rgba(127,127,127,0.14); }
#selection-popup .sp-redact:hover { color: var(--danger); }

/* ---------- OCR area popup ---------- */
#ocr-popup {
  position: fixed; inset: 0; z-index: 70;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.25);
}
#ocr-popup.hidden { display: none; }
#ocr-popup-card {
  width: min(640px, calc(100vw - 80px));
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 10px 12px 12px 12px;
  gap: 8px;
}
#ocr-popup-header { display: flex; align-items: center; gap: 8px; font-weight: 600; }
#ocr-copy {
  font: inherit; font-size: 12px;
  border: none; border-radius: 5px;
  background: var(--accent); color: #fff;
  padding: 5px 14px; cursor: pointer;
}
#ocr-copy:hover { filter: brightness(1.08); }
#ocr-popup-text {
  width: 100%; height: min(320px, 45vh);
  resize: vertical;
  font: 13px/1.5 Consolas, "Segoe UI", monospace;
  border: 1px solid var(--border); border-radius: 5px;
  background: var(--bg); color: var(--text);
  padding: 8px 10px; outline: none;
  user-select: text; -webkit-user-select: text;
  white-space: pre-wrap;
}

/* ---------- Print preview (M365-style) ---------- */
#print-overlay {
  position: fixed; inset: 0; z-index: 90;
  display: flex;
  background: var(--bg);
}
#print-overlay.hidden { display: none; }

#print-panel {
  width: 330px; flex: none;
  display: flex; flex-direction: column; gap: 9px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 18px 24px 24px 24px;
  overflow-y: auto;
}
#print-panel-header { display: flex; align-items: center; margin-bottom: 4px; }
#print-panel-header h2 { margin: 0; flex: 1; font-size: 24px; font-weight: 600; letter-spacing: -0.3px; }
.pp-actions { display: flex; align-items: center; gap: 14px; margin: 6px 0 12px 0; }
#pp-print {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 110px; padding: 10px 24px;
  font: inherit; font-size: 14px; font-weight: 600;
  border: none; border-radius: 4px;
  background: var(--accent); color: #fff;
  cursor: pointer;
}
#pp-print:hover { filter: brightness(1.08); }
#pp-print:disabled { opacity: 0.4; cursor: default; filter: none; }
.pp-copies { display: flex; align-items: center; gap: 7px; color: var(--text-dim); font-size: 12px; }
.pp-copies input {
  width: 54px; font: inherit; text-align: center;
  padding: 7px 4px; border: 1px solid var(--border); border-radius: 4px;
  background: var(--surface); color: var(--text);
}
.pp-section-label { font-size: 12px; font-weight: 600; color: var(--text-dim); margin-top: 6px; }
#print-panel select, #pp-range {
  width: 100%; font: inherit;
  padding: 8px 10px;
  border: 1px solid var(--border); border-radius: 4px;
  background: var(--surface); color: var(--text);
}
#print-panel select:hover, #pp-range:hover { border-color: var(--accent); }
#pp-range.hidden { display: none; }

#print-preview-area { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--surface-2); }
#print-preview-scroll { flex: 1; overflow: auto; display: flex; }
#print-preview-stage {
  margin: auto; padding: 34px;
  width: 100%; display: flex; justify-content: center;
}
#pp-page-img {
  width: 60%;
  background: #fff;
  box-shadow: 0 2px 5px rgba(0,0,0,0.2), 0 10px 34px rgba(0,0,0,0.22);
}
#print-preview-bar {
  flex: none; display: flex; align-items: center;
  padding: 6px 18px;
  background: var(--surface);
  border-top: 1px solid var(--border);
}
.pp-nav { display: flex; align-items: center; gap: 6px; }
#pp-pageinfo { min-width: 64px; text-align: center; font-variant-numeric: tabular-nums; color: var(--text-dim); }
.pp-zoom input { width: 160px; accent-color: var(--accent); }

/* ---------- Print output ---------- */
#print-container { display: none; }
@media print {
  html, body { overflow: visible !important; height: auto !important; display: block !important; }
  body > *:not(#print-container) { display: none !important; }
  #print-container { display: block; }
  /* Each page is hard-limited to exactly one sheet — an image taller than the
     sheet would otherwise spill onto a ghost page. */
  .print-page {
    height: 100vh;
    display: flex; align-items: center; justify-content: center;
    page-break-after: always; break-inside: avoid;
    overflow: hidden;
  }
  .print-page:last-child { page-break-after: auto; }
  .print-page img {
    display: block;
    max-width: 100%; max-height: 100%;
    width: auto; height: auto;
  }
}
@page { margin: 0; }

/* ---------- Status bar ---------- */
#statusbar {
  display: flex; align-items: center;
  padding: 3px 12px;
  font-size: 11px;
  color: var(--text-dim);
  background: var(--bg);
  border-top: 1px solid var(--border);
  flex: none; min-height: 22px;
}

#status-version {
  border: none; background: none; color: var(--text-dim);
  font: inherit; cursor: pointer; padding: 2px 6px; border-radius: 4px; margin-left: 8px;
}
#status-version:hover { background: rgba(127,127,127,0.14); color: var(--text); }

/* ---------- Combine overlay ---------- */
#combine-overlay {
  position: fixed; inset: 0; z-index: 88;
  display: flex; flex-direction: column;
  background: var(--bg);
}
#combine-overlay.hidden { display: none; }
#combine-overlay.working { cursor: progress; }
#combine-header {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex: none;
}
#combine-title { font-size: 16px; font-weight: 600; }
#combine-done {
  font: inherit; font-weight: 600;
  padding: 7px 18px; border: none; border-radius: 5px;
  background: var(--accent); color: #fff; cursor: pointer;
}
#combine-done:hover { filter: brightness(1.08); }
#combine-body {
  flex: 1; display: flex; min-height: 0;
  overflow: hidden;
}
#combine-cols {
  flex: none; display: flex; gap: 0;
  overflow-x: auto; overflow-y: hidden;
  align-items: stretch;
  background: var(--surface-2);
  border-right: 1px solid var(--border);
  max-width: 60%;
}
#combine-preview {
  flex: 1; min-width: 320px;
  background: var(--bg);
  overflow-y: auto; overflow-x: hidden;
  padding: 24px 32px 60px 32px;
  display: flex; flex-direction: column;
  align-items: center;
}
#combine-preview-hint {
  margin-top: 40px;
  font-size: 13px;
  color: var(--text-dim);
  text-align: center;
}
#combine-preview-title {
  width: 100%; max-width: 780px;
  font-size: 15px; font-weight: 600;
  margin-bottom: 20px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  color: var(--text);
  text-align: left;
}
.cp-page-wrap {
  width: 100%; max-width: 780px;
  display: flex; flex-direction: column;
  align-items: center;
  margin-bottom: 24px;
}
.cp-page {
  width: 100%; background: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.18), 0 1px 3px rgba(0,0,0,0.10);
  border-radius: 4px;
  overflow: hidden; min-height: 140px;
}
.cp-page canvas { display: block; width: 100%; height: auto; }
.cp-page-num {
  text-align: center; font-size: 12px;
  color: var(--text-dim); margin: 6px 0 0 0;
}
.combine-col {
  flex: none; width: 184px;
  display: flex; flex-direction: column;
  border-right: 1px solid var(--border);
  min-height: 0;
  background: var(--surface-2);
}
.combine-col:last-child {
  border-right: none;
}
.combine-col-head {
  flex: none; padding: 10px 14px;
  font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
}
.combine-col-head:hover { background: rgba(127,127,127,0.12); }
.combine-col-head.previewing { color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }
.combine-col-count { display: block; font-weight: 400; margin-top: 2px; }
.combine-col-body {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  padding: 12px 0 40px 0;
}
.combine-thumb {
  position: relative;
  width: 138px; margin: 0 auto 12px auto;
  cursor: grab;
}
.combine-thumb:active { cursor: grabbing; }
.combine-thumb-box {
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.18);
  border: 2px solid transparent; border-radius: 3px;
  overflow: hidden; min-height: 70px;
}
.combine-thumb canvas { display: block; width: 100%; }
.combine-thumb.selected .combine-thumb-box { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.combine-thumb-num { text-align: center; font-size: 11px; color: var(--text-dim); margin-top: 3px; }
.combine-thumb.dragging { opacity: 0.4; }
.combine-thumb.drop-before::before, .combine-thumb.drop-after::after {
  content: ""; position: absolute; left: -8px; right: -8px; height: 3px;
  background: var(--accent); border-radius: 2px;
}
.combine-thumb.drop-before::before { top: -8px; }
.combine-thumb.drop-after::after { bottom: 3px; }
.combine-tail { min-height: 44px; margin: -6px 12px 0 12px; border-radius: 4px; }
.combine-tail.drop-here { background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--accent); }

/* ---------- Update banner ---------- */
#update-banner {
  position: fixed; top: 14px; left: 50%; transform: translateX(-50%);
  z-index: 95;
  display: flex; align-items: center; gap: 12px;
  max-width: 620px; width: calc(100% - 48px);
  padding: 10px 12px 10px 18px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  box-shadow: var(--shadow);
}
#update-banner.hidden { display: none; }
#update-msg { font-weight: 500; }
#update-install {
  font: inherit; font-weight: 600;
  padding: 7px 16px; border: none; border-radius: 5px;
  background: var(--accent); color: #fff; cursor: pointer;
}
#update-install:hover { filter: brightness(1.08); }
#update-install:disabled { opacity: 0.5; cursor: default; filter: none; }
.linkish { border: none; background: none; color: var(--accent); font: inherit; cursor: pointer; text-decoration: underline; }
/* ---------- Split PDF overlay ---------- */
#split-overlay {
  position: fixed; inset: 0; z-index: 90;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(2px);
}
#split-overlay.hidden { display: none; }
#split-card-modal {
  width: 860px; max-width: calc(100vw - 48px);
  height: 80vh; max-height: 720px;
  background: var(--surface); border-radius: 10px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  display: flex; flex-direction: column;
  overflow: hidden;
}
#split-header {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
#split-header-info { display: flex; flex-direction: column; gap: 2px; }
#split-title { font-size: 15px; font-weight: 600; color: var(--text); }
#split-toolbar {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 18px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.split-range-box { display: flex; align-items: center; gap: 8px; }
#split-range-input {
  padding: 4px 8px;
  border: 1px solid var(--border); border-radius: 5px;
  background: var(--surface); color: var(--text);
  font: inherit; width: 170px;
}
#split-range-input:focus { outline: none; border-color: var(--accent); }
.split-quick-btns { display: flex; align-items: center; gap: 4px; }
.split-pill-btn {
  padding: 3px 9px;
  border: 1px solid var(--border); border-radius: 12px;
  background: var(--surface); color: var(--text);
  font-size: 11px; cursor: pointer;
}
.split-pill-btn:hover { background: rgba(127,127,127,0.12); }
#split-body { flex: 1; overflow-y: auto; padding: 16px 18px; }
#split-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 14px;
}
.split-card {
  position: relative;
  display: flex; flex-direction: column;
  background: var(--bg);
  border: 2px solid transparent; border-radius: 6px;
  padding: 6px; cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease;
}
.split-card:hover { border-color: rgba(127,127,127,0.3); }
.split-card.selected { border-color: var(--accent); background: var(--accent-soft); }
.split-card-head { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.split-card-checkbox { cursor: pointer; width: 14px; height: 14px; accent-color: var(--accent); }
.split-card-num { font-size: 11px; font-weight: 500; color: var(--text-dim); }
.split-card.selected .split-card-num { color: var(--accent); font-weight: 600; }
.split-card-preview {
  display: flex; justify-content: center; align-items: center;
  min-height: 150px; background: #fff;
  border-radius: 4px; overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.split-card-canvas-box { width: 100%; display: flex; justify-content: center; }
.split-card-canvas-box canvas { display: block; width: 100%; height: auto; }
#split-footer {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 18px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}
#split-footer button {
  font: inherit; padding: 6px 14px;
  border: 1px solid var(--border); border-radius: 5px;
  background: var(--surface); color: var(--text);
  cursor: pointer;
}
#split-footer button:hover { background: rgba(127,127,127,0.12); }
#split-footer button:disabled { opacity: 0.45; cursor: default; }
#split-footer .primary-btn {
  background: var(--accent); color: #fff;
  border-color: var(--accent); font-weight: 600;
}
#split-footer .primary-btn:hover { filter: brightness(1.08); background: var(--accent); }
#split-footer .primary-btn:disabled { filter: none; opacity: 0.45; }

/* ---------- About popup ---------- */
#about-popup {
  position: fixed; inset: 0; z-index: 96;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.38);
  backdrop-filter: blur(2px);
}
#about-popup.hidden { display: none; }
#about-card {
  width: 520px; max-width: calc(100vw - 32px); max-height: 85vh;
  background: var(--surface); border-radius: 10px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 20px 22px 22px 22px;
  display: flex; flex-direction: column; gap: 14px;
  overflow-y: auto;
}
#about-header { display: flex; align-items: center; font-size: 18px; font-weight: 600; }
#about-version { font-size: 13px; margin-top: -6px; }
.about-section-title {
  font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--text-dim); margin-top: 4px; padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}
.about-shortcuts-list {
  display: flex; flex-direction: column; gap: 6px;
  max-height: 280px; overflow-y: auto;
  padding-right: 4px;
}
.about-sc-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  font-size: 13px; padding: 2px 0;
}
.about-sc-desc { color: var(--text); }
.about-sc-keys { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
kbd {
  font-family: inherit; font-size: 11px; font-weight: 600;
  padding: 2px 6px; border-radius: 4px;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border);
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}
#about-updates {
  display: flex; flex-direction: column; gap: 10px;
  padding-top: 10px; border-top: 1px solid var(--border);
}
#about-updates.hidden { display: none; }
.about-row { display: flex; align-items: center; gap: 12px; }
#about-check {
  font: inherit; padding: 7px 14px;
  border: 1px solid var(--border); border-radius: 5px;
  background: var(--surface-2); color: var(--text); cursor: pointer;
}
#about-check:hover { background: rgba(127,127,127,0.14); }
#about-check:disabled { opacity: 0.5; cursor: default; }
.about-toggle { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
#about-updates p { margin: 0; }

/* scrollbars */
::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-thumb { background: rgba(127,127,127,0.35); border-radius: 6px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background-color: rgba(127,127,127,0.55); }
::-webkit-scrollbar-track { background: transparent; }
