.sender-flow { max-width: 720px; margin: 0 auto; }
.sender-landing {
  display: flex; flex-direction: column; align-items: center;
  padding: 60px 24px; min-height: 50vh; text-align: center;
}
.sender-landing h1 { font-size: 24px; margin-bottom: 8px; }
.sender-landing p { color: var(--fg-muted); max-width: 400px; margin-bottom: 24px; }
.sender-landing form { display: flex; gap: 8px; max-width: 480px; width: 100%; }
.sender-landing input { flex: 1; padding: 10px 14px; font-size: 15px; border: 1px solid var(--border); border-radius: 6px; }
.context-pill {
  display: inline-block; background: var(--pill-bg); color: var(--pill-fg);
  padding: 4px 12px; border-radius: 12px; font-size: 12px; font-weight: 500;
  margin-bottom: 16px;
}
.ephemerality-notice { margin-top: 24px; font-size: 11px; color: var(--fg-faint); }
.warning { color: var(--danger); font-weight: 500; }

/* Creator's note (Phase 1 + Phase 2). Plain text only — html/template
 * escapes special chars on the server, white-space: pre-wrap preserves line
 * breaks. accent-soft tint + left rule reads as "branded content from the
 * creator" rather than system chrome (yellow is reserved for system notices).
 * Themes automatically when the creator overrides --accent / --accent-soft. */
.creator-note {
  background: var(--accent-soft);
  border-left: 3px solid var(--accent);
  padding: 12px 16px;
  border-radius: var(--radius);
  margin: 0 auto 20px;
  max-width: 440px;
  text-align: left;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--fg);
  white-space: pre-wrap;
  word-wrap: break-word;
}
.creator-note-label {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
  margin-bottom: 4px;
}
.creator-note-body { display: inline; }
/* Phase 2 banner: same palette, full-width (no max-width) since it sits
 * above the chat header. NOT dismissible — sender sees it every visit. */
.creator-note-banner {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 16px;
  background: var(--accent-soft);
  border-bottom: 1px solid var(--accent);
  font-size: 13px;
  color: var(--fg);
  line-height: 1.55;
}
.creator-note-banner .label {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
  margin-bottom: 2px;
}
.creator-note-banner .body { flex: 1; }
.creator-note-banner .creator-note-body {
  white-space: pre-wrap;
  word-wrap: break-word;
}

.chat-shell {
  display: flex; flex-direction: column;
  height: calc(100vh - 200px); min-height: 480px;
  border: 1px solid var(--border); border-radius: 8px; overflow: hidden;
  background: var(--shell-bg);
  position: relative; /* anchors the long-press action sheet */
}
/* Full-height chat: body → main → .sender-flow → shell flex chain. The
 * calc(100vh - 200px) above was a magic number approximating header +
 * footer + paddings that never summed exactly, so the composer floated
 * mid-screen with dead space below it. The chain must pass through
 * .sender-flow (the template's <section> wrapper around everything) —
 * without it, .chat-shell's flex:1 no-ops inside a block parent and the
 * shell collapses to content height. With the full chain, the shell fills
 * the space between site-header and site-footer exactly; .chat-messages'
 * existing flex:1 puts the slack INSIDE the shell (between messages and
 * the pinned composer). Old-height fallback stays for browsers without
 * :has(); the SPA embed copy solves this differently (100dvh + .embed-shell
 * override) and intentionally does not mirror these page-skeleton rules —
 * its iframe has no site chrome. */
@supports selector(body:has(.chat-shell)) {
  body:has(.chat-shell) {
    display: flex; flex-direction: column;
    min-height: 100vh; min-height: 100dvh;
  }
  body:has(.chat-shell) .site-header,
  body:has(.chat-shell) .site-footer { flex: none; }
  body:has(.chat-shell) main {
    flex: 1; display: flex; flex-direction: column; min-height: 0;
    padding: 16px 20px 20px;
  }
  /* .sender-flow keeps its max-width + auto margins for horizontal
   * centering; it just also becomes the flex column link in the chain.
   * width:100% is load-bearing: auto cross-axis margins on a flex item
   * disable stretch, leaving width:auto to fit-content — floored by the
   * content's min-content, which the return-banner's nowrap URL code
   * inflates past any phone viewport (its flex min-width:0 clamps layout
   * but, per a long-standing flexbox quirk, not the container's intrinsic
   * width). Result: the whole page rendered ~640px wide on iOS and Send
   * lived off-screen right. width:100% pins the flow to the viewport;
   * max-width + auto margins keep it centered, and the shell's own
   * overflow:hidden + the code's ellipsis absorb the rest. */
  body:has(.chat-shell) .sender-flow {
    flex: 1; width: 100%; display: flex; flex-direction: column; min-height: 0;
  }
  .chat-shell { height: auto; flex: 1; }
}
.chat-header { padding: 14px 20px; border-bottom: 1px solid var(--border); position: relative; }
/* Collapsible header (2026-09-02): the orientation block (note banner +
   chat header + return banner) folds into a slim rail on click; the rail is
   its collapsed form. Every zone gets cursor + hover tint; the faint
   chevron button in each state is the keyboard/screen-reader toggle. */
.chat-header, .creator-note-banner, .return-link-banner, .chat-header-rail {
  cursor: pointer;
}
.chat-header, .chat-header-rail { transition: background-color 80ms ease; }
.chat-header:hover, .chat-header-rail:hover { background: var(--bg-soft); }
/* Banners already sit on --accent-soft; hover lifts toward white instead
   (color-mix so per-link theming flows through). */
