/* BabyMon web (Lullawatch): brand tokens from Brand/ sheet, Apple-like layout (see docs/DESIGN.md). */

/* ---------------------------------------------------------------- brand font */
/* Nunito (variable, OFL; see fonts/OFL.txt). Bundled, never hot-linked. */
@font-face {
  font-family: "Nunito";
  src: url("fonts/Nunito.woff2") format("woff2"), url("fonts/Nunito.ttf") format("truetype");
  font-weight: 200 1000;
  font-style: normal;
  font-display: swap;
}

/* ---------------------------------------------------------------- tokens */
/* Lullawatch palette: Dusk #5630D0 · Lilac #7B52EE · Soft #A686FA · Wisteria #9F82FF ·
   Mist #C3B0FF · Lamp #FFD27A · Cradle #4A26B8 · Night #151025 · Ink #211739 ·
   Slate #675C7C · Moonlight #F3EEFF. Status colors (green/orange/red) stay semantic. */
:root {
  color-scheme: light dark;
  --night: #151025;
  --ink: #211739;
  --moonlight: #F3EEFF;
  --cradle: #4A26B8;
  --lamp: #FFD27A;         /* attention only: "I'm on it", alert actions */
  --on-lamp: #211739;
  --bg: #F3EEFF;
  --surface: #FFFFFF;
  --surface2: #E6DEFA;
  --label: #211739;
  --label2: #675C7C;
  --label3: rgba(103, 92, 124, 0.55);
  --separator: rgba(33, 23, 57, 0.12);
  --accent: #5630D0;       /* Dusk */
  --on-accent: #FFFFFF;
  --accent-hl: #7B52EE;    /* Lilac */
  --green: #34C759;
  --orange: #FF9500;
  --red: #FF3B30;
  --teal: #7B52EE;         /* former teal "info" accent, now Lilac */
  --pink: #FF2D55;
  --gray: #675C7C;
  --material: rgba(255, 255, 255, 0.94);
  --glow-strength: 55%;
  --shadow: 0 1px 2px rgba(33, 23, 57, 0.06), 0 4px 16px rgba(33, 23, 57, 0.06);
  --knob-shadow: 0 3px 8px rgba(33, 23, 57, 0.15), 0 1px 1px rgba(33, 23, 57, 0.16);
  /* text on tinted (15%) backgrounds needs darker shades in light mode */
  --green-text: #248A3D;
  --orange-text: #C93400;
  --red-text: #D70015;
  --teal-text: #5630D0;    /* Lilac on a Lilac tint is under 4.5:1, so Dusk */
  --codebox: #F3EEFF;
  --codebox-sheet: #E6DEFA;
  --sheet: #F3EEFF;
  --sheet-group: #FFFFFF;
  --switch-off: #E6DEFA;
  --bar: rgba(243, 238, 255, 0.85);
  --rounded: "Nunito", ui-rounded, "SF Pro Rounded", -apple-system, system-ui, sans-serif;
  --spring: cubic-bezier(.34, 1.36, .64, 1);
  --font: "Nunito", ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151025;
    --surface: #211739;
    --surface2: #2E2350;
    --label: #F3EEFF;
    --label2: rgba(243, 238, 255, 0.62);
    --label3: rgba(243, 238, 255, 0.35);
    --separator: rgba(243, 238, 255, 0.12);
    --accent: #9F82FF;     /* Wisteria */
    --on-accent: #211739;
    --accent-hl: #C3B0FF;  /* Mist */
    --green: #30D158;
    --orange: #FF9F0A;
    --red: #FF453A;
    --teal: #C3B0FF;       /* Mist */
    --pink: #FF375F;
    --gray: #7D7194;
    --material: rgba(46, 35, 80, 0.92);
    --glow-strength: 100%;
    --shadow: 0 0 0 transparent;
    --knob-shadow: 0 3px 8px rgba(0, 0, 0, 0.15), 0 1px 1px rgba(0, 0, 0, 0.16);
    --green-text: #30D158;
    --orange-text: #FF9F0A;
    --red-text: #FF6961;
    --teal-text: #C3B0FF;
    --codebox: #2E2350;
    --codebox-sheet: #3A2D63;
    --sheet: #211739;
    --sheet-group: #2E2350;
    --switch-off: rgba(243, 238, 255, 0.18);
    --bar: rgba(21, 16, 37, 0.85);
  }
}

/* ------------------------------------------------------------------ base */
* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { font-size: 100%; touch-action: manipulation; } /* no double-tap zoom */
html, body {
  margin: 0;
  background: var(--bg);
  color: var(--label);
  font: 1.0625rem/1.3 var(--font);
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}
body {
  padding: env(safe-area-inset-top) max(16px, env(safe-area-inset-right))
    0 max(16px, env(safe-area-inset-left));
  min-height: 100vh;
}
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
svg.i { width: 1em; height: 1em; flex: 0 0 auto; display: inline-block; vertical-align: -0.125em; }
p { margin: 0; }
h1, h2 { margin: 0; }

.screen { display: none; max-width: 560px; margin: 0 auto; padding-top: 12px; padding-bottom: calc(env(safe-area-inset-bottom) + 24px); }
.screen.active { display: block; animation: screen-in .35s cubic-bezier(.2, .8, .2, 1); }
@keyframes screen-in { from { opacity: 0; transform: translateY(8px); } }

.center { text-align: center; }

/* ------------------------------------------------------------- headings */
.large-title { font-size: 2.125rem; line-height: 1.21; font-weight: 700; letter-spacing: 0.012em; }

.hero-header { padding: 28px 4px 8px; }
/* wordmark in place of the plain-text app name (light/dark via <picture>) */
.home-logo { margin: 0 0 10px; padding: 0 4px; line-height: 0; }
.home-logo img { display: block; height: 44px; width: auto; max-width: 100%; }
.subtitle { color: var(--label2); font-size: 1.0625rem; margin-top: 4px; max-width: 34ch; }

.screen-header { padding: 16px 4px 4px; }
.pills { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }

.section-header {
  font-size: 0.8125rem; line-height: 1.38; font-weight: 400; text-transform: uppercase;
  letter-spacing: 0.02em; color: var(--label2);
  margin: 28px 16px 7px;
}
.section-header label { display: inline; font: inherit; }
.section-footer { font-size: 0.8125rem; line-height: 1.38; color: var(--label2); margin: 7px 16px 0; letter-spacing: 0; }
.section-footer.center { margin: 16px 16px 0; }

