/* Escanear documento + Foto 3x4 — ferramentas de câmera (complementa styles.css e studio.css) */
.cap { --q: var(--accent); }
.cap-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; min-width: 0; }
.cap-h { font-family: var(--display); font-size: 20px; letter-spacing: -.02em; margin: 0; }
.cap-wide { width: 100%; }

/* ---- Tela inicial ---- */
.cap-start { max-width: 760px; margin: 0 auto; text-align: center; background: var(--surface); border: 2px dashed var(--line-2); border-radius: 24px; padding: 32px 20px 26px; box-shadow: var(--shadow); transition: border-color .2s, background .2s; }
body.cap-dragging .cap-start, .cap-start.over { border-color: var(--accent); background: var(--accent-soft); }
.cap-art { width: 104px; height: 104px; margin: 0 auto 6px; }
.cap-art svg { width: 100%; height: 100%; overflow: visible; }
.cap-art .a-paper { fill: var(--bg-2); stroke: var(--line-2); stroke-width: 2; transform-origin: 60px 60px; transform: rotate(-6deg); }
.cap-art .a-line { stroke: var(--muted); stroke-width: 3; stroke-linecap: round; opacity: .55; transform-origin: 60px 60px; transform: rotate(-6deg); }
.cap-art .a-corner { fill: none; stroke: var(--accent); stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; }
.cap-art .a-face { fill: var(--bg-2); stroke: var(--line-2); stroke-width: 2; }
.cap-art .a-oval { fill: none; stroke: var(--muted); stroke-width: 3; stroke-dasharray: 5 6; opacity: .7; }
.cap-title { font-family: var(--display); font-size: 24px; letter-spacing: -.02em; font-weight: 800; margin: 4px 0 4px; }
.cap-sub { color: var(--ink-2); margin: 0 auto 20px; max-width: 460px; }
.cap-btns { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.cap-btn { min-height: 56px; min-width: 220px; cursor: pointer; }
.cap-btn .ic { width: 22px; height: 22px; }
.cap-drop-hint { margin: 14px 0 0; font-size: 13px; color: var(--muted); }
.cap-tips { list-style: none; padding: 0; margin: 18px auto 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; max-width: 620px; }
.cap-tips li { font-size: 13px; color: var(--ink-2); background: var(--bg); border: 1px solid var(--line); border-radius: 99px; padding: 6px 12px; display: inline-flex; align-items: center; gap: 6px; }
.cap-tips li::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--zap); box-shadow: 0 0 0 1.5px color-mix(in srgb, var(--zap) 40%, var(--ink)); }
.cap-privacy { display: flex; align-items: flex-start; justify-content: center; gap: 7px; margin: 18px auto 0; font-size: 13px; color: var(--muted); max-width: 520px; text-align: left; }
.cap-privacy .ic { width: 16px; height: 16px; flex: none; margin-top: 2px; color: var(--img); }
.cap-privacy.small { font-size: 12px; margin-top: 4px; justify-content: flex-start; }

/* ---- Barra fixa (celular) ---- */
.cap-dock { display: none; }
@media (max-width: 860px) {
  .cap-dock:not([hidden]) { display: flex; gap: 8px; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(12px); border-top: 1px solid var(--line); box-shadow: 0 -8px 24px -16px rgba(0,0,0,.3); }
  .cap-dock .btn { min-height: 50px; }
  .cap-dock-cam { cursor: pointer; flex: none; background: var(--surface); }
  .cap-dock-main { flex: 1; }
  body.cap-has-dock { padding-bottom: 76px; }
}

