/* The foundation every page shares: the typeface, the colour and type tokens,
 * the reset and the controls. The rules behind it are in docs/UI.md. The
 * build prepends this to each page stylesheet and fills in /inter.woff2. */

@font-face {
  font-family: 'Inter Variable';
  font-style: normal;
  font-weight: 100 900;
  /* Same-origin and precached: a brief blank beats a swap from the fallback. */
  font-display: block;
  src: url(/inter.woff2) format('woff2-variations');
}

:root {
  /* Pages follow the system; the viewer sets .light or .dark itself (theme.ts). */
  color-scheme: light dark;
  --font-sans: 'Inter Variable', -apple-system, system-ui, 'Segoe UI', Roboto, sans-serif;
  --font-mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

  /* Surfaces, from the canvas up: iOS's grouped backgrounds, elevated in dark. */
  --bg: light-dark(#f2f2f7, #000000);
  --sheet: light-dark(#f2f2f7, #1c1c1e);
  --surface: light-dark(#ffffff, #2c2c2e);
  --surface-2: light-dark(#e9e9ee, #3a3a3c);
  --surface-pressed: light-dark(#dcdce1, #48484a);
  --scrim: light-dark(rgb(0 0 0 / 0.28), rgb(0 0 0 / 0.6));

  /* Ink. Secondary and tertiary are translucent so they sit on any surface. */
  --ink: light-dark(#1d1d1f, #f5f5f7);
  --ink-2: light-dark(rgb(60 60 67 / 0.62), rgb(235 235 245 / 0.62));
  --ink-3: light-dark(rgb(60 60 67 / 0.3), rgb(235 235 245 / 0.3));
  --hairline: light-dark(rgb(60 60 67 / 0.2), rgb(84 84 88 / 0.6));

  --accent: light-dark(#007aff, #0a84ff);
  --on-accent: #ffffff;
  --danger: light-dark(#ff3b30, #ff453a);
  --warning: light-dark(#ff9500, #ff9f0a);

  --shadow-float: light-dark(0 24px 64px rgb(0 0 0 / 0.22), 0 24px 64px rgb(0 0 0 / 0.65));
  --shadow-card: light-dark(0 1px 2px rgb(0 0 0 / 0.06), 0 0 0 1px rgb(255 255 255 / 0.06));

  --radius-s: 10px;
  --radius-m: 14px;
  --radius-l: 20px;
  --radius-xl: 26px;

  --ease-out: cubic-bezier(0.22, 0.61, 0.36, 1);
  --t-fast: 160ms;
  --t-base: 260ms;
  --tap: 44px;
}
:root.light { color-scheme: light; }
:root.dark { color-scheme: dark; }

/* Reset */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 17px/1.4 var(--font-sans);
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, p, dl, dd, ol, ul { margin: 0; }
button, input { font: inherit; color: inherit; }
button {
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  touch-action: manipulation;
}
a { color: var(--accent); text-decoration: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

/* Activity ring: a comet arc over a faint track. Shown only while the system
 * itself is busy, never while it waits for a person. */
.ring {
  position: relative;
  width: 22px;
  height: 22px;
  flex: none;
}
.ring::before, .ring::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
}
.ring::before { border: 2.5px solid var(--ink-3); }
.ring::after {
  background: conic-gradient(from 90deg, transparent 0 25%, var(--ink));
  mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 2.5px));
  animation: ring-spin 0.8s linear infinite;
}
@keyframes ring-spin { to { transform: rotate(1turn); } }

/* Buttons */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 0 20px;
  border-radius: 12px;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  transition: transform var(--t-fast) var(--ease-out), background-color var(--t-fast), opacity var(--t-fast);
}
.button:active { transform: scale(0.97); }
.button:disabled { opacity: 0.45; pointer-events: none; }
.button--filled { background: var(--accent); color: var(--on-accent); }
.button--filled:active { background: color-mix(in srgb, var(--accent) 85%, #000); }
.button--tinted { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }
.button--tinted:active { background: color-mix(in srgb, var(--accent) 24%, transparent); }
.button--plain { padding: 0 6px; color: var(--accent); }
.button--block { width: 100%; }

/* A full-screen state: one sentence, an optional hint, a ring while busy. */
.screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 0 max(24px, 8vw);
  text-align: center;
}
.screen__text {
  max-width: 22ch;
  font-size: 28px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.015em;
  text-wrap: balance;
}
.screen__hint {
  max-width: 44ch;
  font-size: 17px;
  line-height: 1.4;
  color: var(--ink-2);
  text-wrap: pretty;
}
.screen .ring { margin-top: 12px; }

/* Scrim: the layer behind a sheet or alert. */
.scrim {
  position: fixed;
  inset: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--scrim);
  -webkit-backdrop-filter: blur(18px) saturate(1.3);
  backdrop-filter: blur(18px) saturate(1.3);
  transition: opacity var(--t-base) var(--ease-out);
}
@starting-style { .scrim { opacity: 0; } }

/* Alert: a centred decision, iOS style. Buttons sit in a hairline row. */
.alert {
  width: min(340px, 100%);
  overflow: hidden;
  border-radius: var(--radius-l);
  background: var(--surface);
  box-shadow: var(--shadow-float);
  text-align: center;
  transition: transform var(--t-base) var(--ease-out), opacity var(--t-base) var(--ease-out);
}
@starting-style { .alert { opacity: 0; transform: scale(1.08); } }
.alert__body {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 22px 20px 20px;
}
.alert__title {
  font-size: 20px;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.01em;
  text-wrap: balance;
}
.alert__code {
  margin: 6px 0 2px;
  font-size: 44px;
  font-weight: 500;
  line-height: 1.1;
  letter-spacing: 0.08em;
  font-variant-numeric: tabular-nums;
}
.alert__text {
  font-size: 15px;
  line-height: 1.4;
  color: var(--ink-2);
  text-wrap: pretty;
}
.alert__body .ring { margin-top: 8px; }
.alert__actions { display: flex; border-top: 1px solid var(--hairline); }
.alert__actions .button {
  flex: 1;
  min-height: 50px;
  border-radius: 0;
  font-weight: 400;
  color: var(--accent);
}
.alert__actions .button + .button { border-left: 1px solid var(--hairline); }
.alert__actions .button:active { background: var(--surface-pressed); transform: none; }
.alert__actions .button--primary { font-weight: 600; }
.alert__actions .button--danger { color: var(--danger); font-weight: 600; }

/* Grouped lists: a caption, cells on a raised surface, an optional note. */
.group { padding-top: 22px; }
.group__title {
  margin: 0 0 7px 16px;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.group__note {
  margin: 8px 16px 0;
  font-size: 13px;
  line-height: 1.4;
  color: var(--ink-2);
  text-wrap: pretty;
}
.cells {
  overflow: hidden;
  border-radius: var(--radius-s);
  background: var(--surface);
}
.cell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  min-height: var(--tap);
  padding: 10px 16px;
  font-size: 17px;
  line-height: 1.3;
  text-align: left;
}
.cell + .cell::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  left: 16px;
  height: 1px;
  background: var(--hairline);
}
.cell__value {
  color: var(--ink-2);
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.cell--warn .cell__value { color: var(--warning); }
.cell--action { color: var(--accent); }
.cell--danger { color: var(--danger); }
button.cell:active { background: var(--surface-pressed); }

/* Segmented control */
.segmented {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  padding: 2px;
  border-radius: 10px;
  background: var(--surface-2);
}
.segmented .button {
  min-height: 40px;
  padding: 0 12px;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 500;
  color: var(--ink);
}
.segmented .button[aria-pressed='true'] {
  background: light-dark(#ffffff, #636366);
  box-shadow: 0 3px 8px rgb(0 0 0 / 0.12), 0 3px 1px rgb(0 0 0 / 0.04);
  font-weight: 600;
}
.segmented .button:active { transform: none; }

@media (prefers-reduced-motion: reduce) {
  .ring::after { animation: none; }
  .scrim, .alert { transition: none; }
}

/* The owner server's landing, setup and renew pages, and the phone recovery
 * page the receiver serves. Appended to ui/base.css by the build. */

body { min-height: 100%; }

.page {
  display: grid;
  gap: 24px;
  width: min(600px, 100%);
  margin: 0 auto;
  padding: clamp(36px, 9vh, 80px) 24px 56px;
}
.page__eyebrow {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.page h1 {
  font-size: 30px;
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.02em;
  text-wrap: balance;
}
.page__lede {
  font-size: 17px;
  line-height: 1.45;
  color: var(--ink-2);
  text-wrap: pretty;
}
.page header { display: grid; gap: 10px; }
.page header .page__lede { margin-top: 2px; }

.card {
  display: grid;
  gap: 18px;
  padding: 24px;
  border-radius: var(--radius-l);
  background: var(--surface);
  box-shadow: var(--shadow-card);
}
.card p { text-wrap: pretty; }

.field { display: grid; gap: 8px; }
.field label { font-size: 15px; font-weight: 500; }
.input {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid var(--hairline);
  border-radius: 12px;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-mono);
  /* 16px keeps iOS Safari from zooming into the field. */
  font-size: 16px;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent);
}

/* Numbered steps with the number in a disc. */
.steps {
  display: grid;
  gap: 16px;
  padding: 0;
  list-style: none;
  counter-reset: step;
}
.steps li {
  position: relative;
  padding-left: 42px;
  counter-increment: step;
  line-height: 1.45;
}
.steps li::before {
  content: counter(step);
  position: absolute;
  top: -2px;
  left: 0;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 14px;
  font-weight: 600;
}
.steps code, .page code {
  font-family: var(--font-mono);
  font-size: 0.92em;
  padding: 1px 5px;
  border-radius: 6px;
  background: var(--surface-2);
}

/* The result of an action, under its button. */
.result {
  min-height: 1.4em;
  font-size: 15px;
  line-height: 1.4;
  color: var(--ink-2);
  overflow-wrap: anywhere;
  text-wrap: pretty;
}
.result:empty { display: none; }

/* Files offered for download. */
.files { display: grid; gap: 8px; }
.files:empty { display: none; }
.file {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  padding: 0 14px 0 16px;
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 15px;
  transition: background-color var(--t-fast), transform var(--t-fast) var(--ease-out);
}
.file:active { transform: scale(0.99); background: var(--surface-pressed); }
.file svg { width: 22px; height: 22px; margin-left: auto; color: var(--accent); }

/* A file picker that looks like a button; the input itself is visually hidden. */
.picker { position: relative; }
.picker input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}
.picker:has(input:focus-visible) .button { outline: 2px solid var(--accent); outline-offset: 2px; }

.mono { font-family: var(--font-mono); font-size: 0.94em; }
