/* Spark for the web.
 *
 * The same clothes as the iPhone app: near-white canvas, near-black ink, one
 * blue (#1858D4), hairline monochrome glyphs, capsule primaries and the
 * system's San Francisco. Every token below is the app's `OnboardingStyle` /
 * `MainStyle` value of the same role (Spark/Onboarding/OnboardingAppearance.swift),
 * including its dark-mode pair. Add colour here, never in a rule further down.
 */

:root {
  --canvas: #FAFAFB;
  --surface: #FFFFFF;
  --ink: #050505;
  --secondary: #56565C;
  --line: #E4E4E8;
  --muted: #E7E7E9;
  --chip: #F2F2F4;
  --button: #1858D4;
  --on-button: #FFFFFF;
  --accent: #1858D4;
  --tint: #E8EEFB;
  --grad-start: #2C4CFA;
  --grad-end: #5A4AFB;
  --arc: #F1F1FD;
  --danger: #B3271E;
  --danger-fill: #E0574F;
  --warning: #B4740A;
  --scrim: rgba(5, 5, 5, 0.32);
  --shadow: 0 1px 2px rgba(5, 5, 5, 0.04), 0 8px 24px rgba(5, 5, 5, 0.06);

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro", system-ui,
          "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro", system-ui,
             "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --gutter: 24px;
  --tabbar-h: 64px;
  --sidebar-w: 260px;
  --content-max: 680px;
  --radius-card: 16px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --canvas: #0E0E10;
    --surface: #1C1C1E;
    --ink: #F7F7F8;
    --secondary: #A0A0A8;
    --line: #2E2E32;
    --muted: #2A2A2E;
    --chip: #26262A;
    --accent: #5B8DEF;
    --tint: #1B2436;
    --arc: #181924;
    --danger: #FF938C;
    --danger-fill: #F0736B;
    --warning: #E2A64B;
    --scrim: rgba(0, 0, 0, 0.55);
    --shadow: none;
  }
}

/* ---------- base ---------- */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

h1, h2, h3, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; text-align: inherit; }
button:disabled { cursor: default; }
a { color: var(--accent); }
img { display: block; max-width: 100%; }
svg { display: block; flex: none; }

:focus { outline: none; }
:focus-visible {
  outline: 2.5px solid var(--accent);
  outline-offset: 2px;
  border-radius: 10px;
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip {
  position: absolute; left: 12px; top: -80px; z-index: 100;
  background: var(--surface); color: var(--ink); padding: 10px 16px;
  border-radius: 999px; box-shadow: var(--shadow); text-decoration: none;
}
.skip:not(:focus) { box-shadow: none; }
.skip:focus { top: calc(12px + var(--safe-top)); }
[tabindex="-1"]:focus, [tabindex="-1"]:focus-visible { outline: none; }

.noscript, .boot {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px; min-height: 100vh; min-height: 100dvh; padding: 24px; text-align: center;
  color: var(--secondary);
}

.boot img { animation: breathe 2.4s var(--ease) infinite; }

@keyframes breathe { 50% { opacity: .55; transform: scale(.97); } }

/* ---------- layout ---------- */

.app { min-height: 100vh; min-height: 100dvh; }

.shell { display: block; }

.main {
  min-width: 0;
  padding-bottom: calc(var(--tabbar-h) + var(--safe-bottom));
}

.screen {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: calc(28px + var(--safe-top)) var(--gutter) 40px;
  animation: enter .32s var(--ease) both;
}

@keyframes enter {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.screen.wide { max-width: 1040px; }

/* Tab bar — four equally weighted destinations, as in the app. */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(4, 1fr);
  padding: 8px 4px calc(6px + var(--safe-bottom));
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  -webkit-backdrop-filter: saturate(1.6) blur(18px);
  backdrop-filter: saturate(1.6) blur(18px);
  border-top: 0.5px solid var(--line);
}

.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; min-height: 48px; color: var(--secondary);
  font-size: 11px; letter-spacing: .01em;
  border-radius: 12px;
  transition: color .15s ease, opacity .12s ease;
  text-decoration: none;
}
.tab svg { width: 26px; height: 26px; }
.tab[aria-current="page"] { color: var(--accent); }
.tab:active { opacity: .55; }

