:root {
  color-scheme: light;
  --page: #ffffff;
  --surface: #f5f5f7;
  --surface-raised: #ffffff;
  --text: #1d1d1f;
  --secondary: #6e6e73;
  --tertiary: #86868b;
  --separator: rgba(0, 0, 0, .12);
  --separator-soft: rgba(0, 0, 0, .07);
  --brand: #087a80;
  --brand-hover: #066b70;
  --brand-soft: #e8f4f4;
  --link: #0066cc;
  --success: #248a3d;
  --danger: #d70015;
  --focus: #0071e3;
  --on-brand: #ffffff;
  --page-max: 980px;
  --content-max: 680px;
  --gutter: 24px;
}

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

html {
  min-height: 100%;
  background: var(--page);
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  min-height: 100svh;
  margin: 0;
  color: var(--text);
  background: var(--page);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Helvetica Neue", sans-serif;
  font-size: 17px;
  line-height: 1.47;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }

.global-header {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 52px;
  border-bottom: 1px solid var(--separator-soft);
  background: color-mix(in srgb, var(--page) 84%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  backdrop-filter: saturate(180%) blur(18px);
}

.global-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(var(--page-max), calc(100% - 2 * var(--gutter)));
  min-height: 52px;
  margin: 0 auto;
}

.wordmark {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  gap: 9px;
  color: var(--text);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -.015em;
}

.wordmark:hover { text-decoration: none; }
.wordmark picture { display: contents; }
.wordmark img { display: block; width: 28px; height: 28px; border-radius: 7px; }
.nav-context { color: var(--secondary); font-size: 13px; }
.nav-link { min-height: 44px; display: inline-flex; align-items: center; font-size: 14px; }

.page-shell {
  display: flex;
  flex-direction: column;
  width: min(var(--page-max), calc(100% - 2 * var(--gutter)));
  min-height: calc(100svh - 53px);
  margin: 0 auto;
  padding-bottom: max(28px, env(safe-area-inset-bottom));
}

.hero {
  padding: 62px 0 42px;
  text-align: center;
}

.hero-label {
  margin: 0 0 11px;
  color: var(--brand);
  font-size: 14px;
  font-weight: 600;
}

h1, h2, p { margin-top: 0; }

.hero h1 {
  max-width: 760px;
  margin: 0 auto;
  font-size: clamp(48px, 7vw, 72px);
  font-weight: 650;
  line-height: 1.04;
  letter-spacing: -.055em;
}

.hero-copy {
  margin: 22px 0 0;
  color: var(--secondary);
  font-size: clamp(19px, 2.4vw, 23px);
  line-height: 1.35;
  letter-spacing: -.015em;
}

body:not([data-stage="start"]) .hero { display: none; }
body:not([data-stage="start"]) .enrollment-surface { margin-top: 56px; }

.enrollment-surface {
  width: min(100%, var(--content-max));
  margin: 0 auto;
  border: 1px solid var(--separator);
  border-radius: 28px;
  background: var(--surface-raised);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .03);
}

.stage-panel { padding: 42px 56px 46px; }
.stage-content { max-width: 470px; margin: 0 auto; }
.stage-header { margin-bottom: 26px; text-align: center; }

.stage-header h2 {
  margin-bottom: 9px;
  font-size: 32px;
  font-weight: 600;
  line-height: 1.16;
  letter-spacing: -.035em;
  outline: none;
}

.stage-header p {
  margin-bottom: 0;
  color: var(--secondary);
  font-size: 16px;
  line-height: 1.5;
}

.field-label {
  display: block;
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 600;
}

input[type="text"] {
  display: block;
  width: 100%;
  height: 52px;
  padding: 0 15px;
  color: var(--text);
  border: 1px solid var(--separator);
  border-radius: 12px;
  outline: none;
  background: var(--page);
  font-size: 17px;
  letter-spacing: .045em;
  text-transform: uppercase;
  transition: border-color .16s ease, box-shadow .16s ease;
}

input[type="text"]::placeholder { color: var(--tertiary); opacity: .72; }
input[type="text"]:focus { border-color: var(--focus); box-shadow: 0 0 0 4px color-mix(in srgb, var(--focus) 18%, transparent); }
input[type="text"][aria-invalid="true"] { border-color: var(--danger); }

.consent-row {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 11px;
  align-items: start;
  margin: 18px 0 22px;
  color: var(--secondary);
  font-size: 13px;
  line-height: 1.55;
}

.consent-row input {
  width: 20px;
  height: 20px;
  margin: 1px 0 0;
  accent-color: var(--brand);
}

.primary-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 50px;
  padding: 0 22px;
  gap: 8px;
  color: var(--on-brand);
  border: 0;
  border-radius: 999px;
  background: var(--brand);
  cursor: pointer;
  font-size: 16px;
  font-weight: 600;
  text-decoration: none;
  transition: background .16s ease, transform .12s ease, opacity .16s ease;
}

