/** Monochrome onboarding and sign-in layout for the tracer, in a dark and a light scheme.
 *
 * The sign-in pages stay black and white on purpose (the app's own themes are coloured). The scheme
 * is dark unless auth-scheme.ts sets data-auth-scheme="light" on the root: the system is light, or the
 * saved theme is a light one. Every colour below is a token; nothing else in this file may use a
 * literal black or white, so the light scheme cannot miss a spot. */
.auth-screen:not(.flow-layer) {
  --fg: #f4f4f5;
  --fg-2: #a1a1aa;
  --fg-3: #63636b;
  --on-fg: #000;
  --line: rgb(255 255 255 / 0.09);
  --edge: rgb(255 255 255 / 0.28);
  --strong: rgb(255 255 255 / 0.4);
  --ring: rgb(255 255 255 / 0.55);
  /* One material: the card and the fields are the same tint, the fields a touch denser. */
  --tint-a: 0.05;
  --halo: rgb(0 0 0 / 0.9);
  --card: rgb(0 0 0 / var(--tint-a));
  --field: rgb(0 0 0 / calc(var(--tint-a) + 0.14));
  --field-focus: rgb(0 0 0 / calc(var(--tint-a) + 0.26));
  --hover: rgb(255 255 255 / 0.06);
  --wash: rgb(255 255 255 / 0.03);
  --shade: rgb(0 0 0 / 0.9);
  --ui-on-fg: var(--on-fg);
}
:root[data-auth-scheme="light"] .auth-screen:not(.flow-layer) {
  --fg: #18181b;
  --fg-2: #52525b;
  --fg-3: #6b6b74;
  --on-fg: #fff;
  --line: rgb(0 0 0 / 0.1);
  --edge: rgb(0 0 0 / 0.32);
  --strong: rgb(0 0 0 / 0.4);
  --ring: rgb(0 0 0 / 0.55);
  --tint-a: 0.1;
  --halo: rgb(255 255 255 / 0.9);
  --card: rgb(255 255 255 / var(--tint-a));
  --field: rgb(255 255 255 / calc(var(--tint-a) + 0.14));
  --field-focus: rgb(255 255 255 / calc(var(--tint-a) + 0.26));
  --hover: rgb(0 0 0 / 0.05);
  --wash: rgb(0 0 0 / 0.03);
  --shade: rgb(0 0 0 / 0.28);
}
:root[data-auth-scheme="light"] { color-scheme: light; background: #f6f6f4; color: #18181b; }
/* The shared tick and counter assume a dark card: ink on the fill, a white hairline. */
.auth-screen:not(.flow-layer) .tick { color: var(--on-fg); box-shadow: inset 0 0 0 1.5px var(--edge); }
.auth-screen:not(.flow-layer) .busy-count { color: var(--on-fg); opacity: 0.6; }
.auth-screen {
  --ease: cubic-bezier(0.23, 1, 0.32, 1);
  position: fixed;
  z-index: 1;
  inset: 0;
  display: grid;
  place-items: safe center;
  overflow-y: auto;
  overscroll-behavior: contain;
  /* Tab scrolls a field just into view; without this its ring would sit flush against the screen edge, cut off. */
  scroll-padding: var(--focus-ring-room);
  padding: max(1.5rem, env(safe-area-inset-top)) 1.25rem max(1.5rem, env(safe-area-inset-bottom));
  color: var(--fg);
  background: transparent;
  font: var(--fw-body) 0.875rem/1.55 var(--font-face);
  letter-spacing: -0.01em;
}

#faulty-field {
  position: fixed;
  z-index: 0;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  transition: opacity 240ms ease-out;
}

