/* ═══════════════════════════════════════════════════════════════════════════
   Messages — Interior Moderna team channels
   Design language: architectural, restrained, newspaper-typographic.
   Two-column layout (channel rail | thread surface).
   Brand palette only: cream bg, bronze accent, hairline borders.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ─── Page shell ──────────────────────────────────────────────────────────── */

.msg-shell {
  display: grid;
  /* DEFAULT (no thread selected): channel rail | wide thread list. The detail
     column only appears once a thread is opened (.msg-has-detail), so the list
     gets the full width for better previews until then. */
  grid-template-columns: 240px 1fr;
  gap: 0;
  /* Fixed height (not min-height) so each column scrolls INTERNALLY and
     independently — scrolling the thread list must not move the rail/detail. */
  height: calc(100vh - 200px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.msg-shell--no-rail {
  grid-template-columns: 1fr;  /* warehouse single-channel: wide thread list */
}
.msg-shell.msg-rail-collapsed {
  grid-template-columns: 0 1fr;
}

/* Thread selected → make room for the 3rd column: rail | 340px list | detail. */
.msg-shell.msg-has-detail {
  grid-template-columns: 240px 340px 1fr;
}
.msg-shell--no-rail.msg-has-detail {
  grid-template-columns: 340px 1fr;
}
.msg-shell.msg-rail-collapsed.msg-has-detail {
  grid-template-columns: 0 340px 1fr;
}

.msg-shell.msg-rail-collapsed .msg-rail {
  display: none;
}

/* ─── 3rd column: the open thread (only shown once a thread is selected) ───── */
.msg-detail-col {
  display: none;
  flex-direction: column;
  min-width: 0;        /* let long content shrink instead of overflowing the grid */
  min-height: 0;       /* allow the conversation to scroll internally */
  border-left: 1px solid var(--border);
  overflow: hidden;
}
.msg-shell.msg-has-detail .msg-detail-col {
  display: flex;
}
.msg-detail-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-dim);
  text-align: center;
  padding: 40px;
}
.msg-detail-empty-icon { opacity: 0.5; }
.msg-detail-empty-text { font-size: 13.5px; margin: 0; }

/* The thread detail was built as a full-screen card; inside the column it should
   fill the cell with no extra chrome (the column already has a left border) and
   scroll its replies internally. */
.msg-detail-col > .msg-detail-shell {
  flex: 1;
  min-height: 0;
  height: 100%;
  border: none;
  border-radius: 0;
  box-shadow: none;
}

/* Selected thread in the list (3-column mode) */
.msg-thread-row--active {
  background: var(--surface-2);
  box-shadow: inset 3px 0 0 var(--accent);
}

/* Rail re-open handle — only visible when the rail is collapsed */
.msg-rail-handle { display: none; }
.msg-shell.msg-rail-collapsed .msg-rail-handle {
  display: flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 52px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: none;
  border-radius: 0 8px 8px 0;
  cursor: pointer;
  z-index: 4;
  color: var(--text-dim);
}
.msg-shell { position: relative; }

/* In 3-column mode the thread list stays visible, so the detail's "Back"
   button is redundant — hide it on wide screens (kept on narrow/full-screen). */
/* Close (×) button — closes the detail column in 3-column mode. Hidden by
   default (narrow uses the full-screen "Back" button instead); shown on wide. */
.msg-detail-close {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 6px;
  border-radius: var(--radius-sm);
  align-items: center;
}
.msg-detail-close:hover { background: var(--surface-2); color: var(--text); }

@media (min-width: 1100px) {
  .msg-detail-back { display: none; }
  .msg-detail-close { display: inline-flex; }
}

/* Below the 3-column breakpoint: never grid-in the detail column; the thread
   opens full-screen (replacing the view) exactly as before — even if a thread
   is selected (.msg-has-detail). */
@media (max-width: 1099px) {
  .msg-shell,
  .msg-shell.msg-has-detail {
    grid-template-columns: 240px 1fr;
  }
  .msg-shell--no-rail,
  .msg-shell--no-rail.msg-has-detail {
    grid-template-columns: 1fr;
  }
  .msg-detail-col,
  .msg-shell.msg-has-detail .msg-detail-col {
    display: none;
  }
}

/* ─── Split View ──────────────────────────────────────────────────────────────
   Four columns in two halves: LEFT half = all teams' messages list + the open
   message's conversation; RIGHT half = all teams' tasks list + the open task's
   conversation. Each half opens its own thread independently. The shell is a
   vertical flex (toolbar on top, the two halves below). */
.msg-shell--split {
  display: flex;
  flex-direction: column;
}
.msg-split-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.msg-split-cols {
  flex: 1;
  min-height: 0;
  display: flex;
}
/* Each half = one list column + one detail column, splitting the width 50/50. */
.msg-split-half {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
}
.msg-split-half + .msg-split-half { border-left: 2px solid var(--border); }
/* The list fills its half until a thread opens, then it shrinks to make room for
   that half's conversation. */
