/* Virtual Checkup — one step per screen, the action always in view, no needless scroll.
   (Layout and the full-screen camera come from the strabismus page; new parts at the end.)
   Layout: body is a full-height column; each step is a flex column whose action bar
   sits at the bottom (sticky if the content ever gets taller than the screen). */
body.vc { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.vc .topbar { flex: none; }
.wizard { flex: 1 0 auto; display: flex; flex-direction: column; width: 100%; max-width: 520px;
  padding-top: 12px; padding-bottom: max(12px, env(safe-area-inset-bottom));
  padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
.screen { flex: 1 0 auto; display: flex; flex-direction: column; gap: 12px; }
.screen[hidden] { display: none !important; }
.screen > * { margin: 0; }
.screen h1 { font-size: clamp(1.5rem, 6.4vw, 2.05rem); }
.screen h2 { font-size: 1.1rem; }
.lead { font-size: 1.06rem; }
.btn.big { min-height: 54px; font-size: 1.06rem; }

/* action bar: bottom of the step, sticky if the step scrolls */
.cta-bar { margin-top: auto; position: sticky; bottom: 0; z-index: 5; display: grid; gap: 10px;
  padding: 10px 0 max(2px, env(safe-area-inset-bottom)); background: linear-gradient(to top, var(--bg) 78%, color-mix(in srgb, var(--bg) 0%, transparent)); }
.cta-bar.two { grid-template-columns: 1fr 1fr; }
.cta-bar.two .btn { padding: 0 10px; white-space: nowrap; }

/* step header: back + progress */
.stepbar { display: flex; align-items: center; gap: 8px; margin: -4px 0 10px; }
.stepbar[hidden] { display: none; }
.back { flex: none; width: 44px; height: 44px; margin-left: -10px; border: 0; border-radius: 12px; background: transparent; color: var(--ink);
  font: 400 2rem/1 var(--font); cursor: pointer; display: grid; place-items: center; padding-bottom: 4px; }
.back:active { background: var(--surface-2); }
.back[hidden] { visibility: hidden; display: grid !important; }
.steptext { flex: 1; font-size: .9rem; font-weight: 650; color: var(--muted); }
.stepbar .skip { margin-left: auto; }
.progress { flex: 1; list-style: none; display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; padding: 0; margin: 0; }
.progress li { font-size: .74rem; font-weight: 600; color: var(--muted); border-top: 4px solid var(--line); padding-top: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.progress li.done, .progress li.now { border-top-color: var(--accent); color: var(--ink); }

/* 1. start */
.start-fig { width: min(200px, 56vw); align-self: center; }
.start-fig svg { width: 100%; height: auto; border-radius: 14px; }
.points { list-style: none; padding: 0; display: grid; gap: 6px; }
.points li { position: relative; padding-left: 28px; color: var(--muted); font-size: .96rem; }
.points li::before { content: ""; position: absolute; left: 4px; top: .42em; width: 13px; height: 7px; border-left: 2.5px solid var(--accent); border-bottom: 2.5px solid var(--accent); transform: rotate(-45deg); }
.urgent { font-size: .9rem; color: var(--danger); background: var(--danger-bg); border-radius: var(--radius-sm); padding: 10px 12px; }
details.more { border-top: 1px solid var(--line); }
details.more summary { cursor: pointer; font-weight: 600; color: var(--accent); list-style: none; min-height: 48px; display: flex; align-items: center; }
details.more summary::-webkit-details-marker { display: none; }
details.more summary::before { content: "+"; width: 1.2em; font-weight: 700; }
details.more[open] summary::before { content: "−"; }
details.more > div { padding-bottom: 8px; font-size: .95rem; }
.vc footer.site { margin: 8px 0 0; padding: 16px 0 4px; }

/* 2. questions */
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.choices.three { grid-template-columns: repeat(3, 1fr); }
.choices button { min-height: 54px; border-radius: 14px; border: 1.5px solid var(--line); background: var(--surface); color: var(--ink);
  font: 600 1rem/1.2 var(--font); cursor: pointer; padding: 6px; }
.choices button[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1.5px var(--accent); }

/* 3. photo — full-screen capture like an ID/KYC selfie screen */
body.vc:is([data-screen="s-cam"], [data-screen="s-stage"]) { height: 100vh; height: 100dvh; overflow: hidden; }
body.vc[data-screen="s-cam"] { background: #000; }
body.vc:is([data-screen="s-cam"], [data-screen="s-stage"]) .topbar,
body.vc:is([data-screen="s-cam"], [data-screen="s-stage"]) .stepbar { display: none !important; }
.camscreen { position: fixed; inset: 0; z-index: 40; background: #000; color: #fff; }
.camfull { position: absolute; inset: 0; overflow: hidden; background: #000; }
.camfull video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .25s; }
.camfull.live video { opacity: 1; }
.camfull.mirror video { transform: scaleX(-1); }
/* dimmed surround with an oval cut-out */
.mask { position: absolute; inset: 0; pointer-events: none; }
.oval { position: absolute; left: 50%; top: 47%; width: min(72vw, 45vh, 360px); width: min(72vw, 45dvh, 360px); aspect-ratio: 3 / 4; transform: translate(-50%, -50%);
  border-radius: 50%; border: 3px dashed rgb(255 255 255 / 85%); box-shadow: 0 0 0 200vmax rgb(0 0 0 / 52%); transition: border-color .2s; }
/* guide tones: searching (white) → adjusting (amber) → holding still (green, dashed) → ready (green, solid) */
.camfull[data-guide="adjust"] .oval { border-color: #ffc24b; }
.camfull[data-guide="hold"] .oval { border-color: #3ddc84; }
.camfull.ready .oval { border-style: solid; border-color: #3ddc84; }
/* distance arrows (inside #oval): "out" sit inside the border and point at it — the face must grow;
   "in" sit outside and point at it — the face must shrink */
.oval-arrows { position: absolute; inset: 0; pointer-events: none; }
.oval-arrows[hidden] { display: none; }
.oval-arrows i { position: absolute; width: 26px; height: 26px; display: grid; place-items: center; animation: 1s ease-in-out infinite; }
.oval-arrows b { width: 15px; height: 15px; border: solid #ffc24b; border-width: 5px 5px 0 0; border-radius: 2px; filter: drop-shadow(0 1px 2px rgb(0 0 0 / 60%)); }
.oval-arrows.strong b { border-color: #ff8a00; width: 18px; height: 18px; }
.oval-arrows .ar-t, .oval-arrows .ar-b { left: calc(50% - 13px); }
.oval-arrows .ar-l, .oval-arrows .ar-r { top: calc(50% - 13px); }
.oval-arrows[data-dir="out"] .ar-t { top: 8px; }
.oval-arrows[data-dir="out"] .ar-b { bottom: 8px; }
.oval-arrows[data-dir="out"] .ar-l { left: 8px; }
.oval-arrows[data-dir="out"] .ar-r { right: 8px; }
.oval-arrows[data-dir="in"] .ar-t { top: -36px; display: none; } /* would sit on the guide text / red dot */
.oval-arrows[data-dir="in"] .ar-b { bottom: -36px; }
.oval-arrows[data-dir="in"] .ar-l { left: -36px; }
.oval-arrows[data-dir="in"] .ar-r { right: -36px; }
.oval-arrows[data-dir="out"] .ar-t, .oval-arrows[data-dir="in"] .ar-b { animation-name: nudge-up; }
.oval-arrows[data-dir="out"] .ar-b, .oval-arrows[data-dir="in"] .ar-t { animation-name: nudge-down; }
.oval-arrows[data-dir="out"] .ar-l, .oval-arrows[data-dir="in"] .ar-r { animation-name: nudge-left; }
.oval-arrows[data-dir="out"] .ar-r, .oval-arrows[data-dir="in"] .ar-l { animation-name: nudge-right; }
.oval-arrows[data-dir="out"] .ar-t b, .oval-arrows[data-dir="in"] .ar-b b { transform: translateY(3px) rotate(-45deg); }
.oval-arrows[data-dir="out"] .ar-b b, .oval-arrows[data-dir="in"] .ar-t b { transform: translateY(-3px) rotate(135deg); }
.oval-arrows[data-dir="out"] .ar-l b, .oval-arrows[data-dir="in"] .ar-r b { transform: translateX(3px) rotate(-135deg); }
.oval-arrows[data-dir="out"] .ar-r b, .oval-arrows[data-dir="in"] .ar-l b { transform: translateX(-3px) rotate(45deg); }
@keyframes nudge-up { 50% { transform: translateY(-7px); } }
@keyframes nudge-down { 50% { transform: translateY(7px); } }
@keyframes nudge-left { 50% { transform: translateX(-7px); } }
@keyframes nudge-right { 50% { transform: translateX(7px); } }
.camfull:not(.live) .oval { border-color: rgb(255 255 255 / 35%); }
/* failed / analysing: only the centre panel matters */
.camfull:is([data-state="failed"], [data-state="analysing"]) :is(.oval, .fix, .cam-guide, .shutter) { visibility: hidden; }
/* top bar: back · look-here dot (front camera sits right above it) · flip */
.cam-top { position: absolute; top: 0; left: 0; right: 0; z-index: 6; display: grid; grid-template-columns: 56px 1fr 56px; align-items: center;
  padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) 0 max(8px, env(safe-area-inset-left)); }
.icon-btn { width: 48px; height: 48px; border-radius: 50%; border: 0; background: rgb(0 0 0 / 42%); color: #fff; display: grid; place-items: center; cursor: pointer;
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
.icon-btn:active { background: rgb(255 255 255 / 22%); }
.icon-btn[hidden] { display: grid !important; visibility: hidden; }
#flipBtn { justify-self: end; }
/* front camera only: blinking red dot right under the camera = where to look */
.fix { justify-self: center; position: relative; display: grid; place-items: center; width: 44px; height: 44px; }
.fix span { width: 18px; height: 18px; border-radius: 50%; background: #ff2a2a;
  box-shadow: 0 0 0 4px rgb(255 42 42 / 30%), 0 0 16px 6px rgb(255 42 42 / 55%); animation: fixblink 1s ease-in-out infinite; }
.fix::after { content: ""; position: absolute; inset: 10px; border: 2px solid rgb(255 60 60 / 80%); border-radius: 50%; animation: fixring 1s ease-out infinite; }
.camfull[data-issue="look"] .fix span, .camfull[data-issue="look"] .fix::after { animation-duration: .55s; } /* asked to look: blink faster */
.camfull[data-mode="environment"] .fix { visibility: hidden; } /* rear camera: the person cannot see the screen */
@keyframes fixblink { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .15; transform: scale(.7); } }
@keyframes fixring { from { transform: scale(.6); opacity: .9; } to { transform: scale(1.9); opacity: 0; } }
.cam-guide { position: absolute; z-index: 5; left: 16px; right: 16px; top: calc(max(8px, env(safe-area-inset-top)) + 56px); margin: 0 auto; max-width: 440px;
  text-align: center; font-weight: 600; font-size: .98rem; line-height: 1.35; text-shadow: 0 1px 4px rgb(0 0 0 / 70%); }
.topprog { position: absolute; z-index: 7; top: 0; left: 0; right: 0; height: 4px; background: rgb(255 255 255 / 18%); }
.topprog i { display: block; height: 100%; width: 0; background: #3ddc84; transition: width .3s; }
/* front "flash": the screen turns white for the shot; the look-here dot stays on top */
.flash { position: absolute; inset: 0; z-index: 5; background: #fff; opacity: 0; pointer-events: none; transition: opacity .12s; }
.flash.on { opacity: 1; }
.camfull.flashing .fix span { animation: none; opacity: 1; background: #e00000; box-shadow: 0 0 0 5px rgb(224 0 0 / 25%); } /* steady while shooting */
.camfull.flashing .fix::after { display: none; }
.camfull.flashing .cam-guide { color: #111; text-shadow: none; }
.camfull.flashing .icon-btn, .camfull.flashing .cam-bottom { visibility: hidden; }
/* centre panels */
.cam-panel { position: absolute; z-index: 8; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(340px, calc(100vw - 40px));
  background: rgb(20 24 26 / 88%); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); border-radius: 20px; padding: 22px 20px;
  display: grid; gap: 12px; text-align: center; box-shadow: 0 10px 40px rgb(0 0 0 / 45%); }
.cam-panel[hidden] { display: none; }
.cam-panel > * { margin: 0; }
.cp-title { font-weight: 700; font-size: 1.1rem; }
.cp-sub { color: rgb(255 255 255 / 78%); font-size: .92rem; line-height: 1.4; }
.cp-icon { justify-self: center; color: rgb(255 255 255 / 85%); }
.cp-link { color: #9fe6c0; font-size: .92rem; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; min-height: 44px; display: grid; place-items: center; }
.cp-link[hidden] { display: none; }
.bar { height: 8px; border-radius: 99px; background: rgb(255 255 255 / 16%); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; border-radius: inherit; background: #3ddc84; transition: width .3s; }
.bar.indeterminate i { width: 35% !important; animation: indet 1.2s ease-in-out infinite; }
@keyframes indet { from { transform: translateX(-110%); } to { transform: translateX(310%); } }
@media (prefers-reduced-motion: reduce) {
  .bar.indeterminate i { animation-duration: 3s; }
  .fix span { animation: fixfade 1.6s ease-in-out infinite; } /* still blinks (colour only), no movement */
  .fix::after, .oval-arrows i { animation: none; }
}
@keyframes fixfade { 50% { opacity: .3; } }
.btn.light { background: rgb(255 255 255 / 12%); border-color: transparent; color: #fff; }
.spinner.light { justify-self: center; border-color: rgb(255 255 255 / 20%); border-top-color: #fff; width: 32px; height: 32px; }
/* bottom: hint + shutter, inside the camera */
.cam-bottom { position: absolute; z-index: 6; left: 0; right: 0; bottom: 0; display: grid; justify-items: center; gap: 14px;
  padding: 0 16px max(22px, calc(env(safe-area-inset-bottom) + 12px)); }
.cam-bottom .hint { position: static; background: rgb(0 0 0 / 60%); color: #fff; border-radius: 999px; padding: 9px 16px; font-weight: 600; font-size: .95rem;
  text-align: center; max-width: 100%; -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
.cam-bottom .hint.good { background: rgb(18 120 66 / 92%); }
.camfull[data-guide="adjust"] .cam-bottom .hint { box-shadow: inset 4px 0 0 #ffc24b; }
.camfull[data-guide="hold"] .cam-bottom .hint { background: rgb(18 120 66 / 70%); }
.camfull.ready .shutter { border-color: #3ddc84; box-shadow: inset 0 0 0 4px #000, inset 0 0 0 40px #fff, 0 0 0 5px rgb(61 220 132 / 45%); }
.cam-alt { background: #fff; color: #10302f; border-radius: 999px; padding: 0 18px; min-height: 44px; display: grid; place-items: center;
  font-weight: 700; font-size: .95rem; cursor: pointer; }
.cam-alt[hidden] { display: none; }
/* distance meter: Far ——[green zone]—— Close, live marker */
.dist { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; width: min(300px, calc(100vw - 48px));
  font-size: .8rem; font-weight: 700; color: #fff; text-shadow: 0 1px 3px rgb(0 0 0 / 80%); }
.dist[hidden] { display: none; }
.dist-track { position: relative; height: 8px; border-radius: 99px; background: rgb(255 255 255 / 28%); box-shadow: 0 1px 3px rgb(0 0 0 / 40%); }
.dist-zone { position: absolute; top: 0; bottom: 0; border-radius: 99px; background: rgb(61 220 132 / 80%); }
.dist-dot { position: absolute; top: 50%; left: 0; width: 20px; height: 20px; margin: -10px 0 0 -10px; border-radius: 50%;
  background: #ffc24b; border: 3px solid #fff; box-shadow: 0 1px 5px rgb(0 0 0 / 55%); transition: left .2s ease-out, background-color .2s; }
.dist.ok .dist-dot { background: #3ddc84; }
@media (max-height: 560px) { .dist { display: none !important; } }
.cam-bottom .hint[hidden] { display: none; }
.camscreen .shutter { width: 78px; height: 78px; border-radius: 50%; border: 4px solid #fff; background: transparent; box-shadow: inset 0 0 0 4px #000, inset 0 0 0 40px #fff; cursor: pointer; }
.camscreen .shutter:active { transform: scale(.95); }
.camscreen .shutter[disabled] { opacity: .35; }
.file-btn { position: relative; }
@media (max-height: 560px) {
  .cam-guide { font-size: .9rem; top: calc(max(6px, env(safe-area-inset-top)) + 50px); }
  .oval { top: 50%; width: min(60vw, 42vh, 300px); width: min(60vw, 42dvh, 300px); }
  .camscreen .shutter { width: 66px; height: 66px; }
  .cam-bottom { gap: 10px; padding-bottom: max(12px, env(safe-area-inset-bottom)); }
}
@media (orientation: landscape) and (max-height: 500px) {
  .oval { width: min(30vw, 58vh); width: min(30vw, 58dvh); top: 52%; }
  .cam-bottom { left: auto; right: max(12px, env(safe-area-inset-right)); top: 0; bottom: 0; align-content: center; padding: 0; width: 120px; }
}

/* 4. result */
.advice { border-radius: 18px; padding: 18px; border: 1.5px solid var(--line); background: var(--surface); }
.advice h2 { margin: 0 0 8px; font-size: 1.3rem; }
.advice p { margin: 0 0 .55em; }
.advice .note { margin: 10px 0 0; font-size: .82rem; color: var(--muted); }
.advice[data-tone="refer"] { background: var(--warn-bg); border-color: color-mix(in srgb, var(--warn) 45%, transparent); }
.advice[data-tone="refer"] h2 { color: var(--warn); }
.advice[data-tone="neutral"] { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 30%, transparent); }
.advice[data-tone="retake"] { background: var(--surface-2); }
.strip canvas { width: 100%; height: clamp(56px, 18vw, 96px); object-fit: cover; border-radius: var(--radius-sm); background: #000; }
.strip figcaption { margin-top: 4px; }

/* short screens: tighten, drop decoration first */
@media (max-height: 640px) {
  .start-fig { display: none; }
  .screen { gap: 10px; }
  .choices button { min-height: 48px; }
  .btn.big { min-height: 50px; }
}
@media (max-height: 600px) {
  .strip { display: none; }
  .advice { padding: 14px; }
  .advice h2 { font-size: 1.15rem; }
}
@media (max-height: 520px) {
  .lead { font-size: 1rem; }
  .screen { gap: 8px; }
  .stepbar { margin-bottom: 4px; }
  .screen h2 { font-size: 1rem; }
  .choices button { min-height: 46px; }
  .advice { padding: 12px 14px; }
  .advice h2 { font-size: 1.05rem; margin-bottom: 6px; }
  .advice p { font-size: .93rem; line-height: 1.42; margin-bottom: .4em; }
  .advice .note { margin-top: 6px; font-size: .78rem; }
  .cta-bar { padding-top: 6px; }
}
/* phone in landscape */
@media (max-height: 430px) and (orientation: landscape) {
  .topbar .container { height: 48px; }
  .wizard { padding-top: 6px; }
  .stepbar { margin-bottom: 2px; }
  .choices { grid-template-columns: repeat(4, 1fr); }
}


/* ================= Virtual Checkup additions ================= */
.hero { align-self: flex-start; }
.hero svg { border-radius: 16px; }
.muted-ink { opacity: .85; font-weight: 500; }

/* ask: grid (age), row (yes/no), list (options, tick list) */
.choices.grid { grid-template-columns: 1fr 1fr; }
.choices.grid button:last-child:nth-child(odd) { grid-column: 1 / -1; }
.choices.row { grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); }
.choices.list { grid-template-columns: 1fr; }
.choices.list button { text-align: left; padding: 10px 16px; min-height: 52px; font-weight: 600; }
@media (max-height: 500px) and (orientation: landscape) {
  .choices.grid { grid-template-columns: repeat(4, 1fr); }
  .choices.grid button:last-child:nth-child(odd) { grid-column: auto; }
}
/* answer scales (short labels): fold into two columns / one row when height is scarce */
@media (max-height: 600px) and (orientation: portrait) {
  .choices.scale { grid-template-columns: 1fr 1fr; gap: 8px; }
  .choices.scale button { min-height: 48px; padding: 8px 12px; }
  .choices.scale button:last-child:nth-child(odd) { grid-column: 1 / -1; }
}
@media (max-height: 500px) and (orientation: landscape) {
  .choices.scale { grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); }
  .choices.scale button { text-align: center; min-height: 56px; padding: 8px; }
}
.choices.checks button { position: relative; padding-left: 50px; }
.choices.checks button::before { content: ""; position: absolute; left: 16px; top: 50%; width: 22px; height: 22px; margin-top: -11px;
  border-radius: 6px; border: 2px solid var(--line); background: var(--surface); }
.choices.checks button[aria-pressed="true"]::before { border-color: var(--accent); background: var(--accent); }
.choices.checks button[aria-pressed="true"]::after { content: ""; position: absolute; left: 23px; top: 50%; width: 6px; height: 11px; margin-top: -8px;
  border: solid var(--accent-ink); border-width: 0 2.5px 2.5px 0; transform: rotate(45deg); }
#askSub { margin: -4px 0 4px; font-size: .95rem; }

/* intro */
.intro-fig { width: min(220px, 60vw); align-self: center; color: var(--accent); }
.intro-fig svg { width: 100%; height: auto; }
.intro-body p { margin: 0 0 .55em; font-size: 1.04rem; }

/* plan */
.plan { display: grid; gap: 14px; }
.plan-group h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 0 0 6px; }
.plan-row { display: flex; gap: 12px; align-items: center; min-height: 56px; padding: 8px 12px; border: 1.5px solid var(--line); border-radius: 14px;
  background: var(--surface); cursor: pointer; }
.plan-row + .plan-row { margin-top: 8px; }
.plan-row:has(input:checked) { border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); }
.plan-row input { width: 22px; height: 22px; accent-color: var(--accent); flex: none; margin: 0; }
.plan-txt { display: grid; gap: 1px; }
.plan-txt b { font-weight: 650; }
.plan-txt small { color: var(--muted); font-size: .84rem; }
.plan-row.off { opacity: .55; cursor: default; }

/* result tones shared by the urgent card and the summary */
.advice[data-tone="today"], .advice[data-tone="soon"] { background: var(--danger-bg); border-color: color-mix(in srgb, var(--danger) 45%, transparent); }
.advice[data-tone="today"] h2, .advice[data-tone="soon"] h2 { color: var(--danger); }
.advice[data-tone="clear"] { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 30%, transparent); }
.advice p:last-child { margin-bottom: 0; }

/* summary */
.sum-h { margin: 6px 0 0; font-size: .82rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.sum-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.sum-item details { border: 1px solid var(--line); border-radius: 14px; background: var(--surface); padding: 0 14px; }
.sum-item summary { list-style: none; cursor: pointer; min-height: 52px; display: flex; align-items: center; gap: 10px; justify-content: space-between; }
.sum-item summary::-webkit-details-marker { display: none; }
.sum-name { font-weight: 650; }
.sum-item p { margin: 0 0 .6em; font-size: .95rem; }
.pill.info { background: var(--accent-soft); color: var(--accent); }
.pill { white-space: nowrap; }
.timing { border-left: 4px solid var(--accent); padding: 2px 0 2px 12px; }
.timing h3 { margin: 0 0 4px; font-size: 1rem; }
.timing p { margin: 0 0 .4em; font-size: .95rem; }
.cta-bar.two .btn.danger { background: var(--surface); }

/* history */
.hist-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.hist-row { width: 100%; min-height: 56px; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 14px;
  border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--ink); font: 600 .95rem var(--font); text-align: left; cursor: pointer; }

/* ---------- stage: full-screen stimulus ---------- */
.stagescreen { position: fixed; inset: 0; z-index: 40; }
.stage { position: absolute; inset: 0; display: flex; flex-direction: column; background: var(--bg); color: var(--ink);
  padding: max(6px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); }
/* optotypes, grids and plates are always black on white, whatever the colour scheme */
.stage[data-tone="paper"] { background: #fff; color: #111; --line: #d9d4cc; --muted: #555; --surface: #fff; --ink: #111; }
.stage-top { display: grid; grid-template-columns: 48px 1fr auto; align-items: center; gap: 6px; min-height: 52px; }
.stage-title { font-weight: 650; font-size: .95rem; text-align: center; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.icon-btn.dark { background: transparent; color: inherit; -webkit-backdrop-filter: none; backdrop-filter: none; }
.stage-hint { margin: 4px auto 0; max-width: 520px; text-align: center; font-weight: 650; font-size: .98rem; padding: 8px 14px; border-radius: 999px;
  background: var(--accent-soft); color: var(--ink); }
.stage-hint[data-tone="warn"] { background: var(--warn-bg); color: var(--warn); }
.stage-body.swipe { touch-action: none; } /* swipes are answers, not scrolls */
.stage-body { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; position: relative; overflow: hidden; }
.stage-bottom { flex: none; display: grid; gap: 10px; padding-top: 10px; width: 100%; max-width: 520px; margin: 0 auto; }
.stage-msg { font-size: 1.2rem; font-weight: 650; text-align: center; max-width: 30ch; margin: 0; line-height: 1.4; }
.stage-msg.small { font-size: 1rem; font-weight: 600; }
.stage-foot { margin: 0; text-align: center; color: var(--muted); font-size: .88rem; }
.btn.round { width: 48px; height: 48px; padding: 0; border-radius: 50%; font-size: 1.4rem; flex: none; }

/* acuity */
.optotype { width: 100%; flex: 1 1 auto; min-height: 120px; display: block; }
.arrows { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.btn.arrow { min-height: 60px; padding: 0; border-radius: 16px; }
.btn.arrow.down svg { transform: rotate(90deg); }
.btn.arrow.left svg { transform: rotate(180deg); }
.btn.arrow.up svg { transform: rotate(-90deg); }

/* Amsler */
.amsler { display: block; touch-action: manipulation; cursor: crosshair; }

/* colour plates */
.plate { width: min(78vw, 46vh, 360px); width: min(78vw, 46dvh, 360px); aspect-ratio: 1; border-radius: 50%; display: block; }
.shapes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.btn.shape { min-height: 60px; padding: 0; border-radius: 16px; }
.reddisc { width: min(50vw, 30vh, 220px); width: min(50vw, 30dvh, 220px); aspect-ratio: 1; border-radius: 50%; background: rgb(220 30 30); }

/* near point */
.np-line { position: absolute; top: 6px; left: 50%; width: 2px; height: 36px; margin-left: -1px; background: #111; box-shadow: 0 0 0 1px #fff; }
.np-line::after { content: ""; position: absolute; left: -3px; top: 40px; width: 8px; height: 8px; border-radius: 50%; background: #111; }
.np-text { position: absolute; top: 4px; left: 0; right: 0; text-align: center; color: #111; font-weight: 500; letter-spacing: .01em; }
.stage:not([data-tone="paper"]) .np-line { background: var(--ink); }
.stage:not([data-tone="paper"]) .np-text { color: var(--ink); }

/* open-eye timer ring (no numbers while timing) */
.ring { --p: 0; width: min(56vw, 34vh, 240px); width: min(56vw, 34dvh, 240px); aspect-ratio: 1; border-radius: 50%; display: grid; place-items: center;
  background: conic-gradient(var(--accent) calc(var(--p) * 360deg), var(--surface-2) 0); }
.ring::before { content: ""; grid-area: 1 / 1; width: 82%; aspect-ratio: 1; border-radius: 50%; background: var(--bg); }
.ring-num { grid-area: 1 / 1; position: relative; font-size: 3.2rem; font-weight: 700; }
.ring.run { animation: pulse 2s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.02); } }

/* reading */
.reading { max-width: 36em; font-size: 1.08rem; line-height: 1.6; overflow: auto; padding: 0 4px; align-self: stretch; }
.readbar { position: absolute; top: 0; left: 0; right: 0; height: 4px; background: var(--line); border-radius: 99px; overflow: hidden; }
.readbar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .25s linear; }
.stage-body.top { justify-content: flex-start; padding-top: 12px; }
/* phone in landscape: the answer buttons share one row so the stimulus keeps its height */
@media (orientation: landscape) and (max-height: 500px) {
  .stage-bottom { grid-auto-flow: column; grid-auto-columns: 1fr; align-items: center; max-width: 720px; }
  .stage-msg { font-size: 1.05rem; }
  .stage-msg.small { font-size: .95rem; max-width: 46ch; }
  .plate { width: min(78vw, 42vh, 360px); width: min(78vw, 42dvh, 360px); }
}

/* screen-size calibration */
/* only the card's width matters: on short screens its height gives way so text and slider stay visible */
.cal { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; width: 100%; }
.cal > * { flex: none; }
.cal-card { flex: 0 1 auto; min-height: 72px; position: relative; border-radius: 12px; background: linear-gradient(135deg, #1f6f73, #0d4649); max-height: 46vh; max-height: 46dvh; overflow: hidden;
  box-shadow: inset 0 0 0 2px rgb(255 255 255 / 55%); }
/* when the card is cut short it fades out downwards (it continues below); the chip and stripe are
   placed by margin-%, i.e. by the card's WIDTH, so they keep their spot however much height is shown */
.cal-card.cut { -webkit-mask-image: linear-gradient(#000 70%, transparent); mask-image: linear-gradient(#000 70%, transparent); }
.cal-chip { position: absolute; top: 0; left: 14%; margin-top: 22%; width: 26%; aspect-ratio: 1.3; border-radius: 6px; background: #d8b45a; }
.cal-line { position: absolute; top: 0; left: 12%; right: 12%; margin-top: 118%; height: 6px; border-radius: 3px; background: rgb(255 255 255 / 55%); }
.cal-row { display: flex; align-items: center; gap: 12px; width: min(100%, 420px); }
.cal-row input[type="range"] { flex: 1; min-height: 44px; font-size: 16px; accent-color: var(--accent); }

/* ---------- camera additions ---------- */
.camfull[data-oval="far"] .oval { width: min(36vw, 22vh, 180px); width: min(36vw, 22dvh, 180px); }
.camfull[data-kind="live"] .shutter { display: none; }
.cam-tip { position: absolute; z-index: 5; left: 16px; right: 16px; top: calc(max(8px, env(safe-area-inset-top)) + 112px); margin: 0 auto; max-width: 440px;
  text-align: center; font-weight: 650; font-size: .92rem; background: #ffc24b; color: #3a2600; border-radius: 12px; padding: 8px 12px; }
.cam-steps { display: flex; gap: 8px; }
.cam-steps i { width: 10px; height: 10px; border-radius: 50%; background: rgb(255 255 255 / 35%); }
.cam-steps i.done { background: #3ddc84; }
.cam-steps i.now { background: #fff; box-shadow: 0 0 0 3px rgb(255 255 255 / 30%); }
.cam-btns { display: grid; gap: 8px; width: min(420px, 100%); }
.cam-btns:empty { display: none; }
.cam-row { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; width: min(420px, 100%); }
.cam-skip { justify-self: start; background: none; border: 0; color: rgb(255 255 255 / 80%); font: 600 .95rem var(--font); min-height: 44px; min-width: 44px; padding: 0 8px; cursor: pointer; }
.camfull:is([data-state="failed"], [data-state="analysing"]) .cam-skip { visibility: hidden; }
.cam-arrow { position: absolute; z-index: 4; top: 47%; width: 64px; height: 64px; margin-top: -32px; display: grid; place-items: center; }
.cam-arrow b { width: 34px; height: 34px; border: solid #ffc24b; border-width: 8px 8px 0 0; border-radius: 3px; filter: drop-shadow(0 1px 3px rgb(0 0 0 / 70%)); }
.cam-arrow[data-dir="right"] { right: 6%; animation: nudge-right 1s ease-in-out infinite; }
.cam-arrow[data-dir="right"] b { transform: rotate(45deg); }
.cam-arrow[data-dir="left"] { left: 6%; animation: nudge-left 1s ease-in-out infinite; }
.cam-arrow[data-dir="left"] b { transform: rotate(-135deg); }

/* the unseen camera for screen tests */
.bgvideo { position: fixed; left: 0; top: 0; width: 64px; height: 48px; object-fit: cover; pointer-events: none; z-index: -1; }
/* ↑ a real, laid-out element hidden BEHIND the page: WebKit pauses videos it considers invisible
   (display:none, 0 opacity, off-screen), and the unseen camera must keep delivering frames */
body.vc:not([data-screen="s-stage"]) .bgvideo { visibility: hidden; }

/* ?diag: engine · ms per frame · stream size · faces · GPU (real-phone checks only) */
.diag { position: fixed; left: 4px; bottom: 4px; z-index: 9999; max-width: calc(100vw - 8px); padding: 2px 6px; border-radius: 4px;
  background: rgb(0 0 0 / 65%); color: #fff; font: 11px/1.35 ui-monospace, SFMono-Regular, Menlo, monospace; pointer-events: none;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.diag[hidden] { display: none; }

/* short screens */
@media (max-height: 640px) {
  .intro-fig { width: min(160px, 44vw); }
  .hero svg { width: 56px; height: 56px; }
}
@media (max-height: 560px) {
  .intro-fig { display: none; }
  .plan-row { min-height: 48px; padding: 6px 10px; }
  .btn.arrow, .btn.shape { min-height: 52px; }
  .cam-tip { top: calc(max(6px, env(safe-area-inset-top)) + 96px); }
}
@media (prefers-reduced-motion: reduce) {
  .cam-arrow, .ring.run { animation: none; }
}

/* ---------- print: the summary only ---------- */
.print-only { display: none; }
@media print {
  body.vc { background: #fff; color: #000; display: block; }
  .topbar, .stepbar, .no-print, dialog, .bgvideo, .screen:not(#s-summary) { display: none !important; }
  #s-summary { display: block !important; }
  .print-only { display: block; font-weight: 700; }
  .sum-item details > * { display: block; }
  details.more > div { display: block; }
  .advice, .sum-item details { border-color: #999; background: #fff !important; }
}

/* headings get focus on each step (screen readers start there) — no visible ring for that */
[tabindex="-1"]:focus { outline: none; }
