/* The viewfinder occupies the viewport throughout preparation and locked preview. */
html:has(body.scan-active), body.scan-active { overflow: hidden; overscroll-behavior: none; }
#editor.scan-screen {
  --scan-safe-top: var(--safe-area-inset-top, env(safe-area-inset-top, 0px));
  --scan-safe-bottom: var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px));
  --scan-gutter: clamp(22px, 5vw, 72px);
  position: fixed; inset: 0; z-index: 10; isolation: isolate;
  min-height: 0; background: #07100d; color: #fff; overflow: hidden; overscroll-behavior: none;
}
.scan-screen .editor-grid, .scan-screen .workspace, .scan-screen .photo-stage,
.scan-screen .editor-comparison {
  position: absolute; inset: 0; display: block; width: 100%; height: 100%; max-width: none;
  max-height: none; min-height: 0; padding: 0; margin: 0; border: 0; border-radius: 0; box-shadow: none;
}
#editor.scan-screen .editor-grid, #editor.scan-screen .workspace { height: 100%; min-height: 0; }
.scan-screen .editor-header {
  position: absolute; z-index: 8; top: var(--scan-safe-top);
  inset-inline-start: max(12px, env(safe-area-inset-left, 0px));
  inset-inline-end: max(12px, env(safe-area-inset-right, 0px));
  height: 64px; margin: 0; padding: 0; max-width: none; grid-template-columns: 48px 1fr 48px;
}
.scan-screen .editor-title { text-align: center; font-size: 14px; letter-spacing: .01em; color: white; text-shadow: 0 1px 8px #07130de0; }
.scan-screen #back-home { color: white; width: 44px; height: 44px; border: 1px solid #ffffff38; background: #101b17a8; border-radius: 50%; }
.scan-screen .edit-panel, .scan-screen .photo-labels, .scan-screen .photo-footnote { display: none; }
.scan-screen .editor-comparison { background: #0a1410; }
.scan-screen #natural-layer { background-size: cover; background-color: transparent; filter: blur(30px) brightness(.42); transform: scale(1.12); }
.scan-screen #original-layer, .scan-screen #veil-layer, #scan-edges {
  position: absolute; inset: auto; left: var(--picture-left, 0px); top: var(--picture-top, 0px);
  width: var(--picture-w, 100%); height: var(--picture-h, 100%);
}
.scan-screen #original-layer, .scan-screen #veil-layer { background-size: 100% 100%; background-color: transparent; }
.scan-screen #original-layer.sample-beauty, .scan-screen #veil-layer.sample-beauty { background-size: 200% 100%; }
.scan-screen .editor-comparison::after {
  content: ""; position: absolute; z-index: 3; inset: 0; pointer-events: none;
  background: linear-gradient(180deg, #03100dd4 0%, #06110d42 14%, transparent 26%, transparent 54%, #07150f55 74%, #04120ef2 100%);
}
.scan-screen.is-locked .editor-comparison::after {
  background: linear-gradient(180deg, #06140dc9, transparent 23%, transparent 78%, #05100c61);
}
.preparation-overlay { position: absolute; z-index: 4; inset: 0; pointer-events: none; overflow: hidden; }
.scan-band {
  position: absolute; inset: 0; overflow: hidden; background: #042a2357;
  -webkit-mask-image: linear-gradient(90deg, transparent calc(var(--scan-cut) - 20%), #000 calc(var(--scan-cut) - 6%), #000 var(--scan-cut), transparent var(--scan-cut));
  mask-image: linear-gradient(90deg, transparent calc(var(--scan-cut) - 20%), #000 calc(var(--scan-cut) - 6%), #000 var(--scan-cut), transparent var(--scan-cut));
}
.scan-raster {
  position: absolute; inset: 0; opacity: .55;
  background-image: radial-gradient(#a4ffe4 0.85px, transparent 1.2px); background-size: 12px 12px;
}
.scan-gate {
  position: absolute; left: max(10%, calc(50% - 240px)); right: max(10%, calc(50% - 240px));
  top: max(17%, calc(var(--scan-safe-top) + 70px)); bottom: 26%; pointer-events: none;
}
.scan-gate i { position: absolute; width: 18px; height: 18px; color: #c5ffe8b8; border: 0 solid currentColor; }
.scan-gate i:nth-child(1) { top: 0; left: 0; border-width: 1px 0 0 1px; }
.scan-gate i:nth-child(2) { top: 0; right: 0; border-width: 1px 1px 0 0; }
.scan-gate i:nth-child(3) { bottom: 0; left: 0; border-width: 0 0 1px 1px; }
.scan-gate i:nth-child(4) { bottom: 0; right: 0; border-width: 0 1px 1px 0; }
.scan-scale { position: absolute; top: 20%; bottom: 28%; inset-inline-end: max(12px, env(safe-area-inset-right,0px)); width: 6px; opacity: .72; background: repeating-linear-gradient(0deg,#d5ffed 0 1px, transparent 1px 12px); }
.scan-screen .preparation-state {
  position: absolute; z-index: 6; inset-inline: var(--scan-gutter); bottom: calc(var(--scan-safe-bottom) + clamp(29px, 6vh, 64px));
  padding: 0; margin: 0 auto; max-width: 660px; color: white; pointer-events: none;
}
.scan-readout { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; margin: 0 0 20px; }
.scan-readout [role=status] { min-width: 0; }
.scan-readout strong,.scan-readout small { display: block; overflow-wrap: anywhere; }
.scan-readout small { color: #c2ffe5; font-size: clamp(12px, 2.9vw, 15px); font-weight: 550; margin-bottom: 5px; }
.scan-readout strong { color: white; font-size: clamp(24px, 6.5vw, 42px); line-height: 1.12; font-weight: 630; letter-spacing: -.035em; }
.scan-meter { display: flex; align-items: flex-end; flex-direction: column; gap: 6px; flex: none; }
#scan-histogram { width: 50px; height: 15px; opacity: .92; }
.scan-readout output { color: #effff7; font: 500 18px/1 ui-monospace,SFMono-Regular,monospace; font-variant-numeric: tabular-nums; direction:ltr; }
.preparation-progress { height: 3px; background: #ffffff41; border-radius: 3px; overflow: hidden; }
.preparation-progress span { display:block; height:100%; background:#83f4c7; transform-origin:left; transform:scaleX(var(--progress,0)); }
[dir=rtl] .preparation-progress span { transform-origin:right; }

.editor-comparison { --scan-cut: 25%; }
.mask-veil, .eye-lens { pointer-events: none; position: absolute; }
.mask-veil {
  inset: 0; z-index: 1; opacity: 0; visibility: hidden; overflow: hidden;
  transition: opacity .42s ease;
  background: #5e6a611c;
}
.is-locked .mask-veil, .eye-detail .mask-veil { opacity: 1; visibility: visible; }
/* Only the separate sample viewer uses the original split illustration. */
.eye-detail:not(.scan-screen) .mask-veil {
  -webkit-mask-image: linear-gradient(90deg, transparent calc(25% - 10px), #000 25%);
  mask-image: linear-gradient(90deg, transparent calc(25% - 10px), #000 25%);
}
.is-locked #original-layer { visibility: hidden; }
#veil-layer { filter: blur(clamp(9px, 3.1vmin, 14px)) saturate(.88); transform: scale(1.035); }
.locked-preview {
  position: absolute; z-index: 5; inset: auto 0 0; max-height: 65%; overflow-y: auto;
  display: grid; justify-items: center; align-content: start; gap: 14px;
  padding: 58px max(20px,env(safe-area-inset-right,0px)) calc(max(20px,var(--scan-safe-bottom)) + 8px) max(20px,env(safe-area-inset-left,0px));
  background: linear-gradient(transparent, #091b14ad 45%, #091b14eb);
}
#locked-prompt {
  max-width: 28rem; margin: 0; color: #fff; font-size: clamp(1.35rem, 6vw, 2rem);
  line-height: 1.18; font-weight: 700; text-align: center; text-wrap: balance; overflow-wrap: anywhere;
}
.scan-unlock {
  display: inline-flex; justify-content: center; align-items: center; gap: 10px; width: min(100%, 380px); min-height: 52px;
  padding: 12px 18px; border: 0; border-radius: 14px; color: #103324; background: #b2f2d0;
  font: inherit; font-weight: 700; font-size: 16px; line-height: 1.35; cursor: pointer; overflow-wrap: anywhere;
}
.scan-unlock svg, .preview-modes svg { width: 18px; height: 18px; flex: none; }
.scan-unlock:focus-visible, .preview-modes button:focus-visible, .scan-screen #back-home:focus-visible { outline: 3px solid white; outline-offset: 3px; }
.scan-unlock:active { background: #94e4b9; }
.preview-modes {
  display: flex; align-self: center; justify-content: center; width: fit-content; max-width: 95%;
  margin: 3px auto 10px; padding: 3px; gap: 2px; border-radius: 14px; background: #e7eee8; z-index: 6;
}
.preview-modes button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 4px 12px; font-size: 13px; color: #465e50; border-radius: 11px; overflow-wrap: anywhere; }
.preview-modes button[aria-pressed="true"] { background: white; color: #193b2b; box-shadow: 0 1px 3px #172b2124; }
.eye-lens { display: none; z-index: 4; top: 0; left: 0; width: 100%; height: 100%; --eye-x: 62.2%; --eye-y: 37.1%; --radius: clamp(20px,6vmin,48px); }
.eye-detail .eye-lens { display: block; }
.eye-detail #original-layer { clip-path: none; }
.eye-detail :is(.split-line,.comparison-range,.photo-labels,#panel-description) { display: none; }
.eye-detail:not(.scan-screen) #natural-layer { visibility: hidden; }
.lens-plane { position: absolute; inset: 0; }
.lens-content { position: absolute; inset: 0; clip-path: circle(var(--radius) at var(--eye-x) var(--eye-y)); }
.lens-content .portrait { background-size: 100% 100%; background-repeat: no-repeat; }
.lens-content :is(.sample-beauty,.sample-natural) { background-size: 200% 100%; }
.lens-content .sample-natural { animation: reveal-eye .8s ease both; }
.lens-outline { position: absolute; left: var(--eye-x); top: var(--eye-y); width: calc(2 * var(--radius)); height: calc(2 * var(--radius)); border: 1.5px solid #d8ffeb; border-radius: 50%; transform: translate(-50%, -50%); box-shadow: 0 0 0 3px #1b352537; }
#eye-caption { position: absolute; top: calc(100% + 6px); left: 50%; transform: translateX(-50%); width: max-content; max-width: min(11em,42vw); text-align: center; overflow-wrap: anywhere; background: #132a23eb; color: white; border-radius: 6px; padding: 3px 8px; font-size: .6875rem; line-height: 1.35; }
@keyframes reveal-eye { 0%,35% { opacity: 0; } 100% { opacity: 1; } }
@media (orientation: landscape) and (max-height: 500px) {
  .scan-screen .editor-header { height: 52px; }
  .scan-screen .preparation-state { bottom: max(15px, var(--scan-safe-bottom)); }
  .scan-readout { margin-bottom: 8px; } .scan-readout strong { font-size: 24px; }
}
@media (prefers-reduced-motion: reduce) { .scan-band { display: none; } .mask-veil { transition: none; } .lens-content .sample-natural { animation: none; } }
/* Keep the focus target available to assistive technology after the scan. */
.is-locked #mobile-editor-title { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.eye-labels {
  position: absolute; z-index: 4; left: var(--eye-pair-center, 50%); top: var(--eye-pair-top, 35%);
  width: min(54%, 228px); margin: 0; transform: translateX(-50%); pointer-events: none;
  animation: uncover-eye .4s ease-out both;
}
.eye-labels[hidden] { display: none; }
.eye-labels canvas {
  display: block; width: 100%; height: auto; border-radius: 9px;
  outline: 1px solid #ffffff69; box-shadow: 0 2px 8px #0c191f24;
}
.eye-labels figcaption {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); justify-items: center;
  align-items: start; gap: 4px; margin-top: 5px; direction: ltr;
}
.eye-labels figcaption span {
  max-width: 100%; padding: 3px 8px; border-radius: 6px; background: #24332e; color: #fff;
  font-size: .6875rem; font-weight: 650; line-height: 1.25; text-align: center; overflow-wrap: anywhere;
}
#locked-result { background: #b2f2d0; color: #102f23; }
@keyframes uncover-eye { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .eye-labels { animation: none; } }
.scan-change { display: inline-flex; align-items: center; justify-content: center; gap: 7px; margin-top: -8px; color: #deeee4; min-height: 44px; padding: 4px 12px; font-size: .8125rem; }
.scan-change svg { width: 15px; height: 15px; flex: none; }
[dir=rtl] .locked-preview { direction: rtl; }
@media (max-height: 500px) {
  .locked-preview { gap: 6px; padding-top: 20px; padding-bottom: max(3px,var(--scan-safe-bottom)); }
  #locked-prompt { font-size: 1.2rem; }
  .scan-unlock { min-height: 46px; }
  .scan-change { margin-top: 0; }
}
