/* Fast Document Scanner — Phase 1–2 gate UI */

.scanner-cross-nav {
    margin-bottom: 18px;
}

.scanner-root {
    text-align: center;
    padding-bottom: 32px;
}

.scanner-hero-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin: 8px auto 20px;
    padding: 12px 18px;
    background: var(--fw-surface, #FFFFFF);
    border: 1px solid var(--fw-border, #E6E8EC);
    border-radius: var(--fw-radius-lg, 16px);
    box-shadow: var(--fw-shadow-1, 0 1px 2px rgba(15, 23, 42, 0.06));
}

.scanner-hero-logo {
    width: 64px;
    height: 64px;
    border-radius: 16px;
    object-fit: cover;
    flex-shrink: 0;
}

.scanner-hero-title {
    margin: 0;
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.3px;
    color: #0f172a;
    line-height: 1.2;
}

.scanner-hero-sub {
    margin: 4px 0 0;
    font-size: 13px;
    font-weight: 600;
    color: #64748b;
}

.scanner-limitations {
    max-width: 600px;
    margin: 0 auto 14px;
    color: #64748b;
    font-size: 13px;
    line-height: 1.55;
    text-align: center;
    overflow-wrap: anywhere;
}

.scanner-gate {
    max-width: 420px;
    margin: 0 auto;
}

.scanner-gate-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    padding: 28px 22px;
    box-shadow: 0 14px 36px -16px rgba(15, 23, 42, 0.14);
}

.scanner-gate-lead {
    margin: 0 0 18px;
    font-size: 16px;
    font-weight: 700;
    color: #1e293b;
    line-height: 1.55;
}

.scanner-gate-note {
    margin: 16px 0 0;
    font-size: 14px;
    color: #64748b;
    line-height: 1.6;
}

/* ── PC QR gate ── */
.scanner-qr-wrap {
    display: flex;
    justify-content: center;
    margin: 8px auto 14px;
    padding: 16px;
    background: #f8fafc;
    border: 1px dashed #cbd5e1;
    border-radius: 16px;
    min-height: 252px;
    align-items: center;
}

.scanner-qr-wrap canvas,
.scanner-qr-wrap img {
    display: block;
    border-radius: 8px;
}

.scanner-qr-loading {
    font-size: 14px;
    color: #94a3b8;
}

.scanner-pc-url {
    margin: 12px 0 0;
    font-size: 12px;
    font-family: ui-monospace, 'Cascadia Code', Consolas, monospace;
    color: #475569;
    word-break: break-all;
    background: #f1f5f9;
    border-radius: 10px;
    padding: 10px 12px;
}

/* ── Mobile PWA gate ── */
.scanner-pwa-logo {
    width: 112px;
    height: 112px;
    border-radius: 24px;
    object-fit: cover;
    margin: 0 auto 16px;
    display: block;
    box-shadow: 0 12px 30px -10px rgba(99, 102, 241, 0.45);
}

.scanner-pwa-title {
    margin: 0 0 10px;
    font-size: 20px;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.3;
}

.scanner-pwa-copy {
    margin: 0 0 20px;
    font-size: 15px;
    color: #334155;
    line-height: 1.65;
}

.scanner-pwa-copy strong {
    color: #4f46e5;
}

.scanner-pwa-install-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    max-width: 320px;
    margin: 0 auto;
    padding: 14px 18px;
    border: none;
    border-radius: 14px;
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
    color: #ffffff;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 10px 24px -8px rgba(79, 70, 229, 0.55);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    touch-action: manipulation;
}

.scanner-pwa-install-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 14px 28px -8px rgba(79, 70, 229, 0.6);
}

.scanner-pwa-install-btn:active {
    transform: scale(0.98);
}

.scanner-pwa-install-btn:disabled,
.scanner-pwa-install-btn[hidden] {
    display: none;
}

.scanner-ios-guide {
    margin-top: 18px;
    padding: 16px;
    background: #eef2ff;
    border: 1px solid #c7d2fe;
    border-radius: 14px;
    text-align: left;
}

.scanner-ios-guide h3 {
    margin: 0 0 10px;
    font-size: 14px;
    font-weight: 700;
    color: #3730a3;
}

.scanner-ios-guide ol {
    margin: 0;
    padding-left: 20px;
    font-size: 14px;
    color: #334155;
    line-height: 1.7;
}

.scanner-standalone-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 0 auto 14px;
    padding: 8px 14px;
    border-radius: 999px;
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    color: #047857;
    font-size: 13px;
    font-weight: 700;
}