/* ================= ESCANEAR ================= */
.sc-ws { display: flex; flex-direction: column; gap: 14px; }
.sc-strip-wrap { overflow-x: auto; margin: 0 -16px; padding: 4px 16px 6px; scrollbar-width: thin; }
.sc-strip { list-style: none; margin: 0; padding: 0; display: flex; gap: 10px; width: max-content; }
.sc-thumb { flex: none; position: relative; }
.sc-thumb > button, .sc-thumb > label { width: 70px; height: 92px; border-radius: 12px; border: 2px solid var(--line); background: var(--surface); padding: 0; cursor: pointer; display: grid; place-items: center; overflow: hidden; position: relative; transition: border-color .15s, transform .15s; }
.sc-thumb img { width: 100%; height: 100%; object-fit: contain; background: var(--bg-2); display: block; pointer-events: none; }
.sc-thumb.on > button { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.sc-thumb.dragging { opacity: .4; }
.sc-thumb.over > button { transform: translateX(6px); border-color: var(--accent); }
.sc-num { position: absolute; left: 4px; bottom: 4px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 99px; background: var(--ink); color: var(--bg); font-size: 11.5px; font-weight: 700; display: grid; place-items: center; }
.sc-thumb.on .sc-num { background: var(--accent); color: var(--accent-ink); }
.sc-thumb-busy { position: absolute; inset: 0; display: grid; place-items: center; background: color-mix(in srgb, var(--surface) 55%, transparent); }
.sc-thumb-busy .pg-loading { width: 22px; height: 22px; }
.sc-add > label { border-style: dashed; color: var(--accent); font-size: 12px; font-weight: 600; gap: 2px; align-content: center; }
.sc-add > label:hover { border-color: var(--accent); background: var(--accent-soft); }
.sc-add .ic { width: 24px; height: 24px; }

.sc-main { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 16px; align-items: start; }
.sc-view { padding: 12px; }
.sc-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin: 0 2px 10px; }
.sc-page-label { font-weight: 700; font-size: 14px; }
.sc-note { font-size: 12.5px; color: var(--img); font-weight: 600; display: inline-flex; align-items: center; gap: 5px; }
.sc-note:not(:empty)::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.sc-note.warn { color: var(--biz); }
.sc-hint { margin: 0 2px 8px; font-size: 13.5px; color: var(--ink-2); }

