@font-face {
  font-family: "Space Grotesk";
  src: url("SpaceGrotesk-Bold.woff") format("woff");
  font-display: swap;
  font-weight: 700;
}

@font-face {
  font-family: Montserrat;
  src: url("Montserrat-Regular.woff") format("woff");
  font-display: swap;
  font-weight: 400;
}

:root {
  color-scheme: light;
  --dark: #33373b;
  --deep: #26292c;
  --muted: #64676a;
  --mint: #75f8cc;
  --sky: #c0f4fb;
  --paper: #fff;
  --surface: #f7f7f7;
  --border: #d2d3d4;
  --success: #247d55;
  --error: #a62828;
  --error-surface: #fdecec;
  --gutter: 20px;
  --display: "Space Grotesk", system-ui, sans-serif;
  --body: Montserrat, system-ui, sans-serif;
  color: var(--dark);
  background: var(--paper);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.5;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
img { display: block; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3, strong, button, summary, .desktop-brand, .home-brand { font-family: var(--display); }

h1 {
  font-size: 1.875rem;
  font-weight: 700;
  letter-spacing: -.045em;
  line-height: 1.13;
  overflow-wrap: anywhere;
}

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

button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }

a { color: inherit; text-underline-offset: .22em; }
a:hover { text-decoration-thickness: 2px; }

.button, .text-button, .icon-button {
  align-items: center;
  display: inline-flex;
  font-family: var(--display);
  font-size: 1rem;
  font-weight: 700;
  justify-content: center;
  min-height: 44px;
  min-width: 44px;
  text-align: center;
}

.button {
  border: 1px solid transparent;
  border-radius: 12px;
  line-height: 1.2;
  min-height: 48px;
  padding: 10px 16px;
}

.button-primary { background: var(--dark); color: white; }
.button-primary:hover { background: var(--deep); }
.button-secondary { background: var(--paper); border-color: #777b7e; color: var(--dark); }
.button-secondary:hover { background: var(--surface); }
.button-full { width: 100%; }
.button:disabled { background: var(--surface); border-color: var(--border); color: var(--muted); }

.text-button, .icon-button {
  background: transparent;
  border: 0;
  border-radius: 8px;
  color: inherit;
  padding: 8px 4px;
}

.text-button { text-decoration: underline; text-underline-offset: .24em; }
.text-button:hover { text-decoration-thickness: 2px; }

input:not([type="checkbox"], [type="range"]), select {
  background: var(--paper);
  border: 1px solid #777b7e;
  border-radius: 12px;
  color: var(--dark);
  display: block;
  font-size: 1rem;
  margin-top: 6px;
  min-height: 48px;
  padding: 10px 12px;
  width: 100%;
}

input[aria-invalid="true"] { border-color: var(--error); }
label { font-family: var(--display); font-weight: 700; }
.field-error { color: var(--error); font-size: .875rem; margin-top: 8px; }
.field-error:empty, .notice:empty, .copy-status:empty { display: none; }

.opening, .busy-screen, .desktop-gate, .result-screen { min-height: 100vh; min-height: 100dvh; }
.opening { background: var(--dark); color: white; display: grid; place-items: center; text-align: center; }
.opening-content { display: grid; justify-items: center; padding: 32px var(--gutter); }
.opening h1 { font-size: clamp(2.4rem, 9vw, 3.5rem); margin: 12px 0 24px; }
.opening-status { align-items: center; display: flex; gap: 10px; }
.opening-status p { font-size: .875rem; }

.spinner {
  animation: spin .85s linear infinite;
  border: 2px solid currentColor;
  border-inline-end-color: transparent;
  border-radius: 50%;
  color: inherit;
  display: block;
  height: 18px;
  width: 18px;
}

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

.mobile-shell {
  margin-inline: auto;
  max-width: 500px;
  padding: env(safe-area-inset-top) max(var(--gutter), env(safe-area-inset-right)) max(28px, env(safe-area-inset-bottom)) max(var(--gutter), env(safe-area-inset-left));
}

.home-brand, .utility-identity { align-items: center; display: flex; gap: 9px; font-weight: 700; }
.home-brand { font-size: 1.25rem; margin-bottom: 12px; min-height: 56px; }

.home-card { border: 1px solid var(--border); border-radius: 20px; overflow: hidden; }
.home-intro { background: var(--sky); display: grid; gap: 12px; padding: 20px; }
.home-intro p { font-size: .875rem; line-height: 1.55; }
.enrol-intro { align-items: center; display: flex; gap: 14px; }
.enrol-intro img { flex: none; }

#registration { display: grid; padding: 20px; }
#registration .check { align-items: center; display: flex; font: .875rem/1.5 var(--body); gap: 10px; margin-top: 10px; min-height: 44px; }
#registration .check input { accent-color: var(--dark); flex: none; height: 20px; margin: 0; width: 20px; }
#registration [type="submit"] { margin-top: 12px; }

.paired-icons { align-items: center; display: flex; gap: 8px; }
.paired-icons > img, .paired-icons > svg {
  background: var(--paper);
  border-radius: 12px;
  height: 42px;
  padding: 7px;
  width: 42px;
}

.short-arrow { font-family: var(--display); font-size: 1.2rem; }
.account-field { background: var(--paper); border: 1px solid var(--border); border-radius: 14px; padding: 10px 12px; }
.account-field label { display: block; }
.account-field select { margin-bottom: 0; }
#accountName { font-family: var(--display); font-size: 1rem; font-weight: 700; overflow-wrap: anywhere; }

.record, .result-record {
  align-items: center;
  background: var(--surface);
  display: flex;
  gap: 10px;
  min-height: 60px;
  padding: 12px;
}

.record { margin: 12px; border-radius: 14px; flex-wrap: wrap; }
.record-description { display: grid; flex: 1 0 auto; }
.record-description span, .result-record span { color: var(--muted); display: block; font-size: .875rem; }
#reviewEnrolled { font-size: .875rem; padding-inline: 10px; }

.account-extras { margin-top: 12px; }
details { border-bottom: 1px solid var(--border); border-top: 1px solid var(--border); margin-top: 8px; }

summary {
  align-content: center;
  cursor: pointer;
  font-weight: 700;
  min-height: 48px;
  padding: 8px 4px;
}

#recovery { padding: 0 4px 12px; }
#recovery .button { margin-top: 12px; }
.tab-code { font-family: var(--display); font-size: 1rem; margin: 0 0 8px; }

.notice {
  background: var(--surface);
  border-radius: 12px;
  font-size: .875rem;
  margin-block: 0 12px;
  padding: 12px;
}

.notice[data-tone="error"] { background: var(--error-surface); color: var(--error); }
.helper { color: var(--muted); font-size: .875rem; margin-bottom: 8px; }
.recovery-actions { align-items: center; display: flex; flex-wrap: wrap; gap: 8px; }
.recovery-actions:has(:not([hidden])) { margin-bottom: 12px; }

.desktop-gate {
  background: var(--surface);
  display: grid;
  padding: 28px var(--gutter);
  place-items: center;
}

.desktop-shell { width: min(100%, 880px); }
.desktop-brand { align-items: center; display: flex; font-size: 1.125rem; font-weight: 700; gap: 16px; margin-bottom: 16px; }
.desktop-brand span { border-inline-start: 1px solid var(--border); padding-inline-start: 16px; }
.desktop-card {
  align-items: stretch;
  background: var(--sky);
  border-radius: 24px;
  display: grid;
  gap: clamp(16px, 4vw, 40px);
  grid-template-columns: minmax(0, 1fr) 270px;
  padding: clamp(16px, 4.5vw, 44px);
}

.desktop-content { align-content: center; display: grid; gap: 12px; justify-items: start; }
.desktop-content h1 { font-size: clamp(2rem, 4.9vw, 3.75rem); max-width: 13ch; }
.desktop-content p { max-width: 29ch; }
.device-icon { background: var(--paper); border-radius: 14px; display: grid; height: 44px; place-items: center; width: 44px; }

.qr-card {
  align-content: center;
  background: var(--paper);
  border-radius: 16px;
  display: grid;
  gap: 8px;
  justify-items: center;
  min-width: 0;
  padding: 12px 8px;
  text-align: center;
}

.qr-card img, .qr-card svg { height: auto; width: min(224px, 100%); }
.qr-card a { display: grid; min-height: 44px; align-items: center; overflow-wrap: anywhere; }
.copy-status { color: var(--muted); font-size: .875rem; }

.busy-screen {
  display: grid;
  grid-template-rows: auto 1fr;
  padding-top: env(safe-area-inset-top);
}

.utility-bar {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin: 0 auto;
  max-width: 500px;
  min-height: 56px;
  padding-inline: var(--gutter);
  width: 100%;
}

.busy-content {
  align-content: center;
  display: grid;
  gap: 20px;
  justify-items: center;
  margin: 0 auto;
  max-width: 420px;
  padding: 24px var(--gutter) max(24px, env(safe-area-inset-bottom));
  text-align: center;
}

.busy-content p { margin-top: 8px; }
.busy-illustration { background: var(--sky); border-radius: 24px; display: grid; height: 148px; place-items: center; width: 148px; }

.result-screen { background: var(--success); display: flex; flex-direction: column; }

.result-hero {
  align-items: center;
  display: flex;
  height: clamp(176px, 28dvh, 248px);
  justify-content: center;
  padding: max(14px, env(safe-area-inset-top)) var(--gutter) 10px;
}

.result-check {
  border: 2px solid white;
  border-radius: 50%;
  color: white;
  display: grid;
  font: 3rem/1 var(--display);
  height: 80px;
  place-items: center;
  width: 80px;
}

.result-sheet {
  background: var(--paper);
  border-radius: 24px 24px 0 0;
  display: grid;
  flex: 1;
  justify-items: center;
  padding: 24px var(--gutter) max(20px, env(safe-area-inset-bottom));
}

.result-body { display: flex; flex-direction: column; gap: 12px; max-width: 460px; width: 100%; }
.result-body > p:empty { display: none; }
.result-record { border-radius: 14px; overflow-wrap: anywhere; }
.result-record > svg, .result-record > img { flex: none; }
.result-actions { display: grid; gap: 4px; margin-top: auto; padding-top: 12px; }

#capture {
  --capture-bg: #17191a;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--capture-bg);
  color: white;
  display: flex;
  flex-direction: column;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
}

#capture :focus-visible, #opening :focus-visible { outline-color: var(--mint); }
#capture[inert] { inset: 0; opacity: 0; pointer-events: none; position: fixed; }

.capture-bar {
  align-items: center;
  background: var(--dark);
  display: flex;
  gap: 10px;
  justify-content: space-between;
  min-height: calc(52px + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) var(--gutter) 0;
}

.capture-bar strong { line-height: 1.25; }

.feed {
  background: #212426;
  display: grid;
  min-height: 270px;
  height: 65vh;
  height: 65dvh;
  overflow: hidden;
  place-items: center;
  position: relative;
}

.feed video, .scrim { height: 100%; inset: 0; object-fit: cover; position: absolute; width: 100%; }
.scrim { background: linear-gradient(#000a, transparent 37%, transparent 72%, #0006); pointer-events: none; }
.gauge { color: white; position: absolute; text-align: center; text-shadow: 0 1px 4px black; top: 12px; }
#dots { align-items: center; display: flex; gap: 8px; height: 26px; justify-content: center; }
#dots i { border: 1.5px solid white; border-radius: 50%; display: block; height: 12px; width: 12px; }
#dots i:nth-child(1) { height: 6px; width: 6px; }
#dots i:nth-child(2) { height: 8px; width: 8px; }
#dots i:nth-child(3) { height: 10px; width: 10px; }
#dots i:nth-child(5) { height: 14px; width: 14px; }
#dots i:nth-child(6) { height: 16px; width: 16px; }
#dots i:nth-child(7) { height: 18px; width: 18px; }
#dots i.active { background: var(--mint); border-color: var(--mint); outline: 1px solid white; outline-offset: 2px; }

.target { aspect-ratio: 1; display: grid; place-items: center; position: relative; width: min(64vw, 36dvh, 320px); }
.target > i { border: solid white; border-width: 3px 0 0 3px; height: 14%; position: absolute; width: 14%; }
.target > i:nth-child(1) { left: 0; top: 0; }
.target > i:nth-child(2) { right: 0; top: 0; transform: rotate(90deg); }
.target > i:nth-child(3) { bottom: 0; right: 0; transform: rotate(180deg); }
.target > i:nth-child(4) { bottom: 0; left: 0; transform: rotate(270deg); }

#finger { bottom: 102%; font: 700 .875rem/1.25 var(--display); position: absolute; text-shadow: 0 1px 4px black; }
.capsule { border: 2px dashed white; border-radius: 99px; height: 92%; position: relative; transform: rotate(45deg); width: 40%; }
.capsule::after { border: 2px dashed var(--mint); border-radius: 99px; content: ""; inset: -8%; opacity: 0; position: absolute; }
.detected .capsule { border-color: var(--mint); border-style: solid; }
.detected .capsule::after { opacity: 1; }
.pad { aspect-ratio: 1; border: 1.5px solid white; border-radius: 50%; left: 7.5%; position: absolute; top: 10%; width: 85%; }
.arcs { border: 3px dashed var(--mint); border-radius: 50%; inset: -7px; opacity: 0; position: absolute; }
#capture[data-state="CAPTURING"] .arcs { animation: spin 5s linear infinite; opacity: 1; }
#capture[data-state="SUCCESS"] .guide-icon { color: var(--mint); }

.banner {
  align-items: center;
  background: var(--dark);
  bottom: 0;
  display: flex;
  font-size: .875rem;
  gap: 8px;
  justify-content: center;
  min-height: 48px;
  padding: 8px var(--gutter);
  position: absolute;
  text-align: center;
  width: 100%;
}

.guide-icon { font-size: 1.1rem; }
.controls { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; padding: 12px var(--gutter) 0; }
#manual { background: var(--mint); color: var(--dark); }
#torch { background: var(--dark); border-color: #b1b3b5; color: white; }
#torch[aria-pressed="true"] { border-color: var(--mint); color: var(--mint); }
#manual:disabled, #torch:disabled { background: var(--dark); border-color: #64676a; color: #d2d3d4; }

#review {
  background: white;
  display: grid;
  grid-template-rows: auto auto minmax(180px, 1fr) auto;
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
  text-align: center;
}

.review-bar {
  align-items: center;
  border-bottom: 1px solid var(--border);
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) 52px;
  min-height: calc(52px + env(safe-area-inset-top));
  padding-top: env(safe-area-inset-top);
}

.review-bar small { color: var(--muted); display: block; font-size: .75rem; }
.review-bar .icon-button { font-size: 1.375rem; }
#reviewFinger { font-size: 1.375rem; margin: 8px var(--gutter); overflow-wrap: anywhere; }
.paper { align-self: stretch; background: var(--surface); display: grid; place-items: center; }
.print { aspect-ratio: 1; position: relative; width: min(88vw, 48dvh, 520px); }
.print canvas { height: 100%; inset: 0; position: absolute; width: 100%; }
.tools { margin-inline: auto; max-width: 520px; padding: 10px var(--gutter) 0; width: 100%; }
.tools p { color: var(--muted); font-size: .875rem; margin-bottom: 8px; }
.toolrow { display: grid; gap: 4px; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 10px; }

.toolrow button {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--dark);
  font: 700 .8125rem/1.1 var(--display);
  min-height: 48px;
  min-width: 44px;
  overflow-wrap: anywhere;
  padding: 4px;
}