.scanner-phase-note {
    margin-top: 18px;
    font-size: 13px;
    color: #94a3b8;
    line-height: 1.5;
}

.scanner-start-scan-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 320px;
    margin: 14px auto 0;
    padding: 14px 18px;
    border: none;
    border-radius: 14px;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: #ffffff;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 10px 24px -8px rgba(16, 185, 129, 0.5);
    touch-action: manipulation;
}

.scanner-start-scan-btn:active {
    transform: scale(0.98);
}

/* ── Native capture stage (no video stream) ── */
.scanner-camera-stage {
    max-width: 100%;
    margin: 0 auto;
    text-align: center;
}

.scanner-camera-trigger {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    pointer-events: none;
}

.scanner-capture-panel {
    max-width: 420px;
    margin: 0 auto;
    padding: 20px 16px 12px;
    border-radius: 18px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    box-shadow: 0 12px 32px -16px rgba(15, 23, 42, 0.2);
}

.scanner-capture-btn {
    display: block;
    width: 100%;
    margin-top: 12px;
}

.scanner-capture-hint {
    margin: 14px 0 0;
    font-size: 13px;
    line-height: 1.5;
    color: #64748b;
}

.scanner-camera-error {
    margin: 12px auto 0;
    max-width: 420px;
    padding: 12px 14px;
    border-radius: 12px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #b91c1c;
    font-size: 14px;
    line-height: 1.5;
}

.scanner-camera-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 16px 24px;
    margin-top: 18px;
    padding: 8px 0 4px;
}

.scanner-done-btn {
    padding: 10px 18px;
    border: 1px solid #c7d2fe;
    border-radius: 999px;
    background: #eef2ff;
    color: #3730a3;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    touch-action: manipulation;
}

.scanner-done-btn[hidden] {
    display: none;
}

.scanner-done-btn:active {
    transform: scale(0.98);
}

.scanner-shot-counter {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 72px;
    padding: 8px 14px;
    border-radius: 999px;
    background: #eef2ff;
    border: 1px solid #c7d2fe;
    color: #3730a3;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.scanner-shutter-btn {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    border: 4px solid #ffffff;
    background: radial-gradient(circle at 30% 30%, #ffffff 0%, #ef4444 45%, #dc2626 100%);
    box-shadow: 0 0 0 4px #dc2626, 0 12px 28px -8px rgba(220, 38, 38, 0.55);
    cursor: pointer;
    touch-action: manipulation;
    transition: transform 0.1s ease;
}

.scanner-shutter-btn:active:not(:disabled) {
    transform: scale(0.94);
}

.scanner-shutter-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    box-shadow: 0 0 0 4px #94a3b8;
}

/* ── Filename modal (Phase 6 skeleton) ── */
.scanner-modal {
    position: fixed;
    inset: 0;
    z-index: 1200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.scanner-modal[hidden] {
    display: none !important;
}

.scanner-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
}

.scanner-modal-card {
    position: relative;
    width: 100%;
    max-width: 380px;
    padding: 24px 20px;
    border-radius: 18px;
    background: #ffffff;
    box-shadow: 0 24px 48px -20px rgba(15, 23, 42, 0.45);
    text-align: left;
}

.scanner-modal-title {
    margin: 0 0 8px;
    font-size: 20px;
    font-weight: 700;
    color: #0f172a;
}

.scanner-modal-copy {
    margin: 0 0 16px;
    font-size: 14px;
    color: #64748b;
    line-height: 1.55;
}

.scanner-modal-label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 700;
    color: #475569;
}

.scanner-modal-input {
    width: 100%;
    box-sizing: border-box;
    padding: 12px 14px;
    border: 1px solid #cbd5e1;
    border-radius: 12px;
    font-size: 15px;
    color: #0f172a;
    margin-bottom: 16px;
}

.scanner-modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.scanner-modal-btn {
    padding: 10px 16px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    border: none;
}

.scanner-modal-btn--ghost {
    background: #f1f5f9;
    color: #475569;
}

.scanner-modal-btn--primary {
    background: #4f46e5;
    color: #ffffff;
}

.scanner-modal-status {
    margin: -8px 0 14px;
    font-size: 13px;
    color: #6366f1;
    line-height: 1.5;
}

.scanner-modal-status.is-error {
    color: #dc2626;
}

/* ── Phase 5.5: Queue manipulation grid ── */
.scanner-manipulate-card {
    max-width: 420px;
}