.msg-split-half .msg-split-col {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}
.msg-split-half.has-detail .msg-split-col { flex: 0 0 clamp(220px, 32%, 300px); }
.msg-split-detail {
  flex: 1 1 0;
  min-width: 0;
  min-height: 0;
  display: none;
  flex-direction: column;
  overflow: hidden;
  border-left: 1px solid var(--border);
}
.msg-split-half.has-detail .msg-split-detail { display: flex; }
/* The per-pane detail reuses .msg-detail-shell; let it fill its column. */
.msg-split-detail > .msg-detail-shell { flex: 1; min-height: 0; height: 100%; border: none; border-radius: 0; box-shadow: none; }
.msg-split-detail .msg-detail-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; color: var(--text-dim); text-align: center; padding: 40px; }
/* Team label in a pane's detail topbar (replaces the channel "back" affordance). */
.msg-split-detail-team {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
}
.msg-split-head {
  display: flex;
  align-items: baseline;
  gap: 9px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.msg-split-head-title {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--text);
}
.msg-split-head-sub {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
/* Column-header unread total — a RED notification badge (like the nav count) so
   the top of each list tells you instantly how many unread there are. */
.msg-split-head-unread {
  margin-left: auto;
  flex-shrink: 0;
  min-width: 19px;
  height: 19px;
  padding: 0 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11.5px;
  font-weight: 700;
  color: #fff;
  background: var(--red, #dc2626);
  border-radius: 10px;
}
.msg-split-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}
.msg-split-group-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--surface-2);
  padding: 6px 18px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
}
/* Per-team unread count — a RED notification badge so each team tells you, at a
   glance, how many unread it has (messages OR tasks). */
.msg-split-group-unread {
  flex-shrink: 0;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  background: var(--red, #dc2626);
  border-radius: 9px;
}
.msg-split-empty { padding: 44px 24px; text-align: center; }
/* Muted "No messages/tasks yet" line under a team that exists but is empty (roster
   mode — so a team like Factory still appears even with nothing in it yet). */
.msg-split-group-empty {
  padding: 9px 18px 11px;
  font-size: 12px;
  font-style: italic;
  color: var(--text-dim);
}
/* Task-column filter bar (assignee / waiting-on / status / priority).
   UI standard (docs/ui-conventions.md): ONE inline row when there's room, and
   collapse into a "Filters" button + popover when the column is narrow — never
   wrap, never crush the controls to slivers. `.is-collapsed` is toggled in JS
   from the live column width. */
.msg-split-filterbar {
  position: relative;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}
.msg-split-filters {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 5px;
}
.msg-split-filter-sel {
  font-size: 11.5px;
  padding: 4px 6px;
  height: auto;
  flex: 1 1 0;
  min-width: 0;       /* allow shrinking below intrinsic width so all fit one row */
}
.msg-split-filter-clear {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text-secondary);
  cursor: pointer;
  flex: 0 0 auto;     /* keep the Clear button at its natural width */
  white-space: nowrap;
}
/* The "Filters" toggle — only shown when the bar is collapsed. */
.msg-split-filterbar-toggle {
  display: none;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text-secondary);
  cursor: pointer;
}
.msg-split-filterbar-toggle:hover { color: var(--text); border-color: var(--accent); }
.msg-filterbar-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
}
/* Collapsed: show the toggle, turn the inline row into a floating popover. */
.msg-split-filterbar.is-collapsed > .msg-split-filterbar-toggle { display: inline-flex; }
.msg-split-filterbar.is-collapsed > .msg-split-filters {
  display: none;
  position: absolute;
  top: calc(100% - 1px);
  left: 14px;
  right: 14px;
  z-index: 30;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow-md, 0 8px 24px rgba(0, 0, 0, 0.14));
}
.msg-split-filterbar.is-collapsed.is-open > .msg-split-filters { display: flex; }
/* In the popover the controls get room to be readable (wrap, ~2 per row). */
.msg-split-filterbar.is-collapsed > .msg-split-filters .msg-split-filter-sel { flex: 1 1 130px; }
.msg-split-filterbar.is-collapsed > .msg-split-filters .msg-split-filter-clear { flex: 1 1 100%; justify-content: center; }
.msg-split-filter-clear:hover { color: var(--text); border-color: var(--accent); }
/* "Waiting on <name>" badge on a task row — distinct from the assignee chip. */
.msg-task-waiting {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  padding: 1px 7px 1px 6px;
  border-radius: 10px;
  background: var(--amber-dim, var(--surface-2));
  color: var(--amber, var(--text-secondary));
  border: 1px solid var(--border);
  white-space: nowrap;
}
/* The Split toggle button shares the .refresh-btn pill; active state is inlined. */
.msg-split-toggle.is-active { font-weight: 600; }

/* Below the 4-column breakpoint, stack the two halves vertically (each still
   shows its list + any open conversation side by side, just half-height). */
@media (max-width: 1199px) {
  .msg-split-cols { flex-direction: column; }
  .msg-split-half { flex: 1 1 0; min-height: 0; }
  .msg-split-half + .msg-split-half { border-left: none; border-top: 2px solid var(--border); }
}

/* Page header — tighter, more deliberate than the default page-header */
.msg-page-header {
  display: flex;
  align-items: center;          /* compact: title + actions on one tight row */
  justify-content: space-between;
  gap: 12px 16px;
  padding: 0 0 8px 0;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  /* Frozen: stays pinned to the top of the content area while anything scrolls. */
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bg);
}

