/* Сакта · «Скан документа». One action per step, big targets (≥ 48 px), no option menus
   (the Chairman is 61, after a stroke — ТЗ-Сакта-скан-и-пометки §0). */
body.scan-open { overflow: hidden; }
/* audit-4 №4: at the bottom the toast covered «Стикер · Стрелка · Рамка» — in the scanner it sits under the title */
body.scan-open .toast { top: calc(var(--tg-safe-area-inset-top, 0px) + env(safe-area-inset-top) + 64px); bottom: auto; z-index: 40; }
.scanner { position: fixed; inset: 0; z-index: 30; background: var(--bg); display: flex; flex-direction: column;
  padding-bottom: var(--safe-b); animation: up .22s var(--ease); }
.sc-top { display: grid; grid-template-columns: 48px 1fr 48px; align-items: center; padding: 8px 8px 4px; flex: none; }
.sc-top h2 { margin: 0; text-align: center; font-size: 17px; font-weight: 800; }
.sc-x, .sc-undo { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 14px; }
.sc-undo:disabled { opacity: .3; }
.sc-body { overflow-y: auto; padding: 4px 16px 32px; flex: 1; max-width: 640px; width: 100%; margin: 0 auto; }
.sc-row { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.sc-row .grow, .sc-bar .grow { flex: 1; }

/* home */
.sc-shoot { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 8px; min-height: 96px;
  border-radius: var(--r-lg); background: var(--accent-fill); color: #fff; font-size: 20px; font-weight: 800;
  box-shadow: 0 8px 24px rgba(0,102,204,.35); cursor: pointer; }
.sc-shoot .ic { width: 30px; height: 30px; }
.sc-gal { width: 100%; text-align: left; }
.sc-draft { margin-top: 4px; }
.sc-item { display: grid; grid-template-columns: 76px 1fr; gap: 12px; padding: 10px; border-radius: var(--r);
  background: var(--surface); border: 1px solid var(--line); }
.sc-item img, .sc-noimg { width: 76px; height: 100px; object-fit: cover; border-radius: 10px; background: #fff; }
.sc-noimg { display: grid; place-items: center; background: var(--surface-2); color: var(--muted); }
.sc-meta b { display: block; font-size: 15px; line-height: 1.3; }
.sc-meta small { color: var(--muted); font-size: 13px; }
.sc-meta .sc-row { margin-top: 8px; }
.sc-meta .btn { min-height: 44px; }

/* corners */
.sc-tip { margin: 0 16px 8px; text-align: center; color: var(--muted); font-size: 14px; flex: none; }
.sc-cwrap { flex: 1; position: relative; display: grid; place-items: center; margin: 0 12px; padding: 26px; min-height: 0; overflow: hidden; }
.sc-cwrap canvas { display: block; border-radius: 6px; }
.sc-quad { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); touch-action: none; }
.sc-quad .q { fill: rgba(77,159,230,.16); stroke: #4D9FE6; stroke-width: 2.5; }
.sc-quad .h { fill: rgba(0,102,204,.25); stroke: #fff; stroke-width: 3; }
.sc-quad .c { fill: #fff; }

/* editor */
.sc-modes { display: flex; gap: 8px; align-items: center; padding: 0 12px 6px; flex: none; }
.sc-modes .seg { flex: 1; }
.sc-modes .btn { min-height: 44px; }
.sc-stage { flex: 1; min-height: 0; margin: 0 8px; border-radius: 12px; background: var(--surface-2); overflow: hidden; touch-action: none; }
.sc-selbar, .sc-colors { display: flex; gap: 10px; justify-content: center; padding: 8px 12px 0; flex: none; }
.sc-selbar .btn { min-height: 48px; }
.sc-colors button { width: 48px; height: 48px; border-radius: 50%; background: var(--c); border: 3px solid transparent; }
.sc-colors button.on { border-color: var(--text); }
.sc-tools { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; padding: 8px 8px 0; flex: none; }
.sc-tools button { display: flex; flex-direction: column; align-items: center; gap: 3px; min-height: 60px; padding: 8px 2px;
  border-radius: 14px; background: var(--surface); border: 1px solid var(--line); font-size: 12.5px; font-weight: 700; color: var(--muted); }
.sc-tools button.on { background: var(--accent-fill); border-color: var(--accent-fill); color: #fff; }
.sc-tools .ic { width: 24px; height: 24px; }
.sc-pages { display: flex; gap: 6px; padding: 8px 12px 0; overflow-x: auto; flex: none; }
.sc-pages button { min-width: 44px; height: 40px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); font-weight: 700; }
.sc-pages button.on { border-color: var(--accent); color: var(--accent); }
.sc-pages .sc-pdel { padding: 0 12px; color: var(--bad); font-weight: 600; white-space: nowrap; }
.sc-bar { display: flex; gap: 8px; padding: 10px 12px 10px; flex: none; }
.sc-bar .btn { min-height: 52px; font-size: 16px; }

/* busy + modal */
.sc-busy { position: absolute; inset: 0; z-index: 3; display: flex; flex-direction: column; gap: 14px; align-items: center;
  justify-content: center; background: color-mix(in srgb, var(--bg) 82%, transparent); font-weight: 700; font-size: 16px; }
.sc-busy .spinner { width: 42px; height: 42px; border-radius: 50%; border: 4px solid var(--line-strong);
  border-top-color: var(--accent); animation: sc-spin .8s linear infinite; }
@keyframes sc-spin { to { transform: rotate(360deg); } }
.sc-modal { position: absolute; inset: 0; z-index: 4; display: grid; place-items: center; padding: 16px;
  background: rgba(0,0,0,.45); }
.sc-mcard { width: 100%; max-width: 480px; background: var(--surface); border-radius: var(--r-lg); padding: 18px; }
.sc-mcard textarea { width: 100%; margin-top: 10px; padding: 12px; border-radius: 12px; border: 1px solid var(--line-strong);
  background: var(--surface-2); color: var(--text); font: 600 18px/1.35 var(--font); resize: none; }
.sc-mcard .btn { min-height: 50px; font-size: 16px; }
@media (prefers-reduced-motion: reduce) { .scanner { animation: none; } .sc-busy .spinner { animation-duration: 2s; } }

/* stage 2: text */
.sc-modes #scText.done { border-color: var(--ok); color: var(--ok); }
.sc-textcard { max-height: 86vh; display: flex; flex-direction: column; }
.sc-text { margin-top: 10px; padding: 12px; border-radius: 12px; background: var(--surface-2); white-space: pre-wrap;
  font-size: 16px; line-height: 1.5; overflow-y: auto; flex: 1; min-height: 120px; user-select: text; -webkit-user-select: text; }
.sc-search { margin: 0 0 10px; }
.sc-hit { margin: 6px 0 0; font-size: 13px; color: var(--muted); line-height: 1.35; }
.sc-hit mark { background: var(--accent-soft); color: var(--text); border-radius: 3px; padding: 0 2px; }