.scanner-thumb-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin: 16px 0 18px;
}

.scanner-thumb-cell {
    position: relative;
    aspect-ratio: 3 / 4;
    border-radius: 12px;
    overflow: hidden;
    background: #0f172a;
    border: 2px solid #e2e8f0;
    touch-action: none;
    cursor: grab;
    transition: border-color 0.15s ease, transform 0.15s ease;
}

.scanner-thumb-cell.is-dragging {
    opacity: 0.72;
    transform: scale(0.96);
    border-color: #6366f1;
}

.scanner-thumb-cell.is-drop-target {
    border-color: #22c55e;
    box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.35);
}

.scanner-thumb-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    pointer-events: none;
    user-select: none;
}

.scanner-thumb-badge {
    position: absolute;
    left: 6px;
    bottom: 6px;
    min-width: 22px;
    padding: 2px 7px;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.72);
    color: #ffffff;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.4;
}

.scanner-thumb-delete {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 50%;
    background: rgba(220, 38, 38, 0.92);
    color: #ffffff;
    font-size: 18px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    touch-action: manipulation;
    z-index: 2;
}

.scanner-manipulate-empty {
    grid-column: 1 / -1;
    margin: 8px 0;
    font-size: 14px;
    color: #64748b;
    text-align: center;
}

.scanner-manipulate-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.scanner-manipulate-btn {
    width: 100%;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 700;
    border: none;
    cursor: pointer;
    touch-action: manipulation;
}

.scanner-manipulate-btn--ghost {
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #e2e8f0;
}

.scanner-manipulate-btn--primary {
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
    color: #ffffff;
}

.scanner-manipulate-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

/* ── PDF export options ── */
.scanner-pdf-options {
    margin: 4px 0 14px;
    padding: 12px 14px;
    border-radius: 12px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    text-align: left;
}

.scanner-option-row {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    font-weight: 600;
    color: #334155;
    cursor: pointer;
    margin: 0;
}

.scanner-option-row + .scanner-option-hint {
    margin-top: 4px;
}

.scanner-option-hint {
    margin: 0 0 10px 28px;
    font-size: 12px;
    color: #94a3b8;
    line-height: 1.45;
}

.scanner-option-hint:last-child {
    margin-bottom: 0;
}

.scanner-watermark-input {
    margin-top: 8px;
    margin-bottom: 0 !important;
}

.scanner-watermark-input[hidden] {
    display: none !important;
}

.scanner-complete-modal .scanner-modal-card {
    text-align: center;
}

.scanner-complete-icon {
    font-size: 42px;
    line-height: 1;
    margin-bottom: 8px;
}

.scanner-complete-copy {
    margin: 0 0 20px;
    font-size: 15px;
    color: #475569;
    line-height: 1.65;
    text-align: left;
}

.scanner-complete-copy strong {
    color: #4f46e5;
}

.scanner-complete-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.scanner-complete-btn {
    width: 100%;
    padding: 14px 16px;
    border: none;
    border-radius: 14px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    touch-action: manipulation;
}

.scanner-complete-btn--primary {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: #ffffff;
    box-shadow: 0 10px 24px -8px rgba(16, 185, 129, 0.45);
}

.scanner-complete-btn--share {
    background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%);
    color: #ffffff;
    box-shadow: 0 10px 24px -8px rgba(14, 165, 233, 0.45);
}

.scanner-complete-btn--secondary {
    background: #eef2ff;
    color: #3730a3;
    border: 1px solid #c7d2fe;
}

/* ── Phase 4: Editor + OpenCV loading ── */
.scanner-editor-stage {
    max-width: 100%;
    margin: 0 auto;
}

/* FULL-SCREEN VIEWPORT MONOPOLY — when the manual editor opens it physically
   anchors to the whole screen so the footer / platform-vision box / ad layers
   can never squeeze #scannerEditorViewport and corrupt the handle coordinate
   space. Buried behind the editor at z 999999. */
.scanner-editor-stage:not([hidden]) {
    position: fixed !important;
    inset: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    height: 100dvh !important;
    max-width: none !important;
    margin: 0 !important;
    z-index: 2147483647 !important;
    background: #0f172a !important;
    overflow: hidden !important;
    pointer-events: auto !important;
}

/* Editor + all its descendants breathe; everything else is silenced by JS. */
.scanner-editor-stage:not([hidden]) * {
    pointer-events: auto;
}

.scanner-editor-loading {
    padding: 48px 20px;
    text-align: center;
    pointer-events: none;
}

