:root {
  --bg: #0e1014;
  --surface: #171a21;
  --surface-2: #1f232c;
  --border: #2b303b;
  --text: #e9ebef;
  --muted: #9aa1ad;
  --accent: #8ab4ff;
  --accent-ink: #0b1220;
  --ok: #4fd18b;
  --warn: #f2b84b;
  --bad: #ff7a7a;
  --radius: 18px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.screen {
  display: none;
  min-height: 100vh;
  padding: 32px 16px;
  align-items: center;
  justify-content: center;
}
.screen.active { display: flex; }

.overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(14, 16, 20, 0.94);
}

.card {
  width: 100%;
  max-width: 600px;
  padding: 40px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.35);
}
.card.wide { max-width: 920px; }
.card.center { text-align: center; }
.card.center .actions { justify-content: center; }

.steps { display: flex; gap: 6px; margin-bottom: 20px; }
.steps i { flex: 1; height: 4px; border-radius: 2px; background: var(--surface-2); }
.steps i.on { background: var(--accent); }

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
h1 { margin: 0 0 14px; font-size: 30px; line-height: 1.2; letter-spacing: -0.01em; }
h2 { margin: 0 0 12px; font-size: 24px; line-height: 1.25; }
.lead { margin: 0 0 24px; color: var(--muted); font-size: 17px; }
.hint { margin: 8px 0 0; color: var(--muted); font-size: 14px; }
.requirements { color: var(--muted); font-size: 14px; }

a { color: var(--accent); }

button, a.button {
  display: inline-block;
  font: inherit;
  font-weight: 600;
  padding: 12px 24px;
  border: 1px solid transparent;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.15s;
}
a.button { text-decoration: none; }
button:active:not(:disabled), a.button:active { transform: scale(0.98); }
button:focus-visible, input:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
button.primary, a.button.primary { background: var(--accent); color: var(--accent-ink); }
button.primary:disabled { opacity: 0.35; cursor: not-allowed; }
button.ghost, a.button.ghost { background: transparent; color: var(--text); border-color: var(--border); }
button.ghost:hover, a.button.ghost:hover { background: var(--surface-2); }

.actions { display: flex; gap: 12px; justify-content: flex-end; flex-wrap: wrap; margin-top: 28px; }
.actions .exit { margin-right: auto; color: var(--muted); }

.notice {
  margin: 20px 0 0;
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 15px;
}
.notice.bad { background: rgba(255, 122, 122, 0.12); color: var(--bad); }

/* Welcome */
.overview { list-style: none; margin: 0 0 20px; padding: 0; display: grid; gap: 10px; }
.overview li { display: flex; align-items: center; gap: 12px; }
.overview span {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--accent);
  font-size: 14px;
  font-weight: 700;
}
.privacy {
  margin-top: 24px;
  padding: 20px;
  border-radius: 12px;
  background: var(--surface-2);
}
.privacy h2 { margin-bottom: 12px; font-size: 17px; }
.privacy dl { display: grid; grid-template-columns: 8.5em 1fr; gap: 8px 16px; margin: 0; font-size: 14px; }
.privacy dt { color: var(--muted); font-weight: 600; }
.privacy dd { margin: 0; }
.consent {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-top: 12px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
}
.consent input { width: 18px; height: 18px; margin-top: 3px; accent-color: var(--accent); }

/* Camera */
.camera-layout { display: grid; grid-template-columns: 1.2fr 1fr; gap: 32px; align-items: start; }
.preview {
  position: relative;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: 14px;
  background: var(--surface-2);
}
.preview video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.face-guide {
  position: absolute;
  left: 50%;
  top: 46%;
  width: 42%;
  height: 66%;
  transform: translate(-50%, -50%);
  border: 2px dashed rgba(255, 255, 255, 0.7);
  border-radius: 50%;
  box-shadow: 0 0 0 999px rgba(0, 0, 0, 0.35);
}
.preview-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.meter {
  position: absolute;
  left: 12px;
  bottom: 12px;
  margin: 0;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.6);
  font-size: 14px;
}
.meter::before { content: "●  "; }
.meter.ok::before { color: var(--ok); }
.meter.warn::before { color: var(--warn); }
.meter.bad::before { color: var(--bad); }

.checklist { list-style: none; margin: 0 0 24px; padding: 0; display: grid; gap: 10px; }
.checklist li { position: relative; padding-left: 28px; }
.checklist li::before { content: "✓"; position: absolute; left: 0; color: var(--ok); font-weight: 700; }

.choices { margin: 0; padding: 0; border: 0; display: grid; gap: 8px; }
.choices legend { margin-bottom: 8px; font-weight: 600; }
.choices label {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
}
.choices label:has(input:checked) { border-color: var(--accent); background: rgba(138, 180, 255, 0.08); }
.choices input { accent-color: var(--accent); }