.toolrow b { display: block; font-size: 1.15rem; margin-block: 2px; }
.toolrow [aria-pressed="true"] { background: var(--sky); border-color: var(--dark); }
.ends { display: flex; font: 700 .875rem var(--display); justify-content: space-between; }
#adjust { accent-color: var(--dark); display: block; margin: 0; min-height: 44px; width: 100%; }

#reviewDialog {
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 16px;
  color: var(--dark);
  max-width: min(95vw, 382px);
  padding: 18px;
  text-align: start;
}

#reviewDialog::backdrop { background: #23282c90; }
#reviewDialog h3 { font-size: 1.25rem; margin-bottom: 6px; }
#reviewDialog p { font-size: .875rem; }
#reviewDialog > div { display: flex; flex-wrap: wrap; gap: 8px; justify-content: end; margin-top: 16px; }

@media (max-width: 767px) {
  .desktop-card { grid-template-columns: minmax(0, 1fr); }
  .qr-card { width: min(100%, 270px); }
}

@media (max-width: 360px) {
  :root { --gutter: 16px; }
  .home-intro, #registration { padding: 16px; }
  .enrol-intro img { height: 52px; width: 52px; }
}

@media (max-height: 500px) {
  .feed { height: max(230px, calc(100dvh - 122px - env(safe-area-inset-top))); min-height: 230px; }
  .busy-illustration { height: 96px; width: 96px; }
  .busy-illustration img { height: 88px; width: 88px; }
}

@media (prefers-reduced-motion: reduce) {
  .spinner, #capture[data-state="CAPTURING"] .arcs { animation: none; }
}

@media (scripting: none) {
  .opening-status { display: none; }
}