.scanner-editor-content.scanner-editor-content--reveal {
    animation: scanner-editor-fade-in 0.32s ease-out forwards;
}

@keyframes scanner-editor-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

.scanner-editor-loading p {
    margin: 16px 0 0;
    font-size: 15px;
    font-weight: 600;
    color: #475569;
}

.scanner-spinner {
    width: 44px;
    height: 44px;
    margin: 0 auto;
    border: 4px solid #e2e8f0;
    border-top-color: #6366f1;
    border-radius: 50%;
    animation: scanner-spin 0.85s linear infinite;
}

@keyframes scanner-spin {
    to { transform: rotate(360deg); }
}

.scanner-editor-hint {
    margin: 0 0 12px;
    font-size: 14px;
    color: #64748b;
    line-height: 1.5;
}

.scanner-editor-viewport {
    position: relative;
    width: 100%;
    max-width: 420px;
    margin: 0 auto;
    min-height: 280px;
    border-radius: 16px;
    overflow: hidden;
    background: #0f172a;
}

.scanner-editor-image {
    display: block;
    max-width: 100%;
    user-select: none;
}

.scanner-editor-content {
    position: relative;
    z-index: 5;
}

/* ── CENTER-AXIS CROP LAYOUT (v74) — no flex; absolute center so Cropper
   drag is never left-locked by flex alignment. */
.scanner-editor-stage:not([hidden]) .scanner-editor-content {
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    width: calc(100vw - 28px);
    max-width: 560px;
    height: calc(100dvh - 32px);
    box-sizing: border-box;
    padding: 0 14px calc(12px + env(safe-area-inset-bottom, 0px));
    overflow: hidden;
    z-index: 5;
}

.scanner-editor-stage:not([hidden]) .scanner-editor-hint {
    position: absolute;
    top: 8px;
    left: 0;
    right: 0;
    color: #cbd5e1;
    text-align: center;
    margin: 0;
    padding: 0 4px;
}

.scanner-editor-stage:not([hidden]) .scanner-editor-viewport {
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    width: calc(100% - 8px);
    height: calc(100% - 168px);
    min-height: 260px;
    max-width: none;
    margin: 0;
    border-radius: 12px;
    background: #0f172a;
    overflow: hidden;
}

.scanner-editor-stage:not([hidden]) .scanner-editor-image {
    display: block;
    max-width: 100%;
    max-height: 100%;
}

.scanner-editor-stage:not([hidden]) .cropper-container {
    width: 100% !important;
    height: 100% !important;
}

/* EQUAL HANDLES (v75) — force every corner/edge point to a finger-sized 24px
   target so all four corners feel identically grabbable on any pixel density.
   No aspect lock: drag any point freely in 360°. */
.scanner-editor-stage:not([hidden]) .cropper-point {
    width: 24px !important;
    height: 24px !important;
    background-color: #22c55e !important;
    opacity: 0.85 !important;
    border-radius: 50% !important;
}

/* Re-centre each point on its anchor so the enlarged hitbox stays aligned. */
.scanner-editor-stage:not([hidden]) .cropper-point.point-n { margin-top: -12px !important; margin-left: -12px !important; }
.scanner-editor-stage:not([hidden]) .cropper-point.point-s { margin-bottom: -12px !important; margin-left: -12px !important; }
.scanner-editor-stage:not([hidden]) .cropper-point.point-w { margin-top: -12px !important; margin-left: -12px !important; }
.scanner-editor-stage:not([hidden]) .cropper-point.point-e { margin-top: -12px !important; margin-right: -12px !important; }
.scanner-editor-stage:not([hidden]) .cropper-point.point-ne { margin-top: -12px !important; margin-right: -12px !important; }
.scanner-editor-stage:not([hidden]) .cropper-point.point-nw { margin-top: -12px !important; margin-left: -12px !important; }
.scanner-editor-stage:not([hidden]) .cropper-point.point-se { margin-bottom: -12px !important; margin-right: -12px !important; }
.scanner-editor-stage:not([hidden]) .cropper-point.point-sw { margin-bottom: -12px !important; margin-left: -12px !important; }

/* Cropper hides the side handles below 768px via opacity:0 — force them all
   back on so N/E/S/W are draggable on phones, not just the corners. */
.scanner-editor-stage:not([hidden]) .cropper-point.point-n,
.scanner-editor-stage:not([hidden]) .cropper-point.point-s,
.scanner-editor-stage:not([hidden]) .cropper-point.point-w,
.scanner-editor-stage:not([hidden]) .cropper-point.point-e {
    display: block !important;
    opacity: 0.85 !important;
}

