/* ---------- Fonts ---------- */
@font-face { font-family: "DocSans"; src: url("vendor/pdfjs/standard_fonts/LiberationSans-Regular.ttf") format("truetype"); font-display: block; }
@font-face { font-family: "Great Vibes"; src: url("fonts/great-vibes.woff2") format("woff2"); font-display: swap; }
@font-face { font-family: "Dancing Script"; src: url("fonts/dancing-script.woff2") format("woff2"); font-display: swap; }
@font-face { font-family: "Homemade Apple"; src: url("fonts/homemade-apple.woff2") format("woff2"); font-display: swap; }
@font-face { font-family: "Sacramento"; src: url("fonts/sacramento.woff2") format("woff2"); font-display: swap; }
@font-face { font-family: "Mr Dafoe"; src: url("fonts/mr-dafoe.woff2") format("woff2"); font-display: swap; }
@font-face { font-family: "Caveat"; src: url("fonts/caveat.woff2") format("woff2"); font-display: swap; }
@font-face { font-family: "La Belle Aurore"; src: url("fonts/la-belle-aurore.woff2") format("woff2"); font-display: swap; }

/* ---------- Tokens ---------- */
:root {
  --bg: #e9edf2;
  --surface: #ffffff;
  --surface-2: #f4f6f9;
  --text: #171a21;
  --muted: #687082;
  --border: #dde2e9;
  --accent: #2557e6;
  --accent-soft: #e6edfd;
  --accent-ink: #ffffff;
  --danger: #d92d20;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 6px 20px rgba(16, 24, 40, .08);
  --page-shadow: 0 1px 3px rgba(16, 24, 40, .12), 0 4px 14px rgba(16, 24, 40, .08);
  --radius: 12px;
  --topbar-h: 54px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1014;
    --surface: #1a1d23;
    --surface-2: #23272f;
    --text: #eceef2;
    --muted: #9aa1ae;
    --border: #2e333c;
    --accent: #5b8cff;
    --accent-soft: #1f2a44;
    --accent-ink: #0b1020;
    --danger: #ff6b5e;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .4);
    --page-shadow: 0 2px 10px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
[hidden] { display: none !important; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
svg { width: 22px; height: 22px; flex: none; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 0 16px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); color: var(--text);
  font-weight: 600; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .45; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent); filter: brightness(1.07); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-sm { min-height: 34px; padding: 0 12px; font-size: 14px; }
.btn-xl { min-height: 56px; font-size: 17px; padding: 0 26px; border-radius: 14px; width: 100%; }
.btn-wide { width: 100%; }
.btn svg { width: 20px; height: 20px; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 42px; height: 42px; border-radius: 10px;
  border: 0; background: transparent; color: var(--text);
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn:disabled { opacity: .35; cursor: default; background: transparent; }

.input {
  width: 100%; min-height: 46px; padding: 0 14px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); font-size: 16px; /* 16px stops iOS zoom-on-focus */
}
.input:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }

/* ---------- Home ---------- */
.home {
  min-height: 100%;
  display: flex; justify-content: center; align-items: flex-start;
  padding: calc(28px + var(--safe-t)) 16px calc(28px + var(--safe-b));
}
.home-card { width: 100%; max-width: 480px; }
.brand { display: flex; align-items: center; gap: 12px; margin: 8px 0 6px; }
.brand img { border-radius: 11px; box-shadow: var(--shadow); }
.brand h1 { font-size: 30px; margin: 0; letter-spacing: -.02em; }
.tagline { color: var(--muted); margin: 6px 0 26px; }
.start { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.start-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  min-height: 116px; padding: 14px 10px; border-radius: 16px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); box-shadow: var(--shadow);
}
.start-btn:hover { border-color: var(--accent); }
.start-btn svg { width: 30px; height: 30px; color: var(--accent); margin-bottom: 4px; }
.start-btn strong { font-size: 17px; }
.start-btn span { font-size: 12.5px; color: var(--muted); }
.start-btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.start-btn.primary svg, .start-btn.primary span { color: rgba(255, 255, 255, .9); }
.drop-hint { text-align: center; margin: 12px 0 0; color: var(--muted); font-size: 13px; }
@media (pointer: coarse) { .drop-hint { display: none; } }

