/* ============================================================
   Kizoona — type
   Manrope (self-hosted woff2 variable, 200..800) is the single
   family for display and body. The CSS stack falls through to
   system-ui for CJK + the first-paint window. Terracotta is the
   single accent, used sparingly.
   Manrope ships roman-only; any `font-style: italic` rendering
   is browser-synthesised (acceptable for the one or two accent
   spots the design uses italic).
   ============================================================ */

@font-face {
  font-family: "Manrope";
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url("/fonts/manrope-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6,
    U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122,
    U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  /* paper → ink, warm neutral spine */
  --paper: #faf7f2;
  --paper-raised: #fffdf7;
  --paper-warm: #f6f0e6;
  --ink: #1f1b16;
  --ink-mid: #4d4840;
  --muted: #857c6f;
  --rule: #e5dfd4;
  --rule-soft: #efebe2;
  /* Default (terracotta) — overridden by [data-theme="..."] below.
   * Changing the base :root values also affects [data-theme="terracotta"]
   * since there's no rule for it — that's intentional: the attribute
   * is only a no-op for the default. */
  --accent: #c25a3a;
  --accent-deep: #9b4529;
  --accent-tint: #fff2ec;
  --accent-rule: #f0c0b6;
  --ok: #2e6547;
  --ok-tint: #f1f7f4;
  --ok-rule: #c6d9cd;
  --err: #a43428;

  /* type */
  --font-display:
    "Manrope", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-body:
    "Manrope", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono:
    ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --text-xs: 12px;
  --text-sm: 14px;
  --text-base: 16px;
  --text-md: 18px;
  --text-lg: 24px;
  --text-xl: 32px;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;
  --space-9: 96px;

  --radius: 10px;
  --radius-lg: 14px;

  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

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

html, body { margin: 0; padding: 0; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  min-height: 100vh;

  /* Two large soft radial gradients for atmosphere; pin to the
     corners so they don't drift with scroll. Subtle enough that
     the page still reads as "warm paper" not "gradient" */
  background:
    radial-gradient(ellipse 700px 600px at 0% 0%, #fdfaf4 0%, transparent 60%),
    radial-gradient(ellipse 700px 600px at 100% 100%, var(--paper-warm) 0%, transparent 60%),
    var(--paper);
  background-attachment: fixed;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

::selection {
  background: var(--accent);
  color: var(--paper-raised);
}

/* ------ Layout ------------------------------------------- */

.app {
  max-width: 480px;
  margin: 0 auto;
  padding: var(--space-4) var(--space-5) var(--space-8);
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  min-height: 100vh;
}

/* ------ Masthead ----------------------------------------- */

.masthead {
  /* No top padding — the .app container owns the breathing
   * room above the logo. Removed the prior var(--space-3) top
   * pad to tighten the header on mobile (was 44px, now 16px). */
}
.masthead__row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
}
.masthead .lang-switcher {
  /* When hosted in the masthead, align-self:auto, no margin-top trick. */
  margin-top: 0;
  padding-top: 0;
  align-self: auto;
  flex: 0 0 auto;
}
.mark {
  font-family: var(--font-display);
  font-size: 38px;
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1;
  color: var(--ink);
  font-feature-settings: "liga", "kern";
  display: inline-flex;
  align-items: baseline;
  gap: 0.25em;
}
.mark__kanji {
  color: var(--accent);
  font-size: 0.9em;
  font-weight: 700;
}
.mark__word {
  /* keeps the word on baseline with the kanji */
}
.mark--link {
  display: inline-block;
  background: transparent;
  border: 0;
  padding: 0;
  margin: 0;
  cursor: pointer;
  color: inherit;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  transition: color 160ms var(--ease);
}
.mark--link:hover {
  color: var(--accent-deep);
}
.subhead {
  margin-top: var(--space-2);
  font-size: var(--text-sm);
  color: var(--muted);
  letter-spacing: 0.01em;
}

/* ------ Progress ----------------------------------------- */

.progress {
  display: flex;
  gap: var(--space-2);
}
.tick {
  flex: 1;
  height: 2px;
  background: var(--rule);
  border-radius: 1px;
  transition: background 260ms var(--ease);
}
.tick--done { background: var(--ink); }
.tick--active { background: var(--accent); }

/* ------ Screen container --------------------------------- */

.screen { padding: var(--space-1) 0; }

.step {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  animation: screen-enter 260ms var(--ease);
}
@keyframes screen-enter {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ------ Type primitives ---------------------------------- */

.h1 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: var(--text-xl);
  letter-spacing: -0.02em;
  line-height: 1.12;
  margin: 0;
  color: var(--ink);
  font-feature-settings: "kern";
}
.h1__name {
  color: var(--accent);
  font-style: italic;
}

.lede {
  margin: 0;
  color: var(--ink-mid);
  font-size: var(--text-base);
  line-height: 1.55;
  max-width: 40ch;
}
.fine {
  margin: 0;
  color: var(--muted);
  font-size: var(--text-sm);
  line-height: 1.55;
  max-width: 42ch;
}

.eyebrow {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 3px 10px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  align-self: flex-start;
  background: var(--paper-raised);
}
.eyebrow--ok {
  color: var(--ok);
  border-color: var(--ok-rule);
  background: var(--ok-tint);
}

/* ------ Role cards --------------------------------------- */

.roles {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.role {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
  padding: var(--space-5);
  background: var(--paper-raised);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  cursor: pointer;
  transition:
    border-color 180ms var(--ease),
    background 180ms var(--ease),
    transform 140ms var(--ease);
}
.role:hover {
  border-color: var(--ink-mid);
}
.role:active {
  transform: scale(0.995);
}
.role:focus-within {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}
.role__input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}
.role__body { flex: 1; min-width: 0; }
.role__title {
  font-family: var(--font-display);
  font-size: var(--text-md);
  font-weight: 500;
  margin-bottom: 2px;
  letter-spacing: -0.005em;
  color: var(--ink);
}
.role__desc {
  font-size: var(--text-sm);
  color: var(--muted);
  line-height: 1.45;
}
.role__check {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1.5px solid var(--rule);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: transparent;
  flex-shrink: 0;
  margin-top: 2px;
  transition: all 180ms var(--ease);
}
.role--selected {
  border-color: var(--accent);
  background: var(--accent-tint);
}
.role--selected:hover {
  border-color: var(--accent-deep);
}
.role--selected .role__check {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--paper-raised);
}

/* ------ Fields ------------------------------------------- */

.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.field__label {
  font-size: var(--text-sm);
  color: var(--ink-mid);
  font-weight: 500;
}
.field__hint {
  font-size: var(--text-xs);
  color: var(--muted);
  line-height: 1.5;
  margin-top: 2px;
}
.input {
  width: 100%;
  padding: 14px 16px;
  background: var(--paper-raised);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  font-size: var(--text-base);
  color: var(--ink);
  appearance: none;
  -webkit-appearance: none;
  transition:
    border-color 180ms var(--ease),
    box-shadow 180ms var(--ease),
    background 180ms var(--ease);
}
.input::placeholder { color: var(--muted); }
.input:hover { border-color: var(--ink-mid); }
.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}

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

.actions {
  display: flex;
  gap: var(--space-3);
  margin-top: var(--space-2);
}
.actions--split { justify-content: space-between; }
.actions--stack {
  flex-direction: column;
  gap: var(--space-2);
}
.actions--stack .btn { width: 100%; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 14px 22px;
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: 500;
  line-height: 1;
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  transition:
    transform 120ms var(--ease),
    background 180ms var(--ease),
    border-color 180ms var(--ease),
    color 180ms var(--ease),
    box-shadow 180ms var(--ease);
  letter-spacing: 0.005em;
  -webkit-appearance: none;
  appearance: none;
}
.btn:focus { outline: none; }
.btn:focus-visible {
  box-shadow: 0 0 0 3px var(--accent-tint);
}
.btn:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}
.btn--primary {
  flex: 1;
  background: var(--ink);
  color: var(--paper-raised);
}
.btn--primary:hover:not(:disabled) {
  background: var(--accent-deep);
}
.btn--primary:active:not(:disabled) {
  transform: scale(0.99);
}
.btn--ghost {
  background: transparent;
  color: var(--ink-mid);
  border-color: transparent;
  padding-left: var(--space-3);
  padding-right: var(--space-3);
}
.btn--ghost:hover:not(:disabled) {
  color: var(--ink);
  background: var(--rule-soft);
}
.btn--danger {
  flex: 1;
  background: var(--err);
  color: var(--paper-raised);
}
.btn--danger:hover:not(:disabled) {
  background: #87271d;
}
.btn--danger:active:not(:disabled) {
  transform: scale(0.99);
}

/* ------ Working state ------------------------------------ */

.working {
  padding: var(--space-8) 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-5);
  text-align: center;
}
.working__dots {
  display: inline-flex;
  gap: 8px;
  align-items: center;
}
.working__dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ink);
  opacity: 0.2;
  animation: dot-pulse 1200ms var(--ease) infinite;
}
.working__dots span:nth-child(2) { animation-delay: 180ms; }
.working__dots span:nth-child(3) { animation-delay: 360ms; }
@keyframes dot-pulse {
  0%, 100% { opacity: 0.2; transform: translateY(0); }
  50%      { opacity: 1;   transform: translateY(-3px); }
}
.working__copy {
  margin: 0;
  color: var(--ink-mid);
  font-family: var(--font-display);
  font-style: italic;
  font-size: var(--text-md);
  letter-spacing: 0.005em;
}

/* ------ Recovery code ------------------------------------ */

.code {
  position: relative;
  margin: var(--space-2) 0;
  padding: var(--space-7) var(--space-4);
  background: var(--paper-raised);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 20px;
  line-height: 1.65;
  letter-spacing: 0.08em;
  color: var(--ink);
  text-align: center;
  word-break: break-all;
  user-select: all;
  animation: code-reveal 420ms var(--ease);
  box-shadow: 0 1px 0 0 var(--rule-soft);
}
.code::before {
  content: "RECOVERY CODE";
  position: absolute;
  top: -9px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--paper);
  padding: 0 10px;
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.16em;
  color: var(--muted);
}
@keyframes code-reveal {
  from { opacity: 0; transform: scale(0.98); }
  to   { opacity: 1; transform: scale(1); }
}

/* ------ Summary / data table ----------------------------- */

.data-table {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--paper-raised);
}
.datum {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: var(--space-4);
  border-bottom: 1px solid var(--rule);
}
.datum:last-child { border-bottom: 0; }
.datum__label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}
.datum__value {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--ink);
  word-break: break-all;
  user-select: all;
}

/* ------ Alerts ------------------------------------------- */

.alert {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius);
  font-size: var(--text-sm);
  line-height: 1.5;
  animation: screen-enter 260ms var(--ease);
}
.alert--error {
  background: #fff1ef;
  border: 1px solid var(--accent-rule);
  color: var(--err);
}
.alert--warning {
  background: #fff8ee;
  border: 1px solid #f0d7a6;
  color: #6e4b10;
  font-family: var(--font-display);
  font-size: var(--text-md);
}

/* ------ Notice banner ------------------------------------ */

.notice {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius);
  background: var(--accent-tint);
  border: 1px solid var(--accent-rule);
  color: var(--accent-deep);
  font-size: var(--text-sm);
  line-height: 1.5;
  animation: screen-enter 260ms var(--ease);
}
.notice__em {
  font-weight: 600;
  word-break: break-all;
}

.invite-banner {
  padding: var(--space-3) var(--space-4);
  background: var(--accent-tint);
  border: 1px solid var(--accent-rule);
  border-radius: var(--radius);
  color: var(--accent-deep);
  font-family: var(--font-display);
  font-style: italic;
  font-size: var(--text-base);
  line-height: 1.5;
  margin-bottom: var(--space-5);
  animation: screen-enter 260ms var(--ease);
}
.invite-banner__who {
  font-style: normal;
  font-weight: 500;
}

/* ------ Language switcher -------------------------------- */

