/* ════════════════════════════════════════════════════════════════
   Firm Messenger — css/messenger.css
   Two-pane layout (channel list + thread) collapsing to single-pane
   on mobile via `.thread-open` toggle.
   ════════════════════════════════════════════════════════════════ */

#module-messenger { padding: 0; }

.msg-wrap {
  display: grid;
  grid-template-columns: 320px 1fr;
  height: calc(100vh - 60px);
  background: var(--cream, #FAFAF7);
  border-top: 1px solid var(--border, #E8E4D8);
}

.msg-left {
  border-right: 1px solid var(--border, #E8E4D8);
  background: #fff;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.msg-left-header {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border, #E8E4D8);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.msg-left-title {
  font-family: var(--font-serif, 'EB Garamond', serif);
  font-size: 1.15rem;
  font-weight: 500;
}

/* Search bar — replaces the old tab strip */
.msg-search-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.85rem;
  border-bottom: 1px solid var(--border, #E8E4D8);
  background: #FBFAF6;
  position: relative;
}
.msg-search-icon {
  color: var(--text-muted, #8A8A7A);
  flex-shrink: 0;
}
.msg-search-input {
  flex: 1;
  border: none;
  background: transparent;
  font-family: var(--font-sans, 'DM Sans', system-ui, sans-serif);
  font-size: 0.82rem;
  color: var(--text, #2A2A24);
  outline: none;
  padding: 0.15rem 0;
}
.msg-search-input::placeholder { color: var(--text-muted, #A8A492); }
.msg-search-clear {
  border: none;
  background: none;
  color: var(--text-muted, #8A8A7A);
  cursor: pointer;
  padding: 0.15rem;
  border-radius: 3px;
  display: inline-flex;
  align-items: center;
}
.msg-search-clear:hover { color: var(--text, #2A2A24); background: #F2EFE5; }

/* Section label between Conversations and People in the unified list */
.msg-section-label {
  padding: 0.6rem 0.95rem 0.3rem;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-muted, #8A8A7A);
  background: #FBFAF6;
  border-top: 1px solid #F2EFE5;
}
.msg-section-label:first-child { border-top: none; }

.msg-channel-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.2rem 0;
}

.msg-channel-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid #F2EFE5;
  cursor: pointer;
  transition: background 0.1s;
}

.msg-channel-row:hover { background: #FBFAF4; }
.msg-channel-row.active { background: #FAF4E0; border-left: 3px solid var(--gold, #C9A84C); padding-left: calc(0.85rem - 3px); }
.msg-channel-row-person:hover { background: #F8F4E8; }

/* Message-body search hits — rendered under the "Messages" section
   of the left list when the user is searching. Slightly more compact
   row than a regular channel + highlighted match in the snippet. */
.msg-channel-row-message-hit {
  padding-top: 0.55rem;
  padding-bottom: 0.55rem;
  gap: 0.55rem;
}
.msg-channel-row-message-hit .msg-channel-row-preview { white-space: normal; line-height: 1.4; }
.msg-search-mark {
  background: rgba(201, 168, 76, 0.32);
  color: var(--text, #2A2A24);
  padding: 0 0.1rem;
  border-radius: 2px;
  font-weight: 500;
}

/* Avatars used in the left list and (smaller) elsewhere */
.msg-avatar {
  width: 40px;
  height: 40px;
  border-radius: 9px;
  background: #EFECE4;
  color: var(--text, #2A2A24);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  object-fit: cover;
  flex-shrink: 0;
}
.msg-avatar.msg-avatar-matter {
  background: #FAF4E0;
  color: #8A6628;
  border: 1px solid #E8D9A6;
}
.msg-avatar.msg-avatar-lex {
  background: #fff;
  color: #8A6628;
  border: 1px solid var(--border, #E8E4D8);
  box-shadow: inset 2px 0 0 var(--gold, #C9A84C);
  border-radius: 9px;
}
img.msg-avatar { object-fit: cover; }

/* Pill chips in the row name — distinguishes matter rows from DMs */
.msg-row-pill {
  display: inline-block;
  font-size: 0.58rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.08rem 0.4rem;
  border-radius: 999px;
  margin-left: 0.35rem;
  vertical-align: middle;
}
.msg-row-pill-matter {
  background: #FAF4E0;
  color: #8A6628;
  border: 1px solid #E8D9A6;
}
.msg-row-pill-lex {
  background: rgba(201, 168, 76, 0.16);
  color: #7A5C1E;
  border: 1px solid #E8D9A6;
}

.msg-channel-row-main {
  flex: 1;
  min-width: 0;
}

.msg-channel-row-name {
  font-size: 0.86rem;
  font-weight: 500;
  color: var(--text, #2A2A24);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.msg-channel-row-preview {
  font-size: 0.74rem;
  color: var(--text-muted, #6B6B5E);
  margin-top: 0.15rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.msg-channel-row-side {
  text-align: right;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.18rem;
}

.msg-channel-row-time {
  font-size: 0.66rem;
  color: var(--text-muted, #8A8A7A);
}

.msg-channel-unread {
  background: var(--gold, #C9A84C);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 600;
  padding: 0.08rem 0.45rem;
  border-radius: 999px;
  min-width: 1.1rem;
  text-align: center;
}

.msg-channel-urgent {
  background: #B23A3A;
  color: #fff;
  font-size: 0.6rem;
  padding: 0.08rem 0.35rem;
  border-radius: 3px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.msg-channel-ack {
  background: #2E6B8E;
  color: #fff;
  font-size: 0.6rem;
  padding: 0.08rem 0.35rem;
  border-radius: 3px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Inbox */
.msg-inbox-actions {
  padding: 0.4rem 0.85rem;
  border-bottom: 1px solid var(--border, #E8E4D8);
  display: flex;
  justify-content: flex-end;
}
.msg-inbox-icon {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #FBFAF6;
  border: 1px solid var(--border, #E8E4D8);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted, #6B6B5E);
}
.msg-inbox-icon[data-kind="mention"]        { background: #FAF4E0; color: #B08C30; border-color: #E8D9A6; }
.msg-inbox-icon[data-kind="urgent_message"] { background: #FFE8E8; color: #B23A3A; border-color: #F2C5C5; }
.msg-inbox-icon[data-kind="ack_required"]   { background: #E8F1F8; color: #2E6B8E; border-color: #BFD8E6; }
.msg-inbox-icon[data-kind="announcement"]   { background: #F0F7EE; color: #4A6B3A; border-color: #C7E0BD; }

.msg-tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--gold, #C9A84C);
  color: #fff;
  font-size: 0.6rem;
  font-weight: 700;
  padding: 0.05rem 0.32rem;
  border-radius: 999px;
  margin-left: 0.3rem;
  min-width: 1rem;
}

.msg-channel-ack-done {
  background: #4A6B3A;
  color: #fff;
  font-size: 0.6rem;
  padding: 0.08rem 0.35rem;
  border-radius: 3px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.msg-channel-row.unread .msg-channel-row-name { font-weight: 600; }
.msg-channel-unread-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  background: var(--gold, #C9A84C);
  border-radius: 50%;
  vertical-align: middle;
  margin-left: 0.25rem;
}

.msg-channel-kind {
  font-size: 0.58rem;
  font-weight: 500;
  color: var(--gold, #C9A84C);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-left: 0.3rem;
  vertical-align: middle;
}

/* Lex DM — pinned, distinct chrome */
.msg-channel-row-lex {
  background: linear-gradient(180deg, #FFFBF0 0%, #FBFAF4 100%);
  border-left: 3px solid var(--gold, #C9A84C);
  padding-left: calc(0.85rem - 3px);
}
.msg-channel-row-lex:hover { background: #FAF4E0; }
.msg-channel-row-lex.active { background: #FAF4E0; }
.msg-channel-row-lex .msg-channel-row-name { font-weight: 600; }
.msg-channel-kind-lex {
  color: #7A5C1E;
  background: rgba(201, 168, 76, 0.16);
  border-radius: 3px;
  padding: 1px 5px;
}

/* Composer disabled (Lex DM is one-way) */
.msg-composer-disabled {
  opacity: 0.55;
  pointer-events: none;
  position: relative;
}
.msg-composer-disabled::before {
  content: "Lex sends updates here. Replies are not delivered.";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(255, 251, 240, 0.95);
  color: #6B6B5E;
  font-size: 0.78rem;
  padding: 0.4rem 0.8rem;
  border: 1px solid var(--border, #E8E4D8);
  border-radius: 6px;
  pointer-events: none;
  z-index: 2;
  white-space: nowrap;
}

.msg-empty {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-muted);
}
.msg-empty-text { font-size: 0.85rem; margin-bottom: 0.8rem; color: var(--text-muted); }

/* ── Right pane (thread) ── */
.msg-right {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--cream, #FAFAF7);
}

.msg-thread-header {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--border, #E8E4D8);
  background: #fff;
}

.msg-mobile-close { display: none; }

/* Avatar wrapper used for Lex DM (non-interactive). */
.msg-thread-avatar-wrap { display: inline-flex; flex-shrink: 0; }

/* Whole left header (avatar + name + subtitle) is a single click target
   that opens the channel-info modal. Lawyer's main affordance for "who
   am I talking to / what's this matter about". */
.msg-thread-title-btn {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  background: none;
  border: none;
  padding: 0.15rem 0.25rem;
  margin: -0.15rem -0.25rem;
  border-radius: 6px;
  cursor: pointer;
  flex: 1;
  min-width: 0;
  text-align: left;
}
.msg-thread-title-btn:hover { background: #FAF4E0; }
.msg-thread-title-btn:focus-visible { outline: 2px solid var(--gold, #C9A84C); outline-offset: 2px; }
.msg-thread-title-btn .msg-thread-header-main { flex: 1; min-width: 0; }

/* Composer hidden until a channel is open — fixes the orphan input bar
   the user reported showing even with no conversation selected. */
.msg-composer.hidden { display: none; }

.msg-thread-header-main { flex: 1; min-width: 0; }
.msg-thread-name {
  font-family: var(--font-serif, 'EB Garamond', serif);
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--text, #2A2A24);
}
.msg-thread-sub {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 0.1rem;
}

.msg-thread-header-actions {
  display: flex;
  gap: 0.4rem;
}

.msg-thread-body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
}

.msg-thread-empty {
  margin: auto;
  text-align: center;
  color: var(--text-muted);
}
.msg-thread-empty-title { font-family: var(--font-serif); font-size: 1.4rem; margin-bottom: 0.3rem; }
.msg-thread-empty-sub { font-size: 0.85rem; }

.msg-day {
  display: flex;
  flex-direction: column;
  margin-bottom: 0.5rem;
}

.msg-day-label {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  margin: 1.1rem 0 0.5rem;
  color: var(--text-muted, #7a7264);
}
.msg-day-label::before,
.msg-day-label::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border, #E8E4D8);
}
.msg-day-label span {
  display: inline-block;
  padding: 0.18rem 0.65rem;
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: #fff;
  border: 1px solid var(--border, #E8E4D8);
  border-radius: 999px;
  color: var(--text-muted, #7a7264);
  white-space: nowrap;
}
.msg-thread-flat .msg-day-label { margin: 0.85rem 0 0.3rem; }

.msg-row {
  display: flex;
  margin-bottom: 0.45rem;
}

.msg-row.mine { justify-content: flex-end; }

.msg-bubble {
  max-width: 65%;
  background: #fff;
  border: 1px solid var(--border, #E8E4D8);
  border-radius: 12px;
  padding: 0.55rem 0.8rem 0.4rem;
  font-size: 0.86rem;
  line-height: 1.4;
  word-wrap: break-word;
  color: var(--text, #2A2A24);
}

.msg-row.mine .msg-bubble {
  background: #FAF4E0;
  border-color: #E8D9A6;
}

/* Reactions */
.msg-reactions {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
  margin-top: 0.3rem;
}
.msg-react-chip {
  border: 1px solid var(--border, #E8E4D8);
  background: #FBFAF6;
  border-radius: 999px;
  padding: 0.1rem 0.5rem;
  font-size: 0.74rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
}
.msg-react-chip.mine { background: #FAF4E0; border-color: var(--gold, #C9A84C); }
.msg-react-chip:hover { background: #F2EFE5; }

.msg-react-picker {
  position: fixed;
  z-index: 200;
  background: #fff;
  border: 1px solid var(--border, #E8E4D8);
  border-radius: 6px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.1);
  padding: 0.3rem;
  display: flex;
  gap: 0.15rem;
}
.msg-react-btn {
  border: none;
  background: none;
  font-size: 1.15rem;
  padding: 0.2rem 0.35rem;
  cursor: pointer;
  border-radius: 4px;
  line-height: 1;
}
.msg-react-btn:hover { background: #FAF4E0; }

/* Voice */
.msg-voice-bar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.4rem 0.65rem;
  margin-bottom: 0.5rem;
  background: #FAF4E0;
  border: 1px solid #E8D9A6;
  border-radius: 6px;
  font-size: 0.82rem;
}
.msg-voice-dot {
  width: 9px;
  height: 9px;
  background: #B23A3A;
  border-radius: 50%;
  animation: msg-voice-pulse 1s ease-in-out infinite;
}
@keyframes msg-voice-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}
#msg-voice-btn.recording {
  background: #FFE8E8 !important;
  color: #B23A3A !important;
}

.msg-row.system { justify-content: center; }
.msg-system-card {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: #FBFAF6;
  border: 1px solid var(--border, #E8E4D8);
  border-radius: 999px;
  padding: 0.25rem 0.75rem;
  font-size: 0.74rem;
  color: var(--text-muted, #6B6B5E);
  max-width: 90%;
}
.msg-system-card[data-event="signature_completed"] {
  background: #F0F7EE;
  border-color: #C7E0BD;
  color: #4A6B3A;
}
.msg-system-card[data-event="document_uploaded"] {
  background: #FAF4E0;
  border-color: #E8D9A6;
  color: #8A6F25;
}
.msg-system-icon {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}
.msg-system-body strong { font-weight: 600; color: var(--text, #2A2A24); }
.msg-system-time {
  font-size: 0.65rem;
  opacity: 0.7;
  margin-left: auto;
}

.msg-bubble-system {
  background: transparent !important;
  border: none !important;
  color: var(--text-muted);
  font-style: italic;
  text-align: center;
  width: 100%;
}

.msg-author {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--gold, #B08C30);
  margin-bottom: 0.15rem;
}

.msg-body { white-space: pre-wrap; }

.msg-mention {
  background: #FAF4E0;
  color: #B08C30;
  padding: 0 0.2rem;
  border-radius: 3px;
  font-weight: 500;
}
.msg-mention.me { background: #C9A84C; color: #fff; }
.msg-mention.lex { background: #2A2A24; color: #fff; }

/* Linkified URLs inside message bodies */
.msg-link {
  color: var(--gold, #B08C30);
  text-decoration: underline;
  word-break: break-word;
}
.msg-link:hover { color: #8A6628; }

/* OG link preview card — rendered under the body when the link-preview
   edge fn returns metadata. Falls back silently if the request fails. */
.msg-link-card {
  display: flex;
  gap: 0.65rem;
  align-items: stretch;
  margin-top: 0.45rem;
  padding: 0.55rem 0.7rem;
  background: #FBFAF6;
  border: 1px solid var(--border, #E8E4D8);
  border-left: 3px solid var(--gold, #C9A84C);
  border-radius: 6px;
  max-width: 480px;
  text-decoration: none;
  color: var(--text, #2A2A24);
}
.msg-link-card:hover { background: #FAF4E0; }
.msg-link-card-img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
}
.msg-link-card-body { min-width: 0; flex: 1; }
.msg-link-card-site {
  font-size: 0.62rem;
  color: var(--text-muted, #8A8A7A);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.15rem;
}
.msg-link-card-title {
  font-weight: 600;
  font-size: 0.86rem;
  line-height: 1.3;
  margin-bottom: 0.2rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.msg-link-card-desc {
  font-size: 0.76rem;
  color: var(--text-muted, #6B6B5E);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.msg-meta {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.25rem;
  flex-wrap: wrap;
}

.msg-time {
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-left: auto;
}

.msg-edited {
  font-size: 0.65rem;
  color: var(--text-muted);
}

.msg-tag {
  font-size: 0.6rem;
  font-weight: 600;
  padding: 0.08rem 0.35rem;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.msg-tag-urgent { background: #B23A3A; color: #fff; }
.msg-tag-ack { background: #2E6B8E; color: #fff; }

.msg-bubble { position: relative; }
/* Message actions (reply, react, edit, delete) — hidden at rest,
   appear on hover / focus / tap. Earlier "always-faint" approach made
   every bubble look like it had a pill stripe; users found it noisy. */
.msg-owner-controls {
  position: absolute;
  top: -12px;
  right: 8px;
  display: flex;
  gap: 0.15rem;
  background: #fff;
  border: 1px solid var(--border, #E8E4D8);
  border-radius: 5px;
  padding: 0.15rem 0.2rem;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  opacity: 0;
  transition: opacity 0.12s ease;
  pointer-events: none;
}
.msg-row:hover .msg-owner-controls,
.msg-row.actions-open .msg-owner-controls,
.msg-owner-controls:focus-within {
  opacity: 1;
  pointer-events: auto;
}
.msg-owner-btn {
  border: none;
  background: none;
  cursor: pointer;
  padding: 0.15rem 0.3rem;
  color: var(--text-muted, #6B6B5E);
  display: inline-flex;
  align-items: center;
  border-radius: 3px;
}
.msg-owner-btn:hover { background: #FAF4E0; color: var(--text); }

.msg-edit-input {
  width: 100%;
  border: 1px solid var(--gold, #C9A84C);
  border-radius: 4px;
  padding: 0.35rem 0.5rem;
  font-family: var(--font-sans);
  font-size: 0.86rem;
  resize: vertical;
  outline: none;
}
.msg-edit-actions {
  display: flex;
  gap: 0.3rem;
  margin-top: 0.4rem;
}

.msg-attachment {
  margin-top: 0.4rem;
  padding: 0.4rem 0.6rem;
  background: #FBFAF6;
  border: 1px solid var(--border, #E8E4D8);
  border-radius: 6px;
  font-size: 0.8rem;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  color: var(--text);
}
.msg-attachment:hover { background: #F2EFE5; }
.msg-attachment-img { padding: 0.3rem; }

/* Voice notes — fixed footprint regardless of duration. Audio playback
   speed scales with length; the visual pill never grows. */
.msg-attachment-voice {
  background: #FAF4E0;
  width: 240px;
  max-width: 100%;
  cursor: default;
}
.msg-voice-play {
  border: none;
  background: var(--gold, #C9A84C);
  color: #fff;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
}
.msg-voice-play:hover { background: #B48F33; }
.msg-voice-play:disabled { background: #C7C2B0; cursor: not-allowed; }
.msg-voice-label { font-size: 0.78rem; color: var(--text, #2A2A24); white-space: nowrap; }
/* When the inline <audio> swaps in after play, force the same width. */
.msg-attachment-voice audio { width: 100%; height: 32px; max-width: none; }
.msg-voice-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-top: 0.4rem;
  max-width: 360px;
}
.msg-voice-transcript-text {
  font-size: 0.78rem;
  color: var(--text-muted, #6B6B5E);
  font-style: italic;
  border-left: 2px solid var(--gold, #C9A84C);
  padding: 0.1rem 0 0.1rem 0.5rem;
  max-width: 100%;
  white-space: pre-wrap;
}
.msg-voice-transcript-pending {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-style: italic;
  opacity: 0.6;
}
.msg-voice-transcribe-retry {
  font-size: 0.72rem;
  color: var(--gold, #B08C30);
  background: none;
  border: 1px solid var(--border, #E8E4D8);
  border-radius: 4px;
  padding: 0.15rem 0.5rem;
  cursor: pointer;
  align-self: flex-start;
}
.msg-voice-transcribe-retry:hover { background: #FAF4E0; }

/* Shared-document picker + chip + card */
.msg-doc-picker-list {
  max-height: 360px;
  overflow-y: auto;
  margin-top: 0.6rem;
  border: 1px solid var(--border, #E8E4D8);
  border-radius: 6px;
}
.msg-doc-result {
  display: flex;
  gap: 0.65rem;
  align-items: center;
  padding: 0.55rem 0.7rem;
  border-bottom: 1px solid #F2EFE5;
  cursor: pointer;
}
.msg-doc-result:last-child { border-bottom: none; }
.msg-doc-result:hover { background: #FAF4E0; }
.msg-doc-result-icon {
  width: 30px; height: 30px;
  border-radius: 7px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #EFECE4;
  color: var(--text, #2A2A24);
  flex-shrink: 0;
}
.msg-doc-result-icon[data-kind="invoice"] { background: #F0F7EE; color: #4A6B3A; }
.msg-doc-result-icon[data-kind="matter_document"] { background: #FAF4E0; color: #8A6628; }
.msg-doc-result-icon[data-kind="library_document"] { background: #E8F1F8; color: #2E6B8E; }
.msg-doc-result-main { min-width: 0; flex: 1; }
.msg-doc-result-title {
  font-weight: 500;
  font-size: 0.86rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.msg-doc-result-sub {
  font-size: 0.72rem;
  color: var(--text-muted, #8A8A7A);
  margin-top: 0.1rem;
}

/* Reply chip above the composer — "Replying to X" with cancel × */
.msg-composer-reply {
  margin-bottom: 0.5rem;
}
.msg-composer-reply.hidden { display: none; }
.msg-reply-chip {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.55rem;
  background: #FAF4E0;
  border-left: 3px solid var(--gold, #C9A84C);
  border-radius: 5px;
  font-size: 0.78rem;
}
.msg-reply-chip-bar { display: none; }
.msg-reply-chip-text { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.msg-reply-chip-name { font-weight: 600; font-size: 0.72rem; color: #8A6628; }
.msg-reply-chip-snippet {
  color: var(--text-muted, #6B6B5E);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Quoted block above a reply in the thread */
.msg-reply-quote {
  display: flex;
  align-items: stretch;
  gap: 0.5rem;
  margin-bottom: 0.3rem;
  padding: 0.35rem 0.5rem;
  background: rgba(201, 168, 76, 0.08);
  border-left: 3px solid var(--gold, #C9A84C);
  border-radius: 4px;
  cursor: pointer;
  max-width: 100%;
}
.msg-reply-quote:hover { background: rgba(201, 168, 76, 0.16); }
.msg-reply-quote-bar { display: none; }
.msg-reply-quote-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.msg-reply-quote-name { font-weight: 600; font-size: 0.7rem; color: #8A6628; }
.msg-reply-quote-snippet {
  color: var(--text-muted, #6B6B5E);
  font-size: 0.78rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.msg-reply-quote-faint {
  font-size: 0.74rem;
  color: var(--text-muted, #8A8A7A);
  font-style: italic;
}

/* Flash effect when scrolling to a quoted message */
.msg-flash { animation: msg-flash 1.2s ease-in-out; }
@keyframes msg-flash {
  0%, 100% { background: transparent; }
  30% { background: rgba(201, 168, 76, 0.22); }
}

/* Preview-kind label in the channel-list row (voice / photo / file) */
.msg-preview-kind { font-style: normal; }

.msg-composer-docref { display: flex; margin-bottom: 0.5rem; }
.msg-composer-docref.hidden { display: none; }
.msg-docref-chip {
  display: flex;
  gap: 0.45rem;
  align-items: center;
  padding: 0.35rem 0.55rem;
  background: #FAF4E0;
  border: 1px solid #E8D9A6;
  border-radius: 6px;
  max-width: 320px;
}
.msg-docref-chip-icon { color: #8A6628; flex-shrink: 0; }
.msg-docref-chip-text { min-width: 0; flex: 1; display: flex; flex-direction: column; }
.msg-docref-chip-title {
  font-size: 0.76rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.msg-docref-chip-sub { font-size: 0.66rem; color: var(--text-muted, #8A8A7A); }

/* Doc-ref card rendered inside a chat message */
.msg-docref-card {
  display: flex;
  gap: 0.55rem;
  align-items: center;
  margin-top: 0.4rem;
  padding: 0.5rem 0.7rem;
  background: #FBFAF6;
  border: 1px solid var(--border, #E8E4D8);
  border-left: 3px solid var(--gold, #C9A84C);
  border-radius: 6px;
  cursor: pointer;
  max-width: 360px;
}
.msg-docref-card:hover { background: #FAF4E0; }
.msg-docref-card-icon { color: #8A6628; flex-shrink: 0; }
.msg-docref-card-icon[data-kind="invoice"] { color: #4A6B3A; }
.msg-docref-card-icon[data-kind="library_document"] { color: #2E6B8E; }
.msg-docref-card-text { min-width: 0; flex: 1; }
.msg-docref-card-title {
  display: block;
  font-weight: 500;
  font-size: 0.82rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.msg-docref-card-sub {
  display: block;
  font-size: 0.7rem;
  color: var(--text-muted, #8A8A7A);
  margin-top: 0.1rem;
}
.msg-docref-card-arrow { color: var(--text-muted, #8A8A7A); flex-shrink: 0; }

/* In-messenger attachment preview modal */
.msg-attachment-modal-body { padding: 0; margin: 0; }
.msg-attachment-loading {
  padding: 2.5rem 1rem;
  text-align: center;
  font-size: 0.86rem;
  color: var(--text-muted, #6B6B5E);
}
.msg-attachment-preview-img {
  display: block;
  max-width: 100%;
  max-height: 70vh;
  margin: 0 auto;
  border-radius: 6px;
}
.msg-attachment-preview-pdf {
  display: block;
  width: 100%;
  height: 70vh;
  border: 1px solid var(--border, #E8E4D8);
  border-radius: 6px;
}
.msg-attachment-preview-file {
  padding: 2.5rem 1rem;
  text-align: center;
  color: var(--text-muted, #6B6B5E);
  font-size: 0.86rem;
}

/* Inline HTML preview for shared lex_documents — clipped to keep the
   modal responsive. Background mimics the editor page chrome. */
.msg-docref-html-preview {
  max-height: 60vh;
  overflow-y: auto;
  padding: 1.25rem 1.5rem;
  background: #FBFAF6;
  border: 1px solid var(--border, #E8E4D8);
  border-radius: 6px;
  font-size: 0.92rem;
  line-height: 1.55;
  color: var(--text, #2A2A24);
}
.msg-docref-html-preview h1,
.msg-docref-html-preview h2,
.msg-docref-html-preview h3 { font-family: var(--font-serif); }
.msg-docref-html-preview img { max-width: 100%; }

/* Invoice metadata grid when there's no PDF to embed */
.msg-docref-invoice-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.6rem 1.25rem;
  padding: 1rem 1.25rem;
  background: #FBFAF6;
  border: 1px solid var(--border, #E8E4D8);
  border-radius: 6px;
  font-size: 0.88rem;
}
.msg-docref-invoice-summary > div span.msg-faint {
  display: block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.15rem;
}

.msg-docref-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border, #E8E4D8);
}

/* Channel info brief modal */
.msg-info-card {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--border, #E8E4D8);
}
.msg-info-card-body { min-width: 0; flex: 1; }
.msg-info-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #EFECE4;
  color: var(--text, #2A2A24);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  object-fit: cover;
}
.msg-info-avatar.matter {
  border-radius: 12px;
  background: #FAF4E0;
  color: #8A6628;
  border: 1px solid #E8D9A6;
}
.msg-info-avatar-btn {
  position: relative;
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
  flex-shrink: 0;
  display: inline-flex;
}
.msg-info-avatar-btn:focus-visible { outline: 2px solid var(--gold, #C9A84C); outline-offset: 2px; border-radius: 12px; }
.msg-info-avatar-edit {
  position: absolute;
  bottom: -3px;
  right: -3px;
  background: var(--gold, #C9A84C);
  color: #fff;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
  transition: transform 0.15s;
}
.msg-info-avatar-btn:hover .msg-info-avatar-edit { transform: scale(1.05); }

/* Shared attachments list inside the DM info modal */
.msg-info-shared {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.4rem;
}
.msg-info-shared-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.6rem;
  background: #FBFAF6;
  border: 1px solid var(--border, #E8E4D8);
  border-radius: 5px;
  font-size: 0.78rem;
  cursor: pointer;
  color: var(--text, #2A2A24);
  min-width: 0;
}
.msg-info-shared-item:hover { background: #FAF4E0; }
.msg-info-shared-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex: 1;
}
.msg-info-name { font-family: var(--font-serif); font-size: 1.15rem; }
.msg-info-role {
  font-size: 0.72rem;
  color: var(--gold, #B08C30);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 0.15rem 0;
}
.msg-info-meta { font-size: 0.82rem; color: var(--text-muted, #6B6B5E); }
.msg-info-section-label {
  margin-top: 1rem;
  margin-bottom: 0.4rem;
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-muted, #8A8A7A);
}
.msg-info-recent { margin: 0; padding-left: 1.1rem; font-size: 0.82rem; line-height: 1.55; }
.msg-info-recent li { margin-bottom: 0.2rem; }
.msg-info-members {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}
.msg-info-member {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.55rem 0.25rem 0.3rem;
  background: #FBFAF6;
  border: 1px solid var(--border, #E8E4D8);
  border-radius: 999px;
  font-size: 0.78rem;
  color: var(--text, #2A2A24);
}
.msg-info-member.is-clickable {
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  transition: background 0.1s, border-color 0.1s;
}
.msg-info-member.is-clickable:hover {
  background: #FAF4E0;
  border-color: var(--gold, #C9A84C);
}
.msg-info-member.self { opacity: 0.7; cursor: default; }

/* Action row under the matter header in the info modal (Open matter etc) */
.msg-info-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.6rem;
  flex-wrap: wrap;
}
.msg-info-member-avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #EFECE4;
  color: var(--text);
  font-size: 0.65rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  object-fit: cover;
}

/* Thread loading state — three pulsing dots */
.msg-thread-loading {
  display: inline-flex;
  gap: 0.35rem;
  margin: 0 auto;
}
.msg-thread-loading span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gold, #C9A84C);
  opacity: 0.4;
  animation: msg-thread-pulse 1.2s ease-in-out infinite;
}
.msg-thread-loading span:nth-child(2) { animation-delay: 0.15s; }
.msg-thread-loading span:nth-child(3) { animation-delay: 0.3s; }
@keyframes msg-thread-pulse {
  0%, 100% { opacity: 0.4; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.2); }
}

.msg-img-placeholder { padding: 0.6rem 1rem; }

.msg-ack-row {
  display: flex;
  gap: 0.3rem;
  margin-top: 0.4rem;
  flex-wrap: wrap;
}
.msg-ack-set {
  margin-top: 0.4rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-style: italic;
}

.msg-faint { color: var(--text-muted); }

/* ── Composer ── */
.msg-composer {
  border-top: 1px solid var(--border, #E8E4D8);
  background: #fff;
  padding: 0.65rem 0.9rem 0.8rem;
  position: relative;
}

.msg-composer-attachments {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}
.msg-composer-attachments.hidden { display: none; }

.msg-composer-att {
  background: #FBFAF6;
  border: 1px solid var(--border, #E8E4D8);
  border-radius: 4px;
  padding: 0.2rem 0.45rem 0.2rem 0.55rem;
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}
.msg-composer-att-x {
  border: none;
  background: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 1rem;
  padding: 0 0.2rem;
  line-height: 1;
}
.msg-composer-att-x:hover { color: #B23A3A; }

.msg-composer-row {
  display: flex;
  align-items: flex-end;
  gap: 0.4rem;
}

/* Attach menu — single paperclip with a popover that offers upload or
   pick-from-Lex. Replaces the side-by-side paperclip + doc-icon. */
.msg-attach-wrap { position: relative; display: inline-flex; }
.msg-attach-menu {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  background: #fff;
  border: 1px solid var(--border, #E8E4D8);
  border-radius: 8px;
  box-shadow: 0 6px 18px rgba(40, 30, 20, 0.12);
  padding: 0.3rem;
  min-width: 240px;
  z-index: 60;
}
.msg-attach-menu.hidden { display: none; }
.msg-attach-menu-item {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  border-radius: 6px;
  padding: 0.55rem 0.65rem;
  cursor: pointer;
  color: var(--text, #2A2A24);
}
.msg-attach-menu-item:hover { background: #FAF4E0; }
.msg-attach-menu-item svg { color: var(--gold, #B08C30); flex-shrink: 0; margin-top: 0.1rem; }
.msg-attach-menu-text { display: flex; flex-direction: column; gap: 0.05rem; min-width: 0; }
.msg-attach-menu-title { font-size: 0.84rem; font-weight: 500; }
.msg-attach-menu-sub { font-size: 0.7rem; color: var(--text-muted, #8A8A7A); }

#msg-composer-input {
  flex: 1;
  border: 1px solid var(--border, #E8E4D8);
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
  font-family: var(--font-sans, 'DM Sans', system-ui, sans-serif);
  font-size: 0.88rem;
  resize: none;
  min-height: 36px;
  max-height: 200px;
  outline: none;
  color: var(--text);
}
#msg-composer-input:focus { border-color: var(--gold, #C9A84C); }

.msg-composer-actions {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.msg-composer-toggles {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin-top: 0.45rem;
  font-size: 0.72rem;
  color: var(--text-muted);
  flex-wrap: wrap;
}
.msg-composer-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  cursor: pointer;
}
.msg-composer-toggle input { margin: 0; }

/* ── Mention popup ── */
.msg-mention-popup {
  position: absolute;
  bottom: calc(100% + 4px);
  left: 0.9rem;
  right: 0.9rem;
  max-width: 320px;
  max-height: 200px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid var(--border, #E8E4D8);
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
  padding: 0.25rem 0;
  display: none;
  z-index: 50;
}
.msg-mention-popup.visible { display: block; }

.msg-mention-item {
  padding: 0.4rem 0.7rem;
  cursor: pointer;
  font-size: 0.82rem;
}
.msg-mention-item:hover,
.msg-mention-item.active { background: #FAF4E0; }
.msg-mention-name { font-weight: 500; }
.msg-mention-role {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ── New DM modal ── */
.msg-dm-picker-list {
  max-height: 320px;
  overflow-y: auto;
  margin-top: 0.6rem;
  border: 1px solid var(--border, #E8E4D8);
  border-radius: 4px;
}
.msg-dm-picker-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.7rem;
  border-bottom: 1px solid #F2EFE5;
  cursor: pointer;
}
.msg-dm-picker-row:hover { background: #FBFAF4; }
.msg-dm-picker-row:last-child { border-bottom: none; }
.msg-dm-picker-name { font-size: 0.85rem; font-weight: 500; }
.msg-dm-picker-role { font-size: 0.65rem; color: var(--text-muted); text-transform: uppercase; }

.msg-members-list {
  max-height: 360px;
  overflow-y: auto;
}
.msg-member-row {
  display: flex;
  justify-content: space-between;
  padding: 0.45rem 0.7rem;
  border-bottom: 1px solid #F2EFE5;
  font-size: 0.85rem;
}
.msg-member-role { color: var(--text-muted); font-size: 0.7rem; text-transform: uppercase; }

.msg-ann-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.6rem;
  font-size: 0.85rem;
}

/* ── Topbar messenger button + badge ── */
.topbar-msg-btn { position: relative; }
.topbar-msg-count {
  position: absolute;
  top: -3px;
  right: -3px;
  background: var(--gold, #C9A84C);
  color: #fff;
  font-size: 0.6rem;
  font-weight: 700;
  padding: 0.05rem 0.32rem;
  border-radius: 999px;
  min-width: 1.1rem;
  text-align: center;
  pointer-events: none;
}

/* Home messenger pill badge */
.home-pill { position: relative; }
.home-msg-dot {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--gold, #C9A84C);
  color: #fff;
  font-size: 0.6rem;
  font-weight: 700;
  padding: 0.05rem 0.35rem;
  border-radius: 999px;
  pointer-events: none;
}

/* ── Flat (Slack-style) channel layout — matter / topic / announce / Lex DM ── */
.msg-thread-flat { padding: 0.6rem 1rem 1.25rem; }

.msg-channel-msg {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 0.55rem;
  padding: 0.45rem 0.5rem 0.15rem;
  border-radius: 8px;
  position: relative;
}
.msg-channel-msg:hover { background: #FBFAF4; }
.msg-channel-msg.grouped { padding-top: 0.05rem; padding-bottom: 0.05rem; }
.msg-channel-msg.deleted .msg-channel-deleted {
  color: var(--text-muted, #7a7264);
  font-style: italic;
  font-size: 0.86rem;
}

.msg-channel-gutter {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  flex-shrink: 0;
}
.msg-channel-gutter.grouped { padding-top: 0.25rem; }
.msg-channel-hovertime {
  font-size: 0.62rem;
  font-family: var(--font-mono, ui-monospace, Menlo, monospace);
  color: var(--text-muted, #a8a08e);
  opacity: 0;
  align-self: center;
  text-align: center;
  width: 100%;
}
.msg-channel-msg.grouped:hover .msg-channel-hovertime { opacity: 1; }

.msg-channel-avatar {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: #EFECE4;
  color: var(--text, #2A2A24);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  object-fit: cover;
  flex-shrink: 0;
}
.msg-channel-avatar.lex {
  background: #fff;
  color: #8A6628;
  border: 1px solid var(--border, #E8E4D8);
  box-shadow: inset 2px 0 0 var(--gold, #C9A84C);
}

.msg-channel-main { min-width: 0; }

.msg-channel-head {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
  margin-bottom: 0.1rem;
  line-height: 1.2;
}
.msg-channel-name {
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text, #2A2A24);
}
.msg-channel-name.lex { color: #8A6628; }
.msg-channel-role {
  font-size: 0.72rem;
  color: var(--text-muted, #a8a08e);
}
.msg-channel-time {
  font-size: 0.66rem;
  color: var(--text-muted, #a8a08e);
  font-family: var(--font-mono, ui-monospace, Menlo, monospace);
}
.msg-channel-badge-ai {
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: #8A6628;
  background: #F5ECD6;
  border-radius: 4px;
  padding: 0.05rem 0.35rem;
}

.msg-channel-main .msg-body {
  font-size: 0.88rem;
  line-height: 1.5;
  color: var(--text, #2A2A24);
  white-space: pre-wrap;
}

.msg-channel-ai-card {
  background: #FFFDF5;
  border: 1px solid #E8D9A6;
  border-left: 3px solid var(--gold, #C9A84C);
  border-radius: 8px;
  padding: 0.55rem 0.75rem;
  max-width: 580px;
}
.msg-channel-ai-card .msg-body { color: #6A4F1A; }

.msg-channel-main .msg-attachment { margin-top: 0.4rem; max-width: 360px; }
.msg-channel-main .msg-voice-wrap { margin-top: 0.4rem; max-width: 360px; }
.msg-channel-main .msg-reactions { margin-top: 0.3rem; }
.msg-channel-main .msg-ack-row,
.msg-channel-main .msg-ack-set { margin-top: 0.4rem; }

/* Unified action toolbar for the flat (matter/topic) channel layout —
   reply + react + edit + delete. Hidden at rest, appears on hover /
   focus / tap. */
.msg-hover-actions {
  position: absolute;
  top: -12px;
  right: 12px;
  display: inline-flex;
  align-items: center;
  gap: 0.1rem;
  background: #fff;
  border: 1px solid var(--border, #E8E4D8);
  border-radius: 8px;
  box-shadow: 0 1px 4px rgba(40, 30, 20, 0.08);
  padding: 0.15rem;
  z-index: 2;
  opacity: 0;
  transition: opacity 0.12s ease;
  pointer-events: none;
}
.msg-channel-msg:hover .msg-hover-actions,
.msg-channel-msg.actions-open .msg-hover-actions,
.msg-hover-actions:focus-within {
  opacity: 1;
  pointer-events: auto;
}
.msg-hover-btn {
  border: 0;
  background: transparent;
  cursor: pointer;
  color: var(--text-muted, #7a7264);
  padding: 0.25rem;
  border-radius: 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.msg-hover-btn:hover { background: #FAF4E0; color: var(--text, #2A2A24); }
.msg-hover-btn.danger:hover { background: #FBECEA; color: #8A2A26; }

/* ── Mobile ── */
@media (max-width: 768px) {
  .msg-wrap {
    grid-template-columns: 1fr;
    height: calc(100vh - 60px);
  }
  .msg-left { display: flex; }
  .msg-right { display: none; }
  .msg-wrap.thread-open .msg-left { display: none; }
  .msg-wrap.thread-open .msg-right { display: flex; }
  .msg-mobile-close { display: inline-flex; }
  .msg-bubble { max-width: 80%; }
  .msg-channel-msg { grid-template-columns: 38px minmax(0, 1fr); gap: 0.45rem; }
  .msg-channel-avatar { width: 30px; height: 30px; border-radius: 7px; font-size: 0.7rem; }
  .msg-channel-ai-card { padding: 0.45rem 0.6rem; }
  /* On touch screens the user can't hover. Show actions when a message
     row is tapped (.actions-open is toggled by JS) but keep them out
     of the way otherwise. */
  .msg-channel-msg.actions-open .msg-hover-actions,
  .msg-row.actions-open .msg-owner-controls {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
  }
}