.auth-card {
  min-width: 0;
  width: min(27.5rem, 100%);
  --auth-pad: 2.25rem;
  /* How far the actions row (.auth-actions) sits outside the pane's content so its icon lines up with the edge;
     the pane viewport leaves the focus ring room beyond it. */
  --auth-overhang: 0.5rem;
  padding: var(--auth-pad) 2rem var(--auth-pad);
  border-radius: 1.375rem;
  animation: auth-card-in 240ms var(--ease) both;
}
/* The card is the shared translucent overlay material (.ui-overlay-surface, packages/ui), tuned for
   this page through its instance properties: a black tint on dark (0.05), a white tint on light (0.10) and a
   4 px blur. The backdrop is low contrast, so a thin tint and a small blur are what make its drifting glyphs
   show through. No top-edge highlight. */
.auth-card.ui-overlay-surface {
  --ui-overlay-background: var(--card);
  --ui-overlay-border: var(--line);
  --ui-overlay-color: var(--fg);
  --ui-overlay-shadow: 0 1.875rem 5rem -1.875rem var(--shade);
  --ui-overlay-blur: 0.25rem;
  --ui-overlay-saturation: 100%;
}
/* Cards that are not glass stay solid. */
.auth-card:not(.ui-overlay-surface) { border: 1px solid var(--line); background: var(--card); box-shadow: 0 1.875rem 5rem -1.875rem rgb(0 0 0 / 0.9); }
/* Where the tint is thin a glyph can sit directly behind a letter, so the text carries a soft halo in
   the card's own tint colour (--halo) instead of the card getting more tint. */
.auth-card.ui-overlay-surface { text-shadow: 0 0 0.375rem var(--halo, transparent); }
.auth-card.ui-overlay-surface .auth-primary { text-shadow: none; }
@keyframes auth-card-in { from { opacity: 0; transform: translateY(0.5rem) scale(0.99); } }
.auth-mark { display: flex; align-items: center; gap: 0.625rem; margin-bottom: 1.75rem; font-weight: var(--fw-title); line-height: 1; }
.auth-mark svg { width: 1.375rem; height: 1.375rem; flex: none; }
.auth-card h1 { margin: 0 0 0.625rem; color: var(--fg); font: var(--fw-title) 1.3125rem/1.25 var(--font-face); letter-spacing: -0.03em; }
.auth-eyebrow { margin: 0 0 0.375rem; color: var(--fg-3); font: var(--fw-label) 0.75rem/1 var(--font-face); letter-spacing: 0.02em; }
.auth-lede { margin: 0 0 1.5rem; color: var(--fg-2); }
.auth-label { display: block; margin: 0 0 0.5rem; color: var(--fg-2); font-size: 0.8125rem; }
.auth-input {
  display: block;
  width: 100%;
  height: 3rem;
  margin: 0;
  padding: 0 0.875rem;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  outline: none;
  background: var(--field);
  color: var(--fg);
  font: var(--fw-body) 1rem/1 var(--font-face);
}
.auth-input:focus { border-color: var(--edge); background: var(--field-focus); }
.auth-mono { font-size: 1rem; letter-spacing: 0.01em; }
.auth-command {
  display: flex;
  min-height: 2.75rem;
  align-items: center;
  gap: 0.625rem;
  margin-top: 0.875rem;
  padding: 0.25rem 0.3125rem 0.25rem 0.75rem;
  border: 1px dashed var(--line);
  border-radius: 0.625rem;
  background: var(--wash);
  color: var(--fg-2);
  font-size: 0.78125rem;
}
.auth-command code { flex: 1; overflow-x: auto; white-space: nowrap; }
.auth-hint { min-height: 1em; margin: 0.375rem 0 0.875rem; color: var(--fg-3); font-size: 0.75rem; }
.recovery-word-label { margin-top: 1.125rem; }
.auth-word-inputs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.375rem; list-style: none; margin: 0; padding: 0; }
.auth-word-inputs li { display: flex; align-items: center; min-width: 0; border: 1px solid var(--line); border-radius: 0.5625rem; background: var(--field); }
.auth-word-inputs li > span { flex: none; width: 1.375rem; text-align: center; color: var(--fg-3); font-size: 0.625rem; }
.auth-word-inputs input { min-width: 0; width: 100%; height: 2.75rem; padding: 0 0.25rem 0 0; border: 0; border-radius: 0.5625rem; outline: none; color: var(--fg); background: transparent; font: var(--fw-body) 1rem/1 var(--font-face); }
.auth-word-inputs li:focus-within { border-color: var(--fg-2); background: var(--field-focus); }
.auth-word-inputs li:has([aria-invalid="true"]) { border-color: var(--fg); }
.auth-error-line { margin: 0.5rem 0 0; padding: 0.625rem 0.75rem; border-radius: 0.625rem; background: var(--hover); color: var(--fg); font-size: 0.84375rem; }
.auth-message { min-height: 1.4em; margin: 0.75rem 0 0; color: var(--fg-2); font-size: 0.75rem; line-height: 1.5; }

