/* PDF Editor — styles. Light-first tool UI with a dark mode; AI Apps blue as the one accent. */
:root {
  --bg: #F6F7F9;
  --surface: #FFFFFF;
  --raised: #F1F3F6;
  --hover: #E8EBF0;
  --line: #DDE1E7;
  --line-soft: #E9ECF0;
  --text: #0E1525;
  --dim: #5A6475;
  --faint: #8C95A3;
  --accent: #2563EB;
  --accent-hover: #1D4ED8;
  --accent-soft: rgba(37, 99, 235, .10);
  --on-accent: #FFFFFF;
  --danger: #DC2626;
  --ok: #059669;
  --desk: #E4E7EC;
  --page-shadow: 0 1px 3px rgba(15, 23, 42, .12), 0 8px 24px -8px rgba(15, 23, 42, .18);
  --shadow: 0 12px 40px -8px rgba(15, 23, 42, .25);
  --radius: 10px;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111318; --surface: #181B21; --raised: #20242B; --hover: #2A2F37; --line: #2E333B; --line-soft: #252A31;
    --text: #E9ECF1; --dim: #A2AAB6; --faint: #78818D; --accent: #5B8DEF; --accent-hover: #7AA3F3;
    --accent-soft: rgba(91, 141, 239, .16); --on-accent: #0B1020; --danger: #F87171; --ok: #34D399; --desk: #0C0E12;
    --page-shadow: 0 1px 3px rgba(0, 0, 0, .5), 0 8px 24px -8px rgba(0, 0, 0, .6); --shadow: 0 12px 40px -8px rgba(0, 0, 0, .7);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111318; --surface: #181B21; --raised: #20242B; --hover: #2A2F37; --line: #2E333B; --line-soft: #252A31;
  --text: #E9ECF1; --dim: #A2AAB6; --faint: #78818D; --accent: #5B8DEF; --accent-hover: #7AA3F3;
  --accent-soft: rgba(91, 141, 239, .16); --on-accent: #0B1020; --danger: #F87171; --ok: #34D399; --desk: #0C0E12;
  --page-shadow: 0 1px 3px rgba(0, 0, 0, .5), 0 8px 24px -8px rgba(0, 0, 0, .6); --shadow: 0 12px 40px -8px rgba(0, 0, 0, .7);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text); font: 14px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased; display: flex; flex-direction: column; overflow: hidden;
  user-select: none; -webkit-user-select: none;
}
input, textarea, .modal p, .modal li { user-select: text; -webkit-user-select: text; }
body.no-doc .stage { background: var(--bg); }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ── top bar ── */
.bar {
  display: flex; align-items: center; gap: 6px; padding: 8px 12px; padding-top: max(8px, env(safe-area-inset-top));
  background: var(--surface); border-bottom: 1px solid var(--line); flex-wrap: wrap; position: relative; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--text); margin-right: 6px; white-space: nowrap; }
.brand-mark {
  font: 800 10px/1 var(--sans); letter-spacing: .04em; color: var(--on-accent); background: var(--accent);
  border-radius: 6px; padding: 7px 5px;
}
.brand-text { font-weight: 650; font-size: 15px; letter-spacing: -.01em; }
.brand-text small { font-weight: 450; color: var(--faint); font-size: 12.5px; }
.bar-group { display: flex; align-items: center; gap: 4px; }
.bar-right { margin-left: auto; }
.sep { width: 1px; height: 22px; background: var(--line); margin: 0 4px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 11px; border-radius: 8px;
  border: 1px solid transparent; background: none; cursor: pointer; white-space: nowrap; font-weight: 520;
}
.btn:hover:not(:disabled) { background: var(--hover); }
.btn:disabled { opacity: .38; cursor: default; }
.btn.icon { width: 34px; padding: 0; justify-content: center; }
.btn.primary { background: var(--accent); color: var(--on-accent); }
.btn.primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn.big { height: 44px; padding: 0 22px; font-size: 15px; border-radius: 10px; }
.btn.danger { color: var(--danger); }
.btn.small { height: 28px; padding: 0 10px; font-size: 12.5px; }
.spacer { flex: 1; }

