/* ════════════════════════════════════════════════════════════════════
   Ania design system
   Tokens → themes (dark default, light override) → text sizes → parts.
   All sizes in rem so the html[data-text] control scales everything.

   Beautify pass: display typography (offline system stacks), a floating
   glass header pill + segmented tab control, per-mode color identities
   for the four core buttons, numbered recovery steps, bordered verdict
   chips, and token aliases so every component actually resolves
   (--text-muted, --panel-2, --ok/--warn/--bad).
   ════════════════════════════════════════════════════════════════════ */

/* ── Tokens: dark (default) ──────────────────────────────────────── */
:root {
  /* surfaces */
  --bg: #0b1120;
  --bg-glow-1: rgba(91, 140, 255, 0.14);
  --bg-glow-2: rgba(52, 201, 142, 0.10);
  --card: #151d31;
  --card-2: #1b2440;
  --line: #273252;
  --line-strong: #35426b;

  /* text */
  --text: #eef2fb;
  --muted: #94a3c4;
  --faint: #7e8cab; /* a11y: ≥4.5:1 on card-2 (was #67759a, 3.3:1) */

  /* aliases — components written against these names resolve everywhere */
  --text-muted: var(--muted);
  --panel-2: var(--card-2);
  --radius-md: var(--r-md);
  --surface: var(--card);
  --surface-2: var(--card-2);
  --border: var(--line);
  --ok: var(--green);
  --warn: var(--yellow);
  --bad: var(--red);

  /* semantic verdicts */
  --green: #3ddc97;
  --green-dim: rgba(61, 220, 151, 0.14);
  --yellow: #ffc857;
  --yellow-dim: rgba(255, 200, 87, 0.14);
  --red: #ff7d82; /* a11y: 4.7:1 on red-dim over card (was #ff6b70, 4.48) */
  --red-dim: rgba(255, 107, 112, 0.15);
  --on-green: #05261a; /* text on green fills (celebration badge) */

  /* accent + danger fills */
  --accent: #5b8cff;
  --accent-strong: #7aa4ff;
  --accent-dim: rgba(91, 140, 255, 0.16);
  --accent-deep: #3c6aec; /* a11y: 4.7:1 under white text (accent itself is 3.2) */
  --primary-grad: linear-gradient(180deg, #3c6aec, #3258c3); /* both stops ≥4.7:1 under --on-accent */
  --on-accent: #ffffff;
  --danger: #e5484d;
  --danger-hover: #f2555a;
  --on-danger: #ffffff;

  /* secondary hues for per-mode button identities */
  --teal: #2dd4bf;
  --teal-dim: rgba(45, 212, 191, 0.14);
  --violet: #a78bfa;
  --violet-dim: rgba(167, 139, 250, 0.16);
  --press-halo: rgba(122, 164, 255, 0.38); /* haptic pulse halo */

  /* a11y: light-theme palette below is the WCAG-AA set; the dark-theme
     values above were verified ≥4.5:1 for body text and ≥3:1 for large
     text/icons at adoption time. Any NEW color must be checked in BOTH
     themes before shipping (see docs/BLUEPRINT.md §12.4). */

  /* elevation */
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-2: 0 8px 28px rgba(0, 0, 0, 0.38);
  --shadow-3: 0 18px 50px rgba(0, 0, 0, 0.45);
  --ring: 0 0 0 2px var(--card), 0 0 0 4px var(--accent-strong); /* a11y: high-visibility keyboard focus */

  /* shape + rhythm */
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-pill: 999px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 36px;

  /* type */
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  /* display stack: rounded/friendly where the OS offers it, zero network */
  --font-display: ui-rounded, "SF Pro Rounded", "Segoe UI Variable Display", "Segoe UI",
    -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;
  --t-xs: 0.75rem;
  --t-sm: 0.84375rem;
  --t-md: 0.9375rem;
  --t-lg: 1.0625rem;
  --t-xl: 1.25rem;
  --t-hero: clamp(1.75rem, 1.3rem + 1.6vw, 2.375rem);
}

/* ── Tokens: light theme ─────────────────────────────────────────── */
html[data-theme="light"] {
  --bg: #f4f6fb;
  --bg-glow-1: rgba(91, 140, 255, 0.10);
  --bg-glow-2: rgba(52, 201, 142, 0.08);
  --card: #ffffff;
  --card-2: #f2f5fc;
  --line: #dde3f0;
  --line-strong: #c2cde4;

  --text: #1a2439;
  --muted: #5b6880;
  --faint: #5d6a83; /* a11y: ≥5.0:1 on white AND the page bg (was #66738d, 4.41 on page bg) */

  /* a11y: light-theme verdict hues darkened to ≥4.5:1 on white */
  --green: #0c7d5b;
  --green-dim: rgba(14, 159, 110, 0.12);
  --yellow: #8a5a10;
  --yellow-dim: rgba(183, 121, 31, 0.13);
  --red: #c03340;
  --red-dim: rgba(214, 69, 80, 0.11);

  --accent: #3b6ef6;
  --accent-strong: #2f5ce0;
  --accent-dim: rgba(59, 110, 246, 0.10);
  --accent-deep: #2c55d4; /* a11y: 6.2:1 under white text (accent itself is 4.4) */
  --primary-grad: linear-gradient(180deg, var(--accent-strong), var(--accent-deep)); /* both stops ≥5.1:1 */
  --on-accent: #ffffff;

  --teal: #0c7166; /* a11y: 5.9:1 on white (was #0d9488, 3.7:1) */
  --teal-dim: rgba(13, 148, 136, 0.10);
  --violet: #6d28d9; /* a11y: ≥4.5:1 on white/card-2 when used as text */
  --violet-dim: rgba(124, 58, 237, 0.10);
  --press-halo: rgba(91, 140, 255, 0.32); /* haptic pulse halo */
  --on-green: #ffffff; /* text on green fills */

  --shadow-1: 0 1px 2px rgba(23, 32, 61, 0.07);
  --shadow-2: 0 10px 30px rgba(23, 32, 61, 0.12);
  --shadow-3: 0 18px 50px rgba(23, 32, 61, 0.16);
  --ring: 0 0 0 2px var(--card), 0 0 0 4px var(--accent); /* a11y: high-visibility keyboard focus */
}

/* ── Text-size control (senior-friendly scaling) ─────────────────── */
html { font-size: 100%; }
html[data-text="large"] { font-size: 112.5%; }
html[data-text="larger"] { font-size: 125%; }

/* ── Base ────────────────────────────────────────────────────────── */
* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  background:
    radial-gradient(1100px 500px at 15% -5%, var(--bg-glow-1), transparent 60%),
    radial-gradient(900px 500px at 110% 15%, var(--bg-glow-2), transparent 55%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  line-height: 1.55;
  transition: background-color 0.25s ease, color 0.25s ease;
}

::selection { background: var(--accent-dim); }

/* a11y (WCAG 2.4.7/2.4.13): keyboard focus must be highly visible.
   Solid 2px outline + the layered --ring halo works on every surface.
   We style plain :focus as well as :focus-visible — Ania serves seniors
   and screen-reader users, for whom an always-visible focus indicator is
   a feature, not noise. */
:focus,
:focus-visible {
  outline: 2px solid var(--accent-strong);
  outline-offset: 2px;
  box-shadow: var(--ring);
  border-radius: var(--r-sm);
}
html[data-theme="light"] :focus,
html[data-theme="light"] :focus-visible { outline-color: var(--accent); }

/* Motion safety net (WCAG 2.3.3 / prefers-reduced-motion): every
   decorative animation and transition is disabled. Elements animated
   with "both"/"forwards" fill modes must also get visibility overrides
   so they never stay stuck at opacity:0 (e.g. staggered steps, verdict
   chip, celebration badge). app.js additionally checks this query
   before running JS-driven motion (smooth scroll, confetti, haptics). */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
  /* Fill-mode "both" freezes an element at its from{} frame (opacity 0)
     once the animation is disabled — force everything back visible. */
  *, *::before, *::after { opacity: 1 !important; transform: none !important; filter: none !important; }
}

.wrap { max-width: 760px; margin: 0 auto; padding: 0 var(--space-4) 88px; }

/* a11y: skip link — visually hidden until keyboard-focused (first Tab stop);
   lands on #main so keyboard/SR users bypass the tablist and controls. */
