/* SPDX-License-Identifier: GPL-3.0-or-later
   PDFish – PDF Workbench. Copyright (C) 2026 Jan-Maurice Dahlmanns (Bugfish). */

:root {
  --bg: #111317;
  --bg2: #0d0f12;
  --panel: #181b20;
  --panel2: #1f232a;
  --panel3: #262b33;
  --line: #2c313a;
  --line2: #3a404b;
  --text: #e7eaef;
  --muted: #9aa3ae;
  --faint: #6b737e;
  --accent: #FF5707;
  --accent2: #ff7a3d;
  --accent-ink: #140800;
  --accent-soft: rgba(255, 87, 7, 0.14);
  --ok: #2fbf71;
  --warn: #ffb020;
  --err: #ff5d5d;
  --blue: #4c8dff;
  --radius: 10px;
  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
  --top: 54px;
  --tw: 170px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.45 var(--font); overflow: hidden; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .45; }
[hidden] { display: none !important; }
a { color: var(--accent2); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.grow { flex: 1 1 auto; min-width: 0; }
.icon-line { display: flex; align-items: center; gap: 6px; margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.ico { flex: none; display: block; }
kbd { font: 11.5px var(--mono); padding: 1px 5px; border: 1px solid var(--line2); border-bottom-width: 2px; border-radius: 4px; color: var(--muted); background: var(--panel2); }

.app { height: 100%; display: flex; flex-direction: column; }
.boot { margin: auto; text-align: center; color: var(--muted); }
.boot-logo { color: var(--accent); margin: 0 auto 8px; }
.noscript { padding: 24px; text-align: center; }

/* ---------- buttons & inputs ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 34px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line2); background: var(--panel2); white-space: nowrap; transition: background .12s, border-color .12s; }
.btn:hover:not(:disabled) { background: var(--panel3); border-color: #4a515d; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn-primary:hover:not(:disabled) { background: var(--accent2); border-color: var(--accent2); }
.btn-ghost { background: transparent; }
.btn-danger { background: transparent; border-color: rgba(255, 93, 93, .5); color: #ff9a9a; }
.btn-danger:hover:not(:disabled) { background: rgba(255, 93, 93, .12); }
.btn-small { height: 30px; padding: 0 10px; font-size: 13px; }
.ibtn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-width: 34px; height: 34px; padding: 0 8px; border-radius: 8px; border: 1px solid transparent; background: transparent; color: var(--text); }
.ibtn:hover:not(:disabled) { background: var(--panel3); }
.ibtn[aria-pressed="true"], .ibtn.on { background: var(--accent-soft); color: var(--accent2); border-color: rgba(255, 87, 7, .35); }
.link { background: none; border: 0; padding: 0; color: var(--accent2); text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
.input { width: 100%; height: 34px; padding: 0 10px; border-radius: 7px; border: 1px solid var(--line2); background: var(--bg2); color: var(--text); }
textarea.input { height: auto; padding: 8px 10px; resize: vertical; line-height: 1.4; }
select.input { padding-right: 6px; }
.input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.input-small { width: 80px; height: 30px; }
.input-big { height: 44px; font-size: 18px; }
.input-unit { display: flex; align-items: center; gap: 6px; }
.input-unit i { font-style: normal; color: var(--muted); font-size: 12px; }
.range { width: 100%; accent-color: var(--accent); }
.range-row { display: flex; align-items: center; gap: 10px; }
.range-out { min-width: 64px; text-align: right; color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.color { width: 42px; height: 30px; padding: 2px; border: 1px solid var(--line2); border-radius: 6px; background: var(--bg2); cursor: pointer; }
.color.is-none { opacity: .35; }
.color-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.swatches { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.swatch { width: 20px; height: 20px; border-radius: 5px; border: 1px solid rgba(255, 255, 255, .25); padding: 0; }
.swatch.big { width: 28px; height: 28px; border-radius: 50%; }
.swatch.on { outline: 2px solid var(--accent); outline-offset: 2px; }
.none-toggle { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-size: 12.5px; }
.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 9px; background: var(--bg2); border: 1px solid var(--line); }
.seg-btn { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); white-space: nowrap; }
.seg-btn:hover { color: var(--text); }
.seg-btn.on { background: var(--panel3); color: var(--text); box-shadow: inset 0 0 0 1px var(--line2); }
.seg-mode .seg-btn.on { background: var(--accent); color: var(--accent-ink); font-weight: 600; box-shadow: none; }
.check-row { display: flex; align-items: flex-start; gap: 9px; cursor: pointer; }
.check-row input { margin-top: 3px; accent-color: var(--accent); }
.field-error { color: var(--err); margin: 0; font-size: 13px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row-fill { flex-wrap: nowrap; }
.row-fill > select.input:first-child { flex: 1 1 auto; width: auto; }
.row-fill > select.input:last-child { flex: 0 0 170px; width: 170px; }
.inline { display: inline-flex; align-items: center; gap: 8px; }
.lbl { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.lbl > .input, .lbl select { color: var(--text); }
.pill { font-size: 11px; padding: 1px 7px; border-radius: 99px; background: var(--accent-soft); color: var(--accent2); }
.badge { display: inline-flex; align-items: center; gap: 3px; font-size: 11px; padding: 1px 5px; border-radius: 5px; background: rgba(17, 19, 23, .85); color: #fff; }
.note { display: flex; gap: 8px; align-items: flex-start; margin: 0; padding: 10px 12px; border-radius: 8px; background: rgba(76, 141, 255, .1); border: 1px solid rgba(76, 141, 255, .25); font-size: 13px; }
.warn-box { padding: 10px 12px; border-radius: 8px; background: rgba(255, 176, 32, .1); border: 1px solid rgba(255, 176, 32, .3); font-size: 13px; }
.warn-box ul { margin: 6px 0 0; padding-left: 18px; }
.attention { animation: pulse 1.6s ease-out 2; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(255, 87, 7, .6); } 100% { box-shadow: 0 0 0 14px rgba(255, 87, 7, 0); } }

/* ---------- top bar ---------- */
.topbar { flex: none; height: var(--top); display: flex; align-items: center; gap: 8px; padding: 0 12px; background: var(--panel); border-bottom: 1px solid var(--line); position: relative; z-index: 20; }
.exit { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 10px 0 6px; border-radius: 8px; color: var(--muted); text-decoration: none; font-size: 13px; white-space: nowrap; }
.exit:hover { background: var(--panel3); color: var(--text); }
.brand { display: flex; align-items: center; gap: 8px; padding: 0 6px; white-space: nowrap; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); }
.brand-name { font-weight: 700; font-size: 16px; letter-spacing: .2px; }
.brand-sub { color: var(--muted); font-size: 12px; }
.doc-name { width: 200px; height: 32px; padding: 0 10px; border-radius: 7px; border: 1px solid transparent; background: transparent; color: var(--text); font-weight: 600; }
.doc-name:hover { border-color: var(--line2); }
.doc-name:focus { border-color: var(--accent); background: var(--bg2); outline: none; }
body:not(.has-doc) .doc-name, body:not(.has-doc) .view-tabs, body:not(.has-doc) .topbar > .ibtn, body:not(.has-doc) .tools-btn, body:not(.has-doc) .topbar .btn-primary { display: none; }
body:not(.has-doc) .topbar > .ibtn[title^="About"] { display: inline-flex; }
.view-tabs { display: flex; gap: 2px; padding: 3px; border-radius: 9px; background: var(--bg2); border: 1px solid var(--line); }
.view-tab { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 12px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); }
.view-tab:hover:not(:disabled) { color: var(--text); }
.view-tab.on { background: var(--panel3); color: var(--text); box-shadow: inset 0 0 0 1px var(--line2); }