/* "More" menu */
.menu-wrap { position: relative; }
.menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 40; min-width: 270px; padding: 6px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); display: flex; flex-direction: column;
}
.menu button {
  display: flex; align-items: center; gap: 10px; height: 36px; padding: 0 10px; border: 0; background: none; border-radius: 8px;
  cursor: pointer; text-align: left; font-size: 13.5px; color: var(--text);
}
.menu button:hover { background: var(--hover); }
.menu button svg { width: 17px; height: 17px; color: var(--dim); }
.menu kbd { margin-left: auto; }

/* find bar */
.work { position: relative; }
.findbar {
  position: absolute; top: 10px; right: 24px; z-index: 25; display: flex; align-items: center; gap: 4px; padding: 5px 6px 5px 10px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
}
.findbar > svg { color: var(--dim); }
.findbar input { width: 220px; height: 30px; border: 0; background: none; color: var(--text); font: inherit; outline: none; }
.find-count { font-size: 12px; color: var(--dim); min-width: 64px; text-align: right; font-variant-numeric: tabular-nums; }
.findbar .btn.icon { width: 30px; height: 30px; }
@media (max-width: 760px) { .findbar { left: 8px; right: 8px; } .findbar input { width: auto; flex: 1; min-width: 0; } }
.zoom-val { min-width: 58px; justify-content: center; font-variant-numeric: tabular-nums; font-size: 13px; padding: 0 6px; }
.link { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }

/* tools */
.tools { display: flex; align-items: center; gap: 2px; padding: 3px; background: var(--raised); border-radius: 10px; margin: 0 4px; overflow-x: auto; scrollbar-width: none; }
.tools::-webkit-scrollbar { display: none; }
.tool {
  display: inline-flex; align-items: center; gap: 5px; height: 32px; padding: 0 9px; border: 0; border-radius: 7px;
  background: none; cursor: pointer; font-size: 13px; font-weight: 520; color: var(--dim); white-space: nowrap;
}
.tool:hover { color: var(--text); background: var(--hover); }
.tool[aria-pressed="true"] { background: var(--surface); color: var(--accent); box-shadow: 0 0 0 1px var(--line), 0 1px 2px rgba(0,0,0,.06); }
.tool svg { width: 17px; height: 17px; }
@media (max-width: 1720px) { .tool span { display: none; } .tool { padding: 0 8px; } }
@media (max-width: 760px) {
  .brand-text small, #b-open span, #b-add span, #b-save-copy span { display: none; }
  .tools { order: 10; width: 100%; margin: 4px 0 0; }
  .bar-right { margin-left: auto; }
  .bar { gap: 2px; padding-left: 8px; padding-right: 8px; }
  .bar .sep { margin: 0 1px; }
}
@media (max-width: 480px) {
  body:not(.no-doc) .brand-text { display: none; }
  #b-zoom-in, #b-zoom-out, .bar .sep { display: none; }
  .zoom-val { min-width: 44px; }
  .brand { margin-right: 2px; }
  .bar .btn { padding: 0 8px; }
  .bar .btn.icon { width: 32px; padding: 0; }
  body:not(.no-doc) .tools { width: calc(100% - 72px); }
  body:not(.no-doc) #b-theme { order: 11; margin: 4px 0 0 4px; }
  body:not(.no-doc) #b-about { order: 12; margin: 4px 0 0 0; }
}