.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 1000;
  padding: var(--space-2) var(--space-4);
  background: var(--accent-deep);
  color: var(--on-accent);
  border-radius: 0 0 10px 0;
  font-weight: 700;
}
.skip:focus { left: 0; }

/* ── Top bar: brand + theme + text size ──────────────────────────── */
/* Floating glass header: a sticky pill that hovers above the page —
   pairs with the segmented tab control below it, no edge tricks needed. */
.topbar {
  position: sticky;
  top: var(--space-2);
  z-index: 45;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin: var(--space-2) 0 var(--space-4);
  padding: var(--space-2) var(--space-3);
  background: color-mix(in srgb, var(--card) 82%, transparent);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  box-shadow: var(--shadow-1);
}

.topbar .brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: var(--t-xl);
  letter-spacing: -0.01em;
}

.topbar .brand .mark {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border-radius: var(--r-sm);
  background: linear-gradient(135deg, var(--accent), var(--green));
  color: var(--on-accent);
  font-size: 19px;
  box-shadow: 0 2px 10px rgba(91, 140, 255, 0.35);
}

.controls { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; justify-content: flex-end; }

/* a11y: base .ctl / .save rules so every instance — even ones outside
   .controls/.wiz-nav/.famcard — gets a ≥36px touch target and styled
   focus ring; container variants only override colors. */