/* Sidebar — the same four destinations, on a laptop. */
.sidebar { display: none; }

@media (min-width: 960px) {
  .shell {
    display: grid;
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
    min-height: 100vh;
  }
  .main { padding-bottom: 0; }
  .tabbar { display: none; }
  .screen { padding-top: 56px; padding-bottom: 72px; }
  .sidebar {
    display: flex; flex-direction: column; gap: 4px;
    position: sticky; top: 0; height: 100vh;
    padding: 34px 18px 24px;
    border-right: 0.5px solid var(--line);
    background: var(--canvas);
  }
  .brand {
    display: flex; align-items: center; gap: 12px;
    padding: 0 12px 30px; font-family: var(--display);
    font-size: 26px; font-weight: 700; letter-spacing: -0.8px;
  }
  .brand img { width: 34px; height: 36px; object-fit: contain; }
  .side-link {
    display: flex; align-items: center; gap: 14px;
    min-height: 46px; padding: 0 14px; border-radius: 12px;
    color: var(--ink); text-decoration: none; font-size: 15.5px;
    transition: background-color .15s ease, color .15s ease;
  }
  .side-link svg { width: 22px; height: 22px; color: var(--secondary); }
  .side-link:hover { background: var(--chip); }
  .side-link[aria-current="page"] { background: var(--tint); color: var(--accent); font-weight: 600; }
  .side-link[aria-current="page"] svg { color: var(--accent); }
  .side-foot { margin-top: auto; padding: 14px; font-size: 13px; color: var(--secondary); }
  .side-foot .status-line { display: flex; align-items: center; gap: 8px; color: var(--ink); font-size: 14px; }
}

/* Two columns where a laptop has the room; one everywhere else. */
.cols { display: grid; gap: 0 40px; }
@media (min-width: 1180px) {
  .cols.two { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
}

/* ---------- type ---------- */

.heading { display: flex; flex-direction: column; gap: 11px; }

.title {
  font-family: var(--display);
  font-size: 32px; line-height: 1.12; font-weight: 700; letter-spacing: -1.1px;
  overflow-wrap: anywhere;
}
.title.home { font-size: 34px; }

.subtitle {
  font-size: 15px; line-height: 1.5; color: var(--secondary);
  max-width: 34em;
}

.summary { font-size: 17px; color: var(--secondary); padding: 8px 0 24px; }

.section {
  display: block;
  font-size: 11px; font-weight: 500; letter-spacing: 1.5px; text-transform: uppercase;
  color: var(--secondary);
  padding: 25px 2px 10px;
}

.note {
  display: flex; gap: 12px; align-items: flex-start;
  font-size: 13px; line-height: 1.55; color: var(--secondary);
  padding: 18px 5px 0;
}
.note svg { width: 17px; height: 17px; margin-top: 1px; }

.fine { font-size: 13px; color: var(--secondary); line-height: 1.5; }

/* ---------- cards & rows ---------- */

.card {
  background: var(--surface);
  border-radius: var(--radius-card);
  overflow: hidden;
}

.divider { height: 0; border-top: 0.5px solid var(--line); margin-left: var(--inset, 0px); }
.rule { height: 0; border: 0; border-top: 0.5px solid var(--line); margin: 0; }

.row {
  display: flex; align-items: center; gap: 17px;
  width: 100%; min-height: 57px;
  padding: 10px 17px;
  color: var(--ink); text-decoration: none;
  transition: background-color .15s ease, opacity .12s ease;
}
button.row:hover, a.row:hover { background: color-mix(in srgb, var(--chip) 70%, transparent); }
button.row:active, a.row:active { opacity: .55; }
.row:disabled { opacity: .5; }

.row .glyph { width: 30px; display: flex; justify-content: center; color: var(--ink); }
.row .glyph svg { width: 24px; height: 24px; }
.row .text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.row .label { font-size: 15.5px; letter-spacing: -0.3px; overflow-wrap: anywhere; }
.row .label.strong { font-weight: 500; }
.row .sub { font-size: 13px; color: var(--secondary); display: flex; align-items: center; gap: 6px; overflow-wrap: anywhere; }
.row .value { font-size: 14px; color: var(--secondary); display: flex; align-items: center; gap: 6px; text-align: right; }
.row .chev, .chev { color: var(--secondary); width: 14px; height: 14px; flex: none; }
.row.compact { min-height: 46px; }
.row.danger .label { color: var(--danger); }
.row.action .label { color: var(--accent); font-weight: 500; }
.row.action .glyph { color: var(--accent); }

.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--button); flex: none; }
.dot.big { width: 11px; height: 11px; }
.dot.off { background: var(--secondary); opacity: .5; }
.dot.warn { background: var(--warning); }