.lang-switcher {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  margin-top: auto;
  padding-top: var(--space-5);
  align-self: flex-start;
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.08em;
}
.lang-switcher__opt {
  background: transparent;
  border: 0;
  padding: 4px 6px;
  font: inherit;
  color: var(--muted);
  cursor: pointer;
  letter-spacing: inherit;
  border-radius: 4px;
  transition: color 160ms var(--ease), background 160ms var(--ease);
}
.lang-switcher__opt:hover {
  color: var(--ink);
}
.lang-switcher__opt--active {
  color: var(--ink);
  font-weight: 600;
}
.lang-switcher__sep {
  color: var(--muted);
  opacity: 0.7;
  padding: 0 2px;
}

/* ------ Footnote (welcome screen "Already have an account?") ---- */

.footnote {
  margin-top: var(--space-3);
  text-align: center;
  color: var(--muted);
  font-size: var(--text-sm);
}
.link {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid var(--accent-rule);
  padding-bottom: 1px;
  transition: color 160ms var(--ease), border-color 160ms var(--ease);
}
.link:hover {
  color: var(--accent-deep);
  border-color: var(--accent-deep);
}

/* ------ Colophon ----------------------------------------- */

.colophon {
  margin-top: 0;
  padding-top: var(--space-6);
  border-top: 1px solid var(--rule);
  font-size: var(--text-xs);
  color: var(--muted);
  line-height: 1.55;
  font-style: italic;
  font-family: var(--font-display);
  letter-spacing: 0.005em;
}

/* ------ Responsive --------------------------------------- */

@media (min-width: 720px) {
  .app {
    max-width: 560px;
    padding: var(--space-8) var(--space-6);
    gap: var(--space-7);
  }
  .mark { font-size: 44px; letter-spacing: -0.028em; }
  .h1 { font-size: 42px; }
  .code {
    font-size: 26px;
    padding: var(--space-8) var(--space-6);
  }
  .roles { flex-direction: row; }
  .role { flex: 1; }
}

/* ------ Family dashboard --------------------------------- */

.family {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}
.family__group {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.family--loading { min-height: 0; }
.family__heading-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
}
.family__heading {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}
/* Top-level heading above the list of kids — mirrors
 * .coparents__heading so the two Family-tab sections read as
 * matched pairs rather than "kids as main content, coparents as
 * footnote". */
.family__section-heading {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0 4px;
}
.family__coparents {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
}
.coparent-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 12px;
  background: var(--paper-raised);
  border: 1px solid var(--rule);
  border-radius: 999px;
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--ink);
  cursor: pointer;
  transition:
    border-color 140ms var(--ease),
    background 140ms var(--ease),
    color 140ms var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.coparent-pill:hover {
  border-color: var(--accent);
  color: var(--accent-deep);
}
.coparent-pill:active {
  background: var(--accent-tint);
}
.coparent-pill__x {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--rule);
  color: var(--muted);
  font-size: 12px;
  line-height: 1;
  transition: background 140ms var(--ease), color 140ms var(--ease);
}
.coparent-pill:hover .coparent-pill__x {
  background: var(--accent);
  color: var(--paper-raised);
}

/* "Your co-parents" section on the Family tab: a flat list of
 * unique co-guardians (not grouped by kid). Row layout mirrors the
 * chat-list rows so the handshake between "who" and "tap to chat"
 * is visually unambiguous. Renders only when at least one
 * co-guardian exists.
 */
.coparents {
  margin-top: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.coparents__heading {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0 4px;
}
.coparents__list {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--paper-raised);
  overflow: hidden;
}
.coparent-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-3) var(--space-4);
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--rule-soft);
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 140ms var(--ease);
  -webkit-user-select: none;
          user-select: none;
}
.coparent-row:last-child { border-bottom: 0; }
.coparent-row:hover { background: rgba(31, 27, 22, 0.03); }
.coparent-row:active { background: var(--accent-tint); }
.coparent-row:focus-visible {
  outline: none;
  box-shadow: inset 0 0 0 2px var(--accent-tint);
}
.coparent-row--pending {
  cursor: default;
  opacity: 0.55;
}
.coparent-row--pending:hover { background: transparent; }
.coparent-row__avatar {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent-tint);
  color: var(--accent-deep);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 15px;
  border: 1px solid var(--accent-rule);
}
.coparent-row__body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.coparent-row__name {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: -0.005em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.coparent-row__meta {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.family__list {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--paper-raised);
}
.kid-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--rule);
}
.kid-row .btn--compact {
  padding: 6px 12px;
  background: transparent;
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.04em;
  line-height: 1;
  color: var(--ink-mid);
  border: 1px solid var(--rule);
  border-radius: 999px;
}
.kid-row .btn--compact:hover:not(:disabled) {
  color: var(--accent-deep);
  border-color: var(--accent);
  background: var(--accent-tint);
}
.kid-row:last-child { border-bottom: 0; }
.kid-row__primary {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}
.kid-row__name {
  font-family: var(--font-display);
  font-size: var(--text-md);
  font-weight: 500;
  color: var(--ink);
}
.kid-row__meta {
  font-size: var(--text-xs);
  color: var(--muted);
}
.kid-row__actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex: 0 0 auto;
}
.btn--icon {
  padding: 6px !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  min-height: 34px;
}
.btn--icon svg {
  width: 18px;
  height: 18px;
}
.btn__label {
  font-size: inherit;
}
.kid-row .btn--ghost.btn--compact {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.kid-row .btn--ghost.btn--compact svg {
  width: 16px;
  height: 16px;
}

/* ------ QR + invite-link row ----------------------------- */

.qr {
  align-self: center;
  padding: var(--space-4);
  background: var(--paper-raised);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  max-width: 320px;
}
.qr svg {
  display: block;
  width: 100%;
  height: auto;
  shape-rendering: crispEdges;
}

.invite-link {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.invite-link__label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}
.invite-link__row {
  display: flex;
  align-items: stretch;
  gap: var(--space-2);
  background: var(--paper-raised);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: var(--space-2) var(--space-3);
}
.invite-link__url {
  flex: 1;
  min-width: 0;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--ink);
  word-break: break-all;
  line-height: 1.4;
  user-select: all;
}

.btn--compact {
  padding: 6px 12px;
  font-size: var(--text-sm);
  border: 1px solid var(--rule);
}
.btn--compact:hover:not(:disabled) {
  border-color: var(--ink-mid);
  background: var(--rule-soft);
}

/* ------ Picker section headings ------------------------- */

.picker-section__heading {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: var(--space-4);
}
.step--picker > .picker-section__heading:first-of-type {
  margin-top: var(--space-3);
}
.picker-row--button {
  border: 0;
  width: 100%;
  text-align: left;
  font: inherit;
  color: inherit;
}

/* ------ Co-parent kid picker ---------------------------- */

.picker {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--paper-raised);
  overflow: hidden;
}
.picker-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 14px var(--space-4);
  min-height: 56px;
  border-bottom: 1px solid var(--rule);
  cursor: pointer;
  transition: background 140ms var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.picker-row:last-child { border-bottom: 0; }
.picker-row:hover { background: var(--rule-soft); }
.picker-row:active { background: var(--accent-tint); }
.picker-row--selected {
  background: var(--accent-tint);
}
.picker-row--selected:hover {
  background: var(--accent-tint);
}
.picker-row__check {
  /* Visually hidden — the row itself IS the tap target. */
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 1px;
  height: 1px;
}
.picker-row__name {
  flex: 1;
  font-family: var(--font-display);
  font-size: var(--text-md);
  color: var(--ink);
  letter-spacing: -0.005em;
}
.picker-row__tick {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1.5px solid var(--rule);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: transparent;
  flex-shrink: 0;
  transition: all 140ms var(--ease);
}
.picker-row--selected .picker-row__tick {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--paper-raised);
}

/* ------ Pending approvals ------------------------------- */

.pending-approvals {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.pending-approvals__heading {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent-deep);
}
.pending-approvals__list {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--accent-rule);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--accent-tint);
}
.pending-approvals__row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--accent-rule);
}
.pending-approvals__row:last-child { border-bottom: 0; }
.pending-approvals__sentence {
  flex: 1;
  font-family: var(--font-display);
  font-size: var(--text-base);
  color: var(--ink);
  line-height: 1.35;
}
.pending-approvals__actions {
  display: flex;
  gap: var(--space-2);
  flex-shrink: 0;
}

/* ------ Rendezvous phrase display ----------------------- */

.phrase-display {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  justify-content: center;
  padding: var(--space-5) var(--space-3);
  background: var(--paper-raised);
  border: 1px solid var(--accent-rule);
  border-radius: var(--radius);
  margin: var(--space-3) 0;
}
.phrase-display__word {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 500;
  color: var(--ink);
  padding: 6px 12px;
  background: var(--accent-tint);
  border-radius: 8px;
  user-select: all;
}

/* ------ Contact pairing --------------------------------- */

.identity-qr-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: center;
}

.approval-list {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--paper-raised);
}
.approval-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 14px var(--space-4);
  border-bottom: 1px solid var(--rule);
  font-family: var(--font-display);
  font-size: var(--text-md);
  color: var(--muted);
}
.approval-row:last-child { border-bottom: 0; }
.approval-row--done {
  color: var(--ok);
}
.approval-row__icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1.5px solid var(--rule);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: var(--muted);
  flex-shrink: 0;
  background: transparent;
  transition: all 180ms var(--ease);
}
.approval-row--done .approval-row__icon {
  border-color: var(--ok);
  background: var(--ok);
  color: var(--paper-raised);
}
.approval-row__label {
  flex: 1;
  min-width: 0;
}

/* Full-screen camera overlay created by ports.js. */
.scanner-overlay {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  animation: screen-enter 180ms var(--ease);
}
.scanner-overlay video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.scanner-overlay__hint {
  position: absolute;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  max-width: 90vw;
  text-align: center;
  padding: var(--space-2) var(--space-4);
  background: rgba(0, 0, 0, 0.6);
  color: var(--paper-raised);
  border-radius: 999px;
  font-family: var(--font-display);
  font-style: italic;
  font-size: var(--text-sm);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.scanner-overlay__cancel {
  position: absolute;
  bottom: calc(env(safe-area-inset-bottom, 0) + 24px);
  left: 50%;
  transform: translateX(-50%);
  padding: 14px 32px;
  border: 0;
  border-radius: 999px;
  background: var(--paper-raised);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: 500;
  cursor: pointer;
}

/* ------ Contacts list ----------------------------------- */

.contacts {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.contacts__heading {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}
.contacts__list {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--paper-raised);
}
.contact-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 14px var(--space-4);
  border-bottom: 1px solid var(--rule);
}
.contact-row:last-child { border-bottom: 0; }
.contact-row {
  /* button reset */
  width: 100%;
  font: inherit;
  color: inherit;
  text-align: left;
  background: transparent;
  border-left: 0;
  border-right: 0;
  border-top: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 140ms var(--ease);
}
.contact-row:hover { background: var(--rule-soft); }
.contact-row:active { background: var(--accent-tint); }
.contact-row__label {
  flex: 1;
  font-family: var(--font-display);
  font-size: var(--text-md);
  color: var(--ink);
  letter-spacing: -0.005em;
}
.contact-row__badge {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  margin-left: var(--space-3);
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  color: var(--paper-raised);
  background: var(--accent);
  border-radius: 999px;
  letter-spacing: 0.01em;
}
.contact-row__pill {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  margin-left: var(--space-3);
  padding: 2px 8px;
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  line-height: 1.5;
  border-radius: 999px;
  border: 1px solid var(--rule);
  color: var(--muted);
  background: var(--paper-warm);
}
.contact-row__pill--family {
  color: var(--accent-deep);
  border-color: var(--accent-rule);
  background: var(--accent-tint);
}
.contact-row--static {
  cursor: default;
}
.contact-row--static:hover,
.contact-row--static:active {
  background: transparent;
}
.contact-row__hint {
  font-size: var(--text-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  flex-shrink: 0;
}
.contacts--waiting .contacts__list {
  background: var(--paper-warm);
}
.contact-row--revokable {
  padding: 0 var(--space-2) 0 0;
  gap: var(--space-2);
}
.contact-row__primary {
  flex: 1;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 14px var(--space-4);
  min-width: 0;
  background: transparent;
  border: 0;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 140ms var(--ease);
}
.contact-row__primary:hover { background: var(--rule-soft); }
.contact-row__primary:active { background: var(--accent-tint); }
.contact-row__primary--static {
  cursor: default;
}
.contact-row__primary--static:hover,
.contact-row__primary--static:active {
  background: transparent;
}
.contact-row__revoke {
  flex-shrink: 0;
  font-size: var(--text-xs);
  padding: 4px 10px;
}

/* ------ Conversation ------------------------------------ */

.conv {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  animation: screen-enter 260ms var(--ease);
}

/* Chat mode: let the conversation stretch to fill the viewport and
 * pin the compose row flush to the bottom safe-area. Drops the
 * dashboard's column padding so messages go edge-to-edge on mobile. */
.app--chat {
  max-width: 560px;
  padding: 0;
  gap: 0;
  min-height: 100vh;
  min-height: 100dvh;
}
/* Chat mode drops the dashboard masthead — the conversation has
 * its own .conv__header (back button + peer name + leave) which
 * does the whole job. Keeping both stacked two headers on top of
 * each other, and the masthead was showing up crammed against the
 * left edge because .app--chat zeroed the shell padding.
 */
.app--chat > .masthead {
  display: none;
}
.app--chat .screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.app--chat .conv {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0;
  min-height: 0;
}
.app--chat .conv__header {
  padding: var(--space-3) var(--space-5);
  margin: 0;
}
.app--chat .conv__list {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4) var(--space-5);
  gap: var(--space-2);
  min-height: 0;
}
/* Composer wrapper sticks the emoji tray + input row together at the
 * bottom of the chat. The tray (when open) expands above the row and
 * steals vertical space from the scrollable message list — the list
 * is `flex: 1` + `overflow: auto`, so opening the picker shrinks it
 * rather than pushing content under the viewport edge. */