.ctl {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  background: var(--card);
  color: var(--muted);
  padding: var(--space-2) var(--space-3);
  min-height: 36px;
  font-size: var(--t-sm);
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.ctl:hover { border-color: var(--line-strong); color: var(--text); }

.save {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--card-2);
  color: var(--text);
  padding: var(--space-2) var(--space-3);
  min-height: 36px;
  font-size: var(--t-sm);
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.save:hover { border-color: var(--line-strong); }

.controls .ctl {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: var(--r-pill);
  padding: var(--space-2) var(--space-3);
  min-height: 36px; /* a11y: touch target */
  font-size: var(--t-sm);
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.controls .ctl:hover { border-color: var(--line-strong); color: var(--text); }
.controls .ctl .seg-current { color: var(--text); font-weight: 700; }

/* segmented text-size control */
.textsize {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  overflow: hidden;
  background: var(--card);
}

.textsize button {
  border: 0;
  background: none;
  color: var(--muted);
  font-family: inherit;
  font-size: var(--t-sm);
  padding: var(--space-2) var(--space-3);
  min-height: 36px; /* a11y: touch target */
  min-width: 40px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.textsize button + button { border-left: 1px solid var(--line); }
.textsize button:hover { color: var(--text); }
.textsize button.active { background: var(--accent-dim); color: var(--text); font-weight: 700; }

/* ── Header / hero ───────────────────────────────────────────────── */
header { text-align: center; padding: var(--space-6) 0 var(--space-2); }

h1 {
  font-family: var(--font-display);
  font-size: var(--t-hero);
  font-weight: 800;
  margin: 0 0 var(--space-2);
  letter-spacing: -0.02em;
  line-height: 1.12;
  text-wrap: balance;
  background: linear-gradient(100deg, var(--text) 55%, var(--accent-strong));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

html[data-theme="light"] h1 {
  background: linear-gradient(100deg, var(--text) 62%, var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
}

.tagline {
  color: var(--muted);
  margin: 0 auto var(--space-5);
  font-size: var(--t-lg);
  max-width: 42ch;
  text-wrap: balance;
}

/* ── Who switcher (with initials avatars) ────────────────────────── */
.who {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  justify-content: center;
  margin: 0 0 var(--space-5);
}

.who button {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  padding: var(--space-2) var(--space-3) var(--space-2) var(--space-2); /* a11y: ~38px target height */
  font-size: var(--t-md);
  font-family: inherit;
  cursor: pointer;
  box-shadow: var(--shadow-1);
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
}

.who button:hover { border-color: var(--line-strong); transform: translateY(-1px); }
.who button.active {
  border-color: var(--accent);
  background: var(--accent-dim);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.who-meta { display: flex; justify-content: center; margin: calc(-1 * var(--space-2)) 0 var(--space-4); }
.who-meta .ctl { background: none; }

/* ── Tab navigation: segmented control ───────────────────────────── */
.tabs {
  display: flex;
  gap: var(--space-1);
  justify-content: center;
  width: fit-content;
  margin: 0 auto var(--space-5);
  padding: var(--space-1);
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
}

.tabbtn {
  background: none;
  border: 1px solid transparent;
  color: var(--muted);
  border-radius: var(--r-pill);
  padding: var(--space-2) var(--space-4);
  font-size: var(--t-md);
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.tabbtn:hover { color: var(--text); }
.tabbtn.active {
  color: var(--text);
  background: var(--card);
  border-color: var(--line-strong);
  box-shadow: var(--shadow-1);
}

.tab { animation: fadeIn 0.18s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ── Staggered panel entrance (Family / Dashboard) ────────────────
   Applied by app.js (.panel-stagger) on tab switches — NOT on boot.
   Each section fades/rises in sequence, echoing the reply card's step
   stagger. No animation-name trickery on hidden elements: app.js only
   applies the class while the panel is visible. */
.tab > .panel-stagger {
  animation: panelIn 0.4s cubic-bezier(0.22, 1, 0.36, 1) both;
  animation-delay: calc(var(--i, 0) * 70ms);
}

@keyframes panelIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  font-size: var(--t-sm);
  font-weight: 800;
  color: var(--on-accent);
  background: linear-gradient(135deg, var(--accent-deep), var(--violet));
  flex: none;
}

.avatar.senior { background: linear-gradient(135deg, var(--teal), var(--green)); }
.avatar.adult { background: linear-gradient(135deg, var(--accent-deep), var(--violet)); }
/* a11y: initial letters on avatar fills must clear ~3:1 (bold large) in
   both themes — child uses red→violet because yellow's light-theme value
   is too pale under white text. */
.avatar.child { background: linear-gradient(135deg, var(--red), var(--violet)); }

/* ── Universal-input pitch + big four buttons ────────────────────── */
.universal {
  font-size: var(--t-lg);
  text-align: center;
  margin: 0 0 var(--space-4);
}

.universal b { color: var(--text); }

.bigbuttons {
  display: grid;
  gap: var(--space-3);
  grid-template-columns: 1fr 1fr;
}

@media (max-width: 560px) { .bigbuttons { grid-template-columns: 1fr; } }

.big {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  column-gap: var(--space-4);
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: linear-gradient(180deg, color-mix(in srgb, var(--card-2) 55%, var(--card)), var(--card));
  padding: var(--space-4);
  text-align: left;
  cursor: pointer;
  color: var(--text);
  font-family: inherit;
  box-shadow: var(--shadow-1);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease, background 0.15s ease;
}

.big:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-2);
  transform: translateY(-2px);
}

.big .emoji {
  grid-row: 1 / 3;
  width: 48px; height: 48px;
  display: grid; place-items: center;
  font-size: 1.5rem;
  border-radius: 14px;
  background: var(--accent-dim);
}

.big .label {
  font-family: var(--font-display);
  font-size: var(--t-xl);
  font-weight: 800;
  display: block;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.big .sub { color: var(--muted); font-size: var(--t-sm); line-height: 1.35; }

/* per-mode identities — each experience gets its own hue */
.big[data-mode="check"] .emoji { background: var(--accent-dim); }
.big[data-mode="support"] .emoji { background: var(--teal-dim); }
.big.danger .emoji { background: var(--red-dim); }
#btnFamily .emoji { background: var(--violet-dim); }

.big.active { border-color: var(--accent); background: var(--accent-dim); }
.big.danger {
  border-color: color-mix(in srgb, var(--red) 42%, var(--line));
}
.big.danger:hover { border-color: var(--red); }
.big.danger.active { border-color: var(--red); background: var(--red-dim); }

/* ── Composer ────────────────────────────────────────────────────── */
.composer { margin-top: var(--space-4); display: none; }
.composer.show { display: block; }

textarea {
  width: 100%;
  min-height: 104px;
  resize: vertical;
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: var(--space-4);
  font-size: var(--t-md);
  font-family: inherit;
  line-height: 1.5;
  box-shadow: var(--shadow-1);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

textarea:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: var(--ring);
}
textarea::placeholder { color: var(--faint); }

.hint { color: var(--muted); font-size: var(--t-sm); margin: var(--space-2) 2px var(--space-3); }

.sendrow { display: flex; gap: var(--space-2); align-items: stretch; }

.send {
  flex: 1;
  padding: var(--space-4);
  font-size: var(--t-lg);
  font-weight: 800;
  font-family: inherit;
  background: var(--primary-grad);
  color: var(--on-accent);
  border: 0;
  border-radius: var(--r-md);
  cursor: pointer;
  box-shadow: 0 2px 12px rgba(91, 140, 255, 0.3);
  transition: filter 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease, background 0.2s ease;
}

/* Containment mode: the primary action turns urgent (tone set by app.js) */
.send[data-tone="danger"] {
  background: linear-gradient(180deg, color-mix(in srgb, var(--red) 88%, #ffffff), var(--red));
  box-shadow: 0 2px 12px rgba(229, 72, 77, 0.35);
}

.send:hover {
  filter: brightness(1.07);
  box-shadow: 0 4px 18px rgba(91, 140, 255, 0.4);
  transform: translateY(-1px);
}
.send:active { transform: translateY(1px) scale(0.98); box-shadow: var(--shadow-1); }
.send:disabled { opacity: 0.6; cursor: default; transform: none; filter: none; }

/* ── Satisfying send response ─────────────────────────────────────────
   Three beats, driven by app.js classes (removed on animationend):
     .send-pressed   — the press itself: quick squash with a glow pulse
     .send-thinking  — while awaiting the verdict: a shimmer sweeps the
                       button under the "thinking" label
     .send-success   — on the reply: a springy bounce + burst glow
   Containment tone keeps its red glow via [data-tone="danger"]. */
.send.send-pressed {
  animation: sendSquash 0.28s cubic-bezier(0.2, 1.4, 0.4, 1);
}
@keyframes sendSquash {
  0%   { transform: scale(0.96); }
  55%  { transform: scale(1.02); }
  100% { transform: scale(1); }
}
.send.send-thinking {
  overflow: hidden;
  position: relative;
}
.send.send-thinking::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 30%, rgba(255, 255, 255, 0.35) 50%, transparent 70%);
  transform: translateX(-100%);
  animation: sendShimmer 1.1s ease-in-out infinite;
  pointer-events: none;
}
@keyframes sendShimmer {
  to { transform: translateX(100%); }
}
.send.send-success {
  animation: sendBounce 0.5s cubic-bezier(0.2, 1.4, 0.4, 1);
}
@keyframes sendBounce {
  0%   { transform: scale(0.94); box-shadow: 0 0 0 0 color-mix(in srgb, var(--verdict-glow, var(--accent)) 60%, transparent); }
  55%  { transform: scale(1.06); box-shadow: 0 0 0 10px color-mix(in srgb, var(--verdict-glow, var(--accent)) 0%, transparent); }
  100% { transform: scale(1); box-shadow: 0 2px 12px rgba(91, 140, 255, 0.3); }
}
.send[data-tone="danger"].send-success {
  animation-name: sendBounceDanger;
}
@keyframes sendBounceDanger {
  0%   { transform: scale(0.94); box-shadow: 0 0 0 0 rgba(229, 72, 77, 0.55); }
  55%  { transform: scale(1.06); box-shadow: 0 0 0 10px rgba(229, 72, 77, 0); }
  100% { transform: scale(1); box-shadow: 0 2px 12px rgba(229, 72, 77, 0.35); }
}

.micbtn {
  width: 54px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--card);
  color: var(--text);
  font-size: 20px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.micbtn:hover { border-color: var(--line-strong); }
.micbtn.listening { background: var(--red-dim); border-color: var(--red); }

.example {
  background: none;
  border: none;
  color: var(--accent-strong);
  cursor: pointer;
  font-size: var(--t-sm);
  font-family: inherit;
  padding: var(--space-2) var(--space-1); /* a11y: inline hit-area padding → ~36px target (layout unaffected) */
  min-height: 36px; /* a11y touch-target floor (§12.4) — padding alone measured 34px */
  text-decoration: underline;
  text-underline-offset: 3px;
}
html[data-theme="light"] .example { color: var(--accent-strong); } /* a11y: 5.6:1 for small underlined text */

/* ── Reply card ──────────────────────────────────────────────────── */
.reply {
  margin-top: var(--space-4);
  display: none;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--space-5);
  background: linear-gradient(180deg, color-mix(in srgb, var(--card-2) 45%, var(--card)), var(--card));
  box-shadow: var(--shadow-2);
}

.reply.show { display: block; animation: replyIn 0.22s ease; }
@keyframes replyIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Animated verdict reveal ─────────────────────────────────────────
   The card fades in as before, then the verdict chip scales in with a
   spring pop and a matching glow ring, so the verdict — the moment the
   whole product exists for — lands with a little ceremony. app.js adds
   .verdict-new on every fresh check (not on restored plans). */
.chip.verdict-new {
  animation: verdictPop 0.5s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}
@keyframes verdictPop {
  0%   { opacity: 0; transform: scale(0.4) rotate(-8deg); }
  60%  { opacity: 1; transform: scale(1.15) rotate(2deg); }
  100% { opacity: 1; transform: scale(1) rotate(0deg); }
}
.chip.verdict-new::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: inherit;
  border: 2px solid currentColor;
  opacity: 0;
  animation: verdictRing 0.7s ease-out 0.18s;
  pointer-events: none;
}
@keyframes verdictRing {
  0%   { opacity: 0.7; transform: scale(0.9); }
  100% { opacity: 0;   transform: scale(1.5); }
}
.chip.verdict-new.ok   { --verdict-glow: var(--green); }
.chip.verdict-new.warn { --verdict-glow: var(--yellow); }
.chip.verdict-new.bad  { --verdict-glow: var(--red); }
.chip.verdict-new { box-shadow: 0 0 18px color-mix(in srgb, var(--verdict-glow, var(--accent)) 45%, transparent); }
.reply.containment { border-color: color-mix(in srgb, var(--red) 55%, transparent); }

.reply .headline {
  font-family: var(--font-display);
  font-size: var(--t-xl);
  font-weight: 800;
  margin-bottom: var(--space-2);
  white-space: pre-wrap;
  letter-spacing: -0.01em;
  line-height: 1.3;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--accent-dim);
  color: var(--accent-strong);
  border: 1px solid var(--accent);
  border-radius: var(--r-pill);
  padding: var(--space-1) var(--space-3);
  font-size: var(--t-xs);
  font-weight: 700;
  margin-bottom: var(--space-2);
}

/* Device-context badge doubles as a link to the member's profile drawer. */
.badge.clickable {
  cursor: pointer;
}
.badge.clickable:hover {
  filter: brightness(1.08);
  border-style: solid;
  box-shadow: 0 0 0 3px var(--accent-dim);
}
.badge.clickable:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.reply .body { font-size: var(--t-md); white-space: pre-wrap; line-height: 1.65; }

/* Ordered action steps: numbered tiles instead of bare bullets.
   Scoped to #replyActions so the checklist's .check-step rows keep
   their own checkbox styling. */
#replyActions {
  list-style: none;
  margin: var(--space-4) 0 0;
  padding: 0;
  counter-reset: step;
}

/* ── Staggered step entrance ──────────────────────────────────────
   Applied only to freshly-rendered steps (renderReplyActions adds
   .stagger); restored plans render fully visible with no animation. */
#replyActions.stagger li {
  animation: stepIn 0.42s cubic-bezier(0.22, 1, 0.36, 1) both;
  animation-delay: calc(var(--i, 0) * 90ms);
}

@keyframes stepIn {
  from { opacity: 0; transform: translateY(7px); filter: blur(2px); }
  60%  { filter: blur(0); }
  to   { opacity: 1; transform: translateY(0); filter: blur(0); }
}

#replyActions li {
  counter-increment: step;
  position: relative;
  margin-bottom: var(--space-2);
  font-size: var(--t-md);
  line-height: 1.55;
  padding: var(--space-3) var(--space-3) var(--space-3) 52px;
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
}
#replyActions li::before {
  content: counter(step);
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 26px; height: 26px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--accent-dim);
  color: var(--accent-strong);
  font-size: var(--t-sm);
  font-weight: 800;
}
.reply.containment #replyActions li::before { background: var(--red-dim); color: var(--red); }

.meta { color: var(--muted); font-size: var(--t-xs); margin-top: var(--space-3); }

.feedback { margin-top: var(--space-3); display: flex; gap: var(--space-2); align-items: center; }

