/* =========================================================
   PITCH. — DIRECT MESSAGES V2
   ========================================================= */

[hidden] {
  display: none !important;
}

:root {
  --messages-bg: #05070a;
  --messages-surface: rgba(8, 12, 17, 0.9);
  --messages-surface-strong: rgba(11, 16, 22, 0.96);
  --messages-surface-soft: rgba(255, 255, 255, 0.035);
  --messages-border: rgba(255, 255, 255, 0.075);
  --messages-border-soft: rgba(255, 255, 255, 0.05);
  --messages-text: #f3f7f9;
  --messages-muted: #7d8997;
  --messages-faint: #505b67;
  --messages-green: #00ff66;
  --messages-green-soft: rgba(0, 255, 102, 0.1);
}

.messages-page {
  overflow-x: hidden;
  background: var(--messages-bg);
}

.messages-page svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.messages-page button,
.messages-page input,
.messages-page textarea {
  font: inherit;
}

.messages-shell {
  position: relative;
  min-height: calc(100vh - 76px);
  padding: 36px 0 72px;
}

.messages-shell::before {
  position: absolute;
  z-index: -1;
  top: -180px;
  left: 50%;
  width: min(1200px, 100vw);
  height: 720px;
  content: "";
  transform: translateX(-50%);
  pointer-events: none;
  background:
    radial-gradient(circle at 72% 16%, rgba(0, 255, 102, 0.065), transparent 31%),
    radial-gradient(circle at 24% 28%, rgba(255, 255, 255, 0.025), transparent 25%);
}

.messages-container {
  width: min(calc(100% - 40px), 1380px);
}

.messages-layout {
  min-height: 700px;
  display: grid;
  grid-template-columns: 390px minmax(0, 1fr);
  overflow: hidden;
  background: var(--messages-surface);
  border: 1px solid var(--messages-border);
  border-radius: 24px;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(24px);
}

/* Sidebar */
.messages-sidebar {
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.012), transparent 24%);
  border-right: 1px solid var(--messages-border-soft);
}

.messages-sidebar__head {
  min-height: 88px;
  padding: 18px 18px 17px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--messages-border-soft);
}

.messages-title {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.messages-title__meta {
  color: rgba(255, 255, 255, 0.3);
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.01em;
}

.messages-sidebar h1 {
  margin: 0;
  color: var(--messages-text);
  font-size: 23px;
  font-weight: 780;
  letter-spacing: -0.035em;
}

.messages-new {
  width: 43px;
  height: 43px;
  display: grid;
  place-items: center;
  flex: 0 0 43px;
  color: rgba(255, 255, 255, 0.78);
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid var(--messages-border);
  border-radius: 13px;
  outline: none;
  cursor: pointer;
  transition: transform 160ms ease, color 160ms ease, background 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.messages-new svg {
  width: 18px;
  height: 18px;
}

.messages-new:hover,
.messages-new[aria-expanded="true"] {
  color: #07120c;
  background: var(--messages-green);
  border-color: var(--messages-green);
  box-shadow: 0 10px 28px rgba(0, 255, 102, 0.14);
  transform: translateY(-1px);
}

.messages-new:focus-visible,
.chat-back:focus-visible,
.chat-profile-link:focus-visible,
.chat-jump:focus-visible,
.chat-compose button:focus-visible,
.chat-empty__action:focus-visible,
.messages-search__head button:focus-visible {
  outline: 2px solid rgba(0, 255, 102, 0.65);
  outline-offset: 2px;
}

/* User search */
.messages-search {
  padding: 15px 14px 14px;
  background: rgba(255, 255, 255, 0.014);
  border-bottom: 1px solid var(--messages-border-soft);
  animation: messagesSearchIn 180ms ease both;
}

.messages-search__head {
  min-height: 26px;
  margin: 0 2px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.messages-search__head label {
  color: rgba(255, 255, 255, 0.57);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.035em;
}

.messages-search__head button {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  color: var(--messages-muted);
  background: transparent;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}

.messages-search__head button:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.045);
}

.messages-search__head button svg {
  width: 15px;
  height: 15px;
}

.messages-search__field {
  height: 44px;
  padding: 0 12px;
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.026);
  border: 1px solid var(--messages-border);
  border-radius: 12px;
  transition: border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.messages-search__field:focus-within {
  background: rgba(255, 255, 255, 0.038);
  border-color: rgba(0, 255, 102, 0.28);
  box-shadow: 0 0 0 3px rgba(0, 255, 102, 0.045);
}

.messages-search__field > svg {
  width: 16px;
  height: 16px;
  color: var(--messages-faint);
}

.messages-search input {
  width: 100%;
  min-width: 0;
  height: 42px;
  padding: 0;
  color: var(--messages-text);
  background: transparent;
  border: 0;
  outline: 0;
  font-size: 13px;
}

.messages-search input::placeholder {
  color: rgba(255, 255, 255, 0.26);
}

.messages-search__results {
  max-height: 250px;
  margin-top: 7px;
  overflow: auto;
}

/* Conversations */
.conversation-list {
  min-height: 0;
  flex: 1;
  overflow-y: auto;
  padding: 9px 10px 12px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.11) transparent;
}

.conversation-item,
.message-search-user {
  position: relative;
  width: 100%;
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  color: inherit;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 15px;
  outline: none;
  cursor: pointer;
  text-align: left;
  transition: background 150ms ease, border-color 150ms ease, transform 150ms ease;
}

