/* Личные сообщения — moner messenger layout */

main:has(.dm-page) {
  max-width: none;
  padding: 1.25rem 1.5rem 1.5rem;
}

.dm-page {
  display: grid;
  grid-template-columns: minmax(280px, 320px) minmax(0, 1fr);
  gap: 1.25rem;
  height: calc(100vh - 148px);
  min-height: 520px;
  max-width: 1320px;
  margin: 0 auto;
}

/* ---- Sidebar ---- */
.dm-sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--moner-bg-card);
  border: 1px solid var(--moner-border);
  border-radius: var(--radius-card, 12px);
  overflow: hidden;
}

body.wall-light .dm-sidebar {
  box-shadow: 4px 4px 0 0 #000;
}

.dm-sidebar-head {
  padding: 1rem 1.1rem 0.85rem;
  border-bottom: 1px solid var(--moner-border);
  background: linear-gradient(180deg, rgba(220, 38, 38, 0.08) 0%, transparent 100%);
}

.dm-sidebar-title {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--moner-text);
}

.dm-sidebar-sub {
  margin: 0.35rem 0 0;
  font-size: 0.74rem;
  color: var(--moner-text-muted);
}

.dm-conv-list {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--moner-red) var(--moner-bg);
}

.dm-conv-item {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.8rem 1rem;
  text-decoration: none;
  border-bottom: 1px solid var(--moner-border);
  position: relative;
  transition: background 0.15s, border-color 0.15s;
}

.dm-conv-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: transparent;
  transition: background 0.15s;
}

.dm-conv-item:hover {
  background: rgba(220, 38, 38, 0.06);
}

.dm-conv-item.active {
  background: rgba(220, 38, 38, 0.1);
}

.dm-conv-item.active::before {
  background: var(--moner-red);
}

/* Spacing only — mask shape comes from profile-edit.css */
.dm-conv-avatar {
  flex-shrink: 0;
}

.dm-conv-meta {
  flex: 1;
  min-width: 0;
}

.dm-conv-name {
  color: var(--moner-text);
  font-size: var(--nick-size-inline);
  font-weight: 800;
  line-height: 1.2;
}

.dm-conv-name .styled-username:not(.name-font-custom),
.dm-chat-header-name .styled-username:not(.name-font-custom) {
  font-size: inherit;
  font-weight: inherit;
  line-height: inherit;
}

.dm-conv-preview {
  color: var(--moner-text-muted);
  font-size: 0.76rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 0.2rem;
}

.dm-conv-item.active .dm-conv-preview {
  color: var(--moner-text);
  opacity: 0.75;
}

.dm-conv-badge {
  background: var(--moner-red);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 800;
  border-radius: 9999px;
  min-width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px var(--moner-bg-card);
}

.dm-empty {
  padding: 2rem 1.25rem;
  color: var(--moner-text-muted);
  font-size: 0.84rem;
  line-height: 1.5;
  text-align: center;
}

.dm-empty-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 0.85rem;
  color: var(--moner-border);
}

/* Telegram panel styles live in inbox.html (.msg-tg-*) — no blue accents. */

/* ---- Chat panel ---- */
.dm-chat {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--moner-bg-card);
  border: 1px solid var(--moner-border);
  border-radius: var(--radius-card, 12px);
  overflow: hidden;
}

body.wall-light .dm-chat {
  box-shadow: 4px 4px 0 0 #000;
}

.dm-chat-header {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.85rem 1.1rem;
  border-bottom: 1px solid var(--moner-border);
  background: linear-gradient(180deg, rgba(220, 38, 38, 0.06) 0%, transparent 100%);
  flex-shrink: 0;
}

.dm-back-link {
  display: none;
  color: var(--moner-text-muted);
  text-decoration: none;
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--moner-border);
  transition: border-color 0.15s, color 0.15s;
}

.dm-back-link:hover {
  border-color: var(--moner-red);
  color: var(--moner-red);
}

.dm-chat-header-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: inherit;
  min-width: 0;
  flex: 1;
}

.dm-chat-header-link:hover .dm-chat-header-name {
  color: var(--moner-red);
}