.feedback button {
  background: none;
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: var(--r-sm);
  padding: var(--space-2) var(--space-3);
  min-height: 36px; /* a11y: touch target */
  cursor: pointer;
  font-size: var(--t-sm);
  font-family: inherit;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.feedback button:hover { border-color: var(--line-strong); color: var(--text); }
.feedback button.chosen { color: var(--text); border-color: var(--accent); background: var(--accent-dim); }

.lesson-offer {
  margin-top: var(--space-4);
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-md);
  padding: var(--space-3) var(--space-4);
  background: var(--card-2);
}

.lesson-offer .want { font-size: var(--t-md); margin: 0 0 var(--space-2); }

.lesson-offer button {
  background: var(--card);
  color: var(--accent-strong);
  border: 1px solid var(--accent);
  border-radius: var(--r-sm);
  padding: var(--space-2) var(--space-4);
  cursor: pointer;
  font-size: var(--t-sm);
  font-family: inherit;
  font-weight: 700;
  transition: background 0.15s ease;
}
html[data-theme="light"] .lesson-offer button { color: var(--accent); }
.lesson-offer button:hover { background: var(--accent-dim); }

.lesson-offer pre {
  white-space: pre-wrap;
  font-family: inherit;
  font-size: var(--t-md);
  margin: 0;
  line-height: 1.6;
}

/* verdict chips injected by app.js in headlines */
.chip {
  display: inline-block;
  position: relative;
  padding: 2px var(--space-3);
  border-radius: var(--r-pill);
  font-size: var(--t-xs);
  font-weight: 800;
  letter-spacing: 0.02em;
  vertical-align: 2px;
  border: 1px solid transparent;
}
.chip.ok   { background: var(--green-dim); color: var(--green); border-color: color-mix(in srgb, var(--green) 45%, transparent); }
.chip.warn { background: var(--yellow-dim); color: var(--yellow); border-color: color-mix(in srgb, var(--yellow) 45%, transparent); }
.chip.bad  { background: var(--red-dim); color: var(--red); border-color: color-mix(in srgb, var(--red) 45%, transparent); }

/* ── Panels + list items ─────────────────────────────────────────── */
section.panel { margin-top: var(--space-6); }

/* Collapsed activity log (dashboard) — a quiet one-line disclosure, not a
   wall of entries. Focus ring follows the theme tokens. */
details.logfold {
  margin-top: var(--space-6);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  overflow: hidden;
}
details.logfold > summary {
  cursor: pointer;
  list-style: none;
  padding: var(--space-3) var(--space-4);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  user-select: none;
}
details.logfold > summary::-webkit-details-marker { display: none; }
details.logfold > summary::after {
  content: "▸";
  margin-left: auto;
  transition: transform 0.15s ease;
  color: var(--text-muted);
}
details.logfold[open] > summary::after { transform: rotate(90deg); }
details.logfold > summary:hover { background: var(--surface-2); }
details.logfold > summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
details.logfold .logfold-hint {
  font-weight: 400;
  font-size: var(--t-sm);
  color: var(--text-muted);
}
details.logfold > #recent { padding: var(--space-1) var(--space-4) var(--space-3); }

section.panel h2 {
  font-family: var(--font-display);
  font-size: var(--t-xl);
  margin: 0 0 var(--space-3);
  letter-spacing: -0.01em;
}

.item {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-2);
  background: var(--card);
  font-size: var(--t-md);
  box-shadow: var(--shadow-1);
  transition: border-color 0.15s ease;
}

.item:hover { border-color: var(--line-strong); }
.item .row1 { display: flex; justify-content: space-between; gap: var(--space-2); }
.item .when { color: var(--muted); font-size: var(--t-xs); white-space: nowrap; }

.dot-ok { color: var(--green); }
.dot-warn { color: var(--yellow); }
.dot-bad { color: var(--red); }
.muted { color: var(--muted); }

.alert {
  border-left: 4px solid var(--red);
  background: linear-gradient(90deg, var(--red-dim), var(--card) 30%);
}
.alert .did { margin: var(--space-2) 0 0; color: var(--muted); font-size: var(--t-sm); }
.incident { border-left: 4px solid var(--red); }

/* ── Metrics ─────────────────────────────────────────────────────── */
.metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-2); }

@media (max-width: 560px) { .metrics { grid-template-columns: repeat(2, 1fr); } }

.metric {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: var(--space-3);
  background: var(--card);
  text-align: center;
  box-shadow: var(--shadow-1);
  transition: border-color 0.15s ease, transform 0.1s ease;
}

.metric:hover { border-color: var(--line-strong); transform: translateY(-1px); }
.metric b {
  display: block;
  font-size: 1.375rem;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}
.metric span { color: var(--muted); font-size: var(--t-xs); }

.rules ol { color: var(--muted); font-size: var(--t-sm); margin: 0; padding-left: 20px; }
.rules li { margin-bottom: var(--space-1); }

footer {
  margin-top: var(--space-6);
  text-align: center;
  color: var(--faint);
  font-size: var(--t-xs);
}

/* ── Guardian banner ─────────────────────────────────────────────── */
.guardian-banner {
  position: relative;
  background: linear-gradient(90deg, var(--red-dim), transparent 65%), var(--card);
  border: 1px solid var(--red);
  border-left-width: 4px;
  color: var(--text);
  border-radius: var(--r-md);
  padding: var(--space-3) var(--space-4) var(--space-3) var(--space-4);
  margin-bottom: var(--space-5);
  font-size: var(--t-md);
  display: none;
  box-shadow: var(--shadow-1);
}
.guardian-banner.show { display: block; animation: replyIn 0.22s ease; }

/* Photo-based guardian alerts: thumbnail of what the member sent
   (dashboard-only context — the SMS channel never carries it). */
.guardian-banner.show:has(.alert-thumb),
.item.alert:has(.alert-thumb) {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
}
.alert-thumb {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: var(--r-sm);
  border: 1px solid var(--red);
  background: #fff;
  flex: 0 0 auto;
}
.alert-thumb-sm { width: 44px; height: 44px; border-color: var(--line-strong); }
/* Placeholder where a purged thumbnail used to be (handled alerts keep
   the fact of the screenshot, never the image itself). */
.thumb-purged {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  background: var(--card-2);
  border-style: dashed;
}
/* Incident cards share the alert thumbnail layout (same lifecycle:
   visible while open, purged placeholder once resolved). */
.item.incident:has(.alert-thumb) {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
}
.incident-body { flex: 1; min-width: 0; }
.alert-body { flex: 1; min-width: 0; }
.alert-thumb:focus-visible {
  outline: 2px solid var(--accent-strong);
  outline-offset: 2px;
}

/* ── Lightbox: the guardian inspects the screenshot full-size ─────── */
.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(4, 8, 18, 0.88);
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-5);
  touch-action: none; /* gestures belong to the lightbox, not the page */
  cursor: grab;
}
.lightbox.dragging { cursor: grabbing; }
.lightbox-img {
  max-width: min(92vw, 900px);
  max-height: 66vh;
  object-fit: contain;
  border-radius: var(--r-md);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-1);
  background: #fff;
  transform-origin: center center;
  will-change: transform;
  user-select: none;
  -webkit-user-drag: none;
}
.lightbox-controls {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.lightbox-controls button {
  min-width: 36px;
  height: 36px;
  padding: 0 var(--space-3);
  border-radius: var(--r-sm);
  border: 1px solid var(--line-strong);
  background: var(--card);
  color: var(--text);
  font-size: var(--t-md);
  cursor: pointer;
}
.lightbox-controls button:hover { border-color: var(--accent); }
.lightbox-controls button:focus-visible {
  outline: 2px solid var(--accent-strong);
  outline-offset: 2px;
}
.lb-zoom-pct {
  color: var(--muted);
  font-size: var(--t-sm);
  min-width: 48px;
  text-align: center;
}
.lightbox-cap {
  color: var(--muted);
  font-size: var(--t-sm);
  max-width: min(92vw, 700px);
  text-align: center;
}
.lightbox-close {
  position: absolute;
  top: var(--space-4);
  right: var(--space-4);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: var(--card);
  color: var(--text);
  font-size: var(--t-md);
  cursor: pointer;
}
.lightbox-close:hover { border-color: var(--red); }
.lightbox-close:focus-visible {
  outline: 2px solid var(--accent-strong);
  outline-offset: 2px;
}

/* ── Family panel ────────────────────────────────────────────────── */
.famgrid { display: grid; gap: var(--space-2); }

/* Read-only share level (non-guardian family view) */
.sharelevel-hint {
  font-size: var(--t-sm);
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-pill);
  padding: var(--space-1) var(--space-3);
  white-space: nowrap;
}