.sc-result { position: relative; display: grid; place-items: center; background: var(--bg-2); border-radius: 12px; padding: 14px; min-height: 260px; }
.sc-result img { display: block; max-width: 100%; max-height: min(64vh, 680px); box-shadow: 0 2px 12px rgba(0,0,0,.18); background: #fff; }
.sc-busy { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 10px; font-size: 14px; font-weight: 600; color: var(--ink); background: color-mix(in srgb, var(--surface) 60%, transparent); border-radius: 12px; backdrop-filter: blur(1px); }
.sc-filters { margin-top: 12px; }
.sc-filters button { min-height: 40px; }
.sc-tools { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-top: 10px; }
.sc-tool { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 56px; border: 1px solid var(--line); background: var(--bg); color: var(--ink-2); border-radius: 12px; cursor: pointer; font-size: 12px; font-weight: 600; padding: 6px 2px; }
.sc-tool:hover:not(:disabled) { background: var(--bg-2); color: var(--ink); }
.sc-tool:disabled { opacity: .4; cursor: default; }
.sc-tool.danger:hover:not(:disabled) { background: var(--pdf-soft); color: var(--pdf); border-color: color-mix(in srgb, var(--pdf) 30%, var(--line)); }
.sc-all { display: block; margin: 10px auto 0; border: 0; background: none; color: var(--accent); font-weight: 600; font-size: 13.5px; cursor: pointer; padding: 8px; border-radius: 8px; }
.sc-all:hover { background: var(--accent-soft); }

/* editor de cantos */
.sc-editor { background: #15121f; border-radius: 12px; padding: 18px; display: grid; place-items: center; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.sc-stage { position: relative; line-height: 0; }
.sc-stage img { display: block; max-width: 100%; max-height: min(62vh, 640px); -webkit-user-drag: none; }
.sc-svg { position: absolute; left: 0; top: 0; overflow: visible; touch-action: none; }
.sc-shade { fill: rgba(10, 8, 20, .45); pointer-events: none; }
.sc-quad { fill: color-mix(in srgb, var(--q) 10%, transparent); stroke: var(--q); stroke-width: 2.5; stroke-linejoin: round; pointer-events: none; }
.sc-quad.bad { stroke: var(--pdf); fill: color-mix(in srgb, var(--pdf) 14%, transparent); }
.sc-corner, .sc-mid { cursor: grab; }
.sc-svg.dragging .sc-corner, .sc-svg.dragging .sc-mid { cursor: grabbing; }
.sc-corner .hit, .sc-mid .hit { fill: transparent; }
.sc-corner .knob { fill: rgba(255,255,255,.18); stroke: #fff; stroke-width: 3; filter: drop-shadow(0 1px 2px rgba(0,0,0,.5)); }
.sc-corner:hover .knob, .sc-corner:active .knob { fill: var(--q); }
.sc-mid .knob { fill: #fff; stroke: var(--q); stroke-width: 2; }
.sc-loupe { position: absolute; width: 120px; height: 120px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 4px 18px rgba(0,0,0,.45); pointer-events: none; z-index: 2; }
.sc-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; align-items: center; }
.sc-actions .btn:not(.sm) { min-height: 46px; }
.sc-actions .btn.sm { min-height: 40px; }

/* exportação */
.sc-export { display: flex; flex-direction: column; gap: 14px; position: sticky; top: 80px; }
.sc-export .seg button { min-height: 40px; }
.cap-name { display: flex; align-items: center; border: 1px solid var(--line-2); border-radius: 11px; background: var(--bg); overflow: hidden; }
.cap-name:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field .cap-name input { box-shadow: none; border: 0; border-radius: 0; width: auto; }
.cap-name input { flex: 1; min-width: 0; height: 42px; border: 0; background: transparent; color: var(--ink); font: inherit; padding: 0 0 0 12px; outline: none; }
.cap-name span { padding: 0 12px 0 2px; color: var(--muted); }
.cap-add-more { cursor: pointer; }
.sc-next { animation: pop .25s ease; }
.sc-next-title { margin: 0 0 12px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.sc-ok { width: 24px; height: 24px; border-radius: 50%; background: var(--zap); color: var(--zap-ink); display: grid; place-items: center; font-size: 13px; font-weight: 800; }
.sc-next .chip { color: var(--ink); }

@media (max-width: 860px) {
  .sc-main { grid-template-columns: 1fr; }
  .sc-export { position: static; }
  .sc-export #pdfBtn { display: none; }
}
@media (max-width: 640px) {
  .cap-start { padding: 24px 14px 20px; border-radius: 20px; }
  .cap-btn { width: 100%; min-width: 0; }
  .cap-title { font-size: 21px; }
  .sc-view { padding: 10px; margin: 0 -6px; }
  .sc-result { padding: 8px; min-height: 200px; }
  .sc-editor { padding: 14px 12px; margin: 0 -4px; }
  .sc-filters { display: grid; grid-template-columns: 1fr 1fr; }
  .sc-filters button { padding: 7px 6px; font-size: 13.5px; }
  .sc-tool { font-size: 11px; }
  .sc-actions .st-spacer { flex-basis: 100%; height: 0; }
  .sc-actions .btn:not(.sm) { flex: 1; }
  .sc-actions .btn.sm { flex: 1; }
}

/* ================= FOTO 3x4 ================= */
.ft-ws { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 16px; align-items: start; }
.ft-editor { padding: 12px; position: sticky; top: 80px; }
.ft-stage { position: relative; width: 100%; max-width: 560px; margin: 0 auto; aspect-ratio: 5 / 5.6; border-radius: 12px; overflow: hidden; background: #2a2735; touch-action: none; user-select: none; -webkit-user-select: none; cursor: grab; }
.ft-stage.grabbing { cursor: grabbing; }
.ft-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.ft-frame { position: absolute; box-shadow: 0 0 0 9999px rgba(18, 14, 32, .62); outline: 2px solid #fff; pointer-events: none; }
.ft-frame svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.ft-guide { fill: none; stroke: var(--zap); stroke-width: 2; stroke-dasharray: 7 6; filter: drop-shadow(0 0 1.5px rgba(0,0,0,.7)); }
.ft-guide-line { stroke: var(--zap); stroke-width: 1.5; stroke-dasharray: 3 5; filter: drop-shadow(0 0 1.5px rgba(0,0,0,.7)); }
.ft-guide-text { fill: var(--zap); font: 600 11px var(--font); paint-order: stroke; stroke: rgba(0,0,0,.55); stroke-width: 3px; }
.ft-frame.noguide svg { display: none; }
.ft-dims { position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); font-size: 12px; font-weight: 600; color: #fff; background: rgba(0,0,0,.45); padding: 3px 10px; border-radius: 99px; pointer-events: none; white-space: nowrap; }
.ft-ctrls { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; margin-top: 14px; }
.ft-ctrl { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.ft-ctrl .label button { border: 0; background: none; color: var(--accent); font-size: 12px; font-weight: 600; cursor: pointer; padding: 0; }
.ft-ctrl input[type=range] { width: 100%; accent-color: var(--accent); height: 28px; margin: 0; }
.ft-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; align-items: center; }
.ft-row .btn { min-height: 42px; }
.ft-switch { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 500; cursor: pointer; min-height: 42px; padding: 0 4px; }
.ft-switch input { width: 18px; height: 18px; accent-color: var(--accent); margin: 0; }
.ft-help { font-size: 12.5px; color: var(--muted); margin: 8px 0 0; text-align: center; }

.ft-side { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.ft-presets { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.ft-preset { text-align: left; border: 1.5px solid var(--line); background: var(--bg); border-radius: 12px; padding: 9px 11px; cursor: pointer; min-height: 58px; display: flex; flex-direction: column; justify-content: center; gap: 1px; color: var(--ink); }
.ft-preset b { font-size: 14.5px; }
.ft-preset span { font-size: 12px; color: var(--muted); line-height: 1.3; }
.ft-preset:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); }
.ft-preset[aria-checked="true"] { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 1px var(--accent) inset; }
.ft-preset[aria-checked="true"] span { color: var(--ink-2); }
.ft-custom { display: flex; gap: 10px; margin-top: 10px; align-items: end; }
.ft-custom .field { width: auto; flex: 1; }
.ft-custom .x { padding-bottom: 11px; color: var(--muted); }
.ft-spec { font-size: 13px; color: var(--ink-2); margin: 6px 0 0; }
.ft-spec b { color: var(--ink); }
.ft-out { display: flex; flex-direction: column; gap: 12px; }
.ft-out .field select { width: 100%; height: 44px; }
.ft-result { font-size: 13px; color: var(--img); font-weight: 600; margin: -2px 0 0; min-height: 18px; }
.ft-sheet-prev { display: grid; place-items: center; background: var(--bg-2); border-radius: 12px; padding: 14px; }
.ft-sheet-prev canvas { max-width: 100%; max-height: 300px; box-shadow: 0 2px 10px rgba(0,0,0,.18); background: #fff; }
.ft-count { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: 14px; }
.ft-count i { font-style: normal; background: var(--zap); color: var(--zap-ink); padding: 1px 8px; border-radius: 99px; }
.ft-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ft-btns .btn { min-height: 46px; padding-left: 10px; padding-right: 10px; }
.ft-tip { font-size: 12.5px; color: var(--ink-2); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; margin: 0; }
.ft-good { margin: 0; padding: 0; list-style: none; display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; font-size: 13px; color: var(--ink-2); }
.ft-good li { display: flex; gap: 6px; align-items: flex-start; }
.ft-good li::before { content: "✓"; color: var(--img); font-weight: 800; }

@media (max-width: 900px) {
  .ft-ws { grid-template-columns: 1fr; }
  .ft-editor { position: static; }
}
@media (max-width: 640px) {
  .ft-editor { padding: 10px; margin: 0 -6px; }
  .ft-ctrls { gap: 10px 14px; }
  .ft-good { grid-template-columns: 1fr; }
  .ft-btns { grid-template-columns: 1fr; }
}
.sc-next, .sc-mode, .sc-view, .ft-out { scroll-margin-top: 84px; }
.ft-result:empty { display: none; }