.creator-note-banner:hover, .return-link-banner:hover {
  background: color-mix(in srgb, var(--accent-soft) 86%, white);
}
.chat-header-rail {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px 20px; border-bottom: 1px solid var(--border);
}
.chat-header-rail .who { font-weight: 600; font-size: 14px; }
.header-chevron {
  background: none; border: none; cursor: pointer;
  color: var(--fg-faint); font-size: 12px; line-height: 1;
  padding: 4px 2px; flex: none;
}
.header-chevron:hover { color: var(--fg); }
.chat-header-rail .header-chevron { margin-left: auto; }
/* 1:1 expanded header floats its chevron at the block's top-right corner
   (that corner is free — its buttons live on a lower row). The conference
   header keeps the chevron inline in .header-actions instead, since its
   top-right is occupied by the occupants trigger + mute. */
.chevron-float { position: absolute; top: 12px; right: 14px; }
.chat-header .who { font-weight: 600; font-size: 14px; }
.chat-header .meta { color: var(--fg-muted); font-size: 12px; margin-top: 4px; }
/* One-line orientation for zero-context visitors. Mirrored in
   web/src/styles/chat.css per the dual-stack sender styling rule. */
.orientation-line { margin: 5px 0 0; font-size: 12.5px; color: var(--fg-muted); }
.orientation-line strong { color: var(--fg); font-weight: 600; }
/* Identified-chats pill chip: shown only on verified-identity rooms. Uses the
   shared accent tokens so per-link theming flows through. Mirrored in
   web/src/styles/chat.css per the dual-stack sender styling rule. */
.identity-chip {
  display: inline-flex; align-items: center; gap: 6px;
  margin-top: 8px; padding: 3px 11px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent);
  border: 1px solid var(--accent);
  font-size: 11.5px; font-weight: 600; line-height: 1.6;
}
.chat-header-actions {
  display: flex; align-items: center; gap: 8px;
}
.chat-header-row {
  display: flex; align-items: center; gap: 12px; margin-top: 6px;
}
.mute-toggle {
  font-size: 16px; line-height: 1;
  padding: 4px 8px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background-color 80ms ease;
}
.mute-toggle:hover { background: var(--code-bg); }
.return-hint { color: var(--fg-faint); font-size: 12px; }

/* Push notification opt-in toggle. Three states (initial/active/blocked)
 * match sender-push.js's setState(). Sits next to the existing .mute-toggle
 * in the chat header; uses a different icon (📱 vs 🔔) and labels to
 * distinguish cross-device push from in-tab audio/visual notifications. */
