/* ============================================================
   Astra Origins — Direct Messages (new design) · page styles
   Shared shell lives in cosmos.css. The chat fills the right pane
   and manages its own scroll. Built on the messages reference.
   ============================================================ */

/* The chat must fill the right pane, so neutralise the padded/scrolling
   .t-scroll wrapper (used on both full page and pane swaps) when it holds
   the chat — the .ms-wrap manages its own layout/scroll instead. */
.t-right .t-scroll:has(> .ms-wrap) {
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.ms-wrap {
  flex: 1; min-height: 0;
  display: grid;
  grid-template-columns: 320px 1fr;
  overflow: hidden;
}

/* ── Conversation list ────────────────────────────────── */
.ms-list {
  display: flex; flex-direction: column; min-height: 0;
  border-right: 1px solid var(--line);
  background: var(--surface);
  position: relative;
}
.ms-list-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 14px 10px;
}
.ms-list-title { font-size: 16px; font-weight: 800; letter-spacing: -0.01em; display: flex; align-items: center; gap: 8px; }
.ms-unread { font-size: 9px; font-weight: 800; color: white; background: var(--accent); padding: 2px 7px; border-radius: 999px; }
.ms-new { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; color: var(--ink-2); background: var(--surface-2); border: 1px solid var(--line); cursor: pointer; }
.ms-new:hover { background: var(--accent-soft); color: var(--accent); }
.ms-search {
  display: flex; align-items: center; gap: 8px;
  margin: 0 14px 10px; padding: 8px 12px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 9px;
  color: var(--ink-3);
}
.ms-search input { flex: 1; min-width: 0; border: none; outline: none; background: none; font-size: 12px; color: var(--ink); }

