/* Layout: app chrome (top bar, tool rail, property strip) over a three-column workspace: page sidebar, viewer, tools dock. */
:root {
  --bg: #eceeed; --panel: #fbfcfb; --panel-2: #f3f5f4; --line: #d6dcd9; --line-2: #c3cbc7;
  --fg: #17201c; --muted: #5b6863; --accent: #1d6b58; --accent-2: #e2efea; --accent-fg: #ffffff;
  --canvas: #d9dedb; --danger: #b3261e; --danger-2: #fbe9e7; --sel: #1d7f68; --warn: #9a6400;
  --shadow: 0 1px 2px rgba(20,32,27,.08), 0 4px 16px rgba(20,32,27,.06);
  --page-shadow: 0 1px 3px rgba(20,32,27,.18), 0 6px 22px rgba(20,32,27,.10);
  --f-ui: "Instrument Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  --f-brand: "Instrument Serif", Georgia, "Times New Roman", serif;
  --f-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --r: 8px;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #111614; --panel: #181e1c; --panel-2: #1e2523; --line: #2b3431; --line-2: #3a4541;
  --fg: #e4ebe8; --muted: #93a19b; --accent: #5cc0a3; --accent-2: #1d3530; --accent-fg: #0b1512;
  --canvas: #0c100f; --danger: #f2867c; --danger-2: #3a1d1a; --sel: #5cc0a3; --warn: #e2b350;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 16px rgba(0,0,0,.3); --page-shadow: 0 1px 3px rgba(0,0,0,.5), 0 6px 24px rgba(0,0,0,.45);
  color-scheme: dark;
} }
:root[data-theme="dark"] {
  --bg: #111614; --panel: #181e1c; --panel-2: #1e2523; --line: #2b3431; --line-2: #3a4541;
  --fg: #e4ebe8; --muted: #93a19b; --accent: #5cc0a3; --accent-2: #1d3530; --accent-fg: #0b1512;
  --canvas: #0c100f; --danger: #f2867c; --danger-2: #3a1d1a; --sel: #5cc0a3; --warn: #e2b350;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 16px rgba(0,0,0,.3); --page-shadow: 0 1px 3px rgba(0,0,0,.5), 0 6px 24px rgba(0,0,0,.45);
  color-scheme: dark;
}
html, body { height: 100%; }
body { background: var(--bg); color: var(--fg); font-family: var(--f-ui); font-size: 14px; overflow: hidden; }
* { box-sizing: border-box; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--muted); }
[data-i] { display: inline-flex; width: 18px; height: 18px; flex: none; }
[data-i] svg { width: 100%; height: 100%; }

.app { height: 100%; display: grid; grid-template-rows: auto auto auto minmax(0,1fr) auto; }

/* top bar */
.topbar { display: flex; align-items: center; gap: 12px; padding: 8px 12px; background: var(--panel); border-bottom: 1px solid var(--line); min-width: 0; }
.brand { display: flex; align-items: center; gap: 6px; color: var(--accent); flex: none; }
.brand svg { width: 26px; height: 26px; }
.wordmark { font-family: var(--f-brand); font-size: 26px; line-height: 1; color: var(--fg); letter-spacing: .01em; white-space: nowrap; }
.filebox { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1; }
.filename { border: 1px solid transparent; background: transparent; padding: 5px 8px; border-radius: 6px; font-weight: 600; min-width: 60px; width: 100%; max-width: 340px; text-overflow: ellipsis; }
.filename:hover { border-color: var(--line); }
.filename:focus { border-color: var(--accent); background: var(--panel-2); outline: none; }
.dirty { font-size: 12px; color: var(--muted); white-space: nowrap; }
.top-actions { display: flex; align-items: center; gap: 6px; flex: none; min-width: 0; }
.topbar { overflow: hidden; }
.sep { width: 1px; height: 22px; background: var(--line); margin: 0 2px; }
.btn { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border-radius: var(--r); border: 1px solid var(--line); background: var(--panel); cursor: pointer; font-weight: 500; white-space: nowrap; }
.btn:hover { background: var(--panel-2); border-color: var(--line-2); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--panel-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-2); }
.btn.small { height: 30px; padding: 0 10px; font-size: 13px; }
.btn:disabled, .icon-btn:disabled { opacity: .45; cursor: default; }
.icon-btn { width: 34px; height: 34px; display: inline-grid; place-items: center; border-radius: var(--r); border: 0; background: transparent; cursor: pointer; color: var(--fg); }
.icon-btn:hover { background: var(--panel-2); }
.icon-btn.sm { width: 26px; height: 26px; }
.zoom { display: flex; align-items: center; gap: 2px; }
.zoom select { height: 30px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); padding: 0 6px; font-family: var(--f-mono); font-size: 12px; font-variant-numeric: tabular-nums; }