.primary-button:hover { background: var(--brand-hover); text-decoration: none; }
.primary-button:active { transform: scale(.985); }
.primary-button:disabled { cursor: wait; opacity: .55; }
.primary-button svg { width: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.primary-button.busy .button-label::after { content: "…"; }

.version-label,
.detail-copy,
.install-note {
  color: var(--secondary);
  font-size: 12px;
  line-height: 1.45;
}

.form-message { margin: 13px 2px 0; color: var(--danger); font-size: 13px; line-height: 1.45; }
.form-message.success-message { color: var(--success); }

.instruction-list {
  margin: 0 0 22px;
  padding: 0;
  overflow: hidden;
  list-style: none;
  border-radius: 16px;
  background: var(--surface);
}

.instruction-list li {
  display: grid;
  grid-template-columns: 26px 1fr;
  gap: 12px;
  align-items: start;
  min-height: 58px;
  padding: 16px;
}

.instruction-list li + li { border-top: 1px solid var(--separator-soft); }
.instruction-list li > span { color: var(--brand); font-size: 14px; font-weight: 650; line-height: 1.55; }
.instruction-list p { margin: 0; color: var(--secondary); font-size: 14px; line-height: 1.55; }
.instruction-list strong { color: var(--text); font-weight: 600; }

.waiting-row {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  gap: 9px;
  color: var(--secondary);
  font-size: 14px;
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--separator);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin .9s linear infinite;
}

.text-button,
.delete-button {
  display: block;
  min-height: 44px;
  margin: 8px auto 0;
  padding: 0 12px;
  border: 0;
  background: transparent;
  cursor: pointer;
  font-size: 14px;
}

.text-button { color: var(--link); }
.delete-button { margin: 8px 0 0; padding-left: 0; color: var(--danger); }
.text-button:hover, .delete-button:hover { text-decoration: underline; }
.text-button:disabled, .delete-button:disabled { cursor: wait; opacity: .55; }

.success-panel { text-align: center; }
.status-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin: 0 auto 20px;
  color: var(--success);
  border-radius: 50%;
  background: color-mix(in srgb, var(--success) 12%, transparent);
}
.status-mark svg { width: 25px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.status-mark.rejected { color: var(--danger); background: color-mix(in srgb, var(--danger) 11%, transparent); }
.installation-panel { margin-top: 26px; }
.version-label { margin: 10px 0 0; }
.install-note { margin: 3px 0 0; }

.registration-details {
  margin-top: 26px;
  padding-top: 20px;
  border-top: 1px solid var(--separator-soft);
  text-align: left;
}

.registration-details summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 44px;
  color: var(--secondary);
  cursor: pointer;
  font-size: 14px;
  list-style: none;
}

.registration-details summary::-webkit-details-marker { display: none; }
.registration-details summary::after { color: var(--tertiary); content: "+"; font-size: 20px; font-weight: 300; }
.registration-details[open] summary::after { content: "−"; }
.device-summary { display: flex; justify-content: space-between; gap: 18px; padding-top: 10px; color: var(--secondary); font-size: 13px; }
.device-summary strong { color: var(--text); font: 600 13px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace; }
.detail-copy { margin: 5px 0 0; }

footer {
  display: flex;
  justify-content: center;
  gap: 18px;
  margin-top: auto;
  padding: 54px 0 4px;
  color: var(--tertiary);
  font-size: 12px;
  text-align: center;
}

.legal-page { width: min(760px, calc(100% - 2 * var(--gutter))); }
.legal-hero { padding: 72px 0 38px; }
.legal-hero h1 { margin: 0; font-size: clamp(40px, 6vw, 56px); font-weight: 650; line-height: 1.05; letter-spacing: -.05em; }
.legal-hero p { margin: 16px 0 0; color: var(--secondary); font-size: 17px; }
.legal-copy { padding-bottom: 28px; }
.legal-section { padding: 25px 0; border-top: 1px solid var(--separator-soft); }
.legal-section h2 { margin: 0 0 9px; font-size: 20px; font-weight: 600; letter-spacing: -.02em; }
.legal-section p { margin: 0; color: var(--secondary); font-size: 15px; line-height: 1.62; }

button:focus-visible,
a:focus-visible,
input:focus-visible,
summary:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--focus) 55%, transparent);
  outline-offset: 3px;
}

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

@media (max-width: 620px) {
  :root { --gutter: 18px; }
  .global-nav { min-height: 48px; }
  .global-header { min-height: 48px; }
  .page-shell { min-height: calc(100svh - 49px); }
  .hero { padding: 48px 0 34px; }
  .hero-label { margin-bottom: 9px; font-size: 13px; }
  .hero h1 { font-size: clamp(37px, 11.2vw, 46px); line-height: 1.06; letter-spacing: -.048em; }
  .hero-copy { margin-top: 15px; font-size: 18px; }
  body:not([data-stage="start"]) .enrollment-surface { margin-top: 30px; }
  .enrollment-surface { border-radius: 22px; }
  .stage-panel { padding: 34px 22px 38px; }
  .stage-header { margin-bottom: 24px; }
  .stage-header h2 { font-size: 27px; }
  .stage-header p { font-size: 15px; }
  .consent-row { margin-bottom: 20px; }
  footer { padding-top: 40px; }
  .legal-hero { padding: 52px 0 28px; }
  .legal-hero h1 { font-size: 39px; }
}

@media (max-width: 360px) {
  :root { --gutter: 14px; }
  .hero h1 { font-size: 36px; }
  .stage-panel { padding-right: 18px; padding-left: 18px; }
  .stage-indicator > span { gap: 4px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