.auth-steps { display: flex; align-items: center; gap: 0; margin: 0 0 1.875rem; padding: 0; list-style: none; }
.auth-steps li { display: flex; flex: 1; align-items: center; }
.auth-steps li:last-child { flex: none; }
.auth-dot {
  display: grid;
  width: 1.5rem;
  height: 1.5rem;
  flex: none;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  color: var(--fg-3);
  font: var(--fw-label) 0.71875rem/1 var(--font-face);
  cursor: pointer;
}
.auth-dot:disabled { cursor: default; }
.auth-steps .is-current .auth-dot { border-color: var(--fg); background: var(--fg); color: var(--on-fg); }
.auth-steps .is-done .auth-dot { border-color: var(--edge); color: var(--fg); }
.auth-step-bar { position: relative; height: 1px; flex: 1; overflow: hidden; margin: 0 0.5rem; background: var(--line); }
.auth-step-bar::after { position: absolute; inset: 0; transform: scaleX(0); transform-origin: left; background: var(--strong); content: ""; transition: transform 240ms var(--ease); }
.auth-steps .is-done .auth-step-bar::after { transform: scaleX(1); }
.auth-steps .tick { width: 1.5rem; height: 1.5rem; border-radius: 50%; box-shadow: none; }
.auth-steps .tick-fill { background: var(--fg); }

/* The viewport clips the sliding panes and the height glide, so it must leave the focus ring room on all four
   sides (--focus-ring-room, packages/ui). The negative margin cancels the padding: the content does not move.
   Its `height` is the pane's height, set from the pane in script, so the box must be content-box: under the
   page-wide border-box the padding would eat 2 x room of that height and clip the pane's last lines.
   Sibling margins collapse with the negative one (steps 30 - 6, footer 26 - 6), which keeps the distances to
   the steps and the footer unchanged. */