/* -------------------------------------------------------- grouped lists */
.group, .card {
  background: var(--surface);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.cell {
  position: relative;
  display: flex; align-items: center; gap: 12px;
  min-height: 44px; padding: 11px 16px;
  font-size: 1.0625rem; color: var(--label);
}
/* hairline separators, inset from the leading edge */
.group > .cell + .cell::before,
.listeners li + li::before,
.listeners:not(:empty) + .cell::before {
  content: ""; position: absolute; top: 0; right: 0; left: 16px;
  height: 1px; background: var(--separator); transform: scaleY(.5); transform-origin: top;
}
.group > .cell:has(> .icon-tile) + .cell::before { left: 57px; }
.group > .cell + .cell:has(> .icon-tile)::before { left: 57px; }
.cell-label { flex: 1; min-width: 0; }
.cell-value { color: var(--label2); font-variant-numeric: tabular-nums; }
.empty-cell { color: var(--label2); font-size: 0.9375rem; }

.icon-tile {
  width: 29px; height: 29px; border-radius: 7px; flex: 0 0 auto;
  display: grid; place-items: center; color: #fff; font-size: 1.125rem;
}
.tint-red { background: var(--red); }
.tint-orange { background: var(--orange); }
.tint-pink { background: var(--pink); }
.tint-gray { background: var(--gray); }
.tint-accent { background: var(--accent); color: var(--on-accent); }
.tint-green { background: var(--green); }

/* -------------------------------------------------------------- buttons */
button {
  font: inherit; letter-spacing: inherit; color: var(--accent);
  border: 0; background: none; padding: 0; margin: 0; cursor: pointer;
  -webkit-user-select: none; user-select: none;
  transition: opacity .15s, transform .2s var(--spring), background-color .2s;
}
button:disabled { opacity: .35; cursor: default; }
button[aria-disabled="true"] { cursor: default; }
button:focus-visible, input:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 2px; }

button.primary, button.secondary, button.destructive-button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 50px; padding: 0 20px; border-radius: 12px;
  font-size: 1.0625rem; font-weight: 600; white-space: nowrap;
}
button.primary { background: var(--accent); color: var(--on-accent); }
button.secondary { background: var(--surface2); color: var(--accent); }
.card button.secondary { background: color-mix(in srgb, var(--accent) 12%, var(--surface)); }
button.destructive-button { background: var(--surface); color: var(--red); box-shadow: var(--shadow); width: 100%; }
button.primary:not(:disabled):active, button.secondary:not(:disabled):active,
button.destructive-button:active, .tile:active { opacity: .85; transform: scale(.98); }
button.big { width: 100%; }

.text-button { color: var(--accent); font-size: 1.0625rem; min-height: 44px; padding: 0 4px; }
.text-button:active { opacity: .5; }
.text-button.small { font-size: 0.9375rem; }
.destructive { color: var(--red); }

.actions { display: grid; gap: 12px; margin-top: 32px; }

/* --------------------------------------------------------------- inputs */
input { font: inherit; color: var(--label); }
input.code {
  flex: 1; min-width: 0; border: 0; background: none; padding: 4px 0;
  font-size: 1.75rem; font-weight: 600; letter-spacing: .22em;
  font-variant-numeric: tabular-nums; font-feature-settings: "tnum";
}
input.code::placeholder { letter-spacing: 0; font-weight: 400; font-size: 1.25rem; color: var(--label3); }
input.code:focus, input.text:focus { outline: none; }
/* keyboard users still see where they are */
input.code:focus-visible, input.text:focus-visible, select:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 2px; border-radius: 6px; }
.cell:has(> input.text:focus-visible) { box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--accent) 55%, transparent); }
.code-cell { padding-top: 8px; padding-bottom: 8px; }
.code-cell .text-button { flex: 0 0 auto; }
input.text { flex: 1; min-width: 0; border: 0; background: none; font-size: 1.0625rem; padding: 0; }
input.text::placeholder { color: var(--label3); }

/* iOS-style switch (works for a checkbox and for a role=switch button) */
.switch {
  -webkit-appearance: none; appearance: none; position: relative; flex: 0 0 auto;
  width: 51px; height: 31px; margin: 0; border-radius: 999px; border: 0;
  background: var(--surface2); cursor: pointer; transition: background-color .25s;
}
@media (prefers-color-scheme: dark) { .switch { background: var(--switch-off); } }
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px;
  border-radius: 50%; background: #fff; box-shadow: var(--knob-shadow);
  transition: transform .3s var(--spring);
}
.switch:checked, .switch[aria-checked="true"] { background: var(--green); }
.switch:checked::after, .switch[aria-checked="true"]::after { transform: translateX(20px); }
.switch-cell { cursor: pointer; }