.dm-chat-header-text {
  min-width: 0;
}

.dm-chat-header-name {
  color: var(--moner-text);
  font-weight: 800;
  font-size: var(--nick-size-card);
  line-height: 1.2;
  transition: color 0.15s;
}

.dm-chat-header-handle,
.dm-chat-header-status {
  color: var(--moner-text-muted);
  font-size: 0.74rem;
  margin-top: 0.15rem;
}

.dm-chat-header-status.is-online {
  color: #4ade80;
}

.dm-chat-header-action {
  flex-shrink: 0;
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--moner-red);
  text-decoration: none;
  padding: 0.4rem 0.65rem;
  border: 1px solid var(--moner-border);
  border-radius: 8px;
  transition: background 0.15s, border-color 0.15s;
}

.dm-chat-header-action:hover {
  background: rgba(220, 38, 38, 0.08);
  border-color: var(--moner-red);
}

.dm-msg-typing {
  align-self: flex-start;
  max-width: min(72%, 520px);
  pointer-events: none;
}

.dm-msg-bubble--typing {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 3.25rem;
  padding: 0.7rem 0.95rem;
}

.dm-typing-dots {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
}

.dm-typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--moner-text-muted);
  animation: dm-typing-bounce 1.2s infinite ease-in-out;
}

.dm-msg.mine .dm-typing-dots span {
  background: rgba(255, 255, 255, 0.75);
}

.dm-typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.dm-typing-dots span:nth-child(3) { animation-delay: 0.3s; }

@keyframes dm-typing-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40% { transform: translateY(-4px); opacity: 1; }
}

@keyframes dm-msg-appear {
  from {
    opacity: 0;
    transform: translateY(7px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.dm-msg.dm-msg-appear {
  animation: dm-msg-appear 0.26s ease-out forwards;
}

/* ---- Messages ---- */
.dm-messages {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  padding: 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  scrollbar-width: thin;
  scrollbar-color: var(--moner-red) var(--moner-bg);
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.18) 0%, transparent 28%),
    var(--moner-bg);
}

.dm-conv-list::-webkit-scrollbar,
.dm-messages::-webkit-scrollbar {
  width: 8px;
}

.dm-conv-list::-webkit-scrollbar-track,
.dm-messages::-webkit-scrollbar-track {
  background: var(--moner-bg);
  border-left: 1px solid var(--moner-border);
}

.dm-conv-list::-webkit-scrollbar-thumb,
.dm-messages::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #7f1d1d, var(--moner-red));
  border-radius: 9999px;
  border: 1px solid rgba(0, 0, 0, 0.25);
}

.dm-conv-list::-webkit-scrollbar-thumb:hover,
.dm-messages::-webkit-scrollbar-thumb:hover {
  background: var(--moner-red-hover);
}

body.wall-light .dm-conv-list,
body.wall-light .dm-messages {
  scrollbar-color: var(--moner-red) #f3f4f6;
}

body.wall-light .dm-conv-list::-webkit-scrollbar-track,
body.wall-light .dm-messages::-webkit-scrollbar-track {
  background: #f3f4f6;
  border-left-color: #e4e4e7;
}

body.wall-light .dm-conv-list::-webkit-scrollbar-thumb,
body.wall-light .dm-messages::-webkit-scrollbar-thumb {
  border-color: rgba(0, 0, 0, 0.12);
}

body.wall-light .dm-messages {
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.03) 0%, transparent 28%),
    #f3f4f6;
}