.push-toggle {
  font-size: 13px; line-height: 1;
  padding: 5px 10px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background-color 80ms ease, border-color 80ms ease, color 80ms ease;
  font-family: inherit;
  color: var(--fg-muted);
  display: inline-flex; align-items: center; gap: 4px;
}
.push-toggle:hover { color: var(--fg); }
.push-toggle.primary {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 500;
}
.push-toggle.primary:hover { background: #243218; }
.push-toggle.active {
  background: #16a34a;
  border-color: #16a34a;
  color: white;
}
.push-toggle.blocked {
  background: var(--bg-soft);
  border-color: var(--border);
  color: var(--fg-faint);
  cursor: not-allowed;
  text-decoration: line-through;
}

/* Notify placement (hybrid A+B, 2026-09-10): the header/rail pills anchor
   to the RIGHT edge (identity left, action right) and a labelled CTA row
   hugs the composer. Placement rules only — the pill itself stays the
   untouched .push-toggle above. Mirrored in web/src/styles/chat.css per
   the dual-stack sender styling rule. */
.chat-header .hdr-actions {
  position: absolute; top: 12px; right: 44px; /* leaves the chevron its corner (right:14px) */
  display: flex; gap: 8px; align-items: center;
}
.chat-header-rail .rail-actions {
  margin-left: auto; display: flex; gap: 8px; align-items: center; flex: none;
}
.chat-header-rail .rail-actions .header-chevron { margin-left: 0; }
.notify-cta-row {
  display: flex; justify-content: flex-end; align-items: center; gap: 8px;
  padding: 10px 16px 0;
}
.notify-cta-row.hidden { display: none; }
.notify-cta-row .dismiss {
  background: none; border: none; color: var(--fg-faint);
  font-size: 13px; cursor: pointer; padding: 2px;
}
.notify-cta-row .dismiss:hover { color: var(--fg); }
@media (max-width: 400px) {
  /* Narrow rails: shorten to the same label the header pill uses so the
     row never crowds Send. */
  .notify-cta-row .push-cta { font-size: 12px; }
}

/* One-time banner shown after initiate succeeds. Sticky at the top of the
   chat surface so the sender sees it before sending anything. */
.return-link-banner {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px;
  background: #2a2310;
  border-bottom: 1px solid #6b541a;
  color: #f0d68a;
  font-size: 13px;
}
.return-link-banner code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: rgba(0,0,0,0.4);
  padding: 2px 6px; border-radius: 3px;
  font-size: 12px;
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.return-link-banner .link-button {
  font-size: 12px;
  color: #f0d68a;
}
.return-link-banner .link-button:hover { color: #ffe9b3; }

/* Inline push nudge under the sender's first sent message (2026-08-23).
   Right-aligned so it sits under their own bubble; meta-line weight. The
   .done variant is the settled state after subscribe/deny. Mirrored in
   web/src/styles/chat.css (deviation 16 sync rule). */
.inline-notify {
  display: flex; align-items: center; justify-content: flex-end; gap: 8px;
  margin: -4px 4px 6px; padding: 0 4px;
  font-size: 12.5px; color: var(--fg-muted);
}
.inline-notify .act {
  font: inherit; font-size: inherit; padding: 0; border: none; background: none;
  color: var(--accent); text-decoration: underline;
  text-underline-offset: 3px; text-decoration-color: rgba(198, 255, 58, 0.4);
  cursor: pointer; font-weight: 500;
}
.inline-notify .act:hover { color: #d6ff5a; }
.inline-notify .x { color: var(--fg-faint); cursor: pointer; font-size: 13px; }
.inline-notify .x:hover { color: var(--fg); }
.inline-notify.done { color: var(--fg-faint); pointer-events: none; }

/* "This conversation has ended." banner shown when xmpp.js fires
 * room-destroyed (creator clicked Delete, account cascade-delete, etc.).
 * Mirrors the .return-link-banner palette so both top-of-chat banners read
 * as the same visual family. */
.chat-ended-banner {
  padding: 12px 16px;
  background: var(--bg-warn);
  border-bottom: 1px solid #6b541a;
  color: #f0d68a;
  font-size: 14px;
  text-align: center;
}
.chat-ended-banner .muted.small { display: block; margin-top: 2px; }

.chat-messages { flex: 1; padding: 16px 20px; overflow-y: auto; overflow-x: hidden; background: var(--chat-bg); }
.chat-msg { margin-bottom: 12px; max-width: 70%; }
.chat-msg.them { margin-right: auto; }
.chat-msg.me { margin-left: auto; text-align: right; }
.chat-msg .bubble {
  display: inline-block; padding: 8px 12px; border-radius: 12px;
  font-size: 14px; line-height: 1.4; text-align: left;
  /* Bodies carry interior \n intact through XMPP + SQLite; without pre-wrap
     HTML collapses each newline into a single space. Mirrored in
     web/src/styles/chat.css. */
  white-space: pre-wrap;
  /* Unbroken runs (HARROW!!!111…) must wrap inside the bubble — see the
     mirrored rule + rationale in web/src/styles/chat.css. */
  overflow-wrap: break-word; /* fallback: Safari < 16 lacks `anywhere` */
  overflow-wrap: anywhere;
}
/* Links inside bubbles take the bubble's own foreground, not a global
   accent: an accent-tinted own-bubble background would render the link
   accent-on-accent, invisible (2026-08-29). Mirrored in
   web/src/styles/chat.css. */
.chat-msg .bubble a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.chat-msg.them .bubble {
  background: var(--bubble-them-bg); color: var(--bubble-them-fg);
  border: 1px solid var(--bubble-them-border); border-bottom-left-radius: 4px;
}
.chat-msg.me .bubble {
  background: var(--bubble-me-bg); color: var(--bubble-me-fg); border-bottom-right-radius: 4px;
}
.chat-msg .meta { font-size: 10px; color: var(--fg-faint); margin-top: 3px; }

/* ── Reply-to (XEP-0447) ──────────────────────────────────────────────
 * Quote band (full-bleed header inside the bubble, mockup v5), reply bar
 * above the composer, long-press action sheet, and the quote-tap flash.
 * MIRRORED in web/src/styles/chat.css (deviation 16) — change both or
 * neither. */
.chat-msg .bubble.has-quote { padding: 0; overflow: hidden; }
.quote-block {
  display: block; margin: 0; padding: 8px 10px 6px;
  border-left: 3px solid var(--accent);
  font-size: 12px; line-height: 1.3; cursor: pointer;
  background: rgba(255,255,255,0.05); color: var(--fg-muted);
  /* The bubble is pre-wrap (line-break fix): whitespace-only text nodes
     between template/DOM tags must never render as blank lines here. */
  white-space: normal;
}
.quote-block .q-sender { display: block; font-weight: 600; color: var(--accent); }
/* Wraps (never nowrap): a nowrap run inflates the inline-block bubble's
 * min-content width past .chat-msg's max-width and the page scrolls
 * horizontally. Length is already bounded by the 80-rune truncation. */
.quote-block .q-snippet {
  display: block; overflow-wrap: anywhere;
}
.quote-body { display: block; padding: 6px 10px 8px; }
.chat-msg.me .quote-block {
  border-left-color: rgba(0,0,0,0.45);
  background: rgba(0,0,0,0.14); color: rgba(0,0,0,0.62);
}
.chat-msg.me .quote-block .q-sender { color: rgba(0,0,0,0.8); }
.quote-block.q-missing { border-left-color: var(--fg-faint); color: var(--fg-faint); cursor: default; }

.reply-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 16px; border-top: 1px solid var(--border);
  background: var(--bg-soft); font-size: 12px; color: var(--fg-muted);
}
.reply-bar .q-sender { color: var(--accent); font-weight: 600; flex-shrink: 0; }
.reply-bar .q-snippet { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reply-bar .cancel {
  background: none; border: none; color: var(--fg-faint); cursor: pointer;
  font-size: 13px; padding: 2px 4px;
}

.action-sheet {
  position: absolute; z-index: 30;
  background: rgba(29,29,32,0.97); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5); padding: 6px;
  display: flex; flex-direction: column; gap: 2px;
}
.action-sheet .as-reply {
  display: flex; align-items: center; gap: 8px; background: none; border: none;
  color: var(--accent); font: inherit; font-size: 13px; font-weight: 600;
  padding: 7px 12px; border-radius: 8px; cursor: pointer; text-align: left;
}
.action-sheet .as-reply:hover { background: rgba(255,255,255,0.06); }
.action-sheet .as-emojis { display: flex; gap: 2px; border-top: 1px solid var(--border); padding-top: 4px; margin-top: 2px; }
.action-sheet .as-emoji { background: none; border: none; font-size: 16px; padding: 4px 6px; border-radius: 8px; cursor: pointer; }
.action-sheet .as-emoji:hover { background: rgba(255,255,255,0.08); }

@keyframes quote-flash {
  0%, 55% { box-shadow: 0 0 0 2px var(--accent); }
  100% { box-shadow: 0 0 0 2px transparent; }
}
.chat-msg .bubble.flash { animation: quote-flash 1.4s ease-out; }
/* ── end reply-to ──────────────────────────────────────────────────── */
/* XEP-0085 typing indicator: slim line above the composer. Mirrored in
   web/src/styles/chat.css (deviation 16). */
.typing-line {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 16px 2px; font-size: 12px; color: var(--fg-muted);
  min-height: 24px;
}
.typing-dots { display: inline-flex; gap: 3px; }
.typing-dots span {
  width: 5px; height: 5px; border-radius: 50%; background: var(--fg-muted);
  animation: typing-bounce 1.2s infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.typing-dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes typing-bounce {
  0%, 60%, 100% { opacity: 0.25; }
  30% { opacity: 1; }
}
.chat-msg .react-picker {
  margin-bottom: 4px;
  width: fit-content;
  opacity: 0; transition: opacity 0.1s;
  pointer-events: none;
}
.chat-msg.them .react-picker { margin-right: auto; }
.chat-msg.me .react-picker { margin-left: auto; }
.chat-msg:hover .react-picker { opacity: 1; pointer-events: auto; }
.chat-msg .react-button {
  background: transparent; border: none; cursor: pointer;
  font-size: 14px; padding: 2px 4px; line-height: 1;
  border-radius: 10px;
}
.chat-msg .react-button:hover {
  background: var(--bg-warn, rgba(255,255,255,0.12));
}
.chat-msg .reactions {
  display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px;
}
.chat-msg.me .reactions { justify-content: flex-end; }
.chat-msg .reaction-pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 1px 6px; border-radius: 10px; font-size: 12px;
  background: var(--bg-elevated, rgba(255,255,255,0.06));
  border: 1px solid var(--border);
}
.chat-msg .reaction-pill .reaction-count { color: var(--fg-faint); font-size: 11px; }
.chat-msg.date-sep {
  max-width: 100%; margin: 18px 0 12px; text-align: center;
}
.chat-msg.date-sep span {
  font-size: 11px; font-weight: 600; letter-spacing: 0.05em;
  text-transform: uppercase; color: var(--fg-faint);
  border: 1px solid var(--border); border-radius: 10px; padding: 2px 10px;
  background: var(--bg-soft);
}
.chat-msg.system { text-align: center; max-width: 100%; }
.chat-msg.system .bubble {
  background: var(--bg-warn); color: #f0d68a; border: 1px solid #6b541a;
  font-size: 12px; border-radius: 4px;
}
/* Suggested first-message openers (fresh sender mode only). Sits between the
 * message list and the composer; hides once draft is non-empty. Reuses the
 * context-pill palette so it reads as part of the same surface. */
.prompt-chips {
  padding: 8px 16px 0; display: flex; flex-wrap: wrap; gap: 8px;
}
.prompt-chip {
  background: var(--pill-bg); color: var(--pill-fg);
  border: 1px solid var(--border); border-radius: 999px;
  font-family: inherit; font-size: 13px; padding: 6px 12px;
  cursor: pointer;
}
.prompt-chip:hover, .prompt-chip:focus-visible { color: var(--fg); }

.chat-input {
  padding: 12px 16px; border-top: 1px solid var(--border); display: flex; gap: 8px;
}
.chat-input textarea {
  flex: 1; padding: 8px 12px; border: 1px solid var(--border);
  border-radius: 6px; font-family: inherit; font-size: 14px;
  resize: none; min-height: 38px;
}

.creator-chat-page { max-width: 900px; margin: 0 auto; }
.creator-chat-page .chat-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 16px; border-bottom: 1px solid var(--border); padding-bottom: 12px;
}
.back-link { color: var(--fg-muted); text-decoration: none; font-size: 13px; }
.chat-meta-bar {
  padding: 8px 16px; background: var(--bg-soft); border-bottom: 1px solid var(--border);
  font-size: 12px; color: var(--fg-muted); display: flex; gap: 16px;
}
.chat-meta-bar code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--code-bg); padding: 2px 6px; border-radius: 3px;
}

