/* ============================================================================
   ComplyChat — Governed Rooms PWA
   Red-skinned WhatsApp-mimic. Brand colour = RED (never WhatsApp green/teal).
   Own artwork only: the wallpaper is our own CSS/SVG doodle pattern in muted
   tones; icons are our own SVG glyphs. British English throughout.
   ========================================================================== */

:root {
  --red:        #b3261e;   /* primary brand red — FILL behind white text (topbar, buttons, badges, send FAB) */
  --red-dark:   #8c1d17;   /* darker fill for :hover states */
  --red-accent: #b3261e;   /* brand red used as TEXT/GLYPH on the app background (senders, links, read ticks,
                              pills). Split from --red so dark mode can lift it to a legible light red while the
                              fills stay deep enough to keep white text readable. */
  --red-tint:   #fde7e5;   /* outgoing bubble tint (light red/pink) */
  --ink:        #1c1b1f;
  --ink-soft:   #5b5960;
  --line:       #e3e1e6;
  --bg-app:     #f4f2f5;
  --bg-surface: #ffffff;   /* elevated light surfaces: cards, chats-list, rows, composer field, coachmark */
  --bg-bubble-in: #ffffff;
  --tick-grey:  #8b9aa6;
  --unread-red: var(--red);
  --wallpaper-base: #efeae1;         /* cream backdrop, recoloured doodle's light end */
  --safe-top:    env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  /* 64px — reference --screen-main-header-height:77px is a DESKTOP two/three-pane figure (messaging-
     conventions spec §4, §10 breakpoints); scaled down for our single-column mobile PWA rather than
     adopted verbatim (spec §11 gap row 9 explicitly calls for "scaled sensibly for mobile", not the
     desktop px). */
  --topbar-h: 64px;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0,0,0,.12);
  /* Two-layer focus-visible ring (spec §11 gap row 32 — the reference defines an explicit two-layer
     ring; own colours, not the reference's literal blue: an inner --bg-surface layer resets whatever
     sits under the ring, an outer --red-accent layer gives the visible brand-coloured ring). */
  --focus-ring: 0 0 0 2px var(--bg-surface), 0 0 0 4px var(--red-accent);
  /* One-directional UI-feedback curve shape (spec §9/§11 gap row 28 — reference --animation-curve-
     responsive-default). Adopted as a curve SHAPE for our existing transitions, not a copied rule; the
     symmetric looping animations (.rec-dot pulse, .msg--flash) keep plain ease/ease-in-out since a
     fast-out/slow-in curve reads oddly on a breathing loop. */
  --ease-responsive: cubic-bezier(.1, 1, .36, 1);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  /* Pull-to-refresh guard: Chrome reads this off the ROOT (html), not body — the old body-only value
     was ignored, letting a downward drag on a non-scrolling surface (attach sheet) reload the app. */
  overscroll-behavior-y: none;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg-app);
  -webkit-font-smoothing: antialiased;
}

.app {
  height: 100%;
  max-width: 560px;          /* phone-width app, centred on desktop */
  margin: 0 auto;
  position: relative;
  background: var(--bg-app);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* The hidden attribute MUST win over the display rules below — view switching
   (#view-landing/otp/rooms/room) and the coachmark all rely on [hidden] to hide. */
[hidden] { display: none !important; }

.view {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* ── Recording-dot motif ──────────────────────────────────────────────────── */
.rec-dot {
  display: inline-block;
  flex: 0 0 auto; /* never let a flex row (brand / topbar / auth-note) squash the dot into an oval */
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 0 4px rgba(179, 38, 30, .18);
  animation: rec-pulse 2s ease-in-out infinite;
}
.rec-dot--sm { width: 9px; height: 9px; box-shadow: 0 0 0 3px rgba(179, 38, 30, .18); }
@keyframes rec-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: .45; }
}
@media (prefers-reduced-motion: reduce) {
  .rec-dot { animation: none; }
}

/* ============================================================================
   Auth views (landing + OTP)
   ========================================================================== */
.view--auth {
  justify-content: center;
  align-items: center;
  /* safe-top so the auth card never underlaps the status bar in an installed PWA (black-translucent overlays). */
  padding: calc(24px + var(--safe-top)) 18px calc(24px + var(--safe-bottom));
  background:
    radial-gradient(120% 80% at 50% -10%, #fff 0%, var(--bg-app) 60%);
}
.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg-surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 26px 22px;
  box-shadow: 0 6px 24px rgba(0,0,0,.06);
}
.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 18px;
}
.brand-name { font-weight: 700; letter-spacing: .2px; }
.auth-eyebrow { font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-soft); font-weight: 700; margin: 0 0 6px; }
.auth-eyebrow[hidden] { display: none; }
.auth-title { font-size: 1.4rem; margin: 0 0 4px; }
.auth-sub { color: var(--ink-soft); font-size: .95rem; margin: 0 0 18px; }
.auth-form { display: flex; flex-direction: column; gap: 6px; }
/* Passkey sign-in (Brief 17.P3) — full-width primary button with a lock glyph; the phone form stays
   below as the universal fallback. Hidden until app.js reveals it (feature live + platform support). */
.btn--passkey { display: flex; align-items: center; justify-content: center; gap: 9px; }
.btn--passkey[hidden] { display: none; }
.passkey-ico { flex: 0 0 auto; }
.auth-or { display: flex; align-items: center; gap: 12px; color: var(--ink-soft); font-size: .8rem; margin: 14px 0 8px; }
.auth-or[hidden] { display: none; }
.auth-or::before, .auth-or::after { content: ""; flex: 1 1 auto; height: 1px; background: var(--line); }
.field-label { font-size: .8rem; font-weight: 600; color: var(--ink-soft); }
.field {
  font-size: 1.05rem;
  font-family: inherit; /* a <textarea> defaults to monospace otherwise — the event "Details" field (Brief 17.A) */
  padding: 12px 14px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  outline: none;
  transition: border-color .15s var(--ease-responsive);
}
.field:focus { border-color: var(--red); }
.field--otp {
  letter-spacing: .5em;
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-size: 1.4rem;
}
.field-error {
  color: var(--red-dark);
  font-size: .85rem;
  margin: 2px 0 0;
}
.otp-phone { font-weight: 600; color: var(--ink); }
.auth-note {
  margin: 18px 0 0;
  font-size: .8rem;
  color: var(--ink-soft);
  display: flex;
  align-items: baseline;
  gap: 7px;
  line-height: 1.4;
}

.btn {
  font: inherit;
  cursor: pointer;
  border: none;
  border-radius: var(--radius);
}
.btn--primary {
  background: var(--red);
  color: #fff;
  font-weight: 600;
  padding: 13px 16px;
  margin-top: 8px;
}
.btn--primary:hover { background: var(--red-dark); }
.btn--primary:disabled { opacity: .6; cursor: progress; }
.btn--link {
  background: none;
  color: var(--ink-soft);
  padding: 8px;
  text-decoration: underline;
}

/* ============================================================================
   App chrome (chats-list + conversation)
   ========================================================================== */
.topbar {
  flex: 0 0 auto;
  min-height: var(--topbar-h);
  padding-top: var(--safe-top);
  background: var(--red);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 10px;
  padding-left: 14px;
  padding-right: 14px;
  box-shadow: var(--shadow);
  z-index: 5;
}
.topbar-title {
  font-size: 1.1rem;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 auto;
}
.topbar-title .rec-dot { background: #fff; box-shadow: 0 0 0 3px rgba(255,255,255,.3); }
.topbar-action {
  font: inherit;
  background: rgba(255,255,255,.18);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 7px 12px;
  cursor: pointer;
}
.topbar-action:hover { background: rgba(255,255,255,.3); }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  padding: 6px;
  border-radius: 50%;
}

/* ── Chats-list search ────────────────────────────────────────────────────── */
.rooms-search {
  flex: 0 0 auto;
  padding: 8px 12px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--line);
}
.rooms-search-input {
  width: 100%;
  font: inherit;
  font-size: .95rem;
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--bg-app);
  color: var(--ink);
  outline: none;
}
.rooms-search-input:focus { border-color: var(--red); }
.rooms-search-input::placeholder { color: var(--ink-soft); }

/* ── Chats-list ───────────────────────────────────────────────────────────── */
.rooms-list {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--bg-surface);
}