.msg-page-header .msg-title-block {
  display: flex;
  flex-direction: row;          /* title + subtitle inline to save vertical space */
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 10px;
}

.msg-page-header .msg-title {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}

.msg-page-header .msg-title svg {
  color: var(--accent);
}

.msg-page-header .msg-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0;
  letter-spacing: 0.005em;
}

.msg-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.msg-header-actions .form-input {
  font-size: 12px;
  max-width: 140px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
}

/* ─── Channel rail (left) ─────────────────────────────────────────────────── */

.msg-rail {
  background: var(--bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 18px 0;
  min-height: 0;
  overflow-y: auto;  /* scroll the channel list independently */
}

.msg-rail-section-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-dim);
  padding: 0 18px 8px;
}

.msg-rail-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
}

.msg-channel-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px 9px 22px;
  cursor: pointer;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  font-family: inherit;
  font-size: 13.5px;
  color: var(--text-muted);
  transition: background 0.12s ease, color 0.12s ease;
  border-radius: 0;
}

/* Was a '#' prefix — now a per-team emoji rendered in .msg-channel-ico (JS). */
.msg-channel-item::before { content: none; }

.msg-channel-item .msg-channel-ico {
  flex-shrink: 0;
  font-size: 14.5px;
  line-height: 1;
}

.msg-channel-item .msg-channel-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}

.msg-channel-item:hover {
  background: var(--surface-2);
  color: var(--text);
}

.msg-channel-item:hover::before {
  color: var(--text-muted);
}

.msg-channel-item.is-active {
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  box-shadow: inset 3px 0 0 var(--accent);
}

.msg-channel-item.is-active::before {
  color: var(--accent);
  font-weight: 600;
}

.msg-channel-item.is-active .msg-channel-name {
  font-weight: 600;
}

.msg-channel-item.is-muted {
  color: var(--text-dim);
}

.msg-channel-item.is-muted::before {
  color: var(--text-dim);
}

.msg-channel-unread-pill {
  flex-shrink: 0;
  background: var(--accent);
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 10px;
  letter-spacing: 0.01em;
  min-width: 20px;
  text-align: center;
}

.msg-channel-item.is-muted .msg-channel-unread-pill {
  background: var(--text-dim);
}

.msg-channel-mute-btn {
  flex-shrink: 0;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-dim);
  padding: 2px;
  border-radius: 4px;
  display: none;
  align-items: center;
  justify-content: center;
}

.msg-channel-item:hover .msg-channel-mute-btn {
  display: inline-flex;
}

.msg-channel-mute-btn:hover {
  color: var(--text);
  background: var(--surface-2);
}

.msg-rail-footer {
  margin-top: auto;
  padding: 16px 18px 0;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.msg-rail-footer-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-dim);
}

.msg-rail-footer .form-input {
  width: 100%;
  font-size: 12.5px;
  padding: 6px 10px;
}

/* ─── Surface (right column) ──────────────────────────────────────────────── */

.msg-surface {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;   /* allow the inner thread list to scroll instead of growing the page */
  background: var(--surface);
}

/* Channel header — name, description, meta */
.msg-channel-header {
  padding: 22px 32px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.msg-channel-header-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  flex: 1;
}

.msg-channel-header-name {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin: 0;
}

/* Was a '#' prefix — the per-team emoji is now prepended to the title text (JS). */
.msg-channel-header-name::before {
  content: none;
}

.msg-channel-header-desc {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.5;
}

.msg-channel-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.msg-channel-header-actions .btn {
  font-size: 13px;
  padding: 7px 14px;
}

/* Mobile-only affordances — hidden on desktop, revealed in css/mobile.css.
   The rail-drawer toggle (the phone channel switcher) + its backdrop only make
   sense once the rail collapses to an off-canvas drawer below 768px. */
.msg-rail-mobile-toggle { display: none; }
.msg-rail-backdrop { display: none; }

/* Filter strip */
.msg-filter-strip {
  padding: 14px 32px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* Chat / Tasks tab switcher for a team (migration: team-tabs nav consolidation) */
.msg-team-tabs {
  display: flex;
  gap: 8px;
  padding: 10px 32px 0;
  background: var(--surface);
}
.msg-team-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-bottom: none;
  background: var(--bg);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border-radius: 8px 8px 0 0;
  position: relative;
  top: 1px;
}
.msg-team-tab:hover { color: var(--text); }
.msg-team-tab.is-active {
  color: var(--accent);
  border-color: var(--border);
  background: var(--surface);
  border-bottom: 2px solid var(--accent);
}
.msg-team-tab svg { opacity: 0.8; }
.msg-team-tab-badge {
  background: var(--red, #e5484d);
  color: #fff;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
  min-width: 17px;
  height: 17px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
}

.msg-status-toggle {
  display: inline-flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px;
  gap: 0;
}

.msg-status-toggle .toggle-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 12.5px;
  font-weight: 500;
  padding: 5px 14px;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
  font-family: inherit;
}

.msg-status-toggle .toggle-btn:hover {
  color: var(--text);
}

.msg-status-toggle .toggle-btn.active {
  background: var(--text);
  color: var(--surface);
  font-weight: 600;
}

.msg-filter-spacer {
  flex: 1;
}

.msg-filter-search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.msg-filter-search-wrap svg {
  position: absolute;
  left: 10px;
  color: var(--text-dim);
  pointer-events: none;
}

