/* Design tokens ---------------------------------------------------------- */
:root {
  --void: #f4f5f8;
  --panel: #ffffff;
  --panel-2: #eef0f5;
  --hairline: rgba(20, 23, 35, 0.08);
  --hairline-strong: rgba(20, 23, 35, 0.15);
  --bone: #14151b;
  --slate: #6b6f7d;

  /* The signal is a gradient, not a flat hex — the single-flat-accent look
     is the exact AI-default this system is deliberately avoiding. Amber ->
     coral, the same pair used in the icon mark, unchanged from the dark
     build so the brand mark reads identically in both themes. */
  --amber: #f0a742;
  --coral: #ff6b57;
  --signal-gradient: linear-gradient(135deg, var(--amber), var(--coral));
  --confirm: #1f9660;
  --danger: #d1442c;

  --font-display: -apple-system, "Segoe UI", Roboto, system-ui, sans-serif;
  --font-body: -apple-system, "Segoe UI", Roboto, system-ui, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Roboto Mono", "Cascadia Code", monospace;

  --radius: 22px;
  --radius-sm: 14px;
  --bar-h: 92px;
}

* { box-sizing: border-box; }

/* [hidden] must always win, even against component classes with equal
   specificity (e.g. .action-bar sets display:flex) — without this, an
   element can end up simultaneously "hidden" and visually flexed/shown. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--void);
  color: var(--bone);
  font-family: var(--font-body);
  -webkit-tap-highlight-color: transparent;
}

body {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
}

/* Atmosphere: a soft aura bloomed from the icon's own gradient, fixed behind
   everything. On the light canvas this reads as a warm wash of sunlight
   rather than a glow in the dark — same signature, different register. */
body::before {
  content: "";
  position: fixed;
  top: -20%;
  left: 50%;
  width: 640px;
  height: 640px;
  transform: translateX(-50%);
  background: radial-gradient(circle, rgba(240, 167, 66, 0.20), rgba(255, 107, 87, 0.10) 45%, transparent 72%);
  filter: blur(10px);
  pointer-events: none;
  z-index: 0;
}

main {
  position: relative;
  z-index: 1;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 28px 24px calc(var(--bar-h) + 32px);
  max-width: 480px;
  width: 100%;
  margin: 0 auto;
}