.main { flex: 1 1 auto; min-height: 0; position: relative; }
.view { position: absolute; inset: 0; display: flex; flex-direction: column; min-height: 0; }
.view-body { flex: 1 1 auto; min-height: 0; display: flex; }
.toolbar { flex: none; display: flex; align-items: center; gap: 4px; min-height: 48px; padding: 6px 10px; background: var(--panel); border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: thin; }
.tb-sep { flex: none; width: 1px; height: 24px; margin: 0 6px; background: var(--line2); }
.tb-zoom { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); width: 160px; }
.tb-tools { display: flex; align-items: center; gap: 2px; }
.tb-hint { margin-left: 8px; font-size: 12.5px; color: var(--accent2); white-space: nowrap; }
.tb-pages { display: inline-flex; align-items: center; gap: 4px; margin-right: 6px; }
.page-input { width: 46px; height: 30px; text-align: center; padding: 0 4px; }
.zoom-label { min-width: 62px; font-variant-numeric: tabular-nums; }
.only-narrow { display: none; }

/* ---------- side panel ---------- */
.side { flex: none; width: 318px; display: flex; flex-direction: column; background: var(--panel); border-left: 1px solid var(--line); min-height: 0; }
.side-body { flex: 1 1 auto; overflow-y: auto; padding: 14px 16px 24px; scrollbar-width: thin; }
.side-title { margin: 18px 0 8px; font-size: 12px; letter-spacing: .6px; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.side-title:first-child { margin-top: 0; }
.side-row { margin: 8px 0; }
.side-actions { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); }
.side-tabs { padding: 8px 10px 0; flex: none; }
.tab { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--muted); margin-bottom: -1px; }
.tab:hover { color: var(--text); }
.tab.on { color: var(--text); border-bottom-color: var(--accent); }
.insp-head { display: flex; align-items: center; gap: 4px; margin-bottom: 10px; min-height: 34px; }
.insp-head strong { font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.align-row { display: flex; flex-wrap: wrap; gap: 2px; padding: 6px; margin-bottom: 12px; border-radius: 8px; background: var(--bg2); border: 1px solid var(--line); }
.align-row .ibtn { min-width: 30px; height: 30px; padding: 0 6px; }
.tips { margin: 12px 0; padding-left: 18px; color: var(--muted); font-size: 13px; }
.tips li { margin: 4px 0; }

.ctl-grid { display: flex; flex-wrap: wrap; gap: 10px 10px; }
.ctl { display: flex; flex-direction: column; gap: 5px; flex: 1 1 100%; min-width: 0; }
.ctl-half { flex: 1 1 calc(50% - 5px); }
.ctl-third { flex: 1 1 calc(33% - 7px); }
.ctl-label { font-size: 12.5px; color: var(--muted); }
.ctl-hint { font-size: 12px; color: var(--faint); }
.ctl-heading { flex: 1 1 100%; margin: 10px 0 0; padding-top: 10px; border-top: 1px solid var(--line); font-size: 12px; letter-spacing: .6px; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.ctl-grid > .ctl-heading:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.ctl-note { flex: 1 1 100%; margin: 0; font-size: 12.5px; color: var(--muted); }
.ctl-note:empty { display: none; }
.ctl-note.warn { color: #ffcf7a; }
.ctl-check { flex-direction: row; align-items: center; gap: 8px; cursor: pointer; }
.ctl-check input { accent-color: var(--accent); width: 16px; height: 16px; }
.ctl-seg .seg { align-self: flex-start; }

.file-list, .out-list, .field-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.file-item { display: flex; align-items: center; gap: 10px; padding: 8px 6px 8px 10px; border-radius: 8px; background: var(--panel2); }
.file-dot { width: 10px; height: 28px; border-radius: 4px; background: var(--src); flex: none; }
.file-text { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.file-text strong { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-text small { color: var(--muted); font-size: 12px; }
.out-item, .field-item { width: 100%; display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; border: 1px solid transparent; background: transparent; text-align: left; }
.out-item:hover, .field-item:hover { background: var(--panel2); }
.field-item.on { background: var(--accent-soft); border-color: rgba(255, 87, 7, .35); }
.field-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.field-item.existing .ico { color: var(--muted); }
.chip-pick { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.chip { height: 26px; padding: 0 9px; border-radius: 99px; border: 1px solid var(--line2); background: var(--panel2); font-size: 12.5px; }
.chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent2); }
.opt-editor { display: flex; flex-direction: column; gap: 6px; }
.opt-rows { display: flex; flex-direction: column; gap: 4px; }
.opt-row { display: grid; grid-template-columns: 18px 1fr 1fr 28px 28px; gap: 4px; align-items: center; }
.opt-row .input { height: 30px; padding: 0 6px; font-size: 13px; }
.opt-row .ibtn { min-width: 28px; height: 28px; padding: 0; }

/* ---------- start screen ---------- */
.view-start { overflow-y: auto; background: radial-gradient(1200px 500px at 50% -10%, rgba(255, 87, 7, .13), transparent 60%), var(--bg); }
.start-inner { max-width: 1120px; margin: 0 auto; padding: 44px 24px 40px; }
.hero { text-align: center; max-width: 820px; margin: 0 auto 26px; }
.hero h1 { margin: 0 0 12px; font-size: clamp(26px, 3.6vw, 40px); line-height: 1.15; letter-spacing: -.3px; }
.lead { margin: 0; color: var(--muted); font-size: 16.5px; }
.dropzone { width: 100%; max-width: 760px; margin: 0 auto; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 34px 20px; border-radius: 16px; border: 2px dashed rgba(255, 87, 7, .55); background: rgba(255, 87, 7, .06); color: var(--text); transition: background .15s, border-color .15s, transform .15s; }
.dropzone:hover, body.drop-hover .dropzone { background: rgba(255, 87, 7, .12); border-color: var(--accent); }
.dropzone .ico { color: var(--accent); margin-bottom: 4px; }
.dropzone strong { font-size: 19px; }
.dropzone span { color: var(--muted); }
.start-h2 { margin: 40px 0 14px; font-size: 15px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); font-weight: 600; text-align: center; }
.task-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
.task { display: flex; align-items: flex-start; gap: 12px; padding: 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); text-align: left; transition: border-color .12s, background .12s, transform .12s; }
.task:hover { border-color: rgba(255, 87, 7, .55); background: var(--panel2); transform: translateY(-1px); }
.task-icon { flex: none; width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent2); }
.task-text { display: flex; flex-direction: column; gap: 2px; }
.task-text strong { font-size: 15px; }
.task-text span { color: var(--muted); font-size: 13px; }
.privacy-strip { display: flex; align-items: center; gap: 10px; margin: 28px auto 0; max-width: 760px; padding: 12px 16px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line); color: var(--muted); font-size: 13.5px; }
.privacy-strip .ico { color: var(--ok); }
.start-foot { display: flex; flex-wrap: wrap; justify-content: center; gap: 18px; margin-top: 28px; color: var(--faint); font-size: 13px; }
.start-foot a { color: var(--muted); }

