:root {
  --bg: #f4f6fa;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #d8dee8;
  --accent: #2563eb;
  --accent-text: #ffffff;
  --ok: #15803d;
  --err: #b91c1c;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1120;
    --card: #131c2e;
    --text: #e2e8f0;
    --muted: #94a3b8;
    --border: #26324a;
    --accent: #3b82f6;
    --ok: #4ade80;
    --err: #f87171;
  }
}

* { box-sizing: border-box; }

html, body { margin: 0; height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

main {
  max-width: 420px;
  min-height: 100%;
  margin: 0 auto;
  padding: max(24px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
}

header h1 {
  font-size: 1.25rem;
  font-weight: 600;
  text-align: center;
  margin: 0 0 24px;
}

.view {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 16px;
}

[hidden] { display: none !important; }

form {
  width: 100%;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.9rem;
  color: var(--muted);
}

input {
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
}

input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

button { font: inherit; cursor: pointer; }

.primary {
  background: var(--accent);
  color: var(--accent-text);
  border: 0;
  border-radius: 10px;
  padding: 12px;
  font-weight: 600;
}

.primary:disabled { opacity: 0.6; }

.gate-btn {
  width: min(70vw, 240px);
  aspect-ratio: 1;
  border-radius: 50%;
  border: 0;
  background: var(--accent);
  color: var(--accent-text);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 1.4rem;
  font-weight: 700;
  box-shadow: 0 10px 30px rgb(37 99 235 / 0.35);
  transition: transform 0.1s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.gate-btn svg {
  width: 56px;
  height: 56px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.gate-btn:active { transform: scale(0.96); }
.gate-btn:disabled { cursor: default; }
.gate-btn.busy { opacity: 0.7; }
.gate-btn.done { background: var(--ok); box-shadow: 0 10px 30px rgb(21 128 61 / 0.35); }
.gate-btn.fail { background: var(--err); box-shadow: 0 10px 30px rgb(185 28 28 / 0.35); }

.msg { min-height: 1.5em; margin: 0; text-align: center; }
.msg.ok { color: var(--ok); }
.msg.err { color: var(--err); }

.muted { color: var(--muted); }
.small { font-size: 0.85rem; }

.link {
  background: none;
  border: 0;
  padding: 0 0 0 8px;
  color: var(--accent);
  text-decoration: underline;
}