.ms-threads { list-style: none; padding: 6px; margin: 0; overflow: auto; flex: 1; min-height: 0; }
.ms-threads-empty { padding: 24px 12px; text-align: center; font-size: 10px; letter-spacing: 0.14em; color: var(--ink-3); }
.ms-thread {
  display: grid; grid-template-columns: 44px 1fr auto; gap: 11px; align-items: center;
  width: 100%; text-align: left;
  padding: 10px; border-radius: 10px;
  border: 1px solid transparent; cursor: pointer; background: none;
}
.ms-thread:hover { background: var(--surface-2); }
.ms-thread.is-active { background: var(--accent-soft); border-color: var(--accent-line); }
.ms-thread-li { position: relative; }
.ms-thread-menu {
  position: absolute; top: 8px; right: 8px; z-index: 2;
  width: 24px; height: 24px; border-radius: 6px; padding: 0; border: 0; cursor: pointer;
  display: grid; place-items: center; font-size: 11px;
  color: var(--ink-2); background: var(--surface); box-shadow: 0 1px 5px oklch(0 0 0 / 0.18);
  opacity: 0; transition: opacity 0.12s ease;
}
.ms-thread-li:hover .ms-thread-menu { opacity: 1; }
.ms-thread-menu:hover { background: var(--surface-2); color: var(--ink); }
.ms-av {
  position: relative; overflow: hidden;
  width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center;
  color: white; font-size: 13px; font-weight: 800;
  background: linear-gradient(135deg, oklch(0.55 0.16 250), oklch(0.34 0.12 265));
  box-shadow: inset -3px -4px 10px oklch(0 0 0 / 0.25);
  flex-shrink: 0;
}
.ms-av img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.ms-av.sm { width: 38px; height: 38px; font-size: 12px; }
.ms-av.xs { width: 28px; height: 28px; font-size: 10px; align-self: flex-end; }
.ms-thread-body { min-width: 0; }
.ms-thread-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.ms-thread-name { font-size: 13px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ms-thread-time { font-size: 9px; color: var(--ink-3); flex-shrink: 0; }
.ms-thread-prev { font-size: 11px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 3px; display: block; }
.ms-badge { align-self: center; font-size: 9px; font-weight: 800; color: white; background: var(--accent); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; display: grid; place-items: center; }
.ms-badge[hidden] { display: none; }

/* New-message recipient picker */
.ms-newbox { margin: 0 14px 10px; padding: 10px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; }
.ms-newbox[hidden] { display: none; }
.ms-newbox-head { display: flex; align-items: center; justify-content: space-between; font-size: 11px; font-weight: 800; letter-spacing: 0.06em; color: var(--ink-2); margin-bottom: 8px; }
.ms-newbox-head button { color: var(--ink-3); background: none; border: 0; cursor: pointer; }
.ms-newbox-search { margin: 0 0 8px; }
.ms-userresults { list-style: none; margin: 0; padding: 0; max-height: 260px; overflow: auto; }
.ms-userresults li { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 8px; cursor: pointer; }
.ms-userresults li:hover, .ms-userresults li.is-active { background: var(--accent-soft); }
.ms-userresults .nm { font-size: 12px; font-weight: 700; }
.ms-userresults .un { font-size: 10px; color: var(--ink-3); }

/* ── Chat thread ──────────────────────────────────────── */
.ms-chat-host { display: flex; flex-direction: column; min-height: 0; }
.ms-chat { display: flex; flex-direction: column; min-height: 0; flex: 1; background: var(--bg); }
.ms-chat-head {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.ms-back { display: none; width: 34px; height: 34px; border-radius: 8px; place-items: center; color: var(--ink-2); background: var(--surface-2); border: 1px solid var(--line); cursor: pointer; }
.ms-chat-who { display: flex; align-items: center; gap: 11px; min-width: 0; flex: 1; }
.ms-chat-name { font-size: 14px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ms-chat-status { font-size: 9px; color: var(--ink-3); letter-spacing: 0.08em; margin-top: 3px; }
.ms-chat-tools { display: flex; gap: 4px; }
.ms-chat-tools button { width: 34px; height: 34px; border-radius: 8px; display: grid; place-items: center; color: var(--ink-2); background: none; border: 0; cursor: pointer; }
.ms-chat-tools button:hover:not(:disabled) { background: var(--surface-2); color: var(--ink); }
.ms-chat-tools button:disabled { opacity: 0.4; cursor: not-allowed; }

/* In-conversation search bar + hit highlighting */
.ms-chat-search { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--line); background: var(--surface); }
.ms-chat-search[hidden] { display: none; }
.ms-chat-search > i { color: var(--ink-3); font-size: 13px; }
.ms-chat-search input { flex: 1; min-width: 0; border: 0; outline: none; background: none; font-size: 13px; color: var(--ink); }
.ms-search-count { font-size: 10px; color: var(--ink-3); min-width: 36px; text-align: center; }
.ms-chat-search button { width: 28px; height: 28px; border-radius: 6px; display: grid; place-items: center; background: none; border: 0; color: var(--ink-2); cursor: pointer; flex-shrink: 0; }
.ms-chat-search button:hover { background: var(--surface-2); color: var(--ink); }
mark.ms-hl { background: #ffe264; color: #222; border-radius: 2px; padding: 0; }
mark.ms-hl.is-current { background: #ff9f45; }

.ms-feed {
  flex: 1; min-height: 0; overflow: auto;
  padding: 18px 18px 8px;
  display: flex; flex-direction: column; gap: 10px;
  background:
    radial-gradient(ellipse at 80% 0%, oklch(0.55 0.1 265 / 0.05), transparent 50%),
    radial-gradient(ellipse at 10% 100%, oklch(0.55 0.1 220 / 0.05), transparent 50%);
}
.ms-feed-start { align-self: center; font-size: 8px; color: var(--ink-3); letter-spacing: 0.16em; font-weight: 800; padding: 4px 12px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); margin-bottom: 4px; }

.ms-row { display: flex; align-items: flex-end; gap: 8px; max-width: 78%; }
.ms-row.in { align-self: flex-start; }
.ms-row.out { align-self: flex-end; flex-direction: row-reverse; }
.ms-bubble {
  position: relative;
  font-size: 13px; line-height: 1.5;
  padding: 10px 13px; border-radius: 16px;
  max-width: 100%; min-width: 0;
}
.ms-row.in .ms-bubble { background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 5px; color: var(--ink); }
.ms-row.out .ms-bubble { background: var(--accent); color: white; border-bottom-right-radius: 5px; }
.ms-text { overflow-wrap: break-word; word-break: break-word; white-space: pre-wrap; }
.ms-text a { color: inherit; text-decoration: underline; }
/* Mentions render as a clear pill so they stand out in both bubble colours. */
.ms-text a.tagged-user, .ms-row.in .ms-text a.tagged-user {
  color: var(--accent); font-weight: 700; text-decoration: none;
  background: var(--accent-soft); border-radius: 4px; padding: 0 3px;
}
.ms-row.out .ms-text a.tagged-user { color: #fff; background: oklch(1 0 0 / 0.24); }
.ms-time { display: block; text-align: right; font-size: 8px; opacity: 0.7; letter-spacing: 0.06em; margin-top: 4px; }
.ms-row.in .ms-time { color: var(--ink-3); }
.ms-read { color: oklch(0.85 0.12 200); }
/* Optimistic / failed send states */
.ms-pending { opacity: 0.6; }
.ms-row.out[data-pending="1"] .ms-bubble { opacity: 0.92; }
.ms-failed { color: oklch(0.7 0.2 25); }
.ms-row.out[data-failed="1"] .ms-bubble { cursor: pointer; opacity: 0.9; }
.ms-row.out[data-failed="1"] .ms-time { color: oklch(0.7 0.2 25); }

/* media inside a bubble */
.ms-media { display: block; margin-bottom: 6px; border-radius: 12px; overflow: hidden; max-width: 320px; cursor: pointer; padding: 0; border: 0; }
.ms-media img { display: block; max-width: 100%; max-height: 360px; object-fit: cover; }
.ms-media-video { position: relative; width: 320px; max-width: 100%; background: #000; }
.ms-media-video video { display: block; width: 100%; max-height: 360px; object-fit: cover; pointer-events: none; }
.ms-media-play { position: absolute; inset: 0; display: grid; place-items: center; }
.ms-media-play i { font-size: 26px; color: #fff; width: 52px; height: 52px; display: grid; place-items: center; background: oklch(0 0 0 / 0.45); border-radius: 50%; backdrop-filter: blur(2px); }

/* fullscreen media lightbox */
.ms-lightbox { position: fixed; inset: 0; z-index: 4000; display: none; align-items: center; justify-content: center; padding: 32px; background: oklch(0 0 0 / 0.86); backdrop-filter: blur(4px); }
.ms-lightbox.is-open { display: flex; }
.ms-lightbox-stage { display: flex; align-items: center; justify-content: center; max-width: 94vw; max-height: 88vh; }
.ms-lightbox-stage img, .ms-lightbox-stage video { max-width: 94vw; max-height: 88vh; border-radius: 10px; box-shadow: 0 24px 70px oklch(0 0 0 / 0.6); }
.ms-lightbox-close { position: absolute; top: 18px; right: 22px; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-size: 18px; color: #fff; background: oklch(1 0 0 / 0.14); border: 1px solid oklch(1 0 0 / 0.28); cursor: pointer; }
.ms-lightbox-close:hover { background: oklch(1 0 0 / 0.26); }

/* Media bubbles: shrink the coloured padding so the media nearly fills it. */
.ms-bubble.ms-has-media { padding: 3px; }
.ms-bubble.ms-has-media .ms-media { margin-bottom: 0; border-radius: 13px; }
.ms-bubble.ms-has-media .ms-text { padding: 5px 8px 0; }
.ms-bubble.ms-has-media .ms-time { padding: 1px 8px 3px; }

/* ── Message actions (hover caret + menu) ─────────────────── */
.ms-msg-caret {
  position: absolute; top: 4px; right: 5px; z-index: 3;
  width: 22px; height: 22px; padding: 0; border: 0; border-radius: 6px;
  display: grid; place-items: center; cursor: pointer; font-size: 11px;
  opacity: 0; transition: opacity 0.12s ease; background: transparent; color: inherit;
}
.ms-row:hover .ms-msg-caret { opacity: 0.9; }
.ms-msg-caret:hover { opacity: 1; }
.ms-row.in .ms-msg-caret { background: var(--surface-2); color: var(--ink-2); }
.ms-row.out .ms-msg-caret { background: oklch(1 0 0 / 0.2); color: #fff; }
.ms-bubble.ms-has-media .ms-msg-caret { background: oklch(0 0 0 / 0.5); color: #fff; }
.ms-row[data-pending="1"] .ms-msg-caret,
.ms-row[data-failed="1"] .ms-msg-caret,
.ms-deleted .ms-msg-caret { display: none; }

.ms-msg-menu {
  z-index: 4100; min-width: 184px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 12px 30px oklch(0 0 0 / 0.25); padding: 5px;
}
.ms-msg-menu button {
  display: flex; align-items: center; gap: 9px; width: 100%; text-align: left;
  padding: 9px 11px; border: 0; background: none; cursor: pointer; border-radius: 7px;
  font-size: 12.5px; color: var(--ink); font-family: inherit;
}
.ms-msg-menu button:hover { background: var(--surface-2); }
.ms-msg-menu button[data-msg-act="del-all"], .ms-msg-menu button.danger { color: oklch(0.6 0.2 25); }
.ms-msg-menu button i { font-size: 13px; }
.ms-msg-confirm { padding: 8px 10px; }
.ms-msg-confirm > span { display: block; font-size: 12px; color: var(--ink-2); margin-bottom: 8px; }
.ms-msg-confirm-btns { display: flex; gap: 6px; }
.ms-msg-confirm-btns button { flex: 1; justify-content: center; padding: 7px; border-radius: 7px; border: 1px solid var(--line); background: var(--surface-2); font-size: 12px; cursor: pointer; color: var(--ink); }
.ms-msg-confirm-btns button.danger { background: oklch(0.6 0.2 25); color: #fff; border-color: transparent; }

/* Tombstone (deleted for everyone) */
.ms-deleted .ms-bubble { opacity: 0.9; }
.ms-deleted-text { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-style: italic; opacity: 0.85; }
.ms-deleted-text i { font-size: 13px; }

/* Toast (copy / errors) */
.ms-toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(8px);
  background: oklch(0.2 0.02 250); color: #fff; font-size: 12px; font-weight: 600;
  padding: 8px 16px; border-radius: 999px; z-index: 5000; opacity: 0; pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.ms-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* document attachment */
.ms-att { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; }
.ms-att-ic { width: 34px; height: 34px; border-radius: 8px; display: grid; place-items: center; background: oklch(1 0 0 / 0.18); font-size: 16px; flex-shrink: 0; }
.ms-row.in .ms-att-ic { background: var(--surface-2); color: var(--accent); }
.ms-att-body { min-width: 0; }
.ms-att-name { font-size: 12px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; }
.ms-att-meta { font-size: 8px; opacity: 0.85; letter-spacing: 0.08em; margin-top: 2px; }
.ms-att-dl { margin-left: auto; font-size: 14px; opacity: 0.85; }

/* link preview card (added by messages.js, like the feed) — a compact, clear
   light card that stays legible on both incoming and outgoing (blue) bubbles. */
.ms-link-preview { display: block; margin-top: 8px; max-width: 260px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); background: var(--surface); color: var(--ink); text-decoration: none; }
.ms-link-preview img { width: 100%; height: 110px; object-fit: cover; display: block; }
.ms-lp-body { padding: 7px 9px; }
.ms-lp-title { font-size: 11.5px; font-weight: 700; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ms-lp-desc { font-size: 10px; color: var(--ink-3); margin-top: 2px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ms-lp-host { font-size: 9px; color: var(--ink-3); margin-top: 3px; letter-spacing: 0.04em; }

/* ── Composer ─────────────────────────────────────────── */
.ms-composer { position: relative; border-top: 1px solid var(--line); background: var(--surface); padding: 10px 14px; }
.ms-composer-row { display: flex; align-items: flex-end; gap: 6px; }
.ms-c-btn { width: 36px; height: 36px; border-radius: 9px; display: grid; place-items: center; color: var(--ink-2); flex-shrink: 0; background: none; border: 0; cursor: pointer; }
.ms-c-btn:hover { background: var(--surface-2); color: var(--ink); }
.ms-c-btn.is-on { background: var(--accent-soft); color: var(--accent); }
/* Input + a highlight "mirror" layer behind it: the textarea's own text is made
   transparent (caret stays visible) and the mirror renders the same text with
   confirmed @mentions highlighted, kept perfectly aligned (same font/padding). */
.ms-input-wrap {
  position: relative; flex: 1; min-width: 0;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 18px;
}
.ms-input-wrap:focus-within { background: var(--surface); border-color: var(--accent-line); }
.ms-c-input, .ms-input-mirror {
  font-family: inherit; font-size: 13px; line-height: 1.4;
  padding: 9px 16px; box-sizing: border-box;
  white-space: pre-wrap; overflow-wrap: break-word; word-break: break-word;
}
.ms-c-input {
  display: block; width: 100%; resize: none; max-height: 120px; overflow-y: auto;
  background: transparent; border: 0; outline: none; position: relative; z-index: 2;
  color: transparent; -webkit-text-fill-color: transparent; caret-color: var(--ink);
}
.ms-c-input::placeholder { color: var(--ink-3); -webkit-text-fill-color: var(--ink-3); }
.ms-input-mirror {
  position: absolute; inset: 0; z-index: 1; margin: 0; max-height: 120px;
  color: var(--ink); overflow: hidden; pointer-events: none;
}
/* Mirror highlight must NOT change text width (no bold / padding / letter-spacing)
   or the real textarea caret drifts out of alignment — colour + background only. */
.ms-mention-hl { color: var(--accent); background: var(--accent-soft); border-radius: 3px; }
.ms-c-send { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: white; flex-shrink: 0; border: 0; cursor: pointer; }
.ms-c-send:hover { filter: brightness(0.95); }
.ms-c-send:disabled { opacity: 0.5; cursor: default; }

/* pending attachment preview */
.ms-attach-preview { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; padding: 8px 10px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; }
.ms-attach-preview[hidden] { display: none; }
.ms-attach-info { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--ink-2); min-width: 0; flex: 1; }
.ms-attach-info img { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; }
.ms-attach-info .nm { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ms-attach-remove { color: var(--ink-3); background: none; border: 0; cursor: pointer; }
.ms-attach-remove:hover { color: var(--accent); }

/* @mention dropdown */
.ms-mention { position: absolute; left: 14px; right: 14px; bottom: 58px; z-index: 30; list-style: none; margin: 0; padding: 6px; max-height: 240px; overflow: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 30px oklch(0 0 0 / 0.25); }
.ms-mention[hidden] { display: none; }
.ms-mention li { display: flex; align-items: center; gap: 9px; padding: 7px 8px; border-radius: 8px; cursor: pointer; }
.ms-mention li:hover, .ms-mention li.is-active { background: var(--accent-soft); }
.ms-mention .av { width: 28px; height: 28px; border-radius: 50%; overflow: hidden; display: grid; place-items: center; background: linear-gradient(135deg, oklch(0.55 0.16 250), oklch(0.34 0.12 265)); color: white; font-size: 10px; font-weight: 800; flex-shrink: 0; }
.ms-mention .av img { width: 100%; height: 100%; object-fit: cover; }
.ms-mention .nm { font-size: 12px; font-weight: 700; }
.ms-mention .un { font-size: 10px; color: var(--ink-3); }

/* emoji panel */
.ms-emoji-panel { position: absolute; right: 14px; bottom: 58px; z-index: 30; width: 300px; max-width: calc(100% - 28px); background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 30px oklch(0 0 0 / 0.25); overflow: hidden; }
.ms-emoji-panel[hidden] { display: none; }
.ms-emoji-tabs { display: flex; gap: 2px; padding: 6px; border-bottom: 1px solid var(--line); }
.ms-emoji-tabs button { flex: 1; padding: 6px; border-radius: 7px; font-size: 16px; background: none; border: 0; cursor: pointer; }
.ms-emoji-tabs button.is-on { background: var(--accent-soft); }
.ms-emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; padding: 8px; max-height: 210px; overflow: auto; }
.ms-emoji-grid button { font-size: 18px; padding: 4px; border-radius: 6px; background: none; border: 0; cursor: pointer; }
.ms-emoji-grid button:hover { background: var(--surface-2); }

/* ── Empty state ──────────────────────────────────────── */
.ms-chat-empty { align-items: center; justify-content: center; background: var(--bg); }
.ms-empty-inner { text-align: center; max-width: 320px; padding: 30px; }
.ms-empty-orb { width: 72px; height: 72px; border-radius: 50%; display: grid; place-items: center; margin: 0 auto 16px; font-size: 30px; color: var(--accent); background: var(--accent-soft); border: 1px solid var(--accent-line); }
.ms-empty-title { font-size: 18px; font-weight: 800; margin: 0 0 6px; }
.ms-empty-sub { font-size: 13px; color: var(--ink-3); margin: 0 0 16px; line-height: 1.5; }
.ms-empty-btn { display: inline-flex; align-items: center; gap: 8px; font-size: 11px; font-weight: 800; letter-spacing: 0.08em; color: white; background: var(--accent); border: 0; border-radius: 999px; padding: 9px 16px; cursor: pointer; }

/* ── Custom scrollbars ────────────────────────────────────
   Subtle, surface-matched bars for the chat's inner scroll areas
   (conversation list + message feed + the two pickers), so they blend
   with the panel instead of the bold light bars used by the main panes. */
.ms-threads,
.ms-feed,
.ms-userresults,
.ms-emoji-grid {
  scrollbar-width: thin;
  scrollbar-color: var(--line-2) transparent;
}
.ms-threads::-webkit-scrollbar,
.ms-feed::-webkit-scrollbar,
.ms-userresults::-webkit-scrollbar,
.ms-emoji-grid::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
.ms-threads::-webkit-scrollbar-track,
.ms-feed::-webkit-scrollbar-track,
.ms-userresults::-webkit-scrollbar-track,
.ms-emoji-grid::-webkit-scrollbar-track {
  background: transparent;
  margin: 4px 0;
}
.ms-threads::-webkit-scrollbar-thumb,
.ms-feed::-webkit-scrollbar-thumb,
.ms-userresults::-webkit-scrollbar-thumb,
.ms-emoji-grid::-webkit-scrollbar-thumb {
  background: var(--line-2);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
  transition: background 200ms ease;
}
.ms-threads:hover::-webkit-scrollbar-thumb,
.ms-feed:hover::-webkit-scrollbar-thumb,
.ms-userresults:hover::-webkit-scrollbar-thumb,
.ms-emoji-grid:hover::-webkit-scrollbar-thumb {
  background: var(--ink-3);
  background-clip: padding-box;
}
.ms-threads::-webkit-scrollbar-corner,
.ms-feed::-webkit-scrollbar-corner,
.ms-userresults::-webkit-scrollbar-corner,
.ms-emoji-grid::-webkit-scrollbar-corner {
  background: transparent;
}

/* ── Responsive ───────────────────────────────────────── */
@media (max-width: 900px) {
  .ms-wrap { grid-template-columns: 1fr; }
  /* Single column: list by default; .show-chat reveals the conversation. */
  .ms-wrap .ms-chat-host { display: none; }
  .ms-wrap.show-chat .ms-list { display: none; }
  .ms-wrap.show-chat .ms-chat-host { display: flex; }
  .ms-back { display: grid; }
  .ms-row { max-width: 88%; }
}