.famcard {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--card);
  padding: var(--space-3) var(--space-4);
  font-size: var(--t-md);
  box-shadow: var(--shadow-1);
  transition: border-color 0.15s ease;
}

.famcard:hover { border-color: var(--line-strong); }

.famcard .row1 {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

/* Name ↔ share level spreads (the daily control, always visible); the
   once-a-setup rows (phone/Save/Profile/Delete, toggles) live inside the
   fam-manage disclosure and cluster left — space-between across a 660px
   card reads sparse. */
.famcard > .row1 { justify-content: space-between; }
.fam-manage .row1 { justify-content: flex-start; }

/* The disclosure itself: one calm row, chevron shows where it opens. */
.fam-manage {
  margin-top: var(--space-2);
  border-top: 1px solid var(--line);
}
.fam-manage summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  min-height: 36px; /* a11y touch-target floor (§12.4) */
  padding: var(--space-1) 0;
  color: var(--muted);
  font-size: var(--t-sm);
  cursor: pointer;
  list-style: none;
}
.fam-manage summary::-webkit-details-marker { display: none; }
.fam-manage summary::after {
  content: "▾";
  color: var(--muted);
  transition: transform 0.15s ease;
}
.fam-manage[open] summary::after { transform: rotate(180deg); }
.fam-manage[open] summary,
.fam-manage summary:hover { color: var(--text); }
.fam-manage .saved:empty { display: none; }
/* Belt-and-braces for leaky webviews: some engines let author display rules
   on children defeat the closed-details slot. Harmless where correct. */
.fam-manage:not([open]) > *:not(summary) { display: none; }

.famcard select {
  background: var(--card-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  /* a11y: ≥36px touch target */
  padding: var(--space-2);
  font-size: var(--t-sm);
  font-family: inherit;
}

.famcard .phone {
  width: 150px;
  background: var(--card-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  /* a11y: ≥36px touch target */
  padding: var(--space-2);
  font-size: var(--t-sm);
  font-family: inherit;
}

.famcard .phone:focus, .famcard select:focus { border-color: var(--accent); outline: none; }

.famcard .save {
  background: none;
  border: 1px solid var(--accent);
  color: var(--accent-strong);
  border-radius: var(--r-sm);
  padding: var(--space-2) var(--space-3);
  min-height: 36px; /* a11y: touch target */
  font-size: var(--t-sm);
  font-family: inherit;
  cursor: pointer;
}
html[data-theme="light"] .famcard .save { color: var(--accent); }
.famcard .save:hover { background: var(--accent-dim); }

.famcard .save.danger { border-color: var(--red); color: var(--red); }
.famcard .save.danger:hover { background: var(--red-dim); }

.danger-btn {
  background: var(--red-dim);
  color: var(--red);
  border: 1px solid var(--red);
  border-radius: var(--r-sm);
  padding: var(--space-2) var(--space-3);
  font-size: var(--t-md);
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
}
.danger-btn:hover { filter: brightness(1.06); }

.famcard .saved { color: var(--green); font-size: var(--t-xs); }

.addrow { display: flex; gap: var(--space-2); flex-wrap: wrap; margin-top: var(--space-1); }

.addrow input, .addrow select {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: var(--space-2) var(--space-3);
  font-size: var(--t-md);
  font-family: inherit;
}

/* Shared field styling — wizard bank select, profile/household inputs,
   guardian select. Previously unstyled (native selects rendered ~19px,
   far under the touch floor). Token-styled to match .addrow. */
.field {
  display: block;
  width: 100%;
  min-height: 36px; /* a11y touch-target floor (§12.4) */
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: var(--space-2) var(--space-3);
  font-size: var(--t-md);
  font-family: inherit;
}
.field:focus { border-color: var(--accent); outline: none; }

.addrow input:focus, .addrow select:focus { border-color: var(--accent); outline: none; }

.addrow button {
  background: var(--accent-deep);
  color: var(--on-accent);
  border: 0;
  border-radius: var(--r-sm);
  padding: var(--space-2) var(--space-4);
  font-size: var(--t-md);
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: filter 0.15s ease;
}
.addrow button:hover { filter: brightness(1.08); }

/* ── Avatar sizes ────────────────────────────────────────────────── */
.avatar.sm { width: 22px; height: 22px; font-size: 11px; vertical-align: -4px; }
.avatar.lg { width: 56px; height: 56px; font-size: 26px; }

/* ── Family tech map ─────────────────────────────────────────────── */
.techmap {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: var(--space-3);
}

.techperson {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--card);
  padding: var(--space-3) var(--space-4);
  box-shadow: var(--shadow-1);
}

.techperson-head {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-2);
}

.techperson-name { font-size: var(--t-md); }
.techperson-name .muted { font-size: var(--t-sm); }

.techperson-devices {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

/* ── Profile modal ───────────────────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 60;
  padding: var(--space-4);
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3, 6, 16, 0.6);
  backdrop-filter: blur(3px);
}

.modal-card {
  position: relative;
  width: 100%;
  max-width: 560px;
  max-height: 86vh;
  overflow: auto;
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-3);
  padding: var(--space-5);
  animation: replyIn 0.2s ease;
}

.profile-head { display: flex; gap: var(--space-3); align-items: center; }
.profile-head .avatar.lg { cursor: pointer; }

.profile-title { flex: 1; }
.profile-title .field {
  width: 100%;
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: var(--space-2);
  font-size: var(--t-lg);
  font-weight: 700;
  font-family: inherit;
}
.profile-title .field:focus { border-color: var(--accent); outline: none; }
.profile-title .muted { font-size: var(--t-sm); }

.profile-avatars { display: flex; gap: var(--space-2); flex-wrap: wrap; margin: var(--space-4) 0 var(--space-2); }

.avatarpick {
  width: 38px;
  height: 38px;
  font-size: 20px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--card);
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.12s ease, background 0.12s ease, transform 0.1s ease;
}
.avatarpick:hover { border-color: var(--line-strong); transform: translateY(-1px); }
.avatarpick.active { border-color: var(--accent); background: var(--accent-dim); }

.profile-sec { margin-top: var(--space-4); }
.profile-sec h3 { font-size: var(--t-md); margin: 0 0 var(--space-2); }

.devices { display: flex; gap: var(--space-2); flex-wrap: wrap; margin-bottom: var(--space-2); }

.device-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  padding: var(--space-1) var(--space-2);
  font-size: var(--t-sm);
}

/* The chip label is a button: tap it to start that device's support flow. */
.device-chip .dev-start {
  border: 0;
  background: none;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  padding: 0 var(--space-1) 0 var(--space-2);
}
.device-chip .dev-start:hover { text-decoration: underline; color: var(--accent-strong); }
.device-chip .dev-start:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.device-chip .dev-x {
  border: 0;
  background: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  width: 28px; /* a11y: ≥24px minimum target */
  height: 28px;
  display: grid;
  place-items: center;
  padding: 0;
}
.device-chip .dev-x:hover { color: var(--red); }

.hist-item {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--line);
  font-size: var(--t-sm);
}
.hist-item:last-child { border-bottom: 0; }
.hist-dot { width: 1em; flex: none; }
.hist-text { flex: 1; }

.profile-actions { margin-top: var(--space-4); display: flex; justify-content: flex-end; }

/* ── 🚨 Containment wizard ─────────────────────────────────────────
   This is the one screen for a PANICKED user. Visual intent: the red
   "I Messed Up" button gets them here (urgency is useful for finding
   help), but everything inside is deliberately calm — soft teal instead
   of alarm-red, a breathing indicator, gentle motion, reassuring copy.
   Once a plan exists (reply card), urgency colors return for the
   time-critical steps themselves. */