.msg-filter-search-input {
  font-size: 12.5px;
  padding: 6px 12px 6px 32px;
  min-width: 220px;
  border-radius: var(--radius-sm);
}

.msg-filter-tagged-select {
  font-size: 12.5px;
  padding: 6px 10px;
  min-width: 140px;
  border-radius: var(--radius-sm);
}

/* Compose */
.msg-compose-area {
  padding: 0 32px;
}

.msg-compose-box {
  margin: 16px 0;
  padding: 18px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
  /* Tall task-compose forms must never push Cancel/Create off-screen: cap the
     box to the viewport and scroll its body, with the actions pinned (below). */
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 230px);
  overflow-y: auto;
}

.msg-compose-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.msg-compose-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
}

.msg-compose-title .ch-name {
  color: var(--accent);
}

.msg-compose-hint {
  font-size: 11px;
  color: var(--text-dim);
}

.msg-compose-tag-row {
  margin-top: 10px;
}

.msg-compose-tag-row-label {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-weight: 500;
}

.msg-compose-tag-list {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.msg-compose-tag-list label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.msg-compose-tag-list label:hover {
  border-color: var(--border-hover);
  color: var(--text);
}

.msg-compose-tag-list label:has(input:checked) {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

.msg-compose-tag-list input[type="checkbox"] {
  margin: 0;
  accent-color: var(--accent);
}

.msg-compose-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  align-items: center;
  /* Pinned to the bottom of the (scrollable) compose box so Cancel + Create
     stay visible no matter how tall the task form gets. */
  position: sticky;
  bottom: -18px;                 /* cancel the box's 18px bottom padding */
  margin: 14px -18px -18px;      /* bleed to the box edges */
  padding: 12px 18px;
  background: var(--bg);
  border-top: 1px solid var(--border);
  border-bottom-left-radius: var(--radius);
  border-bottom-right-radius: var(--radius);
}

/* Thread list */
.msg-thread-list {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  padding: 8px 0 24px;
}

.msg-thread-row {
  display: grid;
  grid-template-columns: auto 1fr auto;  /* status dot | body | read-toggle */
  align-items: start;
  gap: 12px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.12s ease;
  position: relative;
}

.msg-thread-row:hover {
  background: var(--bg);
}

.msg-thread-row::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: transparent;
  transition: background 0.12s ease;
}

.msg-thread-row:hover::before {
  background: var(--accent);
}

/* Leading dot = UNREAD status (the thing you scan for). Filled accent dot with a
   glow = unread; a faint hollow ring = read/seen. (Open/closed is conveyed by the
   "Closed" pill in the row meta + the Open/Closed/All filter, not this dot.) */
.msg-thread-unread-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 5px;  /* align with the first line of the wrapped title */
  box-sizing: border-box;
}
.msg-thread-unread-dot.is-unread {
  background: var(--red, #dc2626);
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.18);
}
.msg-thread-unread-dot.is-read {
  background: transparent;
  border: 1.5px solid var(--border);
}
/* Per-row unread MESSAGE count — a red badge ("3") in the leading slot, like a
   chat app. Replaces the dot when there are unread messages to count. */