/* slider */
.slider-cell { flex-direction: column; align-items: stretch; gap: 6px; padding-top: 12px; padding-bottom: 12px; }
.slider-head { display: flex; justify-content: space-between; gap: 8px; }
.slider-head label { display: block; }
.slider-ends { display: flex; justify-content: space-between; gap: 8px; font-size: 0.8125rem; color: var(--label2); }
input[type=range] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 36px; margin: 0;
  background: transparent; --pct: 55%;
}
input[type=range]::-webkit-slider-runnable-track {
  height: 4px; border-radius: 2px;
  background: linear-gradient(90deg, var(--accent) var(--pct), var(--surface2) var(--pct));
}
input[type=range]::-moz-range-track { height: 4px; border-radius: 2px; background: var(--surface2); }
input[type=range]::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--accent); }
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 28px; height: 28px; margin-top: -12px; border-radius: 50%;
  background: #fff; box-shadow: var(--knob-shadow), 0 0 0 .5px rgba(0, 0, 0, .04);
}
input[type=range]::-moz-range-thumb { width: 28px; height: 28px; border: 0; border-radius: 50%; background: #fff; box-shadow: var(--knob-shadow); }

.cell-button { width: 100%; text-align: left; color: var(--accent); }
.cell-button:not(:disabled):active { background: var(--surface2); }
.cell-button:disabled { opacity: 1; color: var(--label2); }
.cell-button:disabled .icon-tile { opacity: .5; }

/* -------------------------------------------------------------- notices */
.error { color: var(--red); text-align: center; min-height: 22px; font-size: 0.9375rem; margin: 12px 16px 0; }
.error:empty { margin-top: 4px; }
.notice {
  display: flex; gap: 10px; align-items: flex-start;
  font-size: 0.8125rem; line-height: 1.38; color: var(--label2);
  margin: 12px 4px 0;
}
.notice svg.i { font-size: 1rem; margin-top: 1px; color: var(--orange); }
#keepOpen svg.i { color: var(--label2); }

/* ---------------------------------------------------------------- pills */
.pill {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%;
  border-radius: 999px; padding: 5px 11px; font-size: 0.8125rem; font-weight: 500;
  background: var(--surface); color: var(--label2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  letter-spacing: 0;
}
.pill.status { display: inline-block; padding-left: 24px; position: relative;
  background: color-mix(in srgb, var(--orange) 16%, transparent); color: var(--orange-text); }
.pill.status::before {
  content: ""; position: absolute; left: 11px; top: 50%; width: 7px; height: 7px; margin-top: -3.5px;
  border-radius: 50%; background: currentColor;
}
.pill.status.ok { background: color-mix(in srgb, var(--green) 16%, transparent); color: var(--green-text); }
.pill.status.ok::before { animation: live 2s ease-in-out infinite; }
.pill.status.bad { background: color-mix(in srgb, var(--red) 15%, transparent); color: var(--red-text); }
@keyframes live { 50% { opacity: .35; } }
.code-pill b { font-weight: 600; color: var(--label); font-variant-numeric: tabular-nums; letter-spacing: .04em; }
.pill.orange { background: color-mix(in srgb, var(--orange) 16%, transparent); color: var(--orange-text); }

/* ----------------------------------------------------------- sound ring */
.hero { display: flex; justify-content: center; padding: 24px 0 0; }
.ring {
  --ring: 236px; --ring-color: var(--green);
  position: relative; width: var(--ring); height: var(--ring); flex: 0 0 auto;
  margin: 0 auto; display: grid; place-items: center;
}
.ring-glow {
  position: absolute; inset: 8%; border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--ring-color) var(--glow-strength), transparent) 0%, transparent 68%);
  opacity: 0; transform: scale(.9); filter: blur(14px);
  transition: opacity .3s ease-out, transform .3s ease-out;
}
.ring-svg { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); overflow: visible; }
.ring-track { fill: none; stroke: var(--surface2); stroke-width: 7; }
.ring-progress {
  fill: none; stroke: var(--ring-color); stroke-width: 7; stroke-linecap: round;
  stroke-dasharray: 100 100; stroke-dashoffset: 100;
  transition: stroke-dashoffset .2s linear;
}
.ring-tick { stroke: var(--red); stroke-opacity: .55; stroke-width: 1.4; stroke-linecap: round; }
.ring-center {
  position: static; display: flex; flex-direction: column; align-items: center; gap: 4px;
  text-align: center; max-width: calc(var(--ring) - 44px);
}
.ring-center { z-index: 1; }
.ring-word { font-size: 1.875rem; line-height: 1.13; font-weight: 700; letter-spacing: 0.01em; }
.ring[data-tone="dim"] .ring-word { color: var(--label2); }
.ring[data-tone="bad"] .ring-word { color: var(--red); }
.ring { margin-bottom: 34px; }
.ring-sub {
  position: absolute; top: 100%; left: 50%; transform: translateX(-50%); margin-top: 12px;
  display: inline-flex; align-items: center; gap: 5px; white-space: nowrap;
  font-size: 0.8125rem; line-height: 1.23; color: var(--label2); letter-spacing: 0;
}
.ring-sub .ring-lock { font-size: 0.6875rem; color: var(--green); }
.ring:not([data-lock]) .ring-lock { display: none; }
.ring-sub-text:empty { display: none; }

/* --------------------------------------------------------------- video */
video { width: 100%; border-radius: 12px; background: var(--night); display: none; margin: 12px 0 0; aspect-ratio: 4 / 3; object-fit: cover; }
video.has-video { display: block; }
#selfView { margin-top: 8px; max-height: 240px; }

/* --------------------------------------------------------- pairing code */
.code-display { flex-direction: column; gap: 12px; padding: 18px 16px 16px; }
.big-code {
  font-size: 2.125rem; line-height: 1.21; font-weight: 600; letter-spacing: .2em; text-indent: .2em;
  font-variant-numeric: tabular-nums; font-feature-settings: "tnum";
}
.code-display .secondary { width: 100%; }

/* ------------------------------------------------------------- listeners */
.listeners { list-style: none; padding: 0; margin: 0; }
.listeners li {
  position: relative; display: flex; align-items: center; gap: 12px;
  min-height: 44px; padding: 11px 16px;
}
.listeners li::before { left: 57px !important; }
.listeners + .cell::before { left: 16px; }
.li-icon { width: 29px; height: 29px; border-radius: 7px; display: grid; place-items: center; color: #fff; font-size: 1rem; flex: 0 0 auto; background: var(--green); }
.listeners li.pending .li-icon { background: var(--orange); }
.li-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.listeners small { color: var(--label2); font-size: 0.9375rem; white-space: nowrap; }
.listeners li.new { animation: row-in .6s var(--spring); }
@keyframes row-in { from { opacity: 0; transform: translateY(-6px); } }
.listeners .pill { font-size: 0.75rem; padding: 4px 9px; flex: 0 1 auto; }

/* ------------------------------------------------------- approval cards */
#approvals { display: grid; gap: 12px; margin-top: 16px; }
#approvals:empty { display: none; }
.approve-card {
  padding: 20px 16px 16px; text-align: center;
  box-shadow: var(--shadow), inset 0 0 0 2px var(--accent);
  animation: card-in .45s var(--spring);
}
@keyframes card-in { from { opacity: 0; transform: translateY(-8px) scale(.97); } }
.approve-card .approve-icon { font-size: 2.125rem; color: var(--accent); display: block; margin: 0 auto 8px; }
.approve-card b { display: block; font-size: 1.0625rem; font-weight: 600; }
.approve-card p { font-size: 0.8125rem; line-height: 1.4; color: var(--label); margin-top: 4px; }
.sas {
  display: block; font-size: 2.125rem; line-height: 1.21; font-weight: 600; letter-spacing: .08em;
  font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; color: var(--label);
  margin: 14px 0 16px;
}
.approve-card .buttons, .approval-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.approval-buttons { grid-template-columns: 2fr 1fr; }
.approve-card .buttons button, .approval-buttons button { padding: 0 10px; min-width: 0; }

/* -------------------------------------------------------- parent: babies */
#babies { display: grid; gap: 16px; margin-top: 16px; }
.empty-state {
  display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center;
  padding: 40px 24px; background: var(--surface); border-radius: 12px; box-shadow: var(--shadow);
}
.empty-state svg.i { font-size: 2.5rem; color: var(--label3); animation: breathe 2.4s ease-in-out infinite; }
.empty-text { color: var(--label2); font-size: 0.9375rem; line-height: 1.33; max-width: 30ch; }
@keyframes breathe { 50% { opacity: .45; transform: scaleY(.85); } }

.baby-card { padding: 14px 16px 12px; transition: box-shadow .3s; }
.card-head { display: flex; align-items: center; gap: 10px; }
.baby-name { flex: 1; min-width: 0; font-size: 1.0625rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.baby-kind { background: var(--surface2); color: var(--label2); flex: 0 1 auto; max-width: 45%; }
.baby-card .ring { --ring: 220px; margin: 20px auto 40px; }
.baby-card:not([data-state="active"]) canvas.history { display: none; }
.baby-card[data-state="active"] .baby-state { display: none; }
.baby-card[data-state="active"] .card-foot:has(.remove[hidden]) { display: none; }
.baby-card video.has-video + .ring { --ring: 180px; }
#babies:has(.baby-card ~ .baby-card) .ring { --ring: 150px; }
#babies:has(.baby-card ~ .baby-card) .ring-word { font-size: 1.375rem; line-height: 1.27; }
#babies:has(.baby-card ~ .baby-card) .ring-sub-text { display: none; }

.approval {
  margin-top: 12px; padding: 16px; border-radius: 12px; text-align: center;
  background: color-mix(in srgb, var(--accent) 10%, var(--surface));
  animation: card-in .45s var(--spring);
}
.approval button.secondary { background: var(--surface); }
.approval-text { font-size: 0.9375rem; line-height: 1.35; color: var(--label); }
.approval .sas { margin: 8px 0 14px; }

canvas.history { width: 100%; height: 50px; display: block; margin-top: 12px; }
.card-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 32px; margin-top: 6px; }
.baby-state { font-size: 0.8125rem; line-height: 1.38; color: var(--label2); letter-spacing: 0; }
.card-foot .remove { min-height: 32px; }

.baby-card.loud { box-shadow: var(--shadow), inset 0 0 0 2px var(--orange); }
.baby-card.lost, .baby-card.offline { box-shadow: var(--shadow), inset 0 0 0 2px var(--red); }
.baby-card.offline .baby-state, .baby-card.lost .baby-state { color: var(--red-text); }

/* ------------------------------------------------------------ alert banner */
#alertBanner {
  position: sticky; top: calc(env(safe-area-inset-top) + 8px); z-index: 20;
  display: flex; align-items: center; gap: 12px;
  margin: 8px 0 4px; padding: 12px 12px 12px 14px; border-radius: 16px;
  background: var(--material); color: var(--label);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  box-shadow: 0 8px 30px rgba(0, 0, 0, .14), inset 0 0 0 1px color-mix(in srgb, var(--red) 35%, transparent);
  animation: banner-in .5s var(--spring);
}
@keyframes banner-in { from { opacity: 0; transform: translateY(-16px) scale(.96); } }
.banner-icon {
  width: 40px; height: 40px; border-radius: 50%; flex: 0 0 auto; display: grid; place-items: center;
  background: var(--red); color: #fff; font-size: 1.375rem;
  animation: icon-pulse 1.2s ease-in-out infinite;
}
#alertBanner .warn { display: none; }
#alertBanner[data-kind="conn"] .bell { display: none; }
#alertBanner[data-kind="conn"] .warn { display: inline; }
#alertBanner[data-kind="test"] .banner-icon { background: var(--orange); }
@keyframes icon-pulse { 50% { transform: scale(1.1); box-shadow: 0 0 0 6px color-mix(in srgb, var(--red) 22%, transparent); } }
.banner-text { flex: 1; min-width: 0; }
.banner-text b { display: block; font-size: 1.0625rem; line-height: 1.29; font-weight: 600; }
.banner-text small { display: block; font-size: 0.8125rem; color: var(--label2); margin-top: 1px; font-variant-numeric: tabular-nums; }
#dismissAlert {
  flex: 0 0 auto; min-width: 60px; min-height: 44px; padding: 0 14px; border-radius: 999px;
  background: var(--accent); color: var(--on-accent); font-size: 0.9375rem; font-weight: 600;
}