/* Peer presence — two layout variants share the same dot color/animation:
 *
 *   .peer-name     — inline, dot annotates the peer's name directly. Used on
 *                    sender side inside the .context-pill ("[with the ● Creator
 *                    online]"). Slack member-list pattern.
 *
 *   .presence-pill — pill format, sibling to the peer's name in the H1. Used
 *                    on creator side ("Chat with Alice [● Online]") because
 *                    the creator cares about reply-urgency and benefits from
 *                    the pill's visual weight.
 *
 * State class (.online / .idle / .away / .connecting / .reconnecting /
 * .offline) goes on whichever layout container is in use; the dot rules
 * below target either ancestor.
 *
 * Visual hierarchy: solid dots feel "present" (online, idle), hollow rings
 * feel "absent" (away, offline). Animations: pulse for "in progress"
 * (connecting/reconnecting), breathe for "alive but slow" (idle).
 * bewoke- prefix avoids collisions. */
.peer-name,
.presence-pill {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
}
.peer-name { gap: 5px; }
.presence-pill {
  gap: 6px;
  font-size: 12px;
  color: var(--fg-muted);
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  vertical-align: middle;
  margin-left: 6px;
  /* Pills read as labels, not sentence continuations — capitalize. */
  text-transform: capitalize;
}
.peer-name .dot,
.presence-pill .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--fg-faint);
  flex-shrink: 0;
}
.peer-name.online .dot,
.presence-pill.online .dot { background: #16a34a; }
.peer-name.idle .dot,
.presence-pill.idle .dot {
  background: #d97706;
  animation: bewoke-breathe 2.4s ease-in-out infinite;
}
.peer-name.away .dot,
.presence-pill.away .dot {
  background: transparent;
  border: 1.5px solid #d97706;
  width: 9px; height: 9px;
}
.peer-name.connecting .dot,
.presence-pill.connecting .dot {
  background: var(--fg-faint);
  animation: bewoke-pulse 1.2s ease-in-out infinite;
}
.peer-name.reconnecting .dot,
.presence-pill.reconnecting .dot {
  background: #d97706;
  animation: bewoke-pulse 1.2s ease-in-out infinite;
}
.peer-name.offline .dot,
.presence-pill.offline .dot {
  background: transparent;
  border: 1.5px solid var(--fg-faint);
  width: 9px; height: 9px;
}
.peer-name .aside {
  font-size: 12px;
  color: var(--fg-muted);
  font-weight: normal;
  margin-left: 2px;
}
@keyframes bewoke-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.3; transform: scale(0.75); }
}
@keyframes bewoke-breathe {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.55; }
}