/* ---------- switch ---------- */

.switch {
  position: relative; flex: none;
  width: 51px; height: 31px; border-radius: 999px;
  background: var(--muted);
  transition: background-color .22s var(--ease);
}
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 27px; height: 27px; border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .18), 0 0 0 .5px rgba(0, 0, 0, .04);
  transition: transform .22s var(--ease);
}
.switch[aria-checked="true"] { background: var(--button); }
.switch[aria-checked="true"]::after { transform: translateX(20px); }
.switch[aria-busy="true"] { opacity: .55; }
.switch[aria-busy="true"]::after { animation: pulse 1s ease-in-out infinite; }
.switch:disabled { cursor: default; }
.switch:focus-visible { border-radius: 999px; }

@keyframes pulse { 50% { opacity: .6; } }

/* A row that is a switch: the whole row is the control's label. */
.toggle-row { display: flex; align-items: center; gap: 17px; padding: 8px 17px; min-height: 64px; }
.toggle-row .glyph { width: 27px; display: flex; justify-content: center; }
.toggle-row .glyph svg { width: 23px; height: 23px; }
.toggle-row .text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.toggle-row .label { font-size: 15.5px; font-weight: 500; letter-spacing: -0.35px; }
.toggle-row .sub { font-size: 13px; color: var(--secondary); }
.toggle-row.hero { padding: 18px; min-height: 80px; }
.toggle-row .badge {
  width: 31px; height: 31px; border-radius: 50%; display: grid; place-items: center;
  background: var(--button); color: var(--on-button); flex: none;
}
.toggle-row .badge svg { width: 18px; height: 18px; }

/* ---------- buttons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; min-height: 56px; padding: 0 24px;
  border-radius: 999px;
  font-size: 18px; font-weight: 600; letter-spacing: -0.2px;
  background: var(--button); color: var(--on-button);
  transition: opacity .12s ease, transform .12s ease, background-color .15s ease;
  text-decoration: none;
}
.btn:not(:disabled):hover { background: color-mix(in srgb, var(--button) 90%, #000); }
.btn:active { opacity: .7; transform: scale(.99); }
.btn:disabled, .btn[aria-disabled="true"] { background: var(--muted); color: var(--secondary); transform: none; }
.btn.gradient { background: linear-gradient(90deg, var(--grad-start), var(--grad-end)); }
.btn.gradient:hover { filter: brightness(.95); }
.btn.quiet { background: var(--chip); color: var(--ink); }
.btn.quiet:not(:disabled):hover { background: var(--muted); }
.btn.danger { background: var(--chip); color: var(--danger); }
.btn.small { min-height: 44px; font-size: 15px; width: auto; padding: 0 20px; }

.btn .spinner { width: 18px; height: 18px; }

.link {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 44px; padding: 0 2px;
  color: var(--accent); font-size: 15px; font-weight: 500;
  border-radius: 8px;
}
.link:hover { text-decoration: underline; text-underline-offset: 3px; }
.link.center { width: 100%; justify-content: center; }
.link.danger { color: var(--danger); }

.back {
  text-decoration: none;
  display: inline-flex; align-items: center; gap: 4px;
  min-height: 44px; margin: -6px 0 10px -6px; padding: 0 8px 0 2px;
  color: var(--accent); font-size: 17px;
  border-radius: 10px;
}
.back svg { width: 22px; height: 22px; }
.back:hover { background: var(--tint); }

.spinner { width: 16px; height: 16px; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- home ---------- */

.big-number {
  font-family: var(--display);
  font-size: 46px; font-weight: 700; letter-spacing: -2px; line-height: 1.05;
  font-variant-numeric: tabular-nums;
}
.big-caption { font-size: 18px; color: var(--secondary); }