.wizard {
  display: none;
  border: 1px solid color-mix(in srgb, var(--teal) 45%, transparent);
  border-radius: var(--r-lg);
  background:
    radial-gradient(120% 90% at 50% 0%, color-mix(in srgb, var(--teal-dim) 55%, transparent), transparent 70%),
    var(--card);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18), 0 0 0 1px color-mix(in srgb, var(--teal) 12%, transparent);
  padding: var(--space-4) var(--space-5);
  margin-top: var(--space-4);
  animation: wizardIn 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes wizardIn {
  from { opacity: 0; transform: translateY(14px) scale(0.985); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* The breathing cue: a slow 4-second in/out rhythm around ~6 breaths/min —
   the rate panic-attack breathing exercises actually coach. */
.wiz-calm {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  background: color-mix(in srgb, var(--teal-dim) 70%, transparent);
  border: 1px solid color-mix(in srgb, var(--teal) 25%, transparent);
  border-radius: var(--r-md);
  padding: var(--space-3) var(--space-4);
  font-size: var(--t-md);
  margin-bottom: var(--space-4);
  text-align: left;
  line-height: 1.55;
}

.wiz-breathe {
  width: 14px;
  height: 14px;
  flex: none;
  border-radius: 50%;
  background: var(--teal);
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--teal) 45%, transparent);
  animation: breathe 4s ease-in-out infinite;
}

@keyframes breathe {
  0%, 100% { transform: scale(0.8);  box-shadow: 0 0 0 0     color-mix(in srgb, var(--teal) 40%, transparent); }
  50%      { transform: scale(1.15); box-shadow: 0 0 0 9px  color-mix(in srgb, var(--teal) 0%,  transparent); }
}

/* Step dots: calm progress indicator — "you're moving forward" (driven by
   data-step on #wizard, set by wizardGotoStep). */
.wiz-dots { display: flex; align-items: center; justify-content: center; gap: var(--space-2); margin: 0 0 var(--space-4); }

.wiz-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--r-pill);
  background: var(--line-strong);
  opacity: 0.55;
  transition: width 0.35s cubic-bezier(0.22, 1, 0.36, 1), background 0.3s ease, opacity 0.3s ease;
}

.wiz-dot.on {
  width: 22px;
  background: var(--teal);
  opacity: 1;
}

/* .done dot keeps the calm teal, unlike the reply card's red urgency */
.wiz-dot.done { background: var(--teal); opacity: 0.45; }

.wiz-step[style*="block"] { animation: wizardStepIn 0.35s cubic-bezier(0.22, 1, 0.36, 1); }

@keyframes wizardStepIn {
  from { opacity: 0; transform: translateX(10px); }
  to   { opacity: 1; transform: translateX(0); }
}

.wiz-step h2 { margin: 0 0 var(--space-2); font-size: var(--t-lg); font-family: var(--font-display); }

.wiz-opts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2);
  margin-top: var(--space-3);
}

.wiz-opt {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  background: var(--card-2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: var(--r-md);
  padding: var(--space-3) var(--space-4);
  font-size: var(--t-md);
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease, transform 0.1s ease;
}

.wiz-opt:hover { border-color: var(--line-strong); transform: translateY(-1px); }

/* Calm interaction model: picked options glow teal, not red — selection
   is progress, not another alarm. */
.wiz-opt.picked {
  border-color: var(--teal);
  background: color-mix(in srgb, var(--teal-dim) 80%, transparent);
  box-shadow: inset 0 0 0 1px var(--teal);
}

.wiz-opt .wiz-ico { font-size: 1.25rem; flex: none; }

.wiz-nav { display: flex; gap: var(--space-2); margin-top: var(--space-4); justify-content: flex-end; align-items: center; }
/* .send's flex:1 is for the composer sendrow (stretch beside the input);
   in a wizard nav it ballooned Continue to ~615px. Natural width here. */
.wiz-nav .send { flex: 0 0 auto; }

.wiz-nav .save { background: var(--card-2); }

.wiz-chips { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-3); }

.wiz-chip {
  background: color-mix(in srgb, var(--teal-dim) 80%, transparent);
  border: 1px solid color-mix(in srgb, var(--teal) 40%, transparent);
  color: var(--text);
  border-radius: var(--r-pill);
  padding: var(--space-1) var(--space-3);
  font-size: var(--t-sm);
}

.wiz-escape { text-align: center; color: var(--muted); font-size: var(--t-sm); margin: var(--space-4) 0 0; }

/* The final submit is the one place urgency is allowed to remain — it
   summons the recovery plan. Slightly softened so it doesn't shout. */