.install {
  margin-top: 16px; padding: 12px 14px; display: flex; align-items: center; gap: 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.install img { border-radius: 10px; flex: none; }
.install-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.install-text span { font-size: 13px; color: var(--muted); }
.steps { margin: 4px 0 6px; padding-left: 22px; display: grid; gap: 12px; }
.steps svg { width: 18px; height: 18px; vertical-align: -3px; color: var(--accent); }

.resume {
  margin-top: 22px; padding: 14px 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap;
  box-shadow: var(--shadow);
}
.resume-info { display: flex; flex-direction: column; min-width: 0; }
.resume-info strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.resume-label { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--accent); font-weight: 700; }
.resume-actions { display: flex; gap: 6px; }

.mine { margin-top: 30px; }
.mine-group + .mine-group { margin-top: 20px; }
.mine h2 { font-size: 15px; margin: 0 0 10px; color: var(--muted); font-weight: 600; }
.mine-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.sig-card {
  position: relative; height: 76px; padding: 10px 14px;
  background: #fff; border: 1px solid var(--border); border-radius: 10px;
  display: grid; place-items: center; grid-template-columns: minmax(0, 1fr);
}
.sig-card img { display: block; max-width: 100%; max-height: 54px; min-width: 0; }
.sig-card .x {
  position: absolute; top: 4px; right: 4px; width: 26px; height: 26px; border-radius: 50%;
  border: 0; background: rgba(0, 0, 0, .06); color: #444; display: grid; place-items: center;
}
.sig-card .x svg { width: 14px; height: 14px; }
.sig-card.add { background: transparent; border-style: dashed; color: var(--muted); font-weight: 600; }