.metrics { display: grid; grid-template-columns: repeat(3, 1fr); padding: 16px 0; }
.metric { display: flex; flex-direction: column; gap: 4px; padding: 0 12px; border-left: 0.5px solid var(--line); }
.metric:first-child { padding-left: 0; border-left: 0; }
.metric strong { font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; }
.metric span { font-size: 14px; color: var(--secondary); }

.plain-link-row { margin: 0 -12px; }

.banner {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 14px 16px; border-radius: 14px;
  background: var(--tint); color: var(--ink); font-size: 14px; line-height: 1.5;
  margin-bottom: 12px;
}
.banner svg { width: 18px; height: 18px; color: var(--accent); margin-top: 1px; }
.banner.warn { background: color-mix(in srgb, var(--warning) 14%, var(--surface)); }
.banner.warn svg { color: var(--warning); }
.banner .actions { display: flex; gap: 14px; margin-top: 4px; }
.banner .link { min-height: 32px; font-size: 14px; }

/* ---------- inline write failure ---------- */

.failure {
  display: flex; gap: 10px; align-items: flex-start;
  margin: 10px 0 0; padding: 12px 14px;
  border-radius: 12px; font-size: 13.5px; line-height: 1.45;
  background: color-mix(in srgb, var(--danger-fill) 12%, var(--surface));
  color: var(--ink);
}
.failure svg { width: 17px; height: 17px; color: var(--danger); margin-top: 1px; }
.failure .actions { display: flex; gap: 16px; margin-top: 2px; }
.failure .link { min-height: 30px; font-size: 13.5px; }
.card .failure { margin: 0 14px 14px; }

/* ---------- forms ---------- */

.field { display: flex; flex-direction: column; gap: 8px; }
.field > label, .field-label { font-size: 16px; font-weight: 600; letter-spacing: -0.3px; }
.input {
  width: 100%; min-height: 50px; padding: 0 15px;
  font-size: 16px;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-radius: 12px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.input::placeholder { color: var(--secondary); opacity: .8; }
.input:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.input[aria-invalid="true"] { border-color: var(--danger); }
.input.code {
  font-size: 34px; font-weight: 600; letter-spacing: .55em; text-align: center;
  padding-left: calc(15px + .55em); min-height: 72px;
  font-variant-numeric: tabular-nums;
}
.inline-add { display: flex; gap: 10px; }
.inline-add .input { flex: 1; }
.error-text { color: var(--danger); font-size: 14px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; justify-content: center; text-align: center;
  min-height: 44px; padding: 0 16px; border-radius: 999px;
  background: var(--surface); color: var(--ink);
  font-size: 14px; font-weight: 500;
  border: 0.5px solid var(--line);
  transition: background-color .15s ease, color .15s ease;
}
.chip:hover { background: var(--chip); }
.chip[aria-pressed="true"], .chip[aria-checked="true"] { background: var(--button); color: var(--on-button); border-color: transparent; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; margin: 0 calc(var(--gutter) * -1); padding-left: var(--gutter); padding-right: var(--gutter); }
.chips.scroll::-webkit-scrollbar { display: none; }
.chips.days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; max-width: 420px; }
.chip.day { min-width: 0; padding: 0; border-radius: 10px; font-weight: 600; font-size: 13px; }

