:root {
  color-scheme: dark;
  --ink: #f8fafc;
  --muted: #bdc4d2;
  --panel: rgba(12, 16, 27, .9);
  --accent: #7657ff;
  --accent-dark: #5335d6;
  --good: #43e08d;
}

* { box-sizing: border-box; }

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  background: #05070c;
  color: var(--ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
select,
input { font: inherit; }

button:focus-visible,
select:focus-visible,
input:focus-visible,
a:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }

.app-shell {
  position: fixed;
  inset: 0;
  width: min(100%, 34rem);
  height: 100dvh;
  margin: auto;
  overflow: hidden;
  background: #080b14;
  box-shadow: 0 0 4rem rgba(0,0,0,.55);
}

.camera-stage { position: absolute; inset: 0; overflow: hidden; }

#camera {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity .25s ease;
}

#camera.ready { opacity: 1; }
#camera.mirrored { transform: scaleX(-1); }

.shade {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(0,0,0,.62), transparent 23%, transparent 70%, rgba(0,0,0,.78));
}

header {
  position: fixed;
  z-index: 5;
  top: 0;
  left: 50%;
  display: flex;
  width: min(100%, 34rem);
  align-items: center;
  justify-content: space-between;
  gap: .7rem;
  padding: max(.85rem, env(safe-area-inset-top)) .9rem .7rem;
  transform: translateX(-50%);
}

header h1 { margin: 0; font-size: clamp(1.05rem, 4.6vw, 1.4rem); letter-spacing: -.035em; }

.status {
  display: inline-flex;
  align-items: center;
  gap: .42rem;
  min-height: 2rem;
  padding: .32rem .68rem;
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 999px;
  background: rgba(8,11,20,.72);
  font-size: .8rem;
  font-weight: 750;
  backdrop-filter: blur(12px);
}

