/* PDF Studio — one stylesheet, system fonts for the UI, Noto faces only for
   text that ends up inside the PDF. */

@font-face { font-family: "PF Sans"; src: url(../fonts/sans-r.ttf); font-weight: 400; font-style: normal; font-display: block; }
@font-face { font-family: "PF Sans"; src: url(../fonts/sans-b.ttf); font-weight: 700; font-style: normal; font-display: block; }
@font-face { font-family: "PF Sans"; src: url(../fonts/sans-i.ttf); font-weight: 400; font-style: italic; font-display: block; }
@font-face { font-family: "PF Sans"; src: url(../fonts/sans-bi.ttf); font-weight: 700; font-style: italic; font-display: block; }
@font-face { font-family: "PF Serif"; src: url(../fonts/serif-r.ttf); font-weight: 400; font-style: normal; font-display: block; }
@font-face { font-family: "PF Serif"; src: url(../fonts/serif-b.ttf); font-weight: 700; font-style: normal; font-display: block; }
@font-face { font-family: "PF Serif"; src: url(../fonts/serif-i.ttf); font-weight: 400; font-style: italic; font-display: block; }
@font-face { font-family: "PF Serif"; src: url(../fonts/serif-bi.ttf); font-weight: 700; font-style: italic; font-display: block; }
@font-face { font-family: "PF Mono"; src: url(../fonts/mono-r.ttf); font-weight: 400; font-display: block; }
@font-face { font-family: "PF Mono"; src: url(../fonts/mono-b.ttf); font-weight: 700; font-display: block; }
@font-face { font-family: "PF Hand"; src: url(../fonts/hand-r.ttf); font-weight: 400; font-display: block; }
@font-face { font-family: "PF Hand"; src: url(../fonts/hand-b.ttf); font-weight: 700; font-display: block; }
@font-face { font-family: "PF He Sans"; src: url(../fonts/he-sans-r.ttf); font-weight: 400; unicode-range: U+0590-05FF, U+FB1D-FB4F, U+20AA; font-display: block; }
@font-face { font-family: "PF He Sans"; src: url(../fonts/he-sans-b.ttf); font-weight: 700; unicode-range: U+0590-05FF, U+FB1D-FB4F, U+20AA; font-display: block; }
@font-face { font-family: "PF He Serif"; src: url(../fonts/he-serif-r.ttf); font-weight: 400; unicode-range: U+0590-05FF, U+FB1D-FB4F, U+20AA; font-display: block; }
@font-face { font-family: "PF He Serif"; src: url(../fonts/he-serif-b.ttf); font-weight: 700; unicode-range: U+0590-05FF, U+FB1D-FB4F, U+20AA; font-display: block; }