.wizard .send[data-tone="danger"] {
  background: linear-gradient(180deg, color-mix(in srgb, var(--red) 72%, #ffffff), var(--red));
  box-shadow: 0 2px 12px rgba(229, 72, 77, 0.28);
}

/* Interactive recovery checklist */
#replyChecklist { margin-top: var(--space-4); position: relative; }

/* ── Checklist completion celebration ────────────────────────────
   Triggered by app.js ONLY on a real transition to 100% (ticking the
   final step, or Mark-all-done) — never when an already-complete plan
   is restored on reload. One confetti burst + a warm banner that then
   settles into a persistent, quieter "done" state. */
.check-celebrate {
  position: relative;
  margin-top: var(--space-4);
  border: 1px solid color-mix(in srgb, var(--green) 45%, transparent);
  background: linear-gradient(180deg, color-mix(in srgb, var(--green-dim) 85%, transparent), transparent 130%),
    var(--card);
  border-radius: var(--r-lg);
  padding: var(--space-4) var(--space-5);
  overflow: hidden;
  animation: celebrateIn 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes celebrateIn {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.check-celebrate .celebrate-head {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin: 0 0 var(--space-1);
  font-family: var(--font-display);
  font-size: var(--t-lg);
  font-weight: 800;
}

.check-celebrate .celebrate-sub {
  color: var(--text-muted);
  font-size: var(--t-sm);
  line-height: 1.55;
  margin: 0;
}

.check-celebrate .celebrate-done {
  position: absolute;
  top: var(--space-3);
  right: var(--space-4);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--green);
  color: var(--on-green);
  display: grid;
  place-items: center;
  font-size: 19px;
  font-weight: 900;
  box-shadow: 0 2px 10px color-mix(in srgb, var(--green) 45%, transparent);
  animation: celebrateCheckPop 0.55s cubic-bezier(0.2, 1.5, 0.4, 1) 0.15s both;
}

@keyframes celebrateCheckPop {
  from { opacity: 0; transform: scale(0.3) rotate(-25deg); }
  to   { opacity: 1; transform: scale(1) rotate(0); }
}

/* The one-shot burst: paper scraps falling through the banner. */
.celebrate-confetti {
  position: absolute;
  top: -10px;
  width: 7px;
  height: 11px;
  border-radius: 2px;
  opacity: 0;
  animation: confettiFall 1.7s cubic-bezier(0.15, 0.6, 0.4, 1) forwards;
  pointer-events: none;
}

@keyframes confettiFall {
  0%   { opacity: 1; transform: translate3d(0, 0, 0) rotate(0deg); }
  80%  { opacity: 1; }
  100% { opacity: 0; transform: translate3d(var(--drift, 0px), 210px, 0) rotate(var(--spin, 540deg)); }
}

/* Settled state: burst finished, banner stays as a quiet badge of honor. */
.check-celebrate.settled { animation: none; }
.check-celebrate.settled .celebrate-done { animation: none; }

/* Progress ring — a conic-gradient dial showing checklist completion.
   --pct is set inline by app.js (0–100); the ::after sweeps as it changes. */
.check-progress {
  position: absolute;
  top: -6px;
  right: -2px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background:
    conic-gradient(var(--green) calc(var(--pct, 0) * 1%), transparent 0),
    color-mix(in srgb, var(--line-strong) 30%, var(--card-2));
  display: grid;
  place-items: center;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
}
.check-progress::before {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  background: var(--card);
}
.check-progress .check-progress-label {
  position: relative;
  font-size: 11px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--green);
}
.check-progress .check-progress-label::after { content: "%"; font-size: 8px; font-weight: 700; }
.check-progress.full .check-progress-label { animation: progressDonePop 0.45s cubic-bezier(0.2, 1.4, 0.4, 1); }
.check-progress.full::before { background: var(--green-dim); }
@keyframes progressDonePop {
  0%   { transform: scale(0.6); }
  60%  { transform: scale(1.25); }
  100% { transform: scale(1); }
}
.check-progress {
  transition: background 0.3s ease;
}
@media (max-width: 640px) { .check-progress { width: 38px; height: 38px; top: -4px; right: 0; } }

#replyChecklist h2 { margin: 0 0 var(--space-2); font-size: var(--t-md); }

#replyChecklist ol { list-style: none; margin: 0; padding: 0; }

.check-step {
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: var(--space-3);
  margin-bottom: var(--space-2);
  cursor: pointer;
  background: var(--card-2);
  transition: opacity 0.15s ease, border-color 0.15s ease;
}

.check-step::before { content: "☐"; font-size: var(--t-lg); flex: none; line-height: 1.3; }
.check-step:hover { border-color: var(--line-strong); }
.check-step { transition: opacity 0.15s ease, border-color 0.15s ease, background 0.2s ease, transform 0.1s ease; }
.check-step:active { transform: scale(0.985); }
/* The step text is a real checkbox button (a11y): strip the browser chrome
   so the li keeps its look, and hold the 36px touch floor on single-line
   steps. Keyboard focus rings come from the global :focus-visible rule. */
.check-step .check-line {
  appearance: none;
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  flex: 1;
  min-height: 36px;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
}
.check-step.done { opacity: 0.55; border-color: var(--green); background: color-mix(in srgb, var(--green-dim) 50%, var(--card-2)); }
.check-step.done::before { content: "☑"; color: var(--green); }
.check-step.done .check-line { text-decoration: line-through; }
.check-line { flex: 1; font-size: var(--t-md); }

@media (max-width: 640px) {
  .wiz-opts { grid-template-columns: 1fr; }
  .wizard { padding: var(--space-3) var(--space-4); }
}

/* a11y: visually hidden but screen-reader-visible (live regions,
   text equivalents of decorative indicators). */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ── Scrollbar (subtle, webkit) ──────────────────────────────────── */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: var(--r-pill); }
::-webkit-scrollbar-track { background: transparent; }

/* ── Haptic-style button feedback (desktop + mobile) ───────────────
   A light press pulse on every primary action: the control dips and a
   quick halo blooms and releases around it, standing in for physical
   key travel. app.js taps .btn-tap onto the pressed element on
   pointerdown (and asks the phone for a real ~8ms vibration where the
   Vibration API exists). #send is excluded — it has its own richer
   three-beat response. The halo rides on `outline` so it never
   clobbers a button's own box-shadow glow. */
.tabbtn, .mnav-btn, .big, .wiz-opt, .feedback button, .survey-opts button,
.survey-actions button, .ctl, .save, .avatarpick, .who button, .micbtn,
.check-step, .textsize button {
  -webkit-tap-highlight-color: transparent; /* our pulse replaces the gray flash */
  touch-action: manipulation; /* no double-tap-zoom lag on rapid taps */
  user-select: none;
}

.btn-tap { animation: tapPulse 0.32s cubic-bezier(0.2, 0.9, 0.3, 1); }

@keyframes tapPulse {
  0%   { transform: scale(0.97); outline: 0px solid var(--press-halo); outline-offset: 1px; }
  45%  { transform: scale(1.012); outline: 5px solid var(--press-halo); outline-offset: 0px; }
  100% { transform: scale(1); outline: 0px solid transparent; outline-offset: 0px; }
}

/* ═══════════════════════════════════════════════════════════════════
   Mobile: app-like fixed bottom tab bar + responsive layouts.
   The desktop .tabs bar stays for ≥641px; phones get an iOS-style
   bottom nav with translucent blur, safe-area padding, and compact
   per-tab layouts.
   ═══════════════════════════════════════════════════════════════════ */
.mobilenav {
  display: none;
}

@media (max-width: 640px) {
  /* Desktop tab bar → hidden; the bottom bar takes over. */
  .tabs { display: none; }

  /* Fixed bottom nav, above everything except modals. */
  .mobilenav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 50;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    background: color-mix(in srgb, var(--card) 88%, transparent);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
    border-top: 1px solid var(--line);
    /* Full-width edge-to-edge content: cancel .wrap's side padding and
       use the safe-area inset for notched phones instead. */
    padding: var(--space-2) max(env(safe-area-inset-left), var(--space-2)) calc(var(--space-2) + env(safe-area-inset-bottom));
    box-shadow: 0 -8px 28px rgba(0, 0, 0, 0.25);
  }

  .mnav-btn {
    background: none;
    border: 0;
    color: var(--faint);
    font-family: inherit;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    /* a11y: 8/8 vertical keeps the stacked icon+label control ≥36px */
    padding: var(--space-2) var(--space-1);
    border-radius: var(--r-md);
    transition: color 0.15s ease, background 0.15s ease;
    -webkit-tap-highlight-color: transparent;
  }

  .mnav-btn:active { background: var(--accent-dim); }

  .mnav-btn .mnav-icon { font-size: 22px; line-height: 1.2; }

  .mnav-btn .mnav-label {
    font-size: var(--t-xs);
    font-weight: 700;
    letter-spacing: 0.01em;
  }

  .mnav-btn.active { color: var(--accent-strong); }

  /* Breathing room so content never hides behind the fixed bar. */
  .wrap { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }

  /* Floating glass header: brand row on top, controls as a full-width
     wrapped row below — nothing orphaned, nothing clipped. */
  .topbar {
    top: var(--space-1);
    padding: var(--space-2);
    flex-wrap: wrap;
    justify-content: center;
    row-gap: var(--space-2);
  }
  .topbar .brand { font-size: var(--t-lg); width: 100%; justify-content: center; }
  .topbar .brand .mark { width: 30px; height: 30px; font-size: 16px; }
  .controls { width: 100%; justify-content: center; }

  /* Hero + context stack tighter on a phone. */
  header { padding-top: var(--space-4); }
  h1 { font-size: 1.5rem; }
  .tagline { font-size: var(--t-md); margin-bottom: var(--space-4); }
  .who { gap: var(--space-2); margin-bottom: var(--space-3); }
  .who button { font-size: var(--t-sm); padding: var(--space-2) var(--space-3) var(--space-2) var(--space-2); } /* a11y: 22px avatar + 2×8px = ~38px target */
  .who button .avatar { width: 22px; height: 22px; font-size: 11px; }
  .who-meta { margin-bottom: var(--space-3); }
  .guardian-banner { margin-bottom: var(--space-4); font-size: var(--t-sm); }

  /* Cards feel like list rows: tighter padding, less shadow noise. */
  .big { padding: var(--space-3); column-gap: var(--space-3); }
  .big .emoji { width: 42px; height: 42px; font-size: 1.25rem; border-radius: var(--r-sm); }
  .big .label { font-size: var(--t-lg); }

  .composer textarea { min-height: 88px; font-size: 16px; } /* 16px stops iOS zoom-on-focus */
  .send { padding: var(--space-3); font-size: var(--t-md); }
  .micbtn { width: 48px; }

  .reply { padding: var(--space-4); }
  .reply .headline { font-size: var(--t-lg); }
  #replyActions li { padding-left: 46px; }
  #replyActions li::before { left: 10px; width: 24px; height: 24px; }

  section.panel { margin-top: var(--space-5); }
  section.panel h2 { font-size: var(--t-lg); }

  .item { padding: var(--space-2) var(--space-3); }

  /* Forms go full-width and stack. */
  .addrow input, .addrow select { flex: 1 1 100%; }
  .addrow button { flex: 1 1 100%; padding: var(--space-3); }

  /* Member cards match: privacy dial and phone each get a full line;
     Save / Profile / Delete become an even 3-up row beneath. */
  .famcard > .row1 > span:last-child { flex: 1 1 100%; }
  .famcard > .row1 select { width: 100%; }
  .fam-manage .row1 > .phone { flex: 1 1 100%; }
  .fam-manage .row1 > .save { flex: 1 1 0; padding: var(--space-2) var(--space-3); }

  .techmap { grid-template-columns: 1fr; }

  /* Modals become bottom sheets. */
  .modal { align-items: flex-end; padding: 0; }
  .modal-card {
    max-width: 100%;
    max-height: 92vh;
    border-radius: var(--r-lg) var(--r-lg) 0 0;
    border-bottom: 0;
  }

  /* Footer gets out of the nav's way. */
  footer { padding-bottom: var(--space-1); }
}

/* Incident recovery progress (guardian sees status, never the conversation) */
.incident-progress {
  display: inline-block;
  margin: var(--space-1) 0 var(--space-2);
  padding: 2px var(--space-2);
  border-radius: 999px;
  background: var(--accent-dim);
  color: var(--accent-strong); /* a11y: ≥4.8:1 on the dim fill in both themes */
  font-size: var(--t-sm);
  font-weight: 600;
}

