/* PDF Editor — workspace: context bars, empty state, thumbnail grid, page view, busy and drop overlays. */
/* ---------------------------------------------------------------- workspace */
.workspace { grid-area: work; position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; background-color: var(--surface); background-image: radial-gradient(var(--dots) 1px, transparent 1.2px); background-size: 18px 18px; }
.ctxbar { display: flex; align-items: center; gap: 2px; height: var(--ctx-h); padding: 0 10px; background: var(--panel); border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: thin; flex: none; }
.pv-tools { display: flex; gap: 1px; }
.pv-num { font: 600 12px var(--mono); color: var(--fg); min-width: 58px; text-align: center; }
.tb-zoom { font: 600 12px var(--mono); min-width: 58px; }
.stage { position: relative; flex: 1; min-height: 0; }
.grid-wrap, .viewer { position: absolute; inset: 0; overflow: auto; }
.app:not([data-mode="grid"]) .grid-wrap { display: none; }
.app:not([data-mode="page"]) .viewer { display: none; }

/* seg control */
.seg { display: inline-flex; padding: 2px; gap: 2px; border-radius: var(--radius-s); background: var(--input); border: 1px solid var(--line); flex-wrap: wrap; }
.seg-b { min-height: 26px; padding: 0 10px; border: 0; border-radius: 4px; background: none; color: var(--dim); font-size: var(--fs-s); font-weight: 500; }
.seg-b:hover { color: var(--fg); background: var(--hover); }
.seg-b.on { background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.seg-sm .seg-b { min-height: 24px; min-width: 28px; padding: 0 6px; }

/* ---------------------------------------------------------------- empty */
.empty { position: absolute; inset: 0; overflow: auto; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; padding: 24px 16px; }
.drop-card { width: min(660px, 100%); padding: 40px 28px 26px; text-align: center; border: 2px dashed var(--line-2); border-radius: 22px; background: color-mix(in srgb, var(--panel) 82%, transparent); transition: border-color .15s, background .15s; }
.drop-card:hover { border-color: var(--faint); }
.empty-art { width: 108px; height: 108px; margin-bottom: 4px; }
.drop-card .sd-preview { margin-bottom: 18px; }
.ea-page { fill: var(--panel-2); stroke: var(--line-2); stroke-width: 2; }
.ea-page2 { fill: var(--input); stroke: var(--ink); stroke-width: 2.5; }
.ea-goo { fill: var(--lime); stroke: var(--ink); stroke-width: 2.5; }
.ea-shine { fill: none; stroke: #fff; stroke-width: 2.4; stroke-linecap: round; }
.drop-card h1 { margin: 0 0 8px; font: 800 clamp(26px, 5vw, 38px)/1.05 var(--font-display); letter-spacing: -.02em; }
.drop-card p { margin: 0 auto 20px; max-width: 460px; color: var(--dim); font-size: 14px; line-height: 1.5; }
.pdf-drop { width: min(460px, 100%); margin: 0 auto 18px; }
.empty-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.restore { margin-top: 12px; }
.empty-privacy { display: flex; align-items: center; justify-content: center; gap: 6px; margin: 18px 0 0 !important; font-size: 12px !important; color: var(--faint) !important; }
.empty-privacy .ic { width: 14px; height: 14px; }
.empty-feats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; width: min(660px, 100%); margin: 0; padding: 0; list-style: none; }
.empty-feats li { padding: 10px 12px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); color: var(--dim); font-size: 12px; line-height: 1.35; }
.empty-feats b { display: block; color: var(--fg); font: 700 13px var(--font-display); margin-bottom: 2px; }