:root {
  --bg: #f3f2ef;
  --surface: #ffffff;
  --surface-2: #f8f7f5;
  --sunken: #e9e7e2;
  --line: #e1dfda;
  --line-strong: #cfccc5;
  --text: #1d1c1a;
  --muted: #6b6862;
  --faint: #9a968f;
  --accent: #2457d6;
  --accent-ink: #ffffff;
  --accent-soft: #e5ecfc;
  --danger: #c4361f;
  --ok: #2c7a4b;
  --stage: #e4e2dd;
  --page-shadow: 0 1px 2px rgba(0,0,0,.12), 0 2px 10px rgba(0,0,0,.06);
  --pop-shadow: 0 10px 30px rgba(20,18,15,.16), 0 1px 3px rgba(20,18,15,.12);
  --radius: 8px;
  --ui: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #161718; --surface: #1e1f21; --surface-2: #232427; --sunken: #121314;
    --line: #2d2f33; --line-strong: #3b3e43; --text: #e7e5e1; --muted: #a09d97; --faint: #74716c;
    --accent: #6f95ff; --accent-ink: #0d1424; --accent-soft: #1f2a44; --danger: #ff7a62; --ok: #6fcf97;
    --stage: #0f1011; --page-shadow: 0 1px 2px rgba(0,0,0,.5), 0 2px 12px rgba(0,0,0,.35);
    --pop-shadow: 0 12px 36px rgba(0,0,0,.5), 0 1px 3px rgba(0,0,0,.5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #161718; --surface: #1e1f21; --surface-2: #232427; --sunken: #121314;
  --line: #2d2f33; --line-strong: #3b3e43; --text: #e7e5e1; --muted: #a09d97; --faint: #74716c;
  --accent: #6f95ff; --accent-ink: #0d1424; --accent-soft: #1f2a44; --danger: #ff7a62; --ok: #6fcf97;
  --stage: #0f1011; --page-shadow: 0 1px 2px rgba(0,0,0,.5), 0 2px 12px rgba(0,0,0,.35);
  --pop-shadow: 0 12px 36px rgba(0,0,0,.5), 0 1px 3px rgba(0,0,0,.5);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--text); font: 14px/1.4 var(--ui);
  display: flex; flex-direction: column; overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
[hidden] { display: none !important; }

/* ---------- buttons ---------- */
.ibtn {
  display: inline-grid; place-items: center; width: 34px; height: 34px; padding: 0;
  border: 0; border-radius: 7px; background: transparent; color: var(--text);
}
.ibtn.sm { width: 28px; height: 28px; }
.ibtn.sm svg { width: 17px; height: 17px; }
.ibtn:hover:not(:disabled) { background: var(--sunken); }
.ibtn:disabled { opacity: .35; cursor: default; }
.ibtn.on, .ibtn.tog.on { background: var(--accent-soft); color: var(--accent); }
.btn {
  display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 14px;
  border-radius: 7px; border: 1px solid var(--line-strong); background: var(--surface); font-weight: 550;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--danger); }
.btn svg { width: 18px; height: 18px; }
.linkbtn { border: 0; background: none; color: var(--accent); padding: 0; }
.linkbtn:hover { text-decoration: underline; }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 8px; height: 52px; padding: 0 10px;
  background: var(--surface); border-bottom: 1px solid var(--line); flex: none; z-index: 20;
}
.brand { width: 38px; height: 38px; }
.docname { display: flex; align-items: center; gap: 6px; min-width: 0; flex: 1 1 0; }
.docname input {
  min-width: 60px; width: auto; max-width: 340px; field-sizing: content; border: 1px solid transparent; background: transparent;
  border-radius: 6px; padding: 5px 7px; font-weight: 600; text-overflow: ellipsis;
}
.docname input:hover { border-color: var(--line); }
.docname input:focus { outline: none; border-color: var(--accent); background: var(--surface-2); }
.dirty { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); flex: none; }
.modes { display: flex; background: var(--sunken); border-radius: 9px; padding: 3px; gap: 2px; flex: none; }
.modes button {
  display: flex; align-items: center; gap: 6px; border: 0; background: transparent; height: 32px; padding: 0 13px;
  border-radius: 7px; color: var(--muted); font-weight: 550;
}
.modes button svg { width: 17px; height: 17px; }
.modes button:hover { color: var(--text); }
.modes button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.1); }
.top-actions { display: flex; align-items: center; gap: 2px; flex: 1 1 0; justify-content: flex-end; }
.top-actions .btn { margin: 0 4px; }
body.no-doc .topbar .modes, body.no-doc .top-actions > :not(#moreBtn), body.no-doc .docname { visibility: hidden; }

/* ---------- tool strip ---------- */
.strip { background: var(--surface); border-bottom: 1px solid var(--line); flex: none; z-index: 15; }
body.no-doc .strip, body.no-doc .props, body.no-doc .work { display: none; }
.strip-scroll { overflow-x: auto; scrollbar-width: none; }
.strip-scroll::-webkit-scrollbar { display: none; }
.tools { display: none; align-items: center; gap: 2px; height: 46px; padding: 0 8px; width: max-content; min-width: 100%; }
body[data-mode="view"] .tools[data-for="view"],
body[data-mode="edit"] .tools[data-for="edit"],
body[data-mode="sign"] .tools[data-for="sign"],
body[data-mode="pages"] .tools[data-for="pages"] { display: flex; }
.sep { width: 1px; height: 22px; background: var(--line); margin: 0 6px; flex: none; }
.tbtn {
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 10px; border: 0;
  border-radius: 7px; background: transparent; white-space: nowrap; color: var(--text);
}
.tbtn.icon-only { padding: 0 7px; }
.tbtn:hover { background: var(--sunken); }
.tbtn.on { background: var(--accent-soft); color: var(--accent); }
.tbtn .caret { width: 13px; height: 13px; margin-left: -2px; opacity: .6; }
.tbtn:disabled { opacity: .4; cursor: default; }
.strip-hint { color: var(--muted); font-size: 13px; padding: 0 10px; white-space: nowrap; }
.select-wrap select {
  height: 32px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); padding: 0 8px; margin: 0 4px;
}

