@font-face {
  font-family: "Buddy Rounded";
  font-weight: 800;
  font-display: swap;
  src: url("/fonts/rounded-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2212;
}
@font-face {
  font-family: "Buddy Rounded";
  font-weight: 800;
  font-display: swap;
  src: url("/fonts/rounded-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1E9F, U+1EF2-1EFF, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --ui: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, sans-serif;
  --rounded: "Buddy Rounded", var(--ui);
  --mono: "Cascadia Mono", Consolas, ui-monospace, "SF Mono", monospace;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);

  --lilac: #a98beb;
  --buddy-ink: #1a1622;

  --bg: #141416;
  --raise: #1f1f23;
  --raise-2: #2a2a30;
  --raise-3: #34343b;
  --line: #2c2c32;
  --fg: #ececef;
  --mute: #a4a4ad;
  --green: #7fd8b8;
  --red: #f29a8a;
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f6f8;
    --raise: #ffffff;
    --raise-2: #e3e3ea;
    --raise-3: #dcdce4;
    --line: #e0e0e7;
    --fg: #18181b;
    --mute: #5c5c66;
    --green: #1e7f5c;
    --red: #b3412e;
    color-scheme: light;
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  min-height: 100dvh; background: var(--bg); color: var(--fg);
  font: 15px/1.5 var(--ui); -webkit-font-smoothing: antialiased;
}
::selection { background: color-mix(in srgb, var(--lilac) 45%, transparent); }
:focus-visible { outline: 2px solid var(--lilac); outline-offset: 2px; }
* { scrollbar-width: thin; scrollbar-color: var(--raise-3) transparent; }
h1 { font-size: 26px; font-weight: 600; line-height: 1.2; text-wrap: balance; }
h2 { font-size: 16px; font-weight: 600; line-height: 1.3; }
[hidden] { display: none !important; }

.site {
  width: 100%; max-width: 448px; margin: 0 auto;
  padding: max(9vh, 40px) 16px 48px;
  display: flex; flex-direction: column; align-items: center;
}

/* the main bot's Buddy, whose face follows the page */
.buddy { line-height: 0; }
.face { overflow: visible; display: block; }
.face .ground { fill: #000; opacity: 0.3; }
.face .body { fill: var(--lilac); }
.face .ink { fill: var(--buddy-ink); }
.face .white, .face .glint { fill: #fff; }
.face .stroke { fill: none; stroke: var(--buddy-ink); stroke-width: 2.8; stroke-linecap: round; }
.face .stroke.thin { stroke-width: 2.4; }
.face .light { fill: rgb(255 255 255 / 0.22); clip-path: ellipse(38% 30% at 34% 24%); }
.face .shade { fill: rgb(0 0 0 / 0.14); clip-path: ellipse(60% 26% at 50% 100%); }
.face .f { display: none; }
.face[data-face="calm"] .f.calm,
.face[data-face="waiting"] .f.waiting,
.face[data-face="happy"] .f.happy,
.face[data-face="worried"] .f.worried { display: inline; }
.face .hop { transform-origin: 32px 56px; }
.face.hopping .hop { animation: hop 620ms var(--ease-out); }
@keyframes hop {
  0% { transform: translateY(0) scale(1, 1); }
  18% { transform: translateY(0) scale(1.08, 0.9); }
  45% { transform: translateY(-9px) scale(0.95, 1.06); }
  75% { transform: translateY(0) scale(1.04, 0.96); }
  100% { transform: translateY(0) scale(1, 1); }
}

.wordmark {
  font-family: var(--rounded); font-weight: 800; font-size: 22px; letter-spacing: 0.01em;
  margin: 10px 0 36px;
}

.view { width: 100%; display: flex; flex-direction: column; gap: 24px; }
.step-view {
  display: flex; flex-direction: column; gap: 20px;
  transition: opacity 260ms var(--ease-out), transform 260ms var(--ease-out);
  @starting-style { opacity: 0; transform: translateY(6px); }
}
.lead { color: var(--mute); font-size: 15px; max-width: 60ch; }
.hint { color: var(--mute); font-size: 13px; }
.error { color: var(--red); font-size: 14px; }
.error:empty { display: none; }

/* steps: one thin pill per step */
.progress { list-style: none; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 8px; }
.progress li { height: 4px; border-radius: 999px; background: var(--raise-2); transition: background-color 240ms var(--ease-out); }
.progress li.done { background: color-mix(in srgb, var(--fg) 45%, var(--raise-2)); }
.progress li.on { background: var(--fg); }

form, .stack { display: flex; flex-direction: column; gap: 16px; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--mute); }
input {
  font: inherit; font-size: 15px; color: var(--fg); background: var(--raise); border: 1px solid var(--line);
  border-radius: 14px; padding: 11px 14px; width: 100%; caret-color: var(--lilac);
  transition: border-color 120ms ease;
}
input:hover { border-color: var(--raise-3); }
input:focus-visible { outline: none; border-color: var(--lilac); box-shadow: 0 0 0 3px color-mix(in srgb, var(--lilac) 25%, transparent); }
input::placeholder { color: var(--mute); }
input.mono { font-family: var(--mono); font-size: 14px; letter-spacing: 0.02em; }
input.digits { font-family: var(--mono); font-size: 22px; letter-spacing: 0.3em; text-align: center; font-variant-numeric: tabular-nums; }

button {
  font: inherit; font-weight: 600; font-size: 15px; color: var(--fg); cursor: pointer; border: 0;
  padding: 11px 20px; border-radius: 999px; background: var(--raise-2);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: background-color 120ms ease, transform 160ms var(--ease-out), opacity 120ms ease;
}
button:hover { background: var(--raise-3); }
button:active:not(:disabled) { transform: scale(0.97); }
button:disabled { opacity: 0.45; cursor: default; }
button.primary { background: var(--fg); color: var(--bg); }
button.primary:hover:not(:disabled) { background: color-mix(in srgb, var(--fg) 85%, var(--bg)); }
button.link {
  padding: 0; background: none; border-radius: 0; font-size: inherit; color: var(--fg);
  text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--raise-3);
}
button.link:hover { background: none; text-decoration-color: var(--fg); }
button.busy::after {
  content: ""; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent; animation: spin 700ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.i { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

.actions { display: flex; align-items: center; gap: 12px; padding-top: 4px; }
.actions .gap { flex: 1; }
.actions.stretch button { flex: 1; }

.or {
  display: flex; align-items: center; gap: 12px; color: var(--mute); font-size: 13px;
}
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* authenticator enrollment */
.enroll { display: grid; grid-template-columns: 148px minmax(0, 1fr); gap: 18px; align-items: center; }
.qr { background: #fff; padding: 10px; border-radius: 16px; line-height: 0; }
.qr svg { width: 100%; height: auto; }
.secret {
  font-family: var(--mono); font-size: 13px; letter-spacing: 0.04em; overflow-wrap: anywhere;
  color: var(--fg); background: var(--raise); border-radius: 12px; padding: 8px 10px; user-select: all;
}
.enroll .stack { gap: 8px; }

/* signed in: the downloads and the link code */
.panel { background: var(--raise); border-radius: 24px; padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.panel .lead { font-size: 14px; }
.panel .secret { background: var(--bg); margin: 0; }
.download {
  display: flex; align-items: center; gap: 14px; padding: 12px 12px 12px 16px;
  border-radius: 18px; background: var(--raise-2); color: var(--fg); text-decoration: none;
  transition: background-color 120ms ease;
}
.download:hover { background: var(--raise-3); }
.download-what { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.download-what strong { font-weight: 600; }
.download-what span { color: var(--mute); font-size: 13px; font-variant-numeric: tabular-nums; }
.download .go {
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center;
  background: var(--fg); color: var(--bg); flex: none;
}

.code {
  font-family: var(--mono); font-weight: 600; font-size: clamp(30px, 9vw, 40px); letter-spacing: 0.12em;
  font-variant-numeric: tabular-nums; text-align: center; padding: 14px 8px; border-radius: 18px;
  background: var(--bg); user-select: all;
  transition: opacity 200ms var(--ease-out);
  @starting-style { opacity: 0; }
}
.code.stale { opacity: 0.4; text-decoration: line-through; text-decoration-thickness: 2px; }
.code-meta { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.code-meta .hint { font-variant-numeric: tabular-nums; }
.steps-list { padding-left: 20px; color: var(--mute); font-size: 14px; display: flex; flex-direction: column; gap: 4px; }
.steps-list strong { color: var(--fg); font-weight: 600; overflow-wrap: anywhere; }

.copied { color: var(--green); }
.foot { display: flex; justify-content: center; gap: 20px; flex-wrap: wrap; color: var(--mute); font-size: 14px; padding-top: 4px; }
.foot button.link { color: var(--mute); }
.foot button.link:hover { color: var(--fg); }
.notice { display: flex; align-items: center; gap: 10px; color: var(--green); font-size: 14px; }

@media (max-width: 420px) {
  .site { padding-top: 32px; }
  h1 { font-size: 23px; }
  .enroll { grid-template-columns: minmax(0, 1fr); }
  .qr { width: 168px; justify-self: center; }
  .actions { flex-wrap: wrap; }
}

@media (prefers-reduced-motion: reduce) {
  .face.hopping .hop { animation: none; }
  .step-view { transition: opacity 200ms ease; @starting-style { opacity: 0; transform: none; } }
  button.busy::after { animation-duration: 1.6s; }
}
