/* ===========================================================================
   Conversations: the Messages list (S4), chat bubbles for direct messages and
   group threads (S3), and the report pages. Tokens only (app.css).
   =========================================================================== */

body.page-plain { background: var(--bg-plain); }
body.page-plain .navbar { background: var(--glass); -webkit-backdrop-filter: blur(20px) saturate(1.8); backdrop-filter: blur(20px) saturate(1.8); }

/* The person in the middle of a DM's navigation bar. */
.nav-title-html { pointer-events: auto; display: flex; justify-content: center; }
.nav-person { display: inline-flex; align-items: center; gap: 8px; max-width: 100%; color: var(--label); font-weight: 600; text-decoration: none; }
.nav-person span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-person:hover { text-decoration: none; }

/* ---- the list ------------------------------------------------------------- */
.dm-list { --sep-inset: 86px; }
.dm-row { align-items: flex-start; padding-left: 4px; }
.dm-row .avatar { margin-top: 2px; }
.dm-dot-col { width: 14px; display: flex; justify-content: center; padding-top: 19px; flex: none; }
.dm-unread .row-title { font-weight: 700; }
.dm-unread .row-sub { color: var(--label); }
.dm-row.is-open { background: var(--tint-soft); }
.dm-help { margin-top: 0; }
.split-list { display: none; }
.split-list .dm-list { margin: 0; }

/* ---- the conversation ------------------------------------------------------- */
.msg-privacy { text-align: center; font-size: var(--fs-footnote); color: var(--label-2); margin: 4px 16px 6px; }
#message-list { padding: 4px 0 8px; display: flex; flex-direction: column; gap: 2px; }

.msg-stamp { text-align: center; font-size: var(--fs-caption); font-weight: 500; color: var(--label-2); margin: 14px 0 6px; }

.msg { display: flex; align-items: flex-end; gap: 8px; max-width: 100%; }
.msg.run { margin-top: 8px; }
.msg.me { justify-content: flex-end; }
.msg-av { width: 30px; flex: none; align-self: flex-start; margin-top: 18px; }
.msg-col { display: flex; flex-direction: column; min-width: 0; max-width: min(78%, 520px); }
.msg.me .msg-col { align-items: flex-end; }
.msg.them .msg-col { align-items: flex-start; }
.msg-who { font-size: var(--fs-caption); color: var(--label-2); margin: 0 0 2px 12px; }

.bubble {
  padding: 8px 13px;
  border-radius: 19px;
  font-size: var(--fs-body);
  line-height: 1.3;
  overflow-wrap: anywhere;
  cursor: pointer;
  -webkit-user-select: text;
  user-select: text;
  position: relative;
}
.msg.them .bubble { background: var(--bubble); color: var(--label); }
.msg.me .bubble { background: var(--tint-fill); color: var(--on-tint); }
/* The tail corner: the last bubble of a run points at its sender. */
.msg.them.run .bubble { border-top-left-radius: 19px; }
.msg.them .bubble { border-bottom-left-radius: 6px; }
.msg.me .bubble { border-bottom-right-radius: 6px; }
.bubble .message-body { white-space: pre-wrap; margin: 0; }
.msg.me .bubble a, .msg.me .bubble .mention { color: var(--on-tint); text-decoration: underline; background: none; }
.bubble .post-image-wrap { margin: 8px -5px -2px; border-radius: 14px; }
.bubble-edit { cursor: default; background: var(--fill) !important; color: var(--label) !important; min-width: min(320px, 70vw); }

.msg-quote {
  display: block;
  max-width: 100%;
  margin: 0 4px 2px;
  padding: 4px 10px;
  border-left: 3px solid var(--sep-opaque);
  font-size: var(--fs-footnote);
  color: var(--label-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-decoration: none;
}

.msg-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 3px 6px 0; }
.msg-time { font-size: var(--fs-caption); color: var(--label-2); font-variant-numeric: tabular-nums; }
.msg.me .msg-meta { justify-content: flex-end; }
.msg.run .msg-time, .msg-time { white-space: nowrap; }
.chip-xs { min-height: 26px; padding: 0 8px; font-size: var(--fs-footnote); border-radius: 13px; }

/* Tap a bubble: its reactions, Reply and "…" menu appear under it. */
.msg-actions { display: none; flex-wrap: wrap; align-items: center; gap: 6px; margin: 6px 0 4px; }
.msg.show-actions .msg-actions, .msg:focus-within .msg-actions { display: flex; }
.msg-react { display: flex; gap: 0; padding: 2px; border-radius: 999px; background: var(--glass-solid); box-shadow: var(--float-shadow), 0 0 0 0.5px var(--glass-edge); }
.msg-actions .post-menu-btn { margin: 0; }
.msg.show-actions .bubble { filter: brightness(0.94); }

