/* A deliberately light scanner. Camera chrome stays translucent white and the
   fluorescent green is reserved for actions, progress and captured targets. */
:root{
  color-scheme:light;

  --bg:#f7faf2;
  --surface:#ffffff;
  --surface-2:#eef3e8;
  --overlay:rgba(255,255,255,.72);  /* chrome floating over the camera */
  --fill:rgba(27,39,16,.12);

  --ink:#12170d;
  --muted:rgba(30,40,22,.64);
  --faint:rgba(30,40,22,.34);
  --line:rgba(49,67,34,.18);

  --accent:#9cff00; --accent-rgb:156,255,0;
  --green:#76f000;  --green-rgb:118,240,0;
  --danger:#e23d32; --danger-rgb:226,61,50;
  --orange:#d97706; --orange-rgb:217,119,6;
  --on-accent:#10150a;

  --r-lg:16px;
  --r:12px;
  --space-1:4px;
  --space-2:8px;
  --space-3:12px;
  --space-4:16px;
  --space-5:24px;
  --font:-apple-system,BlinkMacSystemFont,"SF Pro Text","SF Pro Display","Helvetica Neue",system-ui,sans-serif;
  --pad:max(16px,env(safe-area-inset-left));

  /* Scanner roles, named for what they mean during a scan. */
  --label:var(--ink);
  --label-2:var(--muted);
  --label-3:var(--faint);
  --separator:var(--line);
  --blue:var(--accent); --blue-rgb:var(--accent-rgb);
  --red:var(--danger);  --red-rgb:var(--danger-rgb);
  --captured:var(--green); --captured-rgb:var(--green-rgb);
  --adjust:var(--orange);
  --paused:var(--danger); --paused-rgb:var(--danger-rgb);
  --glass:rgba(255,255,255,.68);
  --glass-strong:rgba(247,250,242,.82);
  --glass-stroke:var(--line);
  --panel-over-camera:rgba(255,255,255,.70);
  --r-modal:var(--r-lg);
  --r-card:var(--r);
}

*{box-sizing:border-box}
[hidden]{display:none!important}
html,body{height:100%}
body{
  margin:0; background:var(--bg); color:var(--label); overflow:hidden;
  font:17px/1.35 var(--font);
  -webkit-font-smoothing:antialiased; -webkit-tap-highlight-color:transparent;
}
button{font:inherit}
button:focus-visible,a:focus-visible,select:focus-visible,input:focus-visible{outline:3px solid var(--blue); outline-offset:3px}
.visually-hidden{position:absolute!important; width:1px; height:1px; overflow:hidden; clip:rect(0 0 0 0); white-space:nowrap}

/* Quiet footer metadata, available without debug mode or tracker startup. */
.scan-version{
  display:block; flex:0 0 auto; color:rgba(30,40,22,.48); font-size:10px; line-height:12px;
  font-weight:400; font-variant-numeric:tabular-nums; white-space:nowrap;
}
.footer-version{align-self:flex-start; justify-self:start; text-align:left}
.diagnostic-reference{user-select:all; white-space:normal; overflow-wrap:anywhere}
.scanner-privacy-link{align-self:flex-start; margin-top:-8px; padding:4px 0; color:var(--muted); font-size:12px; line-height:16px; text-underline-offset:3px}
body.privacy-page{height:auto; min-height:100%; overflow:auto; padding:24px max(20px,env(safe-area-inset-right)) 32px max(20px,env(safe-area-inset-left))}
.privacy-page main{max-width:640px; margin:0 auto; line-height:1.65}
.privacy-page header{display:flex; align-items:center; justify-content:space-between; gap:16px}
.privacy-page h1{font-size:24px; line-height:1.3}
.sheet-heading{display:flex; align-items:center; justify-content:space-between; gap:12px}
.sheet-heading h1{margin:0; min-width:0}
.heading-tools{display:flex; align-items:center; justify-content:flex-end; gap:8px; flex:0 0 auto}
.language-switch{
  display:inline-flex; align-items:center; justify-content:center; flex:0 0 auto;
  min-width:48px; min-height:44px; padding:8px 10px; border:1px solid var(--line); border-radius:12px;
  background:var(--overlay); color:var(--ink); font-size:13px; font-weight:650; line-height:1; cursor:pointer;
}
.language-switch:focus{outline:none}
.language-switch:focus-visible{text-decoration:underline; text-underline-offset:4px}
.language-switch:active{background:var(--surface-2)}
.dialog-toolbar{display:flex; justify-content:flex-end; padding:6px 12px; background:var(--bg)}
.scan-demo .dialog-toolbar{align-items:center; gap:12px}
.dialog-title{margin:0 auto 0 0; font-size:18px; font-weight:650; line-height:1.3; text-align:left}
.ear-check .dialog-toolbar{align-items:center; gap:12px; padding:0; margin:-12px -12px 8px 0; background:transparent}
.setup-heading .heading-tools{gap:4px}
.setup-heading .setup-help{padding:10px 8px}
.hud-caption{display:flex; align-items:center; justify-content:center; flex-wrap:wrap; gap:4px 10px}