/* tool rail */
.toolbar { display: flex; align-items: center; gap: 2px; padding: 5px 10px; background: var(--panel); border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: thin; }
.tgroup { display: flex; gap: 2px; padding: 0 6px; border-right: 1px solid var(--line); flex: none; }
.tgroup:last-child { border-right: 0; }
.tool { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-width: 52px; height: 48px; padding: 2px 6px; border: 0; border-radius: var(--r); background: transparent; cursor: pointer; color: var(--fg); flex: none; }
.tool span { font-size: 11px; color: var(--muted); white-space: nowrap; }
.tool:hover { background: var(--panel-2); }
.tool.active { background: var(--accent-2); color: var(--accent); }
.tool.active span { color: var(--accent); font-weight: 600; }
.tool [data-i] { width: 20px; height: 20px; }

/* property strip */
.propbar { display: flex; align-items: center; gap: 10px; min-height: 42px; padding: 5px 14px; background: var(--panel-2); border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: thin; }
.propbar .lbl { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; white-space: nowrap; }
.prop { display: flex; align-items: center; gap: 6px; flex: none; }
.prop select, .prop input[type=number], .prop input[type=text] { height: 30px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); padding: 0 6px; }
.prop input[type=number] { width: 64px; font-family: var(--f-mono); font-variant-numeric: tabular-nums; }
.prop input[type=range] { width: 90px; accent-color: var(--accent); }
.prop .val { font-family: var(--f-mono); font-size: 12px; min-width: 34px; color: var(--muted); font-variant-numeric: tabular-nums; }
.swatches { display: flex; gap: 4px; align-items: center; }
.sw { width: 20px; height: 20px; border-radius: 50%; border: 1px solid rgba(0,0,0,.18); cursor: pointer; padding: 0; position: relative; }
.sw.on { outline: 2px solid var(--accent); outline-offset: 2px; }
.sw.none { background: linear-gradient(135deg, #fff 45%, #d33 45%, #d33 55%, #fff 55%) !important; }
.sw-custom { width: 24px; height: 24px; border: 1px solid var(--line); border-radius: 6px; padding: 0; background: none; cursor: pointer; }
.toggle { height: 30px; min-width: 30px; padding: 0 7px; border: 1px solid var(--line); background: var(--panel); border-radius: 6px; cursor: pointer; font-weight: 600; }
.toggle.on { background: var(--accent-2); border-color: var(--accent); color: var(--accent); }
.prop-hint { color: var(--muted); font-size: 13px; white-space: nowrap; }
.prop-hint b { color: var(--fg); }

/* workspace */
.main { position: relative; display: grid; grid-template-columns: auto minmax(0,1fr) auto; min-height: 0; }
.side { width: 230px; background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.app.side-hidden .side { display: none; }
.tabs { display: grid; grid-template-columns: repeat(5, 1fr); border-bottom: 1px solid var(--line); }
.tab { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 7px 0 6px; border: 0; background: transparent; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; }
.tab span { font-size: 10.5px; }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.panel { flex: 1; overflow: auto; min-height: 0; padding: 10px; }
.side-toggle { position: absolute; left: 8px; bottom: 10px; z-index: 6; width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line); background: var(--panel); box-shadow: var(--shadow); cursor: pointer; display: grid; place-items: center; color: var(--fg); }

.thumbs { display: flex; flex-direction: column; gap: 12px; align-items: center; }
.thumb { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; cursor: pointer; padding: 6px; border-radius: var(--r); border: 2px solid transparent; user-select: none; touch-action: none; }
.thumb:hover { background: var(--panel-2); }
.thumb.current { border-color: var(--line-2); }
.thumb.selected { border-color: var(--accent); background: var(--accent-2); }
.thumb .tcanvas { background: #fff; box-shadow: var(--page-shadow); display: block; }
.thumb .tnum { font-family: var(--f-mono); font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.thumb .badge { position: absolute; top: 10px; right: 10px; background: var(--accent); color: var(--accent-fg); font-size: 10px; font-weight: 700; padding: 1px 5px; border-radius: 8px; }
.thumb .tacts { position: absolute; top: 8px; left: 50%; transform: translateX(-50%); display: none; gap: 2px; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 2px; box-shadow: var(--shadow); }
.thumb:hover .tacts, .thumb:focus-within .tacts { display: flex; }
.tacts button { width: 26px; height: 26px; border: 0; background: transparent; border-radius: 4px; cursor: pointer; display: grid; place-items: center; color: var(--fg); }
.tacts button:hover { background: var(--panel-2); }
.tacts button.del:hover { color: var(--danger); }
.drop-marker { position: absolute; background: var(--accent); border-radius: 2px; z-index: 5; pointer-events: none; }
.drag-ghost { position: fixed; z-index: 100; pointer-events: none; opacity: .85; transform: rotate(-3deg); box-shadow: var(--page-shadow); background: #fff; }

/* viewer */
.viewer { position: relative; overflow: auto; background: var(--canvas); min-height: 0; outline: none; }
.pages { display: flex; flex-direction: column; align-items: center; gap: 18px; padding: 22px 16px 60px; min-width: min-content; }
.page { position: relative; background: #fff; box-shadow: var(--page-shadow); flex: none; }
.page canvas.pc { position: absolute; inset: 0; width: 100%; height: 100%; }
.page .plabel { position: absolute; bottom: -17px; left: 0; right: 0; text-align: center; font-family: var(--f-mono); font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.ov { position: absolute; inset: 0; overflow: hidden; }
.app[data-tool]:not([data-tool="select"]) .ov { cursor: crosshair; }
.app[data-tool="text"] .ov { cursor: text; }
.app[data-tool="edittext"] .ov { cursor: default; }
.tlayer { position: absolute; inset: 0; }
.tline { position: absolute; border-radius: 2px; cursor: text; }
.tline:hover { background: rgba(29,107,88,.12); outline: 1px dashed rgba(29,107,88,.7); }
.obj { position: absolute; }
.obj.textobj { white-space: pre; line-height: 1.2; transform-origin: center; cursor: move; min-width: 4px; }
.obj.textobj[contenteditable] { cursor: text; outline: 1.5px dashed var(--sel); outline-offset: 2px; background-clip: padding-box; }
.obj.textobj:empty::before { content: "Type here"; color: #9aa; }
.obj.box { cursor: move; }
.obj.hl { mix-blend-mode: multiply; }
.obj.redact { background: #000; }
.obj.redact::after { content: "REDACT"; position: absolute; inset: 0; display: grid; place-items: center; color: #ff6a5c; font: 700 9px/1 var(--f-mono); letter-spacing: .12em; opacity: .9; overflow: hidden; }
.obj.link { border: 1.5px dashed #2a6fdb; background: rgba(42,111,219,.08); }
.obj.link .lurl { position: absolute; left: 0; top: -16px; font: 500 10px/14px var(--f-mono); color: #2a6fdb; background: rgba(255,255,255,.9); padding: 0 4px; border-radius: 3px; white-space: nowrap; max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
.obj.img { cursor: move; transform-origin: center; }
.obj.img img { width: 100%; height: 100%; display: block; pointer-events: none; user-select: none; -webkit-user-drag: none; }
.obj.note { width: 22px; height: 22px; cursor: move; filter: drop-shadow(0 1px 2px rgba(0,0,0,.35)); }
.obj.note svg { width: 100%; height: 100%; }
svg.objsvg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
svg.objsvg .hit { pointer-events: stroke; cursor: move; stroke: transparent; fill: none; }
.app[data-tool]:not([data-tool="select"]) svg.objsvg .hit, .app[data-tool]:not([data-tool="select"]) .obj { pointer-events: none; }
.app[data-tool]:not([data-tool="select"]) .obj.textobj[contenteditable] { pointer-events: auto; }
.selbox { position: absolute; border: 1.5px solid var(--sel); pointer-events: none; transform-origin: center; }
.handle { position: absolute; width: 12px; height: 12px; margin: -6px 0 0 -6px; background: #fff; border: 2px solid var(--sel); border-radius: 3px; pointer-events: auto; touch-action: none; z-index: 3; }
.handle.rot { border-radius: 50%; cursor: grab; }
.handle[data-h="nw"], .handle[data-h="se"] { cursor: nwse-resize; }
.handle[data-h="ne"], .handle[data-h="sw"] { cursor: nesw-resize; }
.handle[data-h="p1"], .handle[data-h="p2"] { cursor: move; border-radius: 50%; }
.obj-menu { position: absolute; z-index: 4; display: flex; gap: 2px; padding: 3px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); pointer-events: auto; transform: translate(-50%, -100%); }
.obj-menu button { width: 28px; height: 28px; border: 0; background: transparent; border-radius: 5px; display: grid; place-items: center; cursor: pointer; color: var(--fg); }
.obj-menu button:hover { background: var(--panel-2); }
.obj-menu button.del:hover { color: var(--danger); }
.marquee { position: absolute; border: 1px dashed var(--sel); background: rgba(29,127,104,.08); pointer-events: none; }
.flash { position: absolute; background: rgba(255,170,0,.45); outline: 2px solid #f29900; border-radius: 2px; pointer-events: none; animation: flash 1.6s ease-out forwards; }
.flash.keep { animation: none; background: rgba(255,200,0,.28); outline: 1px solid rgba(242,153,0,.7); }
@keyframes flash { 0%,60% { opacity: 1; } 100% { opacity: .25; } }
.cropmask { position: absolute; pointer-events: none; box-shadow: 0 0 0 9999px rgba(20,32,27,.38); outline: 1.5px dashed #fff; }
.fw { position: absolute; border: 1px solid rgba(42,111,219,.55); background: rgba(219,232,255,.55); font-family: Helvetica, Arial, sans-serif; color: #0b2a5b; padding: 0 3px; border-radius: 2px; }
.fw:focus { outline: 2px solid #2a6fdb; background: rgba(235,242,255,.95); }
textarea.fw { resize: none; padding-top: 2px; line-height: 1.2; }
input.fw[type=checkbox], input.fw[type=radio] { margin: 0; padding: 0; accent-color: #2a6fdb; cursor: pointer; }
select.fw { padding: 0; }
.ghost-place { position: absolute; pointer-events: none; opacity: .6; outline: 1.5px dashed var(--sel); }
.drop-hint { position: absolute; inset: 12px; border: 2px dashed var(--accent); border-radius: 14px; background: color-mix(in srgb, var(--canvas) 80%, transparent); display: grid; place-items: center; z-index: 20; pointer-events: none; }
.drop-hint div { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; padding: 16px; }
.drop-hint [data-i] { width: 40px; height: 40px; color: var(--accent); }
.drop-hint b { font-size: 18px; }

/* organizer */
.organizer { display: flex; flex-direction: column; min-height: 0; background: var(--canvas); }
.organizer[hidden] { display: none; }
.org-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line); }
.org-title { display: flex; flex-direction: column; gap: 2px; }
.org-title b { font-size: 15px; }
.org-title span { font-size: 12.5px; }
.org-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.org-size { display: flex; align-items: center; gap: 4px; color: var(--muted); }
.org-size input { width: 90px; accent-color: var(--accent); }
.org-grid { flex: 1; overflow: auto; display: flex; flex-wrap: wrap; align-content: flex-start; gap: 18px; padding: 22px 16px 60px; position: relative; }
.org-grid .thumb { background: transparent; }

/* dock */
.dock { width: 300px; background: var(--panel); border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.dock[hidden] { display: none; }
.dock-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px 10px 16px; border-bottom: 1px solid var(--line); }
.dock-head b { font-size: 15px; }
.dock-body { overflow: auto; padding: 12px 12px 30px; display: flex; flex-direction: column; gap: 18px; }
.dsec h4 { margin: 0 0 8px 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; }
.dgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.dtool { display: flex; align-items: center; gap: 8px; padding: 9px 9px; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); cursor: pointer; text-align: left; font-size: 13px; font-weight: 500; min-width: 0; }
.dtool:hover { border-color: var(--accent); background: var(--accent-2); }
.dtool [data-i] { color: var(--accent); }
.dtool span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }

/* status bar */
.statusbar { display: flex; align-items: center; gap: 14px; padding: 4px 12px; background: var(--panel); border-top: 1px solid var(--line); font-size: 12.5px; min-width: 0; }
.pager { display: flex; align-items: center; gap: 4px; font-variant-numeric: tabular-nums; }
.pagenum { width: 44px; height: 24px; border: 1px solid var(--line); border-radius: 5px; background: var(--panel-2); text-align: center; font-family: var(--f-mono); font-size: 12px; }
#pageCount { font-family: var(--f-mono); font-size: 12px; }
.status-msg { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.privacy { display: inline-flex; align-items: center; gap: 5px; color: var(--accent); font-weight: 500; white-space: nowrap; }
.privacy [data-i] { width: 14px; height: 14px; }

/* sidebar lists */
.results { display: flex; flex-direction: column; gap: 4px; }
.res { display: block; width: 100%; text-align: left; padding: 7px 9px; border-radius: 6px; border: 1px solid transparent; background: transparent; cursor: pointer; font-size: 13px; line-height: 1.35; }
.res:hover { background: var(--panel-2); border-color: var(--line); }
.res .rp { font-family: var(--f-mono); font-size: 11px; color: var(--muted); display: block; margin-bottom: 2px; }
.res mark { background: #ffe58a; color: #222; border-radius: 2px; padding: 0 1px; }
.res-row { display: flex; align-items: center; gap: 6px; }
.res-row .res { flex: 1; min-width: 0; }
.res-row .res span.t { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.res-group { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 600; margin: 10px 4px 2px; }
.search-box { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.search-box input[type=search] { height: 34px; border: 1px solid var(--line); border-radius: var(--r); padding: 0 10px; background: var(--panel-2); }
.chk { display: flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; }
.chk input { accent-color: var(--accent); }
.search-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 8px; }
.search-actions .muted { flex-basis: 100%; font-size: 12.5px; }
.empty { color: var(--muted); font-size: 13px; line-height: 1.5; padding: 8px 4px; }
.ol-item { padding-left: calc(var(--d, 0) * 12px + 9px); }
.field-row { display: flex; flex-direction: column; gap: 4px; padding: 8px; border: 1px solid var(--line); border-radius: 6px; }
.field-row label { font-size: 12px; color: var(--muted); font-weight: 600; overflow-wrap: anywhere; }
.field-row input, .field-row select, .field-row textarea { border: 1px solid var(--line); border-radius: 5px; background: var(--panel-2); padding: 5px 7px; min-width: 0; width: 100%; }

/* modal */
.modal-back { position: fixed; inset: 0; z-index: 50; background: rgba(10,16,14,.45); display: grid; place-items: center; padding: 16px; }
.modal { width: min(560px, 100%); max-height: calc(100% - 24px); display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 20px 60px rgba(0,0,0,.3); min-height: 0; }
.modal.wide { width: min(760px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px 12px 20px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 17px; text-wrap: balance; }
.modal-body { padding: 16px 20px; overflow: auto; display: flex; flex-direction: column; gap: 14px; min-height: 0; }
.modal-body p { margin: 0; line-height: 1.5; color: var(--muted); max-width: 65ch; }
.modal-foot { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; padding: 12px 16px 14px; border-top: 1px solid var(--line); }
.frow { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.fld { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.fld > span { font-size: 12px; font-weight: 600; color: var(--muted); }
.fld input[type=text], .fld input[type=number], .fld input[type=password], .fld select, .fld textarea { height: 36px; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel-2); padding: 0 10px; min-width: 0; width: 100%; }
.fld textarea { height: auto; padding: 8px 10px; resize: vertical; }
.fld input[type=color] { height: 36px; width: 100%; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel-2); padding: 3px; }
.fld input[type=range] { accent-color: var(--accent); }
.fld small { color: var(--muted); font-size: 12px; line-height: 1.4; }
.seg { display: flex; flex-wrap: wrap; gap: 4px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px; padding: 3px; }
.seg button { flex: 1; min-width: max-content; height: 30px; border: 0; background: transparent; border-radius: 6px; cursor: pointer; font-weight: 500; padding: 0 10px; }
.seg button.on { background: var(--panel); box-shadow: var(--shadow); color: var(--accent); font-weight: 600; }
.note-box { padding: 10px 12px; border-radius: var(--r); background: var(--accent-2); color: var(--fg); font-size: 13px; line-height: 1.5; }
.note-box.warn { background: color-mix(in srgb, var(--warn) 14%, var(--panel)); }
.posgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; max-width: 180px; }
.posgrid button { height: 30px; border: 1px solid var(--line); background: var(--panel-2); border-radius: 5px; cursor: pointer; font-size: 11px; }
.posgrid button.on { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.filelist { display: flex; flex-direction: column; gap: 6px; }
.fileitem { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel-2); font-size: 13px; }
.fileitem span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sigpad { width: 100%; height: 190px; border: 1px dashed var(--line-2); border-radius: 10px; background: #fff; touch-action: none; cursor: crosshair; display: block; }
.sig-saved { display: flex; flex-wrap: wrap; gap: 8px; }
.sig-saved .sigc { position: relative; width: 140px; height: 60px; border: 1px solid var(--line); border-radius: 8px; background: #fff; cursor: pointer; display: grid; place-items: center; padding: 4px; }
.sig-saved .sigc:hover { border-color: var(--accent); }
.sig-saved img { max-width: 100%; max-height: 100%; }
.sig-saved .x { position: absolute; top: -7px; right: -7px; width: 20px; height: 20px; border-radius: 50%; border: 1px solid var(--line); background: var(--panel); cursor: pointer; font-size: 12px; line-height: 1; display: grid; place-items: center; color: var(--fg); }
.typed-opts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
.typed-opts button { height: 64px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: #1a2a6c; cursor: pointer; font-size: 28px; overflow: hidden; white-space: nowrap; padding: 0 8px; }
.typed-opts button.on { outline: 2px solid var(--accent); }
.stamp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.stamp-grid button { border: 1px solid var(--line); border-radius: 8px; background: #fff; padding: 8px; cursor: pointer; display: grid; place-items: center; height: 70px; }
.stamp-grid button:hover { border-color: var(--accent); }
.stamp-grid img { max-width: 100%; max-height: 54px; }
.sizecmp { font-family: var(--f-mono); font-size: 13px; font-variant-numeric: tabular-nums; }

/* landing state */
.welcome { width: min(720px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 28px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 18px; }
.welcome h1 { font-family: var(--f-brand); font-weight: 400; font-size: clamp(30px, 5vw, 44px); line-height: 1.05; margin: 0; text-wrap: balance; }
.welcome p { margin: 0; color: var(--muted); line-height: 1.55; max-width: 60ch; }

/* busy + toasts */
.busy { position: fixed; inset: 0; z-index: 60; background: rgba(10,16,14,.35); display: grid; place-items: center; padding: 16px; }
.busy-card { display: flex; align-items: center; gap: 14px; padding: 16px 20px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); min-width: min(320px, 100%); }
.busy-card .bar { height: 4px; border-radius: 2px; background: var(--line); margin-top: 8px; overflow: hidden; width: 220px; max-width: 100%; }
.busy-card .bar span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .15s; }
.spinner { width: 26px; height: 26px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin 0.8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.toasts { position: fixed; bottom: 44px; left: 50%; transform: translateX(-50%); z-index: 70; display: flex; flex-direction: column; gap: 8px; align-items: center; width: min(520px, calc(100% - 32px)); pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 10px; background: var(--fg); color: var(--bg); box-shadow: var(--shadow); font-size: 13.5px; line-height: 1.4; animation: tin .2s ease-out; }
.toast.err { background: var(--danger); color: #fff; }
.toast button { border: 0; background: transparent; color: inherit; font-weight: 700; cursor: pointer; text-decoration: underline; }
@keyframes tin { from { opacity: 0; transform: translateY(8px); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* responsive */
@media (max-width: 1100px) { .dock { position: absolute; right: 0; top: 0; bottom: 0; z-index: 15; box-shadow: var(--shadow); } }
@media (max-width: 860px) {
  .hide-sm { display: none !important; }
  .side { position: absolute; left: 0; top: 0; bottom: 0; z-index: 15; box-shadow: var(--shadow); }
  .tool { min-width: 46px; }
  .tool span { font-size: 10px; }
}
@media (max-width: 560px) {
  .hide-xs { display: none !important; }
  .topbar .zoom, .topbar .sep { display: none; }
  #btnOpen span, #btnSave span { display: none; }
  .top-actions { gap: 2px; }
  .filename { font-size: 13px; padding: 4px 4px; }
  .dirty { display: none; }
  .topbar { gap: 6px; padding: 6px 8px; }
  .wordmark { display: none; }
  .zoom select { width: 74px; }
  .zoom .icon-btn { display: none; }
  .btn { padding: 0 9px; }
  .privacy { display: none; }
  .dock { width: 100%; }
  .side { width: 210px; }
}
.dtool svg, .obj-menu svg, .tacts svg, .icon-btn > svg, .toggle svg, .res-row svg, .fileitem svg { width: 18px; height: 18px; flex: none; }
.tacts svg { width: 16px; height: 16px; }
.toggle svg { width: 16px; height: 16px; vertical-align: middle; }
.fw, .page { color-scheme: light; }
.btn.active { background: var(--accent-2); color: var(--accent); }
.app[data-tool="text"] .obj.textobj { pointer-events: auto; cursor: text; }

.dock-about { display: flex; flex-direction: column; gap: 4px; font-size: 13px; line-height: 1.5; color: var(--muted); padding: 0 4px; }
.dock-about b { color: var(--fg); }