/* --------------------------------------------------------------- dim */
#night {
  position: fixed; inset: 0; background: var(--night); z-index: 50;
  display: flex; align-items: flex-end; justify-content: center; cursor: pointer;
}
#night p { color: rgba(243, 238, 255, 0.30); font-size: 0.8125rem; margin-bottom: calc(env(safe-area-inset-bottom) + 32px); }

/* --------------------------------------------------------- small screens */
@media (max-width: 359px) {
  .large-title { font-size: 1.875rem; line-height: 1.2; }
  .ring { --ring: 208px; }
  .baby-card .ring { --ring: 196px; }
  input.code { font-size: 1.5rem; letter-spacing: .16em; }
  .big-code { font-size: 1.875rem; }
  .sas { font-size: 1.875rem; }
}

/* ------------------------------------------------------- reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition-duration: 0s !important; }
}

/* Parent: Safari suspended the audio, one tap brings it back. */
#enableSound { margin: 4px 0 16px; }

/* ------------------------------------------------------------- v3 additions */
.tint-teal { background: var(--teal); color: var(--on-accent); }
.hint { font-size: 0.8125rem; color: var(--label2); margin: 10px 16px 0; min-height: 1em; }
.hint:empty { display: none; }
.warn-text { color: var(--red-text) !important; }
input.text.right { text-align: right; }

/* "Sound is paused" + mic stopped: styled like an alert */
button.alert-button {
  display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%;
  min-height: 50px; padding: 10px 16px; border-radius: 12px; margin: 4px 0 16px;
  background: var(--red); color: #fff; font-size: 1.0625rem; font-weight: 600; text-align: left; white-space: normal;
  animation: banner-in .5s var(--spring);
}
.alert-notice {
  padding: 12px 14px; border-radius: 12px; margin: 12px 0 0; color: var(--label);
  background: color-mix(in srgb, var(--red) 14%, var(--surface)); font-size: 0.9375rem; line-height: 1.35;
}
.alert-notice svg.i { color: var(--red); }

/* baby: what is happening now (soothing, talk-back, someone on it) */
.now-list { display: grid; gap: 8px; margin-top: 8px; }
.now-list:not(:has(.now-row:not([hidden]))) { display: none; }
.now-row { display: flex; align-items: center; gap: 12px; background: var(--surface); border-radius: 12px; padding: 8px 12px; min-height: 44px; box-shadow: var(--shadow); }
.now-text { flex: 1; min-width: 0; font-size: 0.9375rem; }

/* pairing code card buttons + QR */
.code-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; }
.code-buttons .secondary { width: 100%; padding: 0 10px; font-size: 0.9375rem; }
.qr-box { width: min(100%, 300px); aspect-ratio: 1; margin: 0 auto; }
.qr-box svg { width: 100%; height: 100%; display: block; border-radius: 8px; }

/* alert banner buttons */
.banner-buttons { display: flex; flex-direction: column; gap: 6px; flex: 0 0 auto; }
.banner-secondary {
  min-height: 44px; padding: 0 12px; border-radius: 999px; font-size: 0.9375rem; font-weight: 600;
  background: var(--lamp); color: var(--on-lamp);   /* Lamp: needs a parent's attention */
}
#alertBanner[data-kind="battery"] .banner-icon { background: var(--orange); }
#alertBanner:not([data-step="0"]) { box-shadow: 0 8px 30px rgba(0, 0, 0, .2), inset 0 0 0 2px var(--red); }