.auth-viewport { box-sizing: content-box; position: relative; overflow: hidden; margin: calc(-1 * var(--focus-ring-room)) calc(-1 * (var(--focus-ring-room) + var(--auth-overhang))); padding: var(--focus-ring-room) calc(var(--focus-ring-room) + var(--auth-overhang)); transition: height 240ms var(--ease); }
.auth-pane { min-width: 0; transition: opacity 240ms var(--ease), transform 240ms var(--ease); }
.auth-pane[data-direction="forward"] { animation: auth-pane-forward 240ms var(--ease) both; }
.auth-pane[data-direction="back"] { animation: auth-pane-back 240ms var(--ease) both; }
.auth-pane[data-direction="none"] { animation: none; }
.auth-card[data-no-motion] .auth-input,
.auth-card[data-no-motion] .auth-dot,
.auth-card[data-no-motion] .auth-step-bar::after,
.auth-card[data-no-motion] .auth-viewport,
.auth-card[data-no-motion] .auth-pane,
.auth-card[data-no-motion] .auth-primary { transition: none; }
.auth-card[data-no-motion] .auth-pane { animation: none; }
.auth-card[data-no-motion] .auth-primary:active { transform: none; }
@keyframes auth-pane-forward { from { opacity: 0; transform: translateX(1.5rem); } }
@keyframes auth-pane-back { from { opacity: 0; transform: translateX(-1.5rem); } }
.auth-footer { display: flex; min-height: 2.625rem; justify-content: space-between; align-items: center; gap: 0.75rem; margin-top: 1.625rem; }
.auth-primary {
  display: inline-flex;
  min-width: 8.75rem;
  height: 2.625rem;
  align-items: center;
  justify-content: center;
  gap: 0.625rem;
  margin: 0 0 0 auto; /* Keep the primary button at the content edge when the hidden back control is removed. */
  padding: 0 1.25rem;
  border: 0;
  border-radius: 999px;
  background: var(--fg);
  color: var(--on-fg);
  font: var(--fw-title) 0.84375rem/1 var(--font-face);
  letter-spacing: -0.01em;
  cursor: pointer;
  transition: transform 140ms var(--ease), opacity 160ms ease;
}
.auth-primary:active { transform: scale(var(--ui-press-scale-soft)); }
.auth-primary[disabled] { transform: none; opacity: 0.35; cursor: default; }
.auth-primary svg { width: 1.125rem; height: 1.125rem; flex: none; }
.auth-footer .auth-primary { min-width: 8.75rem; }
.auth-back, .auth-text-button {
  border: 0;
  background: none;
  color: var(--fg-2);
  font: var(--fw-label) 0.84375rem/1 var(--font-face);
  cursor: pointer;
}
.auth-back { padding: 0.625rem 0.5rem; margin-left: -0.5rem; }
.auth-back[hidden] { display: inline; visibility: hidden; }
.auth-back:hover { color: var(--fg); }
/* The sign-in card hugs their content. Top and bottom padding are one value
   (--auth-pad), measured to the ink: when the last thing is a quiet text action, its own empty inset
   (--auth-tail, half the 44 px button's height minus its text) is taken off the bottom so the visible gap
   under the text equals the gap above the mark. */
#use-recovery, #recovery-card .auth-primary, #recovery-card .auth-back, #recovery-card .icon-action { min-width: 2.75rem; min-height: 2.75rem; }
.auth-signin { --auth-pad: 2.25rem; --auth-tail: 0.9375rem; padding: var(--auth-pad) 2rem var(--auth-pad); }
.auth-signin:has(.auth-text-button) { padding-bottom: calc(var(--auth-pad) - var(--auth-tail)); }
.auth-signin .auth-lede { margin-bottom: 1.75rem; }
.auth-login { width: 100%; height: 3rem; border-radius: 0.75rem; font-size: 0.9375rem; }
.device-approval-facts { display: grid; gap: 0.75rem; margin: 0 0 1.25rem; }
.device-approval-facts > div { display: grid; grid-template-columns: 4.5rem minmax(0, 1fr); align-items: baseline; gap: 0.75rem; }
.device-approval-facts dt { color: var(--fg-2); font-size: 0.8125rem; }
.device-approval-facts dd { min-width: 0; margin: 0; overflow-wrap: anywhere; font-weight: var(--fw-label); }
.device-approval-code { display: flex; align-items: center; }
.device-approval-access { margin: 0 0 1.25rem; }
.device-approval-access h2 { margin: 0 0 0.5rem; color: var(--fg-2); font: var(--fw-label) 0.8125rem/1.4 var(--font-face); }
.device-approval-scopes { display: grid; gap: 0.5rem; margin: 0; padding: 0; list-style: none; }
.device-approval-scopes li { min-width: 0; overflow-wrap: anywhere; }
.device-approval-note { margin: 0 0 1.5rem; color: var(--fg-2); font-size: 0.8125rem; }
.auth-loading { min-height: 1em; margin: 0.875rem 0 0; text-align: center; }
/* A line that exists only while it has something to say (the passkey wait counter, an error): the
   row is 0fr while empty, so the card hugs its content, and eases open when text arrives. */