.scanner-editor-stage:not([hidden]) .scanner-editor-actions {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    margin: 0;
    padding-top: 10px;
}

/* ── Inline scan history dock ── */
.scanner-history-strip {
    margin: 14px auto 0;
    max-width: 420px;
    text-align: left;
}

.scanner-history-hint {
    margin: 0 0 8px;
    font-size: 12px;
    font-weight: 600;
    color: #64748b;
    line-height: 1.45;
    text-align: center;
}

.scanner-history-empty {
    margin: 0;
    font-size: 13px;
    color: #94a3b8;
    text-align: center;
    padding: 8px 0;
}

.scanner-history-row {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding: 4px 2px 8px;
    -webkit-overflow-scrolling: touch;
}

.scanner-history-thumb {
    position: relative;
    flex: 0 0 88px;
    width: 88px;
    border-radius: 12px;
    overflow: hidden;
    border: 2px solid #e2e8f0;
    background: #f8fafc;
}

.scanner-history-thumb.is-dragging {
    opacity: 0.65;
    border-color: #6366f1;
}

.scanner-history-thumb.is-drop-target {
    border-color: #22c55e;
    box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.35);
}

.scanner-history-img {
    display: block;
    width: 100%;
    height: 72px;
    object-fit: cover;
    pointer-events: none;
}

.scanner-history-badge {
    position: absolute;
    top: 4px;
    left: 4px;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.78);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 20px;
    text-align: center;
}

.scanner-history-tools {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2px;
    padding: 2px;
    background: #f1f5f9;
}

.scanner-history-tool {
    border: none;
    background: #ffffff;
    color: #334155;
    font-size: 10px;
    font-weight: 700;
    padding: 4px 2px;
    border-radius: 6px;
    cursor: pointer;
    touch-action: manipulation;
}

.scanner-history-tool:disabled {
    opacity: 0.35;
}

.scanner-history-tool--retake {
    grid-column: span 2;
    font-size: 11px;
    color: #4f46e5;
}

.scanner-history-tool--delete {
    color: #dc2626;
    font-size: 14px;
}

.scanner-merge-pdf-btn {
    display: block;
    width: 100%;
    max-width: 420px;
    margin: 10px auto 0;
    padding: 14px 16px;
    border: none;
    border-radius: 14px;
    font-size: 15px;
    font-weight: 700;
    color: #ffffff;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    box-shadow: 0 10px 24px -8px rgba(16, 185, 129, 0.45);
    cursor: pointer;
    touch-action: manipulation;
}

.scanner-merge-pdf-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    box-shadow: none;
}

.scanner-shutter-btn--retake {
    animation: scanner-retake-pulse 0.6s ease-in-out 2;
}

@keyframes scanner-retake-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.5); }
    50% { box-shadow: 0 0 0 12px rgba(99, 102, 241, 0); }
}

.scanner-editor-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 16px;
}

.scanner-editor-btn {
    min-width: 120px;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 700;
    border: none;
    cursor: pointer;
    touch-action: manipulation;
}

.scanner-editor-btn--ghost {
    background: #f1f5f9;
    color: #475569;
}

.scanner-editor-btn--primary {
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
    color: #ffffff;
}

.scanner-editor-btn:disabled {
    opacity: 0.6;
    cursor: wait;
}

@media (max-width: 480px) {
    .scanner-hero-badge {
        flex-direction: column;
        gap: 10px;
        padding: 18px 16px;
    }

    .scanner-hero-title {
        font-size: 20px;
    }

    .scanner-gate-card {
        padding: 22px 16px;
    }
}

/* ── Landscape / tablet: keep the portrait capture box inside the screen.
   width is derived from the 3/4 aspect-ratio so the video stream and the
   overlay canvas remain a single, perfectly aligned box on rotation. ── */
@media (orientation: landscape) and (max-height: 720px) {
    .scanner-viewport,
    .scanner-editor-viewport {
        max-width: none;
        width: auto;
        height: min(74vh, 480px);
        margin-left: auto;
        margin-right: auto;
    }
}

/* ── Wide tablets (iPad / Galaxy Tab) in portrait: allow a larger box. ── */
@media (min-width: 768px) and (orientation: portrait) {
    .scanner-viewport,
    .scanner-editor-viewport {
        max-width: 520px;
    }
}