.app--chat .composer {
  position: sticky;
  bottom: 0;
  background: var(--paper-raised);
  border-top: 1px solid var(--rule);
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.app--chat .compose {
  padding: var(--space-3) var(--space-5);
  border-top: none;
  background: transparent;
  position: static;
}
.app--chat .conv__confirm,
.app--chat .conv__readonly {
  margin: 0 var(--space-5);
}
.conv__header {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: var(--space-3);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--rule);
}
.conv__back {
  padding: 6px var(--space-2);
  font-size: var(--text-sm);
  color: var(--muted);
}
.conv__title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 500;
  color: var(--ink);
  letter-spacing: -0.01em;
  text-align: center;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.conv__leave {
  padding: 6px 10px;
  font-size: var(--text-sm);
  color: var(--muted);
  flex-shrink: 0;
}
.conv__leave:hover:not(:disabled) {
  color: var(--err);
  background: var(--rule-soft);
}
.conv__confirm {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-4);
  background: #fff8f5;
  border: 1px solid var(--accent-rule);
  border-radius: var(--radius);
  animation: screen-enter 180ms var(--ease);
}
.conv__confirm-prompt {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--text-md);
  color: var(--ink);
  /* Left-align so the prompt doesn't look oddly offset above the
   * asymmetric split-actions row (narrow ghost left, wide danger
   * right). Centering over the whole box makes the prompt appear
   * to float toward the heavier button on the right. */
  text-align: left;
}
/* Breathing room between the member panel and the confirm banner
 * so they don't read as one stacked rectangle. */
.conv__confirm { margin-top: var(--space-3); }
.conv__list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-height: 40vh;
}
.conv__empty {
  margin: auto;
  padding: var(--space-6) 0;
  color: var(--muted);
  font-family: var(--font-display);
  font-style: italic;
  text-align: center;
}
.conv__readonly {
  margin: 0;
  padding: var(--space-3) var(--space-4);
  background: var(--paper-warm);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  color: var(--ink-mid);
  font-size: var(--text-sm);
  font-family: var(--font-display);
  font-style: italic;
  text-align: center;
}

.bubble-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-width: 100%;
}
.bubble {
  max-width: min(80%, 360px);
  padding: 10px 14px;
  border-radius: 18px;
  font-size: var(--text-base);
  line-height: 1.4;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  animation: screen-enter 180ms var(--ease);
}
.bubble__caption {
  font-size: var(--text-xs);
  color: var(--muted);
  letter-spacing: 0.04em;
  padding: 0 var(--space-3);
}
.bubble-row:has(.bubble--mine) {
  align-items: flex-end;
}
.bubble-row:has(.bubble--theirs-other) {
  align-items: flex-end;
}
.bubble-row:has(.bubble--theirs) {
  align-items: flex-start;
}
.bubble--mine {
  align-self: flex-end;
  background: var(--accent);
  color: var(--paper-raised);
  border-bottom-right-radius: 6px;
}
.bubble--theirs {
  align-self: flex-start;
  background: var(--paper-raised);
  border: 1px solid var(--rule);
  color: var(--ink);
  border-bottom-left-radius: 6px;
}
/* Guardian view: the other kid sits on the right for clarity. */
.bubble--theirs-other {
  align-self: flex-end;
  background: var(--paper-warm);
  border: 1px solid var(--rule);
  color: var(--ink);
  border-bottom-right-radius: 6px;
}
.bubble__pending { opacity: 0.45; }
.bubble__fail { color: var(--err); font-style: italic; }

/* Signal-style 3-state receipt glyph, pinned to the tail of the
 * sender's own bubbles. "sent" and "delivered" sit at low contrast;
 * "read" pops to full white so the transition to "seen" is obvious
 * at a glance. Kept purely typographic — single/double check marks,
 * no emoji or raster icons — to stay legible at any font size. */
.bubble__receipt {
  display: inline-block;
  margin-left: 6px;
  vertical-align: baseline;
  font-family: var(--font-body);
  font-size: 11px;
  line-height: 1;
  letter-spacing: -0.02em;
  color: rgba(255, 255, 255, 0.55);
  user-select: none;
}
.bubble__receipt--delivered {
  color: rgba(255, 255, 255, 0.75);
}
.bubble__receipt--read {
  color: var(--paper-raised);
  font-weight: 700;
}
/* Emoji-only bubbles drop the chrome, so a white ✓ on the page
 * would disappear. Switch the receipt to a muted ink tint. */
.bubble--emoji-only .bubble__receipt {
  color: var(--muted);
}
.bubble--emoji-only .bubble__receipt--read {
  color: var(--accent);
}

/* Inline HH:MM timestamp on the bubble. Mine-side inherits the
 * white-on-ink tint from the bubble background; theirs-side reads
 * as muted ink on the warm chip. Sits flush against the receipt. */
.bubble__time {
  display: inline-block;
  margin-left: 8px;
  vertical-align: baseline;
  font-family: var(--font-body);
  font-size: 11px;
  line-height: 1;
  letter-spacing: 0.01em;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  user-select: none;
}
.bubble--mine .bubble__time {
  color: rgba(255, 255, 255, 0.65);
  margin-left: 8px;
}
.bubble--mine .bubble__time + .bubble__receipt {
  margin-left: 4px;
}
.bubble--emoji-only .bubble__time {
  display: none;
}

.compose {
  display: flex;
  gap: var(--space-2);
  padding-top: var(--space-3);
  border-top: 1px solid var(--rule);
  /* Pin the emoji/paperclip/send buttons to the bottom so the
   * textarea can grow upward without pushing them out of reach. */
  align-items: flex-end;
}
.compose__input {
  flex: 1;
  min-width: 0;
  /* textarea specifics — Enter inserts a newline (native); we
   * disable the manual resize handle, let it grow with its content
   * up to ~6 lines, then scroll. field-sizing: content does the
   * auto-grow in Chrome 123+ / Safari 18+; older browsers see a
   * one-row textarea with scroll, still usable. */
  resize: none;
  field-sizing: content;
  line-height: 1.4;
  min-height: 48px;
  max-height: 9.5em;
  overflow-y: auto;
  font-family: inherit;
}
.compose .btn {
  flex: 0 0 auto;
}
.compose__emoji {
  padding: 8px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-mid);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.compose__emoji:hover:not(:disabled) {
  background: var(--rule-soft);
  color: var(--ink);
}
.compose__emoji[aria-expanded="true"] {
  background: var(--accent-tint);
  border-color: var(--accent-rule);
  color: var(--accent-deep);
}

.compose__image-btn {
  padding: 8px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-mid);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  line-height: 1;
}
.compose__image-btn:hover:not(:disabled) {
  background: var(--rule-soft);
  color: var(--ink);
}
.compose__emoji .feather,
.compose__image-btn .feather {
  display: block;
  width: 22px;
  height: 22px;
}

/* Image bubbles. Render the thumbnail in-flow at the bubble's
 * natural width; clicks promote to the full-screen viewer. */
.bubble__img {
  max-width: 100%;
  border-radius: 10px;
  object-fit: cover;
  display: block;
  cursor: zoom-in;
}
.bubble__img--loading {
  min-height: 120px;
  min-width: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--rule-soft);
  color: var(--muted, #888);
  font-size: 13px;
  border-radius: 10px;
}

/* Full-bleed image viewer: dim overlay, centered image, tap
 * outside to close. */
.image-viewer {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.82);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  cursor: zoom-out;
}
.image-viewer__img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 8px;
}
.image-viewer__close {
  position: absolute;
  top: 16px;
  right: 16px;
  font-size: 28px;
  line-height: 1;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border: none;
  border-radius: 999px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.image-viewer__close:hover {
  background: rgba(255, 255, 255, 0.2);
}
.image-viewer__loading {
  color: rgba(255, 255, 255, 0.8);
  font-size: 14px;
}

/* Prev/next nav — absolute-positioned chevrons on either edge, hidden
 * at the start/end of the conversation's image list. Tap-friendly
 * circles on mobile; the user can also swipe left/right on the
 * overlay or use ← / → on desktop. */
.image-viewer__nav {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.image-viewer__step {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  line-height: 1;
  font-family: var(--font-display);
  font-weight: 300;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  pointer-events: auto;
  transition: background 160ms var(--ease);
}
.image-viewer__step:hover {
  background: rgba(255, 255, 255, 0.22);
}
.image-viewer__step--prev { left: 16px; }
.image-viewer__step--next { right: 16px; }

.image-viewer__counter {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255, 255, 255, 0.78);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
  pointer-events: none;
}

/* Outbox status pills. Sending = subtle grey dot pulse; Failed =
 * reddish tint + tap-to-retry text. */
.bubble__outbox {
  display: inline-block;
  margin-left: 6px;
  font-size: 11px;
  color: var(--muted, #888);
  font-style: italic;
}
.bubble__outbox--sending::before {
  content: "●";
  margin-right: 4px;
  animation: kz-pulse 1.4s ease-in-out infinite;
}
.bubble__outbox--failed {
  color: #c44;
  border: 1px solid #c44;
  border-radius: 999px;
  padding: 2px 8px;
  background: transparent;
  cursor: pointer;
  font-style: normal;
}
.bubble__outbox--failed:hover {
  background: rgba(204, 68, 68, 0.1);
}
.bubble--outbox-failed {
  background: rgba(204, 68, 68, 0.08);
}
@keyframes kz-pulse {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 1; }
}

/* Inline emoji in bubbles. Slightly larger than the text baseline
 * and shifted down by 0.15em so the SVG sits visually centered on
 * the x-height rather than floating up like a superscript. */
.emoji-inline {
  display: inline-block;
  width: 1.2em;
  height: 1.2em;
  vertical-align: -0.2em;
  margin: 0 1px;
  user-select: none;
  -webkit-user-drag: none;
}

/* Emoji-only bubbles (1–3 glyphs, no text) render the SVGs at ~2.2x
 * normal size — the iMessage/WhatsApp "big emoji" treatment — and
 * drop the bubble chrome so the glyphs read as a reaction rather
 * than a message. Larger runs fall back to regular bubble styling
 * to avoid a wall of oversized SVGs. */
.bubble--emoji-only {
  background: transparent !important;
  padding: 2px 0 !important;
  border: 0 !important;
  box-shadow: none !important;
}
.bubble--emoji-only .emoji-inline {
  width: 2.4em;
  height: 2.4em;
  vertical-align: middle;
  margin: 0 3px;
}

/* Emoji picker tray — lives inside .composer, above the compose row.
 * Tabs across the top, virtualized (one group at a time) grid below.
 * Fixed-height so opening it doesn't cause a layout cascade that
 * moves the compose row under the mobile keyboard. */
.emoji-picker {
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--rule);
  background: var(--paper-raised);
  max-height: 42vh;
  min-height: 220px;
  position: relative;
  z-index: 50;
}
/* Invisible full-viewport catcher so a tap anywhere outside the
 * picker closes it. Sibling to the picker so clicks on picker
 * elements never land here — no stopPropagation needed. */