/* ---------- Editor shell ---------- */
.editor {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  background: var(--bg);
}
.topbar {
  flex: none; display: flex; align-items: center; gap: 4px;
  height: calc(var(--topbar-h) + var(--safe-t)); padding: var(--safe-t) 8px 0;
  background: var(--surface); border-bottom: 1px solid var(--border);
  position: relative; z-index: 5;
}
.doc-title {
  flex: 1; min-width: 0; padding: 0 6px;
  font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar .btn { margin-left: 4px; }

.toolbar {
  flex: none; display: flex; justify-content: center; gap: 4px;
  padding: 6px 8px; background: var(--surface); border-bottom: 1px solid var(--border);
  position: relative; z-index: 4;
}
.tool {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-width: 64px; height: 54px; padding: 0 8px;
  border: 0; border-radius: 10px; background: transparent; color: var(--text);
  font-size: 12px; font-weight: 600;
}
.tool:hover { background: var(--surface-2); }
.tool.active { background: var(--accent-soft); color: var(--accent); }

.stage { flex: 1; position: relative; min-height: 0; }
.viewer {
  position: absolute; inset: 0; overflow: auto;
  touch-action: pan-x pan-y;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.pages {
  display: flex; flex-direction: column; align-items: flex-start; gap: 30px;
  width: max-content; min-width: 100%;
  padding: 20px 16px 90px;
}

.hint {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px;
  padding: 6px 6px 6px 16px; max-width: calc(100% - 24px);
  background: #1d2433; color: #fff; border-radius: 999px;
  box-shadow: var(--shadow); font-size: 14px; font-weight: 500; z-index: 6;
  animation: pop .18s ease-out;
}
.hint-cancel {
  border: 0; border-radius: 999px; padding: 6px 12px;
  background: rgba(255, 255, 255, .14); color: #fff; font-size: 13px; font-weight: 600;
}

.zoom {
  position: absolute; right: 14px; bottom: 16px; z-index: 6;
  display: flex; align-items: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow);
}
.zoom .icon-btn { width: 38px; height: 38px; }
.zoom-label { border: 0; background: transparent; min-width: 52px; height: 38px; font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- Pages & items ---------- */
.page {
  position: relative; flex: none;
  width: calc(var(--pw) * var(--s) * 1px);
  height: calc(var(--ph) * var(--s) * 1px);
  /* centre in the visible width; a wider-than-screen page starts at the left edge */
  margin-left: max(0px, calc((var(--vw, 0) - var(--pw) * var(--s)) * .5px));
  background: #fff; box-shadow: var(--page-shadow);
}
/* canvases get swapped on zoom; keep touch targets on the stable .page element */
.page > canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.page::after {
  content: attr(data-label);
  position: absolute; top: 100%; left: 0; right: 0; margin-top: 6px;
  text-align: center; font-size: 12px; color: var(--muted);
}
.page.placing { cursor: crosshair; }

.item {
  position: absolute;
  left: calc(var(--x) * var(--s) * 1px);
  top: calc(var(--y) * var(--s) * 1px);
  width: calc(var(--w) * var(--s) * 1px);
  height: calc(var(--h) * var(--s) * 1px);
  touch-action: none; user-select: none; -webkit-user-select: none;
  cursor: move; z-index: 1;
}
.item img, .item svg { display: block; width: 100%; height: 100%; pointer-events: none; -webkit-user-drag: none; }
.item::before { /* selection frame */
  content: ""; position: absolute; inset: -3px; border-radius: 3px;
  border: 1.5px dashed transparent; pointer-events: none;
}
@media (hover: hover) { .item:hover::before { border-color: color-mix(in srgb, var(--accent) 45%, transparent); } }
.item.sel { z-index: 3; }
.item.sel::before { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, transparent); }

.item.t-text, .item.t-date {
  width: auto; height: auto; min-width: 4px;
  font-family: "DocSans", Arial, Helvetica, sans-serif;
  font-size: calc(var(--fs) * var(--s) * 1px);
  line-height: 1.2; white-space: pre; color: var(--c, #000);
}
.item .txt { outline: none; min-height: 1.2em; white-space: pre; }
.item.editing { cursor: text; touch-action: auto; user-select: text; -webkit-user-select: text; }
.item.editing .txt { cursor: text; }
.item .txt:empty::before { content: "Type here"; color: #9aa3b2; }

.rh { /* resize handle */
  position: absolute; right: -11px; bottom: -11px; width: 22px; height: 22px;
  border-radius: 50%; background: var(--accent); border: 2.5px solid #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .3); cursor: nwse-resize; display: none; touch-action: none;
}
.rh::before { content: ""; position: absolute; inset: -12px; } /* bigger touch target */
.item.sel .rh { display: block; }
.item.editing .rh { display: none; }

/* floating context bar + quick menu live inside the page so they scroll with it */
.ctx {
  position: absolute; z-index: 10;
  display: flex; align-items: center; gap: 2px; padding: 4px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow); white-space: nowrap;
  animation: pop .14s ease-out;
}
.ctx > button, .ctx > label {
  position: relative; display: grid; place-items: center;
  width: 38px; height: 38px; border: 0; border-radius: 8px; background: transparent; color: var(--text); cursor: pointer;
}
.ctx > button:hover, .ctx > label:hover { background: var(--surface-2); }
.ctx svg { width: 20px; height: 20px; }
.ctx .danger { color: var(--danger); }
.ctx select {
  height: 38px; border: 0; border-radius: 8px; background: var(--surface-2);
  padding: 0 6px; font-size: 13px; font-weight: 600; max-width: 150px;
}
.ctx-date input {
  position: absolute; inset: 0; width: 100%; height: 100%;
  opacity: 0; border: 0; padding: 0; cursor: pointer;
}
.ctx-color span { width: 20px; height: 20px; border-radius: 50%; background: var(--c, #000); box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .6), 0 0 0 1px var(--border); }

.quick {
  position: absolute; z-index: 10;
  display: grid; grid-template-columns: repeat(3, 64px); gap: 2px; padding: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow);
  animation: pop .14s ease-out;
}
.quick button {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  height: 56px; border: 0; border-radius: 10px; background: transparent; color: var(--text);
  font-size: 11.5px; font-weight: 600;
}
.quick button:hover { background: var(--accent-soft); color: var(--accent); }
.quick-dot {
  position: absolute; width: 12px; height: 12px; margin: -6px 0 0 -6px; z-index: 9;
  border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 25%, transparent);
  pointer-events: none;
}

@keyframes pop { from { opacity: 0; transform: translateY(4px) scale(.98); } }
.hint { animation-name: hint-pop; }
@keyframes hint-pop { from { opacity: 0; transform: translate(-50%, -4px); } }

/* ---------- Sheets / modals ---------- */
.sheet-wrap {
  /* sized to the visual viewport (set from JS) so the keyboard never covers it */
  position: fixed; left: 0; right: 0; top: var(--vv-top, 0px); height: var(--vv-h, 100%); z-index: 50;
  display: flex; align-items: center; justify-content: center;
  padding: 16px; background: rgba(12, 16, 24, .45);
  animation: fade .15s ease-out;
}
.sheet {
  display: flex; flex-direction: column;
  width: 100%; max-width: 460px; max-height: calc(var(--vv-h, 100dvh) - 32px); overflow: auto;
  background: var(--surface); border-radius: 18px; box-shadow: var(--shadow);
  padding: 14px 18px 18px;
  animation: rise .2s ease-out;
}
.sheet-lg { max-width: 600px; }
.sheet > * { flex: none; }
/* with the keyboard up, the style list shrinks and the buttons stay visible */
.sheet > .tab-panel[data-panel="type"] { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.sheet-head h2 { font-size: 18px; margin: 0; }
.sheet-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(16px); } }

.picker-list { display: grid; gap: 10px; margin-bottom: 12px; }
.pick {
  position: relative; display: grid; place-items: center; grid-template-columns: minmax(0, 1fr);
  height: 92px; padding: 10px 44px;
  background: #fff; border: 1.5px solid var(--border); border-radius: 12px;
}
.pick:hover { border-color: var(--accent); }
.pick img { display: block; max-width: 100%; max-height: 70px; min-width: 0; pointer-events: none; }
.pick .x {
  position: absolute; top: 8px; right: 8px; width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center; border: 0; background: rgba(0, 0, 0, .05); color: #555;
}
.pick .x svg { width: 15px; height: 15px; }

.tabs { display: flex; gap: 4px; padding: 4px; background: var(--surface-2); border-radius: 11px; margin-bottom: 12px; }
.tab { flex: 1; height: 38px; border: 0; border-radius: 8px; background: transparent; font-weight: 600; color: var(--muted); }
.tab.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }

.pad-wrap { position: relative; background: #fff; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.pad { display: block; width: 100%; height: clamp(170px, 42vw, 230px); touch-action: none; cursor: crosshair; }
.pad-line {
  position: absolute; left: 22px; right: 22px; bottom: 28%;
  border-bottom: 1.5px solid #d5dae3; pointer-events: none;
}
.pad-line span { position: absolute; left: -2px; bottom: 3px; color: #a3abb9; font-size: 18px; }
.pad-placeholder {
  position: absolute; inset: 0; display: grid; place-items: center; padding-bottom: 12%;
  color: #a3abb9; pointer-events: none; font-size: 15px;
}
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.row-gap { display: flex; gap: 4px; }
.seg { display: flex; gap: 4px; padding: 3px; background: var(--surface-2); border-radius: 10px; }
.seg button { width: 40px; height: 34px; border: 0; border-radius: 7px; background: transparent; display: grid; place-items: center; }
.seg button i { display: block; width: var(--d); height: var(--d); border-radius: 50%; background: var(--text); }
.seg button.active { background: var(--surface); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }

.font-list { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; flex: 1 1 auto; min-height: 76px; max-height: 300px; overflow: auto; padding: 2px; }
@media (max-width: 520px) { .font-list { grid-template-columns: 1fr; } }
.font-opt {
  height: 70px; padding: 0 14px; border: 1.5px solid var(--border); border-radius: 12px;
  background: #fff; color: var(--ink, #000); font-size: 32px; line-height: 1;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: center;
}
.font-opt.active { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }

.upload-box {
  display: grid; place-items: center; text-align: center; gap: 6px;
  min-height: 170px; padding: 16px; cursor: pointer;
  border: 1.5px dashed var(--border); border-radius: 12px; background: var(--surface-2);
}
.upload-box img { max-width: 100%; max-height: 150px; background: #fff; border-radius: 6px; }

.sig-foot { margin-top: 14px; }
.swatches { display: flex; gap: 8px; }
.swatch { width: 32px; height: 32px; border-radius: 50%; border: 0; background: var(--c); box-shadow: 0 0 0 1px var(--border); }
.swatch.active { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--c); }
.check-label { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); cursor: pointer; }
.check-label input { width: 18px; height: 18px; accent-color: var(--accent); }

.field-label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin: 4px 0 6px; }
.input-suffix { display: flex; align-items: center; gap: 6px; }
.input-suffix span { color: var(--muted); font-weight: 600; }
.export-actions { display: grid; gap: 8px; margin: 16px 0 10px; }
.export-actions .btn { min-height: 50px; }