.dm-msg {
  max-width: min(72%, 520px);
  align-self: flex-start;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.dm-msg.dm-msg-media {
  max-width: min(92%, 560px);
}

.dm-msg.mine {
  align-self: flex-end;
  align-items: flex-end;
  position: relative;
}

.dm-msg-actions {
  display: flex;
  gap: 0.25rem;
  align-self: flex-end;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.dm-msg.mine.is-actions-open .dm-msg-actions {
  opacity: 1;
  pointer-events: auto;
}

.dm-msg.mine.is-actions-open .dm-msg-bubble:not(.dm-msg-deleted) {
  outline: 1px solid color-mix(in srgb, var(--moner-red) 45%, transparent);
  outline-offset: 2px;
}

.dm-msg-action {
  width: 26px;
  height: 26px;
  padding: 0;
  border: 1px solid var(--moner-border);
  background: var(--moner-bg-card);
  color: var(--moner-text-muted);
  font-size: 0.72rem;
  line-height: 1;
  cursor: pointer;
  border-radius: var(--moner-btn-radius, 8px);
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.dm-msg-action:hover {
  border-color: var(--moner-red);
  color: var(--moner-red);
}

.dm-msg-deleted {
  font-style: italic;
  opacity: 0.72;
}

.dm-msg-edited {
  font-size: 0.68rem;
  color: var(--moner-text-muted);
  opacity: 0.8;
}

.dm-msg.mine:has(.dm-msg-edit-form) {
  max-width: min(90%, 720px);
  width: min(90%, 720px);
}

.dm-msg-edit-form {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  width: 100%;
}

.dm-msg-edit-form textarea {
  width: 100%;
  min-width: 280px;
  box-sizing: border-box;
  resize: vertical;
  min-height: 96px;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--moner-border);
  border-radius: 8px;
  background: var(--moner-bg);
  color: var(--moner-text);
  font: inherit;
}

.dm-msg-edit-actions {
  display: flex;
  gap: 0.4rem;
}

.dm-msg-edit-save,
.dm-msg-edit-cancel {
  padding: 0.35rem 0.65rem;
  border: 1px solid var(--moner-border);
  background: var(--moner-bg-card);
  color: var(--moner-text);
  font-size: 0.74rem;
  font-weight: 700;
  cursor: pointer;
  border-radius: var(--moner-btn-radius, 8px);
}

.dm-msg-edit-save {
  background: var(--moner-red);
  border-color: var(--moner-red);
  color: #fff;
}

.dm-msg-bubble {
  background: var(--moner-bg-card);
  border: 1px solid var(--moner-border);
  color: var(--moner-text);
  padding: 0.6rem 0.8rem;
  font-size: 0.88rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

body.wall-light .dm-msg:not(.mine) .dm-msg-bubble {
  background: #fff;
}

.dm-msg.mine .dm-msg-bubble {
  background: var(--moner-red-dark);
  border-color: var(--moner-red);
  color: #fff;
}

.dm-msg-meta {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0 0.15rem;
}

.dm-msg-time {
  font-size: 0.66rem;
  color: var(--moner-text-muted);
}

.dm-msg-read {
  font-size: 0.68rem;
  line-height: 1;
  color: var(--moner-text-muted);
  letter-spacing: -0.06em;
}

.dm-msg-read.is-read {
  color: #60a5fa;
}

body.wall-light .dm-msg-read.is-read {
  color: #2563eb;
}

.dm-msg-image-link {
  display: block;
  width: fit-content;
  max-width: 100%;
  border: 1px solid var(--moner-border);
  overflow: hidden;
  transition: border-color 0.15s;
}

.dm-msg-image-link:hover {
  border-color: var(--moner-red);
}

.dm-msg-image {
  max-width: min(400px, 100%);
  max-height: 400px;
  width: auto;
  height: auto;
  display: block;
  object-fit: contain;
}

.dm-msg-voice {
  padding: 0.45rem 0.55rem;
  background: var(--moner-bg-card);
  border: 1px solid var(--moner-border);
  width: min(340px, 100%);
}

body.wall-light .dm-msg-voice {
  background: #fff;
}

.dm-msg.mine .dm-msg-voice {
  background: rgba(0, 0, 0, 0.2);
  border-color: rgba(255, 255, 255, 0.25);
}

.dm-msg-video {
  max-width: min(100%, 320px);
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--moner-border);
  background: #000;
}

.dm-msg-video-player {
  display: block;
  width: 100%;
  max-height: 240px;
  vertical-align: top;
}

.dm-msg-voice-player {
  display: block;
  width: 100%;
  min-width: 260px;
  max-width: 100%;
  height: 42px;
  background: transparent;
  object-fit: contain;
}

.dm-msg-voice-player::-webkit-media-controls-panel {
  background: transparent;
}

.dm-msg-file {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.55rem 0.75rem;
  background: var(--moner-bg-card);
  border: 1px solid var(--moner-border);
  color: var(--moner-text);
  font-size: 0.82rem;
  text-decoration: none;
  max-width: 260px;
  transition: border-color 0.15s, color 0.15s;
}

body.wall-light .dm-msg-file {
  background: #fff;
}

.dm-msg.mine .dm-msg-file {
  background: rgba(0, 0, 0, 0.2);
  border-color: rgba(255, 255, 255, 0.25);
  color: #fff;
}

.dm-msg-file span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dm-msg-file:hover {
  border-color: var(--moner-red);
  color: var(--moner-red);
}

.dm-msg.mine .dm-msg-file:hover {
  color: #fff;
  border-color: #fff;
}

/* ---- Composer ---- */
.dm-recording-indicator {
  display: none;
  align-items: center;
  gap: 0.55rem;
  padding: 0.55rem 1.1rem;
  color: var(--moner-text-muted);
  font-size: 0.8rem;
  background: rgba(220, 38, 38, 0.06);
  flex-shrink: 0;
}

.dm-recording-indicator.is-visible {
  display: flex;
}

.dm-recording-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--moner-red);
  animation: dm-pulse 1s infinite;
}