.conversation-item + .conversation-item {
  margin-top: 4px;
}

.conversation-item:hover,
.message-search-user:hover {
  background: rgba(255, 255, 255, 0.032);
  border-color: rgba(255, 255, 255, 0.04);
}

.conversation-item.is-active {
  background:
    linear-gradient(90deg, rgba(0, 255, 102, 0.085), rgba(0, 255, 102, 0.018) 68%, transparent),
    rgba(255, 255, 255, 0.018);
  border-color: rgba(0, 255, 102, 0.13);
}

.conversation-item.is-active::before {
  position: absolute;
  top: 12px;
  bottom: 12px;
  left: -1px;
  width: 3px;
  content: "";
  background: var(--messages-green);
  border-radius: 999px;
  box-shadow: 0 0 14px rgba(0, 255, 102, 0.4);
}

.conversation-item.is-unread .conversation-top strong {
  color: rgba(255, 255, 255, 0.96);
}

.conversation-item.is-unread .conversation-preview {
  color: rgba(255, 255, 255, 0.74);
}

.message-avatar,
.chat-user__avatar {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  overflow: hidden;
  color: rgba(245, 250, 247, 0.9);
  background:
    radial-gradient(circle at 28% 22%, rgba(0, 255, 102, 0.11), transparent 38%),
    linear-gradient(145deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.025));
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: -0.02em;
}

.message-avatar img,
.chat-user__avatar img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.conversation-copy {
  min-width: 0;
  display: grid;
  gap: 6px;
}

.conversation-top {
  min-width: 0;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.conversation-top strong {
  min-width: 0;
  overflow: hidden;
  color: rgba(255, 255, 255, 0.92);
  font-size: 14px;
  font-weight: 760;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-top time {
  flex: 0 0 auto;
  color: rgba(255, 255, 255, 0.34);
  font-size: 12px;
}

.conversation-preview {
  overflow: hidden;
  color: rgba(255, 255, 255, 0.5);
  font-size: 12px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-unread {
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  display: grid;
  place-items: center;
  color: #041009;
  background: var(--messages-green);
  border-radius: 999px;
  box-shadow: 0 4px 14px rgba(0, 255, 102, 0.15);
  font-size: 11px;
  font-weight: 950;
}

.message-search-user {
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 10px;
  padding: 9px;
}

.message-search-user .message-avatar {
  width: 42px;
  height: 42px;
  border-radius: 13px;
}

.message-search-user strong {
  display: block;
  overflow: hidden;
  color: rgba(255, 255, 255, 0.92);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message-search-user small {
  color: rgba(255, 255, 255, 0.4);
  font-size: 12px;
}

.messages-state {
  min-height: 150px;
  padding: 34px 18px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 10px;
  color: rgba(255, 255, 255, 0.44);
  font-size: 12px;
  line-height: 1.6;
  text-align: center;
}

.messages-state--compact {
  min-height: 78px;
  padding: 18px 12px;
}

.messages-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255, 255, 255, 0.08);
  border-top-color: var(--messages-green);
  border-radius: 50%;
  animation: messagesSpin 700ms linear infinite;
}

/* Chat */
.chat-panel {
  min-width: 0;
  background:
    radial-gradient(circle at 75% 0%, rgba(0, 255, 102, 0.035), transparent 32%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.006), transparent 18%),
    rgba(3, 5, 8, 0.38);
}

.chat-empty {
  min-height: 700px;
  padding: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  text-align: center;
}

.chat-empty__icon {
  position: relative;
  width: 72px;
  height: 72px;
  margin-bottom: 24px;
  display: grid;
  place-items: center;
  color: var(--messages-green);
  background: rgba(0, 255, 102, 0.055);
  border: 1px solid rgba(0, 255, 102, 0.11);
  border-radius: 22px;
  box-shadow: 0 22px 70px rgba(0, 255, 102, 0.065);
}

.chat-empty__icon::after {
  position: absolute;
  inset: 12px;
  content: "";
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 14px;
}

.chat-empty__icon svg {
  position: relative;
  z-index: 1;
  width: 31px;
  height: 31px;
}

.chat-empty strong {
  color: var(--messages-text);
  font-size: 22px;
  font-weight: 780;
  letter-spacing: -0.035em;
}

.chat-empty p {
  max-width: 430px;
  margin: 10px 0 0;
  color: rgba(255, 255, 255, 0.46);
  font-size: 13px;
  line-height: 1.7;
}

.chat-empty__action {
  min-height: 44px;
  margin-top: 22px;
  padding: 0 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--messages-green);
  background: rgba(0, 255, 102, 0.055);
  border: 1px solid rgba(0, 255, 102, 0.16);
  border-radius: 12px;
  font-size: 12px;
  font-weight: 820;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.chat-empty__action:hover {
  color: #07120c;
  background: var(--messages-green);
  border-color: var(--messages-green);
  transform: translateY(-1px);
  box-shadow: 0 12px 30px rgba(0, 255, 102, 0.12);
}

.chat-empty__action svg {
  width: 15px;
  height: 15px;
}

.chat-view {
  --chat-content-width: 900px;
  --chat-content-gutter: 26px;
  height: 700px;
  display: grid;
  grid-template-rows: 78px minmax(0, 1fr) auto;
}

.chat-head {
  min-width: 0;
  padding: 0 22px;
  display: flex;
  align-items: center;
  gap: 11px;
  background: rgba(8, 12, 17, 0.46);
  border-bottom: 1px solid var(--messages-border-soft);
  backdrop-filter: blur(14px);
}

.chat-back {
  display: none;
}

.chat-user {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 11px;
  color: inherit;
  text-decoration: none;
}

.chat-user__avatar {
  width: 43px;
  height: 43px;
  flex: 0 0 43px;
  border-radius: 14px;
}

.chat-user__copy {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.chat-user strong {
  display: block;
  overflow: hidden;
  color: var(--messages-text);
  font-size: 14px;
  font-weight: 760;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-user__meta {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  overflow: hidden;
  color: rgba(255, 255, 255, 0.42);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-user__presence {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: rgba(255, 255, 255, 0.38);
}

.chat-user__presence.is-online {
  color: rgba(0, 255, 102, 0.78);
}

.chat-user__presence-dot {
  width: 6px;
  height: 6px;
  flex: 0 0 6px;
  background: rgba(255, 255, 255, 0.24);
  border-radius: 50%;
}

.chat-user__presence.is-online .chat-user__presence-dot {
  background: var(--messages-green);
  box-shadow: 0 0 9px rgba(0, 255, 102, 0.34);
}

.chat-user__separator {
  color: rgba(255, 255, 255, 0.16);
}

.chat-profile-link {
  width: 38px;
  height: 38px;
  margin-left: auto;
  display: grid;
  place-items: center;
  flex: 0 0 38px;
  color: rgba(255, 255, 255, 0.46);
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid rgba(255, 255, 255, 0.055);
  border-radius: 11px;
  text-decoration: none;
  transition: color 150ms ease, background 150ms ease, border-color 150ms ease;
}

.chat-profile-link:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.045);
  border-color: rgba(255, 255, 255, 0.085);
}

.chat-profile-link svg {
  width: 17px;
  height: 17px;
}

.chat-body {
  position: relative;
  min-height: 0;
  overflow: hidden;
}

.chat-messages {
  height: 100%;
  min-height: 0;
  overflow-y: auto;
  padding: 22px max(var(--chat-content-gutter), calc((100% - var(--chat-content-width)) / 2)) 13px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.11) transparent;
}

/* Keep short conversations close to the composer while preserving normal
   scrolling once the history is taller than the viewport. */
.chat-messages::before {
  min-height: 0;
  margin-top: auto;
  content: "";
  flex: 0 0 auto;
}

.chat-day {
  position: relative;
  width: 100%;
  margin: 12px 0 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.22);
  font-size: 11px;
  font-weight: 760;
  letter-spacing: 0.045em;
  text-transform: uppercase;
}