/* ---------- page organizer ---------- */
.grid-scroll { flex: 1 1 auto; overflow-y: auto; position: relative; background: var(--bg2); scrollbar-width: thin; }
.pgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(var(--tw), 1fr)); gap: 26px 28px; padding: 24px 28px 80px; align-content: start; min-height: 100%; outline: none; }
.pcard { position: relative; display: flex; flex-direction: column; gap: 6px; border-radius: 10px; padding: 8px; outline: none; user-select: none; touch-action: pan-y; }
.pcard:hover { background: rgba(255, 255, 255, .03); }
.pcard:focus-visible { box-shadow: 0 0 0 2px var(--accent); }
.pcard.selected { background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--accent); }
.pcard.dragging { opacity: .35; }
.pcard-thumb { position: relative; display: grid; place-items: center; aspect-ratio: 1 / 1.1; }
.pcard-canvas { max-width: 100%; max-height: 100%; aspect-ratio: var(--ar, 0.707); width: auto; height: auto; background: #fff; box-shadow: 0 2px 10px rgba(0, 0, 0, .45), 0 0 0 1px rgba(0, 0, 0, .3); border-radius: 2px; }
.pcard-badges { position: absolute; right: 6px; bottom: 6px; display: flex; gap: 3px; }
.pcard-foot { display: flex; align-items: baseline; gap: 8px; min-width: 0; padding: 0 2px; }
.pcard-num { font-weight: 700; font-variant-numeric: tabular-nums; display: inline-flex; align-items: center; gap: 6px; }
.pcard-num::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--src); }
.pcard-src { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pcard-tools { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); display: flex; gap: 2px; padding: 3px; border-radius: 9px; background: rgba(17, 19, 23, .92); box-shadow: 0 4px 14px rgba(0, 0, 0, .5); opacity: 0; pointer-events: none; transition: opacity .12s; }
.pcard-tools .ibtn { min-width: 28px; height: 28px; padding: 0; }
.pcard:hover .pcard-tools, .pcard:focus-within .pcard-tools { opacity: 1; pointer-events: auto; }
.pcard-split { position: absolute; right: -24px; top: calc(50% - 30px); width: 22px; height: 40px; display: grid; place-items: center; border: 0; border-radius: 6px; background: transparent; color: var(--faint); opacity: 0; transition: opacity .12s; }
.pcard:hover .pcard-split, .pcard-split:focus-visible { opacity: 1; }
.pcard-split:hover { color: var(--accent2); background: var(--panel3); }
.pcard.split-after .pcard-split { opacity: 1; color: var(--accent); }
.pcard.split-after::after { content: ""; position: absolute; right: -15px; top: 4px; bottom: 4px; border-right: 2px dashed var(--accent); }
.drop-marker { position: absolute; width: 4px; margin-left: -2px; border-radius: 2px; background: var(--accent); box-shadow: 0 0 12px var(--accent); pointer-events: none; z-index: 5; }
.drag-ghost { position: fixed; left: 0; top: 0; z-index: 100; pointer-events: none; }
.drag-ghost canvas { width: 110px; height: auto; border-radius: 3px; box-shadow: 0 10px 30px rgba(0, 0, 0, .6); transform: rotate(-3deg); }
.drag-count { position: absolute; right: -10px; top: -10px; min-width: 26px; height: 26px; padding: 0 6px; display: grid; place-items: center; border-radius: 13px; background: var(--accent); color: var(--accent-ink); font-weight: 700; }
body.is-dragging, body.is-dragging * { cursor: grabbing !important; }