.emoji-picker__backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: transparent;
  -webkit-tap-highlight-color: transparent;
}
.emoji-picker--loading {
  min-height: 44px;
  max-height: 44px;
  align-items: center;
  justify-content: center;
  color: var(--muted);
}
.emoji-picker__hint {
  font-family: var(--font-display);
  color: var(--muted);
}
.emoji-picker__search {
  flex: 0 0 auto;
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--rule);
  background: var(--paper-raised);
}
.emoji-picker__search-input {
  width: 100%;
  padding: 8px 12px;
  font: inherit;
  font-size: var(--text-sm);
  color: var(--ink);
  background: var(--paper-warm);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  appearance: none;
  -webkit-appearance: none;
  transition: border-color 160ms var(--ease), box-shadow 160ms var(--ease);
}
.emoji-picker__search-input::placeholder { color: var(--muted); }
.emoji-picker__search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}
.emoji-picker__tabs {
  flex: 0 0 auto;
  display: flex;
  overflow-x: auto;
  overflow-y: hidden;
  gap: 2px;
  padding: 4px var(--space-3);
  border-bottom: 1px solid var(--rule);
  background: var(--paper-warm);
  scrollbar-width: thin;
}
.emoji-picker__empty {
  padding: var(--space-5);
  text-align: center;
  color: var(--muted);
  font-size: var(--text-sm);
}
.emoji-picker__tab {
  flex: 0 0 auto;
  appearance: none;
  background: transparent;
  border: none;
  padding: 6px 10px;
  font-size: 20px;
  line-height: 1;
  border-radius: 8px;
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 120ms var(--ease), background 120ms var(--ease);
}
.emoji-picker__tab:hover {
  opacity: 1;
  background: var(--rule-soft);
}
.emoji-picker__tab--active {
  opacity: 1;
  background: var(--rule-soft);
  box-shadow: inset 0 -2px 0 var(--accent);
}
.emoji-picker__grid {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: var(--space-2) var(--space-3);
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(36px, 1fr));
  gap: 2px;
  align-content: start;
  -webkit-overflow-scrolling: touch;
}
.emoji-picker__cell {
  appearance: none;
  background: transparent;
  border: none;
  padding: 4px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.emoji-picker__cell:hover {
  background: var(--rule-soft);
}
.emoji-picker__img {
  width: 28px;
  height: 28px;
  pointer-events: none;
  -webkit-user-drag: none;
  user-select: none;
}

/* ------ Pair card (contact pairing "waiting for sigs") ---- */

.pair-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  padding: var(--space-5);
  background: var(--paper-raised);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
}
.pair-card__parties {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: var(--space-3);
}
.pair-card__party {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
}
.pair-card__party-name {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 500;
  color: var(--ink);
  letter-spacing: -0.01em;
  text-align: center;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pair-card__link {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  color: var(--muted);
  user-select: none;
}
.pair-card__tick {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1.5px solid var(--rule);
  font-size: 12px;
  color: var(--muted);
  transition: all 180ms var(--ease);
}
.pair-card__tick--done {
  border-color: var(--ok);
  background: var(--ok);
  color: var(--paper-raised);
}
.pair-card__guardians {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding-top: var(--space-4);
  border-top: 1px solid var(--rule-soft);
}
.pair-card__guardians-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: center;
}
.pair-card__guardian-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
}
.pair-card__guardian-col {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-width: 0;
}
.pair-card__guardian {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  min-width: 0;
}
.pair-card__guardian-name {
  font-family: var(--font-display);
  font-size: var(--text-base);
  color: var(--ink);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ------ Static pages (About / Security / Privacy / Impressum) --- */

.step--static {
  gap: var(--space-4);
}
.static__body {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  max-width: 56ch;
}
.static__body p {
  margin: 0;
  color: var(--ink-mid);
  line-height: 1.65;
  font-size: var(--text-base);
}
.static__body p.lede {
  color: var(--ink);
  font-size: var(--text-md);
  font-weight: 500;
}
.static__h2 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--text-md);
  margin: var(--space-4) 0 calc(-1 * var(--space-2));
  letter-spacing: -0.01em;
  color: var(--ink);
}
.static__body ul {
  margin: 0;
  padding-left: 1.25em;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  color: var(--ink-mid);
  line-height: 1.55;
}
.colophon__text {
  margin: 0 0 var(--space-3);
}
.colophon__links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: baseline;
}
.colophon__link {
  color: var(--muted);
  text-decoration: none;
  font-style: normal;
  font-family: var(--font-body);
  font-size: 12px;
  letter-spacing: 0.02em;
  border-bottom: 1px solid transparent;
  transition: color 160ms var(--ease), border-color 160ms var(--ease);
}
.colophon__link:hover {
  color: var(--accent-deep);
  border-color: var(--accent-rule);
}
.colophon__sep {
  color: var(--rule);
  user-select: none;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ============================================================
   Bottom tab bar — dashboard navigation
   Rendered inside .step--summary, sticky-bottom so it stays in
   thumb reach on mobile and doesn't scroll with the list. The
   tab bar is NOT rendered on the conversation drill-in
   (viewConversation doesn't mount viewTabBar), so the composer
   takes the same slot without a tab bar below it.
   ============================================================ */

.step--summary {
  /* Leave room for the fixed tab bar so content never ends up
   * under it. 64px bar + safe-area inset + a little breathing room. */
  padding-bottom: calc(80px + env(safe-area-inset-bottom, 0));
}

.tabbar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  background: var(--paper-raised);
  border-top: 1px solid var(--rule);
  padding: 6px 0 calc(6px + env(safe-area-inset-bottom, 0));
  z-index: 10;
}
@media (min-width: 720px) {
  .tabbar { max-width: 560px; }
}
.tabbar__btn {
  appearance: none;
  background: transparent;
  border: 0;
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font: inherit;
  color: var(--muted);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: color 120ms var(--ease);
}
.tabbar__btn:hover { color: var(--ink-mid); }
.tabbar__btn--active { color: var(--accent); }
.tabbar__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  line-height: 1;
}
.tabbar__icon svg {
  display: block;
}
.tabbar__label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  line-height: 1;
}

/* ------ Group rows + create-group screen ------------- */

.contact-row--group {
  gap: var(--space-3);
  align-items: center;
}
.contact-row__glyph {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: var(--accent-tint);
  color: var(--accent-deep);
  font-size: 14px;
  letter-spacing: 1px;
  font-weight: 700;
}
.contact-row__body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}
.contact-row__sub {
  font-size: var(--text-xs);
  color: var(--muted);
  letter-spacing: 0.01em;
}
.contacts--groups {
  margin-bottom: var(--space-3);
}

.conv--group .conv__title--button {
  background: transparent;
  border: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  cursor: pointer;
  font: inherit;
  color: inherit;
  padding: 0;
}
.conv__title-sub {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  color: var(--muted);
  letter-spacing: 0.01em;
}
/* Stacked variant — group conv title puts the name on top and a
 * comma-separated member list underneath, both truncated by
 * ellipsis. The parent grid in .conv__header already constrains
 * the middle column's width so the flex-column can ellipsise. */
.conv__title--stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
  white-space: normal;
}
.conv__title--stack .conv__title-name {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.15;
}
.conv__title--stack .conv__title-sub {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.2;
  margin-top: 1px;
}
.conv__members {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  background: var(--paper-warm);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  animation: screen-enter 180ms var(--ease);
}
.conv__member {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--ink);
}
.conv__member-name {
  flex: 1;
}

.step--create-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}
.create-group__list {
  display: flex;
  flex-direction: column;
  gap: 0;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  overflow: hidden;
}
.create-group__row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 12px var(--space-3);
  border-bottom: 1px solid var(--rule);
  cursor: pointer;
  transition: background 140ms var(--ease);
}
.create-group__row:last-child {
  border-bottom: 0;
}
.create-group__row:hover {
  background: var(--rule-soft);
}
.create-group__row input[type="checkbox"] {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
}
.create-group__name {
  flex: 1;
  font-family: var(--font-display);
  font-size: var(--text-md);
  color: var(--ink);
}
.create-group__error {
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--err);
  border-radius: var(--radius);
  background: #fff6f4;
  color: var(--err);
  font-size: var(--text-sm);
}
.create-group__error p {
  margin: 0 0 var(--space-2) 0;
}
.create-group__error ul {
  margin: 0;
  padding-left: var(--space-4);
}
.create-group__chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 4px 8px;
  margin: 2px;
  border-radius: 999px;
  background: var(--accent-soft, rgba(0, 0, 0, 0.06));
  color: var(--ink);
  font-size: var(--text-sm);
  line-height: 1;
}
.create-group__chip-name {
  white-space: nowrap;
}
.create-group__chip-x {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  color: var(--muted);
  font-size: 14px;
  transition: color 140ms var(--ease), background 140ms var(--ease);
}
.create-group__chip:hover .create-group__chip-x {
  color: var(--ink);
  background: rgba(0, 0, 0, 0.08);
}

/* ------ Chats / Guarded tab search input ------ */
.tab__search {
  padding-bottom: var(--space-3);
  margin-bottom: var(--space-3);
  border-bottom: 1px solid var(--rule);
}
.tab__search .input {
  width: 100%;
}

/* ============================================================
   Accent themes. data-theme="<name>" on .app overrides the four
   --accent-* custom properties; everything else (paper, ink,
   muted, rule, ok, err) stays put so the warm-paper spine is
   preserved across palettes. Values chosen to pair with the
   existing #faf7f2 paper background.
   ============================================================ */

.app[data-theme="teal"] {
  --accent: #1e8b8b;
  --accent-deep: #165f5f;
  --accent-tint: #ecf7f7;
  --accent-rule: #b4dede;
}

.app[data-theme="indigo"] {
  --accent: #5b4bbf;
  --accent-deep: #3f358a;
  --accent-tint: #eeeafc;
  --accent-rule: #cac0ec;
}

.app[data-theme="moss"] {
  --accent: #5d7a3f;
  --accent-deep: #3f5429;
  --accent-tint: #eef3e4;
  --accent-rule: #c9d5ad;
}

.app[data-theme="rose"] {
  --accent: #c24669;
  --accent-deep: #8a2f4a;
  --accent-tint: #fdeaee;
  --accent-rule: #f0bccb;
}

.app[data-theme="amber"] {
  --accent: #c28a1e;
  --accent-deep: #8a6114;
  --accent-tint: #fdf3dc;
  --accent-rule: #ead4a2;
}

/* ------ Profile section (Settings tab top) ---------------- */

.profile-section {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-4) 0;
  border-bottom: 1px solid var(--rule-soft);
}
.profile-section__avatar {
  flex: 0 0 auto;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--accent-tint);
  border: 1px solid var(--rule);
  display: flex;
  align-items: center;
  justify-content: center;
}
.profile-section__avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.profile-section__avatar-placeholder {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 24px;
  letter-spacing: 0.02em;
  color: var(--accent-deep);
}
.profile-section__body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-items: flex-start;
}
.profile-section__name {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: var(--text-md);
  letter-spacing: -0.005em;
  color: var(--ink);
}

/* ------ Signed-in devices (Settings tab) ------------------- */