.dm-recording-indicator button {
  margin-left: auto;
  background: transparent;
  border: 1px solid var(--moner-border);
  color: var(--moner-text-muted);
  font-size: 0.76rem;
  font-weight: 700;
  padding: 0.3rem 0.65rem;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.dm-recording-indicator button:hover {
  border-color: var(--moner-red);
  color: var(--moner-red);
}

.dm-compose-footer {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--moner-border);
  background: var(--moner-bg-card);
}

.dm-compose-attachment {
  flex-shrink: 0;
  padding: 0.75rem 1rem 0;
  background: var(--moner-bg-card);
}

.dm-compose-attachment[hidden] {
  display: none !important;
}

.dm-attachment-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.55rem;
}

.dm-attachment-preview-title {
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--moner-red);
}

.dm-attachment-clear-btn {
  padding: 0.35rem 0.65rem;
  border: 1px solid var(--moner-border);
  border-radius: 8px;
  background: transparent;
  color: var(--moner-text-muted);
  font-size: 0.74rem;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.dm-attachment-clear-btn:hover {
  border-color: var(--moner-red);
  color: var(--moner-red);
  background: rgba(220, 38, 38, 0.06);
}

.dm-attachment-preview-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  max-height: 11.5rem;
  overflow-y: auto;
  padding-bottom: 0.15rem;
}

.dm-attachment-preview-item {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  width: min(100%, 15.5rem);
  padding: 0.5rem 0.55rem;
  border: 1px solid var(--moner-border);
  border-radius: 10px;
  background: rgba(220, 38, 38, 0.05);
}

.dm-attachment-preview-media {
  flex-shrink: 0;
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--moner-border);
  background: var(--moner-bg);
  display: flex;
  align-items: center;
  justify-content: center;
}

.dm-attachment-thumb {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.dm-attachment-thumb--video {
  object-fit: cover;
  background: #000;
}

.dm-attachment-file-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  color: var(--moner-text-muted);
}

.dm-attachment-preview-info {
  flex: 1;
  min-width: 0;
}