/* mute */
button.pill.mute-pill { min-height: 32px; cursor: pointer; background: color-mix(in srgb, var(--pink) 16%, transparent); color: var(--red-text); }
.mute-cell { flex-wrap: wrap; }
.mini-buttons { display: flex; gap: 6px; flex-wrap: wrap; }
.mini-buttons button, .mini-primary {
  min-height: 44px; min-width: 44px; padding: 0 12px; border-radius: 999px; font-size: 0.9375rem; font-weight: 500;
  background: var(--surface2); color: var(--accent);
}
.mini-primary { background: var(--accent); color: var(--on-accent); }

/* morning summary */
.summary-card { display: flex; gap: 12px; align-items: center; padding: 12px 16px; margin-top: 12px; }
.summary-card b { display: block; font-size: 0.9375rem; }
.summary-card p { font-size: 0.9375rem; color: var(--label); }

/* baby card additions */
.battery-pill { background: color-mix(in srgb, var(--green) 14%, transparent); color: var(--green-text); flex: 0 0 auto; }
.battery-pill.low { background: color-mix(in srgb, var(--red) 15%, transparent); color: var(--red-text); }
.listen-button {
  display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 14px; margin-top: 8px;
  border-radius: 999px; background: var(--surface2); color: var(--accent); font-size: 0.9375rem; font-weight: 600;
}
.listen-button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }
.baby-card.chosen { box-shadow: var(--shadow), inset 0 0 0 2px var(--accent); }
.card-info { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.card-info:empty { display: none; }
.card-info li { border-radius: 999px; padding: 5px 11px; font-size: 0.8125rem; font-weight: 500; background: var(--surface2); color: var(--label); }
.card-info .info-ok { background: color-mix(in srgb, var(--green) 16%, transparent); color: var(--green-text); }
.card-info .info-bad { background: color-mix(in srgb, var(--red) 15%, transparent); color: var(--red-text); }
.card-info .info-accent { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); }
.card-info .info-teal { background: color-mix(in srgb, var(--teal) 18%, transparent); color: var(--teal-text); }
.peek { margin: 12px 0 0; }
.peek img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 12px; background: var(--night); }
.peek figcaption { font-size: 0.8125rem; color: var(--label2); margin-top: 4px; text-align: center; }
.card-controls { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 8px; margin-top: 12px; }
.card-controls button { padding: 0 10px; font-size: 0.9375rem; touch-action: none; -webkit-touch-callout: none; }
.card-controls .talk-button.talking { background: var(--red); color: #fff; }
.soothe-panel { display: grid; gap: 10px; margin-top: 10px; padding: 12px; border-radius: 12px; background: color-mix(in srgb, var(--teal) 10%, var(--surface)); }
.soothe-field { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; font-size: 0.9375rem; }
.soothe-field select { font: inherit; min-height: 40px; padding: 0 8px; border-radius: 8px; border: 0; background: var(--surface2); color: var(--label); }
.soothe-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.soothe-actions button { padding: 0 10px; }
.soothe-actions:has(.soothe-stop[hidden]) { grid-template-columns: 1fr; }

/* baby: approval prompt details */
.approve-who { display: flex; justify-content: center; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 0.9375rem !important; }
.approve-name { font-weight: 600; }
.approve-fp { font-variant-numeric: tabular-nums; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.pill.accent { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); }
.listeners .text-button.small { min-height: 44px; flex: 0 0 auto; }
#night:focus-visible { outline: 2px solid rgba(243, 238, 255, .3); outline-offset: -6px; }
.mute-cell .mini-buttons { flex: 1 1 100%; padding-left: 41px; }
.mute-cell .mini-buttons button { flex: 1 1 auto; }
.cell-button.destructive { color: var(--red); }
.cell-button.destructive:disabled { color: var(--label2); }

/* =================================================================== setup
   S1–S8 from docs/SETUP-DESIGN.md. Sizes in rem follow the browser's font size. */
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
[tabindex="-1"]:focus { outline: none; }
.headline { font-size: 1.0625rem; line-height: 1.3; font-weight: 600; margin: 0; }
.title2 { font-size: 1.375rem; line-height: 1.27; font-weight: 700; margin: 0; }
.title3 { font-size: 1.25rem; line-height: 1.25; font-weight: 600; margin: 0; letter-spacing: 0.01em; }
.card-body { font-size: 0.9375rem; line-height: 1.33; color: var(--label2); }

/* pages with a bottom bar fill the screen so the bar sits at the bottom */
.setup-page { position: relative; padding-bottom: 0; }
.setup-page.active { display: flex; flex-direction: column; min-height: calc(100vh - env(safe-area-inset-top)); min-height: calc(100dvh - env(safe-area-inset-top)); }
.setup-content { flex: 1 0 auto; padding-bottom: 24px; }
#home .setup-content { padding-bottom: calc(env(safe-area-inset-bottom) + 24px); }
.setup-page .large-title { padding: 0 4px; }

/* toolbar + nav */
.circle-button {
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface); color: var(--label); font-size: 1.3125rem; box-shadow: var(--shadow);
}
@media (prefers-color-scheme: dark) { .circle-button { background: var(--surface2); } }
.circle-button:active { opacity: .6; }
.toolbar-button { position: absolute; top: 12px; right: 0; }
.nav-bar { min-height: 44px; display: flex; align-items: center; margin: 0 0 2px -8px; }
.back-button {
  display: inline-flex; align-items: center; gap: 2px; min-height: 44px; padding: 0 8px;
  font-size: 1.0625rem; color: var(--accent);
}
.back-button svg.i { font-size: 1.25rem; margin-left: -4px; }
.back-button:active { opacity: .5; }