.sessions {
  padding: var(--space-4) 0;
  border-top: 1px solid var(--rule-soft);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.sessions__heading {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: var(--text-md);
  letter-spacing: -0.005em;
  color: var(--ink);
}
.sessions__list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.sessions__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--paper-raised);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
}
.sessions__body { min-width: 0; }
.sessions__title {
  font-size: var(--text-base);
  color: var(--ink);
  line-height: 1.3;
}
.sessions__meta {
  font-size: var(--text-xs);
  color: var(--muted);
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}
.sessions__badge {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ok);
  background: var(--ok-tint);
  border: 1px solid var(--ok-rule);
  padding: 3px 10px;
  border-radius: 999px;
  white-space: nowrap;
}
.sessions__busy {
  font-size: var(--text-sm);
  color: var(--muted);
  white-space: nowrap;
}
.sessions__revoke {
  background: transparent;
  border: 0;
  padding: 0;
  font: inherit;
  font-size: var(--text-sm);
  color: var(--err);
  cursor: pointer;
  border-bottom: 1px solid transparent;
  transition: border-color 120ms var(--ease);
  white-space: nowrap;
}
.sessions__revoke:hover {
  border-bottom-color: var(--err);
}

/* ------ Linkified URLs in bubbles -------------------------- */

.bubble__link {
  color: inherit;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  word-break: break-all;
}
.bubble__link:hover { text-decoration-thickness: 2px; }
.bubble--mine .bubble__link { color: rgba(255, 255, 255, 0.95); }

/* ------ Reply strip (above compose input) ------------------ */

.reply-strip {
  display: flex;
  align-items: stretch;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  background: var(--paper-raised);
  border: 1px solid var(--rule);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  margin-bottom: var(--space-2);
}
.reply-strip__body { flex: 1; min-width: 0; }
.reply-strip__label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 2px;
}
.reply-strip__preview {
  font-size: var(--text-sm);
  color: var(--ink-mid);
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.reply-strip__dismiss {
  background: transparent;
  border: 0;
  padding: 0 var(--space-2);
  font-size: 20px;
  color: var(--muted);
  cursor: pointer;
  line-height: 1;
}
.reply-strip__dismiss:hover { color: var(--ink); }

/* Quoted block at the top of a bubble whose message replies to
 * another. Indented left edge + muted copy so it reads as a
 * referenced quote, not the bubble's own body. */
.bubble__quoted {
  padding: 4px var(--space-3);
  margin-bottom: 4px;
  border-left: 2px solid var(--accent-rule);
  background: rgba(0, 0, 0, 0.03);
  border-radius: 4px;
  font-size: var(--text-xs);
  color: var(--ink-mid);
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bubble--mine .bubble__quoted {
  background: rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.78);
  border-left-color: rgba(255, 255, 255, 0.35);
}

/* Bubble is the long-press / contextmenu target. Suppress the
 * iOS text-select callout so a long press opens the menu rather
 * than selecting text; desktop text-select still works via a
 * normal drag (touchstart-timer only, no mouse handler).
 *
 * user-select: text on the body nodes lets the user still select
 * text inside a bubble with a regular click-drag on desktop. */
.bubble {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}
.bubble__body,
.bubble__quoted { -webkit-user-select: text; user-select: text; }

/* Long-press / right-click context menu for a bubble. Backdrop
 * dims and closes on tap; inner panel is either a bottom sheet
 * (mobile) or an anchored tooltip near the cursor (desktop). */
.message-menu-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.28);
  z-index: 9500;
  animation: menu-backdrop-in 160ms var(--ease);
}
@keyframes menu-backdrop-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.message-menu {
  background: var(--paper-raised);
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  box-shadow: 0 18px 36px rgba(0, 0, 0, 0.18);
  padding: var(--space-2);
  min-width: 220px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  /* Long-press on the triggering bubble fires our JS timer and the
   * browser's native "start text selection" heuristic in parallel.
   * By the time the menu paints under the finger, the browser has
   * already grabbed a range inside the menu's first row. Opting
   * the menu out of user-select suppresses that entirely. */
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  user-select: none;
}

.message-menu--sheet {
  position: fixed;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  width: min(420px, calc(100% - 32px));
  padding-bottom: calc(var(--space-2) + env(safe-area-inset-bottom));
  animation: menu-sheet-in 180ms var(--ease);
}
@keyframes menu-sheet-in {
  from { transform: translate(-50%, 16px); opacity: 0; }
  to   { transform: translate(-50%, 0);    opacity: 1; }
}

.message-menu--anchored {
  position: fixed;
  /* top/left/transform are set inline per cursor position. */
  animation: menu-anchored-in 140ms var(--ease);
}
@keyframes menu-anchored-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.message-menu__row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-3) var(--space-4);
  background: transparent;
  border: 0;
  border-radius: var(--radius);
  text-align: left;
  font: inherit;
  color: var(--ink);
  cursor: pointer;
  transition: background 120ms var(--ease), color 120ms var(--ease);
}
.message-menu__row:hover { background: var(--rule-soft); }
.message-menu__row:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.message-menu__row--danger { color: var(--err); }
.message-menu__row--danger:hover {
  background: #fff1ef;
  color: var(--err);
}
.message-menu__icon {
  width: 20px;
  text-align: center;
  font-size: 15px;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-mid);
}
.message-menu__row--danger .message-menu__icon {
  color: var(--err);
}
.message-menu__icon .feather {
  display: block;
}
.message-menu__label {
  font-size: var(--text-base);
}

/* Forward-target picker (modal over the conversation). Inherits the
 * existing .modal overlay treatment; adds a scrollable list of
 * targets with a preview of the message being forwarded. */
.forward-picker__preview {
  margin: 0 0 var(--space-3);
  padding: var(--space-2) var(--space-3);
  background: var(--paper);
  border: 1px solid var(--rule);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  font-size: var(--text-sm);
  color: var(--ink-mid);
  line-height: 1.35;
  max-height: 5.4em;
  overflow: hidden;
  text-overflow: ellipsis;
}
.forward-picker__list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 320px;
  overflow-y: auto;
  margin: 0 calc(var(--space-3) * -1);
  padding: 0 var(--space-3);
}
.forward-picker__row {
  display: block;
  width: 100%;
  text-align: left;
  padding: var(--space-3) var(--space-4);
  background: var(--paper-raised);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
  transition: border-color 120ms var(--ease), background 120ms var(--ease);
}
.forward-picker__row:hover {
  border-color: var(--accent);
  background: var(--accent-tint);
}
.forward-picker__empty {
  margin: 0 0 var(--space-3);
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  color: var(--muted);
  text-align: center;
}

/* ------ Danger zone (Settings tab) ------------------------- */

.danger-zone {
  margin-top: var(--space-5);
  padding: var(--space-4) var(--space-5);
  background: #fff6f4;
  border: 1px solid var(--accent-rule);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.danger-zone--confirm {
  background: #fff1ef;
}
.danger-zone__heading {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: var(--text-md);
  letter-spacing: -0.005em;
  color: var(--err);
}
.danger-zone__lede {
  margin: 0;
  color: var(--ink-mid);
  font-size: var(--text-sm);
  line-height: 1.55;
}
.danger-zone__bullets {
  margin: 0;
  padding-left: var(--space-5);
  color: var(--ink);
  font-size: var(--text-sm);
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.danger-zone__orphans {
  margin: 0;
  padding: var(--space-3) var(--space-4);
  background: #fff8ee;
  border: 1px solid #f0d7a6;
  border-radius: var(--radius);
  color: #6e4b10;
  font-size: var(--text-sm);
  line-height: 1.5;
  font-family: var(--font-display);
  font-style: italic;
}
.danger-zone__busy {
  color: var(--muted);
  font-size: var(--text-sm);
  font-style: italic;
}
.danger-zone__error {
  margin: 0;
  color: var(--err);
  font-size: var(--text-sm);
  font-family: var(--font-display);
  font-style: italic;
}

.btn--danger-outline {
  flex: 0 0 auto;
  align-self: flex-start;
  background: transparent;
  color: var(--err);
  border: 1px solid var(--accent-rule);
}
.btn--danger-outline:hover:not(:disabled) {
  background: var(--err);
  color: var(--paper-raised);
  border-color: var(--err);
}
.btn--danger-outline:active:not(:disabled) { transform: scale(0.99); }

/* ------ Theme picker (Settings tab) ------------------------ */

.theme-picker {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-4) 0;
}
.theme-picker__label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.theme-picker__swatches {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
}
.theme-swatch {
  appearance: none;
  border: 2px solid var(--rule);
  width: 36px;
  height: 36px;
  border-radius: 999px;
  padding: 0;
  cursor: pointer;
  transition: transform 120ms var(--ease), border-color 120ms var(--ease),
    box-shadow 120ms var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.theme-swatch:hover {
  transform: scale(1.08);
  border-color: var(--ink-mid);
}
.theme-swatch--active {
  border-color: var(--ink);
  box-shadow: 0 0 0 2px var(--paper), 0 0 0 4px var(--ink);
}
/* Fill colour per preview — does NOT apply data-theme, so these
 * swatches keep showing their own colour regardless of the active
 * theme on .app. */
.theme-swatch[data-theme-preview="terracotta"] { background: #c25a3a; }
.theme-swatch[data-theme-preview="teal"]       { background: #1e8b8b; }
.theme-swatch[data-theme-preview="indigo"]     { background: #5b4bbf; }
.theme-swatch[data-theme-preview="moss"]       { background: #5d7a3f; }
.theme-swatch[data-theme-preview="rose"]       { background: #c24669; }
.theme-swatch[data-theme-preview="amber"]      { background: #c28a1e; }

/* ------ Landing / marketing homepage -------------------- */

.step--landing {
  gap: var(--space-5);
}
.landing__title {
  font-size: 36px;
  line-height: 1.08;
  letter-spacing: -0.025em;
  max-width: 18ch;
}
.landing__lede {
  font-size: var(--text-md);
  max-width: 44ch;
}
.landing__features {
  list-style: none;
  padding: 0;
  margin: var(--space-2) 0 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  font-size: var(--text-sm);
  color: var(--ink-mid);
  line-height: 1.45;
  max-width: 48ch;
}
.landing__features li {
  padding-left: var(--space-4);
  position: relative;
}
.landing__features li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.55em;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}
.landing__actions {
  margin-top: var(--space-3);
}

/* ------ Settings: legal links (settings-native list) ---- */
.settings-legal {
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  margin: var(--space-4) 0;
}
.settings-legal__row {
  padding: 14px 2px;
  border-bottom: 1px solid var(--rule-soft);
  color: var(--ink);
  text-decoration: none;
  font-size: var(--text-base);
  transition: color 120ms var(--ease);
}
.settings-legal__row:last-child { border-bottom: 0; }
.settings-legal__row:hover { color: var(--accent); }

/* ------ Outlined button (used for Sign out in Settings) - */
.btn--outline {
  flex: 1;
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--rule);
}
.btn--outline:hover:not(:disabled) {
  border-color: var(--ink-mid);
  background: var(--rule-soft);
}
.btn--outline:active:not(:disabled) { transform: scale(0.99); }

/* ------ Lang-switcher pipe: make it visible --------------- */
/* The prior `color: var(--rule)` was too pale to register. */

/* ------ Tab content vertical rhythm ---------------------- */
.tab {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

/* ------ Landing: let text use the column width ---------- */
.landing__title { max-width: none; }
.landing__lede { max-width: none; }
.landing__features { max-width: none; }

/* Static-page back link — sits above the heading so visitors who
 * landed on /about /privacy /security /legal can get out without
 * hitting the browser back button (and signed-in users navigating
 * from Settings don't get stranded there). */
.static__back {
  display: inline-block;
  margin-bottom: var(--space-3);
  font-size: var(--text-sm);
  color: var(--muted);
  text-decoration: none;
  transition: color 120ms var(--ease);
}
.static__back:hover { color: var(--accent); }

/* ------ PWA install CTA (Settings tab) --------------------- */

.install-cta {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-4);
  margin-bottom: var(--space-4);
  background: var(--accent-tint);
  border: 1px solid var(--accent-rule);
  border-radius: var(--radius);
}
.install-cta__body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.install-cta__title {
  font-family: var(--font-display);
  font-size: var(--text-md);
  font-weight: 600;
  color: var(--accent-deep);
}
.install-cta__lede {
  font-size: var(--text-sm);
  color: var(--ink-mid);
  line-height: 1.45;
}

/* ------ Change-passphrase card (Settings tab) --------------
 * Neutral card vs .install-cta's accent-tint nudge. Same rhythm:
 * title + action in a row when collapsed; when expanded (the
 * form), the fields stack below the heading. Kept understated
 * on purpose — password change is an infrequent, deliberate
 * action and shouldn't out-scream the install CTA.
 */
.change-pass {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-4);
  margin-bottom: var(--space-4);
  background: var(--paper-raised);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
}
.change-pass:not(.change-pass--editing) {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}
.change-pass__heading {
  font-family: var(--font-display);
  font-size: var(--text-md);
  font-weight: 600;
  color: var(--ink);
  flex: 1;
  min-width: 0;
}
.change-pass .btn--compact {
  flex: 0 0 auto;
}
.change-pass--editing {
  gap: var(--space-4);
}
.change-pass--editing .change-pass__heading {
  font-size: var(--text-lg);
}
.change-pass__meta {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--muted);
  line-height: 1.5;
}
.change-pass__error {
  margin: 0;
  padding: var(--space-3);
  background: rgba(164, 52, 40, 0.08);
  border-left: 2px solid var(--err);
  color: var(--err);
  font-size: var(--text-sm);
  border-radius: 4px;
}
.change-pass__busy {
  font-size: var(--text-sm);
  color: var(--muted);
  font-style: italic;
}
.change-pass--ok {
  border-color: var(--ok-rule);
  background: var(--ok-tint);
}
.change-pass--ok .change-pass__heading {
  color: var(--ok);
}

/* ------ Settings tab: list + sub-pages -----------------------
 * Two-level navigation. The root is a compact list of five
 * entries (Profile, Sign-in & security, Appearance, About,
 * Danger zone); tapping opens a full-screen sub-page with its
 * own back header. Keeps the root tight instead of stacking
 * every control in one long scroll.
 */
.settings-list {
  list-style: none;
  margin: var(--space-4) 0 0 0;
  padding: 0;
  background: var(--paper-raised);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  overflow: hidden;
}
.settings-list__item {
  border-bottom: 1px solid var(--rule);
}
.settings-list__item:last-child {
  border-bottom: 0;
}
.settings-list__button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-4);
  background: transparent;
  border: 0;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 140ms var(--ease);
}
.settings-list__button:hover {
  background: rgba(31, 27, 22, 0.03);
}
.settings-list__button:active {
  background: var(--accent-tint);
}
.settings-list__label {
  font-family: var(--font-display);
  font-size: var(--text-md);
  font-weight: 500;
  color: var(--ink);
}
.settings-list__chevron {
  font-size: 20px;
  color: var(--muted);
  line-height: 1;
}

/* Sub-page chrome. Header has a back button on the left, the
 * page title centred, and a spacer on the right to keep the
 * title visually centred regardless of back-button width. Body
 * inherits the old .tab--settings layout so existing cards
 * (passkey, passphrase, sessions, theme, etc.) drop in unchanged.
 */
.tab--settings-sub {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}
.settings-sub__header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--rule);
}
.settings-sub__back {
  flex: 0 0 auto;
  padding: 6px 10px;
}
.settings-sub__title {
  flex: 1;
  text-align: center;
  font-family: var(--font-display);
  font-size: var(--text-md);
  font-weight: 500;
  color: var(--ink);
}
.settings-sub__spacer {
  flex: 0 0 auto;
  /* Match the back-button width approximately so the title
   * stays visually centred. Not pixel-perfect but good enough. */
  width: 60px;
}
.settings-sub__body {
  display: flex;
  flex-direction: column;
}