.msg-thread-unread-badge {
  flex-shrink: 0;
  margin-top: 2px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  color: #fff;
  background: var(--red, #dc2626);
  border-radius: 9px;
}
/* Combined-team list sections (channel view): "Messages" then "Tasks", with a
   clear gap so the two categories are obviously distinct. */
.msg-thread-section--tasks { margin-top: 14px; border-top: 8px solid var(--bg); }
.msg-thread-section-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 22px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
}
.msg-thread-section-title { display: inline-flex; align-items: center; gap: 6px; }
.msg-thread-section-unread {
  flex-shrink: 0;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  background: var(--red, #dc2626);
  border-radius: 9px;
}
.msg-thread-section-new {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
}
.msg-thread-section-new:hover { color: var(--accent); border-color: var(--accent); }
.msg-thread-section-empty {
  padding: 14px 22px;
  font-size: 12.5px;
  font-style: italic;
  color: var(--text-dim);
}

/* Headline row: title on the left, WhatsApp-style last-activity time on the right. */
.msg-thread-row-headline {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.msg-thread-row-headline .msg-thread-row-title { flex: 1; min-width: 0; }
.msg-thread-row-time {
  flex-shrink: 0;
  margin-top: 2px;
  font-size: 11.5px;
  color: var(--text-dim);
  white-space: nowrap;
}
.msg-thread-row--unread .msg-thread-row-time {
  color: var(--red, #dc2626);
  font-weight: 600;
}
/* Latest-message preview line ("Name: text") — one truncated line, iMessage-style. */
.msg-thread-row-preview {
  font-size: 12.5px;
  color: var(--text-secondary);
  margin-top: 1px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.msg-thread-row-preview-by { font-weight: 600; color: var(--text-muted); }
/* Unread rows: keep the latest message at full strength so it reads as "new". */
.msg-thread-row--unread .msg-thread-row-preview { color: var(--text); }

.msg-thread-row-body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.msg-thread-row-title {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.005em;
  /* Wrap the message overview across up to 3 lines instead of truncating to one
     — the narrow column needs the preview visible. */
  white-space: normal;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  line-height: 1.35;
  word-break: break-word;
}

.msg-thread-row-meta {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ── Read vs unread (email-client style) ──────────────────────────────────
   Read rows are de-emphasized (lighter weight + dimmer title); unread rows are
   bright + bold with a leading accent dot. Non-task unread rows also get a soft
   tint + a persistent left accent bar (task rows keep their priority stripe, so
   we don't add a bar there). Makes "did I read this?" obvious at a glance. */
.msg-thread-row--read .msg-thread-row-title {
  font-weight: 500;
  color: var(--text-muted);
}
/* Read rows recede so unread ones jump out — works everywhere, including task
   rows whose left edge is taken by the priority stripe. The open thread
   (--active) and hovered rows stay full strength so they're still easy to read. */
.msg-thread-row--read:not(.msg-thread-row--active) {
  opacity: 0.62;
}
.msg-thread-row--read:not(.msg-thread-row--active):hover {
  opacity: 1;
}
.msg-thread-row--unread .msg-thread-row-title {
  font-weight: 800;
  color: var(--text);
}
.msg-thread-row--unread:not(.msg-task-row) {
  background: rgba(176, 141, 87, 0.14);  /* stronger accent wash */
}
.msg-thread-row--unread:not(.msg-task-row)::before {
  background: var(--accent);
  width: 4px;  /* thicker persistent left accent bar (overrides 3px hover default) */
}
/* Unread task rows: keep the priority stripe + status tint, but lift them above
   their dimmed read siblings with a soft accent ring drawn INSIDE the row so it
   never collides with the left priority box-shadow. */
.msg-thread-row--unread.msg-task-row {
  outline: 1.5px solid rgba(176, 141, 87, 0.45);
  outline-offset: -1.5px;
}

/* Per-row read/unread toggle (envelope / check). Hidden until row hover; always
   faintly visible on unread rows so the action is discoverable. */
.msg-thread-readtoggle {
  align-self: center;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-dim);
  padding: 5px 7px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  opacity: 0;
  transition: opacity 0.12s ease, color 0.12s ease, background 0.12s ease;
}
.msg-thread-row:hover .msg-thread-readtoggle { opacity: 0.75; }
.msg-thread-row--unread .msg-thread-readtoggle { opacity: 0.85; color: var(--accent); }
.msg-thread-readtoggle:hover { opacity: 1; color: var(--accent); background: var(--surface-2); }

.msg-thread-row-meta .author {
  color: var(--text);
  font-weight: 500;
}

.msg-thread-row-meta .replies {
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.msg-thread-row-meta .dot {
  color: var(--text-dim);
}

.msg-thread-row-tags {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
  margin-top: 5px;   /* sits at the bottom of the row, below the meta line */
}

.msg-tag-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px;
  background: var(--accent-dim);
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
  border-radius: 10px;
  border: 1px solid transparent;
}

/* Empty + loading */
.msg-empty {
  padding: 80px 32px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.msg-empty-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent-dim);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 4px;
}

.msg-empty-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
  margin: 0;
}

.msg-empty-body {
  font-size: 13.5px;
  color: var(--text-muted);
  max-width: 380px;
  line-height: 1.55;
  margin: 0;
}

.msg-empty-cta {
  margin-top: 8px;
}

.msg-load-more-row {
  display: flex;
  justify-content: center;
  padding: 20px 32px 8px;
}

/* ─── Thread detail ───────────────────────────────────────────────────────── */

.msg-detail-shell {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 200px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.msg-detail-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  flex-wrap: wrap;
}

.msg-detail-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  padding: 6px 10px;
  margin-left: -10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: inherit;
  transition: background 0.12s ease, color 0.12s ease;
}

.msg-detail-back:hover {
  background: var(--surface-2);
  color: var(--text);
}

.msg-detail-back .back-channel {
  color: var(--accent);
  font-weight: 600;
}

.msg-detail-header {
  padding: 22px 32px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.msg-detail-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
  min-width: 0;
  margin-bottom: 8px;
}

.msg-detail-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.015em;
  margin: 0;
  line-height: 1.3;
  /* One line + ellipsis so the header stays compact and leaves more room for
     the conversation in the 3-column layout. */
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ─── People dropdown (tagged users) — used in the thread list + detail ───── */
.msg-thread-row-people { margin-top: 6px; }

.msg-people { display: inline-block; }
.msg-people-summary {
  cursor: pointer;
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--text-muted);
  padding: 2px 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  user-select: none;
  white-space: nowrap;
}
.msg-people-summary::-webkit-details-marker { display: none; }
.msg-people-summary:hover { color: var(--text); }
.msg-people[open] > .msg-people-summary { color: var(--text); border-color: var(--accent); }
.msg-people-menu {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 6px;
}
.msg-people-item {
  font-size: 12px;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
  white-space: nowrap;
}

.msg-detail-title-edit-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-dim);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}

.msg-detail-title-edit-btn:hover {
  color: var(--text);
  background: var(--surface-2);
  border-color: var(--border);
}

.msg-detail-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 12.5px;
  color: var(--text-muted);
}

.msg-detail-meta .author {
  color: var(--text);
  font-weight: 600;
}

.msg-detail-meta .dot {
  color: var(--text-dim);
}