/* Motion respect ---------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* App identity block (index.html) ----------------------------------------- */
.app-id {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.app-icon-wrap {
  position: relative;
  width: 120px;
  height: 120px;
  margin-bottom: 24px;
}

.app-icon-wrap svg {
  position: absolute;
  inset: -11px;
  transform: rotate(-90deg);
}

.app-icon-wrap circle {
  fill: none;
  stroke-width: 3;
}

.app-icon-wrap .ring-track { stroke: var(--hairline); }

.app-icon-wrap .ring-fill {
  stroke: url(#ringGradient);
  stroke-linecap: round;
  stroke-dasharray: 358;
  stroke-dashoffset: 358;
  transition: stroke-dashoffset 0.6s ease;
  opacity: 0;
}

.app-icon-wrap.ready .ring-fill {
  stroke-dashoffset: 0;
  opacity: 1;
}

.app-icon-wrap.installing .ring-fill {
  animation: spin 1.1s linear infinite;
  transform-origin: center;
}

@keyframes spin { to { transform: rotate(270deg); } }

.app-icon {
  position: absolute;
  inset: 11px;
  border-radius: 26px;
  background: var(--panel);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  box-shadow: 0 14px 34px -10px rgba(255, 107, 87, 0.35), inset 0 0 0 1px var(--hairline);
}

.app-icon img { width: 100%; height: 100%; object-fit: cover; display: block; }

.app-name {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 32px;
  letter-spacing: -0.015em;
  margin: 0 0 8px;
}

.app-meta {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--slate);
  margin: 0 0 36px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.app-meta .dot { color: var(--hairline-strong); }
.app-meta .verified { color: var(--confirm); text-transform: none; letter-spacing: 0; font-weight: 600; }

.benefits {
  list-style: none;
  padding: 4px 18px;
  margin: 0;
  width: 100%;
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(20, 23, 35, 0.04);
}

.benefits li {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 14.5px;
  line-height: 1.4;
  color: var(--bone);
  padding: 15px 0;
  text-align: left;
}

.benefits li + li { border-top: 1px solid var(--hairline); }

.benefits .glyph {
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(31, 150, 96, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
}

.benefits .glyph svg { width: 13px; height: 13px; }

/* Status line -------------------------------------------------------------- */
.status-line {
  color: var(--slate);
  font-size: 14px;
  text-align: center;
  margin: 0;
}

.status-line.error { color: var(--danger); }

/* iOS install steps --------------------------------------------------------- */
.ios-steps {
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  font-size: 14px;
  color: var(--bone);
  line-height: 1.6;
  margin-top: 24px;
}

.ios-steps strong { color: #c17d1f; }

/* Sticky bottom action bar --------------------------------------------------- */
.action-bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: var(--bar-h);
  padding: 0 24px calc(env(safe-area-inset-bottom, 0px));
  background: linear-gradient(to top, var(--void) 55%, transparent);
  display: flex;
  align-items: center;
  z-index: 10;
}

.btn {
  width: 100%;
  border: none;
  border-radius: 999px;
  padding: 17px 20px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 16px;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease, box-shadow 0.15s ease;
}

.btn:active { transform: scale(0.98); }
.btn[disabled] { opacity: 0.5; cursor: default; }

.btn-primary {
  background: var(--signal-gradient);
  color: #1a1305;
  box-shadow: 0 12px 28px -8px rgba(255, 107, 87, 0.4);
}

.btn-primary:hover { box-shadow: 0 14px 32px -6px rgba(255, 107, 87, 0.55); }

.btn:focus-visible {
  outline: 2px solid var(--coral);
  outline-offset: 3px;
}

/* Progress dots (pin.html stages) ------------------------------------------- */
.stages {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 36px;
}

.stages .stage {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--hairline-strong);
  transition: background 0.25s ease, width 0.25s ease;
}

.stages .stage.active { background: var(--signal-gradient); width: 22px; border-radius: 4px; }
.stages .stage.done { background: var(--confirm); }

/* Verification screen -------------------------------------------------------- */
.verify-head {
  text-align: center;
  margin-bottom: 32px;
}

.verify-head h1 {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 24px;
  margin: 0 0 8px;
  letter-spacing: -0.015em;
}

.verify-head p {
  color: var(--slate);
  font-size: 14px;
  margin: 0;
  line-height: 1.5;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.field label {
  font-size: 13px;
  font-weight: 600;
  color: var(--slate);
}

.field input[type="tel"] {
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  color: var(--bone);
  font-family: var(--font-body);
  font-size: 17px;
  padding: 16px;
  min-height: 44px;
}

.field input[type="tel"]:focus {
  outline: none;
  border-color: var(--amber);
  box-shadow: 0 0 0 3px rgba(240, 167, 66, 0.18);
}

/* PIN input rendered as boxed digits via a fixed-pixel background pitch +
   matching letter-spacing. letter-spacing does NOT accept percentages (an
   earlier version tried calc(% ...) here — invalid, silently dropped, so
   the boxes never actually rendered) so every value below is a plain px length. */
.pin-input-wrap {
  position: relative;
  margin: 4px 0 24px;
  width: min(280px, 100%);
}

.pin-input-wrap input {
  width: 100%;
  min-height: 58px;
  background: repeating-linear-gradient(
    to right,
    var(--panel-2) 0, var(--panel-2) 40px,
    transparent 40px, transparent 48px
  );
  background-size: 48px 100%;
  background-repeat: repeat-x;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--bone);
  font-family: var(--font-mono);
  font-size: 24px;
  font-weight: 600;
  letter-spacing: 34px;
  padding: 0 0 0 13px;
  text-align: left;
}

.pin-input-wrap input:focus { outline: none; }

.pin-input-wrap::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: var(--radius-sm);
  border: 1px solid var(--hairline);
  pointer-events: none;
}

.pin-input-wrap:has(input:focus)::before {
  border-color: var(--amber);
  box-shadow: 0 0 0 3px rgba(240, 167, 66, 0.18);
}

/* Countdown ring on the pin screen ------------------------------------------ */
.countdown {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--slate);
  font-size: 13px;
  margin-top: -4px;
  margin-bottom: 20px;
}

.countdown svg { width: 16px; height: 16px; }
.countdown circle { fill: none; stroke-width: 2; }
.countdown .ring-track { stroke: var(--hairline); }
.countdown .ring-fill {
  stroke: url(#countdownGradient);
  stroke-linecap: round;
  transform: rotate(-90deg);
  transform-origin: center;
  transition: stroke-dashoffset 1s linear;
}

.countdown .time { font-family: var(--font-mono); color: var(--bone); }