.auth-note { display: grid; grid-template-rows: 0fr; transition: grid-template-rows 240ms var(--ease); }
.auth-note > div { min-height: 0; overflow: hidden; }
.auth-note:has(.auth-message:not(:empty), .busy-count:not([hidden])) { grid-template-rows: 1fr; }
@media (prefers-reduced-motion: reduce) { .auth-note { transition: none; } }
/* A failure of the primary action sits in the notice row directly above it, centred, never below the quiet action. */
.auth-signin .auth-message { margin: 0 0 0.75rem; text-align: center; }
.auth-signin .auth-message:empty { min-height: 0; margin: 0; }
.auth-check { position: relative; display: flex; min-height: 2.75rem; align-items: center; gap: 0.625rem; margin-top: 1.125rem; color: var(--fg-2); font-size: 0.875rem; cursor: pointer; }
.auth-check input { width: 1.125rem; height: 1.125rem; accent-color: var(--fg); }
[data-focus-ring="on"] .auth-check input:focus-visible + .tick { outline: 2px solid var(--ring); outline-offset: 2px; }
.auth-check[data-pressed] { transform: scale(0.98); }
.auth-check .tick { width: 1.25rem; height: 1.25rem; }
.auth-words { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.375rem 0.625rem; margin: 0.25rem 0 0; padding: 0.875rem; border: 1px solid var(--line); border-radius: 0.875rem; background: rgb(255 255 255 / 0.03); counter-reset: recovery; list-style: none; }
.auth-words li { display: flex; min-width: 0; align-items: baseline; gap: 0.3125rem; color: var(--fg); font: var(--fw-body) 0.8125rem/1.9 var(--font-face); }
.auth-word-number { width: 1.1875rem; flex: none; color: var(--fg-3); font-size: 0.65625rem; text-align: right; }
.auth-actions { display: flex; justify-content: flex-end; gap: 0.25rem; margin: 0.625rem calc(-1 * var(--auth-overhang)) -0.25rem 0; }
.icon-action { display: inline-grid; width: 2.5rem; height: 2.5rem; place-items: center; padding: 0; border: 0; border-radius: 0.625rem; background: transparent; color: var(--fg-2); cursor: pointer; }
.icon-action:hover { background: var(--hover); color: var(--fg); }
.auth-recovery-message { min-height: 1em; margin: 2px 0 0; color: var(--fg-3); font-size: 0.6875rem; }
.auth-welcome { text-align: center; }
.welcome-copy { max-width: 100%; text-align: center; }
.welcome-copy h1 { margin: 0 0 0.875rem; font-size: clamp(1.25rem, 6vw, 4rem); font-weight: var(--fw-title); letter-spacing: -0.04em; line-height: 1.05; }
.welcome-copy p { margin: 0; color: var(--fg-2); animation: auth-welcome-caption 240ms 900ms var(--ease) both; }
.auth-welcome[data-no-motion] .welcome-copy p { animation: none; }
@keyframes auth-welcome-caption { from { opacity: 0; transform: translateX(0.625rem); } }

.auth-screen button:focus { outline: none; }
[data-focus-ring="on"] .auth-screen button:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
@media (max-width: 480px) {
  .auth-card { --auth-pad: 1.75rem; padding: var(--auth-pad) 1.375rem var(--auth-pad); border-radius: 1.25rem; }
  .auth-signin { --auth-pad: 1.75rem; padding-inline: 1.375rem; padding-bottom: var(--auth-pad); }
  .auth-card h1 { font-size: 1.4375rem; }
  .auth-words { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (prefers-reduced-motion: reduce) {
  .auth-card, .auth-pane, .auth-welcome p { animation: none; }
  .auth-pane { transition: opacity 200ms var(--ease); }
  .auth-viewport { transition: none; }
  .auth-primary:active { transform: none; transition: none; }
  .auth-check[data-pressed] { transform: none; }
}
