/* Shared look for the home (backup) pages — /enroll, /restore, and the manage
   page. The tokens mirror the messenger's "classic" theme: a user lands here
   mid-flow from a chat and goes straight back, so the round trip must read as
   one product. (The chat's own theme choice can't cross origins — passkeys and
   localStorage are bound to the instance — so classic-neutral is the deliberate
   default rather than a guess at the user's theme.) */

:root {
  color-scheme: light dark;
  --bg: light-dark(#f6f7fb, #15171c);
  --panel: light-dark(#ffffff, #1d2026);
  --ink: light-dark(#1c2333, #e7e9f0);
  --muted: light-dark(#5a6170, #9aa1b3);
  --border: light-dark(#e7e9f0, rgba(255, 255, 255, 0.10));
  --accent: light-dark(#5666f0, #7d8bff);
  --accent-ink: light-dark(#ffffff, #0a0e2a);
  --quiet: light-dark(#eef0f6, #2a2e38);
  --shadow: light-dark(rgba(20, 30, 80, 0.10), rgba(0, 0, 0, 0.55));
  --danger: light-dark(#c2410c, #f0936b);
  --ok: light-dark(#237a41, #58b97e); /* dark enough for AA on the panel at status size */
  /* Plain SF (system), not the rounded variant — the rounded display face read
     as toy-like at heading sizes and was explicitly voted off the page. */
  --font-display: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100svh;
  padding: 24px 16px calc(32px + env(safe-area-inset-bottom));
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  display: grid;
  place-items: center;
}

/* The ceremony card (enroll / restore) — same geometry as the messenger's
   join/onboarding card, so arriving here doesn't feel like leaving the app. */
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 28px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 12px 40px var(--shadow);
  text-align: center;
}
.card h1 { margin: 14px 0 6px; font-size: 22px; font-family: var(--font-display); }
.card .sub { margin: 0 0 20px; color: var(--muted); font-size: 15px; }

/* The entry tile — the confirmation gate. It names exactly what's being saved
   (or unlocked), so it gets the hero spot: the chat's photo (or a chat glyph)
   wearing a key badge that seals to a check once the backup is written. */
.entry { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.entry-badge { position: relative; width: 72px; height: 72px; margin-bottom: 10px; }
.entry-photo { width: 72px; height: 72px; border-radius: 18px; object-fit: cover; display: block; }
.entry-glyph {
  width: 72px; height: 72px; border-radius: 18px;
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--accent) 14%, var(--panel));
  color: var(--accent);
}
.entry-glyph svg { width: 34px; height: 34px; }
.badge {
  position: absolute; right: -8px; bottom: -8px;
  width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink);
  border: 3px solid var(--panel);
  transition: background 0.25s ease;
}
.badge svg { width: 15px; height: 15px; }
.badge .check { display: none; }
.badge.sealed { background: var(--ok); color: #fff; }
.badge.sealed .key { display: none; }
.badge.sealed .check { display: block; }
.entry .name { font-weight: 700; font-size: 18px; font-family: var(--font-display); }
.entry .host { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }

/* Action buttons stack full-width; flow steps that swap in a question (the
   replace confirmation) style its text via .actions p. */
.actions { display: flex; flex-direction: column; gap: 10px; }
.actions p { margin: 0 0 4px; font-size: 15px; }

/* The two-intent divider: "Sign in" above it, the create path for people who
   are new below — both visible up front, so nobody has to fail a ceremony to
   discover which path was theirs. Muted rules either side of a short label;
   --muted is the status-text colour, so contrast holds in both themes. */
.path-divider {
  display: flex; align-items: center; gap: 10px;
  margin: 2px 0; color: var(--muted); font-size: 13px;
}
.path-divider::before, .path-divider::after {
  content: ""; flex: 1; height: 1px; background: var(--border);
}

/* The demo offer sits under the create path, quieter still: the honest
   one-liner does the explaining (--muted keeps contrast in both themes). */
#demo-offer { display: flex; flex-direction: column; gap: 8px; }
#demo-offer.hidden { display: none; }
.demo-hint { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.4; }

button {
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  border: none;
  border-radius: 999px;
  padding: 11px 18px;
  background: var(--accent);
  color: var(--accent-ink);
  line-height: 1.2;
}
button.secondary { background: var(--quiet); color: var(--ink); }
button:disabled { opacity: 0.5; cursor: default; }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

input {
  font: inherit;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px;
  background: var(--panel);
  color: var(--ink);
}
input:focus-visible { outline: 2px solid var(--accent); border-color: transparent; }

/* CLI paste handoff: the sealed sign-in code a terminal user copies back.
   Monospace + break-anywhere so the base64url block wraps cleanly. */
.code-wrap { display: grid; gap: 10px; margin-top: 14px; justify-items: center; }
.code {
  font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace;
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  background: var(--panel);
  color: var(--ink);
  word-break: break-all;
  resize: none;
}
.code:focus-visible { outline: 2px solid var(--accent); border-color: transparent; }

/* Inline status only — never a floating toast (product-wide rule). */
.status { margin: 14px 0 0; font-size: 14px; color: var(--muted); }
.status.error { color: var(--danger); }
.status.ok { color: var(--ok); }
.status:empty { display: none; }
/* a ceremony step in flight gets a small inline spinner */
.status.busy::before {
  content: "";
  display: inline-block; vertical-align: -2px;
  width: 13px; height: 13px; margin-right: 8px;
  border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--ink) 15%, transparent);
  border-top-color: var(--accent);
  animation: home-spin 0.7s linear infinite;
}
@keyframes home-spin { to { transform: rotate(360deg); } }

/* Text swapped in for the final "all done" state eases into place instead of
   snapping mid-glance. */
.swap-in { animation: home-swap-in 0.35s ease; }
@keyframes home-swap-in { from { opacity: 0; transform: translateY(3px); } }

@media (prefers-reduced-motion: reduce) {
  .status.busy::before { animation: none; opacity: 0.5; }
  .badge { transition: none; }
  .swap-in { animation: none; }
}

/* The single-serve "space is ready" confirmation: a sealed-check moment, then a
   full-width "set up" link and a quiet Done. Centered within the create screen. */
#new-space-result { margin-top: 10px; text-align: center; }
#new-space-result p { margin: 0 0 12px; }
.ok-check {
  width: 46px; height: 46px; margin: 6px auto 12px; border-radius: 50%;
  display: grid; place-items: center; background: var(--ok); color: #fff;
}
.ok-check svg { width: 22px; height: 22px; }
.created-name { font-family: var(--font-display); font-weight: 400; font-size: 17px; margin: 0 0 4px; }
a.btn-link {
  display: block;
  font: inherit;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  border-radius: 999px;
  padding: 11px 18px;
  background: var(--accent);
  color: var(--accent-ink);
  line-height: 1.2;
}
a.btn-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.hidden { display: none; }