/* ── properties bar ── */
.props {
  display: flex; align-items: center; gap: 10px; padding: 6px 12px; min-height: 44px; flex-wrap: wrap;
  background: var(--surface); border-bottom: 1px solid var(--line); font-size: 13px; color: var(--dim); position: relative; z-index: 15;
}
.props .hint { color: var(--dim); }
.props label { display: inline-flex; align-items: center; gap: 6px; }
.props select, .props input[type="number"] {
  height: 30px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); color: var(--text); padding: 0 6px; font: inherit;
}
.props input[type="number"] { width: 62px; }
.swatches { display: inline-flex; gap: 4px; align-items: center; }
.sw {
  width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--line); cursor: pointer; padding: 0;
}
.sw[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--accent); }
.sw-custom { position: relative; overflow: hidden; background: conic-gradient(red, yellow, lime, cyan, blue, magenta, red); }
.sw-custom input { position: absolute; inset: -6px; opacity: 0; cursor: pointer; }
.tog { height: 30px; min-width: 30px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); cursor: pointer; font-weight: 700; }
.tog[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.props .spacer { flex: 1; }
.props .lbl { color: var(--dim); }
.seg-mini { display: inline-flex; gap: 0; }
.seg-mini .tog { border-radius: 0; margin-left: -1px; padding: 0 9px; font-weight: 560; font-size: 12.5px; color: var(--text); }
.seg-mini .tog:first-child { border-radius: 7px 0 0 7px; margin-left: 0; }
.seg-mini .tog:last-child { border-radius: 0 7px 7px 0; }
.seg-mini .tog[aria-pressed="true"] { position: relative; z-index: 1; color: var(--accent); }
.sw-none { background: linear-gradient(135deg, transparent 45%, var(--danger) 45% 55%, transparent 55%), var(--surface); }
.stamps { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.stamp-chip {
  height: 26px; padding: 0 8px; border: 1.5px solid var(--c); border-radius: 4px; background: none; color: var(--c);
  font: 700 11px var(--sans); letter-spacing: .03em; cursor: pointer;
}
.stamp-chip[aria-pressed="true"] { background: var(--c); color: #fff; }
.stamp-custom { height: 28px; width: 120px; border: 1px solid var(--line); border-radius: 7px; padding: 0 8px; background: var(--surface); color: var(--text); font: inherit; text-transform: uppercase; }

/* ── workspace ── */
.work { flex: 1; display: flex; min-height: 0; }
.side { width: 184px; flex: none; display: flex; flex-direction: column; background: var(--surface); border-right: 1px solid var(--line); min-height: 0; }
.side-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; padding: 6px 8px 0; }
.side-tabs button { border: 0; background: none; height: 30px; border-radius: 7px; cursor: pointer; color: var(--dim); font-weight: 560; font-size: 12.5px; }
.side-tabs button[aria-selected="true"] { background: var(--raised); color: var(--text); }
.clist { list-style: none; margin: 0; padding: 8px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 8px; }
.citem { border: 1px solid var(--line); border-radius: 9px; padding: 8px 9px; font-size: 12.5px; background: var(--surface); }
.cmeta { color: var(--dim); }
.cmeta b { color: var(--text); font-weight: 600; }
.cfile { color: var(--faint); }
.ctext { margin-top: 4px; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 120px; overflow: auto; }
.cacts { display: flex; gap: 12px; margin-top: 6px; }
.cacts .link { font-size: 12px; }
.link.danger { color: var(--danger); }
.cempty { color: var(--faint); font-size: 12.5px; padding: 8px 4px; }
.modal-ta { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font: 14px/1.4 var(--sans); background: var(--surface); color: var(--text); resize: vertical; }
.side-head { padding: 10px 10px 8px; border-bottom: 1px solid var(--line-soft); font-size: 12.5px; color: var(--dim); }
.side-head > span { display: block; margin-bottom: 6px; font-weight: 600; }
.side-actions { display: flex; flex-wrap: wrap; gap: 2px; }
.side-actions .btn { height: 28px; width: 28px; padding: 0; justify-content: center; border-radius: 6px; }
.side-actions .btn svg { width: 16px; height: 16px; }
.thumbs { list-style: none; margin: 0; padding: 10px 12px 40px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 14px; }
.thumb { position: relative; cursor: pointer; border-radius: 6px; padding: 5px; text-align: center; user-select: none; }
.thumb:hover { background: var(--raised); }
.thumb[aria-selected="true"] { background: var(--accent-soft); }
.thumb[aria-selected="true"] .thumb-box { box-shadow: 0 0 0 2px var(--accent); }
.thumb.current .thumb-num { color: var(--accent); font-weight: 700; }
.thumb-box { position: relative; margin: 0 auto; background: #fff; box-shadow: 0 0 0 1px var(--line); border-radius: 2px; overflow: hidden; }
.tsheet { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.tsheet img { display: block; width: 100%; height: 100%; }
.tann { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.tann .an { pointer-events: none; }
.thumb-num { font-size: 11.5px; color: var(--faint); margin-top: 4px; font-variant-numeric: tabular-nums; }
.thumb-tools { position: absolute; top: 8px; right: 8px; display: none; gap: 2px; }
.thumb:hover .thumb-tools, .thumb:focus-within .thumb-tools { display: flex; }
.thumb-tools button {
  width: 24px; height: 24px; border-radius: 6px; border: 0; background: var(--surface); box-shadow: 0 1px 4px rgba(0,0,0,.2);
  cursor: pointer; display: grid; place-items: center; padding: 0;
}
.thumb-tools button:hover { color: var(--accent); }
.thumb-tools svg { width: 14px; height: 14px; }
.thumb.drop-before::before, .thumb.drop-after::after {
  content: ""; position: absolute; left: 4px; right: 4px; height: 3px; background: var(--accent); border-radius: 2px;
}
.thumb.drop-before::before { top: -9px; }
.thumb.drop-after::after { bottom: -9px; }
.thumb.dragging { opacity: .4; }

.stage { flex: 1; overflow: auto; background: var(--desk); position: relative; min-width: 0; outline: none; }
.pages { display: flex; flex-direction: column; align-items: center; gap: 18px; padding: 24px 16px 80px; min-width: min-content; }
.page { position: relative; background: #fff; box-shadow: var(--page-shadow); flex: none; }
.page-label { position: absolute; left: 0; top: 100%; margin-top: 3px; font-size: 11px; color: var(--faint); }
.sheet { position: absolute; left: 0; top: 0; transform-origin: 0 0; isolation: isolate; --scale-round-x: 1px; --scale-round-y: 1px; --user-unit: 1; }
.sheet canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.layer { position: absolute; inset: 0; }
.decor, .hits, .croplayer { pointer-events: none; }
.croplayer, .decor { overflow: hidden; }
.annots { touch-action: none; }
/* In Select the empty page belongs to the text layer underneath (select and copy text). */
.stage[data-tool="select"] .annots { pointer-events: none; touch-action: auto; }
.stage[data-tool="select"] .annots > .an, .stage[data-tool="select"] .annots > .an-edit { pointer-events: auto; }
.stage[data-tool="text"] .annots, .stage[data-tool="edit"] .annots { cursor: text; }
.stage[data-tool="cover"] .annots, .stage[data-tool="hl"] .annots, .stage[data-tool="shape"] .annots, .stage[data-tool="link"] .annots,
.stage[data-tool="ink"] .annots, .stage[data-tool="tick"] .annots, .stage[data-tool="note"] .annots, .stage[data-tool="stamp"] .annots,
.stage[data-tool="crop"] .annots, .stage[data-tool="place"] .annots { cursor: crosshair; }
.fields { pointer-events: none; }
.fld { pointer-events: auto; }
.stage:not([data-tool="select"]) .fld { pointer-events: none; }
.stage:not([data-tool="select"]) .an { pointer-events: none; }
.stage[data-tool="text"] .an.t-text, .stage[data-tool="note"] .an.t-note { pointer-events: auto; }

/* selectable text (pdf.js text layer; rules adapted from pdf.js's pdf_viewer.css, Apache-2.0) */
.textLayer {
  position: absolute; text-align: initial; inset: 0; overflow: clip; opacity: 1; line-height: 1; letter-spacing: normal; word-spacing: normal;
  -webkit-text-size-adjust: none; text-size-adjust: none; forced-color-adjust: none; transform-origin: 0 0; caret-color: CanvasText; z-index: 0;
  --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 span, .textLayer br {
  color: transparent; position: absolute; white-space: pre; cursor: text; transform-origin: 0% 0%;
  -webkit-user-select: text; 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 ::selection { background: rgba(37, 99, 235, .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; }
.textLayer[data-main-rotation="90"] { transform: rotate(90deg) translateY(-100%); }
.textLayer[data-main-rotation="180"] { transform: rotate(180deg) translate(-100%, -100%); }
.textLayer[data-main-rotation="270"] { transform: rotate(270deg) translateX(-100%); }
.stage:not([data-tool="select"]) .textLayer { pointer-events: none; }

.find-hit { position: absolute; background: rgba(250, 204, 21, .45); mix-blend-mode: multiply; border-radius: 2px; }
.find-hit.cur { background: rgba(249, 115, 22, .55); outline: 2px solid #f97316; }
.crop-box { position: absolute; box-shadow: 0 0 0 9999px rgba(15, 23, 42, .5); outline: 1.5px dashed #fff; }

/* annotations */
.an { position: absolute; touch-action: none; }
.stage[data-tool="select"] .an { cursor: move; }
.an.sel { outline: 1.5px solid var(--accent); outline-offset: 1px; }
.an.t-text { white-space: pre; line-height: 1.2; color: #000; }
.an.t-cover { background: #fff; }
.an.t-hl.k-highlight { background: var(--c); opacity: .4; mix-blend-mode: multiply; }
.an.t-hl .hl-line { position: absolute; left: 0; right: 0; height: max(1px, 7%); background: var(--c); top: 86.5%; }
.an.t-hl.k-strike .hl-line { top: 51.5%; }
.an.t-link { outline: 1.5px dashed #2563eb; background: rgba(37, 99, 235, .08); }
.thumb .an.t-link, .decor .an.t-link { outline: 0; background: none; }
.an.t-stamp svg text { font-kerning: none; }
.an.t-img img { width: 100%; height: 100%; display: block; pointer-events: none; user-select: none; -webkit-user-drag: none; }
.an svg { position: absolute; overflow: visible; width: auto; height: auto; stroke-width: inherit; pointer-events: none; }
.handle {
  position: absolute; right: -7px; bottom: -7px; width: 12px; height: 12px; background: var(--surface);
  border: 2px solid var(--accent); border-radius: 3px; cursor: nwse-resize; touch-action: none;
}
.an-del {
  position: absolute; right: -4px; top: -30px; height: 24px; padding: 0 8px; border-radius: 6px; border: 0; background: var(--danger);
  color: #fff; font-size: 11.5px; font-weight: 600; cursor: pointer; white-space: nowrap; font-family: var(--sans);
  box-shadow: 0 2px 6px rgba(0,0,0,.2);
}
.an-edit {
  position: absolute; margin: 0; padding: 0; border: 0; outline: 1.5px dashed var(--accent); outline-offset: 1px;
  background: rgba(255,255,255,.0); resize: none; overflow: hidden; white-space: pre; line-height: 1.2; z-index: 5; color: #000;
}
.an.t-redact {
  outline: 2px solid #dc2626; background: repeating-linear-gradient(-45deg, rgba(220, 38, 38, .22) 0 4px, rgba(220, 38, 38, .06) 4px 9px);
}
.stage[data-tool="redact"] .an.t-redact { pointer-events: none; }
.obj-hit { position: absolute; outline: 1.5px dashed var(--accent); background: rgba(37, 99, 235, .06); pointer-events: none; }
.obj-sel { position: absolute; outline: 2px solid var(--accent); pointer-events: none; }
.obj-sel .handle, .obj-sel .an-del { pointer-events: auto; }
.stage[data-tool="objects"] .annots { cursor: default; }
.ghost.obj-ghost { background: rgba(37, 99, 235, .12); }
.para-edit {
  position: absolute; z-index: 6; margin: 0; padding: 0; border: 0; resize: none; overflow: hidden; white-space: pre-wrap; overflow-wrap: break-word;
  outline: 1.5px dashed var(--accent); outline-offset: 2px; box-shadow: 0 0 0 4px rgba(37, 99, 235, .08);
}
.handle.end { right: auto; bottom: auto; border-radius: 50%; cursor: move; }
.ghost { position: absolute; border: 1.5px dashed var(--accent); background: var(--accent-soft); pointer-events: none; }
.ghost.round { border-radius: 50%; }
.ghost.crop { background: none; box-shadow: 0 0 0 9999px rgba(15, 23, 42, .35); border-color: #fff; }

/* comment popup */
.note-pop {
  position: absolute; z-index: 12; width: 260px; background: var(--surface); color: var(--text); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: var(--shadow); padding: 10px; display: flex; flex-direction: column; gap: 8px;
}
.note-pop textarea {
  width: 100%; min-height: 84px; resize: vertical; border: 1px solid var(--line); border-radius: 8px; padding: 8px; font: 13.5px/1.4 var(--sans);
  background: var(--surface); color: var(--text);
}
.note-row { display: flex; align-items: center; gap: 6px; }
.note-row .sw { width: 18px; height: 18px; }
.text-hit { position: absolute; background: rgba(37, 99, 235, .14); outline: 1px solid rgba(37, 99, 235, .5); pointer-events: none; border-radius: 1px; }

/* form fields */
.fld {
  position: absolute; margin: 0; border: 0; padding: 0 2px; background: rgba(37, 99, 235, .09); color: #000;
  font-family: Helvetica, Arial, sans-serif; border-radius: 1px; outline: none;
}
.fld:hover { background: rgba(37, 99, 235, .16); }
.fld:focus { background: rgba(37, 99, 235, .05); box-shadow: inset 0 0 0 1.5px var(--accent); }
textarea.fld { resize: none; line-height: 1.15; padding-top: 2px; }
input[type="checkbox"].fld, input[type="radio"].fld { appearance: auto; accent-color: #1f2937; background: none; padding: 0; }
select.fld { appearance: auto; }
.fld:disabled { background: none; }

/* ── empty state ── */
.empty { max-width: 640px; margin: 0 auto; padding: 48px 16px 64px; }
.drop {
  border: 2px dashed var(--line); border-radius: 16px; background: var(--surface); text-align: center; padding: 40px 20px 30px;
  transition: border-color .15s, background .15s;
}
.drop.over, body.dragging .drop { border-color: var(--accent); background: var(--accent-soft); }
.drop-icon { width: 54px; height: 54px; color: var(--accent); stroke-width: 1.6; }
.drop h1 { font-size: 26px; letter-spacing: -.02em; margin: 10px 0 6px; font-weight: 720; }
.drop-sub { color: var(--dim); margin: 0 0 16px; }
.drop-or { margin: 14px 0 0; font-size: 13px; }
.feats { list-style: none; padding: 0; margin: 22px 0 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px 18px; color: var(--dim); font-size: 13.5px; }
.feats li { padding-left: 18px; position: relative; }
.feats li::before { content: ""; position: absolute; left: 2px; top: 7px; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); opacity: .7; }
.feats b { color: var(--text); font-weight: 600; }
@media (max-width: 560px) { .feats { grid-template-columns: 1fr; } }
.privacy { display: flex; align-items: center; justify-content: center; gap: 8px; color: var(--dim); font-size: 13px; margin: 26px 0 0; text-align: center; }
.privacy svg { width: 16px; height: 16px; color: var(--ok); }
.restore {
  margin-top: 14px; padding: 12px 14px; border: 1px solid var(--line); background: var(--surface); border-radius: 12px;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 13.5px;
}
.restore .grow { flex: 1; min-width: 200px; }
.restore b { font-weight: 600; }
body.dragging .stage::after {
  content: "Drop to add these pages"; position: absolute; inset: 12px; border: 2px dashed var(--accent); border-radius: 14px;
  background: var(--accent-soft); display: grid; place-items: center; font-weight: 650; color: var(--accent); font-size: 16px; pointer-events: none;
}
body.dragging.no-doc .stage::after { display: none; }

/* ── toast, busy ── */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: var(--text); color: var(--bg);
  padding: 10px 16px; border-radius: 10px; font-size: 13.5px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
  max-width: min(560px, calc(100vw - 32px)); box-shadow: var(--shadow); z-index: 60;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: var(--danger); color: #fff; }
.busy {
  position: fixed; inset: 0; background: rgba(0,0,0,.18); display: flex; align-items: center; justify-content: center; gap: 12px;
  z-index: 70; font-weight: 600;
}
.busy > * { background: var(--surface); }
.busy span { padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow); }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; box-shadow: var(--shadow); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── modals ── */
.modal { border: 0; border-radius: 16px; padding: 0; width: min(560px, calc(100vw - 24px)); background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.modal.wide { width: min(640px, calc(100vw - 24px)); }
.modal::backdrop { background: rgba(10, 14, 24, .45); }
.modal-body { padding: 20px 22px; display: flex; flex-direction: column; gap: 12px; }
.modal h2 { margin: 0; font-size: 18px; letter-spacing: -.01em; }
.modal h3 { margin: 6px 0 -4px; font-size: 14px; }
.modal p, .modal ul { margin: 0; color: var(--dim); font-size: 13.5px; }
.modal ul { padding-left: 18px; display: grid; gap: 4px; }
.modal b { color: var(--text); }
.modal input[type="text"], .modal input[type="password"] {
  height: 40px; border: 1px solid var(--line); border-radius: 8px; padding: 0 12px; background: var(--surface); color: var(--text); font: inherit; font-size: 15px;
}
.modal-actions { display: flex; justify-content: flex-end; align-items: center; gap: 8px; margin-top: 6px; }
.fieldset { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--dim); font-weight: 560; }
.fieldset input:not([type="color"]):not([type="range"]), .fieldset select, .grid3 input {
  height: 36px; border: 1px solid var(--line); border-radius: 8px; padding: 0 10px; background: var(--surface); color: var(--text); font: 14px var(--sans); width: 100%;
}
.fieldset input[type="color"] { width: 100%; height: 36px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); padding: 2px; }
.fieldset .inline { display: inline-flex; align-items: center; gap: 8px; color: var(--text); font-weight: 450; font-size: 14px; }
.fieldset .inline input { width: 90px !important; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.modal code { font: 12px var(--mono); background: var(--raised); padding: 1px 4px; border-radius: 4px; color: var(--text); }
@media (max-width: 520px) { .grid2, .grid3 { grid-template-columns: 1fr; } }
.modal-actions .btn:not(.primary) { border-color: var(--line); }
.row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.hint { color: var(--faint); font-size: 12.5px; }
.check { display: inline-flex; gap: 8px; align-items: center; font-size: 13px; color: var(--dim); }
.keys { font-size: 12.5px !important; }
kbd { font: 11px var(--mono); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 4px; background: var(--raised); color: var(--text); }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--raised); border-radius: 9px; padding: 3px; gap: 3px; }
.seg button { border: 0; background: none; border-radius: 7px; height: 32px; cursor: pointer; color: var(--dim); font-weight: 560; }
.seg button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
#sig-canvas { width: 100%; aspect-ratio: 3 / 1; background: #fff; border: 1px solid var(--line); border-radius: 10px; touch-action: none; cursor: crosshair; display: block; }
.sig-fonts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.sig-font {
  height: 64px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: #111; cursor: pointer; font-size: 28px;
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis; padding: 0 10px;
}
.sig-font[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.sig-saved { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; min-height: 80px; }
.sig-saved .empty-note { grid-column: 1 / -1; color: var(--faint); font-size: 13px; align-self: center; text-align: center; }
.sig-item { position: relative; height: 80px; border: 1px solid var(--line); border-radius: 10px; background: #fff; cursor: pointer; padding: 6px; }
.sig-item[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.sig-item img { width: 100%; height: 100%; object-fit: contain; }
.sig-item .x { position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; border-radius: 6px; border: 0; background: var(--raised); cursor: pointer; font-size: 13px; line-height: 1; color: #333; }
.sig-colors { justify-content: flex-start; }
.noscript { padding: 24px; }

@media (max-width: 760px) {
  .side-tabs { display: none; }
  .work { flex-direction: column-reverse; }
  .side { width: auto; height: 132px; border-right: 0; border-top: 1px solid var(--line); flex-direction: row; }
  .side-head { width: 92px; border-bottom: 0; border-right: 1px solid var(--line-soft); padding: 8px; flex: none; overflow-y: auto; }
  .thumbs { flex-direction: row; overflow-x: auto; overflow-y: hidden; padding: 8px 10px; gap: 8px; }
  .thumb { flex: none; width: 82px; padding: 3px; }
  .thumb-num { margin-top: 1px; }
  .thumb-tools { display: none !important; }
  .pages { padding: 12px 8px 40px; gap: 12px; }
}