/* Sign out lives on the Settings root bottom — it's routine, not
 * destructive, so it doesn't belong in Danger Zone. */
.settings-root__signout {
  margin-top: var(--space-5);
  display: flex;
  justify-content: center;
}
.settings-root__signout .btn--outline {
  flex: 0 0 auto;
  padding: 10px 24px;
}

/* Generic modal / overlay pattern — reused by the iOS install
 * modal and available for future modals. Tap outside the .modal
 * body dismisses; body-level click is stopped from propagating
 * in the Elm handler. */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(31, 27, 22, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  z-index: 100;
  animation: fadeIn 140ms var(--ease);
}
.modal {
  width: 100%;
  max-width: 420px;
  background: var(--paper-raised);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  box-shadow: 0 12px 40px rgba(31, 27, 22, 0.25);
  animation: fadeInUp 180ms var(--ease);
}
.modal__title {
  margin: 0;
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.install-ios-steps {
  margin: 0;
  padding-left: 1.2em;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  color: var(--ink-mid);
  font-size: var(--text-sm);
  line-height: 1.5;
}

/* ============================================================
   Onboarding — editorial warm minimalism
   Overrides the generic .step chrome on the four onboarding
   views (welcome, identity, recovery, working). Uses
   chapter-marker numerals, sigil role cards, underline-style
   fields, and a stamped recovery tile with the 絆 seal.
   ============================================================ */

.onb {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  animation: none; /* children own the motion */
}

.onb-head {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  animation: onb-rise 520ms var(--ease) both;
  animation-delay: 40ms;
}

/* ------ Chapter marker ----------------------------------- */

.onb-chapter {
  display: flex;
  align-items: baseline;
  gap: 10px;
  color: var(--muted);
  font-feature-settings: "tnum", "kern";
  margin-bottom: -4px;
}
.onb-chapter__num {
  font-family: var(--font-display);
  font-size: 44px;
  font-weight: 200;
  line-height: 0.9;
  letter-spacing: -0.04em;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.onb-chapter__slash {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 200;
  line-height: 1;
  color: var(--rule);
  transform: translateY(-2px);
}
.onb-chapter__total {
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
  transform: translateY(-4px);
}

/* ------ Title / lede ------------------------------------- */

.onb-title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 34px;
  letter-spacing: -0.028em;
  line-height: 1.08;
  margin: 0;
  color: var(--ink);
  max-width: 16ch;
  font-feature-settings: "kern";
  text-wrap: balance;
}

.onb-lede {
  margin: 0;
  color: var(--ink-mid);
  font-size: var(--text-md);
  line-height: 1.55;
  max-width: 38ch;
  font-weight: 300;
  text-wrap: pretty;
}

/* ------ Role selection (welcome) ------------------------- */

.onb-roles {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-top: var(--space-1);
}

.onb-role {
  position: relative;
  display: grid;
  grid-template-columns: 60px 1fr;
  gap: var(--space-4);
  align-items: center;
  padding: var(--space-4) var(--space-5);
  background: var(--paper-raised);
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition:
    border-color 220ms var(--ease),
    background 220ms var(--ease),
    transform 180ms var(--ease),
    box-shadow 220ms var(--ease);
  animation: onb-rise 560ms var(--ease) both;
  overflow: hidden;
}
.onb-role::before {
  /* quiet decorative corner tick */
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 36px;
  height: 36px;
  background:
    linear-gradient(225deg, var(--rule-soft) 0%, transparent 55%);
  opacity: 0;
  transition: opacity 240ms var(--ease);
  pointer-events: none;
}
.onb-role:nth-of-type(1) { animation-delay: 180ms; }
.onb-role:nth-of-type(2) { animation-delay: 260ms; }
.onb-role:hover {
  border-color: var(--ink-mid);
  transform: translateY(-1px);
}
.onb-role:hover::before { opacity: 0.7; }
.onb-role:active { transform: scale(0.995); }
.onb-role:focus-within {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}
.onb-role__input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}

/* --- Sigils (pure CSS, no external assets) --- */

.onb-role__sigil {
  width: 58px;
  height: 58px;
  position: relative;
  border-radius: 50%;
  border: 1.5px solid var(--rule);
  background: var(--paper-warm);
  transition: border-color 240ms var(--ease), background 240ms var(--ease);
}
.onb-role__sigil::before,
.onb-role__sigil::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  border-radius: 50%;
  transition: all 240ms var(--ease);
}
/* Parent: two overlapping circles — family / guardianship */
.onb-role--parent .onb-role__sigil::before {
  width: 18px;
  height: 18px;
  background: var(--ink);
  transform: translate(calc(-50% - 7px), calc(-50% - 3px));
}
.onb-role--parent .onb-role__sigil::after {
  width: 12px;
  height: 12px;
  background: var(--ink-mid);
  transform: translate(calc(-50% + 6px), calc(-50% + 5px));
}
/* Kid: large circle with an orbital spark */
.onb-role--kid .onb-role__sigil::before {
  width: 20px;
  height: 20px;
  background: var(--ink);
  transform: translate(-50%, -50%);
}
.onb-role--kid .onb-role__sigil::after {
  width: 6px;
  height: 6px;
  background: var(--accent);
  transform: translate(calc(-50% + 14px), calc(-50% - 10px));
}

.onb-role__body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.onb-role__title {
  font-family: var(--font-display);
  font-size: var(--text-md);
  font-weight: 500;
  letter-spacing: -0.005em;
  color: var(--ink);
}
.onb-role__desc {
  font-size: var(--text-sm);
  color: var(--muted);
  line-height: 1.5;
}

/* --- Selected --- */

.onb-role--selected {
  border-color: var(--accent);
  background: var(--accent-tint);
  box-shadow: 0 1px 0 0 var(--accent-rule), 0 10px 24px -18px rgba(194, 90, 58, 0.4);
}
.onb-role--selected::before { opacity: 1; }
.onb-role--selected .onb-role__sigil {
  border-color: var(--accent);
  background: var(--paper-raised);
}
.onb-role--selected.onb-role--parent .onb-role__sigil::before { background: var(--accent-deep); }
.onb-role--selected.onb-role--parent .onb-role__sigil::after  { background: var(--accent); }
.onb-role--selected.onb-role--kid .onb-role__sigil::before    { background: var(--accent-deep); }
.onb-role--selected.onb-role--kid .onb-role__sigil::after     { background: var(--ink); }

/* ------ Fields (identity) -------------------------------- */

.onb-fields {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  margin-top: var(--space-2);
}
.onb-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  animation: onb-rise 560ms var(--ease) both;
}
.onb-field:nth-of-type(1) { animation-delay: 180ms; }
.onb-field:nth-of-type(2) { animation-delay: 240ms; }
.onb-field:nth-of-type(3) { animation-delay: 300ms; }
.onb-field__label {
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}
.onb-input {
  width: 100%;
  padding: 10px 2px 12px;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--rule);
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 400;
  letter-spacing: -0.005em;
  color: var(--ink);
  line-height: 1.2;
  appearance: none;
  -webkit-appearance: none;
  border-radius: 0;
  transition:
    border-color 220ms var(--ease),
    box-shadow 220ms var(--ease);
}
.onb-input::placeholder {
  color: var(--rule);
  font-style: italic;
  font-weight: 300;
  letter-spacing: 0;
}
.onb-input:hover { border-color: var(--ink-mid); }
.onb-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 1px 0 0 var(--accent);
}
/* Autofill in webkit: keep warm paper background */
.onb-input:-webkit-autofill,
.onb-input:-webkit-autofill:hover,
.onb-input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--ink);
  -webkit-box-shadow: 0 0 0 1000px var(--paper) inset;
  caret-color: var(--ink);
  transition: background-color 9999s;
}
.onb-field__hint {
  font-family: var(--font-display);
  font-style: italic;
  font-size: var(--text-xs);
  color: var(--muted);
  line-height: 1.55;
  margin-top: 2px;
}

/* ------ Actions ------------------------------------------ */

.onb-actions {
  display: flex;
  gap: var(--space-3);
  margin-top: var(--space-4);
  align-items: center;
  justify-content: space-between;
  animation: onb-rise 560ms var(--ease) both;
  animation-delay: 360ms;
}
.onb-actions--single { justify-content: stretch; }
.onb-actions--single .onb-btn { flex: 1; }