.segmented { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.segmented .chip { border-radius: 11px; padding: 0 6px; font-size: 13.5px; }

.icon-choices { display: grid; grid-template-columns: repeat(6, minmax(0, 52px)); justify-content: space-between; gap: 4px; }
.icon-choice {
  width: 100%; aspect-ratio: 1; border-radius: 50%; display: grid; place-items: center;
  border: 1.5px solid transparent; padding: 3px;
}
.icon-choice span { width: 100%; height: 100%; border-radius: 50%; display: grid; place-items: center; color: #30313A; }
.icon-choice span svg { width: 22px; height: 22px; }
.icon-choice[aria-checked="true"] { border-color: var(--button); }

.select-row { position: relative; }
.select-row select {
  appearance: none; -webkit-appearance: none;
  width: 100%; min-height: 57px; padding: 0 44px 0 17px;
  background: var(--surface); border: 0; border-radius: var(--radius-card);
  font-size: 16px; color: var(--ink);
}
.select-row .chev { position: absolute; right: 17px; top: 50%; transform: translateY(-50%) rotate(90deg); width: 14px; height: 14px; color: var(--secondary); pointer-events: none; }
.select-row .select-label { position: absolute; left: 17px; top: 9px; font-size: 12px; color: var(--secondary); pointer-events: none; }
.select-row.labelled select { padding-top: 18px; }

/* ---------- devices ---------- */

.device-card {
  display: flex; align-items: center; gap: 14px;
  width: 100%; min-height: 72px; padding: 16px 18px;
  background: var(--surface); border-radius: 18px;
  color: var(--ink); text-decoration: none;
  transition: background-color .15s ease, opacity .12s ease;
}
.device-card:hover { background: color-mix(in srgb, var(--surface) 70%, var(--chip)); }
.device-card:active { opacity: .6; }
.device-card .glyph { width: 34px; display: flex; justify-content: center; }
.device-card .glyph svg { width: 25px; height: 25px; }
.device-card .text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.device-card .name { font-size: 16px; font-weight: 600; overflow-wrap: anywhere; }
.device-card .sub { font-size: 13px; color: var(--secondary); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.device-card .chev { width: 13px; height: 13px; color: var(--secondary); }
.device-list { display: grid; gap: 10px; }
@media (min-width: 1180px) { .device-list.grid { grid-template-columns: 1fr 1fr; } }

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px; border-radius: 999px;
  background: var(--chip); color: var(--secondary); font-size: 12px; font-weight: 500;
}
.pill.on { background: var(--tint); color: var(--accent); }

.group-head { font-size: 16px; font-weight: 600; padding: 14px 2px 6px; }
.group-help { font-size: 13px; color: var(--secondary); padding: 0 2px 8px; line-height: 1.5; }

.usage { display: flex; flex-direction: column; gap: 6px; }
.usage .line { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font-size: 15px; }
.usage .line strong { font-weight: 600; }
.usage .line span { color: var(--secondary); }
.bar { width: 160px; height: 6px; border-radius: 999px; background: var(--line); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: inherit; background: var(--button); transition: width .4s var(--ease); }
.bar.full i { background: var(--warning); }

.empty {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  padding: 26px 18px; gap: 6px;
}
.empty strong { font-size: 15px; }
.empty span { font-size: 13.5px; color: var(--secondary); }

/* Family empty state */
.family-empty { display: flex; flex-direction: column; align-items: center; text-align: center; padding-top: clamp(32px, 9vh, 96px); }
.family-empty h2 { font-family: var(--display); font-size: 24px; font-weight: 700; letter-spacing: -0.65px; margin-top: 25px; }
.family-empty p { font-size: 16px; color: var(--secondary); margin-top: 10px; max-width: 18em; line-height: 1.5; }
.family-empty .btn { max-width: 320px; margin-top: 28px; }
.family-art { width: 185px; height: 110px; color: var(--button); }

.avatar {
  width: 47px; height: 47px; border-radius: 50%; display: grid; place-items: center;
  background: color-mix(in srgb, var(--button) 80%, transparent); color: var(--on-button);
  font-weight: 500; font-size: 16px; flex: none;
}

.kv { display: flex; justify-content: space-between; gap: 16px; padding: 15px 17px; font-size: 15.5px; }
.kv span:last-child { color: var(--secondary); text-align: right; overflow-wrap: anywhere; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 12.5px; letter-spacing: .02em; }

/* ---------- setup ---------- */

.setup {
  position: relative; overflow: hidden;
  min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column;
  padding: calc(24px + var(--safe-top)) var(--gutter) calc(24px + var(--safe-bottom));
}
.setup-inner { width: 100%; max-width: 460px; margin: 0 auto; flex: 1; display: flex; flex-direction: column; }
.setup-body { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 18px; padding: 16px 0; }
.setup-foot { display: flex; flex-direction: column; gap: 6px; padding-top: 16px; }
.setup.centered .setup-body { align-items: center; text-align: center; }
.setup .arc {
  position: absolute; left: 50%; top: 71%; width: 270vw; height: 270vw; max-width: 2400px; max-height: 2400px;
  transform: translateX(-50%); border-radius: 50%;
  background: linear-gradient(var(--arc), color-mix(in srgb, var(--arc) 35%, transparent));
  z-index: -1; pointer-events: none;
}
@media (min-width: 700px) { .setup .arc { top: 64%; width: 180vw; height: 180vw; } }
.setup .setup-inner { position: relative; z-index: 1; }
.setup-title {
  font-family: var(--display);
  font-size: clamp(34px, 9vw, 44px); line-height: 1.05; font-weight: 700; letter-spacing: -1.6px;
}
.setup-title.huge { font-size: clamp(48px, 15vw, 64px); letter-spacing: -2px; }
.setup-sub { font-size: 18px; color: var(--secondary); line-height: 1.45; }
.setup-art { width: min(68%, 300px); margin: 0 auto; animation: rise .6s var(--ease) both; }
.setup-art.hero { width: 132px; }
.rise { animation: rise .55s var(--ease) both; }
.rise.d1 { animation-delay: .06s; } .rise.d2 { animation-delay: .12s; } .rise.d3 { animation-delay: .18s; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

.benefits { display: flex; flex-direction: column; gap: 30px; padding-top: 14px; }
.benefit { display: flex; gap: 18px; align-items: flex-start; }
.benefit svg { width: 30px; height: 30px; flex: none; }
.benefit strong { display: block; font-size: 18px; font-weight: 600; letter-spacing: -0.3px; }
.benefit span { font-size: 15.5px; color: var(--secondary); }

.check-ring { width: 112px; height: 112px; color: var(--button); }
.check-ring circle { stroke-dasharray: 302; stroke-dashoffset: 302; animation: draw .5s ease-out forwards; }
.check-ring path { stroke-dasharray: 40; stroke-dashoffset: 40; animation: draw .32s ease-out .28s forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }

.cert-help { text-align: left; font-size: 14px; color: var(--secondary); line-height: 1.55; }

/* ---------- dialogs: a bottom sheet on a phone, a centred card on a laptop ---------- */

dialog.sheet {
  border: 0; padding: 0; margin: 0;
  width: 100%; max-width: 100%; max-height: calc(100dvh - 40px - var(--safe-top));
  position: fixed; inset: auto 0 0 0;
  background: var(--canvas); color: var(--ink);
  border-radius: 22px 22px 0 0;
  box-shadow: 0 -8px 40px rgba(0, 0, 0, .18);
  overflow: hidden;
}
dialog.sheet[open] { display: flex; flex-direction: column; animation: sheet-in .32s var(--ease); }
dialog.sheet::backdrop { background: var(--scrim); animation: fade .25s ease; }
dialog.sheet.closing { animation: sheet-out .22s ease forwards; }
dialog.sheet.closing::backdrop { animation: fade .22s ease reverse forwards; }

@keyframes sheet-in { from { transform: translateY(100%); } to { transform: none; } }
@keyframes sheet-out { to { transform: translateY(100%); } }
@keyframes fade { from { opacity: 0; } }

@media (min-width: 700px) {
  dialog.sheet {
    inset: 0; margin: auto; max-width: 520px; max-height: min(760px, calc(100vh - 80px));
    border-radius: 22px; height: fit-content;
  }
  dialog.sheet[open] { animation: pop .26s var(--ease); }
  dialog.sheet.closing { animation: pop-out .18s ease forwards; }
}
@keyframes pop { from { opacity: 0; transform: scale(.96) translateY(8px); } }
@keyframes pop-out { to { opacity: 0; transform: scale(.97); } }

.sheet-head {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 12px 8px 22px;
}
.sheet-head h2 { flex: 1; font-size: 19px; font-weight: 700; letter-spacing: -0.4px; }
.grabber { display: block; width: 38px; height: 5px; border-radius: 3px; background: var(--line); margin: 8px auto 0; }
@media (min-width: 700px) { .grabber { display: none; } }
.icon-btn {
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center;
  color: var(--secondary);
}
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn:hover { background: var(--chip); color: var(--ink); }
.icon-btn.danger:hover { color: var(--danger); }
.sheet-body { padding: 4px 22px 22px; overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; gap: 14px; }
.sheet-body > p { color: var(--secondary); font-size: 15px; }
.sheet-foot { padding: 6px 22px calc(18px + var(--safe-bottom)); display: flex; flex-direction: column; gap: 8px; }
@media (min-width: 700px) { .sheet-foot { padding-bottom: 22px; } }

.option {
  display: flex; align-items: center; gap: 12px;
  width: 100%; min-height: 54px; padding: 0 17px;
  font-size: 16px; color: var(--ink);
}
.option:hover { background: color-mix(in srgb, var(--chip) 70%, transparent); }
.option .check { width: 20px; height: 20px; color: var(--accent); margin-left: auto; visibility: hidden; }
.option[aria-checked="true"] .check { visibility: visible; }
.option[aria-checked="true"] { font-weight: 600; }
.option .text { display: flex; flex-direction: column; gap: 2px; }
.option .text small { font-size: 13px; color: var(--secondary); font-weight: 400; }

.list-item { display: flex; align-items: center; gap: 12px; padding: 6px 6px 6px 17px; min-height: 54px; }
.list-item span { flex: 1; min-width: 0; overflow-wrap: anywhere; font-size: 16px; }

.candidate {
  display: flex; align-items: center; gap: 14px; width: 100%;
  padding: 14px 17px; min-height: 64px;
}
.candidate:hover { background: color-mix(in srgb, var(--chip) 70%, transparent); }
.candidate .code-badge {
  font-size: 22px; font-weight: 700; letter-spacing: .2em; font-variant-numeric: tabular-nums;
  padding: 6px 12px; border-radius: 10px; background: var(--tint); color: var(--accent);
}

.url-box {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 10px 10px 15px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--line);
}
.url-box code { flex: 1; min-width: 0; overflow-wrap: anywhere; font-size: 13px; }

/* ---------- toast ---------- */

.toast {
  position: fixed; left: 50%; z-index: 60;
  bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 14px);
  transform: translate(-50%, 20px); opacity: 0;
  display: flex; align-items: center; gap: 10px;
  max-width: calc(100vw - 32px); padding: 12px 18px;
  border-radius: 999px; background: var(--ink); color: var(--canvas);
  font-size: 14.5px; font-weight: 500;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .2);
  transition: opacity .2s ease, transform .3s var(--ease);
  pointer-events: none;
}
.toast svg { width: 18px; height: 18px; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
@media (min-width: 960px) { .toast { bottom: 28px; left: calc(50% + var(--sidebar-w) / 2); } }

/* ---------- motion ---------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
  .check-ring circle, .check-ring path { stroke-dashoffset: 0; }
}

@media (hover: none) {
  button.row:hover, a.row:hover, .device-card:hover, .option:hover, .chip:hover, .candidate:hover { background: inherit; }
  .chip[aria-pressed="true"]:hover, .chip[aria-checked="true"]:hover { background: var(--button); }
  .device-card:hover { background: var(--surface); }
  .btn:not(:disabled):hover { background: var(--button); }
  .btn.quiet:not(:disabled):hover, .btn.danger:not(:disabled):hover { background: var(--chip); }
  .btn.gradient:hover { filter: none; }
}

/* ---------- finding the box (hosted copy) ---------- */

/* The app's search rings: faint circles breathing out from behind the box. */
.search { position: relative; width: min(78vw, 300px); aspect-ratio: 1; margin: 0 auto; display: grid; place-items: center; }
.search img { position: relative; width: 62%; height: auto; animation: rise .6s var(--ease) both; }
.search .ring {
  position: absolute; inset: 0; margin: auto; width: 100%; height: 100%;
  border-radius: 50%; border: 2px solid color-mix(in srgb, var(--button) 40%, transparent);
  animation: ripple 2.8s ease-out infinite; opacity: 0;
}
.search .ring:nth-child(2) { animation-delay: .9s; }
.search .ring:nth-child(3) { animation-delay: 1.8s; }
@keyframes ripple { from { transform: scale(.35); opacity: .9; } to { transform: scale(1); opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .search .ring { animation: none; opacity: .5; }
  .search .ring:nth-child(2) { transform: scale(.7); }
  .search .ring:nth-child(3) { transform: scale(.45); }
}

.steps { display: flex; flex-direction: column; gap: 16px; text-align: left; width: 100%; padding-top: 6px; }
.step { display: flex; gap: 14px; align-items: flex-start; }
.step p { font-size: 17px; line-height: 1.45; color: var(--ink); }
.step-n {
  flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  background: var(--tint); color: var(--accent); font-weight: 700; font-size: 15px; margin-top: 1px;
}
