/* Messages — additions on top of main's chat UI (notification.css).
   The transcript, composer and header are main's; this file adds only:
   file cards, the upload tray / drop zone, the native conversation list
   (compact rows, presence dot, live preview / typing / unread), the header's
   live subtitle, and the Electron window fit. Tokens are main's --msg-*. */

/* ─── Header: one quiet subtitle line that turns into "typing…" ──────── */
.messages-conversation-header .messages-conversation-subtitle {
  margin: 0;
  font-size: 12px;
  line-height: 16px;
  color: var(--msg-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.messages-conversation-header .messages-conversation-subtitle.is-typing { color: var(--msg-ink); font-style: italic; }

/* ─── Files: Notion-style cards (same surface as main's audio card) ──── */
.message-file-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.message-file-card {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 300px;
  max-width: 100%;
  padding: 8px 8px 8px 8px;
  border: 1px solid rgba(var(--msg-ink-rgb), 0.09);
  border-radius: 8px;
  background: #f7f7f5;
  color: var(--msg-ink);
  text-decoration: none;
  transition: background-color 0.12s ease;
}
.message-file-card:hover { background: #efefed; }
html.dark .message-file-card { background: #232326; border-color: rgba(255, 255, 255, 0.08); }
html.dark .message-file-card:hover { background: #2a2a2e; }
.message-file-tile {
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.3px;
  color: #fff;
  background: #787774;
}
.message-file-tile--red { background: #d44c47; }
.message-file-tile--blue { background: #337ea9; }
.message-file-tile--green { background: #448361; }
.message-file-tile--amber { background: #cb912f; }
.message-file-tile--gray { background: #787774; }
.message-file-text { min-width: 0; flex: 1; display: flex; flex-direction: column; }
.message-file-name { font-size: 14px; line-height: 18px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.message-file-meta { font-size: 11px; line-height: 15px; color: var(--msg-quiet); }
.message-file-download {
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--msg-muted);
}
.message-file-card:hover .message-file-download { background: rgba(var(--msg-ink-rgb), 0.06); }
.message-file-download svg { width: 16px; height: 16px; }

/* ─── Consistency with the rest of the app ───────────────────────────── */
/* Primary actions are ink (like Accept / View & RSVP), not blue. */
.messages-send-split .messages-send-button,
.messages-send-split .messages-send-caret {
  background: var(--btn, #171717) !important;
  color: var(--btn-ink, #fbfbfa) !important;
}
.messages-send-split .messages-send-caret { border-left: 1px solid rgba(255, 255, 255, 0.16); }
html.dark .messages-send-split .messages-send-button,
html.dark .messages-send-split .messages-send-caret {
  background: #f2f1ee !important;
  color: #171717 !important;
}
html.dark .messages-send-split .messages-send-caret { border-left-color: rgba(0, 0, 0, 0.14); }
/* Unread marks are gold everywhere (Notifications, list rows, sections). */
.messages-sidebar-section-title .message-thread-unread-count,
.messages-sidebar .message-thread-unread-count {
  background: var(--gold-hi, #d6b72f) !important;
  color: #1c1910 !important;
}

/* Inbox card: neutral tile and an ink action, like the rest of the app. */
.messages-recents-badge { background: rgba(var(--msg-ink-rgb), 0.06) !important; color: var(--msg-ink) !important; }
.messages-recents-cta { color: var(--msg-ink) !important; border-color: rgba(var(--msg-ink-rgb), 0.14) !important; }
.messages-recents-cta:hover { background: rgba(var(--msg-ink-rgb), 0.05) !important; }

/* The reactions holder renders whitespace when empty — collapse it. */
.messages-stream .message-row [id^="message_reactions_"]:not(:has(.message-reactions)) { display: none; }

/* ─── Conversation list: compact native rows ─────────────────────────── */
@media (min-width: 768px) {
  .messages-index-shell .messages-sidebar { width: 288px; min-width: 288px; }
}
@media (min-width: 1440px) {
  .messages-index-shell .messages-sidebar { width: 312px; min-width: 312px; }
}
.messages-sidebar-search {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  margin: 4px 10px 0;
  padding: 0 10px;
  border-radius: 6px;
  background: rgba(var(--msg-ink-rgb), 0.05);
  color: var(--msg-muted);
}
.messages-sidebar-search svg { width: 15px; height: 15px; flex: none; }
.messages-sidebar-search input,
.messages-sidebar-search input:focus {
  flex: 1;
  min-width: 0;
  padding: 0;
  border: 0 !important;
  outline: 0;
  box-shadow: none !important;
  background: transparent !important;
  font: inherit;
  font-size: 13px;
  color: var(--msg-ink);
}
.messages-sidebar-search input::placeholder { color: var(--msg-quiet); }
/* Chips: the same outline pills as Notifications' filters. */
.messages-sidebar-chips { display: flex; gap: 6px; padding: 8px 10px 4px; overflow-x: auto; scrollbar-width: none; }
.messages-sidebar-chips::-webkit-scrollbar { display: none; }
.messages-sidebar-chip {
  flex: none;
  height: 26px;
  padding: 0 10px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  box-shadow: inset 0 0 0 1px rgba(var(--msg-ink-rgb), 0.12);
  color: var(--msg-muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.12s ease, box-shadow 0.12s ease, color 0.12s ease;
}
.messages-sidebar-chip:hover { background: rgba(var(--msg-ink-rgb), 0.04); }
.messages-sidebar-chip.is-on { box-shadow: inset 0 0 0 1.5px var(--msg-ink); color: var(--msg-ink); }
.messages-sidebar[data-filter="unread"] .messages-thread-item:not(:has(.is-unread-row)),
.messages-sidebar[data-filter="unread"] .messages-sidebar-requests,
.messages-sidebar[data-filter="channels"] section[data-sidebar-section-key-value="dms"],
.messages-sidebar[data-filter="channels"] .messages-sidebar-requests,
.messages-sidebar[data-filter="requests"] section[data-sidebar-section-key-value="dms"],
.messages-sidebar[data-filter="requests"] [data-sidebar-section-key-value="channels"],
.messages-sidebar[data-filter="requests"] .messages-channels-section { display: none !important; }

/* Rows: 32px round avatar with presence dot · name + time · preview + badge. */
.messages-thread-item:not(.messages-channel-item) .messages-thread-row > .flex {
  gap: 10px;
  padding-top: 6px;
  padding-bottom: 6px;
}
.messages-thread-item:not(.messages-channel-item) .message-thread-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 13px;
}
.messages-thread-item:not(.messages-channel-item) .message-thread-avatar--initial,
.messages-thread-item:not(.messages-channel-item) .message-thread-group-avatar {
  background: rgba(var(--msg-ink-rgb), 0.09);
  color: var(--msg-ink);
  font-weight: 600;
}
.messages-thread-item:not(.messages-channel-item) .message-thread-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.messages-thread-item .message-thread-title-text { font-size: 13.5px; }
.messages-thread-item .message-thread-preview { font-size: 12.5px; line-height: 16px; margin-top: 1px; }
.messages-thread-item .message-thread-preview.is-typing { color: var(--msg-ink); font-style: italic; font-weight: 400; }
.messages-thread-item .message-thread-unread-count {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--gold-hi, #d6b72f);
  color: #1c1910;
  font-size: 10.5px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.messages-thread-item .message-thread-time.is-unread { color: var(--gold, #b89a23); font-weight: 600; }
/* Selection: a soft fill that eases in — no jump, no colour flash. */
.messages-thread-row { transition: background-color 0.14s ease; }
.messages-thread-row.is-active,
.messages-thread-item .messages-thread-row.is-active { background: rgba(var(--msg-ink-rgb), 0.07) !important; }
.messages-thread-row.is-active .message-thread-title { color: var(--msg-ink) !important; }
.messages-thread-row.is-active .message-thread-unread-count { background: var(--gold-hi, #d6b72f); color: #1c1910; }
html.dark .messages-thread-row.is-active,
html.dark .messages-thread-item .messages-thread-row.is-active { background: rgba(255, 255, 255, 0.08) !important; }

/* A pane that's loading another conversation dims a touch instead of
   blanking — the frame swaps in place (no page reload). */
#messages_stage[busy] .messages-conversation-main { opacity: 0.7; transition: opacity 0.12s ease 0.12s; }

/* ─── Upload tray: per-file progress, cancel, retry ──────────────────── */
.message-upload-tile { position: relative; }
.message-upload-ring {
  position: absolute;
  inset: 50% auto auto 50%;
  width: 40px;
  height: 40px;
  margin: -20px 0 0 -20px;
  border-radius: 50%;
  background: conic-gradient(#fff calc(var(--p, 0) * 1%), rgba(255, 255, 255, 0.28) 0);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}
.message-upload-ring::before {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
}
.message-upload-ring .message-upload-state { position: relative; color: #fff; font-size: 10px; font-weight: 800; }
.message-upload-tile[data-upload-status="done"] .message-upload-ring,
.message-upload-tile[data-upload-status="idle"] .message-upload-ring { display: none; }
.message-upload-tile[data-upload-status="error"] .message-upload-ring { background: var(--danger, #d94f4a); }
.message-upload-tile--file .message-upload-progress {
  display: block;
  height: 3px;
  margin-top: 6px;
  border-radius: 2px;
  background: rgba(var(--msg-ink-rgb), 0.08);
  overflow: hidden;
}
.message-upload-progress-bar { display: block; height: 100%; background: var(--ink, #1f1f1f); transition: width 0.15s ease-out; }
.message-upload-tile[data-upload-status="done"] .message-upload-progress { visibility: hidden; }
.message-upload-tile[data-upload-status="error"] .message-upload-progress-bar { background: var(--danger, #d94f4a); }
.message-upload-tile[data-upload-status="error"] .message-upload-state { color: var(--danger, #d94f4a); }
.message-upload-retry {
  position: absolute;
  left: 50%;
  bottom: 6px;
  transform: translateX(-50%);
  z-index: 3;
  height: 22px;
  padding: 0 9px;
  border: 0;
  border-radius: 999px;
  background: var(--btn, #171717);
  color: var(--btn-ink, #fbfbfa);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}
.message-upload-retry[hidden] { display: none; }
.message-upload-notice {
  margin: 0 4px 6px;
  padding: 6px 10px;
  border-radius: 10px;
  background: var(--danger-fill, #f8e4e3);
  color: var(--danger, #d94f4a);
  font-size: 12.5px;
  font-weight: 600;
}
.message-upload-notice[hidden] { display: none; }



/* Drop anywhere in the conversation. */
.messages-conversation-shell.is-file-dragging,
.mobile-message-container.is-file-dragging { position: relative; }
.messages-conversation-shell.is-file-dragging::after,
.mobile-message-container.is-file-dragging::after {
  content: "Drop files to send";
  position: absolute;
  inset: 8px;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 18px;
  border: 2px dashed rgba(var(--msg-ink-rgb), 0.35);
  background: color-mix(in srgb, var(--surface, #fff) 82%, transparent);
  color: var(--ink, #1f1f1f);
  font-size: 15px;
  font-weight: 700;
  pointer-events: none;
}

/* Phones: inside an open conversation the header owns the top edge (back
   arrow, name, actions) — the nav chevron would sit on the name. It stays on
   the list, one tap back. */
@media (max-width: 767px) {
  .messages-index-shell:has(.messages-index-frame--thread) .event-nav-peek { display: none !important; }
}

/* Two panes: centre the nav chevron over the conversation, not the window,
   and keep the name block to the left half of the header so the two can
   never meet (long names truncate first). */
@media (min-width: 768px) {
  body:not(.desktop-app) .messages-index-shell:has(.messages-index-frame--thread) .event-nav-peek {
    left: calc(288px + (100vw - 288px) / 2);
  }
  .messages-index-frame--thread .messages-conversation-header > :first-child { max-width: calc(50% - 36px); }
}
@media (min-width: 1440px) {
  body:not(.desktop-app) .messages-index-shell:has(.messages-index-frame--thread) .event-nav-peek {
    left: calc(312px + (100vw - 312px) / 2);
  }
}

/* ─── Electron: fit the window under the title bar ───────────────────── */
/* The desktop app's body already starts below the title bar (the nav island
   folds into it), so a 100dvh shell ran off the bottom of the window and
   hid the composer. Same full-bleed panes as every other page. */
@media (min-width: 768px) {
  body.desktop-app .messages-index-shell:not(.messages-index-shell--popout) {
    height: calc(100dvh - var(--desktop-content-offset, 53px));
    min-height: calc(100dvh - var(--desktop-content-offset, 53px));
    max-height: calc(100dvh - var(--desktop-content-offset, 53px));
  }
}

/* ── Message keyword search (task 1429743114) ──
   Hits from MessagesController#search sit between the search box and the
   name-filtered conversation list, capped so the list stays reachable. */
.messages-sidebar-search-panel[hidden] { display: none !important; }
.messages-sidebar-search-panel {
  flex: 0 1 auto;
  max-height: 55%;
  overflow-y: auto;
  border-bottom: 1px solid rgba(var(--msg-ink-rgb), 0.08);
}
.messages-search-results { padding: 6px 0 8px; }
.messages-search-results__head {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 14px 4px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--msg-muted);
}
.messages-search-results__count {
  padding: 0 6px; border-radius: 999px;
  background: rgba(var(--msg-ink-rgb), 0.06);
  font-variant-numeric: tabular-nums;
}
.messages-search-results__empty { padding: 6px 14px 10px; font-size: 13px; color: var(--msg-muted); }
.messages-search-results__list { margin: 0; padding: 0 6px; list-style: none; }
.messages-search-hit {
  display: flex; flex-direction: column; gap: 2px;
  padding: 7px 8px; border-radius: 6px;
  color: var(--msg-ink); text-decoration: none;
}
.messages-search-hit:hover, .messages-search-hit:focus-visible { background: rgba(var(--msg-ink-rgb), 0.06); outline: none; }
.messages-search-hit__meta { display: flex; align-items: baseline; gap: 8px; min-width: 0; font-size: 12px; }
.messages-search-hit__thread { flex: 1; min-width: 0; font-weight: 600; }
.messages-search-hit__meta time { flex: none; color: var(--msg-muted); font-size: 11px; }
.messages-search-hit__text {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  font-size: 13px; line-height: 1.35; color: var(--msg-ink-soft); overflow-wrap: anywhere;
}
.messages-search-hit__text strong { font-weight: 600; color: var(--msg-ink); }
.messages-search-hit mark { background: rgba(214, 183, 47, 0.35); color: inherit; border-radius: 2px; padding: 0 1px; }
html.dark .messages-search-hit mark { background: rgba(214, 183, 47, 0.32); }

/* The message a search hit opened, briefly picked out in the transcript. */
.message-search-focus { animation: message-search-focus 2.4s ease-out 1; border-radius: 8px; }
@keyframes message-search-focus {
  0%, 35% { background: rgba(214, 183, 47, 0.28); }
  100% { background: transparent; }
}

/* ═══════════════════════════════════════════════════════════════════════
   Modern CSS patterns
   Same look as before; these replace JS/server state with CSS where CSS can
   see the state, and smooth a few state changes. Motion is opt-in under
   prefers-reduced-motion: no-preference.
   ═══════════════════════════════════════════════════════════════════════ */

/* ─── :has() — unread dot on a collapsed section ─────────────────────────
   Collapsing Channels hid its unread rows with nothing left to say so (the
   DM section sums a count in JS; Channels has no badge). The section can be
   asked directly: collapsed body + an unread row inside → a gold dot on the
   toggle. No server condition, no JS — and it follows live row updates. */
.messages-sidebar-section:has(> .messages-sidebar-section-body[hidden] .is-unread-row) .messages-sidebar-section-toggle::after {
  --size: 7px;
  content: "";
  flex: none;
  inline-size: var(--size);
  block-size: var(--size);
  margin-inline-start: 2px;
  border-radius: var(--size);
  background: var(--gold-hi, #d6b72f);
}

/* ─── Touch: tap-to-open row actions at any width ────────────────────────
   Phones already open a row's toolbar with a tap (.is-actions-open); a
   touch-only tablet in a wide layout relied on sticky :hover instead. Same
   look as the phone state, now driven by the input device, not the width. */
@media (any-hover: none) and (pointer: coarse) {
  .message-row.is-actions-open { background: rgba(var(--msg-ink-rgb), 0.04); }
  .message-row.is-actions-open .message-row-actions {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0);
  }
}

/* ─── Smooth state changes ───────────────────────────────────────────────
   Sending: the optimistic row eases in to its pending opacity (instead of a
   keyframe that ran to full opacity and then dropped back to pending), and
   the saved row that replaces it starts from that same opacity and
   brightens — no second slide-in, no flash. message_form_controller /
   messages_controller mark the replacement .message-row--confirmed. */
.message-row--pending.animate-slide-in-bottom,
.message-row--confirmed.animate-slide-in-bottom { animation: none; }
@media (prefers-reduced-motion: no-preference) {
  .message-row--pending { transition: opacity 0.22s ease-out, translate 0.22s ease-out, background-color 0.15s ease; }
  .message-row--confirmed { transition: opacity 0.24s ease-out, background-color 0.15s ease; }
  .message-row--confirmed.message-row--jump-highlight { transition: background-color 0.45s ease; }
  @starting-style {
    .message-row--pending { opacity: 0; translate: 0 8px; }
    .message-row--confirmed { opacity: var(--message-pending-opacity, 0.62); }
  }

  /* Menus and popovers fade in as they open rather than popping. Opacity
     only where a controller measures the panel on open (more-menu flip,
     composer emoji placement) so no measurement sees a moved box. Entry
     only: the schedule menu's composer re-clips the instant it closes, so a
     fade-out (transition-behavior: allow-discrete) would be cut off. */
  .message-more-menu[open] .message-more-menu-panel,
  .messages-composer-emoji-popover,
  .messages-schedule-popover { transition: opacity 0.14s ease-out, translate 0.14s ease-out; }
  @starting-style {
    .message-more-menu[open] .message-more-menu-panel,
    .messages-composer-emoji-popover { opacity: 0; }
    .messages-schedule-popover { opacity: 0; translate: 0 4px; }
  }
}
@media (prefers-reduced-motion: reduce) {
  /* Live messages slid in regardless of the setting. */
  .animate-slide-in-bottom { animation: none; }
}

/* ─── File viewer: in-app preview for message files (file_viewer_controller) ─
   Notion gray/ink, no accent colour. Desktop: centred panel; phones: a
   full-screen sheet. */
.file-viewer[hidden], .file-viewer [hidden] { display: none !important; }
body.file-viewer-open { overflow: hidden; }
.file-viewer {
  position: fixed;
  inset: 0;
  z-index: 140;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  color: #37352f;
}
.file-viewer-backdrop { position: absolute; inset: 0; background: rgba(15, 15, 15, 0.55); }
.file-viewer-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(1100px, 100%);
  height: min(860px, 100%);
  background: #ffffff;
  border: 1px solid rgba(55, 53, 47, 0.09);
  border-radius: 10px;
  box-shadow: 0 16px 48px rgba(15, 15, 15, 0.22);
  overflow: hidden;
}
.file-viewer-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px 10px 16px;
  border-bottom: 1px solid rgba(55, 53, 47, 0.09);
}
.file-viewer-heading { min-width: 0; flex: 1; }
.file-viewer-name {
  margin: 0;
  font-size: 14px;
  line-height: 20px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.file-viewer-meta {
  margin: 0;
  font-size: 12px;
  line-height: 16px;
  color: #787774;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.file-viewer-actions { display: flex; align-items: center; gap: 4px; flex: none; }
.file-viewer-counter { font-size: 12px; color: #9b9a97; padding: 0 6px; font-variant-numeric: tabular-nums; }
.file-viewer-icon,
.file-viewer-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #37352f;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
}
.file-viewer-icon { width: 32px; }
.file-viewer-button { padding: 0 10px; border: 1px solid rgba(55, 53, 47, 0.16); }
.file-viewer-icon svg, .file-viewer-button svg { width: 16px; height: 16px; flex: none; }
.file-viewer-icon:hover, .file-viewer-button:hover { background: rgba(55, 53, 47, 0.06); }
.file-viewer-icon:disabled { opacity: 0.35; cursor: default; background: transparent; }
.file-viewer-icon:focus-visible, .file-viewer-button:focus-visible, .file-viewer-text:focus-visible {
  outline: 2px solid rgba(55, 53, 47, 0.45);
  outline-offset: 1px;
}
.file-viewer-button--solid { background: #37352f; border-color: #37352f; color: #ffffff; height: 34px; padding: 0 14px; }
.file-viewer-button--solid:hover { background: #2f2d28; }
.file-viewer-body {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #f7f7f5;
  overflow: auto;
}
.file-viewer-frame { width: 100%; height: 100%; border: 0; background: #ffffff; }
.file-viewer-image { max-width: 100%; max-height: 100%; object-fit: contain; cursor: zoom-in; }
.file-viewer.is-zoomed .file-viewer-body { align-items: flex-start; justify-content: flex-start; }
.file-viewer.is-zoomed .file-viewer-image { max-width: none; max-height: none; cursor: zoom-out; }
.file-viewer-video { max-width: 100%; max-height: 100%; background: #0f0f0f; }
.file-viewer-audio { width: min(480px, calc(100% - 32px)); }
.file-viewer-text {
  align-self: stretch;
  flex: 1;
  margin: 0;
  padding: 16px 20px;
  background: #ffffff;
  color: #37352f;
  font: 13px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre-wrap;
  word-break: break-word;
  overflow: auto;
}
.file-viewer-truncated {
  align-self: stretch;
  margin: 0;
  padding: 8px 20px;
  font-size: 12px;
  color: #787774;
  background: #f7f7f5;
  border-bottom: 1px solid rgba(55, 53, 47, 0.09);
}
.file-viewer-loading { margin: 0; font-size: 13px; color: #9b9a97; }
.file-viewer-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  max-width: 360px;
  padding: 28px 24px;
  text-align: center;
  background: #ffffff;
  border: 1px solid rgba(55, 53, 47, 0.09);
  border-radius: 10px;
}
.file-viewer-card-tile {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  margin-bottom: 6px;
  border-radius: 8px;
  background: #787774;
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
}
.file-viewer-card-name { margin: 0; font-size: 14px; font-weight: 600; word-break: break-word; }
.file-viewer-card-meta { margin: 0 0 10px; font-size: 12px; color: #787774; }
.file-viewer-card.is-notice .file-viewer-card-meta { color: #37352f; }

html.dark .file-viewer { color: #e6e6e4; }
html.dark .file-viewer-panel { background: #191919; border-color: rgba(255, 255, 255, 0.08); }
html.dark .file-viewer-header, html.dark .file-viewer-truncated { border-color: rgba(255, 255, 255, 0.08); }
html.dark .file-viewer-body, html.dark .file-viewer-truncated { background: #202020; }
html.dark .file-viewer-icon, html.dark .file-viewer-button { color: #e6e6e4; }
html.dark .file-viewer-button { border-color: rgba(255, 255, 255, 0.14); }
html.dark .file-viewer-icon:hover, html.dark .file-viewer-button:hover { background: rgba(255, 255, 255, 0.06); }
html.dark .file-viewer-button--solid { background: #e6e6e4; border-color: #e6e6e4; color: #191919; }
html.dark .file-viewer-text, html.dark .file-viewer-card { background: #191919; color: #e6e6e4; border-color: rgba(255, 255, 255, 0.08); }
html.dark .file-viewer-card.is-notice .file-viewer-card-meta { color: #e6e6e4; }

@media (max-width: 640px) {
  .file-viewer { padding: 0; align-items: stretch; }
  .file-viewer-panel {
    width: 100%;
    height: 100%;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .file-viewer-header { flex-wrap: wrap; padding: 8px 8px 8px 14px; row-gap: 6px; }
  .file-viewer-actions { width: 100%; justify-content: flex-end; }
  .file-viewer-counter { margin-right: auto; padding-left: 0; }
}

/* ═══════════════════════════════════════════════════════════════════════
   Conversation pane + chat bubbles
   ═══════════════════════════════════════════════════════════════════════ */

/* ─── The conversation pane: the scroller and its jump-to-latest button ──
   The button used to be appended to the scroller's parent — the whole
   column, live strip and composer included — so its `bottom: 12px` put it
   on the composer and the send button. The pane wraps only the scroller,
   and the button is positioned against it, so it floats at the bottom of
   the transcript and the composer below can never be under it. */
.messages-stream-pane {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.messages-stream-pane > .messages-stream { flex: 1 1 auto; min-height: 0; }
.messages-stream-pane > .messages-jump-latest {
  right: 16px;
  bottom: 12px;
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  justify-content: center;
  background: var(--msg-surface);
  color: var(--msg-ink);
  box-shadow: 0 0 0 1px rgba(var(--msg-ink-rgb), 0.1), 0 4px 14px rgba(var(--msg-shadow-rgb), 0.12);
}
.messages-stream-pane > .messages-jump-latest:hover { background: var(--msg-well); }
.messages-stream-pane > .messages-jump-latest[hidden] { display: none; }
.messages-stream-pane .messages-jump-latest__count {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--gold-hi, #d6b72f);
  color: #1c1910;
  font-size: 10.5px;
  line-height: 18px;
  text-align: center;
}
@media (max-width: 767px) {
  .messages-stream-pane > .messages-jump-latest { right: 12px; bottom: 10px; }
}

/* ─── Bubbles: theirs left in soft gray, yours right in ink ──────────── */
.messages-stream .message-row.message-row--bubble {
  --bubble-radius: 18px;
  --bubble-tight: 5px;
  --bubble-theirs-bg: #f1f1ef;
  --bubble-theirs-ink: #37352f;
  --bubble-mine-bg: #37352f;
  --bubble-mine-ink: #fbfbfa;
  --bubble-mine-soft: rgba(251, 251, 250, 0.16);
  --bubble-mine-quiet: rgba(251, 251, 250, 0.66);
  --bubble-avatar: 30px;
  padding: 1px 16px !important;
}
html.dark .messages-stream .message-row.message-row--bubble {
  --bubble-theirs-bg: #2c2c30;
  --bubble-theirs-ink: rgba(255, 255, 255, 0.88);
  --bubble-mine-bg: #e9e8e4;
  --bubble-mine-ink: #1c1c1e;
  --bubble-mine-soft: rgba(28, 28, 30, 0.08);
  --bubble-mine-quiet: rgba(28, 28, 30, 0.6);
}
/* A new run starts with breathing room; the run's last row closes it. */
.messages-stream .message-row.message-row--bubble:not(.is-grouped) { padding-top: 10px !important; }
.messages-stream .message-row.message-row--bubble.is-group-end { padding-bottom: 4px !important; }
/* Bubbles carry the shape; the row-wide hover wash would box them in. The
   jump / search highlights still paint (they're !important / animated). */
.messages-stream .message-row--bubble:hover,
.messages-stream .message-row--bubble:focus-within { background: transparent; }

.message-row--bubble .message-row-layout {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  min-width: 0;
}

/* The avatar leads the header row: pinned to the top of the run, never
   stretched to the row's height. A stretched <button> centres its content,
   which is what used to float the avatar to the middle of a long message. */
.message-row--bubble .message-row-avatar {
  flex: none;
  align-self: flex-start;
  width: var(--bubble-avatar);
  height: var(--bubble-avatar);
  margin: 0;
  border-radius: 50%;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(var(--msg-ink-rgb), 0.07);
}
.message-row--bubble .message-row-avatar-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}
.message-row--bubble .message-row-avatar-initial {
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  color: var(--msg-muted);
}

.message-row--bubble .message-row-body {
  flex: 1 1 auto;
  min-width: 0;
  max-width: min(76%, 620px);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}
.message-row--bubble .message-bubble,
.message-row--bubble .message-row-header { max-width: 100%; }
@media (max-width: 767px) {
  .message-row--bubble .message-row-body { max-width: 84%; }
  .messages-stream .message-row.message-row--bubble { padding-left: 12px !important; padding-right: 12px !important; }
}

/* Header: @handle · time, aligned with the avatar's top edge. */
.message-row--bubble .message-row-header {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 2px 6px;
  min-width: 0;
  margin: 0 0 3px;
  padding: 0 4px;
  line-height: 18px;
}
.message-row--bubble .message-row-author {
  font-size: 13px;
  font-weight: 600;
  color: var(--msg-ink-soft);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.message-row--bubble .message-row-time { font-size: 11px; color: var(--msg-quiet); }

/* The bubble itself. */
.message-row--bubble .message-bubble {
  padding: 7px 12px;
  border-radius: var(--bubble-radius);
  background: var(--bubble-theirs-bg);
  color: var(--bubble-theirs-ink);
  font-size: 14.5px;
  line-height: 1.42;
  overflow-wrap: anywhere;
}
.message-row--bubble .message-bubble :where(h1, h2, h3, h4, h5, h6) { color: inherit; }
/* Runs: the corners between bubbles of one run tighten on the sender's side. */
.message-row--bubble.is-theirs:not(.is-group-end) .message-bubble { border-bottom-left-radius: var(--bubble-tight); }
.message-row--bubble.is-theirs.is-grouped .message-bubble { border-top-left-radius: var(--bubble-tight); }
.message-row--bubble.is-mine:not(.is-group-end) .message-bubble { border-bottom-right-radius: var(--bubble-tight); }
.message-row--bubble.is-mine.is-grouped .message-bubble { border-top-right-radius: var(--bubble-tight); }

/* A continuing row has no header and keeps the avatar's column empty, so
   its bubble lines up under the first one. */
.message-row--bubble.is-grouped .message-row-header { display: none; }
.message-row--bubble.is-grouped .message-row-avatar { visibility: hidden; height: 0; }

/* Yours: right-aligned, ink, no avatar, the time as the only header. */
.message-row--bubble.is-mine .message-row-layout { flex-direction: row-reverse; }
.message-row--bubble.is-mine .message-row-avatar { display: none; }
.message-row--bubble.is-mine .message-row-body { align-items: flex-end; }
.message-row--bubble.is-mine .message-row-header { justify-content: flex-end; }
.message-row--bubble.is-mine .message-row-author,
.message-row--bubble.is-mine .message-author-status {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}
.message-row--bubble.is-mine .message-bubble {
  background: var(--bubble-mine-bg);
  color: var(--bubble-mine-ink);
}
.message-row--bubble.is-mine .message-bubble .trix-content a,
.message-row--bubble.is-mine .message-bubble a { color: inherit; }
.message-row--bubble.is-mine .message-bubble .message-mention {
  color: inherit;
  background: var(--bubble-mine-soft);
}
.message-row--bubble.is-mine .message-bubble :where(pre, code) {
  background: var(--bubble-mine-soft);
  color: inherit;
  border-color: transparent;
}
.message-row--bubble.is-mine .message-bubble blockquote { border-color: var(--bubble-mine-quiet); color: inherit; }
.message-row--bubble.is-mine .message-reactions { justify-content: flex-end; }
.message-row--bubble.is-mine .messages-photo-grid { justify-content: flex-end; }
.message-row--bubble.is-mine .message-file-list { justify-content: flex-end; }
/* Toolbar opens on the empty side of the row. */
.message-row--bubble.is-mine .message-row-actions { right: auto; left: 10px; }

/* ─── Attachments in the bubble style ────────────────────────────────── */
.message-row--bubble .message-row-body > .mt-3 { margin-top: 4px; }
.message-row--bubble .message-bubble + .mt-3,
.message-row--bubble .message-bubble + .message-file-list { margin-top: 4px; }
.message-row--bubble .message-reply-quote { margin-bottom: 4px; border-radius: 12px; }
.message-row--bubble .messages-photo-grid { gap: 4px; }
.message-row--bubble .messages-photo-card,
.message-row--bubble .messages-video-player { border-radius: 14px; }
.message-row--bubble .message-file-list { margin-top: 4px; gap: 4px; }
.message-row--bubble .message-file-card {
  width: 280px;
  border: 0;
  border-radius: 14px;
  padding: 8px 10px 8px 8px;
  background: var(--bubble-theirs-bg);
  color: var(--bubble-theirs-ink);
}
.message-row--bubble .message-file-card:hover { background: color-mix(in srgb, var(--bubble-theirs-bg) 92%, #000); }
html.dark .message-row--bubble .message-file-card { background: var(--bubble-theirs-bg); }
html.dark .message-row--bubble .message-file-card:hover { background: color-mix(in srgb, var(--bubble-theirs-bg) 90%, #fff); }
.message-row--bubble.is-mine .message-file-card,
html.dark .message-row--bubble.is-mine .message-file-card {
  background: var(--bubble-mine-bg);
  color: var(--bubble-mine-ink);
}
.message-row--bubble.is-mine .message-file-card:hover,
html.dark .message-row--bubble.is-mine .message-file-card:hover { background: color-mix(in srgb, var(--bubble-mine-bg) 88%, var(--bubble-mine-ink)); }
.message-row--bubble.is-mine .message-file-meta,
.message-row--bubble.is-mine .message-file-download { color: var(--bubble-mine-quiet); }
.message-row--bubble.is-mine .message-file-card:hover .message-file-download { background: var(--bubble-mine-soft); }
.message-row--bubble .message-audio-card { border: 0 !important; border-radius: 14px !important; background: var(--bubble-theirs-bg) !important; }
.message-row--bubble .message-row-reactions { margin-top: 4px; }
.message-row--bubble .message-row-reactions:empty { display: none; }
.message-row--bubble .message-row-failed { justify-content: flex-end; }
@media (max-width: 767px) {
  .message-row--bubble .message-file-card { width: 100%; max-width: 280px; }
  .message-row--bubble .messages-photo-grid { --message-media-tile: 104px; }
}
