:root {
  --bg: #000000;
  --panel: #0D0F12;
  --line: #1F2329;
  --text: #FFFFFF;
  --body: #D9DDE3;
  --muted: #A7ADB7;
  --accent: #D4FF3F;
  --mono: 'Geist Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: 'Archivo', system-ui, -apple-system, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: var(--sans); -webkit-text-size-adjust: 100%; }
body { overflow: hidden; overscroll-behavior: none; }
button { font: inherit; color: inherit; }
button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* ---------- Layout: phone first ---------- */
.app {
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas: "info" "stage" "controls";
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.brand { display: none; }

.info { grid-area: info; padding: 10px 16px 8px; min-height: 92px; }
.step { font-family: var(--mono); font-size: 11px; letter-spacing: 0.12em; color: var(--muted); text-transform: uppercase; }
.title { display: none; }
.caption { margin: 5px 0 0; font-size: 15px; line-height: 1.35; color: var(--body); }
.hint { margin: 4px 0 0; font-size: 13px; line-height: 1.3; font-weight: 700; color: var(--accent); }
.hint:empty { display: none; }

.stage { grid-area: stage; position: relative; overflow: hidden; touch-action: pan-y; }
.device { position: absolute; left: 50%; top: 50%; width: 390px; height: 844px; transform: translate(-50%, -50%) scale(var(--s, 1)); transform-origin: 50% 50%; }
.screen { position: relative; width: 390px; height: 844px; overflow: hidden; background: #000; border-radius: 28px; }
.island { display: none; }
.screen.enter { animation: screen-in 280ms cubic-bezier(.2,.8,.2,1) both; }
@keyframes screen-in { from { opacity: 0; } to { opacity: 1; } }

.controls { grid-area: controls; display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; padding: 8px 12px 10px; }
.nav { height: 48px; min-width: 48px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 0 16px; border-radius: 24px; border: 1px solid var(--line); background: var(--panel); font-size: 16px; font-weight: 700; cursor: pointer; }
.nav.next { background: var(--accent); color: #000; border-color: var(--accent); }
.nav:disabled { opacity: 0.35; cursor: default; }
.nav.list { font-family: var(--mono); font-size: 13px; letter-spacing: 0.06em; font-weight: 600; color: var(--muted); }

/* Screen list: a bottom sheet on phones */
.index { position: fixed; z-index: 20; left: 0; right: 0; bottom: 0; max-height: 78vh; overflow-y: auto; padding: 8px 12px calc(16px + env(safe-area-inset-bottom)); border-radius: 22px 22px 0 0; background: #0D0F12; border-top: 1px solid var(--line); transform: translateY(105%); transition: transform 260ms cubic-bezier(.2,.8,.2,1); }
.index.open { transform: none; }
.index-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 6px 8px; font-family: var(--mono); font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.index-close { width: 44px; height: 44px; border: 0; border-radius: 22px; background: transparent; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.index-list { list-style: none; margin: 0; padding: 0; }
.index-list button { width: 100%; min-height: 48px; display: flex; align-items: center; gap: 12px; padding: 8px 10px; border: 0; border-radius: 12px; background: transparent; text-align: left; font-size: 16px; font-weight: 650; cursor: pointer; }
.index-list .num { width: 26px; flex: none; font-family: var(--mono); font-size: 12px; color: var(--muted); }
.index-list .group { display: block; padding: 14px 10px 4px; font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.12em; text-transform: uppercase; color: #7C838E; }
.index-list button[aria-current="step"] { background: #16191D; color: var(--accent); }
.index-list button[aria-current="step"] .num { color: var(--accent); }
.scrim { position: fixed; inset: 0; z-index: 15; background: rgba(0,0,0,.55); }

/* ---------- Tablet: show the phone frame ---------- */
@media (min-width: 640px) {
  .device { width: 422px; height: 876px; padding: 16px; border-radius: 66px; background: linear-gradient(160deg, #34373c, #141518 40%, #0c0d0f); box-shadow: inset 0 0 0 1.5px #4a4d53, inset 0 0 0 5px #08090a, 0 50px 90px rgba(0,0,0,.65), 0 0 0 1px #000; }
  .device::before, .device::after { content: ""; position: absolute; width: 4px; border-radius: 2px; background: #2a2c30; }
  .device::before { left: -3px; top: 170px; height: 64px; box-shadow: 0 86px 0 #2a2c30; }
  .device::after { right: -3px; top: 220px; height: 100px; }
  .screen { border-radius: 50px; }
  .island { display: block; position: absolute; z-index: 5; top: 27px; left: 50%; width: 122px; height: 35px; margin-left: -61px; border-radius: 20px; background: #000; }
  .info { padding: 16px 24px 4px; }
  .caption { font-size: 17px; }
}

/* ---------- Desktop: index | phone | caption ---------- */
@media (min-width: 1040px) and (min-height: 560px) {
  .app {
    grid-template-columns: 260px minmax(0, 1fr) 340px;
    grid-template-rows: auto minmax(0, 1fr) auto;
    grid-template-areas:
      "brand stage info"
      "index stage info"
      "index stage controls";
    column-gap: 24px;
    padding: 28px 32px;
  }
  .brand { display: block; grid-area: brand; padding: 4px 8px 18px; }
  .wordmark { font-size: 30px; font-weight: 850; font-stretch: 125%; letter-spacing: 0.01em; line-height: 1; }
  .wordmark span { color: var(--accent); }
  .brand-sub { margin-top: 8px; font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; color: var(--muted); }
  .index { grid-area: index; position: static; transform: none; max-height: none; padding: 0; border: 0; border-radius: 0; background: transparent; overflow-y: auto; }
  .index-head { padding: 0 8px 4px; }
  .index-close, .nav.list { display: none; }
  .index-list button { min-height: 40px; font-size: 15px; }
  .info { align-self: center; padding: 0; min-height: 0; }
  .step { font-size: 12px; }
  .title { display: block; margin: 10px 0 0; font-size: 40px; line-height: 1; font-weight: 850; font-stretch: 118%; text-transform: uppercase; letter-spacing: 0.01em; }
  .caption { margin-top: 14px; font-size: 19px; line-height: 1.45; }
  .hint { margin-top: 12px; font-size: 15px; }
  .controls { grid-template-columns: 1fr 1fr; padding: 0 0 8px; align-self: end; }
  .scrim { display: none; }
}

/* ---------- Intro and end cards (drawn inside the phone screen) ---------- */
.card { position: absolute; inset: 0; display: flex; flex-direction: column; padding: 96px 28px 40px; background: radial-gradient(120% 70% at 50% 0%, #1a2008 0%, #000 60%); }
.card .mark { font-size: 54px; line-height: 0.95; font-weight: 850; font-stretch: 125%; letter-spacing: 0.005em; }
.card .mark span { color: var(--accent); }
.card .tag { margin: 18px 0 0; font-size: 26px; line-height: 1.15; font-weight: 800; }
.card .lede { margin: 18px 0 0; font-size: 17px; line-height: 1.45; color: var(--body); }
.card ul { margin: 22px 0 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 12px; }
.card li { display: flex; gap: 12px; font-size: 16px; line-height: 1.4; color: var(--body); }
.card li::before { content: ""; flex: none; width: 8px; height: 8px; margin-top: 8px; border-radius: 50%; background: var(--accent); }
.card .go { margin-top: auto; height: 64px; border: 0; border-radius: 22px; background: var(--accent); color: #000; font-size: 20px; font-weight: 850; font-stretch: 110%; text-transform: uppercase; letter-spacing: 0.02em; cursor: pointer; display: flex; align-items: center; justify-content: center; text-decoration: none; }
.card .go.quiet { margin-top: 10px; height: 52px; background: #16191D; color: var(--text); font-size: 16px; }
.card .qs { margin: 18px 0 0; padding: 0; list-style: none; counter-reset: q; }
.card .qs li { counter-increment: q; padding: 12px 0; border-top: 1px solid var(--line); }
.card .qs li::before { content: counter(q); width: 22px; height: 22px; margin-top: 0; display: flex; align-items: center; justify-content: center; font-family: var(--mono); font-size: 12px; font-weight: 700; color: #000; }
.card .note { margin: 14px 0 0; font-size: 14px; line-height: 1.4; color: var(--muted); }

/* ---------- Survey (end card) ---------- */
.card.survey { padding: 64px 20px 28px; overflow-y: auto; overscroll-behavior: contain; gap: 0; }
.survey .tag { margin: 0 0 6px; font-size: 24px; }
.survey fieldset { margin: 18px 0 0; padding: 0; border: 0; min-width: 0; }
.survey legend, .survey .q { display: block; padding: 0; margin-bottom: 10px; font-size: 17px; line-height: 1.3; font-weight: 700; color: var(--text); }
.survey legend b, .survey .q b { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; margin-right: 8px; border-radius: 50%; background: var(--accent); color: #000; font-family: var(--mono); font-size: 13px; vertical-align: 2px; }
.survey .q i { font-style: normal; font-weight: 500; color: var(--muted); }
.survey .opt { position: relative; display: block; cursor: pointer; }
.survey .opt input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.survey .opt span { display: flex; align-items: center; justify-content: center; min-height: 48px; padding: 6px 8px; border-radius: 14px; border: 1px solid #2A2E35; background: #0D0F12; font-size: 15px; font-weight: 650; text-align: center; transition: background 150ms ease, border-color 150ms ease; }
.survey .opt input:checked + span { background: var(--accent); border-color: var(--accent); color: #000; }
.survey .opt input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.survey .scale { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.survey .num span { min-height: 56px; font-size: 24px; font-weight: 800; font-stretch: 80%; }
.survey .ends { display: flex; justify-content: space-between; margin-top: 6px; font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.survey .grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.survey .field { display: block; margin-top: 18px; }
.survey textarea, .survey input[type="email"], .survey input[type="text"] { display: block; width: 100%; padding: 12px 14px; border-radius: 14px; border: 1px solid #2A2E35; background: #0D0F12; color: var(--text); font: 500 20px/1.35 var(--sans); resize: vertical; }
.survey textarea::placeholder { color: #7C838E; }
.survey textarea:focus, .survey input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.survey .check { display: flex; align-items: center; gap: 12px; margin-top: 20px; min-height: 48px; padding: 10px 14px; border-radius: 14px; background: #16191D; font-size: 16px; font-weight: 700; cursor: pointer; }
.survey .check input { flex: none; width: 24px; height: 24px; accent-color: var(--accent); }
.survey .optin .field { margin-top: 12px; }
.survey .fine { margin: 10px 2px 0; font-size: 13px; line-height: 1.4; color: var(--muted); }
.survey .trap { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.survey .error { min-height: 20px; margin: 14px 0 0; font-size: 15px; font-weight: 700; color: #FF8A80; }
.survey .error:empty { min-height: 0; margin: 0; }
.survey .go { flex: none; margin-top: 16px; }
.survey .go:disabled { opacity: 0.6; cursor: default; }
.card .go.quiet { flex: none; }

/* ---------- Demo video overlay ---------- */
.card .go.quiet[data-video] { gap: 8px; }
.player { position: fixed; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center; padding: calc(56px + env(safe-area-inset-top)) 12px calc(16px + env(safe-area-inset-bottom)); background: rgba(0,0,0,.92); }
.player[hidden] { display: none; }
.player-box { position: relative; }
.player-close { position: absolute; top: -50px; right: 0; width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 22px; background: var(--panel); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.player-frame { overflow: hidden; border-radius: 18px; background: #000; }
.player-frame.is-vertical { height: min(calc(100dvh - 90px), calc((100vw - 24px) * 2340 / 1080)); aspect-ratio: 1080 / 2340; }
.player-frame.is-wide { width: min(calc(100vw - 24px), calc((100dvh - 90px) * 16 / 9), 1280px); aspect-ratio: 16 / 9; }
.player-frame iframe { display: block; width: 100%; height: 100%; border: 0; }

/* ---------- Recording mode (?rec=phone or ?rec=desktop) ---------- */
body.rec .info, body.rec .controls, body.rec .brand, body.rec .index { display: none; }
body.rec .app { display: block; padding: 0; }
body.rec .stage { position: fixed; inset: 0; }
body.rec.rec-desktop .stage { background: radial-gradient(60% 70% at 50% 45%, #10140a 0%, #000 70%); }
.tap { position: fixed; z-index: 50; width: 64px; height: 64px; margin: -32px 0 0 -32px; border-radius: 50%; border: 3px solid rgba(255,255,255,.9); background: rgba(255,255,255,.25); pointer-events: none; animation: tap 700ms ease-out both; }
@keyframes tap { from { transform: scale(.4); opacity: 1; } to { transform: scale(1.4); opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  .screen.enter, .index { animation: none; transition: none; }
}