.dm-attachment-preview-name {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--moner-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dm-attachment-preview-size {
  margin-top: 0.12rem;
  font-size: 0.7rem;
  color: var(--moner-text-muted);
}

.dm-attachment-remove-btn {
  flex-shrink: 0;
  width: 1.65rem;
  height: 1.65rem;
  padding: 0;
  border: 1px solid var(--moner-border);
  border-radius: 50%;
  background: var(--moner-bg-card);
  color: var(--moner-text-muted);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.dm-attachment-remove-btn:hover {
  border-color: var(--moner-red);
  color: var(--moner-red);
  background: rgba(220, 38, 38, 0.06);
}

.dm-msg-attachments {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  max-width: 100%;
}

.dm-msg-attachments.is-gallery {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.4rem;
}

.dm-msg-attachments.is-gallery .dm-msg-image-link,
.dm-msg-attachments.is-gallery .dm-msg-video,
.dm-msg-attachments.is-gallery .dm-msg-file {
  margin: 0;
}

.dm-msg-attachments.is-gallery .dm-msg-image {
  width: 100%;
  max-height: 160px;
}

.dm-msg-attachments.is-gallery .dm-msg-video-player {
  max-height: 160px;
}

.dm-msg.dm-msg-media-gallery {
  max-width: min(96%, 420px);
}

.dm-send-form {
  --dm-compose-height: 2.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.85rem 1rem;
  background: var(--moner-bg-card);
  flex-shrink: 0;
}

.dm-compose-attachment:not([hidden]) + .dm-send-form {
  padding-top: 0.65rem;
}

.dm-send-form.has-attachment .dm-send-btn {
  box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.25);
}

.dm-send-form input[type="text"] {
  flex: 1;
  min-width: 0;
  width: auto;
  height: var(--dm-compose-height);
  margin: 0;
  padding: 0 0.85rem;
  box-sizing: border-box;
  background: var(--moner-bg);
  border: 1px solid var(--moner-border);
  border-radius: 8px;
  color: var(--moner-text);
  font-size: 0.88rem;
  font-family: inherit;
  line-height: 1.35;
  transition: border-color 0.15s;
}

.dm-send-form input[type="text"]:focus {
  outline: none;
  border-color: var(--moner-red);
}

body.wall-light .dm-send-form input[type="text"] {
  background: #fff;
}

.dm-icon-btn {
  background: transparent;
  border: 1px solid var(--moner-border);
  border-radius: 8px;
  color: var(--moner-text-muted);
  width: var(--dm-compose-height);
  height: var(--dm-compose-height);
  min-width: var(--dm-compose-height);
  flex-shrink: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  box-sizing: border-box;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.dm-icon-btn:hover {
  border-color: var(--moner-red);
  color: var(--moner-red);
  background: rgba(220, 38, 38, 0.06);
}

.dm-icon-btn.recording {
  border-color: var(--moner-red);
  color: #fff;
  background: var(--moner-red);
  animation: dm-pulse 1.2s infinite;
}

.dm-icon {
  display: block;
}

.dm-send-btn {
  width: var(--dm-compose-height);
  height: var(--dm-compose-height);
  min-width: var(--dm-compose-height);
  padding: 0;
  background: var(--moner-red);
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 800;
  font-size: 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-sizing: border-box;
  transition: background 0.15s, transform 0.1s;
}

.dm-send-btn:hover {
  background: var(--moner-red-hover);
}

.dm-send-btn:disabled {
  opacity: 0.65;
  cursor: wait;
}

.dm-send-btn:active {
  transform: translateY(1px);
}

@keyframes dm-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

/* ---- Empty chat state ---- */
.dm-placeholder {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.85rem;
  color: var(--moner-text-muted);
  font-size: 0.9rem;
  text-align: center;
  padding: 2.5rem 2rem;
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.12) 0%, transparent 40%),
    var(--moner-bg);
}

body.wall-light .dm-placeholder {
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.03) 0%, transparent 40%),
    #f3f4f6;
}

.dm-placeholder-icon {
  width: 64px;
  height: 64px;
  color: var(--moner-border);
}

.dm-placeholder-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 800;
  color: var(--moner-text);
}

.dm-placeholder-text {
  margin: 0;
  max-width: 320px;
  line-height: 1.5;
  font-size: 0.84rem;
}

/* Hover card on avatars (wall) */
.dm-userhover {
  position: relative;
  display: inline-block;
  cursor: pointer;
}

.dm-userhover-popover {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 4px;
  min-width: 170px;
  background: var(--moner-bg-card);
  border: 1px solid var(--moner-border);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  z-index: 200;
}