.chat-day::before,
.chat-day::after {
  width: min(90px, 14%);
  height: 1px;
  margin: 0 10px;
  content: "";
  background: rgba(255, 255, 255, 0.032);
}

.chat-message {
  position: relative;
  max-width: min(68%, 540px);
  padding: 9px 11px 7px;
  align-self: flex-start;
  color: rgba(255, 255, 255, 0.9);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.062);
  border-radius: 15px 15px 15px 6px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
}

.chat-message.is-own {
  align-self: flex-end;
  background: linear-gradient(145deg, rgba(0, 255, 102, 0.095), rgba(0, 255, 102, 0.045));
  border-color: rgba(0, 255, 102, 0.11);
  border-radius: 15px 15px 6px 15px;
}

.chat-message.is-grouped {
  margin-top: -2px;
}

.chat-message.is-new {
  animation: messageIn 220ms cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

.chat-message__body {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 12.5px;
  line-height: 1.45;
}

.chat-message__meta {
  min-height: 12px;
  margin-top: 4px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
  color: rgba(255, 255, 255, 0.38);
  font-size: 11px;
  line-height: 1;
}

.chat-message__read {
  color: var(--messages-green);
}

.chat-jump {
  position: absolute;
  right: max(var(--chat-content-gutter), calc((100% - var(--chat-content-width)) / 2));
  bottom: 14px;
  z-index: 4;
  min-height: 34px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: rgba(255, 255, 255, 0.86);
  background: rgba(12, 17, 23, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 999px;
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.32);
  font-size: 11px;
  font-weight: 760;
  cursor: pointer;
  backdrop-filter: blur(12px);
  animation: messageIn 180ms ease both;
}

.chat-jump:hover {
  color: #fff;
  border-color: rgba(0, 255, 102, 0.2);
}

.chat-jump svg {
  width: 13px;
  height: 13px;
  color: var(--messages-green);
}

/* Composer */
.chat-compose {
  width: auto;
  margin: 0 max(var(--chat-content-gutter), calc((100% - var(--chat-content-width)) / 2)) 18px;
  padding: 7px 7px 7px 15px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  align-items: end;
  gap: 8px;
  background: rgba(12, 17, 23, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.085);
  border-radius: 16px;
  box-shadow: 0 14px 38px rgba(0, 0, 0, 0.16);
  backdrop-filter: blur(18px);
  transition: border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.chat-compose:focus-within {
  background: rgba(255, 255, 255, 0.044);
  border-color: rgba(0, 255, 102, 0.22);
  box-shadow: 0 0 0 3px rgba(0, 255, 102, 0.035);
}

.chat-compose__input {
  min-width: 0;
  min-height: 44px;
  display: flex;
  align-items: center;
}

.chat-compose textarea {
  width: 100%;
  min-height: 22px;
  max-height: 126px;
  padding: 10px 0;
  resize: none;
  overflow-y: auto;
  color: var(--messages-text);
  background: transparent;
  border: 0;
  outline: 0;
  font-size: 13px;
  line-height: 1.5;
}

/* Shared form styles use :is() with high specificity and load after this file.
   The composer owns the surface and focus ring; the textarea stays unboxed. */
.messages-page .chat-compose .chat-compose__input textarea[data-message-input],
.messages-page .chat-compose .chat-compose__input textarea[data-message-input]:focus {
  background: transparent;
  border: 0;
  border-radius: 0;
  outline: none;
  box-shadow: none;
}

.messages-page .chat-compose textarea::placeholder {
  color: var(--messages-muted);
  opacity: 1;
}

.chat-compose button {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  color: #041009;
  background: var(--messages-green);
  border: 0;
  border-radius: 12px;
  cursor: pointer;
  transition: transform 150ms ease, opacity 150ms ease, box-shadow 150ms ease;
}

.chat-compose button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 8px 24px rgba(0, 255, 102, 0.16);
}

.chat-compose button:disabled {
  opacity: 0.38;
  cursor: default;
}

.chat-compose button svg {
  width: 18px;
  height: 18px;
  stroke-width: 1.8;
}

/* Toast */
.messages-toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 1500;
  max-width: min(360px, calc(100vw - 40px));
  padding: 12px 14px;
  color: rgba(255, 255, 255, 0.92);
  background: rgba(11, 15, 20, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 13px;
  box-shadow: 0 18px 54px rgba(0, 0, 0, 0.42);
  font-size: 12px;
  line-height: 1.5;
  backdrop-filter: blur(18px);
  animation: toastIn 180ms ease both;
}

/* Animations */
@keyframes messagesSpin {
  to { transform: rotate(360deg); }
}

@keyframes messagesSearchIn {
  from { opacity: 0; transform: translateY(-5px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes messageIn {
  from { opacity: 0; transform: translateY(5px) scale(0.99); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(7px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Responsive */
@media (max-width: 980px) {
  .messages-layout {
    grid-template-columns: 360px minmax(0, 1fr);
  }

  .chat-view {
    --chat-content-gutter: 18px;
  }

  .chat-message {
    max-width: 78%;
  }
}

@media (max-width: 860px) {
  /* The shared design stylesheet loads later; keep mobile chat in one column. */
  .messages-page .messages-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .messages-title__meta {
    font-size: 11px;
  }

  .messages-shell {
    padding: 18px 0 38px;
  }

  .messages-container {
    width: min(calc(100% - 20px), 1380px);
  }

  .messages-layout {
    min-height: min(760px, calc(100dvh - 116px));
  }

  .messages-sidebar {
    border-right: 0;
  }

  .chat-panel {
    display: none;
  }

  .messages-layout.is-chat-open .messages-sidebar {
    display: none;
  }

  .messages-layout.is-chat-open .chat-panel {
    display: block;
  }

  .chat-view,
  .chat-empty {
    height: min(760px, calc(100dvh - 116px));
    min-height: 590px;
  }

  .chat-view {
    grid-template-rows: 70px minmax(0, 1fr) auto;
  }

  .chat-back {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    flex: 0 0 38px;
    color: rgba(255, 255, 255, 0.72);
    background: rgba(255, 255, 255, 0.025);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 11px;
    cursor: pointer;
  }

  .chat-back svg {
    width: 18px;
    height: 18px;
  }
}

@media (max-width: 520px) {
  .messages-shell {
    padding: 0;
  }

  .messages-container {
    width: 100%;
  }

  .messages-layout {
    min-height: calc(100dvh - 68px);
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .messages-sidebar__head {
    min-height: 82px;
    padding-inline: 16px;
  }

  .messages-sidebar h1 {
    font-size: 22px;
  }

  .conversation-list {
    padding-inline: 7px;
  }

  .conversation-item {
    padding: 10px 9px;
  }

  .chat-view,
  .chat-empty {
    height: calc(100dvh - 68px);
    min-height: 520px;
  }

  .chat-head {
    padding-inline: 10px;
  }

  .chat-profile-link {
    width: 36px;
    height: 36px;
    flex-basis: 36px;
  }

  .chat-view {
    --chat-content-gutter: 10px;
  }

  .chat-messages {
    padding-top: 16px;
    padding-bottom: 10px;
  }

  .chat-message {
    max-width: 87%;
  }

  .chat-compose {
    margin-top: 0;
    margin-bottom: max(8px, env(safe-area-inset-bottom));
    padding-left: 12px;
    border-radius: 15px;
  }

  .chat-jump {
    bottom: 10px;
  }

  .chat-empty {
    padding: 32px 22px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .messages-search,
  .chat-message.is-new,
  .chat-jump,
  .messages-toast,
  .messages-spinner {
    animation: none;
  }

  .chat-messages {
    scroll-behavior: auto;
  }
}

/* =========================================================
   DIRECT MESSAGES — ACTIONS / TYPING (stabilized)
   This block is intentionally isolated so feature work cannot
   alter the proven chat geometry above.
   ========================================================= */

/* Make the messages surface resilient even if a global import is cached
   incorrectly or arrives late. */
.messages-page {
  margin: 0;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  font-weight: 400;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.messages-page *,
.messages-page *::before,
.messages-page *::after {
  box-sizing: border-box;
}

.messages-container {
  margin-inline: auto;
}

/* Lighter type hierarchy. */
.messages-sidebar h1 { font-weight: 700; }
.messages-title__meta { font-weight: 500; }
.message-avatar,
.chat-user__avatar { font-weight: 700; }
.conversation-top strong,
.chat-user strong { font-weight: 600; }
.conversation-unread { font-weight: 700; }
.chat-day { font-weight: 600; }
.chat-jump { font-weight: 600; }
.chat-empty strong { font-weight: 700; }
.chat-empty__action { font-weight: 600; }

.conversation-preview.is-deleted {
  color: rgba(255, 255, 255, 0.3);
  font-style: italic;
}

.chat-message__edited {
  color: rgba(255, 255, 255, 0.32);
  font-size: inherit;
  font-style: normal;
  font-weight: 400;
}

.chat-message.is-deleted {
  color: rgba(255, 255, 255, 0.46);
  background: rgba(255, 255, 255, 0.024);
  border-style: dashed;
}

.chat-message.is-own.is-deleted {
  background: rgba(0, 255, 102, 0.024);
  border-color: rgba(0, 255, 102, 0.075);
}

.chat-message__deleted {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  font-style: italic;
  font-weight: 400;
}

.chat-message__deleted svg {
  width: 13px;
  height: 13px;
  opacity: 0.5;
}

/* Actions are discoverable: the control is always faintly visible on own
   messages and becomes clear on hover/focus. */
.chat-message__menu {
  position: absolute;
  top: 50%;
  right: calc(100% + 7px);
  z-index: 8;
  transform: translateY(-50%);
}

.chat-message__menu-toggle {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  padding: 0;
  color: rgba(255, 255, 255, 0.42);
  background: rgba(10, 14, 19, 0.66);
  border: 1px solid rgba(255, 255, 255, 0.055);
  border-radius: 9px;
  opacity: 0.62;
  cursor: pointer;
  transition: opacity 140ms ease, color 140ms ease, background 140ms ease, border-color 140ms ease;
}

.chat-message__menu-toggle span {
  display: block;
  transform: translateY(-2px);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 1px;
  line-height: 1;
}

.chat-message:hover .chat-message__menu-toggle,
.chat-message__menu.is-open .chat-message__menu-toggle,
.chat-message__menu-toggle:focus-visible {
  color: rgba(255, 255, 255, 0.9);
  background: rgba(18, 24, 31, 0.96);
  border-color: rgba(255, 255, 255, 0.095);
  opacity: 1;
}

.chat-message__menu-popover {
  position: absolute;
  right: 35px;
  bottom: 0;
  width: 146px;
  padding: 5px;
  display: none;
  background: rgba(12, 17, 23, 0.98);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 12px;
  box-shadow: 0 16px 42px rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(18px);
}

.chat-message__menu.is-open .chat-message__menu-popover {
  display: grid;
  animation: messageMenuIn 130ms ease both;
}

.chat-message__menu-popover button {
  min-height: 35px;
  padding: 0 9px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: rgba(255, 255, 255, 0.74);
  background: transparent;
  border: 0;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
}

.chat-message__menu-popover button:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.05);
}

.chat-message__menu-popover button.is-danger {
  color: rgba(255, 125, 125, 0.9);
}

.chat-message__menu-popover button.is-danger:hover {
  color: #ff9696;
  background: rgba(255, 74, 74, 0.07);
}

.chat-message__menu-popover svg {
  width: 14px;
  height: 14px;
}

/* Typing state lives in the message flow without changing the chat layout. */
.chat-typing {
  min-height: 32px;
  margin-top: 3px;
  padding: 6px 10px;
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  gap: 8px;
  color: rgba(255, 255, 255, 0.43);
  background: rgba(255, 255, 255, 0.028);
  border: 1px solid rgba(255, 255, 255, 0.045);
  border-radius: 13px 13px 13px 6px;
  animation: messageIn 160ms ease both;
}

.chat-typing small {
  font-size: 11px;
  font-weight: 400;
  white-space: nowrap;
}

.chat-typing__dots {
  height: 12px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.chat-typing__dots i {
  width: 4px;
  height: 4px;
  display: block;
  background: rgba(255, 255, 255, 0.46);
  border-radius: 50%;
  animation: typingDot 1.05s ease-in-out infinite;
}

.chat-typing__dots i:nth-child(2) { animation-delay: 120ms; }
.chat-typing__dots i:nth-child(3) { animation-delay: 240ms; }

/* Editing only changes the composer geometry while editing. */
.chat-compose.is-editing .chat-compose__input {
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
}

.chat-compose__edit {
  min-height: 34px;
  margin: 0 0 1px;
  padding: 2px 0 6px;
  display: grid;
  grid-template-columns: 2px minmax(0, 1fr) 28px;
  align-items: center;
  gap: 9px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.055);
}

.chat-compose__edit-mark {
  width: 2px;
  height: 25px;
  background: var(--messages-green);
  border-radius: 999px;
  box-shadow: 0 0 10px rgba(0, 255, 102, 0.2);
}

.chat-compose__edit-copy {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.chat-compose__edit-copy small {
  color: rgba(0, 255, 102, 0.72);
  font-size: 11px;
  font-weight: 600;
}

.chat-compose__edit-copy strong {
  overflow: hidden;
  color: rgba(255, 255, 255, 0.52);
  font-size: 11px;
  font-weight: 400;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-compose__edit button {
  width: 32px;
  height: 32px;
  color: rgba(255, 255, 255, 0.48);
  background: transparent;
  border: 0;
  border-radius: 8px;
  box-shadow: none;
}

.chat-compose__edit button:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.05);
  transform: none;
  box-shadow: none;
}

.chat-compose__edit button svg {
  width: 14px;
  height: 14px;
}

.chat-compose.is-editing {
  border-color: rgba(0, 255, 102, 0.16);
}

/* Delete confirmation modal. */
.messages-modal {
  position: fixed;
  inset: 0;
  z-index: 1800;
  display: grid;
  place-items: center;
  padding: 20px;
}

.messages-modal__backdrop {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: rgba(2, 4, 7, 0.72);
  border: 0;
  backdrop-filter: blur(8px);
  cursor: default;
}

.messages-modal__card {
  position: relative;
  z-index: 1;
  width: min(410px, 100%);
  padding: 22px;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 14px;
  background: linear-gradient(180deg, rgba(18, 24, 31, 0.98), rgba(10, 14, 19, 0.98));
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 20px;
  box-shadow: 0 32px 90px rgba(0, 0, 0, 0.5);
  animation: modalIn 170ms ease both;
}

.messages-modal__icon {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  color: #ff7878;
  background: rgba(255, 80, 80, 0.08);
  border: 1px solid rgba(255, 80, 80, 0.12);
  border-radius: 13px;
}

.messages-modal__icon svg { width: 19px; height: 19px; }

.messages-modal__copy h2 {
  margin: 1px 0 6px;
  color: #f6f8fa;
  font-size: 16px;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.messages-modal__copy p {
  margin: 0;
  color: rgba(255, 255, 255, 0.45);
  font-size: 12px;
  line-height: 1.55;
}

.messages-modal__actions {
  grid-column: 1 / -1;
  margin-top: 4px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.messages-modal__button {
  min-height: 38px;
  padding: 0 14px;
  color: rgba(255, 255, 255, 0.72);
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.075);
  border-radius: 11px;
  font-size: 12px;
  font-weight: 550;
  cursor: pointer;
}

.messages-modal__button:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.055);
}

.messages-modal__button.is-danger {
  color: #fff;
  background: #d84f57;
  border-color: #d84f57;
}

.messages-modal__button.is-danger:hover { background: #e35b63; }
.messages-modal__button:disabled { opacity: 0.5; cursor: default; }
.messages-modal-open { overflow: hidden; }

@keyframes typingDot {
  0%, 60%, 100% { opacity: 0.32; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-2px); }
}

@keyframes messageMenuIn {
  from { opacity: 0; transform: translateY(3px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(8px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (max-width: 860px) {
  .chat-message__menu {
    right: calc(100% + 3px);
  }

  .chat-message__menu-toggle {
    opacity: 0.72;
  }

  .chat-message__menu-popover {
    right: 31px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .chat-typing,
  .chat-typing__dots i,
  .chat-message__menu-popover,
  .messages-modal__card {
    animation: none;
  }
}

/* =========================================================
   DIRECT MESSAGES — native compact bubbles
   The renderer now owns avatars, rows and delivery metadata.
   ========================================================= */
.chat-messages {
  gap: 3px;
}

.chat-day {
  margin: 10px 0 8px;
  color: rgba(255, 255, 255, 0.28);
  font-size: 11px;
  font-weight: 600;
}

.chat-message-row {
  width: 100%;
  min-width: 0;
  display: flex;
  align-items: flex-end;
  gap: 7px;
}

.chat-message-row.is-own {
  justify-content: flex-end;
}

.chat-message-row.is-incoming {
  justify-content: flex-start;
}

.chat-message-row.is-grouped {
  margin-top: 0;
}

.chat-message-avatar {
  width: 31px;
  height: 31px;
  flex: 0 0 31px;
  display: grid;
  place-items: center;
  overflow: hidden;
  margin-bottom: 1px;
  color: rgba(245, 250, 247, 0.88);
  background:
    radial-gradient(circle at 28% 22%, rgba(0, 255, 102, 0.11), transparent 38%),
    rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.075);
  border-radius: 9px;
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
  box-shadow: 0 5px 16px rgba(0, 0, 0, 0.15);
}

.chat-message-avatar img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.chat-message-avatar--placeholder {
  visibility: hidden;
}

.chat-message {
  position: relative;
  width: max-content;
  inline-size: max-content;
  min-width: 0;
  min-inline-size: 0;
  min-height: 0;
  height: auto;
  max-width: min(68%, 520px);
  padding: 6px 8px 5px;
  display: block;
  flex: 0 1 auto;
  align-self: auto;
  box-sizing: border-box;
  color: rgba(255, 255, 255, 0.91);
  background: rgba(255, 255, 255, 0.042);
  border: 1px solid rgba(255, 255, 255, 0.058);
  border-radius: 13px 13px 13px 5px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.065);
  text-align: left;
  transition: border-color 140ms ease, background 140ms ease;
}

.chat-message:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.078);
}

.chat-message.is-own {
  border-radius: 13px 13px 5px 13px;
  background: linear-gradient(145deg, rgba(0, 255, 102, 0.078), rgba(0, 255, 102, 0.036));
  border-color: rgba(0, 255, 102, 0.105);
}

.chat-message.is-own:hover {
  background: linear-gradient(145deg, rgba(0, 255, 102, 0.095), rgba(0, 255, 102, 0.043));
  border-color: rgba(0, 255, 102, 0.145);
}

.chat-message__body {
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: 0;
  display: inline;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: inherit;
  font-size: 13px;
  font-weight: 400;
  line-height: 1.35;
  text-align: left;
}

.chat-message__meta {
  position: static;
  width: auto;
  min-width: 0;
  min-height: 0;
  height: auto;
  margin: 0 0 0 7px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 2px;
  color: rgba(255, 255, 255, 0.38);
  font-size: 10px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  vertical-align: -1px;
  pointer-events: none;
}

.chat-message__time {
  display: inline-flex;
  align-items: center;
  font-variant-numeric: tabular-nums;
}

.chat-message__checks {
  width: 11px;
  height: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.42);
}

.chat-message__checks.is-read {
  width: 16px;
  color: rgba(0, 255, 102, 0.9);
}

.chat-message__checks svg {
  width: 100%;
  height: 100%;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.55;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chat-message__edited {
  font-size: 9.5px;
}

.chat-message.is-deleted {
  padding-block: 7px 6px;
}

.chat-message.is-deleted .chat-message__body,
.chat-message.is-own.is-deleted .chat-message__body {
  padding-right: 0;
}

.chat-message__deleted {
  font-size: 12px;
}

.chat-message__menu {
  position: absolute;
  top: 50%;
  z-index: 20;
  display: inline-flex;
  align-items: center;
  transform: translateY(-50%);
}

.chat-message-row.is-own .chat-message__menu {
  right: calc(100% + 5px);
}

.chat-message-row.is-incoming .chat-message__menu {
  left: calc(100% + 5px);
}

.chat-message__menu-toggle {
  width: 24px;
  height: 24px;
  position: relative;
  display: grid;
  place-items: center;
  padding: 0;
  color: rgba(255, 255, 255, 0.4);
  background: rgba(10, 14, 19, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.055);
  border-radius: 8px;
  opacity: 0;
  cursor: pointer;
  transition: opacity 130ms ease, color 130ms ease, background 130ms ease;
}

.chat-message__menu-toggle::before {
  position: absolute;
  inset: -5px;
  content: "";
}

.chat-message__menu-toggle svg {
  width: 12px;
  height: 12px;
  fill: currentColor;
  stroke: none;
}

.chat-message:hover .chat-message__menu-toggle,
.chat-message__menu.is-open .chat-message__menu-toggle,
.chat-message__menu-toggle:focus-visible {
  color: rgba(255, 255, 255, 0.8);
  background: rgba(18, 24, 31, 0.96);
  opacity: 1;
}

.chat-message__menu-popover {
  position: absolute;
  bottom: calc(100% + 7px);
  width: 158px;
  padding: 5px;
  background: rgba(10, 15, 21, 0.985);
  border: 1px solid rgba(255, 255, 255, 0.085);
  border-radius: 11px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.46);
  backdrop-filter: blur(18px);
}

.chat-message-row.is-own .chat-message__menu-popover {
  right: 0;
}

.chat-message-row.is-incoming .chat-message__menu-popover {
  left: 0;
}

.chat-message__menu-popover button {
  min-height: 34px;
  padding: 0 9px;
  font-size: 12px;
}

.chat-message__menu-popover button.is-report {
  color: rgba(255, 196, 112, 0.92);
}

.chat-message__menu-popover button.is-report:hover {
  color: #ffd09a;
  background: rgba(255, 170, 72, 0.075);
}

@media (max-width: 860px) {
  .chat-message-row {
    gap: 7px;
  }

  .chat-message {
    max-width: 82%;
  }

  .chat-message-avatar {
    width: 28px;
    height: 28px;
    flex-basis: 28px;
  }

  .chat-message__menu-toggle {
    width: 22px;
    height: 22px;
    opacity: 0.4;
  }
}

@media (hover: none) {
  .chat-message__menu-toggle {
    opacity: 0.34;
  }
}

/* Message report modal reuses the moderation system instead of creating a
   parallel support flow. */
.messages-report {
  width: min(470px, 100%);
}

.messages-modal__icon--report {
  color: #ffbd66;
  background: rgba(255, 174, 72, 0.08);
  border-color: rgba(255, 174, 72, 0.13);
}

.messages-report__preview {
  grid-column: 1 / -1;
  max-height: 86px;
  overflow: auto;
  padding: 10px 12px;
  color: rgba(255, 255, 255, 0.63);
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid rgba(255, 255, 255, 0.055);
  border-radius: 11px;
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.messages-report__field {
  grid-column: 1 / -1;
  display: grid;
  gap: 6px;
}

.messages-report__field > span {
  color: rgba(255, 255, 255, 0.66);
  font-size: 12px;
  font-weight: 600;
}

.messages-report__field > span small {
  margin-left: 4px;
  color: rgba(255, 255, 255, 0.28);
  font-weight: 400;
}

.messages-report select,
.messages-report textarea {
  width: 100%;
  color: rgba(255, 255, 255, 0.88);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.075);
  border-radius: 11px;
  outline: none;
  font-size: 13px;
  transition: border-color 150ms ease, background 150ms ease, box-shadow 150ms ease;
}

.messages-report select {
  height: 40px;
  padding: 0 11px;
}

.messages-report textarea {
  min-height: 82px;
  max-height: 150px;
  padding: 10px 11px;
  resize: vertical;
  line-height: 1.45;
}

.messages-report select:focus,
.messages-report textarea:focus {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(0, 255, 102, 0.22);
  box-shadow: 0 0 0 3px rgba(0, 255, 102, 0.035);
}

.messages-report select option {
  color: #f3f7f9;
  background: #0b1016;
}

.messages-modal__button.is-report {
  color: #11160f;
  background: #ffb65c;
  border-color: #ffb65c;
}

.messages-modal__button.is-report:hover {
  color: #0b0f0c;
  background: #ffc478;
}

@media (max-width: 860px) {
  .chat-message {
    max-width: 88%;
  }

  .chat-message__menu-toggle {
    width: 19px;
    opacity: 0.46;
  }

  .chat-message__menu-popover {
    right: -4px;
    bottom: calc(100% + 7px);
  }

  .messages-report {
    padding: 18px;
  }
}

@media (hover: none) {
  .chat-message__menu-toggle {
    opacity: 0.38;
  }
}

/* =========================================================
   BLOCKED INTERACTION
   ========================================================= */

.chat-interaction-blocked {
  width: min(100%, 900px);
  margin: 0 auto 10px;
  min-height: 48px;
  padding: 10px 14px;
  border: 1px solid rgba(255,91,113,.11);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  background: rgba(255,91,113,.025);
  color: rgba(229,216,220,.5);
  font-size: 12px;
  text-align: center;
}

.chat-interaction-blocked[hidden] { display: none !important; }
.chat-interaction-blocked svg {
  width: 15px;
  height: 15px;
  flex: 0 0 15px;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
}

.chat-compose[hidden] { display: none !important; }
@media (max-width: 720px) {
  .chat-message {
    max-width: min(82%, 430px);
  }

  .chat-message-avatar {
    width: 29px;
    height: 29px;
    flex-basis: 29px;
  }
}

/* =========================================================
   DIRECT MESSAGES V7 — isolated bubble renderer
   Uses dm-* classes so legacy .chat-message rules cannot affect geometry.
   ========================================================= */
.dm-row {
  width: 100%;
  min-width: 0;
  display: flex;
  align-items: flex-end;
  gap: 7px;
}

.dm-row.is-own { justify-content: flex-end; }
.dm-row.is-incoming { justify-content: flex-start; }
.dm-row.is-grouped { margin-top: 0; }

.dm-avatar {
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  display: grid;
  place-items: center;
  overflow: hidden;
  margin: 0 0 1px;
  color: rgba(245, 250, 247, 0.88);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.075);
  border-radius: 9px;
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
  box-shadow: 0 5px 16px rgba(0, 0, 0, 0.15);
}

.dm-avatar img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.dm-bubble {
  position: relative;
  width: fit-content;
  max-width: min(68%, 520px);
  min-width: 0;
  min-height: 0;
  padding: 7px 9px 6px;
  display: flow-root;
  box-sizing: border-box;
  color: rgba(255, 255, 255, 0.91);
  background: rgba(255, 255, 255, 0.042);
  border: 1px solid rgba(255, 255, 255, 0.058);
  border-radius: 13px 13px 13px 5px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.065);
  text-align: left;
  font-size: 13px;
  line-height: 1.4;
}

.dm-bubble.is-own {
  border-radius: 13px 13px 5px 13px;
  background: linear-gradient(145deg, rgba(0, 255, 102, 0.078), rgba(0, 255, 102, 0.036));
  border-color: rgba(0, 255, 102, 0.105);
}

.dm-body {
  min-width: 0;
  min-height: 0;
  display: inline;
  margin: 0;
  padding: 0;
  color: inherit;
  font-size: 13px;
  font-weight: 400;
  line-height: 1.35;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.dm-meta {
  /* Follow the final text line instead of reserving a column beside every line. */
  float: right;
  min-width: 0;
  margin: 6px 0 -1px 8px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 2px;
  color: rgba(255, 255, 255, 0.46);
  font-size: 10px;
  font-weight: 400;
  line-height: 12px;
  white-space: nowrap;
}

/* The shared typography layer forces 13px on time and metadata labels. */
.dm-bubble .dm-meta .dm-time,
.dm-bubble .dm-meta .dm-edited {
  font-size: 10px !important;
  font-weight: 400;
  line-height: 12px;
}

.dm-time {
  display: inline-flex;
  align-items: center;
  font-variant-numeric: tabular-nums;
}

.dm-checks {
  width: 11px;
  height: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.42);
}

.dm-checks.is-read {
  width: 16px;
  color: rgba(0, 255, 102, 0.9);
}

.dm-checks svg {
  width: 100%;
  height: 100%;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.55;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.dm-edited { font-size: 9.5px; }

.dm-deleted {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: rgba(255, 255, 255, 0.44);
  font-size: 12px;
}

.dm-deleted svg {
  width: 12px;
  height: 12px;
  flex: 0 0 12px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.65;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.dm-row.is-own .chat-message__menu { right: calc(100% + 5px); }
.dm-row.is-incoming .chat-message__menu { left: calc(100% + 5px); }
.dm-row.is-own .chat-message__menu-popover { right: 0; }
.dm-row.is-incoming .chat-message__menu-popover { left: 0; }

.dm-bubble:hover .chat-message__menu-toggle,
.dm-bubble .chat-message__menu.is-open .chat-message__menu-toggle,
.dm-bubble .chat-message__menu-toggle:focus-visible {
  color: rgba(255, 255, 255, 0.8);
  background: rgba(18, 24, 31, 0.96);
  opacity: 1;
}

.dm-bubble.is-new {
  animation: messageIn 220ms cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

@media (max-width: 860px) {
  .dm-bubble { max-width: 82%; }
  .dm-avatar {
    width: 28px;
    height: 28px;
    flex-basis: 28px;
  }
}

@media (max-width: 520px) {
  .dm-bubble {
    max-width: 87%;
    padding: 7px 9px 6px;
  }
}