/* ── Pilot survey (agenda item 8) ────────────────────────────────────── */
.survey {
  margin-top: var(--space-3);
  padding: var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel-2);
}
.survey .want { margin: 0 0 var(--space-2); }
.survey-q {
  display: flex; justify-content: space-between; align-items: center; gap: var(--space-2);
  padding: var(--space-1) 0; font-size: var(--t-sm);
}
.survey-opts { display: flex; gap: var(--space-1); }
.survey-opts button {
  border: 1px solid var(--line-strong); background: transparent; color: var(--text-muted);
  border-radius: 999px; padding: var(--space-2) var(--space-3); cursor: pointer; font-size: var(--t-sm);
  font-family: inherit;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
.survey-opts button:hover { color: var(--text); border-color: var(--accent); }
.survey-opts button.chosen { color: var(--text); border-color: var(--accent); background: var(--accent-dim); }
.survey-actions { display: flex; gap: var(--space-2); margin-top: var(--space-2); align-items: center; }
.survey-actions #surveySubmit {
  background: var(--primary-grad);
  color: var(--on-accent);
  border: 0;
  border-radius: var(--r-sm);
  padding: var(--space-2) var(--space-4);
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
}
.survey-actions #surveySubmit:disabled { opacity: 0.5; cursor: default; }
.survey-actions .linklike {
  background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: var(--t-sm);
  padding: var(--space-2) var(--space-1); /* a11y: touch target */
}
.survey-actions .linklike:hover { color: var(--text); }

/* ── Dashboard per-member tables ─────────────────────────────────────── */
.mini-table { width: 100%; border-collapse: collapse; font-size: var(--t-sm); }
.mini-table th, .mini-table td { text-align: left; padding: var(--space-2); border-bottom: 1px solid var(--line); }
.mini-table th { color: var(--text-muted); font-weight: 600; font-size: var(--t-xs); text-transform: uppercase; letter-spacing: 0.04em; }
.mini-table tr:last-child td { border-bottom: none; }
.mini-table td { font-variant-numeric: tabular-nums; }

/* ── First-run onboarding (agenda item 7) ─────────────────────────── */
.onboard-card {
  max-width: 560px;
  max-height: min(86vh, 720px);
  overflow-y: auto;
  padding: 0;
}
.onboard-hero {
  text-align: center;
  padding: var(--space-5) var(--space-4) var(--space-3);
  background: linear-gradient(180deg, var(--accent-dim), transparent);
}
.onboard-mark {
  width: 64px; height: 64px;
  margin: 0 auto var(--space-2);
  display: grid; place-items: center;
  font-size: 34px; line-height: 1;
  border-radius: 20px;
  background: linear-gradient(135deg, var(--accent-deep), var(--green));
  box-shadow: 0 6px 24px rgba(91, 140, 255, 0.35);
}
.onboard-hero h2 { margin: 0 0 var(--space-1); font-size: 26px; font-family: var(--font-display); }
.onboard-tag { margin: 0; color: var(--text-muted); font-size: var(--t-sm); }
.onboard-step {
  display: flex; gap: var(--space-3); align-items: flex-start;
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--line);
}
.onboard-ico { font-size: 26px; line-height: 1.2; }
.onboard-step b { display: block; margin-bottom: var(--space-1); }
.onboard-step p { margin: 0; color: var(--text-muted); font-size: var(--t-sm); line-height: 1.5; }
.onboard-calm {
  margin: 0;
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--line);
  background: var(--accent-dim);
  font-size: var(--t-sm);
  line-height: 1.5;
}
.onboard-actions {
  display: flex; gap: var(--space-2); justify-content: center;
  padding: var(--space-3) var(--space-4) var(--space-4);
  flex-wrap: wrap;
}
.onboard-actions button {
  border-radius: 999px; padding: var(--space-3) var(--space-5); font-size: var(--t-sm);
  border: 1px solid var(--line-strong); background: transparent; color: var(--text); cursor: pointer;
  font-family: inherit;
  transition: filter 0.15s ease, border-color 0.15s ease;
}
.onboard-actions button.primary {
  background: var(--primary-grad);
  border-color: var(--accent); color: var(--on-accent); font-weight: 700;
  box-shadow: 0 2px 12px rgba(91, 140, 255, 0.3);
}
.onboard-actions button:hover { filter: brightness(1.08); border-color: var(--accent); }
@media (max-width: 560px) {
  .onboard-step { padding: var(--space-3); }
  .onboard-hero { padding: var(--space-4) var(--space-3) var(--space-2); }
}

/* ── Urgency chip (agenda item 2) ────────────────────────────────────── */
.urgency-chip {
  display: inline-flex; align-items: center; gap: var(--space-2);
  border-radius: 999px; padding: var(--space-1) var(--space-3);
  font-size: var(--t-sm); font-weight: 600;
  border: 1px solid var(--line-strong); color: var(--text);
}
.urgency-chip.bad { border-color: var(--bad); color: var(--bad); background: var(--red-dim); }
.urgency-chip.warn { border-color: var(--warn); color: var(--warn); background: var(--yellow-dim); }
.urgency-chip.ok { border-color: var(--ok); color: var(--ok); background: var(--green-dim); }

/* ── Layering: welcome card above the Who-are-you? picker ─────────── */
#onboard { z-index: 70; }

/* ── Who-are-you? identity picker buttons ─────────────────────────── */
.who-modal-btn {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-3) var(--space-4); border-radius: var(--r-sm);
  border: 1px solid var(--line-strong); background: transparent; color: var(--text);
  font-size: var(--t-sm); cursor: pointer; text-align: left;
}
.who-modal-btn:hover { border-color: var(--accent); background: var(--accent-dim); }

/* ── Demo-reset panel (organizer only) ─────────────────────────── */
#demoResetPanel .save {
  background: none; border: 1px solid var(--red); color: var(--red);
  border-radius: var(--r-sm); padding: var(--space-2) var(--space-3); font-size: var(--t-sm);
  font-family: inherit; cursor: pointer; margin-top: var(--space-2);
}
#demoResetPanel .save:hover { background: var(--red-dim); }

/* ── Simple Mode (the grandma-facing portal) ──────────────────────────
 * One view (Ask), no tabs, no logs, no stats. The toggle lives in the
 * topbar; seniors get a one-time friendly offer when they pick their name. */
.simple-offer {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin: 0 0 var(--space-4);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  background: var(--accent-dim);
}
.simple-offer span { font-size: var(--t-md); }
.simple-offer .primary {
  background: var(--accent);
  color: var(--on-accent);
  border: none;
  border-radius: var(--r-sm);
  padding: var(--space-2) var(--space-3);
  font-family: inherit;
  cursor: pointer;
}
.simple-offer .primary:hover { background: var(--accent-strong); }
.simple-offer .linklike { background: none; border: none; cursor: pointer; font-family: inherit; }

body.simple-mode .who-meta { display: none; }
body.simple-mode #simpleToggle { border-color: var(--accent); }

/* ── Large-text ergonomics for Simple Mode (most-used controls) ────── */
body.simple-mode .big { min-height: 76px; }
body.simple-mode .composer textarea {
  min-height: 120px;
  font-size: var(--t-lg);
}
body.simple-mode .sendrow .send {
  padding: var(--space-4) var(--space-5);
  font-size: var(--t-lg);
}
body.simple-mode .who button { padding: var(--space-2) var(--space-3); }

/* ── 📷 Web photo attach (the P0 screenshot flow, minus the LLM) ───── */

#photoPending {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-top: var(--space-3);
  padding: var(--space-2) var(--space-3);
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md, 10px);
  font-size: var(--t-sm);
}

#photoPending img {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: var(--r-sm, 8px);
  border: 1px solid var(--line);
}

#photoPending span {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Drag-over state: the composer answers "yes, drop it here" visually. */
.composer.photo-drag {
  outline: 2px dashed var(--accent);
  outline-offset: 3px;
}

@media (prefers-reduced-motion: no-preference) {
  #photoPending { animation: fadeIn 160ms ease-out; }
}

/* Emergency exception (F6): the private-dial add-on in the family panel. */
.emergency-notify {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-2);
  font-size: 0.86rem;
  color: var(--muted);
  cursor: pointer;
}
.emergency-notify input[type="checkbox"] {
  accent-color: var(--accent);
  flex: none;
}


/* ── Demo-mode badge (the tour's breathing room) ───────────────────── */
.demo-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px dashed var(--border-primary);
  border-radius: 999px;
  background: var(--page-secondary);
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
}
.demo-badge:hover { color: var(--text-strong); border-color: var(--text-secondary); }