/* Inbox shell (/chats) — two-pane layout: link tabs on top, conversation
 * list + chat pane below. The conv-list shows all rooms for the active
 * link tab; selecting one mounts the chatRoom component in the chat-pane.
 * CSS variables --bg-selected / --bg-unread are defined in main.css.
 * .dot-pres here is a *different pattern* from the .peer-name/.presence-pill
 * dot above: those annotate a name inline, while .dot-pres is a standalone
 * 7px dot in the conv-list row (smaller because the row is denser). */
.inbox-shell { display: flex; flex-direction: column; height: calc(100vh - 60px); }
.inbox-tabs {
  display: flex; gap: 2px; padding: 0 16px;
  background: var(--bg); border-bottom: 1px solid var(--border-soft);
  overflow-x: auto;
}
.inbox-tab {
  padding: 10px 14px; font-size: 13px; color: var(--fg-muted);
  background: none; border: none; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  white-space: nowrap; flex-shrink: 0; border-bottom: 2px solid transparent;
}
.inbox-tab:hover { color: var(--fg); }
.inbox-tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.inbox-tab .unread-pill {
  font-size: 10px; padding: 1px 6px; border-radius: 999px;
  background: #dc2626; color: white; font-weight: 600;
}
.unread-pill[x-show="false"] { display: none; }
.inbox-mute-toggle {
  margin-left: auto; padding: 6px 10px; font-size: 14px; line-height: 1;
  border-bottom-color: transparent !important;
}
.inbox-mute-toggle:hover { border-bottom-color: transparent !important; }
.inbox-mute-toggle.active { border-bottom-color: transparent !important; }

