:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f0f1f3;
  --line: #d9dce1;
  --line-2: #c3c7ce;
  --text: #1f2328;
  --muted: #5f6672;
  --accent: #1473e6;
  --accent-2: #0d66d0;
  --accent-soft: #e6f0fc;
  --danger: #d7373f;
  --ok: #2d9d78;
  --warn: #e68619;
  --brand: #e2141b;
  --radius: 8px;
  --shadow: 0 8px 30px rgba(20, 30, 50, .18);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --top-h: 48px;
  --tool-h: 44px;
  --left-w: 232px;
  --right-w: 320px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.4 var(--font); overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 12px; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
svg.i { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
svg.i.sm { width: 15px; height: 15px; }
svg.i.lg { width: 24px; height: 24px; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line-2); background: var(--surface); color: var(--text); padding: 6px 12px; border-radius: 6px; cursor: pointer; white-space: nowrap; line-height: 1.2; }
.btn:hover:not(:disabled) { background: var(--surface-2); border-color: #a9aeb7; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:hover:not(:disabled) { background: var(--accent-2); }
.btn.danger { color: var(--danger); border-color: #f0b4b7; }
.btn.danger:hover:not(:disabled) { background: #fdecec; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover:not(:disabled) { background: rgba(0, 0, 0, .06); border-color: transparent; }
.btn.sm { padding: 4px 8px; font-size: 13px; }
.btn.icon { padding: 6px; width: 32px; height: 32px; }
.btn.icon.sm { width: 28px; height: 28px; padding: 4px; }
.btn.active, .btn[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-2); }
.btn.block { width: 100%; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
.btn-row.right { justify-content: flex-end; }
.btn-row.split { justify-content: space-between; }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 6px; overflow: hidden; }
.seg .btn { border: 0; border-radius: 0; }
.seg .btn + .btn { border-left: 1px solid var(--line-2); }

/* inputs */
.field { display: grid; gap: 4px; }
.field label, label.lbl { font-size: 12px; color: var(--muted); font-weight: 600; letter-spacing: .01em; }
.input, select.input, textarea.input { border: 1px solid var(--line-2); border-radius: 6px; padding: 6px 8px; background: #fff; width: 100%; min-width: 0; }
.input:focus, select.input:focus, textarea.input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
textarea.input { resize: vertical; min-height: 70px; font-family: inherit; }
.input.sm { padding: 3px 6px; font-size: 13px; }
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.check input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.color-input { width: 32px; height: 28px; padding: 0 2px; border: 1px solid var(--line-2); border-radius: 6px; background: #fff; cursor: pointer; }
.range { width: 100%; accent-color: var(--accent); }
.hint { font-size: 12px; color: var(--muted); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 13px; }
.kv b { font-weight: 500; color: var(--muted); }
.notice { padding: 8px 10px; border-radius: 6px; font-size: 13px; background: var(--accent-soft); color: #0b4a97; }
.notice.warn { background: #fff4e5; color: #8a4b00; }
.notice.error { background: #fdecec; color: #9b1c22; }
.notice.ok { background: #e7f7f0; color: #0f5e42; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); font-size: 12px; color: var(--muted); }

/* layout */
#app { display: grid; grid-template-rows: var(--top-h) 1fr; height: 100vh; }
.top { display: flex; align-items: center; gap: 10px; padding: 0 12px; background: #fff; border-bottom: 1px solid var(--line); z-index: 20; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; letter-spacing: -.01em; cursor: pointer; user-select: none; }
.brand .logo { width: 26px; height: 26px; border-radius: 6px; background: var(--brand); color: #fff; display: grid; place-items: center; font-size: 11px; font-weight: 800; }
.brand .muted { font-weight: 400; font-size: 12px; }
.top .tabs { display: flex; gap: 2px; margin-left: 10px; }
.top .tabs .tab { padding: 6px 12px; border-radius: 6px; cursor: pointer; border: 0; background: transparent; color: var(--muted); font-weight: 600; }
.top .tabs .tab.active { background: var(--surface-2); color: var(--text); }
.top .spacer { flex: 1; }
.menubar { display: flex; gap: 2px; }
.menubar .menu-btn { padding: 6px 10px; border: 0; background: transparent; border-radius: 6px; cursor: pointer; }
.menubar .menu-btn:hover, .menubar .menu-btn.open { background: var(--surface-2); }
.docname { display: flex; align-items: center; gap: 6px; min-width: 0; max-width: 420px; }
.docname input { border: 1px solid transparent; background: transparent; padding: 4px 6px; border-radius: 6px; font-weight: 600; min-width: 80px; width: 100%; }
.docname input:hover { border-color: var(--line); }
.docname input:focus { border-color: var(--accent); background: #fff; outline: 0; }
.dirty { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); display: none; }
.dirty.on { display: inline-block; }
.user { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.user img { width: 28px; height: 28px; border-radius: 50%; }
.user .avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 12px; }

/* dropdown menus */
.menu { position: fixed; z-index: 100; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); padding: 6px; min-width: 220px; max-height: 70vh; overflow: auto; }
.menu .item { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 6px; cursor: pointer; border: 0; background: transparent; width: 100%; text-align: left; }
.menu .item:hover { background: var(--surface-2); }
.menu .item.disabled { opacity: .45; pointer-events: none; }
.menu .item .k { margin-left: auto; color: var(--muted); font-size: 12px; }
.menu .sep { height: 1px; background: var(--line); margin: 5px 4px; }
.menu .head { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 6px 10px 2px; }

/* ===== HOME ===== */
#home { overflow: auto; height: calc(100vh - var(--top-h)); }
.home-wrap { max-width: 1180px; margin: 0 auto; padding: 24px 20px 60px; display: grid; gap: 24px; }
.home-hero { display: grid; grid-template-columns: 1.3fr 1fr; gap: 16px; }
.drop { border: 2px dashed var(--line-2); border-radius: 12px; background: #fff; padding: 26px; text-align: center; display: grid; gap: 8px; justify-items: center; cursor: pointer; transition: border-color .15s, background .15s; }
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop h2 { margin: 0; font-size: 18px; }
.quick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.quick .qa { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 14px; background: #fff; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; text-align: left; }
.quick .qa:hover { border-color: var(--accent); box-shadow: 0 2px 10px rgba(20, 115, 230, .12); }
.quick .qa b { font-size: 14px; }
.quick .qa span { font-size: 12px; color: var(--muted); }
.quick .qa svg { color: var(--accent); }
.section-head { display: flex; align-items: center; gap: 12px; }
.section-head h2 { margin: 0; font-size: 17px; }
.section-head .spacer { flex: 1; }
.section-head .search { max-width: 260px; }
.doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.doc-card { background: #fff; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; cursor: pointer; display: grid; grid-template-rows: 150px auto; transition: box-shadow .15s, border-color .15s; position: relative; }
.doc-card:hover { border-color: var(--accent); box-shadow: 0 4px 14px rgba(20, 30, 50, .12); }
.doc-card.selected { outline: 2px solid var(--accent); }
.doc-card .thumb { background: var(--surface-2); display: grid; place-items: center; overflow: hidden; border-bottom: 1px solid var(--line); }
.doc-card .thumb img { max-width: 100%; max-height: 100%; box-shadow: 0 1px 4px rgba(0, 0, 0, .2); background: #fff; }
.doc-card .meta { padding: 10px 12px; display: grid; gap: 2px; }
.doc-card .name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-card .sub { font-size: 12px; color: var(--muted); }
.doc-card .more { position: absolute; top: 6px; right: 6px; opacity: 0; background: #fff; }
.doc-card:hover .more { opacity: 1; }
.doc-list { display: grid; gap: 4px; }
.doc-row { display: grid; grid-template-columns: 44px 1fr 90px 90px 150px 40px; align-items: center; gap: 10px; padding: 6px 10px; background: #fff; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
.doc-row:hover { border-color: var(--accent); }
.doc-row img { width: 36px; height: 44px; object-fit: contain; background: var(--surface-2); border: 1px solid var(--line); }
.doc-row .name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-row .sub { font-size: 12px; color: var(--muted); }
.tools-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
.tool-card { display: flex; align-items: center; gap: 10px; padding: 12px; background: #fff; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; text-align: left; }
.tool-card:hover { border-color: var(--accent); background: var(--accent-soft); }
.tool-card .ic { width: 36px; height: 36px; border-radius: 8px; display: grid; place-items: center; background: var(--surface-2); color: var(--accent); flex: none; }
.tool-card b { display: block; font-size: 13px; }
.tool-card span { font-size: 11px; color: var(--muted); }
.empty { padding: 40px; text-align: center; color: var(--muted); background: #fff; border: 1px dashed var(--line-2); border-radius: 10px; }

/* ===== EDITOR ===== */
#editor { display: grid; grid-template-rows: var(--tool-h) 1fr; height: calc(100vh - var(--top-h)); min-height: 0; }
.toolbar { display: flex; align-items: center; gap: 4px; padding: 0 8px; background: #fff; border-bottom: 1px solid var(--line); overflow: hidden; }
.toolbar .sep { width: 1px; height: 24px; background: var(--line); margin: 0 6px; flex: none; }
.toolbar .spacer { flex: 1; }
.toolbar .zoom-val { width: 58px; text-align: center; border: 1px solid transparent; border-radius: 6px; padding: 4px 0; background: transparent; }
.toolbar .zoom-val:hover { border-color: var(--line); }
.toolbar .page-nav { display: flex; align-items: center; gap: 4px; }
.toolbar .page-nav input { width: 44px; text-align: center; padding: 4px; border: 1px solid var(--line-2); border-radius: 6px; }
.toolbar .find { display: flex; align-items: center; gap: 4px; }
.toolbar .find input { width: 180px; padding: 5px 8px; border: 1px solid var(--line-2); border-radius: 6px; }
.toolbar .find .count { font-size: 12px; color: var(--muted); min-width: 60px; text-align: center; }
.workspace { display: grid; grid-template-columns: var(--left-w) 1fr var(--right-w); min-height: 0; height: 100%; }
.workspace.no-left { grid-template-columns: 0 1fr var(--right-w); }
.workspace.no-right { grid-template-columns: var(--left-w) 1fr 0; }
.workspace.no-left.no-right { grid-template-columns: 0 1fr 0; }
.pane { background: #fff; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.pane.left { border-right: 1px solid var(--line); }
.pane.right { border-left: 1px solid var(--line); }
.pane-tabs { display: flex; border-bottom: 1px solid var(--line); flex: none; overflow-x: auto; }
.pane-tabs button { flex: 1; padding: 8px 4px; border: 0; background: transparent; cursor: pointer; color: var(--muted); display: grid; place-items: center; gap: 2px; font-size: 10px; min-width: 44px; }
.pane-tabs button.active { color: var(--accent); box-shadow: inset 0 -2px 0 var(--accent); }
.pane-body { overflow: auto; flex: 1; padding: 10px; display: grid; gap: 10px; align-content: start; }
.pane-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); font-weight: 700; flex: none; }
.pane-head .spacer { flex: 1; }

/* thumbnails */
.thumbs { display: grid; gap: 10px; }
.thumb-item { display: grid; justify-items: center; gap: 4px; padding: 6px; border-radius: 8px; cursor: pointer; border: 2px solid transparent; }
.thumb-item:hover { background: var(--surface-2); }
.thumb-item.current { border-color: var(--accent); background: var(--accent-soft); }
.thumb-item.selected { border-color: var(--accent); }
.thumb-item img { max-width: 100%; box-shadow: 0 1px 4px rgba(0, 0, 0, .25); background: #fff; }
.thumb-item .n { font-size: 11px; color: var(--muted); }
.thumb-item.dragging { opacity: .4; }
.thumb-item.drop-before { box-shadow: -3px 0 0 var(--accent); }
.thumb-item.drop-after { box-shadow: 3px 0 0 var(--accent); }

/* bookmarks / comments / fields lists */
.tree { display: grid; gap: 2px; }
.tree .node { display: flex; align-items: center; gap: 6px; padding: 5px 8px; border-radius: 6px; cursor: pointer; }
.tree .node:hover { background: var(--surface-2); }
.tree .node .pg { margin-left: auto; font-size: 11px; color: var(--muted); }
.list { display: grid; gap: 6px; }
.list .row { display: grid; gap: 4px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; background: #fff; }
.list .row:hover { border-color: var(--accent); }
.list .row.active { border-color: var(--accent); background: var(--accent-soft); }
.list .row .t { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.list .row .t b { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list .row .s { font-size: 12px; color: var(--muted); white-space: pre-wrap; }
.swatch { width: 12px; height: 12px; border-radius: 3px; border: 1px solid rgba(0, 0, 0, .2); flex: none; }

/* center viewer */
.center { position: relative; min-width: 0; min-height: 0; display: flex; flex-direction: column; background: #e9eaed; }
.viewer { flex: 1; overflow: auto; position: relative; padding: 24px 0 60px; scroll-behavior: auto; }
.viewer.grab { cursor: grab; }
.viewer.grabbing { cursor: grabbing; user-select: none; }
.pages { display: flex; flex-direction: column; align-items: center; gap: 18px; min-width: min-content; padding: 0 24px; }
.page { position: relative; background: #fff; box-shadow: 0 2px 12px rgba(0, 0, 0, .22); flex: none; overflow: visible; contain: layout; }
.page canvas.pg { display: block; position: absolute; left: 0; top: 0; width: 100%; height: 100%; }
.page .pending-render { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 12px; }
.page .textLayer, .page .layer { position: absolute; inset: 0; }
.page .layer { pointer-events: none; }
.page .layer > * { pointer-events: auto; }
.page .overlay { z-index: 4; }
.page .formLayer { z-index: 3; }
.page .editLayer { z-index: 5; }
.page .annotLayer { z-index: 2; }
.page .textLayer { z-index: 1; }
.page .hitLayer { position: absolute; inset: 0; z-index: 6; cursor: crosshair; display: none; }
.page.tool-draw .hitLayer { display: block; }
.page .page-num { position: absolute; left: 0; right: 0; top: 100%; text-align: center; font-size: 11px; color: var(--muted); padding-top: 3px; user-select: none; pointer-events: none; }

/* pdf.js text layer */
.textLayer { color-scheme: only light; position: absolute; text-align: initial; inset: 0; overflow: clip; opacity: 1; line-height: 1; letter-spacing: normal; word-spacing: normal; text-size-adjust: none; forced-color-adjust: none; transform-origin: 0 0; caret-color: CanvasText; --min-font-size: 1; --text-scale-factor: calc(var(--total-scale-factor) * var(--min-font-size)); --min-font-size-inv: calc(1 / var(--min-font-size)); }
.textLayer :is(span, br) { color: transparent; position: absolute; white-space: pre; cursor: text; transform-origin: 0% 0%; user-select: text; }
.textLayer > :not(.markedContent), .textLayer .markedContent span:not(.markedContent) { z-index: 1; --font-height: 0; font-size: calc(var(--text-scale-factor) * var(--font-height)); --scale-x: 1; --rotate: 0deg; transform: rotate(var(--rotate)) scaleX(var(--scale-x)) scale(var(--min-font-size-inv)); }
.textLayer .markedContent { display: contents; }
.textLayer span[role="img"] { user-select: none; cursor: default; }
.textLayer ::selection { background: rgba(20, 115, 230, .3); color: transparent; }
.textLayer br::selection { background: transparent; }
.textLayer .endOfContent { display: block; position: absolute; inset: 100% 0 0; z-index: 0; cursor: default; user-select: none; }
.textLayer.selecting .endOfContent { top: 0; }
.tool-select .textLayer, .tool-highlight .textLayer, .tool-underline .textLayer, .tool-strikeout .textLayer, .tool-squiggly .textLayer { pointer-events: auto; }
.page .textLayer { pointer-events: none; }
.page.sel-text .textLayer { pointer-events: auto; }

/* find highlights */
.find-hit { position: absolute; background: rgba(255, 200, 0, .45); border-radius: 2px; pointer-events: none; }
.find-hit.current { background: rgba(255, 120, 0, .6); outline: 1px solid #e67e00; }

/* annotation hit boxes (existing annots) */
.annot-box { position: absolute; border: 1px solid transparent; cursor: pointer; }
.annot-box:hover { border-color: rgba(20, 115, 230, .6); background: rgba(20, 115, 230, .06); }
.annot-box.selected { border: 1px solid var(--accent); box-shadow: 0 0 0 2px rgba(20, 115, 230, .25); }
.img-box { position: absolute; border: 1px dashed transparent; cursor: move; }
.page.tool-edit .img-box { border-color: rgba(20, 115, 230, .45); }
.img-box:hover, .img-box.selected { border: 1px solid var(--accent); }

/* form fields overlay */
.fld { position: absolute; font: inherit; border: 1px solid rgba(20, 115, 230, .45); background: rgba(221, 236, 255, .55); padding: 0 3px; border-radius: 1px; color: #000; }
.fld:focus { outline: 2px solid var(--accent); background: #fff; }
.fld.fld-text { resize: none; overflow: hidden; }
.fld.fld-check { padding: 0; margin: 0; accent-color: #000; background: transparent; appearance: auto; }
.fld.fld-sig { cursor: pointer; display: grid; place-items: center; color: var(--accent-2); font-size: 12px; background: rgba(255, 240, 200, .5); border: 1px dashed #d19b00; }
.fld.fld-btn { cursor: default; background: #eee; border: 1px solid #bbb; display: grid; place-items: center; }
.fld.selected { outline: 2px solid var(--accent); }
.page.tool-form .fld { cursor: move; }
.page.tool-form .fld.fld-check, .page.tool-form .fld.fld-text { pointer-events: auto; }

/* pending objects */
.pobj { position: absolute; cursor: move; user-select: none; }
.pobj.selected { outline: 1px solid var(--accent); }
.pobj svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.pobj .txt { position: absolute; inset: 0; white-space: pre-wrap; word-break: break-word; overflow: hidden; line-height: 1.2; padding: 0; outline: 0; }
.pobj .txt[contenteditable="true"] { cursor: text; outline: 1px dashed var(--accent); background: rgba(255, 255, 255, .6); }
.pobj img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: fill; pointer-events: none; }
.pobj.note-icon { display: grid; place-items: center; }
.handle { position: absolute; width: 9px; height: 9px; background: #fff; border: 1.5px solid var(--accent); border-radius: 2px; z-index: 7; }
.handle.nw { left: -5px; top: -5px; cursor: nwse-resize; }
.handle.ne { right: -5px; top: -5px; cursor: nesw-resize; }
.handle.sw { left: -5px; bottom: -5px; cursor: nesw-resize; }
.handle.se { right: -5px; bottom: -5px; cursor: nwse-resize; }
.handle.n { left: calc(50% - 4.5px); top: -5px; cursor: ns-resize; }
.handle.s { left: calc(50% - 4.5px); bottom: -5px; cursor: ns-resize; }
.handle.e { right: -5px; top: calc(50% - 4.5px); cursor: ew-resize; }
.handle.w { left: -5px; top: calc(50% - 4.5px); cursor: ew-resize; }
.rubber { position: absolute; border: 1px dashed var(--accent); background: rgba(20, 115, 230, .08); pointer-events: none; }
.ink-live { position: absolute; inset: 0; pointer-events: none; overflow: visible; }

/* text edit mode */
.tblock { position: absolute; border: 1px solid transparent; cursor: text; }
.page.tool-edit .tblock { border-color: rgba(20, 115, 230, .35); }
.tblock:hover { border-color: var(--accent); background: rgba(20, 115, 230, .04); }
.tblock.editing { border: 1px solid var(--accent); background: #fff; outline: 0; white-space: pre-wrap; overflow: visible; z-index: 8; box-shadow: 0 0 0 2px rgba(20, 115, 230, .2); }
.tblock.edited { background: #fff; border-color: rgba(230, 134, 25, .7); white-space: pre-wrap; }
.tblock.deleted { background: #fff; border-color: rgba(215, 55, 63, .7); }
.tblock .ln { position: absolute; left: 0; white-space: pre; }
.tblock.moved { background: #fff; border-color: rgba(230, 134, 25, .7); white-space: pre-wrap; }
.tblock.moving { opacity: .9; box-shadow: 0 3px 10px rgba(0, 0, 0, .25); cursor: move; z-index: 9; }
.tblock-ghost { position: absolute; background: #fff; border: 1px dashed rgba(215, 55, 63, .55); pointer-events: none; }
/* move grip (top-left corner); the block's border also drags */
.tblock .mv { position: absolute; left: -8px; top: -8px; width: 16px; height: 16px; border-radius: 4px; background: var(--accent); color: #fff; display: none; align-items: center; justify-content: center; cursor: move; z-index: 9; user-select: none; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); }
.tblock .mv svg { width: 11px; height: 11px; }
.page.tool-edit .tblock:hover .mv, .tblock.editing .mv, .tblock.moved .mv, .tblock.selected .mv { display: flex; }

/* organize pages grid */
.organize { position: absolute; inset: 0; background: #e9eaed; overflow: auto; padding: 16px; z-index: 9; }
.organize .org-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.org-page { background: #fff; border: 2px solid transparent; border-radius: 8px; padding: 8px; display: grid; justify-items: center; gap: 6px; cursor: pointer; position: relative; user-select: none; }
.org-page:hover { border-color: var(--line-2); }
.org-page.selected { border-color: var(--accent); background: var(--accent-soft); }
.org-page img { max-width: 100%; max-height: 180px; box-shadow: 0 1px 4px rgba(0, 0, 0, .25); }
.org-page .n { font-size: 12px; color: var(--muted); }
.org-page .ins { position: absolute; top: 50%; right: -9px; width: 18px; height: 18px; border-radius: 50%; background: var(--accent); color: #fff; display: none; place-items: center; font-size: 14px; line-height: 1; z-index: 2; }
.org-page:hover .ins { display: grid; }
.org-page.drop-before { box-shadow: -4px 0 0 var(--accent); }
.org-page.drop-after { box-shadow: 4px 0 0 var(--accent); }
.org-bar { position: sticky; top: 0; z-index: 3; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; background: #fff; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 14px; }
.org-bar .sel-info { font-size: 12px; color: var(--muted); margin-left: auto; }

/* right pane tools */
.tool-list { display: grid; gap: 2px; }
.tool-list button { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 0; background: transparent; border-radius: 8px; cursor: pointer; text-align: left; width: 100%; }
.tool-list button:hover { background: var(--surface-2); }
.tool-list button.active { background: var(--accent-soft); color: var(--accent-2); }
.tool-list button .ic { width: 30px; height: 30px; border-radius: 7px; display: grid; place-items: center; background: var(--surface-2); color: var(--accent); flex: none; }
.tool-list button b { display: block; font-size: 13px; font-weight: 600; }
.tool-list button span { font-size: 11px; color: var(--muted); }
.tool-list .group { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 10px 10px 2px; }
.tool-panel { display: grid; gap: 12px; }
.tool-panel h3 { margin: 0; font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.subtools { display: flex; flex-wrap: wrap; gap: 4px; }
.subtools .btn { padding: 6px; }
.subtool-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.subtool-grid .btn { flex-direction: column; gap: 2px; font-size: 10px; padding: 6px 2px; height: auto; }
.props { display: grid; gap: 8px; padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); }
.props .row2 { display: flex; align-items: center; gap: 8px; }
.props .row2 label { font-size: 12px; color: var(--muted); min-width: 60px; }
.sig-list { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sig-item { border: 1px solid var(--line); border-radius: 8px; padding: 6px; background: #fff; display: grid; gap: 4px; justify-items: center; cursor: pointer; position: relative; }
.sig-item:hover { border-color: var(--accent); }
.sig-item img { max-width: 100%; max-height: 50px; }
.sig-item .del { position: absolute; top: 2px; right: 2px; }
.sigpad { border: 1px solid var(--line-2); border-radius: 8px; background: #fff; width: 100%; height: 130px; touch-action: none; cursor: crosshair; }
.combine-list { display: grid; gap: 6px; }
.combine-item { display: grid; grid-template-columns: 24px 40px 1fr auto; align-items: center; gap: 8px; padding: 6px; border: 1px solid var(--line); border-radius: 8px; background: #fff; cursor: grab; }
.combine-item img { width: 40px; height: 48px; object-fit: contain; background: var(--surface-2); }
.combine-item .nm { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.combine-item input { width: 70px; }
.combine-item.dragging { opacity: .4; }
.stamp-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.stamp-grid .btn { font-size: 11px; padding: 5px 4px; }
.sizes { display: flex; flex-wrap: wrap; gap: 4px; }
.sizes .btn { font-size: 12px; padding: 4px 8px; }
.result-box { padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; font-size: 13px; display: grid; gap: 6px; }
.diff { font-size: 13px; line-height: 1.5; }
.diff del { background: #fdd; text-decoration: line-through; }
.diff ins { background: #dfd; text-decoration: none; }
.versions .row { cursor: pointer; }

/* status bar */
.statusbar { display: flex; align-items: center; gap: 12px; padding: 3px 12px; background: #fff; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); min-height: 24px; }
.statusbar .spacer { flex: 1; }

/* dialogs */
.modal-back { position: fixed; inset: 0; background: rgba(15, 20, 30, .45); z-index: 200; display: grid; place-items: center; padding: 20px; }
.modal { background: #fff; border-radius: 12px; box-shadow: var(--shadow); width: min(560px, 100%); max-height: 90vh; overflow: auto; display: grid; grid-template-rows: auto 1fr auto; }
.modal.wide { width: min(900px, 100%); }
.modal header { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); font-weight: 700; font-size: 16px; }
.modal header .spacer { flex: 1; }
.modal .body { padding: 16px 18px; display: grid; gap: 12px; overflow: auto; }
.modal footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); }

/* toasts */
.toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 300; }
.toast { background: #1f2328; color: #fff; padding: 10px 14px; border-radius: 8px; box-shadow: var(--shadow); max-width: 380px; font-size: 13px; display: flex; gap: 10px; align-items: center; }
.toast.error { background: var(--danger); }
.toast.ok { background: var(--ok); }
.toast .spin { width: 14px; height: 14px; border: 2px solid rgba(255, 255, 255, .4); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.busy { position: fixed; inset: 0; z-index: 250; background: rgba(255, 255, 255, .55); display: grid; place-items: center; }
.busy .box { background: #fff; padding: 18px 24px; border-radius: 10px; box-shadow: var(--shadow); display: flex; align-items: center; gap: 12px; font-weight: 600; }
.busy .spin { width: 22px; height: 22px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }

/* popover (annotation properties) */
.popover { position: absolute; z-index: 60; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); padding: 10px; display: grid; gap: 8px; width: 260px; font-size: 13px; }
.popover textarea { min-height: 54px; }

/* login */
.login-body { display: grid; place-items: center; background: var(--bg); overflow: auto; }
.login { padding: 24px; }
.login-card { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 32px; max-width: 420px; text-align: center; display: grid; gap: 14px; justify-items: center; box-shadow: var(--shadow); }
.login-card h1 { margin: 0; font-size: 24px; }
.login-card .logo { width: 64px; height: 64px; border-radius: 14px; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 22px; }
.login-status { margin: 0; color: var(--muted); }
.login-status.error { color: var(--danger); }
.gsi { min-height: 44px; }

/* cookie notice */
.consent { position: fixed; left: 16px; right: 16px; bottom: 16px; z-index: 400; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; box-shadow: var(--shadow); max-width: 900px; margin: 0 auto; }
.consent p { margin: 0; font-size: 13px; color: var(--muted); flex: 1 1 380px; }
.consent-actions { display: flex; gap: 8px; }

@media (max-width: 1000px) {
  :root { --right-w: 280px; --left-w: 170px; }
  .home-hero { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .workspace { grid-template-columns: 0 1fr 0 !important; }
  .pane.left, .pane.right { display: none; }
  .toolbar .find input { width: 110px; }
  .menubar { display: none; }
}
@media print { body { overflow: visible; } }