/* S1 */
#home .hero-header { padding: 64px 4px 0; }
#home .subtitle { margin-top: 6px; }
.question { font-size: 1.25rem; line-height: 1.25; font-weight: 600; margin: 28px 4px 12px; letter-spacing: 0.01em; }
#home.returning .question { font-size: 1.0625rem; margin-top: 26px; }
.role-tiles { display: grid; gap: 12px; }
.role-tile {
  display: flex; align-items: center; gap: 14px; width: 100%; min-height: 88px; padding: 16px;
  border-radius: 22px; background: var(--surface); color: var(--label); text-align: left;
  box-shadow: var(--shadow); transition: transform .15s, background-color .15s;
}
.role-tile:active { transform: scale(.98); background: var(--surface2); }
.role-circle {
  width: 52px; height: 52px; border-radius: 50%; flex: 0 0 auto; display: grid; place-items: center; font-size: 1.625rem;
  background: color-mix(in srgb, var(--accent) 15%, transparent); color: var(--accent);
}
.role-circle.parent { background: color-mix(in srgb, var(--teal) 16%, transparent); color: var(--teal-text); }
.role-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.role-title { font-size: 1.0625rem; font-weight: 600; line-height: 1.3; }
.role-sub { font-size: 0.9375rem; line-height: 1.33; color: var(--label2); }
.role-chevron { color: var(--label3); font-size: 0.875rem; }
#home.returning .role-tiles { grid-template-columns: 1fr 1fr; }
#home.returning .role-tile { min-height: 64px; padding: 12px 14px; gap: 10px; }
#home.returning .role-tile .role-circle { width: 36px; height: 36px; font-size: 1.1875rem; }
#home.returning .role-title { font-size: 1rem; }
#home.returning .role-sub {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}
#home.returning .role-chevron { display: none; }
@media (max-width: 22em) { #home.returning .role-tiles { grid-template-columns: 1fr; } }
.privacy {
  display: flex; gap: 6px; justify-content: center; align-items: flex-start; text-align: center;
  font-size: 0.8125rem; line-height: 1.38; color: var(--label2); margin: 24px 24px 0;
}
.privacy svg.i { font-size: 0.75rem; margin-top: 3px; }
#home .notice { margin-top: 16px; }

/* hero cards: Last time + Scan */
.hero-card {
  display: grid; gap: 12px; padding: 20px; margin-top: 24px; border-radius: 22px;
  background: var(--surface); box-shadow: var(--shadow);
}
.last-card { animation: card-rise .3s ease-out; }
@keyframes card-rise { from { opacity: 0; transform: translateY(8px); } }
.last-head { display: flex; gap: 14px; align-items: center; }
.last-card .role-circle { width: 44px; height: 44px; font-size: 1.375rem; }
.last-text { flex: 1; min-width: 0; }
.last-line { font-size: 0.9375rem; line-height: 1.33; color: var(--label2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stopped-pill { justify-self: start; font-weight: 600; font-size: 0.75rem; }
.hero-card .primary { margin-top: 4px; }
.plain-big { width: 100%; min-height: 44px; font-size: 1.0625rem; }
.last-card .plain-big { margin-top: -6px; }
.scan-tile {
  width: 56px; height: 56px; border-radius: 14px; display: grid; place-items: center; font-size: 1.875rem;
  background: color-mix(in srgb, var(--accent) 15%, transparent); color: var(--accent); margin-bottom: 2px;
}
.scan-card .card-body { margin-top: -6px; }
.scan-card .primary { margin-top: 4px; }

/* S2 */
.tips { padding: 4px 16px; margin-top: 16px; }
.tip { display: flex; gap: 12px; align-items: center; padding: 10px 0; font-size: 0.9375rem; line-height: 1.33; }
.tip + .tip { box-shadow: inset 0 0.5px 0 var(--separator); }
.tip-icon { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; flex: 0 0 auto; font-size: 1.0625rem; }
.soft-green { background: color-mix(in srgb, var(--green) 18%, transparent); color: var(--green-text); }
.soft-accent { background: color-mix(in srgb, var(--accent) 15%, transparent); color: var(--accent); }
.setup-group { margin-top: 24px; }
.value-row { color: var(--label); }
.value-row .cell-label { flex: 1 0 auto; }
.value-row .cell-value { margin-left: auto; text-align: right; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.code-value { letter-spacing: 0.03em; }
.row-chevron { color: var(--label3); font-size: 0.8125rem; margin-left: -4px; }
.password-row input::placeholder { color: var(--label3); }
.cell label.cell-label { cursor: default; }
.cell:has(> input.text) > label.cell-label { flex: 0 0 auto; }

/* inline status cards (§4.8) */
.status-card {
  display: flex; gap: 12px; align-items: flex-start; margin-top: 24px; padding: 16px;
  border-radius: 12px; background: var(--surface); box-shadow: var(--shadow);
}
.status-icon { font-size: 1.75rem; color: var(--orange); flex: 0 0 auto; }
.status-icon.red { color: var(--red); }
.status-text { flex: 1; min-width: 0; display: grid; gap: 4px; }
.status-body { font-size: 0.9375rem; line-height: 1.33; color: var(--label2); }
.status-body:empty { display: none; }
.status-button { width: 100%; min-height: 44px; margin-top: 10px; font-size: 1rem; }
.status-card .plain-big { font-size: 1rem; }
#micDenied .headline:focus { outline: none; }

/* sticky bottom bar (§4.6) */
.bottom-bar {
  position: sticky; bottom: 0; z-index: 5; margin: 0 -16px;
  padding: 12px 16px calc(8px + env(safe-area-inset-bottom));
  background: var(--bar); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
  box-shadow: 0 -0.5px 0 var(--separator);
}
.bottom-bar > * { max-width: 560px; margin-left: auto; margin-right: auto; }
/* very large text (or a short window): the bar scrolls with the page */
@media (max-height: 34em) { .bottom-bar { position: static; } }
.primer { text-align: center; font-size: 0.8125rem; line-height: 1.38; color: var(--label2); margin-bottom: 8px; }
.primer svg.i { font-size: 0.8125rem; margin-right: 5px; vertical-align: -0.1em; }
.primer.warn { color: var(--orange-text); }
.start-button[aria-disabled="true"] { opacity: .38; }
.start-button[aria-disabled="true"]:active { transform: none; }
.start-button.busy { opacity: .6; }
.hint-line:empty { display: none; }
.hint-line { margin-top: 2px; }
.hint-button, .hint-text {
  display: flex; gap: 5px; align-items: center; justify-content: center; width: 100%; min-height: 44px;
  font-size: 0.8125rem; line-height: 1.38; color: var(--label2); text-align: center;
  animation: fade-in .2s;
}
.hint-button svg.i, .hint-text svg.i { font-size: 0.875rem; }
.hint-button .hint-chevron { color: var(--accent); font-size: 0.6875rem; }
.hint-button:active { opacity: .5; }
@keyframes fade-in { from { opacity: 0; } }

/* code field (§4.5): one real input drawn as boxes */
.code-card { padding: 16px 10px; display: flex; justify-content: center; container-type: inline-size; }
.code-field { position: relative; border-radius: 14px; }
.code-boxes { display: flex; gap: 8px; justify-content: center; }
.code-gap { width: 4px; flex: 0 0 auto; }
.code-box {
  position: relative; width: 2.875rem; height: 3.625rem; border-radius: 12px; flex: 0 0 auto;
  display: grid; place-items: center; background: var(--codebox); color: var(--label);
  font: 600 1.875rem/1 var(--rounded); font-variant-numeric: tabular-nums;
}
.code-field:focus-within .code-box.active { box-shadow: inset 0 0 0 2px var(--accent); }
.code-field:focus-within .code-box.active:empty::after {
  content: ""; width: 2px; height: 1.75rem; border-radius: 1px; background: var(--accent);
  animation: caret 1s steps(1) infinite;
}
@keyframes caret { 50% { opacity: 0; } }
.code-input {
  position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; padding: 0; border: 0;
  opacity: 0; font-size: 16px; color: transparent; background: transparent; caret-color: transparent;
}
.code-field:has(.code-input:focus-visible) { outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 5px; }
.code-field.error .code-box { box-shadow: inset 0 0 0 2px var(--red); }
.code-field.error .code-boxes { animation: shake .3s; }
@keyframes shake { 25% { transform: translateX(-6px); } 50% { transform: translateX(6px); } 75% { transform: translateX(-3px); } }
@container (max-width: 20.5em) {
  .code-box { width: 2.5rem; height: 3.25rem; }
}
@container (max-width: 18.25em) {
  .code-boxes { flex-wrap: wrap; row-gap: 8px; }
  .code-gap { flex-basis: 100%; height: 0; }
}

/* dialogs as sheets */
dialog.sheet {
  border: 0; padding: 0; margin: auto; color: var(--label); background: var(--sheet);
  width: min(100% - 32px, 560px); max-width: 560px; max-height: calc(100dvh - 48px);
  border-radius: 14px; overflow: auto; overscroll-behavior: contain;
  box-shadow: 0 24px 80px rgba(0, 0, 0, .35);
}
dialog.sheet[open] { animation: sheet-in .3s cubic-bezier(.2, .8, .2, 1); }
dialog.sheet::backdrop { background: rgba(21, 16, 37, .35); }
@media (prefers-color-scheme: dark) { dialog.sheet::backdrop { background: rgba(10, 7, 20, .6); } }
@keyframes sheet-in { from { opacity: 0; transform: translateY(24px); } }
@media (max-width: 600px) {
  dialog.sheet {
    width: 100%; max-width: 100%; margin: auto 0 0; border-radius: 14px 14px 0 0;
    min-height: calc(100dvh - env(safe-area-inset-top) - 24px); max-height: calc(100dvh - env(safe-area-inset-top) - 24px);
    padding-bottom: env(safe-area-inset-bottom);
  }
  dialog.sheet.sheet-small { min-height: 0; }
  dialog.sheet[open] { animation-name: sheet-up; }
  @keyframes sheet-up { from { transform: translateY(100%); } }
}
.sheet .group, .sheet .code-card { background: var(--sheet-group); }

/* confirm / alert (replaces the browser's confirm() and alert()) */
dialog.ask {
  border: 0; padding: 0; margin: auto; color: var(--label); background: var(--sheet-group);
  width: min(100% - 48px, 320px); border-radius: 18px; overflow: hidden;
  box-shadow: 0 24px 80px rgba(0, 0, 0, .35), 0 0 0 .5px var(--separator);
}
dialog.ask[open] { animation: ask-in .28s var(--spring); }
dialog.ask::backdrop { background: rgba(21, 16, 37, .4); }
@media (prefers-color-scheme: dark) { dialog.ask::backdrop { background: rgba(10, 7, 20, .65); } }
@keyframes ask-in { from { opacity: 0; transform: scale(1.12); } }
.ask-text { padding: 22px 20px 18px; text-align: center; }
.ask-text h2 { margin: 0; font-size: 1.0625rem; font-weight: 700; line-height: 1.3; }
.ask-text h2:focus { outline: none; }
.ask-text p { margin: 6px 0 0; font-size: 0.9375rem; line-height: 1.4; color: var(--label2); white-space: pre-line; overflow-wrap: anywhere; }
.ask-text p:empty { display: none; }
.ask-actions { display: flex; box-shadow: inset 0 .5px 0 var(--separator); }
.ask-actions button {
  flex: 1 1 0; min-height: 48px; padding: 8px 12px; font-size: 1.0625rem; color: var(--accent);
  white-space: normal; line-height: 1.2;
}
.ask-actions button + button { box-shadow: inset .5px 0 0 var(--separator); }
.ask-actions button:hover { background: color-mix(in srgb, var(--accent) 7%, transparent); }
.ask-actions button:active { background: color-mix(in srgb, var(--accent) 14%, transparent); }
.ask-actions button:focus-visible { outline: none; background: color-mix(in srgb, var(--accent) 12%, transparent); }
#askOk { font-weight: 700; }
#askOk.destructive { color: var(--red); }
#askOk.destructive:hover, #askOk.destructive:focus-visible { background: color-mix(in srgb, var(--red) 9%, transparent); }
.sheet .code-box { background: var(--codebox); }
@media (prefers-color-scheme: dark) { .sheet .code-box { background: var(--codebox-sheet); } }
.sheet-nav {
  position: sticky; top: 0; z-index: 2; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  min-height: 52px; padding: 4px 8px 0; background: var(--sheet);
}
.sheet-nav h2 { font-size: 1.0625rem; font-weight: 600; text-align: center; margin: 0; }
.sheet-nav .text-button { justify-self: start; padding: 0 8px; }
.sheet-nav .nav-done { justify-self: end; font-weight: 600; }
.sheet-body { padding: 0 16px 24px; }
.sheet-body > .section-header:first-child { margin-top: 12px; }
.sheet-small .sheet-body > .code-card { margin-top: 12px; }
.sheet-small .secondary.big { margin-top: 16px; }
.center-body { text-align: center; display: grid; gap: 8px; justify-items: center; }
.center-body .group { width: 100%; text-align: left; margin-top: 8px; }
.center-body .primary { margin-top: 8px; }
.key-circle {
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-size: 1.375rem;
  background: color-mix(in srgb, var(--accent) 15%, transparent); color: var(--accent); margin-top: 8px;
}

/* S8 */
.qr-card { width: min(100%, 292px); margin: 4px auto 0; padding: 16px; border-radius: 20px; background: #fff; }
.qr-box { width: 100%; aspect-ratio: 1; }
.qr-box svg { width: 100%; height: 100%; display: block; }
.qr-code-label { text-align: center; font-size: 0.8125rem; color: var(--label2); margin-top: 14px; }
.qr-code {
  text-align: center; font-size: 1.75rem; font-weight: 700; letter-spacing: 0.06em; line-height: 1.2;
  font-variant-numeric: tabular-nums; font-family: var(--rounded);
}
.steps { list-style: none; margin: 18px 0 0; padding: 0; }
.steps li { position: relative; display: flex; gap: 12px; align-items: center; min-height: 44px; padding: 8px 16px; font-size: 0.9375rem; line-height: 1.33; }
.steps li + li::before { content: ""; position: absolute; top: 0; right: 0; left: 52px; height: 1px; background: var(--separator); transform: scaleY(.5); }
.step-num {
  width: 24px; height: 24px; border-radius: 50%; flex: 0 0 auto; display: grid; place-items: center;
  background: var(--accent); color: var(--on-accent); font-size: 0.8125rem; font-weight: 600;
}
.sheet-group { margin-top: 20px; }
.clock-footer { display: flex; gap: 6px; align-items: flex-start; margin-top: 16px; }
.clock-footer svg.i { margin-top: 2px; flex: 0 0 auto; }
.toast {
  display: flex; gap: 8px; align-items: center; width: fit-content; max-width: 100%; margin: 0 auto 12px;
  padding: 8px 14px; border-radius: 999px; background: var(--sheet-group); box-shadow: var(--shadow);
  font-size: 0.9375rem; font-weight: 600; animation: card-rise .3s ease-out;
}
.toast svg.i { color: var(--green); font-size: 1.125rem; }

/* S5 scanner: always dark */
dialog.scanner {
  position: fixed; inset: 0; width: 100%; height: 100%; max-width: none; max-height: none;
  margin: 0; padding: 0; border: 0; background: var(--night); color: var(--moonlight); overflow: hidden; color-scheme: dark;
}
dialog.scanner::backdrop { background: var(--night); }
#scanVideo { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: 0; margin: 0; display: block; aspect-ratio: auto; }
.scan-window {
  position: absolute; left: 50%; top: 42%; width: 260px; height: 260px; max-width: 72vw; max-height: 72vw;
  translate: -50% -50%; border-radius: 28px; box-shadow: 0 0 0 200vmax rgba(21, 16, 37, .6);
  animation: bracket-pulse 1.6s ease-in-out infinite alternate;
}
@keyframes bracket-pulse { to { scale: 1.03; } }
.corner { position: absolute; width: 36px; height: 36px; border: 4px solid #fff; transition: border-color .25s; }
.corner.tl { top: -2px; left: -2px; border-right: 0; border-bottom: 0; border-top-left-radius: 28px; }
.corner.tr { top: -2px; right: -2px; border-left: 0; border-bottom: 0; border-top-right-radius: 28px; }
.corner.bl { bottom: -2px; left: -2px; border-right: 0; border-top: 0; border-bottom-left-radius: 28px; }
.corner.br { bottom: -2px; right: -2px; border-left: 0; border-top: 0; border-bottom-right-radius: 28px; }
.scanner.found .scan-window { animation: none; scale: .94; transition: scale .25s var(--spring); }
.scanner.found .corner { border-color: #30D158; }
.scanner.denied #scanVideo, .scanner.denied .scan-window { display: none; }
.scan-top {
  position: absolute; top: calc(env(safe-area-inset-top) + 12px); left: 16px; right: 16px;
  display: flex; justify-content: space-between; align-items: center;
}
.glass-button {
  min-height: 44px; padding: 0 20px; border-radius: 22px; font-size: 1rem; font-weight: 600; color: #fff;
  background: rgba(46, 35, 80, .6); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
}
.glass-button.round { width: 44px; padding: 0; display: grid; place-items: center; font-size: 1.25rem; }
.glass-button[aria-pressed="true"] { background: var(--moonlight); color: var(--ink); }
.glass-button:focus-visible, .scanner button:focus-visible { outline: 3px solid rgba(255, 255, 255, .8); outline-offset: 2px; }
.scan-text {
  position: absolute; left: 24px; right: 24px; top: calc(42% + min(130px, 36vw) + 24px);
  text-align: center; max-width: 30rem; margin: 0 auto;
}
#scanTitle { font-size: 1.0625rem; line-height: 1.3; font-weight: 600; margin: 0; }
#scanSub { font-size: 0.9375rem; line-height: 1.33; color: rgba(255, 255, 255, .7); margin-top: 4px; }
.scan-error { display: flex; gap: 6px; justify-content: center; align-items: flex-start; font-size: 0.9375rem; line-height: 1.33; color: #FF9F0A; margin-top: 4px; }
.scan-error svg.i { margin-top: 2px; }
.scan-bottom { position: absolute; left: 16px; right: 16px; bottom: calc(env(safe-area-inset-bottom) + 24px); display: flex; justify-content: center; }
.scan-denied {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; padding: 72px 24px 24px; text-align: center;
}
.scan-denied > * { max-width: 360px; }
.scan-denied p { font-size: 0.9375rem; line-height: 1.33; color: rgba(255, 255, 255, .7); margin-bottom: 8px; }
.scan-denied .big { width: 100%; }
.scan-denied .secondary { background: #2E2350; color: var(--moonlight); }
.denied-circle { width: 72px; height: 72px; border-radius: 50%; display: grid; place-items: center; background: #2E2350; font-size: 2rem; margin-bottom: 8px; }

/* S7 */
.pairing-page.active { display: flex; align-items: center; justify-content: center; min-height: calc(100dvh - env(safe-area-inset-top)); }
.pair-center { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 24px; width: 100%; padding: 24px 8px; }
.pair-ring { position: relative; width: 120px; height: 120px; display: grid; place-items: center; }
.pair-ring-svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.pair-track { fill: none; stroke: var(--surface2); stroke-width: 6; }
.pair-arc {
  fill: none; stroke: var(--accent); stroke-width: 6; stroke-linecap: round; stroke-dasharray: 26 100;
  transform-origin: 60px 60px; animation: spin 1.1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.pair-qr { font-size: 2.5rem; color: var(--accent); }
.pair-ring .pair-check { display: none; font-size: 3.25rem; color: var(--green); }
[data-state="done"] .pair-arc { animation: none; stroke: var(--green); stroke-dasharray: 100 100; transition: stroke-dasharray .3s; }
[data-state="done"] .pair-qr { display: none; }
[data-state="done"] .pair-ring .pair-check { display: block; animation: pop .35s var(--spring); }
@keyframes pop { from { transform: scale(.4); opacity: 0; } }
[data-state="failed"] .pair-arc { animation: none; opacity: 0; }
[data-state="failed"] .pair-qr { color: var(--label3); }
.pair-sub { font-size: 0.8125rem; color: var(--label2); margin-top: 6px; font-variant-numeric: tabular-nums; }
.pair-body { font-size: 0.9375rem; line-height: 1.38; color: var(--label2); max-width: 32ch; margin: 10px auto 0; }
.pair-actions { display: grid; gap: 12px; width: 100%; max-width: 400px; }
@media (prefers-reduced-motion: reduce) {
  .pair-arc { stroke-dasharray: 26 100; }
}

.text-button:focus-visible, .back-button:focus-visible, .hint-button:focus-visible { border-radius: 8px; }
.sheet-nav h2:focus, .scan-denied h2:focus { outline: none; }
.cell > input.text:focus-visible { outline: none; }

/* large text / 200% zoom: nothing pushes the page wider than the screen */
.hero-card { grid-template-columns: minmax(0, 1fr); }
.setup-page button.big, .pairing-page button.big, dialog button.big { white-space: normal; text-align: center; line-height: 1.2; padding-top: 8px; padding-bottom: 8px; }
.setup-page .cell:has(> input.text), dialog .cell:has(> input.text) { flex-wrap: wrap; row-gap: 4px; }
.cell:has(> input.text) > label.cell-label { flex: 0 1 auto; overflow-wrap: anywhere; }
.setup-page .cell > input.text, dialog .cell > input.text { flex: 1 1 7em; min-width: 7em; }
.value-row { flex-wrap: wrap; }
@media (max-width: 22em) { .last-line { white-space: normal; } }