/* Calibration */
.card-stage {
  display: grid;
  place-items: center;
  height: 320px;
  overflow: hidden;
  border-radius: 14px;
  background: var(--surface-2);
}
.card-rect {
  position: relative;
  width: 324px;
  aspect-ratio: 85.6 / 53.98;
  border-radius: 4%;
  background: linear-gradient(135deg, #3a4a6b, #26324a);
  border: 1px solid rgba(255, 255, 255, 0.25);
}
.card-rect .chip {
  position: absolute;
  left: 9%;
  top: 34%;
  width: 14%;
  height: 22%;
  border-radius: 12%;
  background: linear-gradient(135deg, #d9c27a, #a8904a);
}
.card-rect .stripe {
  position: absolute;
  left: 9%;
  bottom: 14%;
  width: 55%;
  height: 7%;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.25);
}
input[type="range"] { width: 100%; margin-top: 20px; accent-color: var(--accent); }

/* How-to */
.howto-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; margin: 8px 0 4px; }
.howto-grid figure { margin: 0; }
.howto-grid figcaption { margin-top: 12px; color: var(--muted); font-size: 15px; }
.howto-grid figcaption b { color: var(--accent); margin-right: 6px; }
.demo {
  display: grid;
  place-items: center;
  height: 140px;
  border-radius: 14px;
  background: #808080;
}
.demo-dot { display: grid; place-items: center; width: 56px; height: 56px; border-radius: 50%; background: #fff; }
.demo-dot .pip { width: 7px; height: 7px; border-radius: 50%; background: #1a1a1a; }
.demo-dot svg { width: 36px; height: 36px; fill: none; stroke: #1a1a1a; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.demo.keys { grid-template-columns: repeat(3, 40px); grid-template-rows: repeat(2, 40px); gap: 6px; place-content: center; }
.demo.keys .up { grid-column: 2; grid-row: 1; }
.demo.keys .left { grid-column: 1; grid-row: 2; }
.demo.keys .down { grid-column: 2; grid-row: 2; }
.demo.keys .right { grid-column: 3; grid-row: 2; }
kbd {
  display: inline-grid;
  place-items: center;
  min-width: 40px;
  height: 40px;
  padding: 0 8px;
  border-radius: 8px;
  background: #f4f4f4;
  color: #1a1a1a;
  box-shadow: inset 0 -3px 0 #c9c9c9;
  font: 600 16px/1 system-ui, sans-serif;
}
figcaption kbd, .hint kbd { min-width: 0; height: 26px; font-size: 13px; box-shadow: inset 0 -2px 0 #c9c9c9; }

/* Upload and done */
.progress { height: 10px; overflow: hidden; border-radius: 999px; background: var(--surface-2); }
.progress div { width: 0; height: 100%; background: var(--accent); transition: width 0.2s; }
.check {
  display: inline-grid;
  place-items: center;
  width: 64px;
  height: 64px;
  margin-bottom: 16px;
  border-radius: 50%;
  background: rgba(79, 209, 139, 0.15);
  color: var(--ok);
  font-size: 32px;
}
.code { margin: 0; font: 700 40px/1.2 ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: 0.12em; }
.session-ref { margin-top: 8px; }
.task-code { margin-top: 20px; padding: 16px 20px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; }
.task-code p { margin: 0; }
.task-code .code { margin: 4px 0 8px; }

/* Privacy notice page */
.doc { max-width: 760px; margin: 0 auto; padding: 48px 16px 64px; }
.doc > .back-link { margin-bottom: 32px; }
.doc .actions { justify-content: flex-start; margin-top: 40px; }
.doc h1 { font-size: 28px; }
.doc h2 { margin-top: 36px; font-size: 20px; }
.doc p, .doc li { color: var(--text); }
.doc ul { padding-left: 1.2em; }
.doc li { margin-bottom: 6px; }
.doc .table-wrap { overflow-x: auto; }
.doc table { width: 100%; border-collapse: collapse; font-size: 15px; }
.doc th, .doc td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.doc th { color: var(--muted); font-weight: 600; }

/* Task */
#stage {
  position: fixed;
  inset: 0;
  display: block;
  width: 100vw;
  height: 100vh;
  background: #808080;
  cursor: none;
}
#probe {
  /* Kept rendered (just invisible) so the browser keeps firing frame callbacks. */
  position: fixed;
  right: 0;
  bottom: 0;
  width: 2px;
  height: 2px;
  opacity: 0.01;
  pointer-events: none;
}

@media (max-width: 760px) {
  .card { padding: 28px 20px; }
  h1 { font-size: 24px; }
  .camera-layout, .howto-grid, .privacy dl { grid-template-columns: 1fr; }
  .privacy dd { margin-bottom: 6px; }
  .card-stage { height: 260px; }
}