.msg-detail-meta .translate-status {
  color: var(--accent);
  font-style: italic;
}

.msg-replies-container {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0 24px;
  min-height: 0;
}

/* Reply blocks — newspaper-style stacked, no bubbles */
.msg-reply {
  padding: 18px 32px;
  border-bottom: 1px solid var(--border);
  position: relative;
}

.msg-reply:last-child {
  border-bottom: none;
}

.msg-reply-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.msg-reply-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 12.5px;
  font-weight: 700;
  flex-shrink: 0;
  letter-spacing: 0.02em;
}

.msg-reply-author {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.005em;
}

.msg-reply-time {
  font-size: 11.5px;
  color: var(--text-dim);
  margin-left: 2px;
}

.msg-reply-actions {
  margin-left: auto;
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity 0.12s ease;
}

.msg-reply:hover .msg-reply-actions {
  opacity: 1;
}

.msg-reply-actions button {
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  color: var(--text-dim);
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}

.msg-reply-actions button:hover {
  background: var(--surface-2);
  border-color: var(--border);
}

.msg-reply-actions button[data-action="msg-recall-reply"]:hover {
  color: var(--red);
  border-color: var(--red-dim);
  background: var(--red-dim);
}

.msg-reply-content {
  font-size: 14.5px;
  color: var(--text);
  line-height: 1.6;
  padding-left: 42px;
  word-break: break-word;
  white-space: pre-wrap;
}

.msg-reply-own .msg-reply-avatar {
  background: var(--accent) !important;
}

.msg-reply-jarvis {
  background: linear-gradient(180deg, rgba(166, 124, 82, 0.04) 0%, transparent 100%);
}

.msg-reply-jarvis .msg-reply-author::after {
  content: 'AI';
  margin-left: 6px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  background: var(--accent);
  color: #fff;
  padding: 1px 5px;
  border-radius: 3px;
  vertical-align: middle;
}

.msg-reply-deleted .msg-reply-content {
  color: var(--text-dim);
  font-style: italic;
}

.msg-mention {
  background: var(--accent-dim);
  color: var(--accent);
  padding: 0 4px;
  border-radius: 3px;
  font-weight: 600;
}

.msg-translated-badge {
  display: inline-block;
  margin-top: 8px;
  font-size: 11px;
  color: var(--accent);
  cursor: pointer;
  font-style: italic;
  padding: 2px 8px;
  border: 1px solid var(--accent-dim);
  border-radius: 10px;
  background: var(--accent-dim);
  transition: opacity 0.12s ease;
}

.msg-translated-badge:hover {
  opacity: 0.75;
}

.msg-typing-indicator {
  padding: 8px 32px 0;
  font-size: 12px;
  color: var(--text-dim);
  font-style: italic;
}

/* Reply composer — pinned at bottom */
.msg-reply-composer {
  padding: 14px 32px 18px;
  border-top: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  bottom: 0;
}

.msg-reply-composer-inner {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
  box-shadow: var(--shadow-xs);
}

.msg-reply-composer-inner:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.msg-reply-composer textarea {
  width: 100%;
  resize: none;
  padding: 12px 80px 12px 14px;
  font-size: 14.5px;
  font-family: inherit;
  border: none;
  background: transparent;
  outline: none;
  color: var(--text);
  line-height: 1.5;
  min-height: 56px;
  max-height: 220px;
}

.msg-reply-composer textarea::placeholder {
  color: var(--text-dim);
}

.msg-reply-composer .send-btn {
  position: absolute;
  right: 8px;
  bottom: 8px;
  font-size: 12.5px;
  padding: 6px 14px;
  background: var(--accent);
  color: #fff;
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
  transition: background 0.12s ease, opacity 0.12s ease;
}

.msg-reply-composer .send-btn:hover {
  background: #8e6943;
  border-color: #8e6943;
}

.msg-reply-composer .send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Status pills (lists + sometimes detail) */
.msg-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 11px;
  letter-spacing: 0.01em;
}

.msg-status-pill.msg-status-closed {
  background: var(--surface-2);
  color: var(--text-muted);
}

.msg-status-pill::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* Title edit inline form */
.msg-title-edit-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.msg-title-edit-input {
  flex: 1;
  min-width: 200px;
  max-width: 540px;
  font-size: 19px;
  font-weight: 700;
  padding: 8px 12px;
}

/* Mention dropdown — stays similar to before but cleaner */
.msg-mention-dropdown {
  position: absolute;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  max-height: 200px;
  overflow-y: auto;
  z-index: 100;
  min-width: 180px;
}

.msg-mention-dropdown.msg-dropdown-down {
  top: 100%;
  left: 0;
  margin-top: 4px;
}

.msg-mention-dropdown.msg-dropdown-up {
  bottom: 100%;
  left: 0;
  margin-bottom: 4px;
}

/* ─── Responsive — collapse rail on narrower screens ──────────────────────── */

@media (max-width: 1024px) {
  .msg-shell {
    grid-template-columns: 200px 1fr;
  }
  .msg-channel-header,
  .msg-filter-strip,
  .msg-reply,
  .msg-thread-row,
  .msg-reply-composer,
  .msg-compose-area,
  .msg-detail-header {
    padding-left: 22px;
    padding-right: 22px;
  }
  .msg-reply-content {
    padding-left: 42px;
  }
}

