html.scanner-active,
html.scanner-active body { overflow: hidden !important; overscroll-behavior: none; }
html.host-upload-active,
html.host-upload-active body { overflow: hidden !important; overscroll-behavior: none; }
html.embedded-upload-active,
html.embedded-upload-active body { overflow: hidden !important; overscroll-behavior: none; }

.document-scanner { position: fixed; inset: 0; z-index: 10000; overflow: hidden; color: #fff; background: #090b12; font-family: Inter, Roboto, sans-serif; }
.document-scanner video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.scanner-shade { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(4,7,15,.64), transparent 22%, transparent 72%, rgba(4,7,15,.72)); pointer-events: none; }
.scanner-topbar { position: absolute; inset: max(14px, env(safe-area-inset-top)) 16px auto; display: grid; grid-template-columns: 48px 1fr 48px; align-items: center; gap: 10px; text-align: center; }
.scanner-topbar strong { font-size: 1.05rem; text-shadow: 0 2px 8px #000; }
.scanner-close { width: 46px; height: 46px; padding: 0; border: 1px solid rgba(255,255,255,.3); border-radius: 50%; color: #fff; background: rgba(9,11,18,.55); font-size: 2rem; line-height: 1; backdrop-filter: blur(8px); }
.scanner-guide { --detected-ratio: 1.58; position: absolute; top: 50%; left: 50%; width: min(86vw, calc(52vh * var(--detected-ratio)), 680px); aspect-ratio: var(--detected-ratio); border: 1px solid rgba(255,255,255,.32); border-radius: 18px; box-shadow: 0 0 0 100vmax rgba(2,5,12,.22); transform: translate(-50%, -50%); transition: border-color .18s ease, box-shadow .18s ease; pointer-events: none; }
.scanner-guide.detected { border-color: rgba(255,255,255,.88); box-shadow: 0 0 12px rgba(255,255,255,.12), 0 0 0 100vmax rgba(2,5,12,.2); }
.scanner-guide.tracking { border-color: rgba(255,255,255,.68); }
.scanner-guide span { position: absolute; width: 34px; height: 34px; border-color: #fff; border-style: solid; }
.scanner-guide span:nth-child(1) { top: -2px; left: -2px; border-width: 4px 0 0 4px; border-radius: 16px 0 0; }
.scanner-guide span:nth-child(2) { top: -2px; right: -2px; border-width: 4px 4px 0 0; border-radius: 0 16px 0 0; }
.scanner-guide span:nth-child(3) { bottom: -2px; right: -2px; border-width: 0 4px 4px 0; border-radius: 0 0 16px; }
.scanner-guide span:nth-child(4) { bottom: -2px; left: -2px; border-width: 0 0 4px 4px; border-radius: 0 0 0 16px; }
.scanner-guide.detected span { border-color: #fff; }
.scanner-status { position: absolute; right: 18px; bottom: calc(58px + env(safe-area-inset-bottom)); left: 18px; color: #fff; font-size: 1rem; font-weight: 750; text-align: center; text-shadow: 0 2px 9px #000; }
.scanner-native-fallback { position: absolute; right: 24px; bottom: calc(92px + env(safe-area-inset-bottom)); left: 24px; min-height: 52px; padding: 12px 18px; border: 1px solid rgba(255,255,255,.35); border-radius: 999px; color: #fff; background: #6d4ce9; font: inherit; font-weight: 800; box-shadow: 0 12px 32px rgba(0,0,0,.3); }
.scanner-native-fallback[hidden] { display: none; }
.scanner-native-fallback:not([hidden]) + .scanner-progress { display: none; }
.scanner-progress { position: absolute; right: 15%; bottom: calc(38px + env(safe-area-inset-bottom)); left: 15%; height: 5px; overflow: hidden; border-radius: 99px; background: rgba(255,255,255,.24); }
.scanner-progress i { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #20cfa1, #79f2d1); transition: width .12s linear; }

@media (orientation: landscape) {
    .scanner-guide { width: min(68vw, calc(72vh * var(--detected-ratio)), 720px); }
}