/* ---------- properties row ---------- */
.props {
  display: flex; align-items: center; gap: 6px; min-height: 44px; padding: 5px 12px; background: var(--surface-2);
  border-bottom: 1px solid var(--line); overflow-x: auto; flex: none; z-index: 14; scrollbar-width: thin;
}
.props .lbl { color: var(--muted); font-size: 12.5px; margin: 0 2px 0 6px; white-space: nowrap; }
.props .lbl:first-child { margin-left: 0; }
.swatches { display: flex; gap: 4px; }
.sw {
  width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--line-strong);
  padding: 0; flex: none;
}
.sw.on { box-shadow: 0 0 0 2px var(--accent); }
.sw.none { background: linear-gradient(135deg, transparent 45%, var(--danger) 45%, var(--danger) 55%, transparent 55%), var(--surface); }
.sw-custom { position: relative; overflow: hidden; background: conic-gradient(#e43, #ec3, #3c5, #3ae, #a4e, #e43); }
.sw-custom input { position: absolute; inset: -6px; opacity: 0; cursor: pointer; }
.props select, .props input[type=number], .props input[type=text] {
  height: 30px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); padding: 0 6px;
}
.props input[type=number] { width: 58px; }
.props input[type=range] { width: 96px; accent-color: var(--accent); }
.props .ibtn { width: 30px; height: 30px; }
.props .ibtn svg { width: 17px; height: 17px; }
.props .grow { flex: 1; }
.props .psep { width: 1px; height: 20px; background: var(--line); margin: 0 4px; flex: none; }

/* ---------- workspace ---------- */
.work { flex: 1; display: flex; min-height: 0; position: relative; }
.sidebar {
  width: 216px; flex: none; display: flex; flex-direction: column; background: var(--surface);
  border-right: 1px solid var(--line); min-height: 0;
}
body.side-closed .sidebar { display: none; }
body[data-mode="pages"] .sidebar { display: none; }
.side-tabs { display: flex; gap: 2px; padding: 6px; border-bottom: 1px solid var(--line); }
.side-tabs button { flex: 1; height: 30px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); display: grid; place-items: center; }
.side-tabs button svg { width: 18px; height: 18px; }
.side-tabs button.on { background: var(--sunken); color: var(--text); }
.side-body { flex: 1; overflow: auto; min-height: 0; }
.side-pane { display: none; padding: 10px; }
.side-pane.on { display: block; }
.thumb {
  display: block; width: 100%; border: 0; background: none; padding: 6px 0 4px; text-align: center; border-radius: 8px;
}
.thumb .tcanvas {
  display: block; margin: 0 auto; background: #fff; box-shadow: var(--page-shadow); border-radius: 2px;
  outline: 2px solid transparent; outline-offset: 2px; min-height: 40px;
}
.thumb canvas { display: block; width: 100%; height: auto; }
.thumb.on .tcanvas { outline-color: var(--accent); }
.thumb small { display: block; color: var(--muted); font-size: 12px; margin-top: 5px; }
.outline-item { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 5px 6px; border-radius: 6px; color: var(--text); }
.outline-item:hover { background: var(--sunken); }
.outline-kids { padding-left: 12px; }
.empty { color: var(--muted); font-size: 13px; padding: 8px 4px; }
.note-row { display: flex; gap: 8px; width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--line); background: none; padding: 9px 4px; }
.note-row:hover { background: var(--surface-2); }
.note-row .chip { width: 10px; height: 10px; border-radius: 3px; margin-top: 4px; flex: none; }
.note-row .nt { flex: 1; min-width: 0; }
.note-row .nt b { font-weight: 550; font-size: 13px; }
.note-row .nt span { display: block; color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach-row { display: flex; align-items: center; gap: 8px; padding: 8px 4px; border-bottom: 1px solid var(--line); }
.attach-row span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.stage { flex: 1; position: relative; min-width: 0; background: var(--stage); }
#viewerContainer { position: absolute; inset: 0; overflow: auto; outline: none; isolation: isolate; }
#viewerContainer.hand { cursor: grab; }
#viewerContainer.hand.grabbing { cursor: grabbing; }
#viewerContainer.hand .textLayer { pointer-events: none; }
.pdfViewer { padding: 14px 0 80px; }
.pdfViewer .page { border: 0 !important; margin: 0 auto 14px !important; box-shadow: var(--page-shadow); background-clip: padding-box; }
.pdfViewer.scrollHorizontal .page, .pdfViewer.scrollWrapped .page, .pdfViewer .spread .page { margin: 7px !important; }
.pdfViewer.scrollHorizontal { padding: 14px 14px 80px; }
body.night .pdfViewer .page .canvasWrapper { filter: invert(.92) hue-rotate(180deg); }
body.night .pdfViewer .page { background: #111; }

/* forms: make fillable fields easy to spot */
.annotationLayer .textWidgetAnnotation :is(input, textarea),
.annotationLayer .choiceWidgetAnnotation select,
.annotationLayer .buttonWidgetAnnotation:is(.checkBox, .radioButton) input {
  background-image: none; background-color: rgba(36, 87, 214, .09);
}
.annotationLayer .textWidgetAnnotation :is(input, textarea):focus { background-color: rgba(36, 87, 214, .16); outline: 1.5px solid var(--accent); }

/* ---------- overlay objects ---------- */
.ov { position: absolute; left: 50%; top: 50%; transform-origin: 50% 50%; pointer-events: none; z-index: 30; }
.ov.capture { pointer-events: auto; cursor: crosshair; touch-action: none; }
.ov.capture.cursor-text { cursor: text; }
.ov.capture.cursor-place { cursor: copy; }
.obj { position: absolute; transform-origin: 50% 50%; pointer-events: auto; touch-action: none; cursor: move; }
body[data-mode="view"] .obj { pointer-events: none; }
.ov.capture .obj, body.tool-markup .obj { pointer-events: none; }
.obj > svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; stroke-width: initial; }
.obj img { display: block; width: 100%; height: 100%; pointer-events: none; user-select: none; -webkit-user-drag: none; }
.obj .tx { white-space: pre; font-synthesis: none; font-kerning: none; font-feature-settings: "kern" 0; unicode-bidi: plaintext; }
.obj .tx > div { white-space: pre; unicode-bidi: plaintext; min-height: 1em; }
.obj textarea {
  position: absolute; left: 0; top: 0; margin: 0; padding: 0; border: 0; outline: none; resize: none; overflow: hidden;
  background: transparent; white-space: pre; font-synthesis: none; font-kerning: none; font-feature-settings: "kern" 0;
  unicode-bidi: plaintext; cursor: text; caret-color: var(--accent);
}
.obj.editing { outline: 1.5px dashed var(--accent); outline-offset: 2px; cursor: text; }
.obj.sel { outline: 1.5px solid var(--accent); outline-offset: 1px; }
.obj.sel.editing { outline-style: dashed; }
.obj.hover-del { opacity: .35; }
.h { position: absolute; width: 11px; height: 11px; background: #fff; border: 1.5px solid var(--accent); border-radius: 2px; z-index: 2; touch-action: none; }
.h.nw { left: -6px; top: -6px; cursor: nwse-resize; } .h.ne { right: -6px; top: -6px; cursor: nesw-resize; }
.h.sw { left: -6px; bottom: -6px; cursor: nesw-resize; } .h.se { right: -6px; bottom: -6px; cursor: nwse-resize; }
.h.n { left: calc(50% - 5.5px); top: -6px; cursor: ns-resize; } .h.s { left: calc(50% - 5.5px); bottom: -6px; cursor: ns-resize; }
.h.w { top: calc(50% - 5.5px); left: -6px; cursor: ew-resize; } .h.e { top: calc(50% - 5.5px); right: -6px; cursor: ew-resize; }
.h.rot { left: calc(50% - 6px); top: -30px; width: 12px; height: 12px; border-radius: 50%; cursor: grab; }
.h.rot::after { content: ""; position: absolute; left: 4px; top: 11px; width: 1.5px; height: 13px; background: var(--accent); }
.h.p1, .h.p2 { border-radius: 50%; width: 13px; height: 13px; cursor: move; }
@media (pointer: coarse) { .h { width: 18px; height: 18px; } .h.nw,.h.sw,.h.w { left: -10px; } .h.ne,.h.se,.h.e { right: -10px; } .h.nw,.h.ne,.h.n { top: -10px; } .h.sw,.h.se,.h.s { bottom: -10px; } .h.n,.h.s { left: calc(50% - 9px); } .h.w,.h.e { top: calc(50% - 9px); } .h.rot { top: -40px; left: calc(50% - 9px); } .h.rot::after { left: 7px; top: 17px; } }
.mk { position: absolute; pointer-events: auto; cursor: pointer; }
.mk.hl { mix-blend-mode: multiply; }
body.night .mk.hl { mix-blend-mode: screen; }
.mk.sel { outline: 1.5px solid var(--accent); }
.ov.capture .mk, body[data-mode="view"] .mk, body.tool-markup .mk { pointer-events: none; }
.redact-box { background: repeating-linear-gradient(-45deg, rgba(0,0,0,.82) 0 6px, rgba(0,0,0,.7) 6px 12px); outline: 1.5px solid #e0412a; }
.note-ico { width: 100%; height: 100%; display: grid; place-items: center; border-radius: 4px 4px 4px 0; box-shadow: 0 1px 3px rgba(0,0,0,.35); }
.note-ico svg { width: 70%; height: 70%; stroke: #1d1c1a; stroke-width: 1.8; }
.ghost { position: absolute; pointer-events: none; opacity: .65; z-index: 40; outline: 1px dashed var(--accent); }
.rubber { position: absolute; border: 1.5px dashed var(--accent); background: rgba(36,87,214,.06); pointer-events: none; z-index: 40; }
body.tool-edittext .textLayer span { cursor: text; border-radius: 2px; }
body.tool-edittext .textLayer span:hover { outline: 1.5px solid var(--accent); background: rgba(36,87,214,.08); }
body.tool-edittext .textLayer { pointer-events: auto; z-index: 31; }
body.tool-markup .textLayer ::selection { background: rgba(255, 213, 0, .45); }

/* ---------- find + nav pill ---------- */
.findbar {
  position: absolute; top: 10px; right: 14px; display: flex; align-items: center; gap: 4px; padding: 5px 6px 5px 10px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--pop-shadow); z-index: 25;
  max-width: calc(100% - 28px); flex-wrap: wrap;
}
.findbar input#findInput { width: 200px; border: 0; outline: none; background: transparent; height: 28px; }
.find-count { color: var(--muted); font-size: 12.5px; min-width: 56px; text-align: right; }
.chk { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; color: var(--muted); padding: 0 4px; white-space: nowrap; }
.navpill {
  position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); display: flex; align-items: center; gap: 2px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 4px 6px; box-shadow: var(--pop-shadow); z-index: 25;
}
body[data-mode="pages"] .navpill { display: none; }
.navpill input { width: 40px; text-align: center; border: 1px solid transparent; background: transparent; border-radius: 6px; height: 26px; }
.navpill input:focus { outline: none; border-color: var(--accent); }
.navpill .of { color: var(--muted); font-size: 13px; padding-right: 4px; white-space: nowrap; }
.vsep { width: 1px; height: 18px; background: var(--line); margin: 0 4px; }
.zoomval { border: 0; background: none; min-width: 52px; height: 28px; border-radius: 6px; font-size: 13px; font-variant-numeric: tabular-nums; }
.zoomval:hover { background: var(--sunken); }

/* ---------- organizer ---------- */
.organizer { position: absolute; inset: 0; overflow: auto; background: var(--stage); }
.org-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 22px 18px; padding: 22px; user-select: none; }
.pcard { position: relative; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 10px 8px 8px; border-radius: 10px; touch-action: none; }
.pcard:hover { background: rgba(0,0,0,.04); }
:root[data-theme="dark"] .pcard:hover { background: rgba(255,255,255,.04); }
.pcard .pc-img { height: 180px; display: flex; align-items: center; justify-content: center; width: 100%; }
.pcard canvas { max-width: 100%; max-height: 180px; background: #fff; box-shadow: var(--page-shadow); border-radius: 2px; outline: 2.5px solid transparent; outline-offset: 3px; }
.pcard.sel canvas { outline-color: var(--accent); }
.pcard.sel { background: var(--accent-soft) !important; }
.pcard .pc-num { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.pcard .pc-tag { position: absolute; top: 14px; right: 14px; background: var(--accent); color: var(--accent-ink); font-size: 11px; border-radius: 99px; padding: 1px 7px; }
.pcard .pc-acts { position: absolute; bottom: 34px; display: none; gap: 2px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 2px; box-shadow: var(--pop-shadow); }
.pcard:hover .pc-acts { display: flex; }
@media (pointer: coarse) { .pcard .pc-acts { display: none !important; } }
.pcard.dragging { opacity: .35; }
.drop-marker { position: absolute; width: 3px; background: var(--accent); border-radius: 2px; pointer-events: none; z-index: 5; }
.pcard .pc-placeholder { width: 120px; height: 160px; background: var(--surface); box-shadow: var(--page-shadow); }

/* ---------- landing ---------- */
.landing { position: fixed; inset: 52px 0 0; overflow: auto; background: var(--bg); }
body:not(.no-doc) .landing { display: none; }
.land-inner { max-width: 760px; margin: 0 auto; padding: 48px 20px 60px; }
.land-head { display: flex; align-items: center; gap: 16px; margin-bottom: 22px; }
.land-head h1 { font-size: 26px; margin: 0; letter-spacing: -.01em; font-weight: 650; }
.land-head p { margin: 2px 0 0; color: var(--muted); }
.drop {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; height: 210px;
  border: 1.5px dashed var(--line-strong); border-radius: 14px; background: var(--surface); cursor: pointer; text-align: center; padding: 16px;
}
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop .drop-ico { width: 30px; height: 30px; color: var(--accent); margin-bottom: 4px; }
.drop strong { font-size: 16px; }
.drop span { color: var(--muted); }
.land-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 12px; }
.lbtn {
  display: flex; align-items: center; gap: 12px; text-align: left; padding: 12px 14px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface);
}
.lbtn:hover { border-color: var(--line-strong); background: var(--surface-2); }
.lbtn svg { color: var(--accent); }
.lbtn b { display: block; font-weight: 600; }
.lbtn small { color: var(--muted); font-size: 12.5px; }
.recent { margin-top: 34px; }
.recent-head { display: flex; align-items: baseline; justify-content: space-between; border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.recent h2 { font-size: 15px; margin: 0; font-weight: 600; }
#recentList { list-style: none; margin: 0; padding: 0; }
#recentList li { display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--line); }
#recentList li > button.open { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; border: 0; background: none; padding: 11px 2px; text-align: left; }
#recentList li > button.open:hover b { color: var(--accent); }
#recentList .rname { flex: 1; min-width: 0; }
#recentList b { display: block; font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#recentList small { color: var(--muted); font-size: 12.5px; }
#recentList .edits { color: var(--accent); }
.fine { color: var(--faint); font-size: 12.5px; margin-top: 28px; line-height: 1.55; }
.dropveil { position: fixed; inset: 0; background: rgba(36,87,214,.12); border: 3px dashed var(--accent); z-index: 200; display: grid; place-items: center; pointer-events: none; }
.dropveil div { background: var(--surface); padding: 12px 20px; border-radius: 10px; font-weight: 600; box-shadow: var(--pop-shadow); }

/* ---------- menus, dialogs, toasts ---------- */
.menu-layer { position: fixed; inset: 0; pointer-events: none; z-index: 120; }
.menu {
  position: fixed; min-width: 200px; max-width: min(340px, calc(100vw - 16px)); max-height: calc(100vh - 70px); overflow: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--pop-shadow);
  padding: 5px; pointer-events: auto;
}
.menu .mi {
  display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: none; text-align: left;
  padding: 7px 10px; border-radius: 6px; white-space: nowrap; color: var(--text);
}
.menu .mi svg { width: 18px; height: 18px; color: var(--muted); }
.menu .mi:hover, .menu .mi:focus-visible { background: var(--sunken); outline: none; }
.menu .mi .mt { flex: 1; }
.menu .mi small { color: var(--faint); font-size: 12px; }
.menu .mi.danger { color: var(--danger); }
.menu .mh { font-size: 12px; color: var(--faint); padding: 8px 10px 3px; }
.menu .msep { height: 1px; background: var(--line); margin: 5px 4px; }
.menu .mi.disabled { opacity: .45; pointer-events: none; }
.menu .sig-item img { height: 36px; max-width: 170px; object-fit: contain; }
:root[data-theme="dark"] .menu .sig-item img { filter: invert(1) hue-rotate(180deg); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .menu .sig-item img { filter: invert(1) hue-rotate(180deg); } }

.scrim { position: fixed; inset: 0; background: rgba(15,14,12,.42); z-index: 150; display: grid; place-items: center; padding: 16px; }
.dlg {
  width: min(520px, 100%); max-height: calc(100vh - 32px); overflow: auto; background: var(--surface); border-radius: 14px;
  box-shadow: var(--pop-shadow); display: flex; flex-direction: column;
}
.dlg.wide { width: min(720px, 100%); }
.dlg h3 { margin: 0; padding: 18px 20px 4px; font-size: 17px; font-weight: 650; }
.dlg .dbody { padding: 10px 20px 6px; }
.dlg .dbody p { margin: 0 0 10px; color: var(--muted); }
.dlg .dfoot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px 18px; flex-wrap: wrap; }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field > span { font-size: 12.5px; color: var(--muted); }
.field input[type=text], .field input[type=password], .field input[type=url], .field input[type=number], .field select, .field textarea {
  height: 36px; border: 1px solid var(--line-strong); border-radius: 8px; padding: 0 10px; background: var(--surface);
}
.field textarea { height: auto; padding: 8px 10px; min-height: 70px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > .field { flex: 1; min-width: 120px; }
.radio-row { display: flex; flex-wrap: wrap; gap: 6px; }
.pill {
  border: 1px solid var(--line-strong); background: var(--surface); border-radius: 99px; padding: 5px 12px; font-size: 13px;
}
.pill.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.check-line { display: flex; align-items: center; gap: 8px; margin: 6px 0; color: var(--text); }
.check-line input { accent-color: var(--accent); width: 16px; height: 16px; }
.kbd-grid { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 13.5px; }
kbd { font: 12px/1 ui-monospace, monospace; background: var(--sunken); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 3px 6px; white-space: nowrap; }
.props-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.props-table td { padding: 6px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.props-table td:first-child { color: var(--muted); width: 38%; padding-right: 10px; }

.sig-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 0 -20px 14px; padding: 0 20px; }
.sig-tabs button { border: 0; background: none; padding: 9px 12px; border-bottom: 2px solid transparent; color: var(--muted); font-weight: 550; }
.sig-tabs button.on { color: var(--text); border-bottom-color: var(--accent); }
.sig-pad { position: relative; border: 1px solid var(--line-strong); border-radius: 10px; background: #fff; height: 200px; touch-action: none; }
.sig-pad canvas { width: 100%; height: 100%; display: block; border-radius: 10px; cursor: crosshair; }
.sig-pad .baseline { position: absolute; left: 24px; right: 24px; bottom: 50px; border-bottom: 1px solid #d6d3cc; pointer-events: none; }
.sig-pad .hintx { position: absolute; left: 26px; bottom: 54px; color: #b2aea6; font-size: 18px; pointer-events: none; }
.sig-fonts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.sig-font { border: 1px solid var(--line); background: #fff; color: #1d1c1a; border-radius: 10px; height: 64px; font-size: 28px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; padding: 0 10px; }
.sig-font.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.sig-up { border: 1.5px dashed var(--line-strong); border-radius: 10px; height: 200px; display: grid; place-items: center; background: #fff; color: #6b6862; cursor: pointer; overflow: hidden; }
.sig-up img { max-width: 100%; max-height: 196px; }
.sig-colors { display: flex; align-items: center; gap: 8px; margin-top: 12px; flex-wrap: wrap; }

.toasts { position: fixed; left: 50%; bottom: 74px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; z-index: 300; pointer-events: none; }
.toast { background: #24231f; color: #f3f2ef; padding: 9px 14px; border-radius: 9px; font-size: 13.5px; box-shadow: 0 6px 20px rgba(0,0,0,.25); max-width: min(520px, calc(100vw - 32px)); pointer-events: auto; display: flex; gap: 12px; align-items: center; }
.toast.err { background: #8f2615; }
.toast button { border: 0; background: none; color: #9fbaff; font-weight: 600; padding: 0; }
.busy { position: fixed; inset: 0; background: rgba(15,14,12,.35); z-index: 250; display: grid; place-items: center; }
.busy-card { background: var(--surface); border-radius: 12px; padding: 18px 22px; box-shadow: var(--pop-shadow); min-width: 260px; max-width: calc(100vw - 32px); }
.busy-card .bmsg { font-weight: 550; }
.busy-card .bsub { color: var(--muted); font-size: 12.5px; margin-top: 3px; min-height: 1em; }
.bar { height: 4px; background: var(--sunken); border-radius: 4px; overflow: hidden; margin-top: 12px; }
.bar i { display: block; height: 100%; width: 30%; background: var(--accent); border-radius: 4px; animation: slide 1.1s ease-in-out infinite; }
.bar.det i { animation: none; transition: width .2s; }
@keyframes slide { 0% { transform: translateX(-100%); } 100% { transform: translateX(340%); } }

/* presentation */
.stage:fullscreen { background: #000; }
.stage:fullscreen .navpill, .stage:fullscreen .findbar { display: none; }
.stage:fullscreen .pdfViewer .page { box-shadow: none; margin: 0 auto !important; }
.stage:fullscreen .pdfViewer { padding: 0; }

/* ---------- small screens ---------- */
@media (max-width: 900px) {
  .modes button span { display: none; }
  .modes button { padding: 0 11px; }
  .tbtn span { display: none; }
  .tbtn { padding: 0 8px; }
  .strip-hint { display: none; }
}
@media (max-width: 640px) {
  .topbar { padding: 0 6px; gap: 4px; }
  .docname { display: none; }
  .modes { margin-right: auto; }
  .top-actions { flex: none; }
  #findBtn, #redoBtn { display: none; }
  .btn.primary span { display: none; }
  .btn.primary { padding: 0 9px; }
  .sidebar { position: absolute; inset: 0 auto 0 0; z-index: 22; box-shadow: var(--pop-shadow); width: 200px; }
  .land-actions { grid-template-columns: 1fr; }
  .land-inner { padding-top: 28px; }
  .drop { height: 170px; }
  .org-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); padding: 14px; gap: 14px 10px; }
  .pcard .pc-img { height: 140px; } .pcard canvas { max-height: 140px; }
  .findbar { left: 8px; right: 8px; top: 8px; }
  .findbar input#findInput { flex: 1; width: auto; min-width: 100px; }
  .navpill { bottom: 12px; }
}
body[data-mode="view"] .hit, .ov.capture .hit, body.tool-markup .hit { pointer-events: none !important; }
.obj.line.sel-line svg path:nth-child(2) { filter: drop-shadow(0 0 1.2px var(--accent)) drop-shadow(0 0 1.2px var(--accent)); }
.mkwrap { position: absolute; inset: 0; pointer-events: none; }