/* ---- the message box --------------------------------------------------------- */
.composer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  margin: 0;
  padding: 8px max(12px, env(safe-area-inset-right, 0px)) calc(8px + var(--safe-b)) max(12px, env(safe-area-inset-left, 0px));
  background: var(--glass);
  -webkit-backdrop-filter: blur(20px) saturate(1.8);
  backdrop-filter: blur(20px) saturate(1.8);
  box-shadow: 0 -0.5px 0 var(--sep);
}
.composer > * { max-width: 680px; margin-left: auto; margin-right: auto; }
body:has(.composer) .container { padding-bottom: calc(110px + var(--safe-b)); }
.composer-form { display: flex; align-items: flex-end; gap: 8px; margin: 0; }
.composer-form textarea {
  flex: 1;
  min-height: 40px;
  max-height: 160px;
  padding: 9px 16px;
  border-radius: 20px;
  border: 1px solid var(--sep-opaque);
  background: var(--bg-plain);
  line-height: 1.3;
}
.composer-form .send-btn { width: 40px; height: 40px; min-height: 40px; }
.composer .reply-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin: 0 0 6px;
  padding: 0 4px 0 12px;
  font-size: var(--fs-footnote);
  color: var(--label-2);
}
.composer-note { margin: 4px 8px; text-align: center; color: var(--label-2); font-size: var(--fs-subhead); }
.composer .notice { margin: 0; }
@media (min-width: 1024px) {
  /* Beside the sidebar (and the inbox list, in the split view). */
  .composer { position: sticky; margin: 8px 0 0; border-radius: 22px 22px 0 0; }
  body:has(.composer) .container { padding-bottom: 0; }
  .split-main, body:not(:has(.split)) main.container:has(.composer) { display: flex; flex-direction: column; min-height: calc(100vh - var(--nav-h) - 8px); }
  .split-main #message-list, main.container:has(.composer) > #message-list { flex: 1; }
}

/* ---- report and moderator pages --------------------------------------------- */
.dm-quote { background: var(--fill); border-left: 4px solid var(--sep-opaque); border-radius: 8px; padding: 10px 12px; margin: 0 0 12px; }
.dm-report-form { display: flex; flex-direction: column; gap: 8px; }
.dm-label { font-weight: 600; margin: 6px 0 0; }
.dm-radio { display: flex; align-items: center; gap: 10px; min-height: 44px; font-size: var(--fs-body); }
.dm-radio input { width: 22px; height: 22px; }
.dm-flash { background: var(--tint-soft); color: var(--tint); border-radius: var(--r-inner); padding: 12px 14px; margin: 0 0 12px; font-weight: 600; }
.dm-flash-bad { background: var(--red-soft); color: var(--red); }
.dm-title { margin: 4px 0 12px; }
.dm-report-open { box-shadow: inset 4px 0 0 var(--orange); }
.dm-report-meta { margin: 0 0 8px; }
.dm-status { color: var(--label-2); }
.dm-snaps { border-radius: var(--r-inner); overflow: hidden; margin: 6px 0 10px; background: var(--fill); }
.dm-snap { padding: 8px 12px; font-size: var(--fs-subhead); }
.dm-snap + .dm-snap { border-top: 0.5px solid var(--sep); }
.dm-snap-hit { background: var(--red-soft); }
.dm-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.dm-inline { margin: 0; }
.dm-sub { margin: 22px 0 8px; color: var(--label-2); font-size: var(--fs-footnote); text-transform: uppercase; letter-spacing: 0.02em; }

/* ---- a group thread: the post on top, the comments under it ---------------- */
.msg.op { display: block; margin: 4px 0 2px; }
.op-card { background: var(--card); border-radius: 18px; padding: 14px 16px 10px; box-shadow: 0 0 0 0.5px var(--sep); }
.op-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.op-who { display: flex; flex-direction: column; min-width: 0; }
.op-name { font-weight: 600; }
.op-bubble { padding: 0; border-radius: 0; background: none; color: var(--label); font-size: var(--fs-body); line-height: 1.4; }
.op-bubble .post-image-wrap { margin: 10px 0 0; }
.msg.op .msg-meta { margin: 6px 0 0; }
.msg.op.show-actions .bubble { filter: none; }
.op-count { margin: 14px 4px 2px; font-size: var(--fs-footnote); font-weight: 600; color: var(--label-2); text-transform: uppercase; letter-spacing: 0.02em; }
.op-peek[hidden] { display: none !important; }
.op-peek {
  position: fixed; z-index: 45; left: 0; right: 0; top: calc(var(--nav-h) + var(--safe-t));
  max-width: 680px; margin: 0 auto; display: block; width: 100%;
  padding: 8px 16px; border: 0; border-radius: 0; text-align: left;
  background: var(--glass, var(--card)); color: var(--label);
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
  box-shadow: 0 0.5px 0 var(--sep);
  font: 400 var(--fs-footnote)/1.3 var(--font);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer;
}
.op-peek:hover { background: var(--glass, var(--card)); }