/* Upload is a separate, lazy-loaded step; these controls never overlay capture. */
.upload-dialog{width:min(580px,calc(100% - 28px)); max-height:calc(100dvh - 28px); box-sizing:border-box; padding:20px 20px 8px; border:1px solid var(--line); border-radius:22px; background:var(--panel,#fff); color:var(--ink,#1e2816); overflow:auto}
.upload-dialog::backdrop{background:rgba(0,0,0,.48); backdrop-filter:blur(6px)}
.upload-heading{display:flex; align-items:center; justify-content:space-between; gap:12px}
.upload-heading h2{min-width:0; font-size:22px; margin:0; overflow-wrap:anywhere}
.upload-dialog p{font-size:15px; line-height:1.5; margin:12px 0; overflow-wrap:anywhere}
.upload-dialog button{touch-action:manipulation}
.upload-dialog form{min-width:0; max-width:100%}
.upload-dialog .primary-button,.upload-dialog>.ghost-button{width:100%}
.upload-dialog>.ghost-button{margin-top:8px}
.prescription-choices{min-width:0; min-inline-size:0; max-width:100%; padding:0; margin:18px 0; border:0; display:grid; grid-template-columns:minmax(0,1fr); gap:8px}
.prescription-choices legend{font-size:16px; font-weight:600; margin-bottom:10px}
.prescription-option{position:relative; display:block; min-width:0; cursor:pointer; touch-action:manipulation}
.prescription-option>span{display:flex; align-items:center; min-height:48px; padding:12px; border:1px solid var(--line); border-radius:12px; background:var(--surface-2); color:var(--ink); font-size:15px; line-height:1.4; overflow-wrap:anywhere}
.prescription-option input:checked+span{background:var(--accent); border-color:var(--accent); color:var(--on-accent); font-weight:650}
.prescription-option input:focus-visible+span{outline:2px solid var(--ink); outline-offset:2px}
.prescription-option input:disabled+span{opacity:.6; cursor:default}
.prescription-file,.prescription-notes{display:grid; min-width:0; gap:10px; padding:12px; border:1px solid var(--line); border-radius:12px; font-size:15px}
/* Separate the selected method from its fields, without widening the fieldset. */
.prescription-file,.manual-prescription{margin-top:14px}
.prescription-file{min-height:148px; padding:20px 16px; gap:16px; align-content:center; border:2px solid var(--green); background:rgba(var(--green-rgb),.04); cursor:pointer}
.prescription-file>span{font-weight:600; line-height:1.4}
.prescription-file input{display:block; width:100%; min-width:0; max-width:100%; font:inherit; font-size:14px; line-height:1.4; color:var(--muted); cursor:inherit}
/* Keep the native camera/photo/file picker, with a comfortably sized touch target.
   Separate the WebKit fallback so older Safari cannot invalidate the standard rule. */
.prescription-file input::-webkit-file-upload-button{min-height:48px; max-width:100%; padding:12px 16px; margin:0 10px 0 0; border:0; border-radius:10px; background:var(--accent); color:var(--on-accent); font:inherit; font-size:16px; font-weight:650; cursor:inherit}
.prescription-file input::file-selector-button{min-height:48px; max-width:100%; padding:12px 16px; margin:0 10px 0 0; border:0; border-radius:10px; background:var(--accent); color:var(--on-accent); font:inherit; font-size:16px; font-weight:650; cursor:inherit}
.prescription-choices:disabled .prescription-file{opacity:.6; cursor:default}
.manual-prescription{min-width:0; display:grid; grid-template-columns:minmax(0,1fr); gap:20px}
/* Always enter the right eye first, then the left. Labels and DOM order remain
   explicit, so distinguishing the eyes does not depend on color alone. */
.prescription-eye-od{--eye-color:#1557b0; --eye-background:#eef6ff}
.prescription-eye-os{--eye-color:#a3420c; --eye-background:#fff3e6}
.manual-prescription fieldset{min-width:0; min-inline-size:0; margin:0; padding:12px; border:2px solid var(--eye-color); border-radius:12px; background:var(--eye-background)}
.manual-prescription legend{max-width:100%; margin-bottom:8px; padding:6px 12px; border-radius:8px; background:var(--eye-color); color:#fff; font-size:20px; font-weight:750; line-height:1.4; overflow-wrap:anywhere}
.prescription-eye-fields{min-width:0; display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:12px; align-items:end}
.manual-prescription label{display:grid; min-width:0; gap:6px; margin:0; font-size:14px}
.manual-prescription label>span{line-height:1.45; overflow-wrap:anywhere}
.manual-prescription select,.prescription-notes textarea{width:100%; min-width:0; max-width:100%; box-sizing:border-box; font:inherit; font-size:16px; padding:10px; border:1px solid var(--line); border-radius:8px; background:#fff; color:#1e2816}
.prescription-notes textarea{resize:vertical}
.upload-dialog .upload-privacy{font-size:13px; color:var(--muted)}
.upload-dialog progress{width:100%; accent-color:#6e9300; margin-bottom:12px}
.upload-success{text-align:center; margin-top:20px}
.submission-code{display:grid; gap:8px; padding:20px 8px; width:100%; border:1px solid var(--line); border-radius:16px; color:inherit; background:rgba(156,255,0,.14); cursor:pointer; font-size:14px}
.submission-code strong{font-size:clamp(30px,8vw,48px); letter-spacing:.08em; user-select:all}
.upload-dialog [hidden]{display:none!important}

/* Code recovery is a normal page, not another camera-permission dialog. */
#recentSheet .sheet-inner{min-height:100%; display:flex; flex-direction:column; gap:16px; padding-top:calc(env(safe-area-inset-top) + 16px); padding-bottom:calc(env(safe-area-inset-bottom) + 8px)}
#recentSheet .sheet-inner>*{min-width:0; margin:0}
#recentSheet .sheet-heading{margin-bottom:8px}
#recentSheet h2{font-size:24px; line-height:1.25; font-weight:600; overflow-wrap:anywhere}
.recent-metadata{display:grid; gap:4px; font-size:13px; line-height:1.5; color:var(--muted)}
.recent-code{border-color:var(--green); cursor:pointer; touch-action:manipulation}
.recent-copy-status{font-size:14px; line-height:1.4; color:#4d7f00}
.recent-copy-status:empty{display:none}
#recentSheet #startNewScanButton{margin-top:8px}
#recentSheet .sheet-inner>.footer-version{margin-top:auto; padding-top:8px}

#stage{position:fixed; inset:0; overflow:hidden}
#cam{
  display:block; position:fixed!important; inset:0!important;
  width:100vw!important; height:100dvh!important; min-width:100vw; min-height:100dvh;
  max-width:none!important; max-height:none!important; object-fit:cover!important; object-position:center center;
  background:var(--bg);
}
#cam.mirror{transform:scaleX(-1)}
#overlay{position:absolute; inset:0; width:100%; height:100%; pointer-events:none}

/* Calm, directional edge light: no flashing, and no extra circles to align. */
.frame-edges{position:absolute; inset:0; pointer-events:none}
.frame-edge{
  position:absolute; display:flex; align-items:center; justify-content:center;
  color:#fff; font-size:44px; font-style:normal; font-weight:700;
  text-shadow:0 1px 5px #000; transition:opacity .18s linear;
}
.frame-edge.left,.frame-edge.right{
  width:clamp(26px,7vw,60px); transform:translateY(-50%);
  -webkit-mask-image:linear-gradient(to bottom,transparent,#000 35%,#000 65%,transparent);
  mask-image:linear-gradient(to bottom,transparent,#000 35%,#000 65%,transparent);
  transition:opacity .3s linear,top .18s linear,height .18s linear;
}
.frame-edge.top,.frame-edge.bottom{
  height:clamp(26px,7vh,60px); transform:translateX(-50%);
  -webkit-mask-image:linear-gradient(to right,transparent,#000 35%,#000 65%,transparent);
  mask-image:linear-gradient(to right,transparent,#000 35%,#000 65%,transparent);
  transition:opacity .3s linear,left .18s linear,width .18s linear;
}
.frame-edge.left{top:var(--edge-left-position,50%); height:var(--edge-left-span,20%)}
.frame-edge.right{top:var(--edge-right-position,50%); height:var(--edge-right-span,20%)}
.frame-edge.top{left:var(--edge-top-position,50%); width:var(--edge-top-span,20%)}
.frame-edge.bottom{left:var(--edge-bottom-position,50%); width:var(--edge-bottom-span,20%)}
.frame-edge.left{left:0; opacity:var(--edge-left,0); border-left:5px solid var(--red); background:linear-gradient(to right,rgba(var(--red-rgb),.8),transparent)}
.frame-edge.right{right:0; opacity:var(--edge-right,0); border-right:5px solid var(--red); background:linear-gradient(to left,rgba(var(--red-rgb),.8),transparent)}
.frame-edge.top{top:0; opacity:var(--edge-top,0); border-top:5px solid var(--red); background:linear-gradient(to bottom,rgba(var(--red-rgb),.8),transparent)}
.frame-edge.bottom{bottom:0; opacity:var(--edge-bottom,0); border-bottom:5px solid var(--red); background:linear-gradient(to top,rgba(var(--red-rgb),.8),transparent)}

/* ── HUD ─────────────────────────────────────────────── */
#hud{position:absolute; inset:0; display:flex; flex-direction:column; justify-content:space-between; pointer-events:none}
.hud-top{
  display:flex; flex-direction:column; gap:12px; pointer-events:auto;
  padding:calc(env(safe-area-inset-top) + 12px) var(--pad) 0;
}
.hud-row{display:flex; align-items:center; gap:10px; justify-content:space-between}

/* ScanHUDChip: one visual language for every floating control. */
.icon-button{
  flex:0 0 auto; width:48px; height:48px; border-radius:50%; border:1px solid var(--glass-stroke);
  color:var(--ink); background:var(--overlay);
  font-size:16px; line-height:1; cursor:pointer;
  box-shadow:0 8px 24px rgba(18,23,13,.09),inset 0 1px 0 rgba(255,255,255,.72);
}
.hud-chip{
  display:inline-flex; align-items:center; gap:6px; min-height:30px; max-width:calc(100vw - 126px);
  padding:7px 11px; border-radius:14px;
  border:1px solid var(--line); background:var(--overlay);
  color:var(--ink); font-size:11px; line-height:1.35; font-weight:600; white-space:pre-line;
  font-variant-numeric:tabular-nums;
  box-shadow:0 8px 24px rgba(18,23,13,.08),inset 0 1px 0 rgba(255,255,255,.68);
}
.debug-readout{position:relative; min-width:0}
#debugChip{width:100%; text-align:left; cursor:pointer; -webkit-appearance:none; appearance:none}
#debugChip:active{border-color:var(--accent)}
.debug-copy-status{
  position:absolute; z-index:2; top:calc(100% + 6px); left:50%; transform:translateX(-50%);
  width:max-content; max-width:calc(100vw - 32px); padding:6px 12px; border-radius:99px;
  background:var(--ink); color:#fff; font-size:12px; line-height:1.35; text-align:center;
  box-shadow:0 4px 14px rgba(18,23,13,.15); pointer-events:none;
}
.debug-copy-status:empty{display:none}
/* ScanGuidanceCard: a light frosted panel over the live camera. */
.guidance-card{
  display:flex; flex-direction:column; gap:5px; padding:14px 16px; border-radius:var(--r-card);
  max-width:520px; width:100%; align-self:center;
  background:var(--panel-over-camera);
  border:1px solid var(--glass-stroke);
  box-shadow:0 12px 36px rgba(18,23,13,.10),inset 0 1px 0 rgba(255,255,255,.74);
  transition:border-color .22s ease;
}
.guidance-card.complete{border-color:rgba(var(--captured-rgb),.62)}
.guidance-card.paused{border-color:rgba(var(--paused-rgb),.72)}
.guidance-card.framing{border-color:var(--adjust)}
.guidance-card.framing strong{font-size:24px}
.guidance-card.framing small{font-size:18px; line-height:1.4; color:var(--label)}
.guidance-card strong{
  display:block; font-size:22px; font-weight:600; line-height:1.2;
  text-align:left; color:var(--label);
}
.guidance-card small{display:block; font-size:15px; text-align:left; color:var(--label-2); line-height:1.4}
.guidance-card.warn strong{color:var(--adjust)}
.guidance-card.bad strong{color:var(--paused)}
.guidance-card.good strong{color:var(--captured)}

/* ── Bottom controls: the app's shutter ──────────────── */
.hud-bottom{
  pointer-events:auto; display:flex; flex-direction:column; align-items:center; gap:10px;
  padding:12px var(--pad) calc(env(safe-area-inset-bottom) + 6px);
  background:linear-gradient(transparent,rgba(247,250,242,.72) 48%,rgba(247,250,242,.86));
}
.hud-bottom>.footer-version{margin-top:-7px}
.caption{font-size:13px; font-weight:500; color:var(--label-2); text-align:center}
.progress-track{
  width:min(240px,70vw); height:5px;
  overflow:hidden; border-radius:99px; background:var(--fill);
}
#progressFill{display:block; height:100%; border-radius:inherit; background:var(--blue); transition:width .3s}

/* ── Sheets: iOS grouped screens over the camera ──────── */
.sheet{
  position:absolute; inset:0; overflow-y:auto; -webkit-overflow-scrolling:touch;
  background:var(--bg);
}
#reviewSheet,#stoppedSheet{
  background:rgba(247,250,242,.84);
  -webkit-backdrop-filter:saturate(1.1) blur(20px);
  backdrop-filter:saturate(1.1) blur(20px);
}
.sheet::before{
  content:""; position:fixed; z-index:3; top:0; left:0; right:0; height:4px;
  background:linear-gradient(90deg,var(--accent),#d8ff6d 60%,var(--accent));
  box-shadow:0 0 18px rgba(var(--accent-rgb),.65);
}
.sheet-inner{
  max-width:460px; margin:0 auto; padding:calc(env(safe-area-inset-top) + 26px) var(--pad)
  calc(env(safe-area-inset-bottom) + 26px);
}
h1{margin:0 0 6px; font-size:22px; font-weight:600; letter-spacing:.35px}
.lede{margin:0 0 20px; color:var(--muted); font-size:15px; line-height:1.5}
.lede b{color:var(--label); font-weight:600}

/* Setup is already part of the scan: show the face at camera scale and float
   only the essential controls over it. */
#setupSheet{
  background:linear-gradient(to bottom,rgba(247,250,242,.58),transparent 23%);
}
#setupSheet .sheet-inner{
  max-width:none; min-height:100%; padding-top:calc(env(safe-area-inset-top) + 12px);
  padding-bottom:0; display:flex; flex-direction:column;
}
.setup-heading{
  display:flex; align-items:center; justify-content:space-between; margin-bottom:12px; position:relative; z-index:1;
  align-self:center; width:min(100%,460px); min-height:52px; padding:5px 8px 5px 14px;
  border:1px solid var(--line); border-radius:18px; background:var(--overlay);
  box-shadow:0 8px 28px rgba(26,35,18,.08);
}
.setup-heading .setup-brand-name{font-size:18px; margin:0; white-space:nowrap; letter-spacing:0}
/* Original Faysics Fit mark, served locally with the reference site's badge. */
.setup-brand-group{display:flex; align-items:center; gap:8px; min-width:0; flex:0 0 auto}
.setup-brand{
  display:grid; place-items:center; flex:0 0 auto; width:38px; height:38px; overflow:hidden;
  background:#d8ee72; border:1px solid #2e483a24; border-radius:50%; box-shadow:0 5px 14px #2e483a1f;
}
.setup-brand img{display:block; width:21px; height:25px; object-fit:contain}
.setup-help{margin-left:auto; padding:12px; min-height:44px; border:0; background:transparent; color:#4d7f00; font:inherit; font-size:14px; font-weight:600; cursor:pointer}
@media (max-width:360px){
  .setup-brand{width:32px; height:32px}
  .setup-brand img{width:18px; height:22px}
  .setup-brand-group{gap:7px}
  .setup-heading .setup-brand-name{font-size:15px}
  .setup-heading .setup-help{font-size:12px; padding:10px 4px}
  .setup-heading .language-switch{min-width:44px; padding:8px}
}
#setupSheet .card-group{background:none; border:0; margin:0}
#setupSheet .light-card{padding:0; border:0; background:none}
#setupSheet .light-card strong{font-size:20px; font-weight:600; color:inherit}
#setupSheet #lightAdvice{font-size:17px; color:inherit}
#setupSheet .setup-error{margin:0}
.camera-quality{
  display:inline-flex; align-items:center; justify-content:center; align-self:center;
  min-height:28px; margin:0; padding:5px 10px; border:1px solid rgba(var(--accent-rgb),.5);
  border-radius:99px; background:rgba(var(--accent-rgb),.12); color:#3f6800;
  font-size:12px; font-weight:650; letter-spacing:.1px;
}
.camera-quality::before{content:""; width:7px; height:7px; margin-right:7px; border-radius:50%; background:var(--accent); box-shadow:0 0 10px rgba(var(--accent-rgb),.9)}
.camera-quality.bad{border-color:rgba(var(--red-rgb),.45); background:rgba(var(--red-rgb),.1); color:var(--red)}
.camera-quality.bad::before{background:var(--red); box-shadow:none}
.capture-options{
  display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:var(--space-2);
  align-items:stretch; margin:0; text-align:left;
}
.capture-option,.toggle-option{
  min-width:0; border:1px solid var(--line); border-radius:11px; background:var(--surface-2);
}
.capture-option{display:flex; flex-direction:column; align-items:stretch; justify-content:center; gap:1px; padding:5px 8px}
.capture-option>span{color:var(--label-2); font-size:11px; font-weight:600}
.capture-option select{
  width:100%; min-width:0; border:0; background:transparent; color:var(--label); font:inherit;
  font-size:13px; font-weight:700;
}
.toggle-option{
  display:flex; align-items:center; justify-content:flex-start; gap:8px; min-height:48px; padding:6px 10px;
  color:var(--label); font-size:12px; font-weight:650; white-space:nowrap;
}
.toggle-option input{width:17px; height:17px; margin:0; accent-color:var(--accent)}

.steps{list-style:none; margin:0 0 20px; padding:0; display:flex; flex-direction:column; gap:10px}
.steps li{display:flex; gap:12px; align-items:center}
.steps i{
  flex:0 0 26px; height:26px; border-radius:50%; display:grid; place-items:center;
  background:var(--fill); color:var(--blue); font-style:normal; font-size:13px; font-weight:600;
}
.steps span{color:var(--label-2); font-size:15px}

/* An inset-grouped list row, the way Settings draws one. */
.card-group{border-radius:var(--r); background:var(--surface); overflow:hidden; margin-bottom:16px}
.light-card{padding:14px 16px; border-left:3px solid transparent}
.light-card strong{display:block; font-size:16px; font-weight:600}
.light-card.checking{border-left-color:var(--label-3)}
.light-card.ok{border-left-color:var(--green)}
.light-card.warn{border-left-color:var(--orange)}
.light-card.bad{border-left-color:var(--red)}
.light-card.ok strong{color:var(--green)}
.light-card.warn strong{color:var(--orange)}
.light-card.bad strong{color:var(--red)}
#lightAdvice{margin:4px 0 0; color:var(--label-2); font-size:15px}

.setup-error{
  padding:12px 14px; border-radius:var(--r); margin-bottom:14px; font-size:15px;
  background:rgba(var(--red-rgb),.16); color:var(--red);
}

/* .borderedProminent, .controlSize(.large). */
.primary-button{
  width:100%; min-height:50px; padding:15px; border:0; border-radius:var(--r); cursor:pointer;
  background:var(--accent); color:var(--on-accent); font-size:17px; font-weight:700;
  box-shadow:0 8px 24px rgba(var(--accent-rgb),.2);
}
.primary-button:disabled{background:var(--fill); color:var(--faint); cursor:default}
/* Tutorial, preparation notice and Start scan share the same primary action. */
.primary-button.scan-action{
  min-height:56px; font-size:20px; border-radius:22px;
  box-shadow:0 8px 28px rgba(0,0,0,.16);
}
.primary-button.scan-action:disabled{background:rgba(240,247,230,.76); color:rgba(20,33,10,.56)}
.primary-button.scan-action:active:not(:disabled){filter:brightness(.9)}
/* Dialog autofocus must not add a second ring. Keep a non-ring keyboard cue. */
.primary-button.scan-action:focus{outline:none}
.primary-button.scan-action:focus-visible{text-decoration:underline; text-decoration-thickness:2px; text-underline-offset:4px}
.ghost-button{
  display:block; width:100%; min-height:50px; padding:15px; margin-top:10px; border-radius:var(--r);
  border:1px solid var(--line); background:var(--surface-2); color:var(--ink); cursor:pointer;
  font-size:17px; font-weight:400; text-align:center; text-decoration:none;
}
.setup-row{display:flex; gap:10px}

.review-warnings{
  padding:12px 14px; border-radius:var(--r); margin-bottom:16px; font-size:15px; color:var(--orange);
  background:rgba(var(--orange-rgb),.14);
}
.review-warnings p{margin:0 0 6px}
.review-warnings p:last-child{margin:0}
.review-summary{display:grid; grid-template-columns:104px minmax(0,1fr); align-items:center; gap:14px; padding:14px; border:1px solid var(--line); border-radius:var(--r); background:var(--surface)}
.review-preview{position:relative; width:104px; height:138px}
.review-video{display:block; width:104px; height:138px; object-fit:contain; border-radius:10px; background:var(--bg)}
.review-play{position:absolute; left:50%; top:50%; transform:translate(-50%,-50%); display:grid; place-items:center; width:44px; height:44px; padding:12px; border:0; border-radius:50%; background:rgba(18,23,13,.65); color:#fff; cursor:pointer; touch-action:manipulation}
.review-play svg{width:18px; height:18px; pointer-events:none}
.review-error-details{padding:12px; border:1px solid var(--line); border-radius:var(--r); background:var(--surface-2); color:var(--muted); font-size:12px; white-space:pre-wrap; overflow-wrap:anywhere}
.review-meta{display:grid; gap:12px; min-width:0; margin:0}
.review-meta div{display:grid; gap:3px}
.review-meta dt{color:var(--muted); font-size:12px; line-height:1.4}
.review-meta dd{margin:0; color:var(--ink); font-size:14px; line-height:1.5; font-weight:600; overflow-wrap:anywhere; font-variant-numeric:tabular-nums}

/* Sheets use one spacing rhythm instead of a stack of unrelated margins. */
#reviewSheet .sheet-inner,#stoppedSheet .sheet-inner{display:flex; flex-direction:column; gap:var(--space-3)}
#reviewSheet .sheet-inner>*,#stoppedSheet .sheet-inner>*{margin-top:0; margin-bottom:0}
#reviewSheet .ghost-button,#stoppedSheet .ghost-button{margin-top:0}
/* Metadata gets only a 3px gap, not another full control-sized gap. */
#reviewSheet .sheet-inner>.footer-version,#stoppedSheet .sheet-inner>.footer-version{margin-top:calc(3px - var(--space-3))}
#reviewSheet .sheet-inner,#stoppedSheet .sheet-inner{padding-bottom:calc(env(safe-area-inset-bottom) + 8px)}

/* ── The demonstration ───────────────────────────────── */
/* The dialog is an inset-grouped panel, not a tinted one: surface, hairline,
   modal corner — the same recipe as .result-panel on the home page. */
.scan-demo{
  position:relative; width:min(720px,calc(100% - 24px)); max-height:calc(100svh - 24px); padding:0;
  border:1px solid var(--separator); border-radius:var(--r-modal);
  background:rgba(255,255,255,.84); color:var(--label); overflow:auto;
  -webkit-backdrop-filter:saturate(1.12) blur(20px);
  backdrop-filter:saturate(1.12) blur(20px);
  box-shadow:0 24px 80px rgba(0,0,0,.16);
}
.scan-demo::backdrop,.ear-check::backdrop{
  background:rgba(8,12,5,.42);
  -webkit-backdrop-filter:blur(6px);
  backdrop-filter:blur(6px);
}
.demo-scene{
  position:relative; height:clamp(240px,34svh,340px); overflow:hidden;
  background:radial-gradient(ellipse at 35% 45%,var(--surface-2),var(--bg) 75%);
}
.demo-scene canvas{position:absolute; inset:0; display:block; width:100%; height:100%}
.demo-scene>p{position:absolute; z-index:3; inset:48px 0 0; margin:0; display:grid; place-items:center; padding:24px; text-align:center; color:var(--label-2); background:var(--bg)}
.demo-view-labels{
  position:absolute; z-index:2; inset:14px 0 auto; display:grid; grid-template-columns:64% 36%;
  text-align:center; pointer-events:none;
}
.demo-view-labels strong{display:block; font-size:13px; font-weight:600; line-height:1.25}
.demo-view-labels span{display:block; margin-top:3px; color:var(--label-2); font-size:11px; line-height:1.25}
.demo-phone-frame{
  position:absolute; z-index:1; box-sizing:border-box; border:8px solid #222526; border-radius:22px;
  box-shadow:0 0 0 1px #747878,0 5px 12px rgba(0,0,0,.14); pointer-events:none;
}
.demo-phone-frame::before{
  content:""; position:absolute; top:3px; left:50%; width:30%; max-width:38px; height:5px;
  transform:translateX(-50%); border-radius:4px; background:#222526;
}
.demo-phone-frame::after{
  content:""; position:absolute; bottom:4px; left:50%; width:35%; height:3px;
  transform:translateX(-50%); border-radius:3px; background:#222526;
}
.demo-copy{padding:24px 24px 8px}
.demo-instructions{margin:0; color:var(--label-2); font-size:16px; line-height:1.5}
.demo-instructions strong{color:var(--label); font-weight:500}
.demo-recovery-note{margin:0 0 14px; font-size:21px; font-weight:600; line-height:1.35; color:var(--label)}
.demo-exit{display:block; margin-top:12px}
.ear-check{
  width:min(420px,calc(100% - 32px)); max-height:calc(100svh - 24px); overflow:auto; padding:24px 24px 8px; border:1px solid var(--separator); border-radius:var(--r-modal);
  background:rgba(255,255,255,.86); color:var(--label); box-shadow:0 24px 80px rgba(0,0,0,.16);
  -webkit-backdrop-filter:saturate(1.12) blur(20px);
  backdrop-filter:saturate(1.12) blur(20px);
}
.ear-check>h2{margin:0 0 8px; font-size:20px; font-weight:600; letter-spacing:.38px}
.ear-check p{margin:0 0 20px; color:var(--muted); font-size:15px; line-height:1.5}

/* ── Adaptive layout ─────────────────────────────────── */
@media (max-width:390px){
  .hud-row{gap:7px}
  .guidance-card strong{font-size:20px}
}
@media (max-height:740px){
  .guidance-card{padding:12px}
  .hud-top{gap:8px}
  .hud-bottom{gap:6px}
  .hud-bottom>.footer-version{margin-top:-3px}
}
@media (orientation:landscape) and (max-height:550px){
  #setupSheet .sheet-inner{max-width:480px; display:flex; gap:6px}
  .setup-heading{margin:0}
  .hud-top{width:52%}
  .hud-bottom{position:absolute; right:0; bottom:0; width:46%}
  .guidance-card strong{font-size:22px}
}
@media(max-height:600px){
  .demo-scene{height:240px}
}
@media (orientation:landscape) and (max-height:550px){
  .scan-demo[open]{display:grid; grid-template-columns:54% 46%}
  .scan-demo .dialog-toolbar{grid-column:1 / -1; grid-row:1}
  .demo-scene{grid-column:1; grid-row:2; height:260px}
  .demo-copy{grid-column:2; grid-row:2; align-self:center; padding:18px 18px 8px}
}
@media (orientation:portrait) and (max-height:600px){
  .demo-scene{height:200px}
  .demo-copy{padding:14px 16px 8px}.demo-instructions{font-size:15px}
}

@media (prefers-reduced-motion:reduce){
  .frame-edges .frame-edge{transition:none}
}

/* Before detection the oval is a quiet placement hint. Once landmarks arrive,
   the same single element follows the face at a throttled rate; no second
   canvas or face-mesh paint is added to the already busy camera path. */
.setup-oval{
  position:absolute; left:50%; top:41%; transform:translate(-50%,-50%);
  height:min(52dvh,100vw,460px); aspect-ratio:.74; border-radius:50%; pointer-events:none;
  border:2px solid rgba(255,255,255,.9); box-shadow:0 0 0 1px rgba(0,0,0,.16);
  transition:border-color .2s,box-shadow .2s;
}
.setup-oval.ready{border-color:var(--accent); box-shadow:0 0 0 5px rgba(var(--accent-rgb),.16),0 0 26px rgba(var(--accent-rgb),.42)}
.setup-oval.tracking{
  left:0; top:0; aspect-ratio:auto; contain:layout; will-change:transform;
  box-shadow:0 0 0 4px rgba(var(--accent-rgb),.14),0 0 18px rgba(var(--accent-rgb),.34);
}
.setup-bottom{
  position:absolute; bottom:0; left:50%; transform:translateX(-50%); width:min(100%,460px);
  display:grid; gap:18px; padding:12px var(--pad) calc(env(safe-area-inset-bottom) + 6px);
  text-align:center; pointer-events:none;
}
.setup-controls{
  display:grid; gap:var(--space-2); padding:12px; max-height:32dvh; overflow-y:auto; pointer-events:auto;
  background:rgba(255,255,255,.32); border:1px solid rgba(255,255,255,.40); border-radius:20px;
  box-shadow:0 8px 24px rgba(18,23,13,.06),inset 0 1px 0 rgba(255,255,255,.36);
}
.debug-panel-label{justify-self:start; color:var(--ink); font-size:10px; font-weight:700; letter-spacing:.12em; text-transform:uppercase}
.setup-controls .capture-option,.setup-controls .toggle-option{background:rgba(255,255,255,.24)}
.setup-controls .camera-quality{border-color:rgba(70,100,25,.25); background:rgba(255,255,255,.2)}
.setup-actions{display:grid; gap:12px; pointer-events:auto}
.setup-actions>.footer-version{margin-top:-9px}
.setup-status{
  color:#fff; text-shadow:0 1px 4px rgba(0,0,0,.95),0 0 16px rgba(0,0,0,.7);
}
.setup-action-row{display:grid; grid-template-columns:104px minmax(0,1fr); align-items:stretch; gap:14px}
.camera-switch{
  display:flex; flex-direction:column; align-items:center; justify-content:center; gap:3px;
  min-height:56px; padding:9px 6px; border:1px solid rgba(255,255,255,.6); border-radius:22px;
  background:rgba(255,255,255,.56); color:var(--ink); box-shadow:0 8px 28px rgba(0,0,0,.12);
  font-size:11px; font-weight:650; cursor:pointer;
}
.camera-switch svg{width:22px; height:22px}
.camera-switch:disabled{opacity:.5; cursor:default}
.setup-actions .ghost-button{margin:0; background:rgba(255,255,255,.78)}
.setup-actions .setup-error{background:rgba(255,245,242,.94); text-align:left}

/* Small live panels use a restrained blur to keep the camera readable without
   paying the cost of a full-screen filter while face tracking is active. */
.icon-button,.hud-chip,.guidance-card,.setup-heading{
  -webkit-backdrop-filter:saturate(1.12) blur(14px);
  backdrop-filter:saturate(1.12) blur(14px);
}
.setup-controls,.camera-switch{
  -webkit-backdrop-filter:saturate(1.08) blur(10px);
  backdrop-filter:saturate(1.08) blur(10px);
}
.setup-hint{margin:4px 0 0; color:inherit; font-size:14px}
@media (orientation:landscape) and (max-height:550px){
  #setupSheet .sheet-inner{max-width:none}
  .setup-oval{left:30%; top:55%; height:min(72dvh,320px)}
  .setup-bottom{left:auto; right:0; width:44%; transform:none}
}

.sound-button svg{width:23px; height:23px; vertical-align:middle}
.demo-copy h2{margin:0 0 10px; font-size:22px; font-weight:600; line-height:1.2; letter-spacing:.35px}
@media (orientation:portrait) and (max-height:650px){
  .setup-oval{top:38%; height:min(45dvh,95vw)}
  .setup-bottom{gap:12px; padding-bottom:calc(env(safe-area-inset-bottom) + 6px)}
  .setup-controls{gap:6px; padding:10px}
  .setup-hint{font-size:13px}
  .capture-option{padding:4px 7px}
  #setupSheet .light-card strong{font-size:18px}
  .primary-button.scan-action{min-height:50px; padding:12px; font-size:18px}
  .demo-copy{padding:18px 18px 8px}
  .demo-copy h2{font-size:23px}
}
@media (prefers-reduced-motion:reduce){
  .setup-oval,#progressFill{transition:none}
}

@media (orientation:landscape) and (max-height:550px){
  .setup-bottom{right:8px; width:44%; padding:8px 8px calc(env(safe-area-inset-bottom) + 6px); bottom:0; gap:10px}
  .setup-controls{padding:8px; max-height:38dvh}
  .setup-actions{gap:8px}
  .setup-actions>.footer-version{margin-top:-5px}
  .setup-action-row{grid-template-columns:96px minmax(0,1fr); gap:10px}
  #setupSheet .card-group{margin-bottom:3px}
  #setupSheet .light-card strong{font-size:16px}
  #setupSheet #lightAdvice{font-size:13px}
  .setup-hint{font-size:12px}
  .camera-quality{min-height:24px; padding:3px 8px}
  .capture-options{gap:5px}
  .capture-option{padding:3px 6px}
  .toggle-option{min-height:38px; padding:4px 6px}
  .setup-error{padding:6px 8px; margin:0; font-size:13px}
  .primary-button.scan-action{min-height:44px; padding:8px; font-size:16px}
  .camera-switch{min-height:48px; padding:6px}
  #setupSheet{background:linear-gradient(to bottom,rgba(0,0,0,.55),transparent 18%)}
}