/* New-chat floating action button — bottom-right of the chats-list (position parity). */
.fab {
  position: absolute;
  right: 16px;
  bottom: calc(20px + var(--safe-bottom));
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--red);
  color: #fff;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 10px rgba(0,0,0,.3);
  cursor: pointer;
  z-index: 6;
}
.fab:hover { background: var(--red-dark); }
.fab:active { transform: scale(.96); }
.room-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  cursor: pointer;
  /* No persistent row divider — messaging-conventions spec §3/§11 gap row 5: reference rows carry
     --list-border-width:0, separated by padding + hover fill only. */
  border: none;
  text-align: left;
  width: 100%;
  background: var(--bg-surface);
  font: inherit;
  color: inherit;
}
.room-row:hover { background: #faf8f9; }
.room-row:active { background: #f1eef0; }

.avatar {
  flex: 0 0 auto;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #fff;
  font-size: 1.05rem;
  user-select: none;
}
/* Group icon image fill (Brief 12.23) — applies to any room-avatar node (.avatar, .room-avatar, .profile-av). */
.avatar--img { background-size: cover !important; background-position: center; }
.profile-icon-btn {
  margin-top: 8px; font: inherit; font-size: .82rem;
  background: none; border: 1px solid var(--line); border-radius: 16px; padding: 5px 14px;
  color: var(--red-accent); cursor: pointer;
}
.profile-icon-btn:hover { border-color: var(--red-accent); }
.room-meta {
  flex: 1 1 auto;
  min-width: 0;
}
.room-name {
  /* Type-scale correction — messaging-conventions spec §2/§11 gap row 2: reference primary-label is
     15px/500, not 16px/600. */
  font-weight: 500;
  font-size: .9375rem;
  line-height: 1.2667;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.room-preview {
  color: var(--ink-soft);
  /* Type-scale correction — spec §2/§11 gap row 3: reference secondary-label is 13px/500, 17px line-height. */
  font-size: .8125rem;
  font-weight: 500;
  line-height: 1.3077;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 5px; /* reference --list-cell-text-padding — spec §3/§11 gap row 6 */
}
.room-side {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 5px;
}
/* Type-scale correction — spec §2/§11 gap row 4: reference tertiary-label is 11px/500, 16px line-height. */
.room-time { font-size: .6875rem; font-weight: 500; line-height: 1.4545; color: var(--ink-soft); }
.unread-badge {
  min-width: 20px;
  height: 20px;
  padding: 0 8px; /* reference badge-inner-padding-horizontal — spec §3/§11 gap row 8 (6px → 8px) */
  border-radius: 10px;
  background: var(--unread-red);
  color: #fff;
  font-size: .72rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.room-time.has-unread { color: var(--unread-red); font-weight: 600; }
/* Per-room draft prefix (Brief 12.5) — red "Draft:" tag on the chat-list preview. */
.room-draft-tag { color: var(--red-accent); font-weight: 600; }
/* Unread-mention @ badge (Brief 12.27) + composer mention typeahead sheet. */
.room-at-badge {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px;
  background: var(--red); color: #fff; font-size: .72rem; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}
.mention-sheet {
  flex: 0 0 auto; max-height: 40vh; overflow-y: auto;
  background: var(--bg-surface); border-top: 1px solid var(--line);
}
.mention-row {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 9px 14px; background: none; border: none; border-bottom: 1px solid var(--line); cursor: pointer; font: inherit; color: var(--ink);
}
.mention-row:hover { background: var(--bg-app); }
.mention-av { flex: 0 0 auto; width: 32px; height: 32px; border-radius: 50%; color: #fff; display: flex; align-items: center; justify-content: center; font-size: .78rem; font-weight: 700; }
.mention-name { font-size: .92rem; }
/* Pinned-row glyph (Brief 12.7). */
.room-pin { display: inline-flex; color: var(--ink-soft); }

/* ── Chats-list row action sheet (Brief 12.7) — Pin/Unpin + Mute ─────────────── */
.sheet-overlay {
  position: fixed; inset: 0; z-index: 65;
  background: rgba(0,0,0,.4);
  display: flex; align-items: flex-end; justify-content: center;
  padding: 0 10px calc(12px + var(--safe-bottom));
}
.action-sheet {
  width: 100%; max-width: 440px;
  background: var(--bg-surface); border-radius: 16px; overflow: hidden;
  box-shadow: 0 -4px 24px rgba(0,0,0,.25);
}
.action-sheet-title {
  font-size: .82rem; font-weight: 700; color: var(--ink-soft);
  padding: 12px 16px 8px; border-bottom: 1px solid var(--line);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.action-sheet-item {
  width: 100%; text-align: left; font: inherit; font-size: 1rem;
  background: none; border: none; border-bottom: 1px solid var(--line);
  padding: 14px 16px; color: var(--ink); cursor: pointer;
}
.action-sheet-item:hover { background: var(--bg-app); }
.action-sheet-cancel {
  width: 100%; font: inherit; font-size: 1rem; font-weight: 600;
  background: none; border: none; padding: 14px 16px; color: var(--red-accent); cursor: pointer;
}
.action-sheet-cancel:hover { background: var(--bg-app); }

.rooms-empty {
  padding: 40px 24px;
  text-align: center;
  color: var(--ink-soft);
}

/* ── Conversation view ────────────────────────────────────────────────────── */
.topbar--room { padding-left: 4px; }
.room-avatar {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #fff;
  background: var(--red-dark);
  font-size: .9rem;
}
.room-head { display: flex; flex-direction: column; min-width: 0; flex: 1 1 auto; }
.room-title {
  font-size: 1.02rem;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.room-sub { font-size: .74rem; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* Live "X is typing…" takes the subtitle over (visual-parity pass 2026-07-05 — header placement). */
.room-sub--typing { font-style: italic; opacity: 1; }
/* Chat-list preview swap while someone types in a NON-open room (parity pass). */
.room-preview--typing { color: var(--red-accent); font-style: italic; }

/* Wallpaper — doodle art (wallpaper-pattern.png, our own artwork — not WhatsApp's),
   shown once as a full-bleed backdrop (not tiled — the source art has no clean
   repeat unit, so tiling it left visible seams). The ::before layer carries the
   pattern through a duotone filter (defined in index.html) that recolours its
   dark-on-white line art to tan-on-cream, then sits at low opacity over the
   cream base so the doodle reads as a faint watermark, not a bold line drawing. */
.msg-wallpaper {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  position: relative;
  background-color: var(--wallpaper-base);
}
.msg-wallpaper::before {
  content: "";
  position: absolute;
  inset: 0;
  /* Pre-coloured school-doodle wallpaper (cream base + faint line-art baked in) — used directly, so the old
     SVG #wallpaper-duotone recolour + .15 opacity are no longer needed in light mode. */
  background-image: url("background_100.jpg");
  background-repeat: no-repeat;
  background-size: cover;
  background-position: center;
  opacity: 1;
  z-index: 0;
}
.msg-list {
  position: relative;
  z-index: 1;
  height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px 10px calc(12px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  /* Spacing is driven by per-bubble margin-top below (grouping rhythm — spec §5/§11 gap row 14), not a
     flat flex gap, so a same-sender stack can sit tight while a new sender/time group gets real air. */
}

/* Grouping rhythm (spec §5 --chat-spacing/-adj: 15-18px between sender/time groups, tight same-sender
   stacking — §11 gap row 14). Default: every bubble starts a new group. refreshGrouping() (app.js) then
   toggles .msg--grouped on consecutive same-sender messages within a 5-min window, which overrides this
   down to a tight stack below. */
.msg { margin-top: 16px; }
.msg-list > .msg:first-child { margin-top: 0; }

/* Date separator + system line (centred pills) */
.day-sep, .system-line {
  align-self: center;
  background: rgba(255,255,255,.92);
  color: var(--ink-soft);
  font-size: .74rem;
  padding: 4px 12px;
  border-radius: 14px;
  margin: 8px 0;
  box-shadow: var(--shadow);
  text-align: center;
  max-width: 86%;
}
/* A message right after a day pill / system line already inherits that pill's own vertical margin, so
   the full 16px new-group margin above would double up the separation — trim it back. */
.day-sep + .msg, .system-line + .msg, .unread-sep + .msg { margin-top: 6px; }

/* "N unread messages" divider (visual-parity pass 2026-07-05) — a wide catch-up pill planted where the unread
   run starts on room open; purely visual, gone on the next open. Same chip family as the day pill. */
.unread-sep {
  align-self: center;
  width: min(78%, 340px);
  background: rgba(255,255,255,.95);
  color: var(--ink-soft);
  font-size: .78rem;
  padding: 5px 12px;
  border-radius: 14px;
  margin: 10px 0;
  box-shadow: var(--shadow);
  text-align: center;
}
.system-line {
  display: flex;
  align-items: center;
  gap: 7px;
  background: rgba(255, 240, 239, .95);
  color: var(--red-accent);
}

/* Bubbles — incoming white/light on the left; outgoing light-red tint on the
   right; little tail on the top corner (mirrors WhatsApp structure).
   Visual-parity pass 2026-07-05 (side-by-side screenshot ground truth, reference/Test/): radius up to 13px
   with a subtle lift shadow, text is non-selectable on touch (long-press must open the action bar, not the
   OS text-selection loupe — desktop keeps selection), and the meta (time+ticks) tucks inline — see
   .msg--inlinefoot below. */
.msg {
  max-width: 80%;
  /* Asymmetric horizontal padding (leading 9px / trailing 7px) — spec §5/§11 gap row 12. Vertical
     7px/6px is left as-is (spec §11 gap row 13 — the reference's third padding token is ambiguous,
     unbindable to a specific box; insufficient evidence to change). */
  padding: 7px 7px 6px 9px;
  border-radius: 13px;
  position: relative;
  /* Type-scale correction — spec §2/§11 gap row 1: reference body text is 15px, 19px line-height. */
  font-size: .9375rem;
  line-height: 1.2667;
  box-shadow: 0 1px .5px rgba(0, 0, 0, .1); /* the reference's whisper of lift off the wallpaper */
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
@media (hover: none) {
  .msg, .msg * { user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
}
.msg--in {
  align-self: flex-start;
  background: var(--bg-bubble-in);
  border-top-left-radius: 2px;
}
.msg--out {
  align-self: flex-end;
  background: var(--red-tint);
  border-top-right-radius: 2px;
}
/* Tails — reverted to the crisp corner triangle (2026-07-02): the rounded-square "soft tail"
   approximation read as a blob, not a flick. The reference's real tail is an SVG path; a proper
   own-drawn SVG tail is queued for the next look pass with visual ground truth. */
.msg--in::before,
.msg--out::before {
  content: "";
  position: absolute;
  top: 0;
  width: 0;
  height: 0;
  border: 7px solid transparent;
}
.msg--in::before {
  left: -7px;
  border-top-color: var(--bg-bubble-in);
  border-right-color: var(--bg-bubble-in);
}
.msg--out::before {
  right: -7px;
  border-top-color: var(--red-tint);
  border-left-color: var(--red-tint);
}

/* Consecutive-message grouping: a continued run from the same sender loses its tail, hides the repeated sender
   name, tucks up tighter, and re-rounds the tail-side corner so the run reads as one stacked block. Tight
   same-sender spacing (2px) vs the 16px new-group margin above — spec §5/§11 gap row 14. */
.msg--grouped { margin-top: 2px; }
.msg--grouped::before { display: none; }
.msg--grouped .msg-sender { display: none; }
.msg--grouped.msg--in  { border-top-left-radius: 13px; }
.msg--grouped.msg--out { border-top-right-radius: 13px; }

/* ── Sender avatars in group rooms (visual-parity pass 2026-07-05) ─────────────
   .msg-list--group (set on room open for group kinds) opens a left gutter; each incoming bubble carries a
   small initials avatar absolutely positioned into it, shown on the FIRST message of a cluster only. */
.msg-list--group .msg--in { margin-left: 38px; }
.msg-av {
  display: none;
  position: absolute;
  left: -38px;
  top: 0;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  color: #fff;
  font-size: .68rem;
  font-weight: 700;
  align-items: center;
  justify-content: center;
  user-select: none;
}
.msg-list--group .msg--in .msg-av { display: flex; }
.msg-list--group .msg--grouped .msg-av { display: none; }

/* ── Inline meta (visual-parity pass 2026-07-05) ───────────────────────────────
   Text bubbles: the foot (time+ticks) sits absolutely at the bubble's bottom-right; a width-matched inline
   spacer at the end of .msg-text reserves room on the last line, so short messages stay ONE line tall
   ("Ok  16:09 ✓✓") and long ones tuck the meta beside the final line — instead of a full-height meta row. */
.msg--inlinefoot { padding-bottom: 7px; }
.msg--inlinefoot .msg-foot {
  position: absolute;
  right: 8px;
  bottom: 4px;
  margin-top: 0;
}
.msg-meta-spacer { display: inline-block; height: 1px; vertical-align: baseline; }
/* A failed send swaps in a long "tap to retry" foot — fall back to the classic block row for it. */
.msg--failed.msg--inlinefoot { padding-bottom: 6px; }
.msg--failed.msg--inlinefoot .msg-foot { position: static; margin-top: 2px; }
.msg--failed .msg-meta-spacer { display: none; }
.msg--failed.msg--mediafoot::after { display: none; }
.msg--failed.msg--mediafoot .msg-foot { position: static; margin-top: 2px; color: var(--ink-soft); z-index: auto; }

/* Captionless image: the meta floats over the photo's bottom-right on a soft scrim, in white (read ticks keep
   their accent — legible on the scrim). The scrim hugs the image's rounded bottom corners. */
.msg--mediafoot { padding-bottom: 4px; }
.msg--mediafoot::after {
  content: '';
  position: absolute;
  left: 4px;
  right: 4px;
  bottom: 4px;
  height: 30px;
  border-radius: 0 0 10px 10px;
  background: linear-gradient(transparent, rgba(0, 0, 0, .45));
  pointer-events: none;
}
.msg--mediafoot .msg-foot {
  position: absolute;
  right: 12px;
  bottom: 8px;
  margin-top: 0;
  z-index: 1;
  color: rgba(255, 255, 255, .95);
}
.msg--mediafoot .ticks--sent,
.msg--mediafoot .ticks--delivered { color: rgba(255, 255, 255, .95); }

/* ── Jumbo emoji (visual-parity pass 2026-07-05) ───────────────────────────────
   A message that is only 1–3 emoji renders them big; an OWN one drops the bubble fill entirely and the meta
   becomes its own small tinted pill under the emoji (the familiar big-👍 look). Incoming keeps its bubble
   (the sender name needs a surface in groups). */
.msg--jumbo .msg-text { line-height: 1.15; }
.msg--jumbo-1 .msg-text { font-size: 2.9rem; }
.msg--jumbo-2 .msg-text { font-size: 2.4rem; }
.msg--jumbo-3 .msg-text { font-size: 2rem; }
.msg--jumbo.msg--out {
  background: transparent;
  box-shadow: none;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  padding-right: 0;
}
.msg--jumbo.msg--out::before { display: none; }
.msg--jumbo.msg--out .msg-foot {
  background: var(--red-tint);
  border-radius: 12px;
  padding: 2px 9px;
  margin-top: 4px;
  box-shadow: 0 1px .5px rgba(0, 0, 0, .1);
}

.msg-sender {
  font-size: .76rem;
  font-weight: 700;
  margin-bottom: 1px;
  color: var(--red-accent);
}
.msg-text { white-space: pre-wrap; }
/* @mention token (Brief 12.27) — red accent; a message that mentions the viewer gets a subtle bubble treatment. */
.msg-mention { color: var(--red-accent); font-weight: 600; }
.msg--mentions-me { box-shadow: inset 3px 0 0 var(--red-accent); }
/* Inline formatting (Brief 12.9): monospace `code` gets a subtle tinted chip; strong/em/del render natively. */
.msg-text code { font-family: ui-monospace, Menlo, Consolas, "Courier New", monospace; font-size: .88em; background: rgba(0,0,0,.06); border-radius: 4px; padding: 0 3px; }
@media (prefers-color-scheme: dark) { .msg-text code { background: rgba(255,255,255,.1); } }
/* Linkified URLs inside a bubble — accent red + underline in both schemes; break long URLs so they can't
   overflow the bubble. Inherits legible contrast from --red-accent (deep red on light, light red on dark). */
.msg-link { color: var(--red-accent); text-decoration: underline; overflow-wrap: anywhere; }
/* Link unfurl card (GR-LINKPREVIEW-1, round 4 2026-07-05) — image, title, description, domain above the text. */
.msg--linkpre { width: min(80%, 340px); }
.link-preview {
  display: block;
  background: rgba(0, 0, 0, .06);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 5px;
  text-decoration: none;
  color: inherit;
}
@media (prefers-color-scheme: dark) { .link-preview { background: rgba(255, 255, 255, .07); } }
.lp-img { display: block; width: 100%; max-height: 170px; object-fit: cover; }
.lp-body { padding: 7px 9px 8px; }
.lp-title {
  font-weight: 600; font-size: .9rem; line-height: 1.25;
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.lp-desc {
  font-size: .8rem; color: var(--ink-soft); line-height: 1.3; margin-top: 2px;
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.lp-domain { font-size: .74rem; color: var(--ink-soft); margin-top: 3px; }
.msg-img {
  display: block;
  max-width: 100%;
  border-radius: 6px; /* reference --image-corner-radius — spec §8/§11 gap row 25 (8px → 6px) */
  margin-bottom: 3px;
}
.msg-img { cursor: pointer; } /* Brief 12.19 — tap opens the lightbox */
/* Media bubble (visual-parity pass 2026-07-05): a photo/video bubble hugs its media with a slim 4px frame,
   a fixed comfortable width, and a capped height (a tall portrait crops instead of towering) — the reference
   media-tile geometry. The caption inherits the bubble's text styles beneath. */
.msg--media { padding: 4px; max-width: min(78%, 340px); }
.msg-list--group .msg--in.msg--media { max-width: min(78vw - 38px, 340px); }
.msg--media .msg-img {
  width: 100%;
  max-height: 420px;
  object-fit: cover;
  border-radius: 10px;
  margin-bottom: 0;
}
.msg--media .msg-quote { margin: 3px 3px 6px; }
.msg--media .msg-text { padding: 5px 4px 1px; }
.msg--media .msg-sender, .msg--media .msg-fwd { padding: 2px 4px 0; }
.msg--media.msg--inlinefoot .msg-foot { right: 10px; }
.msg-img--missing {
  font-size: .82rem;
  color: var(--ink-soft);
  font-style: italic;
}

/* ══ Structured message types (Brief 09): poll / event / location / contact ══════════════════════════════════
   Shared card chrome — a bordered inset block inside the bubble, RED accent (never green/blue). Individual card
   internals are appended by their item below. */
/* 09.1 — the defensive [unsupported message] fallback chip (a type an older cached client can't render). */
.msg-unsupported {
  border: 1px dashed var(--line, rgba(0,0,0,.2));
  border-radius: 8px;
  padding: 8px 10px;
  font-size: .9rem;
  color: var(--ink-soft);
  max-width: 260px;
}
.msg-unsupported-head { font-weight: 600; }
.msg-unsupported-hint { font-size: .78rem; opacity: .8; margin-top: 2px; }

/* Shared card furniture (visual-parity pass 2026-07-05): full-width hairline-divided action rows at the foot
   of a structured card — the "View votes" / "Add to calendar" / "Save contact" convention. */
.card-action {
  display: block; width: 100%; text-align: center;
  background: none; border: none; border-top: 1px solid color-mix(in srgb, var(--ink) 12%, transparent);
  margin-top: 8px; padding: 10px 4px 4px;
  color: var(--red-accent); font: inherit; font-size: .92rem; font-weight: 600; cursor: pointer;
  text-decoration: none;
}
.card-action + .card-action { margin-top: 0; padding-top: 10px; }
.card-action:hover { filter: brightness(.92); }

/* 09.2 — poll card (visual-parity pass 2026-07-05): bold question + select hint, borderless option rows
   (round check · label · count) over full-width progress bars, hairline-divided footer actions. */
.poll-card { min-width: 230px; max-width: 320px; padding: 2px 2px 0; }
.poll-q { font-weight: 700; font-size: 1rem; margin-bottom: 2px; }
.poll-hint { font-size: .78rem; color: var(--ink-soft); margin-bottom: 8px; }
.poll-opt {
  display: block; width: 100%; text-align: left;
  border: none; border-radius: 0;
  padding: 5px 0 7px; margin: 0; background: none;
  color: inherit; font: inherit; cursor: pointer;
}
.poll-opt:disabled { cursor: default; }
.poll-opt-top { display: flex; align-items: center; gap: 8px; margin-bottom: 5px; }
.poll-opt-radio {
  flex: 0 0 auto; width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--ink-soft) 60%, transparent);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: .66rem; font-weight: 700; color: #fff; line-height: 1;
}
.poll-opt-radio--on { border-color: var(--red-accent); background: var(--red-accent); }
.poll-opt-label { flex: 1 1 auto; min-width: 0; }
.poll-opt--mine .poll-opt-label { font-weight: 600; }
.poll-opt-count { flex: 0 0 auto; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--ink-soft); }
.poll-opt-track { display: block; height: 5px; border-radius: 3px; background: color-mix(in srgb, var(--ink) 10%, transparent); margin-left: 26px; overflow: hidden; }
.poll-opt-bar { display: block; height: 100%; width: 0; border-radius: 3px; background: var(--red-accent); transition: width .25s ease; }
/* Legacy hooks kept for the who-voted sheet typography. */
.poll-link { background: none; border: none; padding: 0; color: var(--red-accent); font: inherit; font-size: .8rem; font-weight: 600; cursor: pointer; }
/* Poll builder (composer) + who-voted sheet — inside the shared history-card modal. */
.poll-builder .pb-body { text-align: left; max-height: 62vh; max-height: 60dvh; overflow-y: auto; }
.pb-field { display: block; margin: 8px 0; }
.pb-label { display: block; font-size: .8rem; color: var(--ink-soft); margin-bottom: 3px; }
.pb-opts { margin-bottom: 6px; }
.pb-optrow { display: flex; align-items: center; gap: 6px; margin: 4px 0; }
.pb-optrow .field { flex: 1; }
.pb-optdel { background: none; border: none; color: var(--ink-soft); cursor: pointer; font-size: 1rem; padding: 4px; }
.pb-toggle { display: flex; align-items: center; gap: 8px; margin: 8px 0; cursor: pointer; }
.poll-vsec { margin: 8px 0; text-align: left; }
.poll-vsec-title { font-weight: 700; font-size: .85rem; margin-bottom: 2px; }
.poll-voter { font-size: .85rem; padding: 2px 0; color: var(--ink-soft); }
/* 09.3 — event card (visual-parity pass 2026-07-05): round calendar badge · bold title · when/where · "N going",
   one segmented RSVP row, then hairline-divided action rows. */
.event-card { min-width: 240px; max-width: 320px; padding: 2px 2px 0; }
.event-card--past { opacity: .6; }
.event-head { display: flex; gap: 10px; align-items: flex-start; }
.event-badge {
  flex: 0 0 auto; width: 40px; height: 40px; border-radius: 50%;
  background: var(--bg-surface); box-shadow: 0 1px 2px rgba(0,0,0,.12);
  display: inline-flex; align-items: center; justify-content: center; font-size: 1.25rem;
}
.event-head-body { flex: 1 1 auto; min-width: 0; }
.event-title { font-weight: 700; font-size: 1rem; }
.event-when { font-size: .85rem; margin-top: 1px; }
.event-loc, .event-desc { font-size: .82rem; color: var(--ink-soft); margin-top: 2px; }
.event-going { font-size: .8rem; color: var(--ink-soft); margin-top: 3px; }
/* One segmented row of the three responses, split by hairlines (the paired-action row convention). */
.event-rsvp { display: flex; margin-top: 10px; border-top: 1px solid color-mix(in srgb, var(--ink) 12%, transparent); }
.event-rsvp-btn {
  flex: 1; border: none; border-left: 1px solid color-mix(in srgb, var(--ink) 12%, transparent);
  padding: 10px 2px 4px; background: none; color: var(--red-accent); font: inherit; font-size: .88rem; font-weight: 600; cursor: pointer;
}
.event-rsvp-btn:first-child { border-left: none; }
.event-rsvp-btn:hover { filter: brightness(.92); }
.event-rsvp-btn--mine { font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }

/* 09.4 — location card (an anchor; tap opens the maps app). STILL zero-egress (D6): the "map" is an abstract
   own-art street pattern drawn with CSS gradients — deliberately not real geography, no tile fetch — with a
   centred pin; coords + an "Open in Maps" action row beneath (visual-parity pass 2026-07-05). */
.location-card { display: block; text-decoration: none; color: inherit; padding: 2px 2px 0; max-width: 280px; min-width: 230px; }
.location-map {
  position: relative;
  height: 120px;
  border-radius: 10px;
  overflow: hidden;
  background:
    linear-gradient(105deg, transparent 46%, rgba(255,255,255,.9) 46%, rgba(255,255,255,.9) 54%, transparent 54%),
    linear-gradient(15deg, transparent 30%, rgba(255,255,255,.85) 30%, rgba(255,255,255,.85) 35%, transparent 35%),
    linear-gradient(15deg, transparent 64%, rgba(255,255,255,.85) 64%, rgba(255,255,255,.85) 68%, transparent 68%),
    linear-gradient(105deg, transparent 20%, rgba(255,255,255,.7) 20%, rgba(255,255,255,.7) 24%, transparent 24%),
    linear-gradient(105deg, transparent 74%, rgba(255,255,255,.7) 74%, rgba(255,255,255,.7) 77%, transparent 77%),
    linear-gradient(160deg, #dbe7d4 0%, #e3ecdc 38%, #d5e3cf 62%, #dfeadb 100%);
}
.location-pin {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -85%);
  font-size: 1.9rem; line-height: 1;
  filter: drop-shadow(0 2px 2px rgba(0,0,0,.25));
}
/* Real Azure Maps thumbnail (GR-MAPTHUMB-1, round 5) — overlays the abstract tile; its own pin renders in
   the image, so ours hides once it loads. */
.location-map-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.location-map--live .location-pin { display: none; }
.location-info { padding: 7px 4px 0; }
.location-title { font-weight: 600; }
.location-coords { font-size: .8rem; color: var(--ink-soft); font-variant-numeric: tabular-nums; }

/* 09.5 — contact card (vCard): header row (avatar · name · number), then a divided "Save contact" row. */
.contact-card { padding: 2px 2px 0; max-width: 300px; min-width: 230px; }
.contact-head { display: flex; align-items: center; gap: 10px; }
.contact-av { width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: .9rem; flex: 0 0 auto; }
.contact-info { flex: 1; min-width: 0; }
.contact-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.contact-num { font-size: .82rem; color: var(--ink-soft); }

/* (Structured attach-sheet option tints live with the attachment-sheet block below.) */
/* (Brief 09.6 GIF picker CSS removed 2026-07-05 — Tenor API decommissioned.) */

/* ── Inline video + lightbox (Brief 12.19) ──────────────────────────────────── */
.msg-video-wrap { margin-bottom: 3px; }
.msg-video-inner { position: relative; display: inline-block; max-width: 100%; }
.msg-video { display: block; max-width: 100%; max-height: 60vh; border-radius: 6px; background: #000; }
.msg-video--uploading { opacity: .7; }
.msg-video-loading { font-size: .82rem; color: var(--ink-soft); font-style: italic; padding: 20px 8px; }
.msg-video-expand {
  position: absolute; top: 6px; right: 6px;
  width: 30px; height: 30px; border-radius: 50%;
  background: rgba(0,0,0,.55); color: #fff; border: none; cursor: pointer;
  font-size: 1rem; line-height: 1; display: inline-flex; align-items: center; justify-content: center;
}
.msg-video-expand:hover { background: rgba(0,0,0,.75); }
.media-preview-video { max-width: 100%; max-height: 100%; border-radius: 10px; background: #000; }
.lightbox-overlay {
  position: fixed; inset: 0; z-index: 90;
  background: #000;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.lightbox-close {
  position: absolute; top: calc(8px + var(--safe-top)); right: 10px; z-index: 2;
  width: 40px; height: 40px; border-radius: 50%;
  background: rgba(0,0,0,.4); color: #fff; border: none; cursor: pointer;
  font-size: 1.8rem; line-height: 1;
}
.lightbox-close:hover { background: var(--red); }
.lightbox-body { flex: 1 1 auto; display: flex; align-items: center; justify-content: center; width: 100%; min-height: 0; padding: 40px 8px; }
.lightbox-media { max-width: 100%; max-height: 100%; object-fit: contain; }
.lightbox-caption {
  flex: 0 0 auto; width: 100%; max-width: 640px;
  color: #eee; font-size: .9rem; text-align: center;
  padding: 10px 16px calc(16px + var(--safe-bottom));
  white-space: pre-wrap; word-break: break-word;
}
.msg-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 2px;
  font-size: .8125rem; /* reference "meta" token, 13px — spec §2/§11 gap row 17 (10.88px → 13px) */
  color: var(--ink-soft);
}
/* Inline-trailing placement (spec §5/§11 gap row 18) — SKIPPED, kept as a block row below the text.
   See docs/design/gap-table-status.md and the note above messageBubble()'s foot construction in app.js:
   true inline-trailing needs the foot nested inside .msg-text, which conflicts with Brief 04.4's edit
   refresh (t.replaceChildren() would discard it) and Brief 03's failed-send dedup (exact textContent
   match). Only the size correction (row 17) shipped here. */

/* Failed send — dimmed (inline opacity) + tap-to-retry. The whole bubble becomes the retry target so the text
   never has to be retyped. */
.msg--failed { cursor: pointer; }
.msg--failed:hover { opacity: .8 !important; }
.msg-retry { color: var(--red-accent); font-weight: 700; }

/* Tick glyphs (our own). One grey = sent; two grey = delivered; two RED = read. */
.ticks {
  display: inline-flex;
  align-items: center;
  line-height: 1;
}
.ticks svg { display: block; }
.ticks--sent      { color: var(--tick-grey); }
.ticks--delivered { color: var(--tick-grey); }
.ticks--read      { color: var(--red-accent); }

/* ── Typing indicator (GR-B3) — a slim ephemeral line above the composer ───── */
.typing-indicator {
  flex: 0 0 auto;
  padding: 4px 14px;
  font-size: .8rem;
  font-style: italic;
  color: var(--ink-soft);
  background: var(--bg-app);
  min-height: 22px;
  line-height: 1.4;
}

/* ── Composer ─────────────────────────────────────────────────────────────── */
.composer {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  /* Horizontal padding doubled to 16px — reference --compose-box-left-right-padding, spec §6/§11 gap row 19. */
  padding: 8px 16px calc(8px + var(--safe-bottom));
  background: var(--bg-app);
  border-top: 1px solid var(--line);
}
/* Pill field holds the text input + inline icon(s), mirroring WhatsApp's
   compose field; the send button floats outside it as its own round FAB. */
.composer-field {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  background: var(--bg-surface);
  border: 1px solid var(--line);
  border-radius: 22px;
}
/* No focus tint on the composer pill (round-2 feedback 2026-07-05): the reference field stays neutral while
   typing — the caret is the cue. (Auth/search fields keep their focus border.) */
.composer-field:focus-within { border-color: var(--line); }
.icon-btn--composer { color: var(--ink-soft); margin-right: 2px; }
.icon-btn--composer:disabled { opacity: .55; cursor: default; }
.composer-input {
  flex: 1 1 auto;
  min-width: 0;
  /* Type-scale correction — spec §6/§11 gap row 21: reference composer input text is 15px/500. */
  font-size: .9375rem;
  font-weight: 500;
  padding: 11px 6px 11px 14px;
  border: none;
  outline: none;
  background: transparent;
}
.icon-btn--send {
  background: var(--red);
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  box-shadow: 0 1px 3px rgba(0,0,0,.3);
}
.icon-btn--send:hover { background: var(--red-dark); }
.icon-btn--send:disabled { opacity: .5; cursor: default; box-shadow: none; }

/* Emoji toggle sits inside the pill, left of the input; active state tints it red. */
.icon-btn--emoji { margin-left: 2px; margin-right: 0; }
.icon-btn--emoji[aria-expanded="true"] { color: var(--red-accent); }

/* ── Emoji picker panel ─────────────────────────────────────────────────────
   Stacks above the composer (flex row before the form); scrolls; grid of glyphs.
   Static data only — no framework, no dependency. */
.emoji-panel {
  flex: 0 0 auto;
  max-height: 42vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--bg-surface);
  border-top: 1px solid var(--line);
  padding: 0; /* the sticky head + body own their padding (round-3: glyphs were showing through at the top) */
}
/* Sticky OPAQUE header — grabber pill + search (round-3 feedback). Fully solid backing so scrolling glyphs
   can never show through around the pill; the grabber row is the swipe-down surface (touch-action:none). */
.emoji-head {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--bg-surface);
  padding: 0 10px 8px;
  border-bottom: 1px solid var(--line);
}
.emoji-grabber-row {
  display: flex;
  justify-content: center;
  padding: 8px 0 6px;
  touch-action: none;
  cursor: pointer;
}
.emoji-grabber-row::after {
  content: '';
  width: 40px;
  height: 4px;
  border-radius: 2px;
  background: #d4d6dc;
}
.emoji-search {
  width: 100%;
  font: inherit;
  font-size: .92rem;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--bg-app);
  color: var(--ink);
  outline: none;
}
.emoji-search::placeholder { color: var(--ink-soft); }
.emoji-body { padding: 4px 8px 8px; }
.emoji-cat-label {
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--ink-soft);
  padding: 8px 4px 2px;
}
.emoji-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
  gap: 1px;
}
.emoji-btn {
  font-size: 1.5rem;
  line-height: 1;
  background: none;
  border: none;
  padding: 6px 0;
  cursor: pointer;
  border-radius: 8px;
  /* Colour-emoji fonts render regardless; the family hint keeps mono/legacy fonts from boxing them. */
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
}
.emoji-btn:hover { background: var(--bg-app); }
.emoji-empty { font-size: .82rem; color: var(--ink-soft); padding: 4px 4px 6px; }

/* ── Attachment sheet (Brief 04.1) — WhatsApp-style option grid above the composer ───────
   Four columns of soft rounded tiles, each a coloured filled glyph with its label beneath.
   Hidden options ([hidden] is display:none) drop out of the grid, so gated flags leave no gaps. */
.attach-sheet {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: repeat(4, minmax(70px, 120px));
  justify-content: center;
  justify-items: center;
  gap: 16px 6px;
  padding: 10px 12px calc(16px + var(--safe-bottom));
  background: var(--bg-surface);
  border-top: 1px solid var(--line);
  touch-action: none; /* the sheet owns vertical drags (swipe-down dismiss) — else the browser pans/refreshes instead */
}
.attach-grabber {
  grid-column: 1 / -1;
  justify-self: center;
  width: 40px;
  height: 4px;
  border-radius: 2px;
  background: #d4d6dc;
}
.attach-opt {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  cursor: pointer;
  font: inherit;
  font-size: .8rem;
  color: var(--ink-soft);
  padding: 2px;
}
/* --attach-tile doubles as the cut-out fill inside the glyph SVGs (index.html). */
.attach-ico {
  --attach-tile: #f0f2f5;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 58px;
  height: 58px;
  border-radius: 18px;
  background: var(--attach-tile);
}
.attach-ico--photos   { color: #a05be6; }
.attach-ico--camera   { color: #f2426f; }
.attach-ico--location { color: #10ab55; }
.attach-ico--contact  { color: #2f80ed; }
.attach-ico--doc      { color: #7d67ee; }
.attach-ico--poll     { color: #f2a730; }
.attach-ico--event    { color: #ee4667; }
.attach-ico--audio    { color: #f2622e; } /* Brief 12.18 */
.attach-opt:active .attach-ico { transform: scale(.94); }

/* ── Media preview + caption overlay (before send) ─────────────────────────── */
.media-preview {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  background: var(--bg-app);
}
.media-preview-top {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  padding: calc(8px + var(--safe-top)) 10px 8px;
}
.media-preview-close {
  background: none; border: none; cursor: pointer;
  color: var(--ink); font-size: 1.6rem; line-height: 1; width: 40px; height: 40px;
}
.media-preview-body {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  padding: 8px 16px;
}
.media-preview-body img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 10px;
  object-fit: contain;
}
/* Non-image (document) preview chip */
.media-doc-chip {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 20px;
  background: var(--bg-surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  max-width: 90%;
}
.media-doc-chip .doc-name { font-weight: 600; overflow-wrap: anywhere; }
.media-doc-chip .doc-meta { font-size: .78rem; color: var(--ink-soft); }
.media-preview-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 8px calc(8px + var(--safe-bottom));
  background: var(--bg-app);
  border-top: 1px solid var(--line);
}
.media-caption-input {
  flex: 1 1 auto; min-width: 0;
  font-size: 1rem;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 22px;
  outline: none;
  background: var(--bg-surface);
  color: var(--ink);
}
.media-caption-input:focus { border-color: var(--red); }
/* Caption emoji toggle (visual-parity pass 2026-07-05) — opens the shared emoji pop for the caption input. */
.media-caption-emoji { font-size: 1.5rem; line-height: 1; width: 40px; height: 40px; flex: 0 0 auto; }

/* ── Document bubble (non-image media, both incoming + outgoing) ───────────── */
.msg-doc {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  margin-bottom: 3px;
  border-radius: 8px;
  background: rgba(0,0,0,.05);
  color: inherit;
  text-decoration: none;
}
@media (prefers-color-scheme: dark) { .msg-doc { background: rgba(255,255,255,.07); } }
.msg-doc .doc-ico { flex: 0 0 auto; color: var(--red-accent); }
.msg-doc .doc-name { font-size: .9rem; font-weight: 600; overflow-wrap: anywhere; }
.msg-doc .doc-meta { font-size: .72rem; color: var(--ink-soft); }

/* ── Upload progress (outgoing media, before the send acks) ───────────────── */
.msg-upload {
  height: 4px;
  border-radius: 3px;
  background: rgba(0,0,0,.12);
  overflow: hidden;
  margin: 2px 0 4px;
}
@media (prefers-color-scheme: dark) { .msg-upload { background: rgba(255,255,255,.15); } }
.msg-upload-bar {
  height: 100%;
  width: 0;
  background: var(--red);
  transition: width .15s var(--ease-responsive);
}
.msg-img--uploading { opacity: .7; }

/* ── Reply / quote (Brief 04.2) ─────────────────────────────────────────────── */
/* Quoted block at the top of a bubble; tap scrolls to the original. */
.msg-quote {
  display: flex;
  flex-direction: row; /* body + (optional) media thumbnail — visual-parity pass 2026-07-05 */
  align-items: stretch;
  gap: 0;
  /* Left accent-bar: 4px, coloured per QUOTED SENDER by quoteBlockNode (inline style) — parity pass. */
  border-left: 4px solid var(--red-accent);
  background: rgba(0,0,0,.05);
  border-radius: 8px;
  padding: 0;
  margin-bottom: 4px;
  cursor: pointer;
  max-width: 100%;
  /* Reference --quoted-min-height/--quoted-max-height: one author line + one text line as the floor,
     growing to a capped height for longer quotes — spec §5/§11 gap rows 26-27. */
  min-height: 42px;
  max-height: 82px;
  overflow: hidden;
}
@media (prefers-color-scheme: dark) { .msg-quote { background: rgba(255,255,255,.07); } }
.msg-quote-body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 1px; padding: 4px 8px; }
/* Image quote thumbnail hugging the right edge (parity pass) — cropped square, no rounding on the inner side. */
.msg-quote-thumb { flex: 0 0 auto; width: 52px; object-fit: cover; border-radius: 0 8px 8px 0; }
/* Explicit line-height boxes — reference --line-height-quoted-author/--line-height-quoted, spec §11 gap row 26. */
.msg-quote-who { font-size: .78rem; font-weight: 700; line-height: 22px; color: var(--red-accent); }
.msg-quote-text {
  font-size: .82rem; line-height: 20px; color: var(--ink-soft);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%;
}
/* Scroll-to-original flash. Rests at no shadow now bubbles carry none (gap row 15) — only the momentary
   highlight ring at 25% remains. */
.msg--flash { animation: msg-flash 1.2s ease; }
@keyframes msg-flash { 0%, 100% { box-shadow: none; } 25% { box-shadow: 0 0 0 3px var(--red-accent); } }
@media (prefers-reduced-motion: reduce) { .msg--flash { animation: none; } }

/* Reply button revealed on hover/focus (desktop + keyboard); touch uses swipe. */
.msg-reply-btn {
  position: absolute;
  top: 2px;
  width: 26px; height: 26px;
  display: inline-flex; align-items: center; justify-content: center;
  border: none; border-radius: 50%;
  background: var(--bg-surface);
  color: var(--ink-soft);
  box-shadow: var(--shadow);
  cursor: pointer;
  opacity: 0; pointer-events: none;
  transition: opacity .12s var(--ease-responsive);
}
.msg--in .msg-reply-btn { right: -30px; }
.msg--out .msg-reply-btn { left: -30px; }
.msg:hover .msg-reply-btn, .msg:focus-within .msg-reply-btn { opacity: 1; pointer-events: auto; }
.msg-reply-btn:hover { color: var(--red-accent); }
@media (hover: none) { .msg-reply-btn { display: none; } }  /* touch devices swipe-to-reply instead */

/* Swipe-to-reply reveal (a subtle reply hint behind the sliding bubble). */
.msg--swiping { opacity: .92; }

/* Always-visible quick-forward chip beside media bubbles (round-2 feedback 2026-07-05) — a translucent round
   button on the bubble's outer side, vertically centred on the photo/video. */
.msg-media-fwd {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 50%;
  background: rgba(80, 80, 80, .45);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.msg-media-fwd:hover { background: rgba(80, 80, 80, .65); }
.msg--in .msg-media-fwd { right: -42px; }
.msg--out .msg-media-fwd { left: -42px; }

/* In-thread typing indicator (round-2 feedback 2026-07-05) — an incoming-style mini bubble with three pulsing
   dots at the foot of the list; name label above the dots in group rooms. Reduced-motion gets static dots. */
.typing-bubble {
  align-self: flex-start;
  background: var(--bg-bubble-in);
  border-radius: 13px;
  border-top-left-radius: 2px;
  box-shadow: 0 1px .5px rgba(0, 0, 0, .1);
  padding: 7px 12px 8px;
  margin-top: 8px;
}
.msg-list--group .typing-bubble { margin-left: 38px; }
.typing-bubble-who { font-size: .72rem; font-weight: 700; color: var(--ink-soft); margin-bottom: 2px; }
.typing-dots { display: flex; gap: 4px; align-items: flex-end; height: 12px; }
.typing-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ink-soft);
  opacity: .35;
  animation: typing-blink 1.2s ease-in-out infinite;
}
.typing-dot:nth-child(2) { animation-delay: .18s; }
.typing-dot:nth-child(3) { animation-delay: .36s; }
@keyframes typing-blink {
  0%, 55%, 100% { opacity: .3; transform: translateY(0); }
  28%           { opacity: 1;  transform: translateY(-3px); }
}
@media (prefers-reduced-motion: reduce) { .typing-dot { animation: none; opacity: .6; } }

/* Compose reply banner (above the composer). */
.reply-banner {
  flex: 0 0 auto;
  background: var(--bg-app);
  border-top: 1px solid var(--line);
  padding: 6px 10px 0;
}
.reply-banner-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-surface);
  border-left: 3px solid var(--red-accent);
  border-radius: 6px;
  padding: 6px 8px;
}
.reply-banner-body { flex: 1 1 auto; min-width: 0; }
.reply-banner-who { font-size: .78rem; font-weight: 700; color: var(--red-accent); }
.reply-banner-text { font-size: .84rem; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reply-banner-cancel { flex: 0 0 auto; background: none; border: none; cursor: pointer; color: var(--ink-soft); font-size: 1.4rem; line-height: 1; width: 32px; height: 32px; }

/* ── Pinned-message banner (Brief 12.21) ────────────────────────────────────── */
.pin-banner {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 10px;
  width: 100%; text-align: left;
  padding: 8px 14px;
  background: var(--bg-surface);
  border: none; border-bottom: 1px solid var(--line); border-left: 3px solid var(--red-accent);
  cursor: pointer; font: inherit; color: inherit;
}
.pin-banner:hover { background: var(--bg-app); }
.pin-banner-ico { flex: 0 0 auto; color: var(--red-accent); display: inline-flex; }
.pin-banner-body { flex: 1 1 auto; min-width: 0; }
.pin-banner-label { font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--red-accent); }
.pin-banner-text { font-size: .86rem; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reaction-opt--pin { color: var(--ink-soft); display: inline-flex; align-items: center; justify-content: center; }
.reaction-opt--pin:hover, .reaction-opt--pin-on { color: var(--red-accent); }

/* ── Reactions (Brief 04.3) ─────────────────────────────────────────────────── */
/* Visual-parity pass 2026-07-05: pills now OVERLAP the bubble's bottom edge (absolute, hanging half out),
   surface-white with a soft shadow — incoming bubbles hang them bottom-left, outgoing bottom-right. The
   bubble opens bottom margin via .msg--has-reacts so the pill never covers the next message. */
.msg-reacts {
  position: absolute;
  bottom: -19px; /* round-2 feedback: hang almost fully BELOW the bubble — -12px overlapped the last text line */
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  z-index: 1;
}
.msg--in .msg-reacts { left: 6px; }
.msg--out .msg-reacts { right: 6px; }
.msg--has-reacts { margin-bottom: 22px; }
.msg-react {
  font: inherit; font-size: .8rem;
  background: var(--bg-surface);
  border: none;
  border-radius: 100px; /* reference --chip-corner-radius: fully round, spec §5/§7 — same chip convention as the day pill/unread badge */
  padding: 2px 8px;
  cursor: pointer;
  color: var(--ink);
  line-height: 1.5;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .18);
}
.msg-react--mine { box-shadow: 0 1px 2px rgba(0, 0, 0, .18), inset 0 0 0 1px var(--red-accent); background: color-mix(in srgb, var(--red-accent) 12%, var(--bg-surface)); }
/* React button (desktop hover/focus), stacked under the reply button. */
.msg-react-btn {
  position: absolute;
  top: 32px;
  width: 26px; height: 26px;
  display: inline-flex; align-items: center; justify-content: center;
  border: none; border-radius: 50%;
  background: var(--bg-surface); color: var(--ink-soft);
  box-shadow: var(--shadow); cursor: pointer;
  opacity: 0; pointer-events: none; transition: opacity .12s var(--ease-responsive);
}
.msg--in .msg-react-btn { right: -30px; }
.msg--out .msg-react-btn { left: -30px; }
.msg:hover .msg-react-btn, .msg:focus-within .msg-react-btn { opacity: 1; pointer-events: auto; }
.msg-react-btn:hover { color: var(--red-accent); }
@media (hover: none) { .msg-react-btn { display: none; } }  /* touch long-presses instead */
/* Quick-forward hover button (Brief 12.4) — stacked below reply + react (3rd slot). */
.msg-fwd-btn {
  position: absolute;
  top: 62px;
  width: 26px; height: 26px;
  display: inline-flex; align-items: center; justify-content: center;
  border: none; border-radius: 50%;
  background: var(--bg-surface); color: var(--ink-soft);
  box-shadow: var(--shadow); cursor: pointer;
  opacity: 0; pointer-events: none; transition: opacity .12s var(--ease-responsive);
}
.msg--in .msg-fwd-btn { right: -30px; }
.msg--out .msg-fwd-btn { left: -30px; }
.msg:hover .msg-fwd-btn, .msg:focus-within .msg-fwd-btn { opacity: 1; pointer-events: auto; }
.msg-fwd-btn:hover { color: var(--red-accent); }
@media (hover: none) { .msg-fwd-btn { display: none; } }  /* touch uses the long-press action bar */
/* Reply option in the floating action bar (Brief 12.4). */
.reaction-opt--reply { color: var(--ink-soft); display: inline-flex; align-items: center; justify-content: center; }
.reaction-opt--reply:hover { color: var(--red-accent); }

/* Floating reaction bar (long-press / react button). position: fixed (viewport coords). Wraps + clamps to the
   viewport so the extra options (7 quick emoji + "+" + reply/star/forward/edit) never overflow a narrow phone
   (Brief 12.11/12.12). */
.reaction-bar {
  position: fixed;
  z-index: 60;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  max-width: calc(100vw - 16px);
  gap: 2px;
  background: var(--bg-surface);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 4px 6px;
  box-shadow: 0 3px 14px rgba(0,0,0,.28);
}
/* "+" open-picker option + the full emoji pop-over for reacting with any emoji (Brief 12.12). */
.reaction-opt--plus { color: var(--ink-soft); font-size: 1.4rem; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; }
.reaction-opt--plus:hover { color: var(--red-accent); }
.emoji-pop-overlay {
  position: fixed; inset: 0; z-index: 66;
  background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.emoji-pop {
  width: 100%; max-width: 400px; max-height: 60vh; overflow-y: auto;
  background: var(--bg-surface); border-radius: 14px; padding: 6px 10px 10px;
  box-shadow: 0 8px 30px rgba(0,0,0,.4);
  scrollbar-width: thin;
}
.reaction-opt {
  font-size: 1.5rem; line-height: 1;
  background: none; border: none; cursor: pointer;
  padding: 4px 5px; border-radius: 50%;
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
}
.reaction-opt:hover { background: var(--bg-app); transform: scale(1.15); }
.reaction-opt--mine { background: color-mix(in srgb, var(--red-accent) 20%, transparent); }
.reaction-opt--edit { color: var(--ink-soft); display: inline-flex; align-items: center; justify-content: center; }
.reaction-opt--edit:hover { color: var(--red-accent); }

/* ── Message info sheet (Brief 12.15) ───────────────────────────────────────── */
.reaction-opt--info { color: var(--ink-soft); font-size: 1.25rem; display: inline-flex; align-items: center; justify-content: center; }
.reaction-opt--info:hover { color: var(--red-accent); }
.minfo-section { margin-bottom: 10px; }
.minfo-note { font-size: .9rem; color: var(--ink-soft); padding: 2px 2px 6px; }
.minfo-row { display: flex; align-items: center; gap: 10px; padding: 6px 2px; }

/* ── Confetti burst on 🎉 (Brief 12.14) — presentation-only, reduced-motion aware ──────────────────────── */
.confetti-layer { position: fixed; inset: 0; pointer-events: none; z-index: 80; overflow: hidden; }
.confetti-piece { position: fixed; width: 8px; height: 8px; border-radius: 2px; will-change: transform, opacity; }
@media (prefers-reduced-motion: reduce) { .confetti-layer { display: none; } }

/* ── Who-reacted sheet (Brief 12.13) ────────────────────────────────────────── */
.react-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 10px; }
.react-tab {
  font: inherit; font-size: .85rem;
  background: var(--bg-app); border: 1px solid var(--line); border-radius: 100px;
  padding: 4px 12px; cursor: pointer; color: var(--ink);
}
.react-tab--active { border-color: var(--red-accent); background: color-mix(in srgb, var(--red-accent) 14%, var(--bg-app)); color: var(--red-accent); font-weight: 600; }
.react-reactors { display: flex; flex-direction: column; gap: 2px; max-height: 46vh; overflow-y: auto; }
.react-reactor { display: flex; align-items: center; gap: 10px; padding: 6px 2px; }
.react-reactor--mine { cursor: pointer; border-radius: 8px; }
.react-reactor--mine:hover { background: var(--bg-app); }
.react-reactor-who { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1 1 auto; }
.react-reactor-emoji { flex: 0 0 auto; font-size: 1.25rem; font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif; }

/* ── Edit-with-history (Brief 04.4) ─────────────────────────────────────────── */
/* "Edited" — plain meta text beside the time (was lowercase italic; parity pass 2026-07-05). */
.msg-edited { opacity: .8; margin-right: 2px; cursor: pointer; }
.msg-edited:hover { color: var(--red-accent); }
/* Edit-history viewer */
.history-overlay {
  /* Brief 17.A — track the VISUAL viewport (dvh), not the layout viewport (vh), so an open on-screen
     keyboard shrinks this overlay and the centred card stays fully visible above it (was: the modal was
     pushed up + its footer hidden behind the keyboard on the A16). overflow-y scrolls rather than clips. */
  position: fixed; top: 0; left: 0; right: 0;
  height: 100vh; height: 100dvh;
  z-index: 70;
  background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  overflow-y: auto;
}
.history-card {
  background: var(--bg-surface); color: var(--ink);
  border-radius: 14px; padding: 16px;
  width: 100%; max-width: 440px;
  max-height: 76vh; max-height: 88dvh; overflow: auto;
  box-shadow: 0 8px 30px rgba(0,0,0,.4);
}
.history-title { font-weight: 700; font-size: 1.05rem; margin-bottom: 10px; }
.history-list { display: flex; flex-direction: column; gap: 8px; }
.history-ver { border-left: 3px solid var(--line); padding: 4px 10px; }
.history-ver--current { border-left-color: var(--red-accent); }
.history-ver-lbl { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--ink-soft); }
.history-ver-txt { white-space: pre-wrap; overflow-wrap: anywhere; }
.history-close {
  margin-top: 14px; width: 100%;
  background: var(--red); color: #fff; border: none; border-radius: 22px;
  padding: 11px; font-size: 1rem; cursor: pointer;
}
.history-close:hover { background: var(--red-dark); }

/* ── Voice notes (Brief 04.5) ───────────────────────────────────────────────── */
.icon-btn--mic { background: var(--red); }
.icon-btn--mic:hover { background: var(--red-dark); }
/* touch-action:none is what makes hold-and-slide WORK on Android (visual-parity pass 2026-07-05): without it
   the browser claims the drag as a scroll after a few px, fires pointercancel, and "slide to cancel / lock"
   never sees the movement — the reported dead gesture. */
.icon-btn--mic { touch-action: none; }
/* Recording bar (replaces the composer field while holding the mic). */
.voice-rec {
  flex: 1 1 auto; min-width: 0;
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--red);
  border-radius: 22px;
  font-size: .95rem; color: var(--ink);
}
.voice-rec-dot { width: 11px; height: 11px; border-radius: 50%; background: var(--red); animation: rec-pulse 1.2s ease-in-out infinite; flex: 0 0 auto; }
.voice-rec-dot--paused { animation: none; opacity: .5; }
.voice-rec-time { font-variant-numeric: tabular-nums; }
/* Shrinkable (min-width:0) so the hint ellipsizes INSIDE the pill on narrow phones instead of pushing the
   timer out of view — the reported cut-off (visual-parity pass 2026-07-05). */
.voice-rec-hint { margin-left: auto; min-width: 0; flex: 0 1 auto; color: var(--ink-soft); font-size: .78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* Recording-bar buttons (round 6 — buttons are the PRIMARY controls): 🔒 tap-to-lock hands-free + ✕ discard. */
.voice-rec-btn {
  flex: 0 0 auto; width: 30px; height: 30px; margin-left: 2px;
  border: none; border-radius: 50%; background: none;
  color: var(--ink-soft); font-size: 1.05rem; line-height: 1; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.voice-rec-btn:hover { color: var(--red-accent); }

/* Composer link-preview banner (round 5) — unfurl-while-typing above the input, like the reply banner. */
.compose-lp {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  background: var(--bg-surface);
  border-top: 1px solid var(--line);
}
.compose-lp-img { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; flex: 0 0 auto; }
.compose-lp-body { flex: 1 1 auto; min-width: 0; }
.compose-lp-title { font-size: .88rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.compose-lp-domain { font-size: .76rem; color: var(--ink-soft); }
.compose-lp-close { flex: 0 0 auto; background: none; border: none; color: var(--ink-soft); font-size: 1.4rem; line-height: 1; width: 32px; height: 32px; cursor: pointer; }
.voice-rec-hint--armed { color: var(--red-accent); font-weight: 700; }
/* Locked (hands-free) recording controls (Brief 12.20). */
.voice-rec--locked { gap: 8px; }
.voice-lock-spacer { flex: 1 1 auto; }
.voice-lock-btn {
  flex: 0 0 auto; width: 34px; height: 34px; border-radius: 50%;
  border: none; cursor: pointer; background: var(--bg-app); color: var(--ink);
  font-size: .95rem; display: inline-flex; align-items: center; justify-content: center;
}
.voice-lock-btn:hover { background: var(--line); }
.voice-lock-done { background: var(--red); color: #fff; }
.voice-lock-done:hover { background: var(--red-dark); }
/* Pre-send preview bar (Brief 12.20) — inline player + discard + send. */
.voice-preview {
  flex: 1 1 auto; min-width: 0;
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px;
  background: var(--bg-surface); border: 1px solid var(--red); border-radius: 22px;
}
/* Two-class selector so this outranks .msg-audio's in-chat min-width regardless of source order — the preview
   must shrink with the composer on narrow phones. */
.voice-preview .voice-preview-player { flex: 1 1 auto; min-width: 0; }
.voice-preview-btn {
  flex: 0 0 auto; width: 32px; height: 32px; border-radius: 50%;
  border: none; cursor: pointer; background: none; color: var(--ink-soft); font-size: 1rem;
  display: inline-flex; align-items: center; justify-content: center;
}
.voice-preview-btn:hover { color: var(--red-accent); }
/* Inline voice player (reference-matched 2026-07-05) — layout: sender initials disc with a mic badge on the
   left (the disc swaps to the speed pill while playing), plain play triangle, a bar-waveform with a round
   scrubber knob that recolours with progress (tap to seek), duration under the waveform's left edge, and a
   red "new" dot after the duration on an unplayed incoming note. */
.msg-audio { display: flex; align-items: center; gap: 8px; min-width: 235px; padding: 2px 2px 0; }
@media (max-width: 349px) { .msg-audio { min-width: 0; } } /* tiny phones: let the wave flex down instead of overflowing the bubble */
/* Voice bubble foot (reference): the sent time + ticks share the DURATION's line — absolute bottom-right over
   the meta row instead of a full-height block row beneath the player. Failed sends fall back to the block row
   (the "tap to retry" foot is long). */
.msg--audiofoot { padding-bottom: 5px; }
.msg--audiofoot .msg-foot { position: absolute; right: 8px; bottom: 5px; margin-top: 0; }
.msg--failed.msg--audiofoot { padding-bottom: 6px; }
.msg--failed.msg--audiofoot .msg-foot { position: static; margin-top: 2px; }
.msg-audio--uploading { opacity: .7; }
/* Played receipt (Brief 12.22) — the sender's own note turns "read"-red once a recipient plays it; an unplayed
   incoming note (msg-audio--new) carries the same accent on its mic badge until first play. */
.msg-audio--played .audio-play { color: var(--red-accent); }
.msg-audio--played .audio-time { color: var(--red-accent); font-weight: 600; }
.msg-audio--played .audio-mic, .msg-audio--new .audio-mic { color: var(--red-accent); }
.msg-audio audio { display: none; }
.audio-side { position: relative; flex: 0 0 auto; width: 42px; height: 42px; }
.audio-av {
  width: 42px; height: 42px; border-radius: 50%; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: .95rem; font-weight: 600; user-select: none;
}
.audio-av--anon { background: color-mix(in srgb, var(--ink-soft) 38%, transparent); }
.audio-av--anon svg { width: 30px; height: 30px; margin-top: 8px; color: #fff; opacity: .92; } /* shoulders crop at the disc edge, reference-style */
.audio-mic { position: absolute; right: -6px; bottom: -2px; width: 18px; height: 18px; color: var(--tick-grey); }
.audio-mic svg { display: block; width: 100%; height: 100%; }
/* While playing, the disc gives way to the speed pill (reference behaviour); tapping cycles 1×/1.5×/2×. */
.audio-side .audio-speed { display: none; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); white-space: nowrap; /* abspos shrink-to-fit vs the 42px disc would wrap "1.5×" */ }
.audio-side--playing .audio-av, .audio-side--playing .audio-mic { visibility: hidden; }
.audio-side--playing .audio-speed { display: inline-flex; }
.audio-play {
  flex: 0 0 auto; width: 30px; height: 38px;
  border: none; cursor: pointer; background: none; color: var(--tick-grey);
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0;
}
.audio-play svg { width: 26px; height: 26px; }
.audio-play:hover { color: var(--red-accent); }
.audio-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.audio-wave {
  position: relative; /* hosts the absolutely-positioned scrubber knob */
  display: flex; align-items: center; gap: 2px;
  height: 26px; cursor: pointer;
}
.audio-wave-bar {
  flex: 1 1 auto;
  min-width: 2px;
  border-radius: 2px;
  background: color-mix(in srgb, var(--ink-soft) 45%, transparent);
}
.audio-wave-bar--played { background: var(--red-accent); }
.audio-knob {
  position: absolute; left: 0%; top: 50%; width: 13px; height: 13px;
  transform: translate(-50%, -50%); border-radius: 50%;
  background: var(--red-accent); box-shadow: 0 1px 2px rgba(0, 0, 0, .3);
  pointer-events: none; /* purely visual — the wave itself handles seeks */
}
.audio-meta { display: flex; align-items: center; gap: 6px; min-height: 14px; }
.audio-new-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--red-accent); flex: 0 0 auto; }
.audio-time { flex: 0 0 auto; font-size: .8125rem; color: var(--ink-soft); font-variant-numeric: tabular-nums; } /* same 13px as .msg-foot — they share a line in the reference */
.audio-speed { flex: 0 0 auto; background: var(--bg-app); border: 1px solid var(--line); border-radius: 12px; font-size: .72rem; padding: 3px 9px; cursor: pointer; color: var(--ink-soft); font-weight: 700; }
.audio-speed:hover { border-color: var(--red-accent); color: var(--red-accent); }

/* ── In-chat search + starred (Brief 04.7) ──────────────────────────────────── */
.search-bar {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 6px;
  padding: 6px 8px;
  background: var(--red); color: #fff;
}
.search-input {
  flex: 1 1 auto; min-width: 0;
  border: none; border-radius: 18px;
  padding: 9px 14px; font-size: .95rem;
  background: rgba(255,255,255,.16); color: #fff;
  outline: none;
}
.search-input::placeholder { color: rgba(255,255,255,.75); }
.search-count { flex: 0 0 auto; font-size: .8rem; opacity: .9; white-space: nowrap; }
.search-bar .icon-btn { color: #fff; }
/* Results dropdown under the bar. */
.search-results {
  position: absolute; left: 0; right: 0;
  z-index: 30;
  max-height: 55vh; overflow-y: auto;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 6px 18px rgba(0,0,0,.22);
}
.search-results-inline { display: flex; flex-direction: column; }
.hit-row {
  display: flex; flex-direction: column; gap: 2px;
  width: 100%; text-align: left;
  padding: 9px 14px; border: none; border-bottom: 1px solid var(--line);
  background: none; cursor: pointer; font: inherit; color: var(--ink);
}
.hit-row:hover { background: var(--bg-app); }
.hit-top { display: flex; justify-content: space-between; gap: 8px; }
.hit-who { font-size: .78rem; font-weight: 700; color: var(--red-accent); }
.hit-time { font-size: .72rem; color: var(--ink-soft); }
.hit-text { font-size: .9rem; color: var(--ink); overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.hit-mark { background: color-mix(in srgb, var(--red-accent) 32%, transparent); color: inherit; border-radius: 2px; }
.hit-empty { color: var(--ink-soft); padding: 10px 4px; }
/* Type stub for a media hit + room name for a global-starred hit (Brief 12.16). */
.hit-text--media { font-style: italic; color: var(--ink-soft); }
.hit-room { font-size: .72rem; font-weight: 600; color: var(--red-accent); margin-top: 2px; }
.starred-clear {
  margin-top: 12px; width: 100%;
  background: none; border: 1px solid var(--red); color: var(--red-accent);
  border-radius: 22px; padding: 10px; font-size: .95rem; font-weight: 600; cursor: pointer;
}
.starred-clear:hover { background: color-mix(in srgb, var(--red) 10%, transparent); }
/* Star indicator + reaction-bar star. */
.msg-star { color: var(--red-accent); margin-right: 3px; }
.reaction-opt--star { color: var(--red-accent); font-size: 1.35rem; }

/* ── Profile / members pane + forward (Brief 04.8) ──────────────────────────── */
.room-head { cursor: pointer; }
.msg-fwd { font-size: .78rem; font-style: italic; color: var(--ink-soft); margin-bottom: 2px; }
.reaction-opt--fwd { color: var(--ink-soft); font-size: 1.3rem; }
.reaction-opt--fwd:hover { color: var(--red-accent); }
/* Forward picker (Brief 12.3) — its own classes (does NOT reuse hit-row, which search/edit-history share). */
.fwd-preview {
  font-size: .84rem; color: var(--ink-soft);
  background: var(--bg-app); border-left: 3px solid var(--red-accent); border-radius: 5px;
  padding: 6px 10px; margin: 2px 0 8px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.fwd-capdrop { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; font-size: .86rem; color: var(--ink); cursor: pointer; }
.fwd-capdrop input { width: 17px; height: 17px; accent-color: var(--red); }
.fwd-filter {
  width: 100%; font: inherit; font-size: .92rem; padding: 8px 12px; margin-bottom: 6px;
  border: 1px solid var(--line); border-radius: 18px; background: var(--bg-app); color: var(--ink); outline: none;
}
.fwd-filter:focus { border-color: var(--red); }
.fwd-list { max-height: 40vh; overflow-y: auto; }
.fwd-row { display: flex; align-items: center; gap: 10px; padding: 9px 6px; border-bottom: 1px solid var(--line); cursor: pointer; }
.fwd-row:hover { background: var(--bg-app); }
.fwd-row input { width: 18px; height: 18px; flex: 0 0 auto; accent-color: var(--red); }
.fwd-row-name { font-size: .92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fwd-send {
  margin-top: 12px; width: 100%;
  background: var(--red); color: #fff; border: none; border-radius: 22px;
  padding: 11px; font-size: 1rem; font-weight: 600; cursor: pointer;
}
.fwd-send:hover:not(:disabled) { background: var(--red-dark); }
.fwd-send:disabled { opacity: .5; cursor: default; }
.profile-card { text-align: left; }
.profile-head { display: flex; flex-direction: column; align-items: center; gap: 4px; margin-bottom: 8px; }
.profile-av { width: 64px; height: 64px; border-radius: 50%; color: #fff; display: flex; align-items: center; justify-content: center; font-size: 1.4rem; font-weight: 700; }
.profile-title { font-size: 1.15rem; font-weight: 700; }
.profile-kind { font-size: .82rem; color: var(--ink-soft); }
.profile-notice { font-size: .82rem; color: var(--ink-soft); background: var(--bg-app); border-radius: 8px; padding: 8px 10px; margin: 8px 0; line-height: 1.4; }
.profile-section-label { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-soft); margin: 10px 0 4px; }
.profile-members { display: flex; flex-direction: column; gap: 2px; max-height: 30vh; overflow-y: auto; }
.profile-member { display: flex; align-items: center; gap: 10px; padding: 5px 2px; }
.profile-member-av { width: 34px; height: 34px; border-radius: 50%; color: #fff; display: flex; align-items: center; justify-content: center; font-size: .82rem; font-weight: 700; flex: 0 0 auto; }
.profile-member-name { font-size: .92rem; }
.profile-toggle { display: flex; align-items: center; gap: 10px; margin: 12px 0; font-size: .95rem; cursor: pointer; }
.profile-toggle input { width: 18px; height: 18px; accent-color: var(--red); }
.profile-leave { width: 100%; margin-top: 6px; background: none; border: 1px solid var(--red); color: var(--red-accent); border-radius: 22px; padding: 10px; font-size: .95rem; font-weight: 600; cursor: pointer; }
.profile-leave:hover { background: color-mix(in srgb, var(--red) 10%, transparent); }

/* Member-admin polish (Brief 12.17): room-header pending badge, section badge, styled confirm/prompt modal. */
.room-pending {
  flex: 0 0 auto; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: #fff; color: var(--red);
  font-size: .68rem; font-weight: 700; display: inline-flex; align-items: center; justify-content: center;
}
.profile-pending-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--red); color: #fff; font-size: .68rem; font-weight: 700; vertical-align: middle;
}
.modal-card { max-width: 400px; }
.modal-msg { font-size: .92rem; color: var(--ink-soft); margin: 4px 0 12px; line-height: 1.4; }
.modal-input {
  width: 100%; font: inherit; font-size: 1rem; padding: 11px 14px; margin-bottom: 4px;
  border: 1.5px solid var(--line); border-radius: 10px; outline: none; background: var(--bg-surface); color: var(--ink);
}
.modal-input:focus { border-color: var(--red); }
.modal-actions { display: flex; gap: 8px; margin-top: 14px; }
/* Brief 17 (Apple 1.2) — stacked action sheet (Report / Block / Cancel). */
.modal-actions--col { flex-direction: column; }
.modal-actions--col .modal-btn { width: 100%; }
.modal-btn { flex: 1; font: inherit; font-size: .95rem; font-weight: 600; border-radius: 22px; padding: 11px; cursor: pointer; border: 1px solid transparent; }
.modal-btn--cancel { background: none; border-color: var(--line); color: var(--ink-soft); }
.modal-btn--primary { background: var(--red); color: #fff; }
.modal-btn--primary:hover { background: var(--red-dark); }
.modal-btn--danger { background: var(--red); color: #fff; }
.modal-btn--danger:hover { background: var(--red-dark); }

/* Member-admin pane (Brief 05.4): masked-number sub-line, remove control, join-request queue, invite. */
.profile-member-who { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1 1 auto; }
.profile-member-sub { font-size: .72rem; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.profile-member-remove { flex: 0 0 auto; background: none; border: 1px solid var(--red); color: var(--red-accent); border-radius: 16px; padding: 5px 12px; font-size: .78rem; font-weight: 600; cursor: pointer; }
/* Message-a-member button + DM row tag (Brief 12.25). */
.profile-member-msg { flex: 0 0 auto; background: none; border: 1px solid var(--line); color: var(--red-accent); border-radius: 16px; padding: 5px 12px; font-size: .78rem; font-weight: 600; cursor: pointer; }
.profile-member-msg:hover { border-color: var(--red-accent); }
.room-dm-tag { color: var(--ink-soft); font-weight: 400; font-size: .78rem; }
.profile-member-remove:hover { background: color-mix(in srgb, var(--red) 12%, transparent); }
.profile-requests { display: flex; flex-direction: column; gap: 8px; margin: 4px 0 6px; }
.profile-req { display: flex; align-items: center; gap: 8px; }
.profile-req-who { flex: 1 1 auto; font-size: .88rem; font-variant-numeric: tabular-nums; }
.profile-req-empty { font-size: .85rem; color: var(--ink-soft); font-style: italic; }
.profile-req-yes, .profile-req-no { flex: 0 0 auto; border-radius: 16px; padding: 6px 14px; font-size: .8rem; font-weight: 600; cursor: pointer; border: 1px solid transparent; }
.profile-req-yes { background: var(--red); color: #fff; }
.profile-req-no { background: none; border-color: var(--red); color: var(--red-accent); }
.profile-invite { width: 100%; margin-top: 10px; background: var(--red); border: 0; color: #fff; border-radius: 22px; padding: 11px; font-size: .95rem; font-weight: 600; cursor: pointer; }
.profile-invite:hover { filter: brightness(.94); }

/* ── Thin custom scrollbars — reference --scrollbar-width:6px (spec §10/§12, §11 gap row 31). Firefox
   via scrollbar-width, WebKit via ::-webkit-scrollbar; browser-default elsewhere is left untouched. */
.rooms-list,
.msg-list,
.emoji-panel,
.search-results {
  scrollbar-width: thin;
}
.rooms-list::-webkit-scrollbar,
.msg-list::-webkit-scrollbar,
.emoji-panel::-webkit-scrollbar,
.search-results::-webkit-scrollbar {
  width: 6px;
}
.rooms-list::-webkit-scrollbar-thumb,
.msg-list::-webkit-scrollbar-thumb,
.emoji-panel::-webkit-scrollbar-thumb,
.search-results::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 3px;
}

/* ============================================================================
   Coachmark + toast
   ========================================================================== */
.coachmark {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 50;
  padding: 0 12px calc(20px + var(--safe-bottom));
}
.coachmark-card {
  background: var(--bg-surface);
  border-radius: 16px;
  padding: 20px 18px;
  max-width: 420px;
  width: 100%;
  position: relative;
  box-shadow: 0 -4px 24px rgba(0,0,0,.2);
}
.coachmark-title { margin: 0 0 8px; font-size: 1.1rem; color: var(--red-accent); }
.coachmark-card p { margin: 0; color: var(--ink-soft); font-size: .92rem; line-height: 1.45; }
.coachmark-close {
  position: absolute;
  top: 8px; right: 10px;
  background: none; border: none;
  font-size: 1.6rem; line-height: 1;
  color: var(--ink-soft); cursor: pointer;
}
/* Android WebAPK-steering coachmark action row (GR-WEBAPK-1) */
.coachmark-actions { margin-top: 14px; display: flex; }
.coachmark-actions .btn { flex: 1; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(76px + var(--safe-bottom));
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 10px 16px;
  border-radius: 22px;
  font-size: .88rem;
  z-index: 60;
  max-width: 90%;
  box-shadow: 0 4px 16px rgba(0,0,0,.3);
}

/* "New version available" prompt (app.js shows it when a new service worker takes over). Same pill as .toast, but
   a real tappable button that reloads onto the new app.js; it does not auto-hide. */
.update-toast {
  position: fixed;
  left: 50%;
  bottom: calc(76px + var(--safe-bottom));
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 10px 16px;
  border: 0;
  border-radius: 22px;
  font-family: inherit;
  font-size: .88rem;
  font-weight: 600;
  cursor: pointer;
  z-index: 61;
  max-width: 90%;
  box-shadow: 0 4px 16px rgba(0,0,0,.3);
}
.update-toast:active { transform: translateX(-50%) scale(.97); }

/* ── App Lock screen (Brief 12.26) — a full-screen passcode gate (screen lock, not encryption) ─────────── */
.lock-screen {
  position: fixed; inset: 0; z-index: 100;
  background: var(--bg-app);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.lock-card {
  width: 100%; max-width: 320px; text-align: center;
  background: var(--bg-surface); border: 1px solid var(--line); border-radius: 18px;
  padding: 28px 22px; box-shadow: 0 6px 24px rgba(0,0,0,.12);
}
.lock-brand { font-weight: 700; color: var(--red-accent); margin-bottom: 14px; }
.lock-title { font-size: 1.2rem; font-weight: 700; margin-bottom: 4px; }
.lock-sub { color: var(--ink-soft); font-size: .9rem; margin-bottom: 16px; }
.lock-input {
  width: 100%; font-size: 1.3rem; letter-spacing: .3em; text-align: center;
  padding: 12px 14px; border: 1.5px solid var(--line); border-radius: 12px; outline: none;
  background: var(--bg-surface); color: var(--ink);
}
.lock-input:focus { border-color: var(--red); }
.lock-err { color: var(--red-dark); font-size: .85rem; margin-top: 8px; }
.lock-card .btn { width: 100%; margin-top: 14px; }

/* spinner / empty hint inside lists */
.loading {
  padding: 30px;
  text-align: center;
  color: var(--ink-soft);
  font-size: .9rem;
}

/* ============================================================================
   Accessibility catch-up (spec §11 gap row 32 / §12) — a genuine gap the reference carries and we
   didn't: a real focus-visible ring (we only had :focus border-colour swaps on a few form fields),
   Windows High-Contrast Mode (forced-colors), and prefers-contrast handling. Own tokens throughout —
   the reference's literal focus-ring blue is not reused (see --focus-ring above).
   ========================================================================== */
a:focus-visible,
button:focus-visible,
[tabindex]:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}
/* TEXT INPUTS opt out of the two-layer ring (round-2 feedback 2026-07-05): unlike buttons, a text field
   matches :focus-visible on EVERY tap, so the ring drew a permanent red halo around the composer while
   typing (and clipped against the poll/event builder's scrolling body). Their focus indicator is the
   border-colour swap the fields already carry, thickened here so keyboard users still get a clear cue. */
input:focus-visible,
textarea:focus-visible {
  outline: none;
  box-shadow: none;
  border-color: var(--red-accent);
}

/* Windows High-Contrast Mode strips our custom colours/box-shadows — fall back to system colour
   keywords so focus is still visible and bubble boundaries (which normally rely on fill-colour
   contrast against the wallpaper, not a border) don't disappear. */
@media (forced-colors: active) {
  a:focus-visible,
  button:focus-visible,
  input:focus-visible,
  textarea:focus-visible,
  [tabindex]:focus-visible {
    outline: 2px solid Highlight;
    outline-offset: 2px;
    box-shadow: none;
  }
  .msg--in, .msg--out { border: 1px solid CanvasText; }
  /* The soft-tail shape can't express meaningfully once colours are forced flat — the bubble border
     above is enough to read the boundary, so hide it rather than leave a stray coloured fragment. */
  .msg--in::before, .msg--out::before { display: none; }
}

/* prefers-contrast: more — thicken the boundaries that normally rely on a subtle colour/tint
   difference (bubble vs wallpaper, field vs surface) rather than a drawn border. */
@media (prefers-contrast: more) {
  .msg--in, .msg--out { border: 1px solid var(--line); }
  .field, .rooms-search-input, .composer-field, .search-input, .media-caption-input { border-width: 2px; }
}

/* ============================================================================
   Dark mode — OS-driven (prefers-color-scheme), no in-app toggle.
   Keeps the Comply Chat RED identity (never a WhatsApp dark-green/teal ensemble):
   FILL reds (--red/--red-dark) stay deep so white text on the topbar/buttons/
   badges/send FAB stays legible; --red-accent lifts to a light coral-red for
   TEXT/GLYPHS on dark (senders, links, read ticks, transparency pill). Surfaces
   swap via tokens; the few hard-coded light values are overridden explicitly.
   ========================================================================== */
@media (prefers-color-scheme: dark) {
  :root {
    --red:        #b3261e;   /* fill: deep enough for white text (≈5.9:1) — brand red, not green */
    --red-dark:   #7a1712;   /* darker fill for :hover */
    --red-accent: #ff8a80;   /* on-dark text/glyph red — legible (≈7:1 on the dark bubble) */
    --red-tint:   #40201c;   /* outgoing bubble: deep warm red-brown (own-brand dark, NOT WhatsApp green) */
    --ink:        #e8e6ea;
    --ink-soft:   #9b98a2;
    --line:       #2c2a33;
    --bg-app:     #121116;
    --bg-surface: #1c1a20;   /* cards, chats-list, rows, composer field, coachmark */
    --bg-bubble-in: #26242c; /* incoming bubble — a touch lighter than the surface so it still reads as a bubble */
    --tick-grey:  #8a97a2;
    --wallpaper-base: #0c0b0f;
    --shadow: 0 1px 2px rgba(0,0,0,.5);
  }
  /* Hard-coded light values that no token covers. */
  .view--auth { background: radial-gradient(120% 80% at 50% -10%, #221f27 0%, var(--bg-app) 60%); }
  .field:focus { border-color: var(--red-accent); }
  .room-row:hover  { background: #23212a; }
  .room-row:active { background: #2a2833; }
  .day-sep { background: rgba(40, 38, 48, .92); }
  .unread-sep { background: rgba(40, 38, 48, .95); }   /* parity pass — same chip family as the day pill */
  .system-line { background: rgba(64, 32, 29, .6); }   /* dark red-tinted transparency pill */
  /* Parity-pass surfaces that hard-code light values. */
  .msg { box-shadow: 0 1px .5px rgba(0, 0, 0, .35); }
  .msg-react { box-shadow: 0 1px 2px rgba(0, 0, 0, .5); }
  .msg-react--mine { box-shadow: 0 1px 2px rgba(0, 0, 0, .5), inset 0 0 0 1px var(--red-accent); }
  .card-action, .event-rsvp, .event-rsvp-btn { border-color: rgba(255, 255, 255, .14); }
  .location-map {
    background:
      linear-gradient(105deg, transparent 46%, rgba(255,255,255,.28) 46%, rgba(255,255,255,.28) 54%, transparent 54%),
      linear-gradient(15deg, transparent 30%, rgba(255,255,255,.22) 30%, rgba(255,255,255,.22) 35%, transparent 35%),
      linear-gradient(15deg, transparent 64%, rgba(255,255,255,.22) 64%, rgba(255,255,255,.22) 68%, transparent 68%),
      linear-gradient(160deg, #232a20 0%, #2a3226 45%, #222920 100%);
  }
  .toast,
  .update-toast { background: #2c2a33; color: var(--ink); }   /* --ink flips light in dark, so the pill bg can't use it */
  .msg-wallpaper::before { opacity: .07; }             /* the cream doodle image → a faint warm texture on near-black */
  /* Remaining on-dark text/glyph reds that still resolved to a deep FILL red — lift to the legible accent.
     --red-dark (error text) and --red/--unread-red (unread time, focus borders) are all sub-AA on the dark
     surfaces; --red-accent (#ff8a80) restores AA. Do NOT flip the --unread-red TOKEN — .unread-badge uses it as
     a fill behind white text, where a light red would fail. Only the TEXT/BORDER consumers move. */
  .field-error { color: var(--red-accent); }
  .room-time.has-unread { color: var(--red-accent); }
  .rooms-search-input:focus { border-color: var(--red-accent); }
  .composer-field:focus-within { border-color: var(--line); } /* neutral while typing — round-2 parity */
}

/* ══ Recorded calls (Brief 15.9) ══════════════════════════════════════════════════════════════════════════
   Full-screen overlays (consent → ring → in-call), the persistent REC banner, and the chat call card.
   Portrait-first (the manifest stays portrait — changing orientation re-mints WebAPKs, GR-WEBAPK memory). */
.call-overlay {
  position: fixed; inset: 0; z-index: 240; /* above lightbox/profile panes */
  background: #10151a; color: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: max(20px, env(safe-area-inset-top)) 20px max(24px, env(safe-area-inset-bottom));
  text-align: center;
}
.call-card { display: flex; flex-direction: column; align-items: center; gap: 10px; max-width: 340px; }
.call-avatar {
  width: 92px; height: 92px; border-radius: 50%;
  background: #2b3942; color: #fff; font-size: 40px; font-weight: 600;
  display: grid; place-items: center;
}
.call-who { font-size: 22px; font-weight: 700; }
.call-sub { font-size: 14px; color: #b7c2ca; }
.call-consent-line { font-size: 14px; color: #ffd9d6; margin: 6px 0 0; }
.call-warn { font-size: 13px; color: #ffb4ab; margin: 4px 0 0; }
.call-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; width: 100%; }
.call-btn {
  appearance: none; border: 0; border-radius: 999px; padding: 14px 18px;
  font-size: 16px; font-weight: 700; cursor: pointer; width: 100%;
}
.call-btn--go { background: #1faa5c; color: #fff; }      /* the ONLY affirmative — Start/Accept recorded call */
.call-btn--end { background: #d93025; color: #fff; }
.call-btn--ghost { background: transparent; color: #cfd8dd; border: 1px solid #46545e; }
.call-btn:disabled { opacity: .5; }

/* in-call */
.call-overlay--live { justify-content: space-between; padding-top: 0; }
.call-rec-banner {
  position: relative;
  width: calc(100% + 40px); margin: 0 -20px;
  background: #c62828; color: #fff; font-weight: 700; font-size: 13.5px;
  padding: calc(8px + env(safe-area-inset-top)) 14px 8px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.call-rec-label { font-weight: 800; letter-spacing: .3px; }
/* minimise button — floated right of the banner (full-screen only), so the centred REC text is undisturbed */
.call-mini-btn {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  appearance: none; border: 0; background: rgba(255,255,255,.18); color: #fff;
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; cursor: pointer; padding: 0;
}
.call-mini-btn svg { width: 17px; height: 17px; }
.call-mini-btn:active { background: rgba(255,255,255,.3); }
.call-rec-dot { width: 10px; height: 10px; border-radius: 50%; background: #fff; animation: callBlink 1.1s steps(2, start) infinite; }
@keyframes callBlink { 50% { opacity: .25; } }
.call-duration { font-variant-numeric: tabular-nums; font-weight: 600; opacity: .95; }
.call-stage { position: relative; flex: 1; width: 100%; display: grid; place-items: center; }
.call-video-remote { position: absolute; inset: 0; display: none; background: #000; }
.call-video-remote.on { display: block; }
.call-video-remote video, .call-video-slot, .call-video-slot > div { width: 100%; height: 100%; }
.call-video-remote video { object-fit: cover; }
.call-video-pip {
  position: absolute; right: 12px; bottom: 12px; width: 28%; max-width: 140px; aspect-ratio: 3/4;
  border-radius: 10px; overflow: hidden; border: 2px solid rgba(255,255,255,.65); background: #222;
  display: none; z-index: 2;
}
.call-video-pip.on { display: block; }
.call-video-pip video { width: 100%; height: 100%; object-fit: cover; }
.call-card--live { position: relative; z-index: 1; }
.call-overlay--live .call-video-remote.on ~ .call-card--live,
.call-overlay--live .call-video-remote.on + .call-video-pip + .call-card--live { display: none; } /* video fills the stage */
.call-controls {
  display: flex; gap: 10px; width: 100%; max-width: 420px;
  padding-bottom: max(6px, env(safe-area-inset-bottom));
}
.call-ctl {
  appearance: none; border: 0; border-radius: 999px; flex: 1; padding: 13px 8px;
  background: #2b3942; color: #fff; font-size: 14px; font-weight: 600; cursor: pointer; min-height: 48px;
}
.call-ctl--end { background: #d93025; flex: 1.2; }

/* ── Minimise-to-PiP: the live call collapses to a small movable window so the app stays usable mid-call. ──────
   Only the overlay is restyled (JS sets left/top); the ACS video renderers are untouched, so no freeze. Because
   the overlay shrinks to this box, the rest of the screen is no longer covered → the app underneath is live. */
.call-mini-end { display: none; }              /* only shown in mini mode */
.call-overlay--mini {
  inset: auto;                                  /* released from full-screen; JS positions via left/top */
  width: 132px; height: 196px; padding: 0;
  border-radius: 14px; overflow: hidden;
  border: 1px solid rgba(255,255,255,.16); box-shadow: 0 10px 30px rgba(0,0,0,.55);
  z-index: 260; cursor: grab; touch-action: none; user-select: none;
}
.call-overlay--mini.dragging { cursor: grabbing; }
.call-overlay--mini .call-stage { padding: 0; }
.call-overlay--mini .call-controls,
.call-overlay--mini .call-diag { display: none; }
.call-overlay--mini .call-video-pip { display: none; }   /* no room for the self-view thumbnail when tiny */
/* compliance: the recording indicator NEVER disappears mid-call — the banner compacts to a "● REC 0:12" pill */
.call-overlay--mini .call-rec-banner {
  position: absolute; top: 6px; left: 6px; width: auto; margin: 0;
  padding: 3px 8px; border-radius: 999px; font-size: 11px; gap: 5px; z-index: 3;
  background: rgba(198,40,40,.94);
}
.call-overlay--mini .call-rec-text, .call-overlay--mini .call-mini-btn { display: none; }
.call-overlay--mini .call-duration { font-size: 11px; }
/* voice / pre-video: show a compact avatar + name centred in the box */
.call-overlay--mini .call-card--live { transform: scale(.66); }
.call-overlay--mini .call-avatar { width: 64px; height: 64px; font-size: 26px; }
.call-overlay--mini .call-who { font-size: 13px; }
/* mini End — small red hang-up, bottom-centre of the box; taps elsewhere on the box expand it back */
.call-overlay--mini .call-mini-end {
  position: absolute; left: 50%; bottom: 8px; transform: translateX(-50%);
  width: 40px; height: 40px; border-radius: 50%; border: 0; cursor: pointer; z-index: 4;
  background: #d93025; color: #fff; display: grid; place-items: center; padding: 0;
}
.call-overlay--mini .call-mini-end svg { width: 20px; height: 20px; transform: rotate(135deg); } /* handset → hang-up */

/* Brief 16.1d — ring-readiness banner: a phone calls can't ring must SAY so (quiet amber, tappable) */
.ring-readiness {
  display: block; width: calc(100% - 24px); margin: 0 12px 8px; padding: 10px 14px;
  background: #fff7e6; color: #7a4d00; border: 1px solid #f0d9a6; border-radius: 10px;
  font-size: 13.5px; font-weight: 600; text-align: left; cursor: pointer;
}
.ring-readiness:active { background: #ffefcc; }

/* ── Brief 16.1 — ring prominence: full-screen takeover, pulsing halo, round phone buttons ─────────────── */
.call-overlay--ring { background: radial-gradient(120% 90% at 50% 0%, #1d2b36 0%, #10151a 55%, #0b0f13 100%); }
.call-overlay--ring .call-who { font-size: 26px; }
.call-avatar-wrap { position: relative; display: grid; place-items: center; width: 92px; height: 92px; }
.call-avatar-wrap .call-avatar { position: relative; z-index: 1; }
.call-overlay--ring .call-avatar-wrap::before,
.call-overlay--ring .call-avatar-wrap::after {
  content: ''; position: absolute; inset: 0; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .35);
  animation: callPulse 2s ease-out infinite;
}
.call-overlay--ring .call-avatar-wrap::after { animation-delay: 1s; }
@keyframes callPulse { 0% { transform: scale(1); opacity: .8; } 100% { transform: scale(2.1); opacity: 0; } }
.call-ring-actions { display: flex; justify-content: center; align-items: flex-start; gap: 44px; margin-top: 12px; width: 100%; }
.call-round-holder { display: flex; flex-direction: column; align-items: center; gap: 8px; max-width: 130px; }
.call-round {
  appearance: none; border: 0; width: 72px; height: 72px; border-radius: 50%;
  display: grid; place-items: center; cursor: pointer;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .35);
}
.call-round svg { width: 32px; height: 32px; fill: #fff; }
.call-round--go { background: #1faa5c; animation: callNudge 1.6s ease-in-out infinite; } /* the ONLY affirmative */
.call-round--end { background: #d93025; }
.call-round--end svg { transform: rotate(135deg); }
.call-round:disabled { opacity: .5; animation: none; }
.call-round-label { font-size: 13px; color: #e6edf1; line-height: 1.25; text-align: center; }
@keyframes callNudge { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
@media (prefers-reduced-motion: reduce) {
  .call-overlay--ring .call-avatar-wrap::before, .call-overlay--ring .call-avatar-wrap::after, .call-round--go { animation: none; }
}

/* the chat card for a terminal call row */
.msg-call { display: flex; align-items: center; gap: 10px; padding: 4px 2px; }
.msg-call:has(.msg-call-summary) { align-items: flex-start; } /* summary makes the body multi-line — top-align the icon */
.msg-call:has(.msg-call-summary) .msg-call-icon { margin-top: 2px; }
.msg-call-icon { font-size: 22px; }
.msg-call-head { font-size: 14.5px; }
.msg-call-sub { font-size: 12px; color: var(--muted, #667781); margin-top: 1px; }
.msg-call--missed .msg-call-head { color: var(--red-accent, #b3261e); }
/* Brief 16.2 — the AI summary under "Recorded — on the record": quiet, clearly labelled as an AI aid */
.msg-call-summary { margin-top: 7px; padding-top: 6px; border-top: 1px solid rgba(17, 27, 33, .12); }
.msg-call-summary-label { font-size: 11px; font-weight: 700; letter-spacing: .02em; color: var(--muted, #667781); margin-bottom: 2px; }
.msg-call-summary-text { font-size: 13px; line-height: 1.35; color: var(--ink, #111b21); }
.call-diag { font-size: 11.5px; color: #8fa0aa; margin-top: 14px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; min-height: 1em; } /* flip-night: the screen says what the machine is doing */

/* ══ Brief 20 — contacts directory, presence dots, profile avatars, swipe-to-archive ═════════════════════════ */
/* Presence dot (Teams-style) on an avatar corner — green online / amber away / grey offline. */
.avatar, .newchat-av, .settings-profile-av, .profile-member-av { position: relative; }
.presence-dot {
  position: absolute; right: -1px; bottom: -1px;
  width: 13px; height: 13px; border-radius: 50%;
  border: 2px solid var(--bg-surface); box-sizing: border-box;
}
.presence-dot--online { background: #22c55e; }
.presence-dot--away { background: #f59e0b; }
.presence-dot--offline { background: #9ca3af; }

/* Swipe-LEFT-to-archive — the amber action sits behind the row, revealed as the row slides left. */
.room-row-wrap { position: relative; overflow: hidden; background: var(--bg-surface); }
.room-row-wrap > .room-row { position: relative; z-index: 1; }
.room-row--swiping { box-shadow: -6px 0 12px -8px rgba(0, 0, 0, .25); }
.room-archive-action {
  position: absolute; top: 0; right: 0; bottom: 0; width: 92px; z-index: 0;
  display: flex; align-items: center; justify-content: center;
  background: #f59e0b; color: #fff; font-weight: 700; font-size: .85rem;
}

/* "🗂 Archived (n)" rollup at the TOP of the chat list + the back row in the archived view. */
.archived-rollup, .archived-back {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 14px;
  border: none; border-bottom: 1px solid var(--line); background: var(--bg-surface);
  font: inherit; color: inherit; text-align: left; cursor: pointer;
}
.archived-rollup:hover, .archived-back:hover { background: #faf8f9; }
.archived-ico, .archived-back-ico { font-size: 1.2rem; width: 32px; text-align: center; color: var(--muted, #667781); }
.archived-label { flex: 1 1 auto; font-weight: 600; }
.archived-count { color: var(--muted, #667781); font-size: .85rem; }
.archived-empty { padding: 24px 16px; text-align: center; color: var(--muted, #667781); font-size: .9rem; }

/* New-chat sheet (bottom sheet: contacts directory + "Message yourself"). */
.newchat-panel {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  max-height: 80dvh; display: flex; flex-direction: column;
  background: var(--bg-surface); border-radius: 16px 16px 0 0;
  padding: 6px 0 max(12px, env(safe-area-inset-bottom));
  box-shadow: 0 -8px 30px rgba(0, 0, 0, .25);
}
.sheet-grab { width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: 6px auto 8px; flex: 0 0 auto; }
.newchat-title { font-weight: 700; font-size: 1.05rem; padding: 2px 16px 8px; }
.newchat-search {
  margin: 0 16px 8px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg-app); font: inherit; color: inherit;
}
.newchat-status { padding: 8px 16px; color: var(--muted, #667781); font-size: .9rem; }
.newchat-list { overflow-y: auto; -webkit-overflow-scrolling: touch; }
.newchat-section { padding: 8px 16px 4px; font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted, #667781); }
.newchat-divider { height: 1px; background: var(--line); margin: 8px 16px; }
.newchat-empty { padding: 10px 16px; color: var(--muted, #667781); font-size: .9rem; }
.newchat-row {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 9px 16px;
  border: none; background: none; font: inherit; color: inherit; text-align: left; cursor: pointer;
}
.newchat-row:hover { background: var(--bg-app); }
.newchat-av { width: 42px; height: 42px; font-size: .95rem; }
.newchat-row-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.newchat-chev { color: var(--muted, #667781); font-size: 1.2rem; }
.newchat-row-actions { display: flex; gap: 6px; flex: 0 0 auto; }
.newchat-call {
  border: none; background: var(--bg-app); border-radius: 50%; width: 38px; height: 38px;
  font-size: 1.05rem; cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.newchat-call:hover:not(:disabled) { background: var(--line); }
.newchat-call:disabled { opacity: .35; cursor: default; }

/* Settings — Profile section (avatar + Change/Remove). */
.settings-profile { display: flex; align-items: center; gap: 14px; margin-top: 6px; }
.settings-profile-av { width: 60px; height: 60px; font-size: 1.3rem; flex: 0 0 auto; }
.settings-profile-btns { display: flex; flex-direction: column; gap: 6px; }
.profile-icon-btn--danger { color: var(--muted, #667781); }