.dm-userhover-popover::before {
  content: '';
  position: absolute;
  top: -10px;
  left: 0;
  right: 0;
  height: 10px;
}

.dm-userhover:hover .dm-userhover-popover,
.dm-userhover.open .dm-userhover-popover {
  display: block;
}

.dm-userhover-popover a {
  display: block;
  padding: 0.55rem 0.9rem;
  color: var(--moner-text);
  text-decoration: none;
  font-size: 0.78rem;
  font-weight: 600;
}

.dm-userhover-popover a:hover {
  background: rgba(220, 38, 38, 0.1);
  color: var(--moner-red);
}

/* ---- Responsive ---- */
@media (max-width: 1024px) {
  body.dm-mobile-chat-open {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    overflow: hidden;
  }

  body.dm-mobile-chat-open #moner-donate-banner {
    display: none !important;
  }

  body.dm-mobile-chat-open > .moner-nav {
    flex-shrink: 0;
    position: sticky;
    top: 0;
    z-index: 500;
  }

  body.dm-mobile-chat-open > .moner-nav-stripe {
    flex-shrink: 0;
  }

  body.dm-mobile-chat-open > main.moner-main {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }

  main:has(.dm-page) {
    padding: 0.75rem;
  }

  body.dm-mobile-chat-open main.moner-main:has(.dm-page-chat-active) {
    padding: 0;
    height: auto;
    max-height: none;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }

  body.dm-mobile-chat-open main.moner-main:has(.dm-page:not(.dm-page-chat-active)) {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .dm-page {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 0;
  }

  body.dm-mobile-chat-open .dm-page.dm-page-chat-active {
    flex: 1;
    min-height: 0;
    height: 100%;
    max-height: 100%;
    margin: 0;
    gap: 0;
  }

  .dm-page:not(.dm-page-chat-active) .dm-chat {
    display: none;
  }

  .dm-page:not(.dm-page-chat-active) .dm-sidebar {
    max-height: none;
    min-height: calc(100dvh - 4rem - 1px - 1.5rem);
  }

  .dm-page-chat-active .dm-sidebar {
    display: none;
  }

  .dm-page-chat-active .dm-chat {
    min-height: 0;
    height: 100%;
    max-height: 100%;
    border-left: none;
    border-right: none;
    border-bottom: none;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .dm-page-chat-active .dm-messages {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  body.dm-keyboard-open .dm-chat {
    overflow: hidden;
  }

  body.dm-keyboard-open .dm-messages {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
  }

  body.dm-keyboard-open .dm-compose-footer,
  body.dm-keyboard-open .dm-recording-indicator,
  body.dm-keyboard-open .dm-compose-attachment,
  body.dm-keyboard-open .dm-send-form {
    flex-shrink: 0;
    margin-top: 0;
  }

  body.dm-keyboard-open .dm-chat-header {
    flex-shrink: 0;
  }

  .dm-back-link {
    display: inline-flex;
    align-items: center;
  }

  .dm-chat-header-action {
    display: none;
  }

}

@media (max-width: 767px) {
  body.dm-mobile-chat-open .moner-mobile-panel.open {
    max-height: min(70dvh, 420px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
  }
}

@media (max-width: 520px) {
  main:has(.dm-page):not(:has(.dm-page-chat-active)) {
    padding: 0.75rem;
  }

  .dm-msg {
    max-width: 88%;
  }

  .dm-msg.dm-msg-media {
    max-width: 96%;
  }

  .dm-msg.mine:has(.dm-msg-edit-form) {
    max-width: 96%;
    width: 96%;
  }

  .dm-send-form {
    --dm-compose-height: 2.75rem;
    gap: 0.35rem;
    padding: 0.65rem 0.75rem;
    padding-bottom: calc(0.65rem + env(safe-area-inset-bottom, 0px));
  }

  .dm-send-form input[type="text"] {
    font-size: 16px;
  }

  .dm-placeholder {
    padding: 1.25rem 1rem;
    min-height: 0;
  }

  .dm-placeholder-icon {
    width: 40px;
    height: 40px;
  }
}