.onb-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 16px 24px;
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: 500;
  line-height: 1;
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition:
    transform 140ms var(--ease),
    background 200ms var(--ease),
    color 200ms var(--ease),
    box-shadow 240ms var(--ease),
    border-color 200ms var(--ease);
  letter-spacing: 0.01em;
  -webkit-appearance: none;
  appearance: none;
}
.onb-btn:focus { outline: none; }
.onb-btn:focus-visible {
  box-shadow: 0 0 0 3px var(--accent-tint);
}
.onb-btn:disabled {
  cursor: not-allowed;
  opacity: 0.35;
}
.onb-btn--primary {
  flex: 1;
  background: var(--ink);
  color: var(--paper-raised);
  box-shadow: 0 2px 0 0 rgba(31, 27, 22, 0.12);
}
.onb-btn--primary::after {
  content: "→";
  font-size: 18px;
  font-weight: 300;
  transition: transform 240ms var(--ease);
}
.onb-btn--primary:hover:not(:disabled) {
  background: var(--accent-deep);
  box-shadow: 0 4px 0 0 rgba(155, 69, 41, 0.18);
  transform: translateY(-1px);
}
.onb-btn--primary:hover:not(:disabled)::after {
  transform: translateX(4px);
}
.onb-btn--primary:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: 0 1px 0 0 rgba(31, 27, 22, 0.12);
}

/* Same shape as --primary but without the → arrow and without
 * the translate-on-hover. For ceremonial commits (Save /
 * Confirm / Delete) where "moving forward" isn't the right
 * semantic — we're committing an action, not advancing through
 * a flow. Picked out of a three-way decision logged in #116. */
.onb-btn--commit {
  flex: 1;
  background: var(--ink);
  color: var(--paper-raised);
  box-shadow: 0 2px 0 0 rgba(31, 27, 22, 0.12);
}
.onb-btn--commit:hover:not(:disabled) {
  background: var(--accent-deep);
  box-shadow: 0 4px 0 0 rgba(155, 69, 41, 0.18);
}
.onb-btn--commit:active:not(:disabled) {
  transform: scale(0.99);
  box-shadow: 0 1px 0 0 rgba(31, 27, 22, 0.12);
}
.onb-btn--commit--danger {
  background: var(--err);
}
.onb-btn--commit--danger:hover:not(:disabled) {
  background: #87271d;
}

.onb-btn--ghost {
  background: transparent;
  color: var(--muted);
  padding: 16px var(--space-3);
  font-size: var(--text-sm);
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.onb-btn--ghost:hover:not(:disabled) {
  color: var(--ink);
}

/* ------ Footnote ----------------------------------------- */

.onb-footnote {
  margin-top: var(--space-4);
  text-align: center;
  color: var(--muted);
  font-size: var(--text-sm);
  font-family: var(--font-display);
  font-style: italic;
  animation: onb-rise 560ms var(--ease) both;
  animation-delay: 440ms;
}

/* Passkey-unlock CTA on welcome + sign-in. A prominent button
 * using the warm accent so it reads as a first-class affordance,
 * not a hidden link. Hidden entirely when the device can't do
 * platform passkeys (isUserVerifyingPlatformAuthenticatorAvailable
 * returned false) — the Elm view renders nothing in that case.
 *
 * A thin "or" divider separates the passkey path from the
 * password path below, so the visual grammar is: "try this fast
 * thing, OR fall through to the slow thing." */
.onb-passkey-cta {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  margin-top: var(--space-2);
  margin-bottom: var(--space-2);
  animation: onb-rise 560ms var(--ease) both;
  animation-delay: 140ms;
}
.onb-btn--passkey {
  flex: 1;
  background: var(--paper-raised);
  color: var(--ink);
  border: 1.5px solid var(--accent);
  box-shadow: 0 2px 0 0 var(--accent-rule);
  padding: 16px 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-weight: 500;
}
.onb-btn--passkey:hover:not(:disabled) {
  background: var(--accent-tint);
  box-shadow: 0 4px 0 0 var(--accent-rule);
  transform: translateY(-1px);
}
.onb-btn--passkey:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: 0 1px 0 0 var(--accent-rule);
}
.onb-btn--passkey svg {
  width: 20px;
  height: 20px;
  color: var(--accent-deep);
}
.onb-passkey-cta__divider {
  position: relative;
  text-align: center;
  color: var(--muted);
  font-family: var(--font-display);
  font-style: italic;
  font-size: var(--text-xs);
  letter-spacing: 0.02em;
}
.onb-passkey-cta__divider::before,
.onb-passkey-cta__divider::after {
  content: "";
  position: absolute;
  top: 50%;
  width: calc(50% - 20px);
  height: 1px;
  background: var(--rule);
}
.onb-passkey-cta__divider::before {
  left: 0;
}
.onb-passkey-cta__divider::after {
  right: 0;
}
.onb-passkey-cta__divider span {
  background: var(--paper);
  padding: 0 var(--space-3);
  position: relative;
  z-index: 1;
}
.onb-link {
  color: var(--accent);
  text-decoration: none;
  font-style: normal;
  font-weight: 600;
  border-bottom: 1px solid var(--accent-rule);
  padding-bottom: 1px;
  transition: color 200ms var(--ease), border-color 200ms var(--ease);
}
.onb-link:hover {
  color: var(--accent-deep);
  border-color: var(--accent-deep);
}

/* ------ Recovery code tile ------------------------------- */

.onb-code {
  position: relative;
  margin: var(--space-3) 0 var(--space-2);
  padding: var(--space-6) var(--space-5) var(--space-6);
  background:
    linear-gradient(180deg, var(--paper-raised) 0%, var(--paper-raised) 100%);
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  box-shadow:
    0 1px 0 0 var(--rule-soft),
    0 30px 50px -30px rgba(31, 27, 22, 0.18);
  animation: onb-code-reveal 760ms var(--ease);
  overflow: hidden;
  isolation: isolate;
}
.onb-code::before {
  /* inner ticket border (dashed) */
  content: "";
  position: absolute;
  inset: 10px;
  border: 1px dashed var(--rule);
  border-radius: calc(var(--radius-lg) - 4px);
  pointer-events: none;
  z-index: 0;
}
.onb-code::after {
  /* warm radial wash in the top-right corner */
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 92% 0%, var(--accent-tint) 0%, transparent 42%);
  opacity: 0.65;
  pointer-events: none;
  z-index: 0;
}
.onb-code__mark {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 500;
  color: var(--accent);
  border: 1.5px solid var(--accent);
  border-radius: 50%;
  background: var(--paper-raised);
  z-index: 2;
  transform: rotate(-8deg);
  box-shadow: 0 3px 8px rgba(194, 90, 58, 0.18);
  line-height: 1;
  letter-spacing: 0;
}
.onb-code__label {
  position: relative;
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: var(--space-3);
  padding-right: 56px; /* clear the seal */
  z-index: 1;
}
.onb-code__value {
  position: relative;
  font-family: var(--font-mono);
  font-size: 19px;
  line-height: 1.75;
  letter-spacing: 0.12em;
  color: var(--ink);
  text-align: left;
  word-break: break-all;
  user-select: all;
  z-index: 1;
  font-variant-ligatures: none;
}

.onb-fine {
  margin: 0;
  color: var(--muted);
  font-size: var(--text-sm);
  line-height: 1.6;
  max-width: 42ch;
  font-family: var(--font-display);
  font-style: italic;
  animation: onb-rise 560ms var(--ease) both;
  animation-delay: 320ms;
}

/* ------ Working / finalising ----------------------------- */

.onb .onb-working {
  padding: var(--space-9) 0 var(--space-8);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-5);
  text-align: center;
  position: relative;
}
.onb-working__mark {
  font-family: var(--font-display);
  font-size: 80px;
  line-height: 1;
  color: var(--accent);
  font-weight: 300;
  animation: onb-breath 2600ms var(--ease) infinite;
  position: relative;
  z-index: 2;
}
.onb-working__ring {
  position: absolute;
  top: calc(50% - 38px);
  left: 50%;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  border: 1px solid var(--accent-rule);
  transform: translate(-50%, -50%);
  z-index: 1;
  animation: onb-ring 2600ms var(--ease) infinite;
}
.onb-working__copy {
  margin: 0;
  color: var(--ink-mid);
  font-family: var(--font-display);
  font-style: italic;
  font-size: var(--text-md);
  letter-spacing: 0.005em;
  max-width: 30ch;
  position: relative;
  z-index: 2;
}

/* ------ Animations --------------------------------------- */

@keyframes onb-rise {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes onb-code-reveal {
  0%   { opacity: 0; transform: scale(0.96) translateY(6px); }
  60%  { opacity: 1; }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes onb-breath {
  0%, 100% { opacity: 0.6; transform: scale(1); }
  50%      { opacity: 1;   transform: scale(1.06); }
}
@keyframes onb-ring {
  0%, 100% { opacity: 0.4; transform: translate(-50%, -50%) scale(0.9); }
  50%      { opacity: 0;   transform: translate(-50%, -50%) scale(1.25); }
}

/* ------ Responsive --------------------------------------- */

@media (min-width: 540px) {
  .onb-title { font-size: 42px; max-width: 18ch; }
  .onb-chapter__num { font-size: 56px; }
  .onb-chapter__slash { font-size: 32px; }
  .onb-input { font-size: 24px; }
  .onb-code__value { font-size: 22px; }
  .onb-code__mark { width: 58px; height: 58px; font-size: 36px; }
}

@media (min-width: 720px) {
  .onb { gap: var(--space-7); }
  .onb-title { font-size: 56px; letter-spacing: -0.03em; }
  .onb-chapter__num { font-size: 68px; }
  .onb-lede { font-size: 20px; max-width: 44ch; }
  .onb-roles { flex-direction: row; }
  .onb-roles .onb-role { flex: 1; align-items: flex-start; padding: var(--space-5); }
  .onb-code { padding: var(--space-7) var(--space-6) var(--space-7); }
  .onb-code__value { font-size: 24px; }
  .onb-working__mark { font-size: 96px; }
  .onb-working__ring { width: 170px; height: 170px; }
}

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

@media (prefers-reduced-motion: reduce) {
  .onb-head,
  .onb-role,
  .onb-field,
  .onb-actions,
  .onb-fine,
  .onb-footnote,
  .onb-code,
  .onb-working__mark,
  .onb-working__ring { animation: none !important; }
}

/* ============================================================
   Chat list — layout B (compact, iMessage/WhatsApp dense)
   Replaces the old framed-rounded .contact-row block for the
   main chats-tab and the guarded-tab lists. Dense single-line
   rows: small circular avatar, name row with inline pill /
   unread, last-message preview underneath. Not used for
   waiting-pair / revokable rows — those stay on .contact-row.
   ============================================================ */

.chats {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.chats + .chats { margin-top: var(--space-4); }
.chats__heading {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0 4px;
}

.chat-list {
  display: flex;
  flex-direction: column;
  /* no frame — layout B uses 1-px bottom-rules between rows */
}

.chat-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 4px;
  width: 100%;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--rule-soft);
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 140ms var(--ease);
  border-radius: 6px;
}
.chat-row:last-child { border-bottom: 0; }
.chat-row:hover { background: rgba(31, 27, 22, 0.03); }
.chat-row:active { background: var(--accent-tint); }
.chat-row:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--accent-tint);
}

.chat-row__avatar {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--accent-tint);
  color: var(--accent-deep);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 16px;
  letter-spacing: 0.01em;
  border: 1px solid var(--accent-rule);
  user-select: none;
}
/* Group avatars read as a distinct slot: warm paper fill, muted */
.chat-row__avatar--group {
  background: var(--paper-warm);
  color: var(--ink-mid);
  border-color: var(--rule);
  font-style: italic;
}