/* ---------------------------------------------------------------- grid */
.grid { --thumb: 168px; position: relative; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(var(--thumb), 100%), 1fr)); gap: 14px 10px; padding: 18px 18px 60px; align-content: start; min-height: 100%; outline: none; }
.thumb { position: relative; display: flex; flex-direction: column; align-items: center; padding: 8px 8px 6px; border-radius: 12px; outline: none; cursor: grab; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: pan-y; transition: background .12s; }
.thumb:hover { background: var(--hover); }
.thumb:focus-visible { box-shadow: 0 0 0 2px var(--accent-line); }
.thumb.selected { background: var(--sel-bg); box-shadow: inset 0 0 0 2px var(--accent-line); }
.thumb.dragging { opacity: .35; }
.thumb-box { width: 100%; height: calc(var(--thumb) * 1.3 - 16px); display: flex; align-items: center; justify-content: center; position: relative; }
.sheet { position: relative; background: #fff; box-shadow: var(--sheet-shadow); border-radius: 2px; overflow: hidden; flex: none; }
.sheet::before { content: ''; position: absolute; inset: 0; background: linear-gradient(110deg, #f4f4f4 30%, #fafafa 50%, #f4f4f4 70%) 0 0 / 300% 100%; animation: shimmer 1.2s linear infinite; }
.sheet.loaded::before, .sheet.is-blank::before { display: none; }
@keyframes shimmer { to { background-position: -150% 0; } }
.thumb .sheet::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: var(--fc); }
.sheet-layer { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.sheet-img { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.sheet-svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: hidden; pointer-events: none; }
.thumb-cap { display: flex; align-items: center; gap: 6px; margin-top: 7px; max-width: 100%; font-size: 11.5px; color: var(--dim); }
.pnum { font: 700 12px var(--mono); color: var(--fg); }
.psrc { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 10.5px; color: var(--faint); }
.fdot { width: 9px; height: 9px; border-radius: 50%; background: var(--fc); flex: none; box-shadow: 0 0 0 1px rgba(0, 0, 0, .25); }
.thumb-check { position: absolute; left: 4px; top: 4px; width: 24px; height: 24px; display: grid; place-items: center; padding: 0; border-radius: 50%; border: 2px solid var(--line-2); background: var(--panel); color: transparent; opacity: 0; transition: opacity .12s; z-index: 2; }
.thumb-check .ic { width: 14px; height: 14px; stroke-width: 3; }
.thumb:hover .thumb-check, .thumb.selected .thumb-check, .grid.multi .thumb-check { opacity: 1; }
.thumb.selected .thumb-check { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.thumb-tools { position: absolute; right: 4px; top: 4px; display: flex; flex-direction: column; gap: 3px; opacity: 0; transform: translateX(4px); transition: opacity .12s, transform .12s; z-index: 2; }
.thumb:hover .thumb-tools, .thumb:focus-within .thumb-tools { opacity: 1; transform: none; }
.thumb-tools button { width: 28px; height: 28px; display: grid; place-items: center; padding: 0; border: 1px solid var(--line-2); border-radius: 7px; background: var(--panel); color: var(--fg); box-shadow: 0 2px 6px rgba(0, 0, 0, .25); }
.thumb-tools button:hover { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.thumb-tools button.danger:hover { background: var(--danger); color: var(--accent-ink); }
.thumb-tools .ic { width: 15px; height: 15px; }
.thumb-grip { display: none; position: absolute; left: 50%; bottom: 30px; transform: translateX(-50%); width: 40px; height: 26px; place-items: center; border-radius: 13px; background: var(--panel); border: 1px solid var(--line-2); color: var(--dim); touch-action: none; z-index: 2; }
.thumb-grip .ic { width: 16px; height: 16px; transform: rotate(90deg); }
.thumb-badge { position: absolute; left: 10px; bottom: 34px; display: inline-flex; align-items: center; gap: 3px; padding: 2px 6px 2px 4px; border-radius: 99px; background: var(--ink); color: var(--lime); font: 700 10px var(--mono); z-index: 1; }
.thumb-badge .ic { width: 11px; height: 11px; }
.thumb-part { position: absolute; left: 50%; top: 2px; transform: translateX(-50%); padding: 1px 8px; border-radius: 99px; background: var(--panel-2); color: var(--dim); border: 1px solid var(--line-2); font: 600 10px var(--mono); white-space: nowrap; z-index: 3; }
.thumb-part.cut { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.drop-marker { position: absolute; width: 4px; border-radius: 2px; background: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-soft), 0 0 18px var(--accent); pointer-events: none; display: none; z-index: 5; }
.drag-ghost { position: fixed; left: 0; top: 0; z-index: 9999; pointer-events: none; }
.drag-ghost-sheet { width: 96px; height: 96px; filter: drop-shadow(0 10px 18px rgba(0, 0, 0, .45)); transform: rotate(-4deg); }
.drag-count { position: absolute; right: -8px; top: -8px; min-width: 24px; height: 24px; padding: 0 6px; border-radius: 12px; background: var(--accent); color: var(--accent-ink); font: 800 12px/24px var(--mono); text-align: center; }
body.is-dragging, body.is-dragging * { cursor: grabbing !important; }
.marquee { position: absolute; border: 1px solid var(--accent-line); background: var(--accent-soft); pointer-events: none; z-index: 6; }

/* ---------------------------------------------------------------- page view */
.viewer { touch-action: none; cursor: default; overflow-anchor: none; } /* the zoom keeps the pointer's point in place itself */
.viewer.panning { cursor: grabbing; }
.pv-pad { position: relative; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 24px; min-width: 100%; min-height: 100%; width: max-content; height: max-content; padding: 24px; box-sizing: border-box; }
.pv-row { display: flex; justify-content: center; align-items: flex-start; gap: 24px; }
.pv-page { position: relative; background: #fff; box-shadow: var(--sheet-shadow); }
.pv-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.pv-svg { pointer-events: auto; }
.pv-svg .stamps { pointer-events: none; }
.pv-svg .an-hit { pointer-events: all; }
.pv-svg .an { pointer-events: visiblePainted; }
.pv-svg .draft { opacity: .85; }
.pv-page[data-tool="select"] .annots [data-aid] { cursor: move; }
.pv-page[data-tool="select"] { cursor: grab; }
.pv-page:not([data-tool="select"]) { cursor: crosshair; }
.pv-page[data-tool="text"] { cursor: text; }
.pv-overlay { position: absolute; inset: 0; pointer-events: none; }
.sel-box { position: absolute; outline: 1.5px solid #0a0a0a; box-shadow: 0 0 0 3.5px rgba(255, 234, 232, .75); pointer-events: none; }
.sel-box.is-line { outline: 1px dashed rgba(10, 10, 10, .5); box-shadow: none; }
.sel-box.is-locked { outline-style: dashed; box-shadow: none; }
.sel-box.is-text { pointer-events: auto; cursor: move; z-index: 2; } /* a text selection's box: pressing it lifts and moves the text (sel-lift.js) */
.handle[data-tb] { z-index: 2; } /* above the text layer (z-index 1), which would take the press otherwise */
.sel-lock { position: absolute; width: 20px; height: 20px; margin: -10px 0 0 -10px; display: grid; place-items: center; border: 1.5px solid var(--line-2); border-radius: 50%; background: var(--panel); color: var(--fg); pointer-events: none; }
.sel-lock .ic { width: 11px; height: 11px; }
.handle { position: absolute; width: 12px; height: 12px; margin: -6px 0 0 -6px; background: var(--lime); border: 1.5px solid #0a0a0a; border-radius: 3px; pointer-events: auto; touch-action: none; }
.handle.h-pt { border-radius: 50%; width: 14px; height: 14px; margin: -7px 0 0 -7px; cursor: move; }
.h-nw, .h-se { cursor: nwse-resize; } .h-ne, .h-sw { cursor: nesw-resize; } .h-n, .h-s { cursor: ns-resize; } .h-e, .h-w { cursor: ew-resize; }
@media (pointer: coarse) { .handle { width: 20px; height: 20px; margin: -10px 0 0 -10px; } .handle::after { content: ''; position: absolute; left: 50%; top: 50%; width: var(--tlbx-hit, 44px); height: var(--tlbx-hit, 44px); transform: translate(-50%, -50%); } }
.pv-text { position: absolute; margin: 0; border: 0; outline: 1.5px dashed #0a0a0a; box-shadow: 0 0 0 3px rgba(255, 234, 232, .6); background: rgba(255, 255, 255, .55); resize: none; overflow: hidden; white-space: pre; z-index: 3; box-sizing: border-box; }

/* ---------------------------------------------------------------- busy & drop */
.busy { position: absolute; left: 50%; bottom: 22px; transform: translateX(-50%); display: flex; align-items: center; gap: 12px; padding: 12px 16px; min-width: 280px; max-width: calc(100% - 32px); border-radius: 14px; background: var(--panel); color: var(--fg); border: 1px solid var(--line-2); box-shadow: 0 16px 40px rgba(0, 0, 0, .45); z-index: 50; flex-wrap: wrap; }
.busy-msg { flex: 1; font-weight: 600; }
.busy-bar { flex-basis: 100%; height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; }
.busy-bar i { display: block; height: 100%; width: 0; background: var(--lime); transition: width .2s; }
.busy-bar.indet i { width: 40%; animation: indet 1s ease-in-out infinite; }
@keyframes indet { from { transform: translateX(-100%); } to { transform: translateX(250%); } }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid var(--line-2); border-top-color: var(--lime); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.tz { display: inline-flex; align-items: center; gap: 8px; }
.tz-range { width: 140px; height: 18px; margin: 0; accent-color: var(--accent-line); cursor: pointer; }
.tz-full .ic { width: 16px; height: 16px; }
@media (max-width: 560px) { .tz-range { width: 96px; } }
/* Phone width: the page view's zoom cluster (Ed.init in editor/view.js). The status bar is hidden there. */
.pv-zoomfab { position: absolute; right: 12px; bottom: 12px; z-index: 6; display: none; align-items: center; gap: 2px; padding: 3px; background: var(--panel); border: 1px solid var(--line-2); border-radius: 999px; box-shadow: 0 6px 18px rgba(0, 0, 0, .35); }
.pv-zf { min-width: 38px; height: 38px; border: 0; border-radius: 50%; background: transparent; color: var(--fg); font: 600 20px/1 var(--mono); cursor: pointer; display: inline-grid; place-items: center; }
.pv-zf .ic { width: 18px; height: 18px; }
.pv-zpct { font: 600 12px var(--mono); color: var(--fg); min-width: 46px; text-align: center; }
@media (max-width: 900px) { .app[data-mode="page"] .pv-zoomfab { display: flex; } }

/* Split view (ui/panes.js): the panes sit over the stage; the page view and the previews fill them. */
.pdf-panes { position: absolute; inset: 0; }
.pdf-panes[hidden] { display: none; }
.app:not([data-mode="page"]) .pdf-panes { display: none; }
.sw-pane { display: flex; flex-direction: column; }
.sw-pane > .viewer { position: relative; inset: auto; flex: 1 1 auto; min-height: 0; } /* below the pane's own tab strip */
.pv-pv { position: relative; flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; background: var(--panel, #f3f4f7); }
.pv-pv-head { display: flex; align-items: center; gap: 6px; padding: 4px 8px; border-bottom: 1px solid var(--line, #d5dae3); font: 13px/1.2 system-ui, sans-serif; }
.pv-pv-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.pv-pv-btn { min-width: 28px; min-height: 26px; border: 1px solid var(--line, #d5dae3); border-radius: 6px; background: var(--panel, #fff); color: inherit; cursor: pointer; }
.pv-pv-pct { min-width: 44px; text-align: center; font-variant-numeric: tabular-nums; }
.pv-pv-body { flex: 1 1 auto; min-height: 0; overflow: auto; padding: 16px; box-sizing: border-box; }
.pv-pv-page { position: relative; margin: 0 auto 16px; background: #fff; box-shadow: 0 1px 4px rgb(0 0 0 / .18); }
.pv-pv-canvas { display: block; }
.pv-pv-note { margin: 0; padding: 4px 8px; font: 12px/1.3 system-ui, sans-serif; color: var(--muted, #666); border-top: 1px solid var(--line, #d5dae3); }
.sw-pane.is-active .pv-pv-note { display: none; }