/* ---------- Overlays ---------- */
.busy {
  position: fixed; inset: 0; z-index: 80; display: grid; place-content: center; justify-items: center; gap: 14px;
  background: color-mix(in srgb, var(--bg) 70%, transparent); backdrop-filter: blur(2px); font-weight: 600;
}
.spinner { width: 36px; height: 36px; border-radius: 50%; border: 3.5px solid var(--border); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast {
  position: fixed; left: 50%; bottom: calc(24px + var(--safe-b)); transform: translateX(-50%);
  z-index: 90; max-width: min(92vw, 480px); padding: 12px 18px;
  background: #1d2433; color: #fff; border-radius: 12px; box-shadow: var(--shadow);
  font-size: 14px; font-weight: 500; text-align: center;
  animation: hint-pop .18s ease-out;
}
.toast.error { background: #b42318; }
.dropzone {
  position: fixed; inset: 10px; z-index: 70; display: grid; place-items: center;
  border: 3px dashed var(--accent); border-radius: 20px; background: color-mix(in srgb, var(--accent-soft) 85%, transparent);
  font-size: 22px; font-weight: 700; color: var(--accent); pointer-events: none;
}

/* ---------- Scanner ---------- */
.scanner, .scanedit {
  position: fixed; inset: 0; z-index: 60;
  display: flex; flex-direction: column; background: #000; color: #fff;
}
.scanedit { z-index: 65; background: #111; }
.scan-top { flex: none; display: flex; align-items: center; gap: 8px; padding: calc(8px + var(--safe-t)) 10px 8px; }
.scan-status { flex: 1; min-width: 0; text-align: center; font-size: 14px; font-weight: 600; color: rgba(255, 255, 255, .92); }
.scan-icon {
  width: 44px; height: 44px; flex: none; border-radius: 50%; border: 0;
  display: grid; place-items: center; background: rgba(255, 255, 255, .14); color: #fff;
}
.scan-icon.on { background: #ffd24d; color: #000; }
.scan-view { flex: 1; position: relative; min-height: 0; overflow: hidden; }
.scan-view video, #scan-overlay { position: absolute; inset: 0; width: 100%; height: 100%; }
.scan-view video { object-fit: contain; }
.scan-flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
.scan-flash.go { animation: shutterfx .35s ease-out; }
@keyframes shutterfx { from { opacity: .85; } to { opacity: 0; } }
.scan-nocam { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 14px; padding: 24px; text-align: center; color: rgba(255, 255, 255, .85); }
.scan-strip { flex: none; display: flex; gap: 8px; overflow-x: auto; padding: 8px 12px 2px; }
.scan-strip:empty { display: none; }
.scan-thumb {
  position: relative; flex: none; width: 50px; height: 64px; padding: 0; overflow: hidden;
  border-radius: 6px; border: 2px solid rgba(255, 255, 255, .75); background: #333;
}
.scan-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.scan-thumb span { position: absolute; right: 2px; bottom: 2px; padding: 0 4px; border-radius: 4px; background: rgba(0, 0, 0, .65); color: #fff; font-size: 11px; font-weight: 700; }
.scan-thumb.busy::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: 20px; height: 20px; margin: -10px 0 0 -10px;
  border-radius: 50%; border: 3px solid rgba(255, 255, 255, .3); border-top-color: #fff; animation: spin .8s linear infinite;
}
.scan-filters { flex: none; display: flex; justify-content: center; gap: 6px; padding: 8px 12px 0; }
.scan-filters button { border: 0; border-radius: 999px; padding: 6px 13px; background: rgba(255, 255, 255, .14); color: #fff; font-size: 13px; font-weight: 600; }
.scan-filters button.active { background: #fff; color: #000; }
.scan-bottom { flex: none; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 10px 18px calc(14px + var(--safe-b)); }
.scan-bottom > :first-child { justify-self: start; }
.scan-shutter { width: 74px; height: 74px; padding: 5px; border-radius: 50%; border: 4px solid #fff; background: transparent; }
.scan-shutter span { display: block; width: 100%; height: 100%; border-radius: 50%; background: #fff; transition: transform .1s; }
.scan-shutter:active span { transform: scale(.88); }
.scan-done { justify-self: end; border: 0; border-radius: 999px; padding: 10px 18px; background: #2557e6; color: #fff; font-weight: 700; font-size: 15px; }
.scan-done:disabled { opacity: .4; }
.scan-text { display: inline-flex; align-items: center; gap: 6px; border: 0; background: transparent; color: #fff; font-weight: 600; padding: 10px 12px; }
.scan-text svg { width: 20px; height: 20px; }
.scan-text.danger { color: #ff7a6e; }
.se-stage { flex: 1; position: relative; min-height: 0; touch-action: none; }
#se-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.se-handle {
  position: absolute; width: 30px; height: 30px; margin: -15px 0 0 -15px; border-radius: 50%;
  border: 3px solid #fff; background: rgba(79, 134, 255, .35); box-shadow: 0 1px 6px rgba(0, 0, 0, .5);
  touch-action: none; cursor: grab;
}
.se-handle::before { content: ""; position: absolute; inset: -14px; }
.se-tools { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 8px calc(14px + var(--safe-b)); }
.se-hint { font-size: 12px; color: rgba(255, 255, 255, .6); text-align: center; }

/* ---------- Phones ---------- */
@media (max-width: 719px) {
  .toolbar {
    order: 3; justify-content: space-around; gap: 0;
    padding: 4px 2px calc(4px + var(--safe-b));
    border-bottom: 0; border-top: 1px solid var(--border);
  }
  .tool { min-width: 0; flex: 1; padding: 0; }
  .topbar .btn { padding: 0 14px; }
  .zoom { bottom: 12px; right: 10px; }
  .pages { padding: 14px 10px 80px; gap: 24px; }
  .sheet-wrap { align-items: flex-end; padding: 0; }
  .sheet {
    max-width: none; border-radius: 18px 18px 0 0; max-height: calc(var(--vv-h, 100dvh) - 8px);
    padding-bottom: calc(18px + var(--safe-b));
  }
  .toast { bottom: calc(86px + var(--safe-b)); }
}
@media (max-width: 380px) {
  .topbar .icon-btn { width: 38px; }
  .topbar .btn span { display: none; }
}