.status-dot { width: .62rem; height: .62rem; border-radius: 50%; background: #8f96a6; }
.status.recording .status-dot { background: #ff4565; box-shadow: 0 0 0 .25rem rgba(255,69,101,.18); }
.status.armed .status-dot, .status.complete .status-dot { background: var(--good); }

.answer-zones { position: absolute; inset: 0; z-index: 3; pointer-events: none; }

.answer {
  position: absolute;
  display: grid;
  width: clamp(5.8rem, 27vw, 8rem);
  height: clamp(3rem, 13vw, 4rem);
  place-items: center;
  border: 3px solid rgba(255,255,255,.92);
  border-radius: 999px;
  background: rgba(4,7,12,.64);
  color: #fff;
  font-size: clamp(1.05rem, 5vw, 1.45rem);
  font-weight: 950;
  line-height: 1;
  text-shadow: 0 2px 4px #000;
  backdrop-filter: blur(6px);
  transition: background .16s ease, border-color .16s ease, transform .16s ease;
}

.answer-maybe { top: 15%; left: 50%; transform: translateX(-50%); }
.answer-yes { top: 44%; left: max(.75rem, env(safe-area-inset-left)); }
.answer-no { top: 44%; right: max(.75rem, env(safe-area-inset-right)); }

.answer.selected {
  border-color: #c7ffdf;
  background: var(--good);
  color: #062515;
  text-shadow: none;
}

.answer-maybe.selected { transform: translateX(-50%) scale(1.08); }
.answer-yes.selected,
.answer-no.selected { transform: scale(1.08); }

.answer-zones.locked .answer:not(.selected) { opacity: .55; }

.message {
  position: fixed;
  z-index: 5;
  top: 63%;
  left: 50%;
  width: min(calc(100% - 2rem), 28rem);
  transform: translateX(-50%);
  text-align: center;
  text-shadow: 0 2px 12px #000;
  pointer-events: none;
}

.message strong { display: block; font-size: clamp(1.5rem, 8vw, 2.6rem); line-height: 1.05; }
.message span { display: block; margin-top: .38rem; color: #f0f2f7; font-size: clamp(.86rem, 3.4vw, 1rem); }

.countdown {
  position: fixed;
  z-index: 9;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(0,0,0,.38);
  font-size: clamp(8rem, 48vw, 17rem);
  font-weight: 950;
  text-shadow: 0 .08em .25em #000;
}

.panel {
  position: fixed;
  z-index: 8;
  left: 50%;
  bottom: max(.8rem, env(safe-area-inset-bottom));
  width: min(calc(100% - 1.25rem), 32rem);
  max-height: calc(100dvh - 4.8rem);
  overflow-y: auto;
  transform: translateX(-50%);
  padding: 1.1rem;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 1.25rem;
  background: var(--panel);
  box-shadow: 0 1rem 4rem rgba(0,0,0,.45);
  backdrop-filter: blur(18px);
}

.panel h2 { margin: 0 0 .55rem; font-size: clamp(1.45rem, 6vw, 2rem); line-height: 1.08; }
.panel > p:not(.eyebrow, .note) { margin: 0 0 .85rem; color: var(--muted); line-height: 1.42; }
.eyebrow { margin: 0 0 .38rem; color: #b9aaff; font-size: .72rem; font-weight: 900; letter-spacing: .14em; }

.steps { display: grid; gap: .65rem; margin: .85rem 0; padding: 0; list-style: none; counter-reset: step; }
.steps li { display: grid; grid-template-columns: 1.7rem minmax(0,1fr); gap: 0 .62rem; align-items: start; counter-increment: step; }
.steps li::before { grid-row: span 2; content: counter(step); display: grid; width: 1.65rem; height: 1.65rem; place-items: center; border-radius: 50%; background: #333a4a; font-size: .78rem; font-weight: 900; }
.steps strong { font-size: .94rem; }
.steps span { color: var(--muted); font-size: .84rem; line-height: 1.32; }

.option { display: flex; align-items: center; gap: .55rem; margin: .4rem 0 .75rem; color: #e6e8ed; font-size: .92rem; }
.option input { width: 1.15rem; height: 1.15rem; accent-color: var(--accent); }
.field { display: grid; grid-template-columns: auto 1fr; gap: .7rem; align-items: center; margin-bottom: .85rem; color: var(--muted); font-size: .88rem; font-weight: 750; }
.field select { min-height: 2.65rem; padding: .45rem .65rem; border: 1px solid rgba(255,255,255,.18); border-radius: .7rem; background: #252b39; color: #fff; }

.button { display: grid; width: 100%; min-height: 3.2rem; place-items: center; padding: .7rem 1rem; border: 0; border-radius: .9rem; background: #343b4b; color: #fff; cursor: pointer; font-weight: 850; text-align: center; text-decoration: none; }
.button.primary { background: linear-gradient(135deg, var(--accent), var(--accent-dark)); }
.button.finish { background: #fff; color: #111722; }
.button:disabled { cursor: wait; opacity: .55; }
.note { min-height: 1.25rem; margin: .55rem 0 0; color: #ffb8c3; font-size: .82rem; }

.session-controls { position: fixed; z-index: 6; left: 50%; bottom: max(1rem, env(safe-area-inset-bottom)); width: min(calc(100% - 1.5rem), 28rem); transform: translateX(-50%); }
.summary { display: grid; grid-template-columns: repeat(3,1fr); gap: .5rem; margin: .7rem 0 .9rem; }
.summary span { display: grid; gap: .18rem; place-items: center; padding: .6rem .25rem; border-radius: .75rem; background: #252b39; color: var(--muted); font-size: .78rem; }
.summary strong { color: #fff; font-size: 1.5rem; }
.result-video { width: 100%; max-height: 42vh; margin: .2rem 0 .85rem; border-radius: .8rem; background: #000; }
.actions { display: grid; gap: .65rem; }
.actions.two { grid-template-columns: 1fr 1fr; }
.save-link { background: #343b4b; }

#analysisCanvas,
#recordingCanvas { position: fixed; width: 1px; height: 1px; opacity: .001; pointer-events: none; }
.hidden { display: none !important; }

@media (orientation: landscape) and (max-height: 540px) { .panel { max-height: calc(100dvh - 1rem); } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
