/* =========================================================================
   WolfsOfChat — css/app.css
   Component styles: app bar, conversation rows, message bubbles, PIN pad,
   setup wizard, filled/ghost/danger buttons, composer, FAB, screen
   transitions (push / cross-fade), wrong-PIN shake, reduced-motion collapse.

   DEPENDS ON css/theme.css (loaded FIRST in index.html). This file consumes
   ONLY the semantic tokens declared there and NEVER invents a color/size:
     surfaces  --bg --surface --surface-raised --surface-sunken --surface-hover
     text      --text-primary --text-secondary --text-tertiary --text-on-accent
     accent    --accent --accent-press --accent-subtle --accent-ring
     bubbles   --bubble-in-bg/-text/-meta  --bubble-out-bg/-text/-meta
     ticks     --tick --read-tick        badges --unread --unread-text --online
     danger    --danger --danger-press --danger-subtle
     palette   --s1..--s5 --avatar-monogram
     layout    --appbar-height --avatar-size(-sm) --fab-size --tap-target …
     motion    --motion-* --ease-* --shake-duration
   Every var() carries a fallback IDENTICAL to the theme.css dark value, so a
   token rename during parallel builds degrades gracefully — but the token is
   always the source of truth, which is what lets data-theme="light" re-skin
   every component here with zero edits.

   HARD LAYOUT RULE: the app lives in #app (index.html) — a phone frame with
   overflow:hidden. Screens are absolutely-positioned children so we can
   push/cross-fade between them. NOTHING may cause horizontal body scroll:
   wide content (long words, URLs, code) wraps or scrolls inside its own box.
   ========================================================================= */

/* ------------------------------------------------------------------ *
 * 0. Scoped reset + typography base
 * ------------------------------------------------------------------ */
#app,
#app *,
#app *::before,
#app *::after {
  box-sizing: border-box;
}

#app {
  font-family: var(--font-system, -apple-system, BlinkMacSystemFont, "Segoe UI",
    Roboto, system-ui, "Helvetica Neue", Arial, sans-serif);
  font-size: var(--fs-md, 16px);
  line-height: var(--lh-normal, 1.45);
  color: var(--text-primary, #E9EEF4);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  -webkit-tap-highlight-color: transparent;   /* no blue tap flash (native feel) */
  overflow-x: hidden;                          /* belt-and-braces: never scroll sideways */
}

#app button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  border: 0;
  margin: 0;
  background: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

#app input,
#app textarea {
  font: inherit;
  color: inherit;
}

/* Keyboard focus only (pointer taps stay flash-free). */
#app :focus-visible {
  outline: 2px solid var(--accent-ring, rgba(58, 130, 246, 0.45));
  outline-offset: 2px;
}
#app :focus:not(:focus-visible) { outline: none; }

/* ------------------------------------------------------------------ *
 * 1. Screen system + transitions (push / cross-fade)
 *    ui.js mounts one screen at a time; during a transition the outgoing
 *    and incoming screens coexist and are layered by z-index.
 * ------------------------------------------------------------------ */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;                 /* let the inner scroller shrink */
  background: var(--bg, #0C1116);
  overflow: hidden;
  will-change: transform, opacity;
  /* Default entrance so a bare screen swap still feels alive. */
  animation: screen-fade-in var(--motion-base, 220ms) var(--ease-decel, cubic-bezier(0, 0, 0.2, 1)) both;
}

/* The vertical scroll region of a screen (list body, thread body, wizard step). */
.screen__body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

/* Signature ambient violet bloom behind the login / setup / PIN screens.
   A fixed radial glow near the top over the near-black bg. Content sits above
   (this ::before is painted first at the same stacking level, pointer-inert).
   Chat screens carry no glow — they stay calmer. */
.screen--auth::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: -1;   /* above the screen's own bg, behind its content */
  background: radial-gradient(ellipse 700px 500px at 50% -5%,
    rgba(144, 97, 249, 0.15) 0%, transparent 65%);
}

/* Explicit PUSH (forward nav): incoming from right, outgoing parks left.
   Explicit POP (back): incoming from left, outgoing exits right.
   ui.js toggles these classes on the two live screens. */
.screen.is-push-in  { animation: push-in  var(--motion-slow, 320ms) var(--ease-emphasized, cubic-bezier(0.2, 0, 0, 1)) both; z-index: 2; }
.screen.is-push-out { animation: push-out var(--motion-slow, 320ms) var(--ease-emphasized, cubic-bezier(0.2, 0, 0, 1)) both; z-index: 1; }
.screen.is-pop-in   { animation: pop-in   var(--motion-slow, 320ms) var(--ease-emphasized, cubic-bezier(0.2, 0, 0, 1)) both; z-index: 1; }
.screen.is-pop-out  { animation: pop-out  var(--motion-slow, 320ms) var(--ease-emphasized, cubic-bezier(0.2, 0, 0, 1)) both; z-index: 2; }

/* Cross-fade (peer swaps: wizard step to step, login to pin). */
.screen.is-fade-in  { animation: screen-fade-in  var(--motion-base, 220ms) var(--ease-standard, cubic-bezier(0.4, 0, 0.2, 1)) both; z-index: 2; }
.screen.is-fade-out { animation: screen-fade-out var(--motion-base, 220ms) var(--ease-standard, cubic-bezier(0.4, 0, 0.2, 1)) both; z-index: 1; }

@keyframes screen-fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes screen-fade-out {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(8px); }
}
@keyframes push-in  { from { transform: translateX(100%); } to { transform: translateX(0); } }
@keyframes push-out { from { transform: translateX(0); }    to { transform: translateX(-24%); } }
@keyframes pop-in   { from { transform: translateX(-24%); } to { transform: translateX(0); } }
@keyframes pop-out  { from { transform: translateX(0); }    to { transform: translateX(100%); } }

/* ------------------------------------------------------------------ *
 * 2. App bar (top chrome for list + thread + wizard)
 * ------------------------------------------------------------------ */
.appbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: var(--sp-1, 4px);
  padding: 0 var(--sp-2, 8px);
  background: var(--surface, #151C24);
  border-bottom: 1px solid var(--border, rgba(255, 255, 255, 0.07));
  /* Respect the notch / status bar on real devices. */
  padding-top: env(safe-area-inset-top, 0px);
  height: calc(var(--appbar-height, 56px) + env(safe-area-inset-top, 0px));
  position: relative;
  z-index: var(--z-appbar, 10);
}