.chat-row__body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chat-row__head {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
}
.chat-row__name {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: -0.005em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.chat-row__time {
  flex: 0 0 auto;
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 400;
  color: var(--muted);
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.chat-row__preview {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.chat-row__pill {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  line-height: 1.6;
  border-radius: 999px;
  border: 1px solid var(--rule);
  color: var(--muted);
  background: var(--paper-warm);
}
.chat-row__pill--family {
  color: var(--accent-deep);
  border-color: var(--accent-rule);
  background: var(--accent-tint);
}

.chat-row__unread {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 7px;
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  color: var(--paper-raised);
  background: var(--accent);
  border-radius: 999px;
  letter-spacing: 0.01em;
  box-shadow: 0 1px 2px rgba(194, 90, 58, 0.35);
}

@media (min-width: 540px) {
  .chat-row { padding: 12px 6px; gap: 14px; }
  .chat-row__avatar { width: 48px; height: 48px; font-size: 17px; }
  .chat-row__name { font-size: 16px; }
  .chat-row__preview { font-size: 14px; }
}

/* ============================================================
   Reactions — aggregated pills under each bubble + quick-pick
   bar at the top of the context menu.
   ============================================================ */

.reactions-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
  max-width: 80%;
}
.bubble-row:has(.bubble--mine) .reactions-strip {
  justify-content: flex-end;
  margin-left: auto;
}

.reaction-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  min-height: 22px;
  font-size: 13px;
  line-height: 1;
  font-family: var(--font-body);
  background: var(--paper-raised);
  color: var(--ink);
  border: 1px solid var(--rule);
  border-radius: 999px;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition:
    background 160ms var(--ease),
    border-color 160ms var(--ease),
    color 160ms var(--ease),
    transform 120ms var(--ease);
}
.reaction-pill:hover {
  border-color: var(--ink-mid);
}
.reaction-pill:active {
  transform: scale(0.94);
}
.reaction-pill__emoji {
  font-size: 14px;
  line-height: 1;
}
.reaction-pill__count {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.reaction-pill--mine {
  background: var(--accent-tint);
  border-color: var(--accent-rule);
  color: var(--accent-deep);
}
.reaction-pill--mine .reaction-pill__count {
  color: var(--accent-deep);
}

/* Quick-pick bar lives at the top of the message context menu —
 * above the Reply / Forward / Copy / Delete rows. Horizontal flex
 * of emoji buttons with generous tap targets. */
.reaction-bar {
  display: flex;
  gap: 4px;
  padding: 6px 8px 10px;
  border-bottom: 1px solid var(--rule-soft);
  margin-bottom: 4px;
  justify-content: space-around;
}
.reaction-bar__btn {
  flex: 1;
  min-height: 40px;
  font-size: 22px;
  line-height: 1;
  background: transparent;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition:
    background 160ms var(--ease),
    transform 120ms var(--ease);
}
.reaction-bar__btn:hover {
  background: var(--rule-soft);
}
.reaction-bar__btn:active {
  transform: scale(0.9);
}


/* Full-emoji-picker overlay scoped to the reaction flow. Sits on
 * top of the conversation as a sheet; the existing
 * .emoji-picker CSS inside renders the catalog, tabs, search.
 * Tap the backdrop (or any non-picker area) to dismiss. */
.reaction-picker-overlay {
  position: fixed;
  inset: 0;
  background: rgba(31, 27, 22, 0.35);
  z-index: 210;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fadeIn 160ms var(--ease);
}
.reaction-picker-sheet {
  width: 100%;
  max-width: 560px;
  max-height: 70vh;
  background: var(--paper-raised);
  border-top-left-radius: var(--radius-lg);
  border-top-right-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 -10px 40px -10px rgba(31, 27, 22, 0.2);
  animation: slideUp 220ms var(--ease);
}
.reaction-picker-sheet .emoji-picker {
  border-top: 0;
  max-height: 70vh;
  min-height: 320px;
}
@keyframes slideUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}
.reaction-bar__btn--more {
  font-size: 22px;
  font-weight: 300;
  color: var(--muted);
  line-height: 1;
}
/* Give the strip full row width so .bubble-row align-items pins
 * it to the correct side under the bubble. */
.reactions-strip {
  width: auto;
}


/* Suppress text selection / iOS tap-and-hold callout on all
 * interactive controls. The long-press-to-context-menu gesture
 * on message bubbles was bleeding into whatever button the user
 * happened to be pressing — notably the compose Send button. */
button,
.btn,
.onb-btn,
.compose__emoji,
.compose__image-btn,
.reaction-bar__btn,
.reaction-pill,
.chat-row,
.tabbar__btn,
.lang-switcher__opt,
.theme-swatch {
  -webkit-user-select: none;
  -moz-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}


/* ============================================================
   Forward-target picker — layout F (alphabet-sectioned list
   with tiny avatars + sticky letter headers). Multi-select via
   per-row tap; the Forward-to-N button at the bottom commits.
   Rebuilt in-place; the older flat-list rules above still drive
   the preview strip and empty-state.
   ============================================================ */

.forward-picker-overlay {
  align-items: stretch;
}
.forward-picker {
  display: flex;
  flex-direction: column;
  max-height: 90vh;
  padding: 0;
  overflow: hidden;
}
.forward-picker__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5) var(--space-2);
}
.forward-picker__title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 500;
  margin: 0;
  letter-spacing: -0.01em;
}
.forward-picker__close {
  background: transparent;
  border: 0;
  padding: 4px 10px;
  font-size: 26px;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  border-radius: 999px;
}
.forward-picker__close:hover { color: var(--ink); background: var(--rule-soft); }

.forward-picker .forward-picker__preview {
  margin: 0 var(--space-5) var(--space-3);
}

.forward-picker__search {
  padding: 0 var(--space-5) var(--space-3);
}
.forward-picker__search-input {
  width: 100%;
  padding: 10px 14px;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  color: var(--ink);
  font: inherit;
  font-size: var(--text-sm);
  -webkit-appearance: none;
  appearance: none;
}
.forward-picker__search-input::placeholder { color: var(--muted); }
.forward-picker__search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}

.forward-picker__sections {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 0 var(--space-5) var(--space-3);
  min-height: 0;
}
.forward-picker__section {
  margin-bottom: var(--space-3);
}
.forward-picker__section-hd {
  position: sticky;
  top: 0;
  background: var(--paper-raised);
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 6px 2px;
  border-bottom: 1px solid var(--rule-soft);
  z-index: 1;
}
.forward-picker__rows {
  display: flex;
  flex-direction: column;
}

.forward-picker__row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 4px;
  width: 100%;
  background: transparent;
  border: 0;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  border-radius: 8px;
  -webkit-tap-highlight-color: transparent;
  transition: background 140ms var(--ease);
}
.forward-picker__row:hover { background: var(--rule-soft); }
.forward-picker__row--selected { background: var(--accent-tint); }
.forward-picker__row--selected:hover { background: var(--accent-tint); }

.forward-picker__avatar {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent-tint);
  color: var(--accent-deep);
  border: 1px solid var(--accent-rule);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 14px;
}
.forward-picker__avatar--group {
  background: var(--paper-warm);
  color: var(--ink-mid);
  border-color: var(--rule);
  font-style: italic;
}

.forward-picker__label {
  flex: 1;
  min-width: 0;
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: -0.005em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.forward-picker__check {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1.5px solid var(--rule);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  line-height: 1;
  color: transparent;
  transition: all 160ms var(--ease);
}
.forward-picker__check--on {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--paper-raised);
}

.forward-picker__footer {
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--rule);
  background: var(--paper-raised);
}
.forward-picker__submit {
  width: 100%;
}


/* Create-group picker (layout F) — reuses the forward picker
 * section/row chrome but lives inline in the create-group form
 * rather than as a modal. */
.create-group__picker {
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--paper-raised);
  overflow: hidden;
}
.create-group__search {
  padding: 8px 10px;
  border-bottom: 1px solid var(--rule-soft);
}
.create-group__search-input {
  width: 100%;
  padding: 8px 12px;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  color: var(--ink);
  font: inherit;
  font-size: var(--text-sm);
  -webkit-appearance: none;
  appearance: none;
}
.create-group__search-input::placeholder { color: var(--muted); }
.create-group__search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}
.create-group__sections {
  max-height: 340px;
  overflow-y: auto;
  padding: 4px 10px 10px;
}
.create-group__sections .forward-picker__section-hd {
  background: var(--paper-raised);
}
.create-group__members-field .create-group__selected-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}


/* Picker chip strip — a horizontally-flowing row of currently-
 * selected items pinned at the top of a picker. Tapping a chip
 * toggles the item off (mirrors the row tap behavior). */
.picker-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: var(--space-3) var(--space-5) var(--space-2);
  border-bottom: 1px solid var(--rule-soft);
}
.create-group__picker > .picker-chips {
  padding: 8px 10px;
}
.picker-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px 4px 4px;
  max-width: 180px;
  background: var(--accent-tint);
  color: var(--accent-deep);
  border: 1px solid var(--accent-rule);
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
  font-size: var(--text-sm);
  -webkit-tap-highlight-color: transparent;
  transition: background 140ms var(--ease);
}
.picker-chip:hover {
  background: #ffe6dc;
}
.picker-chip__avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--paper-raised);
  color: var(--accent-deep);
  border: 1px solid var(--accent-rule);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 10px;
  flex: 0 0 auto;
}
.picker-chip__avatar--group {
  background: var(--paper-warm);
  color: var(--ink-mid);
  border-color: var(--rule);
  font-style: italic;
}
.picker-chip__label {
  font-family: var(--font-display);
  font-weight: 500;
  letter-spacing: -0.005em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.picker-chip__remove {
  font-size: 16px;
  line-height: 1;
  opacity: 0.7;
  padding: 0 2px;
}
.picker-chip:hover .picker-chip__remove { opacity: 1; }


/* ============================================================
   Group settings — burger menu in the conv header opens a
   modal with editable group name, member list, and leave.
   ============================================================ */

.conv__burger {
  padding: 6px 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-mid);
}
.conv__burger:hover:not(:disabled) {
  color: var(--ink);
  background: var(--rule-soft);
}
.conv__burger .feather {
  width: 22px;
  height: 22px;
}

.group-settings-overlay {
  align-items: stretch;
}
.group-settings {
  display: flex;
  flex-direction: column;
  max-height: 90vh;
  padding: 0;
  overflow: hidden;
}
.group-settings__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5) var(--space-3);
  border-bottom: 1px solid var(--rule-soft);
}
.group-settings__title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 500;
  letter-spacing: -0.01em;
  margin: 0;
}
.group-settings__close {
  background: transparent;
  border: 0;
  padding: 4px 10px;
  font-size: 26px;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  border-radius: 999px;
}
.group-settings__close:hover {
  color: var(--ink);
  background: var(--rule-soft);
}
.group-settings__section {
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--rule-soft);
}
.group-settings__section:last-child {
  border-bottom: 0;
}
.group-settings__section-hd {
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: var(--space-2);
}

.group-settings__name-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-2) 0;
  background: transparent;
  border: 0;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.group-settings__name {
  font-family: var(--font-display);
  font-size: var(--text-md);
  font-weight: 500;
  color: var(--ink);
  letter-spacing: -0.005em;
}
.group-settings__edit-hint {
  color: var(--accent);
  font-size: var(--text-sm);
  font-weight: 500;
}

.group-settings__name-edit {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.group-settings__name-input {
  width: 100%;
  font-size: var(--text-md);
}
.group-settings__name-actions {
  display: flex;
  gap: var(--space-2);
  justify-content: flex-end;
}

.group-settings__members {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  max-height: 40vh;
  overflow-y: auto;
}
.group-settings__member {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 6px 0;
}
.group-settings__member-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent-tint);
  color: var(--accent-deep);
  border: 1px solid var(--accent-rule);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 14px;
  flex: 0 0 auto;
}
.group-settings__member-name {
  flex: 1;
  min-width: 0;
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: -0.005em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}


/* Group avatar image in chat-row + group settings. When a group
 * has an image_thumbnail_asset_id and we have the decrypted
 * blob-url cached, render it as a full-bleed img inside the
 * existing circular avatar slot; falls back to initials when
 * absent or still fetching. */
.chat-row__avatar-img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}

.group-settings__section--photo {
  display: flex;
  align-items: center;
  justify-content: center;
}
.group-settings__avatar {
  position: relative;
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: var(--paper-warm);
  color: var(--ink-mid);
  border: 1px solid var(--rule);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  padding: 0;
}
.group-settings__avatar:hover {
  border-color: var(--ink-mid);
}
.group-settings__avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.group-settings__avatar-initials {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 28px;
  color: var(--ink-mid);
}
.group-settings__avatar-hint {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 6px 4px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--paper-raised);
  background: rgba(31, 27, 22, 0.5);
}