@media (max-width: 768px) {
  /* Mobile is fully handled by css/mobile.css — these rules below help
     when desktop CSS still applies in the in-between range. */
  .msg-shell {
    grid-template-columns: 1fr;
  }
  .msg-rail {
    display: none;
  }
}

/* ─── Dark mode adjustments (auto via existing tokens) ────────────────────── */

[data-theme="dark"] .msg-reply-composer .send-btn:hover {
  background: #b88a5e;
  border-color: #b88a5e;
}

[data-theme="dark"] .msg-thread-row:hover {
  background: var(--surface-2);
}

/* ─── Compact pass (2026-06-18) ────────────────────────────────────────────
   Smaller, non-huge headers (normal size, still bold); section descriptions
   removed; denser rail + thread rows; longer message preview. Overrides above
   by source order. */

/* Top page header ("Messages" + New Thread) — small + tight, drop the subtitle */
.msg-page-header { padding-bottom: 10px; margin-bottom: 10px; }
.msg-page-header .msg-title { font-size: 16px; }
.msg-page-header .msg-subtitle { display: none; }

/* Channel header (thread-list column) — compact, no description */
.msg-channel-header { padding: 10px 16px; }
.msg-channel-header-name { font-size: 14.5px; }
.msg-channel-header-desc { display: none; }

/* Open-thread header (3rd column) — compact title */
.msg-detail-header { padding: 12px 18px; }
.msg-detail-title { font-size: 15px; }

/* Channel rail — denser, names tight to the left */
.msg-rail { padding: 12px 0; }
.msg-rail-section-label { padding: 0 14px 6px; font-size: 9.5px; }
.msg-channel-item { padding: 6px 12px 6px 14px; gap: 6px; }
.msg-channel-name { font-size: 13px; }

/* Thread rows — compact, but show MORE of the message preview */
.msg-thread-row { padding: 9px 16px; gap: 10px; }
.msg-thread-row-title { font-size: 13.5px; line-height: 1.32; -webkit-line-clamp: 5; }
.msg-thread-row-meta { font-size: 11.5px; }

/* ─── Channel groups (collapsible dropdowns of sub-channels) ──────────────── */
.msg-rail-group { border: none; }
.msg-rail-group-list { list-style: none; margin: 0; padding: 0; }
.msg-rail-group-header {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px 5px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-dim);
  user-select: none;
}
.msg-rail-group-header::-webkit-details-marker { display: none; }
.msg-rail-group-header:hover { color: var(--text-muted); }
.msg-rail-group-caret { font-size: 9px; transition: transform 0.15s ease; line-height: 1; }
.msg-rail-group[open] > .msg-rail-group-header .msg-rail-group-caret { transform: rotate(90deg); }
.msg-rail-group-label { flex: 1; }
.msg-rail-group-unread {
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 0 6px;
  border-radius: 999px;
  min-width: 16px;
  text-align: center;
  letter-spacing: 0;
}
/* When expanded, per-channel pills carry the unread; hide the group total. */
.msg-rail-group[open] > .msg-rail-group-header .msg-rail-group-unread { display: none; }
/* Indent sub-channel items under their group. */
.msg-rail-group .msg-channel-item { padding-left: 26px; }

/* ─── Column 2: 2-line rows by default, expand the preview + reveal people on
       hover ─────────────────────────────────────────────────────────────── */
/* Default: 1-line preview + the meta line (owner · time · replies) only. */
.msg-thread-row-title { -webkit-line-clamp: 1; }
.msg-thread-row-people { display: none; }
/* Hover: 2 more preview lines + the tagged-people dropdown. */
.msg-thread-row:hover .msg-thread-row-title { -webkit-line-clamp: 3; }
.msg-thread-row:hover .msg-thread-row-people { display: flex; }

/* ─── Column 3: tighter message spacing ───────────────────────────────────── */
.msg-replies-container { padding: 2px 0 14px; }
.msg-reply { padding: 9px 18px; }
.msg-reply-header { margin-bottom: 3px; gap: 8px; }
.msg-reply-avatar { width: 28px; height: 28px; }
.msg-reply-content { line-height: 1.4; padding-left: 36px; font-size: 14px; }

/* ─── Col 2 filter strip: "All people" dropdown sits on the status line, right-
       aligned + small; search drops to its own full-width line ────────────── */
.msg-filter-strip { padding: 10px 16px; gap: 8px; row-gap: 8px; }
.msg-filter-tagged-select {
  min-width: 0;
  max-width: 124px;
  font-size: 11.5px;
  padding: 3px 8px;
}
/* Push search onto its own row, full width, under the status + dropdown line. */
.msg-filter-search-wrap { flex-basis: 100%; }
.msg-filter-search-wrap .msg-filter-search-input { width: 100%; }

/* ─── Col 3: ~20% tighter messages ────────────────────────────────────────── */
.msg-replies-container { padding: 2px 0 10px; }
.msg-reply { padding: 7px 18px; }
.msg-reply-header { margin-bottom: 2px; gap: 7px; }
.msg-reply-avatar { width: 24px; height: 24px; }
.msg-reply-content { line-height: 1.3; padding-left: 31px; font-size: 13.5px; }