.inbox-body { flex: 1; display: grid; grid-template-columns: 320px 1fr; min-height: 0; }
.conv-list { border-right: 1px solid var(--border-soft); overflow-y: auto; }
.conv-item { padding: 12px 16px; cursor: pointer; border-bottom: 1px solid var(--border-soft); }
.conv-item:hover { background: var(--bg-soft); }
.conv-item.selected { background: var(--bg-selected); }
.conv-item.unread {
  background: var(--bg-unread);
  border-left: 3px solid var(--accent);
  padding-left: 13px;  /* compensate for added border-left */
}
.conv-item-top { display: flex; justify-content: space-between; align-items: baseline; }
.conv-item-name {
  font-size: 14px; font-weight: 600; color: var(--fg);
  display: flex; align-items: center; gap: 6px;
}
.conv-item.unread .conv-item-name { font-weight: 700; }
.conv-item.unread .conv-item-name::after {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  margin-left: 4px;
  flex-shrink: 0;
}
.conv-item-name .dot-pres,
.chat-pane-meta .dot-pres {
  width: 7px; height: 7px; border-radius: 50%; background: var(--fg-faint);
  display: inline-block;
}
.conv-item-name .dot-pres.online,
.chat-pane-meta .dot-pres.online { background: #16a34a; }
.conv-item-name .dot-pres.idle,
.chat-pane-meta .dot-pres.idle { background: #d97706; }
.conv-item-name .dot-pres.away,
.chat-pane-meta .dot-pres.away {
  background: transparent; border: 1.5px solid #d97706; width: 8px; height: 8px;
}
.conv-item-name .dot-pres.offline,
.chat-pane-meta .dot-pres.offline {
  background: transparent; border: 1.5px solid var(--fg-faint); width: 8px; height: 8px;
}
.conv-item-time { font-size: 11px; color: var(--fg-faint); }
.conv-item-unread-badge {
  display: inline-block;
  background: var(--accent);
  color: white;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 999px;
  margin-right: 6px;
  min-width: 16px;
  text-align: center;
}
.conv-item-unread-badge[x-show="false"] { display: none; }
.conv-item-preview {
  font-size: 12px; color: var(--fg-muted); margin-top: 3px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.conv-item-link-tag {
  display: inline-block; font-size: 10px; padding: 1px 6px;
  background: var(--bg); border: 1px solid var(--border-soft);
  border-radius: 3px; color: var(--fg-muted); margin-top: 4px;
}
.empty-state, .empty-chat {
  padding: 40px 20px; text-align: center; color: var(--fg-muted); font-size: 13px;
}
.empty-chat h3 { margin: 0 0 8px; color: var(--fg); font-size: 16px; }

/* Chat pane (/chats right side) — Task 19. Every selector here is scoped to
 * `.chat-pane` so it ONLY affects the creator inbox. Without that scope, the
 * unscoped selectors would clobber the sender-side rules on the sender page
 * — see TestChatCSS_ChatPaneRulesAreScoped in css_test.go for the regression
 * that motivated the explicit scope. The bubble-background rules here use
 * `--accent-soft` / `--bg-soft` (NOT the themeable `--bubble-*-bg` variables
 * the sender side consumes), so creator-inbox bubble colors stay decoupled
 * from per-link custom CSS. */
.chat-pane { display: flex; flex-direction: column; min-height: 0; }
/* Alpine's x-for wraps the chatRoom content in an extra <div> that breaks
 * the flex chain — without this rule, .chat-messages' flex:1 / overflow-y:auto
 * silently no-op because its parent isn't the flex container. See chats.html. */
.chat-pane-inner { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.chat-pane-header {
  padding: 12px 16px; border-bottom: 1px solid var(--border-soft);
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px;
}
.chat-pane-title { font-size: 16px; font-weight: 600; color: var(--fg); }
.chat-pane-meta { font-size: 12px; color: var(--fg-muted); display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.chat-pane-meta .room-jid {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px; padding: 1px 5px;
  background: var(--bg); border: 1px solid var(--border-soft);
  border-radius: 3px; cursor: pointer;
}
.chat-pane-meta .room-jid:hover { color: var(--fg); border-color: var(--border); }
.chat-pane-actions { display: flex; gap: 8px; }
.chat-pane .chat-messages { flex: 1; overflow-y: auto; padding: 12px 16px; }
.chat-pane .chat-msg.me .bubble { background: var(--bubble-me-bg); color: var(--bubble-me-fg); margin-left: 60px; }
.chat-pane .chat-msg.them .bubble { background: var(--bg-soft); margin-right: 60px; }
.chat-pane .chat-msg .bubble { padding: 8px 12px; border-radius: 8px; font-size: 14px; }
.chat-pane .chat-msg .meta { font-size: 11px; color: var(--fg-faint); margin-top: 3px; }
.chat-pane .chat-input {
  padding: 10px 16px; border-top: 1px solid var(--border-soft);
  display: flex; gap: 8px;
}
.chat-pane .chat-input textarea {
  flex: 1; resize: none; padding: 8px 12px;
  border: 1px solid var(--border); border-radius: var(--radius);
  font: inherit; min-height: 40px;
}
.mobile-back-btn { display: none; }

/* Mobile: collapse to single pane. List view shows by default; tapping
 * a conversation hides the list and shows the chat. chatInbox.mobileView
 * toggles between 'list' and 'chat'. */
@media (max-width: 720px) {
  .inbox-body { grid-template-columns: 1fr; }
  .inbox-shell.mobile-view-chat .conv-list { display: none; }
  .inbox-shell.mobile-view-list .chat-pane { display: none; }
  .inbox-shell.mobile-view-list .empty-chat { display: none; }
  .mobile-back-btn {
    display: inline-flex; align-items: center; gap: 6px;
    background: none; border: none; color: var(--accent);
    cursor: pointer; font-size: 14px; padding: 6px 10px;
  }
}

.chat-msg[data-nick-color] .bubble {
  border-left: 3px solid var(--nick-color, transparent);
}
.chat-msg.me[data-nick-color] .bubble {
  border-left: none;
}
.chat-msg .nick-avatar {
  display: inline-block;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--nick-color, var(--muted-bg));
  color: white;
  font-size: 11px;
  text-align: center;
  line-height: 20px;
  margin-right: 6px;
}
.chat-msg .bubble-header {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 2px;
  font-size: 0.8rem;
  color: var(--muted-text);
}

/* Conference-mode badge for the dashboard's conference link rows. */
.link-mode-badge.conference {
  background: var(--accent);
  color: white;
}
.link-mode-badge.direct {
  background: var(--muted-bg);
  color: var(--muted-text);
}
.link-mode-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.75rem;
  margin-left: 6px;
}

/* ========================================================================
 * Conference occupants popover (Option C from 2026-08-02 mockup).
 * Trigger chip in the chat header; click to open a popover with the full
 * occupant list + presence summary. Mobile-friendly: minimal footprint when
 * collapsed, full list one tap away.
 * ====================================================================== */

.chat-header .header-top {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.chat-header .header-left { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.chat-header .header-actions { display: flex; align-items: center; gap: 8px; }

.popover-region { position: relative; display: inline-block; }

/* Trigger chip: "●●● 5 here" */
.occupants-trigger {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 4px 12px 4px 4px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  color: var(--fg);
  cursor: pointer;
  font-family: inherit;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}
.occupants-trigger:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}
.occupants-trigger:hover .trigger-avatar {
  border-color: var(--accent-soft);
}

/* Stacked avatars inside the trigger (top 3 by priority: creator first). */
.trigger-stack { display: flex; }
.trigger-avatar {
  width: 20px; height: 20px;
  border-radius: 50%;
  color: white;
  font-size: 10px;
  font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center;
  margin-left: -6px;
  border: 1.5px solid var(--bg-soft);
  transition: border-color 120ms ease;
}
.trigger-avatar:first-child { margin-left: 0; }
.trigger-count { font-variant-numeric: tabular-nums; }

/* Popover container — anchored below the trigger, right-aligned to its edge. */
.occupants-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 280px;
  max-width: calc(100vw - 32px);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5), 0 2px 4px rgba(0, 0, 0, 0.3);
  padding: 14px 16px 12px;
  z-index: 50;
}
.occupants-popover::before {
  /* Pointer arrow back up to the trigger. */
  content: '';
  position: absolute;
  top: -7px; right: 28px;
  width: 12px; height: 12px;
  background: var(--bg-soft);
  border-left: 1px solid var(--border);
  border-top: 1px solid var(--border);
  transform: rotate(45deg);
}

/* Alpine enter/leave transition classes — opacity + translateY. */
.popover-enter { opacity: 0; transform: translateY(-4px); }
.popover-leave { opacity: 0; transform: translateY(-4px); }

.popover-header {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 8px;
}
.popover-title { font-size: 13px; font-weight: 600; }
.popover-close {
  background: none; border: none; cursor: pointer;
  color: var(--fg-faint);
  font-size: 16px; line-height: 1; padding: 2px 4px;
  border-radius: 4px;
}
.popover-close:hover { color: var(--fg); background: var(--bg-soft); }

.popover-summary {
  font-size: 11px;
  color: var(--fg-muted);
  padding-bottom: 10px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border-soft);
  display: flex; gap: 10px; flex-wrap: wrap;
}
.summary-chip { display: inline-flex; align-items: center; gap: 4px; }
.summary-dot { width: 6px; height: 6px; border-radius: 50%; }
.summary-dot.online { background: var(--online-color, #16a34a); }
.summary-dot.idle   { background: var(--idle-color,   #d97706); }
.summary-dot.away   { background: transparent; border: 1.5px solid var(--away-color, #d97706); }

.popover-list {
  max-height: 280px;
  overflow-y: auto;
  margin: 0 -4px;
  padding: 0 4px;
}

.popover-occupant {
  display: flex; align-items: center; gap: 10px;
  padding: 5px 4px;
  border-radius: 4px;
}
.popover-occupant.offline { opacity: 0.55; }

.popover-avatar-wrap { position: relative; display: inline-block; flex-shrink: 0; }
.popover-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  color: white;
  font-size: 12px;
  font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center;
}
.popover-presence {
  position: absolute; bottom: -1px; right: -1px;
  width: 9px; height: 9px;
  border-radius: 50%;
  border: 2px solid var(--bg-soft);
}
.popover-presence.online { background: #16a34a; }
.popover-presence.idle   { background: #d97706; }
.popover-presence.away   { background: transparent; border-color: #d97706; }
.popover-presence.offline { background: transparent; border-color: #6a6a6f; }

.popover-occupant-info { flex: 1; min-width: 0; }
.popover-occupant-name {
  font-size: 12px;
  font-weight: 500;
  display: flex; align-items: center; gap: 6px;
  line-height: 1.2;
}
.popover-occupant-status {
  font-size: 10px;
  color: var(--fg-muted);
  margin-top: 2px;
}

.creator-tag {
  font-size: 9px;
  background: var(--bg-warn);
  color: #f0d68a;
  border: 1px solid #6b541a;
  padding: 1px 5px;
  border-radius: 999px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.you-tag {
  font-size: 10px;
  color: var(--fg-faint);
  font-weight: 400;
}

/* Conflict-blocked banner: another tab holds this conversation's nickname
   (embed re-opened while the popped-out tab is live). Mirror of the SPA's
   chat-conflict-banner — keep both copies in sync (CLAUDE.md deviation 16). */
.chat-conflict-banner {
  padding: 12px 16px;
  background: #1d2233;
  border-bottom: 1px solid #33406b;
  color: #9fb0e0;
  font-size: 14px;
  text-align: center;
}
.chat-conflict-banner .muted { color: #6b7699; }

/* ============================================================
   Scrollbar styling — mirror of web/src/styles/chat.css's block
   (CLAUDE.md deviation 16: chat-chrome rules stay in sync between
   stacks). Vertical scrollbars on .chat-messages and .sender-flow
   (the app-shell pin made .sender-flow a scroll container: the
   nickname phase, and any slight overflow in the chat phase):
   thin + dark themed so the OS-default scrollbar doesn't clash
   with the dark surface.
   ============================================================ */
.chat-messages,
.sender-flow {
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.chat-messages::-webkit-scrollbar,
.sender-flow::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
.chat-messages::-webkit-scrollbar-track,
.sender-flow::-webkit-scrollbar-track {
  background: transparent;
}
.chat-messages::-webkit-scrollbar-thumb,
.sender-flow::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}
.chat-messages::-webkit-scrollbar-thumb:hover,
.sender-flow::-webkit-scrollbar-thumb:hover {
  background: var(--fg-faint);
}

/* ============================================================
   App-shell layout for sender pages (both /c /r and conference
   /g /gr — .sender-flow is the shared root class). The page is
   pinned into a flex column: header, main (chat fills it), one
   -line footer at the bottom edge. .chat-messages is the only
   scroller in the chat phase; the nickname phase scrolls inside
   .sender-flow on short screens. This replaces the old tab-mode
   layout where .chat-shell's calc(100vh - 200px) + main's 80px
   bottom padding + the footer stacked a third of dead space
   below the chat. Scoped with body:has(.sender-flow) so non-chat
   pages (auth etc.) keep normal page scrolling.
   Mirror in web/src/styles/chat.css (CLAUDE.md deviation 16).
   ============================================================ */
html:has(.sender-flow) { height: 100%; }
body:has(.sender-flow) {
  height: 100vh; /* fallback */
  height: 100dvh; /* dynamic viewport: iOS Safari URL bar */
  display: flex;
  flex-direction: column;
}
body:has(.sender-flow) .site-header,
body:has(.sender-flow) .site-footer { flex: none; }
body:has(.sender-flow) .site-footer { padding: 6px 0; }
body:has(.sender-flow) > main.container {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  width: 100%;
  padding-bottom: 0; /* the old 80px bottom padding ate the page */
}
body:has(.sender-flow) .sender-flow {
  flex: 1;
  min-height: 0;
  overflow-y: auto; /* nickname phase scrolls here on short viewports */
}
/* flex-basis takes over from the calc height; drop the 480px
   floor so small phones don't overflow the pinned page. */
body:has(.sender-flow) .chat-shell {
  flex: 1;
  height: auto;
  min-height: 0;
}
body:has(.sender-flow) .chat-messages { min-height: 0; }
/* Only relevant if viewport-fit=cover is ever added; harmless
   (0px) while the app lays out inside the safe area. */
body:has(.sender-flow) .chat-input {
  padding-bottom: max(12px, env(safe-area-inset-bottom, 0px));
}

/* Installed web clips (iOS Add to Home Screen / Android install):
   same pin, harder — no body scroll at all in standalone mode. */
@media (display-mode: standalone) {
  body:has(.sender-flow) { overflow: hidden; }
}

/* ============================================================
   Image attachments (phase 1). Mirrored in
   web/src/styles/chat.css (CLAUDE.md deviation 16:
   chat-chrome rules stay in sync between stacks). The attach-btn rule is
   SPA-only (creators upload); kept in both files per the mirror rule.
   ============================================================ */
.chat-input .attach-btn {
  flex: none; width: 40px; height: 38px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--bg-soft); color: var(--fg-muted);
  font-size: 16px; line-height: 1; cursor: pointer;
}
.chat-input .attach-btn:hover:not(:disabled) { color: var(--fg); }
.chat-input .attach-btn:disabled { opacity: .45; cursor: default; }
.bubble.image-bubble { padding: 3px; }
.img-thumb {
  display: block; max-width: 100%; width: 260px; border-radius: 10px;
  cursor: zoom-in; background: var(--bg);
}
.img-thumb.uploading { filter: blur(3px) brightness(.7); cursor: default; }
.img-thumb.failed { border: 1px solid #5a1d1d; cursor: default; }
.img-upload { position: relative; width: 260px; }
.img-upload-overlay {
  position: absolute; inset: 0; display: flex; flex-direction: column; gap: 8px;
  align-items: center; justify-content: center; color: var(--fg); font-size: 12px;
}
.img-upload-track { width: 70%; height: 4px; border-radius: 2px; background: rgba(255,255,255,.25); overflow: hidden; }
.img-upload-fill { height: 100%; background: var(--accent, #c6ff3a); transition: width .12s linear; }
.img-retry {
  margin-top: 6px; font: inherit; font-size: 12px; color: #ff8f8f;
  background: var(--bg-danger, #2a1010); border: 1px solid #5a1d1d;
  border-radius: 999px; padding: 4px 12px; cursor: pointer;
}
.img-lightbox {
  position: fixed; inset: 0; z-index: 300; background: rgba(0,0,0,.86);
  display: flex; align-items: center; justify-content: center; cursor: zoom-out;
}
.img-lightbox img { max-width: 92vw; max-height: 90vh; border-radius: 10px; }

/* Attach button (phase 2 sender uploads; appears only while a
   mod_bespoke_filegrant window is live). Mirrors the SPA's .attach-btn in
   web/src/styles/chat.css (deviation 16). */
.chat-input .attach-btn {
  flex: none; min-width: 44px; height: 38px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--bg-soft); color: var(--fg-muted);
  font-size: 16px; line-height: 1; cursor: pointer;
}
.chat-input .attach-btn:hover:not(:disabled) { color: var(--fg); }
.chat-input .attach-btn:disabled { opacity: .45; cursor: default; }

/* Non-image attachments render as a download chip (mirrored across both stacks, deviation 16). */

.file-attachment {
  display: inline-flex; align-items: center; gap: 8px;
  color: inherit; text-decoration: none; font-size: 13.5px;
  padding: 6px 4px; overflow-wrap: anywhere;
}
.file-attachment:hover { text-decoration: underline; }