/* ---------- editor ---------- */
.strip { flex: none; width: 128px; overflow-y: auto; padding: 12px 10px 40px; background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 12px; scrollbar-width: thin; }
.strip-item { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px; border: 0; border-radius: 8px; background: transparent; }
.strip-item canvas { width: 88px; height: auto; aspect-ratio: var(--ar, 0.707); background: #fff; box-shadow: 0 1px 6px rgba(0, 0, 0, .5); }
.strip-item:hover { background: var(--panel2); }
.strip-item.on { background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--accent); }
.strip-num { font-size: 12px; color: var(--muted); }
.doc-scroll { flex: 1 1 auto; overflow: auto; background: #2a2e35; scrollbar-width: thin; outline: none; }
.doc { display: flex; flex-direction: column; align-items: center; gap: 22px; padding: 24px 28px 120px; min-width: max-content; }
.epage { position: relative; flex: none; background: #fff; box-shadow: 0 4px 18px rgba(0, 0, 0, .45); }
.epage-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.elayer { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.sublayer { position: absolute; inset: 0; pointer-events: none; }
.sublayer > * { pointer-events: auto; }
.sublayer > .deco { pointer-events: none; }
.epage-label { position: absolute; left: -26px; top: 0; font-size: 11px; color: rgba(255, 255, 255, .45); }

.obj { position: absolute; transform-origin: 50% 50%; cursor: move; touch-action: none; }
.hdl, .fw-design { touch-action: none; }
/* with a drawing tool a finger draws; with the select tool blank page areas still scroll */
.view-edit:not([data-tool="select"]) .epage { touch-action: none; }
.view-edit:not([data-tool="select"]) .obj { cursor: crosshair; }
.obj-svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.obj-svg text { white-space: pre; }
.obj-shape .obj-svg .hit { pointer-events: stroke; }
.obj-line, .obj-arrow { pointer-events: none; }
.obj-line .hit, .obj-arrow .hit { pointer-events: stroke; cursor: move; }
.obj-img { width: 100%; height: 100%; display: block; pointer-events: none; user-select: none; }
.obj-highlight { mix-blend-mode: multiply; }
.obj.deco { pointer-events: none; opacity: .9; }
.obj.selected { outline: 1.5px solid var(--blue); outline-offset: 1px; }
.obj-line.selected, .obj-arrow.selected { outline: none; }
.obj-text.empty { outline: 1px dashed rgba(76, 141, 255, .7); min-width: 20px; }
.obj.editing .obj-svg { visibility: hidden; }
.text-editor { position: absolute; inset: 0; width: 100%; min-height: 100%; height: 100%; margin: 0; border: 0; outline: 1.5px solid var(--blue); outline-offset: 1px; background: rgba(255, 255, 255, .6); resize: none; overflow: hidden; white-space: pre-wrap; overflow-wrap: anywhere; cursor: text; }
.handles { position: absolute; inset: 0; pointer-events: none; }
.hdl { position: absolute; width: 10px; height: 10px; margin: -5px 0 0 -5px; background: #fff; border: 1.5px solid var(--blue); border-radius: 2px; pointer-events: auto; z-index: 2; }
.hdl-nw { left: 0; top: 0; cursor: nwse-resize; } .hdl-n { left: 50%; top: 0; cursor: ns-resize; } .hdl-ne { left: 100%; top: 0; cursor: nesw-resize; }
.hdl-e { left: 100%; top: 50%; cursor: ew-resize; } .hdl-se { left: 100%; top: 100%; cursor: nwse-resize; } .hdl-s { left: 50%; top: 100%; cursor: ns-resize; }
.hdl-sw { left: 0; top: 100%; cursor: nesw-resize; } .hdl-w { left: 0; top: 50%; cursor: ew-resize; }
.hdl-rot { left: 50%; top: -26px; border-radius: 50%; cursor: grab; }
.hdl-rot::after { content: ""; position: absolute; left: 3px; top: 8px; width: 1px; height: 14px; background: var(--blue); }
.hdl-pt { border-radius: 50%; cursor: crosshair; }
.marquee { position: absolute; border: 1px solid var(--blue); background: rgba(76, 141, 255, .12); pointer-events: none; z-index: 3; }
.guide { position: absolute; pointer-events: none; z-index: 4; }
.guide-v { top: 0; bottom: 0; width: 0; border-left: 1px solid #ff3dbb; }
.guide-h { left: 0; right: 0; height: 0; border-top: 1px solid #ff3dbb; }
.create-box { position: absolute; border: 1.5px dashed var(--accent); background: rgba(255, 87, 7, .08); pointer-events: none; z-index: 3; }
.create-box.is-line { border: 0; border-top: 2px dashed var(--accent); background: none; transform-origin: 0 0; }
.pen-preview { position: absolute; left: 0; top: 0; pointer-events: none; z-index: 3; }
.view-edit[data-tool="pen"] .doc-scroll, .view-edit[data-tool^="f-"] .doc-scroll, .view-edit[data-tool="rect"] .doc-scroll, .view-edit[data-tool="ellipse"] .doc-scroll,
.view-edit[data-tool="line"] .doc-scroll, .view-edit[data-tool="arrow"] .doc-scroll, .view-edit[data-tool="highlight"] .doc-scroll, .view-edit[data-tool="whiteout"] .doc-scroll,
.view-edit[data-tool="check"] .doc-scroll, .view-edit[data-tool="cross"] .doc-scroll, .view-edit[data-tool="dot"] .doc-scroll, .view-edit[data-tool="sign"] .doc-scroll,
.view-edit[data-tool="initials"] .doc-scroll, .view-edit[data-tool="image"] .doc-scroll { cursor: crosshair; }
.view-edit[data-tool="text"] .doc-scroll, .view-edit[data-tool="date"] .doc-scroll { cursor: text; }

/* designer fields */
.obj-field { background: var(--fbg); box-shadow: inset 0 0 0 var(--fbw) var(--fborder); color: var(--fcolor); }
.obj-field.f-round { border-radius: 50%; }
.obj-field.f-underline { box-shadow: inset 0 calc(-1 * var(--fbw)) 0 var(--fborder); }
.obj-field.f-dashed { box-shadow: none; outline: var(--fbw) dashed var(--fborder); outline-offset: calc(-1 * var(--fbw)); }
.f-inner { position: absolute; inset: 0; display: flex; align-items: center; padding: 0 3px; overflow: hidden; white-space: nowrap; line-height: 1.1; pointer-events: none; }
.f-inner.f-multi { align-items: flex-start; padding-top: 2px; white-space: pre-wrap; }
.f-mark { justify-content: center; font-family: "Segoe UI Symbol", "DejaVu Sans", sans-serif; padding: 0; }
.f-drop { gap: 4px; }
.f-list { flex-direction: column; align-items: stretch; justify-content: flex-start; padding: 1px; font-size: inherit; }
.f-list > div { padding: 0 3px; }
.f-list > .on { background: #3367d6; color: #fff; }
.f-button { justify-content: center; }
.f-sig { justify-content: center; gap: 6px; color: #5b6573; font-family: var(--font) !important; }
.f-name { position: absolute; left: 0; bottom: 100%; margin-bottom: 2px; padding: 0 5px; border-radius: 4px 4px 4px 0; background: #3367d6; color: #fff; font: 600 10.5px/16px var(--font); white-space: nowrap; pointer-events: none; opacity: 0; transition: opacity .1s; z-index: 3; }
.obj-field.selected .f-name, .obj-field:hover .f-name { opacity: 1; }
/* in the form builder the name sits inside empty fields, so dense tables stay readable */
.view-edit[data-mode="form"] .obj-field:not(.f-small):not(.selected):not(:hover) .f-name { opacity: 1; left: 3px; right: 3px; top: 50%; bottom: auto; margin: 0; padding: 0; transform: translateY(-50%); background: none; color: rgba(37, 84, 196, .85); overflow: hidden; text-overflow: ellipsis; }
.view-edit[data-mode="form"] .obj-field.has-value:not(.selected):not(:hover) .f-name { opacity: 0; }

/* fields that came with the PDF */
.fw { position: absolute; }
.fw-inner { position: absolute; inset: 0; }
.fw-inner.fw-rot { left: 50%; top: 50%; inset: auto; }
.fw-input { width: 100%; height: 100%; margin: 0; padding: 0 3px; border: 0; border-radius: 0; background: rgba(66, 133, 244, .13); color: #000; font-family: Helvetica, Arial, sans-serif; outline: none; resize: none; }
.fw-input:hover { background: rgba(66, 133, 244, .2); }
.fw-input:focus { background: rgba(66, 133, 244, .08); box-shadow: inset 0 0 0 1.5px #3367d6; }
textarea.fw-input { padding-top: 2px; line-height: 1.15; }
select.fw-input { padding: 0; }
.fw-comb { font-family: var(--mono); }
.fw-req .fw-input, .fw-req .fw-check { box-shadow: inset 0 0 0 1px rgba(220, 38, 38, .55); }
.fw-check { width: 100%; height: 100%; display: grid; place-items: center; padding: 0; border: 0; background: rgba(66, 133, 244, .13); color: #000; line-height: 1; font-family: "Segoe UI Symbol", "DejaVu Sans", sans-serif; }
.fw-check.round { border-radius: 50%; }
.fw-check:hover { background: rgba(66, 133, 244, .25); }
.fw-sig { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; gap: 6px; border: 1.5px dashed #3367d6; background: rgba(66, 133, 244, .08); color: #1a4bb3; font-weight: 600; font-size: 12px; }
.fw-ro .fw-input, .fw-ro .fw-check { background: rgba(0, 0, 0, .05); }
.fw-design { border: 1.5px dashed #8a6df1; background: rgba(138, 109, 241, .1); cursor: pointer; }
.fw-design .f-name { opacity: .9; background: #6e54d8; }
.fw-design.on { border-style: solid; background: rgba(138, 109, 241, .22); }
.fw-design:hover { background: rgba(138, 109, 241, .2); }

/* ---------- bookmarks ---------- */
.bm-tools { display: flex; align-items: center; gap: 6px; margin-bottom: 10px; }
.bm-tree, .bm-tree ul { list-style: none; margin: 0; padding: 0; }
.bm-row { display: flex; align-items: center; gap: 2px; min-height: 32px; border-radius: 6px; }
.bm-row:hover { background: var(--panel2); }
.bm-row.gone .bm-title { color: var(--faint); text-decoration: line-through; }
.bm-tog { width: 22px; height: 22px; display: grid; place-items: center; border: 0; background: transparent; padding: 0; color: var(--muted); }
.bm-dot { width: 4px; height: 4px; border-radius: 50%; background: var(--faint); }
.bm-title { flex: 1 1 auto; min-width: 0; height: 30px; display: flex; align-items: center; padding: 0 4px; border: 0; background: transparent; text-align: left; }
.bm-title span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bm-page { flex: none; min-width: 24px; text-align: right; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.bm-row .ibtn { min-width: 26px; height: 26px; padding: 0; opacity: .6; }
.bm-row:hover .ibtn { opacity: 1; }
.bm-rename { height: 28px; }
.bm-dialog { min-height: 260px; }

/* ---------- modal, menus, toasts, busy ---------- */
.modal-back { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: 16px; background: rgba(5, 6, 8, .62); backdrop-filter: blur(2px); animation: fade .12s ease-out; }
@keyframes fade { from { opacity: 0; } }
.modal { width: min(520px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; border-radius: 14px; background: var(--panel); border: 1px solid var(--line2); box-shadow: 0 24px 70px rgba(0, 0, 0, .6); animation: pop .14s ease-out; }
@keyframes pop { from { transform: translateY(8px) scale(.98); opacity: 0; } }
.modal-wide { width: min(720px, 100%); }
.modal-xl { width: min(980px, 100%); }
.modal-head { flex: none; display: flex; align-items: center; gap: 8px; padding: 14px 14px 10px 20px; }
.modal-head h2 { flex: 1 1 auto; margin: 0; font-size: 17px; }
.modal-body { flex: 1 1 auto; overflow-y: auto; padding: 4px 20px 16px; }
.modal-foot { flex: none; display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 12px 20px 16px; border-top: 1px solid var(--line); }
.modal-text { margin: 0; white-space: pre-line; }
.dlg-split { display: grid; grid-template-columns: 1fr 300px; gap: 22px; align-items: start; }
.dlg-preview { position: sticky; top: 0; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.dlg-preview-frame { width: 300px; min-height: 200px; display: grid; place-items: center; padding: 12px; border-radius: 10px; background: #2a2e35; }
.dlg-preview-canvas { max-width: 276px; max-height: 420px; width: auto; height: auto; background: #fff; box-shadow: 0 3px 12px rgba(0, 0, 0, .5); }
.hf-slots { display: grid; grid-template-columns: 64px 1fr 1fr 1fr; gap: 6px; align-items: center; }
.hf-row-label { color: var(--muted); font-size: 12.5px; }
.tokens { line-height: 1.6; }
.preset-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; }
.preset-card { display: flex; flex-direction: column; gap: 4px; padding: 12px; border-radius: 10px; border: 1px solid var(--line2); background: var(--panel2); text-align: left; }
.preset-card span { color: var(--muted); font-size: 12.5px; }
.preset-card.on { border-color: var(--accent); background: var(--accent-soft); }
.img-prev { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; padding: 12px; border-radius: 10px; background: #2a2e35; }
.img-prev-page { position: relative; background: #fff; box-shadow: 0 2px 8px rgba(0, 0, 0, .5); overflow: hidden; }
.img-prev-page img { position: absolute; object-fit: fill; }
.result-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.result-list li { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 8px; background: var(--panel2); font-size: 13px; }
.keys { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 0; }
.keys dd { margin: 0; color: var(--muted); }
select.attention { border-color: var(--accent); }

.sig-panel { min-height: 270px; display: flex; flex-direction: column; gap: 10px; }
.sig-pad-wrap { position: relative; }
.sig-pad { width: 100%; height: auto; aspect-ratio: 620 / 220; display: block; border-radius: 10px; background: #fff; touch-action: none; cursor: crosshair; }
.sig-hint { position: absolute; left: 14px; bottom: 10px; color: #9aa3ae; font-size: 12px; pointer-events: none; }
.sig-tools { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.ink-row { display: flex; align-items: center; gap: 8px; }
.font-choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; max-height: 260px; overflow-y: auto; }
.font-choice { height: 64px; padding: 0 12px; border-radius: 10px; border: 1px solid #d5d9df; background: #fff; font-size: 30px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.font-choice.on { box-shadow: 0 0 0 3px var(--accent); }
.sig-upload-preview { min-height: 140px; display: grid; place-items: center; padding: 10px; border-radius: 10px; background: #fff repeating-conic-gradient(#eef0f3 0 25%, #fff 0 50%) 0 0 / 16px 16px; color: #5b6573; }
.sig-clean { max-width: 100%; max-height: 220px; }
.sig-saved { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
.sig-card { position: relative; border-radius: 10px; background: #fff; }
.sig-card.on { box-shadow: 0 0 0 3px var(--accent); }
.sig-card .ibtn { position: absolute; right: 4px; top: 4px; color: #5b6573; }
.sig-pick { width: 100%; height: 100px; display: grid; place-items: center; padding: 10px 28px 10px 10px; border: 0; background: transparent; }
.sig-preview { max-width: 100%; max-height: 80px; width: auto; height: 70px; }

.menu { position: fixed; z-index: 300; min-width: 220px; max-height: calc(100vh - 16px); overflow-y: auto; padding: 6px; border-radius: 10px; background: var(--panel2); border: 1px solid var(--line2); box-shadow: 0 14px 40px rgba(0, 0, 0, .55); }
.menu-item { width: 100%; display: flex; align-items: center; gap: 10px; height: 34px; padding: 0 10px; border: 0; border-radius: 6px; background: transparent; text-align: left; white-space: nowrap; }
.menu-item:hover:not(:disabled), .menu-item:focus-visible { background: var(--panel3); outline: none; }
.menu-item.checked { color: var(--accent2); }
.menu-noicon { width: 16px; flex: none; }
.menu-sep { height: 1px; margin: 5px 4px; background: var(--line2); }
.menu-head { padding: 8px 10px 4px; font-size: 11px; letter-spacing: .6px; text-transform: uppercase; color: var(--faint); }

.toasts { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 400; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast { max-width: min(560px, calc(100vw - 32px)); padding: 10px 16px; border-radius: 10px; background: #262b33; border: 1px solid var(--line2); box-shadow: 0 10px 30px rgba(0, 0, 0, .5); font-size: 13.5px; animation: toastIn .18s ease-out; transition: opacity .3s, transform .3s; }
.toast-ok { border-color: rgba(47, 191, 113, .5); }
.toast-warn { border-color: rgba(255, 176, 32, .6); }
.toast-error { border-color: rgba(255, 93, 93, .6); }
.toast.out { opacity: 0; transform: translateY(6px); }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } }
.busy { position: fixed; inset: 0; z-index: 500; display: grid; place-items: center; background: rgba(5, 6, 8, .55); }
.busy-box { min-width: 300px; max-width: 90vw; display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 24px 28px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line2); box-shadow: 0 24px 60px rgba(0, 0, 0, .6); }
.busy-text { margin: 0; color: var(--muted); text-align: center; }
.busy-bar { width: 100%; height: 6px; border-radius: 3px; background: var(--bg2); overflow: hidden; }
.busy-bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--line2); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
body.drop-hover .main::after { content: "Drop to add"; position: absolute; inset: 10px; display: grid; place-items: center; border: 3px dashed var(--accent); border-radius: 16px; background: rgba(255, 87, 7, .08); color: var(--accent2); font-size: 22px; font-weight: 600; pointer-events: none; z-index: 50; }

/* ---------- narrow screens ---------- */
@media (max-width: 1180px) {
  .brand-sub { display: none; }
  .doc-name { width: 150px; }
}
@media (max-width: 980px) {
  .only-narrow { display: inline-flex; }
  .side { position: absolute; right: 0; top: 48px; bottom: 0; z-index: 15; box-shadow: -10px 0 30px rgba(0, 0, 0, .45); transform: translateX(105%); transition: transform .18s; }
  .view.side-open .side { transform: none; }
  .strip { display: none; }
  .exit span, .tools-btn span { display: none; }
  .seg-mode .seg-btn span { display: none; }
  .dlg-split { grid-template-columns: 1fr; }
  .dlg-preview { position: static; }
}
@media (max-width: 680px) {
  :root { --top: 52px; }
  body.has-doc .topbar > .ibtn[title^="About"] { display: none; }
  .topbar .ibtn { min-width: 32px; padding: 0 6px; }
  .exit { padding: 0 6px; }
  .brand-name { display: none; }
  .doc-name { display: none !important; }
  .view-tab span { display: none; }
  .topbar { gap: 4px; padding: 0 6px; }
  .topbar .btn-primary span { display: none; }
  .topbar .btn-primary { padding: 0 10px; }
  .pgrid { gap: 18px 16px; padding: 14px 14px 80px; grid-template-columns: repeat(auto-fill, minmax(min(var(--tw), 44vw), 1fr)); }
  .pcard-split { right: -16px; }
  .tb-zoom { display: none; }
  .doc { padding: 14px 10px 100px; }
  .epage-label { display: none; }
  .side { width: min(340px, 92vw); }
  .start-inner { padding: 26px 14px 30px; }
  .task-grid { grid-template-columns: 1fr; }
  .hf-slots { grid-template-columns: 1fr; }
  .modal-body { padding: 4px 14px 14px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