/* Round, tap-target-sized chrome buttons (back arrow, overflow menu, actions). */
.appbar__btn {
  flex: 0 0 auto;
  width: var(--tap-target, 44px);
  height: var(--tap-target, 44px);
  display: grid;
  place-items: center;
  border-radius: var(--radius-full, 999px);
  color: var(--text-primary, #E9EEF4);
  transition: background-color var(--motion-fast, 140ms) var(--ease-standard, ease);
}
.appbar__btn:active { background: var(--surface-hover, #202B36); }
.appbar__btn svg { width: 22px; height: 22px; display: block; }

/* Small conversation avatar shown left of the thread title. */
.appbar__avatar {
  flex: 0 0 auto;
  width: var(--avatar-size-sm, 36px);
  height: var(--avatar-size-sm, 36px);
  margin: 0 var(--sp-1, 4px) 0 2px;
  border-radius: var(--radius-full, 999px);
  display: grid;
  place-items: center;
  font-size: var(--fs-sm, 13px);
  font-weight: var(--fw-semibold, 600);
  color: var(--avatar-monogram, #0C1116);   /* dark monogram on tinted fill */
  user-select: none;
}

.appbar__titles {
  flex: 1 1 auto;
  min-width: 0;                  /* enable ellipsis */
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0 var(--sp-1, 4px);
}
.appbar__title {
  font-size: var(--fs-md, 16px);
  font-weight: var(--fw-semibold, 600);
  letter-spacing: var(--ls-wide, 0.01em);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.appbar__subtitle {
  font-size: var(--fs-xs, 11px);
  color: var(--text-tertiary, #6C7A88);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Large "home" title variant (chat list header). */
.appbar--home { padding-left: var(--sp-4, 16px); }
.appbar--home .appbar__title { font-size: var(--fs-xl, 22px); font-weight: var(--fw-bold, 700); }

/* ------------------------------------------------------------------ *
 * 3. Buttons — filled / ghost / danger
 * ------------------------------------------------------------------ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2, 8px);
  min-height: 50px;
  padding: 0 var(--sp-5, 20px);
  width: 100%;
  border-radius: var(--radius-md, 12px);
  font-size: var(--fs-md, 16px);
  font-weight: var(--fw-semibold, 600);
  letter-spacing: var(--ls-wide, 0.01em);
  transition: transform var(--motion-instant, 80ms) var(--ease-standard, ease),
    background-color var(--motion-fast, 140ms) var(--ease-standard, ease),
    opacity var(--motion-fast, 140ms) var(--ease-standard, ease),
    border-color var(--motion-fast, 140ms) var(--ease-standard, ease);
  user-select: none;
}
.btn:active { transform: scale(0.98); }        /* instant press, native feel */

.btn--filled {
  background: linear-gradient(180deg, #b794ff 0%, #9061f9 50%, #7e47ed 100%);
  color: #fff;
  box-shadow: 0 10px 28px rgba(144, 97, 249, 0.40),
    inset 0 1px 0 rgba(255, 255, 255, 0.22),
    inset 0 -1px 0 rgba(0, 0, 0, 0.12);
}
.btn--filled:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 32px rgba(144, 97, 249, 0.46),
    inset 0 1px 0 rgba(255, 255, 255, 0.22),
    inset 0 -1px 0 rgba(0, 0, 0, 0.12);
}
.btn--filled:active {
  transform: translateY(0) scale(0.98);
  background: linear-gradient(180deg, #9061f9 0%, #7e47ed 100%);
}

.btn--ghost {
  background: transparent;
  color: var(--accent, #3A82F6);
  border: 1px solid var(--border-strong, rgba(255, 255, 255, 0.13));
}
.btn--ghost:active { background: var(--surface, #151C24); }

.btn--danger {
  background: var(--danger, #E5484D);
  color: var(--danger-text, #FFFFFF);
}
.btn--danger:active { background: var(--danger-press, #C93B40); }

.btn[disabled],
.btn.is-disabled {
  opacity: 0.4;
  pointer-events: none;
}

/* Sticky full-width action dock at the bottom of setup / login screens. */
.action-dock {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2, 8px);
  padding: var(--sp-3, 12px) var(--sp-4, 16px)
           calc(var(--sp-4, 16px) + env(safe-area-inset-bottom, 0px));
  background: var(--bg, #0C1116);
  border-top: 1px solid var(--divider, rgba(255, 255, 255, 0.05));
}

/* ------------------------------------------------------------------ *
 * 4. Conversation list + rows (UX §4.6)
 *    Data-driven from vault.conversations. SAME component for every vault —
 *    no real/decoy branch exists here or anywhere in the render path.
 * ------------------------------------------------------------------ */
.chatlist { padding: var(--sp-1, 4px) 0 88px; }   /* bottom pad clears the FAB */

.conv-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3, 12px);
  width: 100%;
  padding: 10px var(--sp-4, 16px);
  text-align: left;
  transition: background-color var(--motion-fast, 140ms) var(--ease-standard, ease);
}
.conv-row:active { background: var(--surface-hover, #202B36); }

.conv-row__avatar {
  position: relative;
  flex: 0 0 auto;
  width: var(--avatar-size, 48px);
  height: var(--avatar-size, 48px);
  border-radius: var(--radius-full, 999px);
  display: grid;
  place-items: center;
  font-size: var(--fs-lg, 18px);
  font-weight: var(--fw-semibold, 600);
  color: var(--avatar-monogram, #0C1116);   /* dark monogram on tinted fill */
  user-select: none;
}
/* Optional presence dot (online). ui.js may add .is-online. */
.conv-row__avatar.is-online::after {
  content: "";
  position: absolute;
  right: 1px;
  bottom: 1px;
  width: 12px;
  height: 12px;
  border-radius: var(--radius-full, 999px);
  background: var(--online, #3AD07A);
  border: 2px solid var(--surface, #151C24);
}

.conv-row__main {
  flex: 1 1 auto;
  min-width: 0;                  /* critical: lets title/preview ellipsize */
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.conv-row__top,
.conv-row__bottom {
  display: flex;
  align-items: center;
  gap: var(--sp-2, 8px);
}

.conv-row__title {
  flex: 1 1 auto;
  min-width: 0;
  font-size: var(--fs-md, 16px);
  font-weight: var(--fw-semibold, 600);
  color: var(--text-primary, #E9EEF4);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conv-row__time {
  flex: 0 0 auto;
  font-size: var(--fs-xs, 11px);
  color: var(--text-tertiary, #6C7A88);
}
.conv-row--unread .conv-row__time {
  color: var(--accent, #3A82F6);
  font-weight: var(--fw-medium, 500);
}

.conv-row__preview {
  flex: 1 1 auto;
  min-width: 0;
  font-size: var(--fs-sm, 13px);
  color: var(--text-secondary, #9CAAB8);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.conv-row--unread .conv-row__preview { color: var(--text-primary, #E9EEF4); }

/* Group-sender prefix ("Alex: …") in previews. */
.conv-row__preview b { color: var(--text-primary, #E9EEF4); font-weight: var(--fw-semibold, 600); }

/* Unread pill. */
.conv-row__badge {
  flex: 0 0 auto;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: var(--radius-full, 999px);
  background: var(--unread, #3A82F6);
  color: var(--unread-text, #FFFFFF);
  font-size: var(--fs-xs, 11px);
  font-weight: var(--fw-bold, 700);
  line-height: 20px;
  text-align: center;
}

/* Muted-speaker icon (inline SVG from ui.js). */
.conv-row__mute {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  color: var(--text-tertiary, #6C7A88);
}
.conv-row__mute svg { width: 100%; height: 100%; display: block; }

/* Thin inset divider between rows (aligned past the avatar). */
.conv-row + .conv-row { position: relative; }
.conv-row + .conv-row::before {
  content: "";
  position: absolute;
  top: 0;
  left: 76px;
  right: 0;
  height: 1px;
  background: var(--divider, rgba(255, 255, 255, 0.05));
}

/* Empty-state (defensive — seeds are never conspicuously empty). */
.chatlist__empty {
  display: grid;
  place-items: center;
  gap: var(--sp-2, 8px);
  padding: var(--sp-10, 64px) var(--sp-6, 24px);
  color: var(--text-tertiary, #6C7A88);
  text-align: center;
}

/* ------------------------------------------------------------------ *
 * 5. FAB (compose)
 * ------------------------------------------------------------------ */
.fab {
  position: absolute;
  right: var(--sp-4, 16px);
  bottom: calc(var(--sp-5, 20px) + env(safe-area-inset-bottom, 0px));
  width: var(--fab-size, 56px);
  height: var(--fab-size, 56px);
  border-radius: var(--radius-bubble, 18px);
  display: grid;
  place-items: center;
  background: var(--accent, #3A82F6);
  color: var(--text-on-accent, #FFFFFF);
  box-shadow: var(--shadow-fab, 0 6px 16px rgba(58, 130, 246, 0.34)),
              var(--shadow-2, 0 4px 12px rgba(0, 0, 0, 0.38));
  transition: transform var(--motion-instant, 80ms) var(--ease-standard, ease),
    background-color var(--motion-fast, 140ms) var(--ease-standard, ease);
  z-index: var(--z-fab, 20);
}
.fab:active { transform: scale(0.94); background: var(--accent-press, #2E6AD1); }
.fab svg { width: 26px; height: 26px; display: block; }

/* ------------------------------------------------------------------ *
 * 6. Thread — bubbles, day separators, ticks (UX §4.5)
 * ------------------------------------------------------------------ */
.thread__body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--sp-3, 12px) 10px var(--sp-2, 8px);
}

/* Centered date pill between day groups. */
.day-sep {
  align-self: center;
  margin: var(--sp-3, 12px) 0 10px;
  padding: var(--sp-1, 4px) var(--sp-3, 12px);
  border-radius: var(--radius-md, 12px);
  background: var(--surface-raised, #1C2530);
  color: var(--text-tertiary, #6C7A88);
  font-size: var(--fs-xs, 11px);
  font-weight: var(--fw-semibold, 600);
  letter-spacing: var(--ls-wide, 0.02em);
}

/* Message bubble — max 78% of thread width (spec §4.5). */
.bubble {
  position: relative;
  max-width: 78%;
  padding: 7px 11px 8px;
  border-radius: var(--radius-bubble, 18px);
  font-size: var(--fs-base, 15px);
  line-height: var(--lh-snug, 1.35);
  box-shadow: var(--bubble-shadow, 0 1px 1px rgba(0, 0, 0, 0.28));
  /* Long words / URLs must wrap, never force horizontal scroll. */
  overflow-wrap: break-word;
  word-break: break-word;
  hyphens: auto;
  margin-top: 2px;
}

/* Incoming (from !== "me"): left aligned, tail flattens bottom-left. */
.bubble--in {
  align-self: flex-start;
  background: var(--bubble-in-bg, #1E2832);
  color: var(--bubble-in-text, #E9EEF4);
  border-bottom-left-radius: 6px;
}
/* Outgoing (from === "me"): right aligned, accent-tinted, tail bottom-right. */
.bubble--out {
  align-self: flex-end;
  background: var(--bubble-out-bg, #234B77);
  color: var(--bubble-out-text, #EAF2FB);
  border-bottom-right-radius: 6px;
}

/* Bubble tails: a small pseudo pinned to the flattened corner, painted the
   same color as the bubble so it reads as one shape. */
.bubble--in::before,
.bubble--out::before {
  content: "";
  position: absolute;
  bottom: 0;
  width: 10px;
  height: 13px;
}
.bubble--in::before {
  left: -6px;
  background: var(--bubble-in-bg, #1E2832);
  clip-path: path("M10 13 C4 13 0 8 0 0 L10 0 Z");
}
.bubble--out::before {
  right: -6px;
  background: var(--bubble-out-bg, #234B77);
  clip-path: path("M0 13 C6 13 10 8 10 0 L0 0 Z");
}

/* Consecutive same-side bubbles: tighten the group; only the last keeps a tail.
   ui.js flags every bubble in a run except the last with .is-grouped. */
.bubble.is-grouped { border-radius: var(--radius-bubble, 18px); margin-top: 1px; }
.bubble.is-grouped::before { display: none; }

/* Group-chat sender label above an incoming bubble. Color = --s1..--s5. */
.bubble__sender {
  display: block;
  margin-bottom: 2px;
  font-size: var(--fs-xs, 11px);
  font-weight: var(--fw-bold, 700);
  line-height: var(--lh-tight, 1.2);
}
.bubble__sender--s1 { color: var(--s1, #E39B9B); }
.bubble__sender--s2 { color: var(--s2, #E0B87A); }
.bubble__sender--s3 { color: var(--s3, #86C79A); }
.bubble__sender--s4 { color: var(--s4, #8FB8E8); }
.bubble__sender--s5 { color: var(--s5, #C2A0E0); }

/* Body text: preserve intentional newlines. */
.bubble__body { white-space: pre-wrap; }

/* Meta line: time + delivery ticks, tucked to the trailing edge and floated
   into the last text line so short messages stay compact. */
.bubble__meta {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  float: right;
  margin: 3px 0 -2px var(--sp-2, 8px);
  font-size: var(--fs-2xs, 10px);
  line-height: 1;
  transform: translateY(3px);
}
.bubble--in  .bubble__meta { color: var(--bubble-in-meta, #7C8A98); }
.bubble--out .bubble__meta { color: var(--bubble-out-meta, #A9C6E6); }

/* Delivery ticks (inline SVG from ui.js): sent = single, delivered/read =
   double; read tints blue via --read-tick. Ticks inherit meta color by default. */
.bubble__tick { display: inline-flex; color: var(--tick, #8A98A6); }
.bubble--out .bubble__tick { color: currentColor; }   /* match outgoing meta */
.bubble__tick svg { width: 15px; height: 15px; display: block; }
.bubble__tick.is-read { color: var(--read-tick, #5AB7F0); }

/* ------------------------------------------------------------------ *
 * 7. Composer (message input + send)
 * ------------------------------------------------------------------ */
.composer {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-end;
  gap: var(--sp-2, 8px);
  min-height: var(--composer-min-height, 52px);
  padding: var(--sp-2, 8px) 10px
           calc(var(--sp-2, 8px) + env(safe-area-inset-bottom, 0px));
  background: var(--surface, #151C24);
  border-top: 1px solid var(--border, rgba(255, 255, 255, 0.07));
  z-index: var(--z-composer, 15);
}

.composer__input {
  flex: 1 1 auto;
  min-width: 0;
  max-height: 120px;             /* grows a few lines, then scrolls internally */
  padding: 10px var(--sp-3, 12px);
  border-radius: var(--radius-xl, 20px);
  background: var(--surface-sunken, #0A0E12);
  border: 1px solid var(--border, rgba(255, 255, 255, 0.07));
  color: var(--text-primary, #E9EEF4);
  font-size: var(--fs-base, 15px);
  line-height: var(--lh-snug, 1.35);
  resize: none;
  overflow-y: auto;
  outline: none;
  transition: border-color var(--motion-fast, 140ms) var(--ease-standard, ease);
}
.composer__input::placeholder { color: var(--text-tertiary, #6C7A88); }
.composer__input:focus { border-color: var(--accent, #3A82F6); }

/* Send button: inert until there's something to send (ui.js toggles .is-active). */
.composer__send {
  flex: 0 0 auto;
  width: var(--tap-target, 44px);
  height: var(--tap-target, 44px);
  border-radius: var(--radius-full, 999px);
  display: grid;
  place-items: center;
  background: var(--surface-raised, #1C2530);
  color: var(--text-tertiary, #6C7A88);
  transform: scale(0.85);
  opacity: 0.6;
  transition: transform var(--motion-fast, 140ms) var(--ease-emphasized, cubic-bezier(0.2, 0, 0, 1)),
    background-color var(--motion-fast, 140ms) var(--ease-standard, ease),
    opacity var(--motion-fast, 140ms) var(--ease-standard, ease),
    color var(--motion-fast, 140ms) var(--ease-standard, ease);
}
.composer__send svg { width: 22px; height: 22px; display: block; }

.composer__send.is-active {
  background: var(--accent, #3A82F6);
  color: var(--text-on-accent, #FFFFFF);
  opacity: 1;
  transform: scale(1);
}
.composer__send.is-active:active { transform: scale(0.9); }

/* ------------------------------------------------------------------ *
 * 8. PIN — dot row + numeric keypad
 * ------------------------------------------------------------------ */
.pin {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--sp-6, 24px) var(--sp-5, 20px)
           calc(var(--sp-5, 20px) + env(safe-area-inset-bottom, 0px));
}

.pin__header {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: center;
}
.pin__title { font-size: var(--fs-xl, 22px); font-weight: var(--fw-semibold, 600); }
.pin__hint  { font-size: var(--fs-sm, 13px); color: var(--text-secondary, #9CAAB8); }

/* Dot row. .pin__dots gets .is-shake to shake on a wrong PIN. */
.pin__dots {
  display: flex;
  gap: 18px;
  margin: var(--sp-6, 24px) 0 var(--sp-8, 40px);
}
.pin__dot {
  width: 14px;
  height: 14px;
  border-radius: var(--radius-full, 999px);
  border: 2px solid var(--text-tertiary, #6C7A88);
  background: transparent;
  transition: background-color var(--motion-instant, 80ms) var(--ease-standard, ease),
    border-color var(--motion-instant, 80ms) var(--ease-standard, ease),
    transform var(--motion-instant, 80ms) var(--ease-standard, ease);
}
.pin__dot.is-filled {
  background: var(--accent, #3A82F6);
  border-color: var(--accent, #3A82F6);
  transform: scale(1.08);
}
/* On a wrong PIN the filled dots flush danger briefly before clearing. */
.pin__dots.is-error .pin__dot.is-filled {
  background: var(--danger, #E5484D);
  border-color: var(--danger, #E5484D);
}

/* Keypad: 3-column grid of large round keys. */
.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-3, 14px) var(--sp-6, 26px);
  width: 100%;
  max-width: 300px;
}
.keypad__key {
  aspect-ratio: 1 / 1;
  max-width: 74px;
  justify-self: center;
  width: 100%;
  border-radius: var(--radius-full, 999px);
  display: grid;
  place-items: center;
  font-size: var(--fs-2xl, 26px);
  font-weight: var(--fw-medium, 500);
  color: var(--text-primary, #E9EEF4);
  background: var(--surface, #151C24);
  transition: transform var(--motion-instant, 80ms) var(--ease-standard, ease),
    background-color var(--motion-fast, 140ms) var(--ease-standard, ease);
  user-select: none;
}
.keypad__key:active {
  background: var(--surface-hover, #202B36);
  transform: scale(0.94);
}
/* Action keys (backspace / submit): no filled circle, muted until usable. */
.keypad__key--action {
  background: transparent;
  color: var(--text-secondary, #9CAAB8);
}
.keypad__key--action:active { background: var(--surface, #151C24); }
.keypad__key--action svg { width: 26px; height: 26px; display: block; }
.keypad__key--submit { color: var(--accent, #3A82F6); }
.keypad__key[disabled],
.keypad__key.is-disabled { opacity: 0.35; pointer-events: none; }

/* ------------------------------------------------------------------ *
 * 9. Setup wizard + login
 * ------------------------------------------------------------------ */
.wizard { flex: 1 1 auto; display: flex; flex-direction: column; min-height: 0; }

/* Step progress dots under the app bar. */
.wizard__progress {
  flex: 0 0 auto;
  display: flex;
  justify-content: center;
  gap: 7px;
  padding: var(--sp-3, 14px) 0 var(--sp-1, 6px);
}
.wizard__progress span {
  width: 7px;
  height: 7px;
  border-radius: var(--radius-full, 999px);
  background: var(--surface-raised, #1C2530);
  transition: background-color var(--motion-base, 220ms) var(--ease-standard, ease),
    width var(--motion-base, 220ms) var(--ease-standard, ease);
}
.wizard__progress span.is-active {
  width: 20px;
  border-radius: var(--radius-xs, 4px);
  background: var(--accent, #3A82F6);
}
.wizard__progress span.is-done { background: var(--accent, #3A82F6); }

/* Scrolling step body. */
.wizard__step {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--sp-5, 18px) var(--sp-6, 22px) var(--sp-2, 8px);
  display: flex;
  flex-direction: column;
  gap: var(--sp-5, 18px);
}
.wizard__heading {
  font-size: var(--fs-2xl, 24px);
  font-weight: var(--fw-bold, 700);
  letter-spacing: var(--ls-tight, -0.01em);
}
.wizard__sub {
  margin-top: -10px;
  font-size: var(--fs-sm, 14px);
  color: var(--text-secondary, #9CAAB8);
  line-height: var(--lh-normal, 1.45);
}

/* Text field. */
.field { display: flex; flex-direction: column; gap: 7px; }
.field__label {
  font-size: var(--fs-sm, 13px);
  font-weight: var(--fw-semibold, 600);
  color: var(--text-secondary, #9CAAB8);
  letter-spacing: var(--ls-wide, 0.02em);
}
.field__input {
  width: 100%;
  min-width: 0;
  padding: 13px 15px;
  border-radius: var(--radius-md, 12px);
  background: var(--surface, #151C24);
  border: 1px solid var(--border, rgba(255, 255, 255, 0.07));
  color: var(--text-primary, #E9EEF4);
  font-size: var(--fs-md, 16px);   /* >=16px prevents iOS zoom-on-focus */
  outline: none;
  transition: border-color var(--motion-fast, 140ms) var(--ease-standard, ease),
    background-color var(--motion-fast, 140ms) var(--ease-standard, ease);
}
.field__input::placeholder { color: var(--text-tertiary, #6C7A88); }
.field__input:focus { border-color: var(--accent, #3A82F6); }
.field__input.is-invalid { border-color: var(--danger, #E5484D); }

/* Inline validation / helper text. */
.field__hint  { font-size: var(--fs-xs, 12px); color: var(--text-tertiary, #6C7A88); line-height: var(--lh-normal, 1.4); }
.field__error { font-size: var(--fs-xs, 12px); color: var(--danger, #E5484D); }

/* Radio "cards" (duress behavior + One-PIN/Two-PINs mode). */
.radio-card {
  display: flex;
  gap: var(--sp-3, 12px);
  padding: var(--sp-3, 14px) var(--sp-4, 16px);
  border-radius: var(--radius-md, 14px);
  background: var(--surface, #151C24);
  border: 1.5px solid var(--border-strong, rgba(255, 255, 255, 0.13));
  transition: border-color var(--motion-fast, 140ms) var(--ease-standard, ease),
    background-color var(--motion-fast, 140ms) var(--ease-standard, ease);
  text-align: left;
  width: 100%;
  align-items: flex-start;
}
.radio-card.is-selected {
  border-color: var(--accent, #3A82F6);
  background: var(--accent-subtle, rgba(58, 130, 246, 0.16));
}
.radio-card__mark {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  margin-top: 1px;
  border-radius: var(--radius-full, 999px);
  border: 2px solid var(--text-tertiary, #6C7A88);
  display: grid;
  place-items: center;
  transition: border-color var(--motion-fast, 140ms) var(--ease-standard, ease);
}
.radio-card.is-selected .radio-card__mark { border-color: var(--accent, #3A82F6); }
.radio-card.is-selected .radio-card__mark::after {
  content: "";
  width: 11px;
  height: 11px;
  border-radius: var(--radius-full, 999px);
  background: var(--accent, #3A82F6);
}
.radio-card__text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.radio-card__title { font-size: var(--fs-md, 16px); font-weight: var(--fw-semibold, 600); }
.radio-card__desc  { font-size: var(--fs-sm, 13px); color: var(--text-secondary, #9CAAB8); line-height: var(--lh-normal, 1.4); }

/* Danger variant (NUKE / "Wipe everything" — the only place --danger reaches
   the setup flow; never in the chat UI). */
.radio-card--danger.is-selected {
  border-color: var(--danger, #E5484D);
  background: var(--danger-subtle, rgba(229, 72, 77, 0.15));
}
.radio-card--danger.is-selected .radio-card__mark { border-color: var(--danger, #E5484D); }
.radio-card--danger.is-selected .radio-card__mark::after { background: var(--danger, #E5484D); }

/* Warning banner + confirm checkbox gating the destructive choice. */
.warn-banner {
  display: flex;
  gap: 10px;
  padding: var(--sp-3, 12px) var(--sp-3, 14px);
  border-radius: var(--radius-md, 12px);
  background: var(--danger-subtle, rgba(229, 72, 77, 0.15));
  border: 1px solid color-mix(in srgb, var(--danger, #E5484D) 45%, transparent);
  color: var(--danger, #E5484D);
  font-size: var(--fs-sm, 13px);
  line-height: var(--lh-normal, 1.45);
}
.warn-banner__icon { flex: 0 0 auto; width: 20px; height: 20px; }
.warn-banner__icon svg { width: 100%; height: 100%; display: block; }

.confirm-check {
  display: flex;
  align-items: center;
  gap: var(--sp-3, 12px);
  padding: 10px 2px;
  font-size: var(--fs-sm, 14px);
}
.confirm-check__box {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  border-radius: 7px;
  border: 2px solid var(--text-tertiary, #6C7A88);
  display: grid;
  place-items: center;
  transition: background-color var(--motion-fast, 120ms) var(--ease-standard, ease),
    border-color var(--motion-fast, 120ms) var(--ease-standard, ease);
  color: transparent;
}
.confirm-check.is-checked .confirm-check__box {
  background: var(--danger, #E5484D);
  border-color: var(--danger, #E5484D);
  color: var(--danger-text, #FFFFFF);
}
.confirm-check__box svg { width: 15px; height: 15px; display: block; }

/* Review step: key/value summary rows. */
.review-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  border-radius: var(--radius-md, 12px);
  overflow: hidden;
  background: var(--border, rgba(255, 255, 255, 0.07));   /* hairline gaps show through */
}
.review-row {
  display: flex;
  justify-content: space-between;
  gap: var(--sp-4, 16px);
  padding: 13px 15px;
  background: var(--surface, #151C24);
  font-size: var(--fs-base, 15px);
}
.review-row__key { color: var(--text-secondary, #9CAAB8); }
.review-row__val {
  font-weight: var(--fw-semibold, 600);
  color: var(--text-primary, #E9EEF4);
  text-align: right;
  min-width: 0;
  overflow-wrap: anywhere;
}

/* Login brand block. */
.login-brand {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: var(--sp-8, 40px) var(--sp-5, 20px) var(--sp-6, 24px);
  text-align: center;
}
.login-brand__logo {
  width: 68px;
  height: 68px;
  border-radius: var(--radius-xl, 22px);
  display: grid;
  place-items: center;
  background: var(--accent, #3A82F6);
  color: var(--text-on-accent, #FFFFFF);
}
.login-brand__logo svg { width: 40px; height: 40px; display: block; }
.login-brand__name { font-size: var(--fs-xl, 22px); font-weight: var(--fw-bold, 700); letter-spacing: var(--ls-tight, -0.01em); }
.login-brand__tag  { font-size: var(--fs-sm, 13px); color: var(--text-secondary, #b7bdc6); }

/* Wolf brand lockup (login + setup): real logo above a tri-color wordmark. */
.brand {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: var(--sp-8, 40px) var(--sp-5, 20px) var(--sp-6, 24px);
  text-align: center;
}
/* Compact when it heads a wizard step (keeps room for the field / keypad). */
.wizard__step .brand { padding: var(--sp-1, 4px) 0 var(--sp-2, 8px); }

.brand__logo {
  width: 64px;
  height: 64px;
  object-fit: contain;
  /* Brand glow: violet halo + faint gold, lifted a touch. */
  filter: drop-shadow(0 0 6px rgba(144, 97, 249, 0.40))
          drop-shadow(0 0 12px rgba(212, 167, 44, 0.18))
          brightness(1.12);
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
}
.brand__tag { font-size: var(--fs-sm, 13px); color: var(--text-secondary, #b7bdc6); }

/* Tri-color wordmark: WOLFS · OF · CHAT. */
.wm {
  display: inline-flex;
  align-items: baseline;
  gap: 3px;
  font-weight: 800;
  font-size: 27px;
  letter-spacing: -0.005em;
  line-height: 1;
}
.wm-w {
  background: linear-gradient(180deg, #ffffff 30%, #b7bdc6 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.wm-of {
  font-family: var(--font-mono, ui-monospace, "SF Mono", "JetBrains Mono", monospace);
  font-weight: 400;
  font-size: 0.55em;
  color: #e8c04a;
  letter-spacing: 0.04em;
}
.wm-c {
  background: linear-gradient(180deg, #c4b5fd 0%, #9061f9 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Version string (long-press => dev reset). Non-selectable so the long-press
   gesture stays clean. */
.version-string {
  padding: var(--sp-3, 14px);
  text-align: center;
  font-size: var(--fs-xs, 12px);
  color: var(--text-tertiary, #6C7A88);
  opacity: 0.6;
  user-select: none;
  -webkit-user-select: none;
}

/* ------------------------------------------------------------------ *
 * 10. Shake keyframes (wrong PIN)
 *     Spec: horizontal ±8px, ~400ms, roughly 3 oscillations.
 * ------------------------------------------------------------------ */
@keyframes shake {
  0%   { transform: translateX(0); }
  12%  { transform: translateX(-8px); }
  25%  { transform: translateX(8px); }
  37%  { transform: translateX(-8px); }
  50%  { transform: translateX(8px); }
  62%  { transform: translateX(-8px); }
  75%  { transform: translateX(8px); }
  87%  { transform: translateX(-4px); }
  100% { transform: translateX(0); }
}
/* Apply to whichever element ui.js flags (dot row or a container). */
.is-shake,
.shake {
  animation: shake var(--shake-duration, 400ms) cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

/* ------------------------------------------------------------------ *
 * 11. Reduced motion — collapse all transitions/animations.
 *     Screens still swap (no slide), dots still fill, shake becomes a static
 *     non-animated state. No motion, full function.
 * ------------------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
  #app *,
  #app *::before,
  #app *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  .screen,
  .screen.is-push-in,
  .screen.is-push-out,
  .screen.is-pop-in,
  .screen.is-pop-out,
  .screen.is-fade-in,
  .screen.is-fade-out {
    animation: none !important;
    transform: none !important;
    opacity: 1;
  }
  .is-shake,
  .shake { animation: none !important; }
  .btn:active,
  .fab:active,
  .keypad__key:active,
  .composer__send.is-active:active { transform: none; }
}

/* ==================================================================== *
 * 12. Media bubbles — voice (F1) / photo · video (F2) / view-once (F6) /
 *     tombstone. UX for the deniable media layer.
 *
 * DOM is produced by js/media-view.js (owner D) and is FIXED; these rules
 * target the exact structure it emits:
 *   voice   .voice-bubble > .voice-bubble__play + .voice-bubble__wave
 *           (.voice-bubble__bar…) + .voice-bubble__time
 *           states: .is-playing (root), .is-gone (root), .is-played (bar)
 *   photo   .media-bubble > .media-bubble__thumb (img | …--placeholder)
 *   video   .media-bubble.media-bubble--video > thumb
 *           + .media-bubble__play (center) + .media-bubble__dur (corner)
 *   once    .media-bubble.is-once > .media-bubble__once-icon
 *           + .media-bubble__once-label   (covered "tap to view once")
 *   gone    .tombstone-bubble > svg + .tombstone-bubble__label
 *           + .tombstone-bubble__time
 *
 * INTEGRATION (owner H / ui.js): place the element media-view returns as the
 * sole child of a `.bubble.bubble--out` / `.bubble--in` so it inherits the
 * thread's alignment, tail and meta. The `.bubble:has(> …)` rules below adapt
 * that wrapper (drop padding for a photo, neutralise the pill for a tombstone)
 * and degrade harmlessly where :has() is unavailable. Each component also
 * carries a self-standing fallback so it still reads correctly if rendered as a
 * bare thread child. Only theme.css tokens are used — no invented palette.
 * ==================================================================== */

/* ---- shared: adapt the wrapping .bubble to its media payload ---------- */
/* Photo/video: a thin colour frame around the clipped thumbnail. */
.bubble:has(> .media-bubble):not(:has(> .media-bubble.is-once)) {
  padding: 3px;
  max-width: 76%;
}
/* Voice: tighter than a text bubble, wide enough for the scrubber. */
.bubble:has(> .voice-bubble) { padding: 6px 10px; }
/* Tombstone: the pill supplies its own chrome — strip the bubble + its tail. */
.bubble:has(> .tombstone-bubble) {
  padding: 0;
  background: none;
  box-shadow: none;
}
.bubble:has(> .tombstone-bubble)::before { display: none; }

/* Bare-thread-child fallback (unwrapped integration): give each its own frame. */
.thread__body > .voice-bubble,
.thread__body > .media-bubble,
.thread__body > .tombstone-bubble { align-self: flex-start; margin-top: 2px; }
.thread__body > .voice-bubble {
  padding: 7px 11px;
  border-radius: var(--radius-bubble, 18px);
  background: var(--bubble-in-bg, #1c2030);
  box-shadow: var(--bubble-shadow, 0 1px 1px rgba(0, 0, 0, 0.28));
}

/* ---- F1 voice bubble ------------------------------------------------- */
/* Waveform bar colours are consumed as inline CSS vars by media-view.js
   (bar background = var(--voice-bar) / var(--voice-bar-played)); we only
   define the tokens per context so played bars read gold on either side. */
.voice-bubble {
  --voice-bar: rgba(255, 255, 255, 0.30);
  --voice-bar-played: var(--warning, #d4a72c);
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 176px;
  max-width: 260px;
}
.bubble--out .voice-bubble {
  --voice-bar: rgba(240, 236, 255, 0.42);
  --voice-bar-played: #d4a72c;
}
.bubble--in .voice-bubble {
  --voice-bar: rgba(255, 255, 255, 0.22);
  --voice-bar-played: var(--warning, #d4a72c);
}

.voice-bubble__play {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full, 999px);
  display: grid;
  place-items: center;
  color: var(--warning, #d4a72c);
  background: color-mix(in srgb, var(--warning, #d4a72c) 20%, transparent);
  transition: transform var(--motion-instant, 80ms) var(--ease-standard, ease),
    background-color var(--motion-fast, 140ms) var(--ease-standard, ease);
}
.voice-bubble__play:active { transform: scale(0.92); }
.voice-bubble__play svg { width: 18px; height: 18px; display: block; }
/* Playing: a touch brighter fill so the state reads without motion. */
.voice-bubble.is-playing .voice-bubble__play {
  background: color-mix(in srgb, var(--warning, #d4a72c) 32%, transparent);
}

.voice-bubble__wave {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 1 1 auto;
  height: 32px;
  cursor: pointer;
  touch-action: none;   /* let the scrubber own horizontal drags */
}
.voice-bubble__bar {
  flex: 0 0 auto;
  width: 3px;
  border-radius: 2px;
  /* height + background set inline by media-view.js (progress-driven) */
}
.voice-bubble__time {
  flex: 0 0 auto;
  min-width: 34px;
  text-align: right;
  font-size: var(--fs-xs, 11px);
  font-variant-numeric: tabular-nums;
  color: inherit;
  opacity: 0.85;
}
/* Blob shredded / chaff / never-existed: degrade quietly, still deniable. */
.voice-bubble.is-gone { opacity: 0.55; }
.voice-bubble.is-gone .voice-bubble__play {
  color: var(--text-tertiary, #8a93a3);
  background: var(--surface-raised, #1c2030);
}

/* ---- F2 photo / video bubble ---------------------------------------- */
.media-bubble {
  display: block;
  position: relative;
  overflow: hidden;
  max-width: min(260px, 100%);
  border-radius: var(--radius-md, 14px);
  background: var(--surface-sunken, #0b0e11);
  line-height: 0;                     /* kill inline-img descender gap */
  box-shadow: var(--bubble-shadow, 0 1px 1px rgba(0, 0, 0, 0.28));
  transition: transform var(--motion-instant, 80ms) var(--ease-standard, ease);
}
.media-bubble:active { transform: scale(0.98); }

.media-bubble__thumb {
  display: block;
  width: 100%;
  height: auto;
  max-width: 260px;
  max-height: 340px;
  object-fit: cover;
  /* aspect-ratio is applied inline by media-view.js when w/h are known */
}
.media-bubble__thumb--placeholder {
  display: grid;
  place-items: center;
  width: 220px;
  height: 160px;
  color: var(--text-tertiary, #8a93a3);
  background: var(--surface-raised, #1c2030);
}
.media-bubble__thumb--placeholder svg { width: 26px; height: 26px; display: block; }

/* Video: centred play glyph + duration badge over the poster. */
.media-bubble__play {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 52px;
  height: 52px;
  border-radius: var(--radius-full, 999px);
  display: grid;
  place-items: center;
  color: #fff;
  background: rgba(3, 4, 8, 0.52);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.45);
  pointer-events: none;               /* clicks belong to the .media-bubble button */
}
.media-bubble__play svg { width: 26px; height: 26px; display: block; }
.media-bubble__dur {
  position: absolute;
  right: 6px;
  bottom: 6px;
  padding: 2px 7px;
  border-radius: var(--radius-full, 999px);
  background: rgba(3, 4, 8, 0.62);
  color: #fff;
  font-size: var(--fs-2xs, 10px);
  font-weight: var(--fw-semibold, 600);
  font-variant-numeric: tabular-nums;
  line-height: 1.4;
  pointer-events: none;
}

/* F6 view-once cover: no preview (thumb is plaintext in the slot) — a covered,
   burn-marked affordance instead. Distinct look so it never reads as a photo. */
.media-bubble.is-once {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: visible;
  padding: 12px 14px;
  line-height: var(--lh-snug, 1.32);
  background: color-mix(in srgb, var(--accent, #9061f9) 12%, var(--surface-raised, #1c2030));
  border: 1px dashed color-mix(in srgb, var(--accent, #9061f9) 45%, transparent);
  color: var(--text-secondary, #b7bdc6);
}
.media-bubble__once-icon {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  color: var(--warning, #d4a72c);     /* burn = gold flame */
}
.media-bubble__once-icon svg { width: 22px; height: 22px; display: block; }
.media-bubble__once-label {
  font-size: var(--fs-sm, 13px);
  font-weight: var(--fw-semibold, 600);
}

/* ---- F5/F6 tombstone: the residue of a consumed / removed media item -- */
.tombstone-bubble {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  align-self: flex-start;
  padding: 6px 11px;
  border-radius: var(--radius-full, 999px);
  background: var(--surface-raised, #1c2030);
  border: 1px dashed var(--border-strong, rgba(255, 255, 255, 0.10));
  color: var(--text-tertiary, #8a93a3);
  font-size: var(--fs-xs, 11px);
}
.tombstone-bubble > svg {
  flex: 0 0 auto;
  width: 15px;
  height: 15px;
  display: block;
  color: var(--text-tertiary, #8a93a3);
}
.tombstone-bubble__label { font-weight: var(--fw-semibold, 600); }
.tombstone-bubble__time {
  color: var(--text-disabled, #5c6373);
  font-size: var(--fs-2xs, 10px);
  font-variant-numeric: tabular-nums;
}

/* ==================================================================== *
 * 13. Composer media controls + disappearing-message chips
 *
 * ui.js (owner H) adds, beside the existing .composer__input/.composer__send:
 *   .composer__attach   (paperclip → photo/video pick)
 *   .composer__mic      (hold-to-record voice; .is-recording while capturing)
 *   .ttl-chip           (set/show the conversation TTL; .is-on when armed)
 *   .countdown-chip     (per-message remaining time; .is-urgent near expiry —
 *                        app.js re-stamps it each 1s tick)
 * Sizing mirrors .composer__send so the row stays balanced.
 * ==================================================================== */
.composer__attach,
.composer__mic {
  flex: 0 0 auto;
  width: var(--tap-target, 44px);
  height: var(--tap-target, 44px);
  border-radius: var(--radius-full, 999px);
  display: grid;
  place-items: center;
  color: var(--text-tertiary, #8a93a3);
  background: transparent;
  transition: transform var(--motion-instant, 80ms) var(--ease-standard, ease),
    background-color var(--motion-fast, 140ms) var(--ease-standard, ease),
    color var(--motion-fast, 140ms) var(--ease-standard, ease);
}
.composer__attach svg,
.composer__mic svg { width: 24px; height: 24px; display: block; }
.composer__attach:active,
.composer__mic:active {
  background: var(--surface-hover, #252a3a);
  transform: scale(0.92);
}

/* Recording: mic flushes danger with an expanding pulse ring (hold gesture). */
.composer__mic.is-recording {
  position: relative;
  color: var(--danger-text, #ffffff);
  background: var(--danger, #f6465d);
}
.composer__mic.is-recording::after {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: inherit;
  border: 2px solid var(--danger, #f6465d);
  pointer-events: none;
  animation: mic-record-pulse 1.3s var(--ease-standard, cubic-bezier(0.4, 0, 0.2, 1)) infinite;
}

/* TTL chip: neutral pill by default; gold-armed when a timer is set. */
.ttl-chip {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 30px;
  padding: 0 10px;
  border-radius: var(--radius-full, 999px);
  background: var(--surface-raised, #1c2030);
  border: 1px solid var(--border, rgba(255, 255, 255, 0.05));
  color: var(--text-tertiary, #8a93a3);
  font-size: var(--fs-xs, 11px);
  font-weight: var(--fw-semibold, 600);
  letter-spacing: var(--ls-wide, 0.02em);
  transition: background-color var(--motion-fast, 140ms) var(--ease-standard, ease),
    color var(--motion-fast, 140ms) var(--ease-standard, ease),
    border-color var(--motion-fast, 140ms) var(--ease-standard, ease);
}
.ttl-chip svg { width: 15px; height: 15px; display: block; }
.ttl-chip:active { background: var(--surface-hover, #252a3a); }
/* Armed: green "protection ON" (calm, persistent). Gold is reserved for the
   per-message .countdown-chip.is-urgent (imminent expiry), so the two states
   never read the same. */
.ttl-chip.is-on {
  color: var(--success, #0ecb81);
  background: color-mix(in srgb, var(--success, #0ecb81) 15%, transparent);
  border-color: color-mix(in srgb, var(--success, #0ecb81) 38%, transparent);
}

/* Countdown chip: tiny inline clock + remaining time, sits in a bubble meta.
   Goes gold + gently pulses in its final stretch (app.js toggles .is-urgent). */
.countdown-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: var(--fs-2xs, 10px);
  font-weight: var(--fw-semibold, 600);
  font-variant-numeric: tabular-nums;
  line-height: 1;
  color: var(--text-tertiary, #8a93a3);
}
.countdown-chip svg { width: 11px; height: 11px; display: block; }
.countdown-chip.is-urgent {
  color: var(--warning, #d4a72c);
  animation: countdown-pulse 1.4s var(--ease-standard, ease) infinite;
}

/* New-component keyframes (all no-op'd under reduced motion — §15). */
@keyframes mic-record-pulse {
  0%   { transform: scale(0.9); opacity: 0.7; }
  70%  { transform: scale(1.55); opacity: 0; }
  100% { transform: scale(1.55); opacity: 0; }
}
@keyframes countdown-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.45; }
}

/* ==================================================================== *
 * 14. Fullscreen media viewer (F2 photo/video, F6 view-once)
 *
 * media-view.js appends .viewer to document.body — OUTSIDE #app — so the
 * #app-scoped reset and the §11 reduced-motion collapse DO NOT reach it.
 * Therefore this section carries its own box-sizing + font reset, and §15
 * adds an explicit reduced-motion override for the viewer's own animation.
 *
 * DOM: .viewer[role=dialog] > .viewer__scrim + .viewer__close
 *      + .viewer__stage > (.viewer__img | .viewer__video | .viewer__gone)
 * .no-anim is added by media-view.js when prefers-reduced-motion is set.
 * No download affordance is styled in (media-view hardens the elements).
 * ==================================================================== */
.viewer {
  position: fixed;
  inset: 0;
  z-index: var(--z-toast, 200);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-system, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif);
  color: var(--text-primary, #eaecef);
  -webkit-tap-highlight-color: transparent;
  animation: viewer-in var(--motion-base, 220ms) var(--ease-decel, cubic-bezier(0, 0, 0.2, 1)) both;
}
.viewer,
.viewer *,
.viewer *::before,
.viewer *::after { box-sizing: border-box; }
.viewer.no-anim { animation: none; }

.viewer__scrim {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: var(--scrim, rgba(3, 4, 8, 0.70));
  /* deepen the media lightbox a step past the modal scrim without a new token */
  background-color: rgba(3, 4, 8, 0.92);
}

.viewer__stage {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 100vw;
  max-height: 100dvh;
  padding: calc(var(--sp-8, 40px) + env(safe-area-inset-top, 0px))
           var(--sp-3, 12px)
           calc(var(--sp-6, 24px) + env(safe-area-inset-bottom, 0px));
  animation: viewer-stage-in var(--motion-base, 220ms) var(--ease-decel, cubic-bezier(0, 0, 0.2, 1)) both;
}
.viewer.no-anim .viewer__stage { animation: none; }

.viewer__img,
.viewer__video {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: var(--radius-sm, 8px);
  background: #000;
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
}

.viewer__close {
  position: absolute;
  top: calc(var(--sp-2, 8px) + env(safe-area-inset-top, 0px));
  left: var(--sp-2, 8px);
  z-index: 2;
  width: var(--tap-target, 44px);
  height: var(--tap-target, 44px);
  border-radius: var(--radius-full, 999px);
  display: grid;
  place-items: center;
  color: #fff;
  background: rgba(3, 4, 8, 0.5);
  border: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color var(--motion-fast, 140ms) var(--ease-standard, ease),
    transform var(--motion-instant, 80ms) var(--ease-standard, ease);
}
.viewer__close:active { transform: scale(0.92); background: rgba(3, 4, 8, 0.68); }
.viewer__close svg { width: 24px; height: 24px; display: block; }

/* Blob already gone (shredded / chaff): a neutral "no longer available" state —
   byte-indistinguishable from a never-existed blob, per the deniability model. */
.viewer__gone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-2, 8px);
  padding: var(--sp-6, 24px);
  color: var(--text-secondary, #b7bdc6);
  text-align: center;
  font-size: var(--fs-sm, 13px);
}
.viewer__gone svg { width: 28px; height: 28px; display: block; color: var(--warning, #d4a72c); }

@keyframes viewer-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes viewer-stage-in {
  from { opacity: 0.6; transform: scale(0.96); }
  to   { opacity: 1;   transform: scale(1); }
}

/* ==================================================================== *
 * 15. Reduced motion — new surfaces.
 *     §11 already collapses every animation/transition on #app descendants
 *     (covers the voice/media bubbles + composer chips). This block adds the
 *     pieces §11 cannot reach or should hold static: the body-mounted viewer,
 *     and the infinite pulses (held at a visible static state, not mid-fade).
 * ==================================================================== */
@media (prefers-reduced-motion: reduce) {
  .viewer,
  .viewer.no-anim { animation: none !important; opacity: 1 !important; }
  .viewer__stage,
  .viewer.no-anim .viewer__stage { animation: none !important; transform: none !important; }
  /* Hold a solid ring / full-opacity chip instead of an invisible end-frame. */
  .composer__mic.is-recording::after { animation: none !important; }
  .countdown-chip.is-urgent { animation: none !important; }
}