/* ─── Image lightbox (attached pictures open here, not a browser tab) ──────── */
.msg-img-lightbox {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0, 0, 0, 0.82);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 40px;
  cursor: zoom-out;
}
.msg-img-lightbox-img {
  max-width: 92vw;
  max-height: 84vh;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 10px 50px rgba(0, 0, 0, 0.6);
  cursor: default;
}
.msg-img-lightbox-close {
  position: absolute;
  top: 16px;
  right: 20px;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.msg-img-lightbox-close:hover { background: rgba(255, 255, 255, 0.28); }
.msg-img-lightbox-cap { color: #fff; font-size: 13px; max-width: 92vw; text-align: center; opacity: 0.9; }

/* ─── Col-2 filter: make sure the status toggle + 'All people' fit one line ── */
.msg-status-toggle .toggle-btn { padding: 3px 9px; font-size: 11.5px; }
.msg-filter-tagged-select { max-width: 112px; }

/* ═══ Task Requests: status pills only ════════════════════════════════════════
   Deliberately NO row background tint, NO priority stripe, NO due-date color —
   those read as confusing noise. Priority is conveyed by sort order (high first);
   status keeps a labelled pill; the due date is a neutral chip. */
.msg-thread-row-taskpills { display: flex; flex-wrap: wrap; gap: 5px; margin: 3px 0 1px; }
.msg-tpill {
  display: inline-flex; align-items: center;
  font-size: 10px; font-weight: 700; letter-spacing: 0.02em;
  padding: 1px 8px; border-radius: 999px; white-space: nowrap;
}
.msg-tpill.msg-tstat-new               { background: var(--blue-dim);   color: var(--blue); }
.msg-tpill.msg-tstat-in_progress       { background: var(--yellow-dim); color: var(--yellow); }
.msg-tpill.msg-tstat-awaiting_response { background: var(--orange-dim); color: var(--orange); }
.msg-tpill.msg-tstat-resolved          { background: var(--green-dim);  color: var(--green); }
.msg-tpill.msg-tstat-cancelled         { background: var(--orange-dim); color: var(--orange); }
/* Urgency pill IS colored (High=Red, Medium=Yellow, Low=Blue) — only the small
   pill, never the whole row. */
.msg-tpill.msg-tprio-high   { background: var(--red-dim);    color: var(--red); }
.msg-tpill.msg-tprio-medium { background: var(--yellow-dim); color: var(--yellow); }
.msg-tpill.msg-tprio-low    { background: var(--blue-dim);   color: var(--blue); }

.msg-compose-urgency-row { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.msg-compose-urgency-select { max-width: 150px; font-size: 13px; padding: 5px 8px; border-radius: var(--radius-sm); }

.msg-detail-task { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 10px; }
.msg-detail-task-field {
  display: flex; flex-direction: column; gap: 3px;
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-dim);
}
.msg-task-select { font-size: 12.5px; font-weight: 600; padding: 4px 26px 4px 9px; border-radius: 999px; border: 1px solid var(--border); }
.msg-task-select.msg-tstat-new               { background: var(--blue-dim);   color: var(--blue); }
.msg-task-select.msg-tstat-in_progress       { background: var(--yellow-dim); color: var(--yellow); }
.msg-task-select.msg-tstat-awaiting_response { background: var(--orange-dim); color: var(--orange); }
.msg-task-select.msg-tstat-resolved          { background: var(--green-dim);  color: var(--green); }
.msg-task-select.msg-tstat-cancelled         { background: var(--orange-dim); color: var(--orange); }
.msg-task-select.msg-tprio-high   { background: var(--red-dim);    color: var(--red); }
.msg-task-select.msg-tprio-medium { background: var(--yellow-dim); color: var(--yellow); }
.msg-task-select.msg-tprio-low    { background: var(--blue-dim);   color: var(--blue); }

/* 'blocked' status (migration 593 — merged Tasks & Requests tab) */
.msg-tpill.msg-tstat-blocked      { background: var(--red-dim); color: var(--red); }
.msg-task-select.msg-tstat-blocked{ background: var(--red-dim); color: var(--red); }

/* Assignee chip + due-date pill on task thread rows (migration 593) */
.msg-task-assignee { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; color: var(--text-secondary); }
.msg-task-avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; border-radius: 50%; background: var(--accent, #c8a97e);
  color: #fff; font-size: 8.5px; font-weight: 700; line-height: 1;
}
/* Unassigned task: muted chip + dashed placeholder avatar. */
.msg-task-assignee--none { color: var(--text-dim); font-style: italic; }
.msg-task-avatar--none { background: transparent; color: var(--text-dim); border: 1px dashed var(--border); }
/* Assignee filter dropdown (task channels) — match the tagged-people select. */
.msg-filter-assignee-wrap { display: inline-flex; }
.msg-filter-assignee-select { font-size: 12px; max-width: 170px; padding: 6px 10px; border-radius: var(--radius-sm); }
/* Due-date chip is NEUTRAL — no due-based color/stripe on the preview row. */
.msg-tpill.msg-due-pill { background: var(--surface-2, rgba(255,255,255,0.06)); color: var(--text-secondary); }
input.msg-task-select.msg-due-overdue { border-color: var(--red); color: var(--red); }
.msg-activity-line strong { color: var(--text-secondary); font-weight: 600; }
