/* ═══════════════════ DM STYLES (FIXED) ═══════════════════ */
.dm-shell {
  display: flex;
  gap: 0;
  height: calc(100vh - 60px);
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
}
.dm-inbox {
  width: 300px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  transition: background 0.3s;
}
.dm-inbox-head {
  padding: 18px 16px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.dm-inbox-head h2 {
  font-family: var(--font-head);
  font-size: 17px;
  font-weight: 800;
  margin-bottom: 10px;
}
.dm-inbox-search {
  position: relative;
}
.dm-inbox-search input {
  width: 100%;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 20px;
  padding: 8px 12px 8px 34px;
  font-size: 13px;
  color: var(--txt);
  outline: none;
  transition: border-color var(--tr);
  font-family: inherit;
}
.dm-inbox-search input:focus {
  border-color: var(--accent);
}
.dm-inbox-search input::placeholder {
  color: var(--txt3);
}
.dm-inbox-search svg {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  color: var(--txt3);
  pointer-events: none;
}
.dm-conv-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px 0;
}
.dm-conv-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 14px;
  cursor: pointer;
  transition: background var(--tr);
  position: relative;
}
.dm-conv-item:hover {
  background: var(--card-hover);
}
.dm-conv-item.active {
  background: var(--accent-bg);
}
.dm-conv-item.unread .dm-conv-name {
  color: var(--txt);
  font-weight: 800;
}
.dm-conv-item.unread .dm-conv-preview {
  color: var(--txt2);
  font-weight: 600;
}
.dm-conv-info {
  flex: 1;
  min-width: 0;
}
.dm-conv-name {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--txt);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dm-conv-preview {
  font-size: 12px;
  color: var(--txt3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}
.dm-conv-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}
.dm-conv-time {
  font-size: 10.5px;
  color: var(--txt3);
}
.dm-unread-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}
.dm-conv-empty {
  text-align: center;
  padding: 40px 16px;
  color: var(--txt2);
}
.dm-conv-empty svg {
  width: 36px;
  height: 36px;
  margin: 0 auto 10px;
  display: block;
  color: var(--txt3);
}
.dm-conv-empty p {
  font-size: 13px;
}

.dm-chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--card);
  transition: background 0.3s;
}
.dm-chat-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--txt2);
  gap: 10px;
  padding: 32px;
}
.dm-chat-empty svg {
  width: 52px;
  height: 52px;
  color: var(--txt3);
}
.dm-chat-empty h3 {
  font-family: var(--font-head);
  font-size: 18px;
  font-weight: 800;
  color: var(--txt);
}
.dm-chat-empty p {
  font-size: 13.5px;
  text-align: center;
  max-width: 220px;
  line-height: 1.5;
}
.dm-chat-empty .btn {
  margin-top: 8px;
}

.dm-chat-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--surface);
  transition: background 0.3s;
}
.dm-chat-head-info {
  flex: 1;
  min-width: 0;
}
.dm-chat-head-name {
  font-size: 15px;
  font-weight: 800;
  font-family: var(--font-head);
}
.dm-chat-head-status {
  font-size: 12px;
  color: var(--txt2);
  margin-top: 1px;
  display: flex;
  align-items: center;
  gap: 5px;
}
.dm-chat-head-status.online {
  color: var(--green);
}
.dm-chat-head-status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--txt3);
  display: inline-block;
  flex-shrink: 0;
}
.dm-chat-head-status.online::before {
  background: var(--green);
}
/* "Seen" read receipt label under last sent message */
.dm-seen-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--txt3);
  text-align: right;
  margin-top: 3px;
  margin-right: 2px;
  letter-spacing: 0.01em;
  animation: fadeInSeen 0.25s ease;
}
@keyframes fadeInSeen {
  from {
    opacity: 0;
    transform: translateY(2px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* FIXED: added missing fadeUp keyframes */
@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.dm-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px 18px 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.dm-date-divider {
  text-align: center;
  font-size: 11px;
  color: var(--txt3);
  font-weight: 700;
  letter-spacing: 0.05em;
  margin: 10px 0 4px;
  text-transform: uppercase;
}
.dm-msg {
  display: flex;
  gap: 9px;
  align-items: flex-end;
  animation: fadeUp 0.2s ease both;
}
.dm-msg.mine {
  flex-direction: row-reverse;
}
.dm-bubble {
  max-width: 90%;
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.55;
  word-break: break-word;
  position: relative;
}
.dm-msg.theirs .dm-bubble {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--txt);
  border-bottom-left-radius: 5px;
}
.dm-msg.mine .dm-bubble {
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 5px;
  box-shadow: 0 3px 14px var(--accent-glow);
}
.dm-bubble-time {
  font-size: 10px;
  margin-top: 4px;
  opacity: 0.55;
  display: block;
  text-align: right;
}
.dm-msg.theirs .dm-bubble-time {
  text-align: left;
}

.dm-compose {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-shrink: 0;
  background: var(--surface);
  transition: background 0.3s;
}
.dm-compose-input {
  flex: 1;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 22px;
  padding: 10px 16px;
  font-size: 14px;
  color: var(--txt);
  outline: none;
  resize: none;
  max-height: 120px;
  overflow-y: auto;
  line-height: 1.5;
  font-family: inherit;
  transition: border-color var(--tr);
}
.dm-compose-input:focus {
  border-color: var(--accent);
}
.dm-compose-input::placeholder {
  color: var(--txt3);
}
.dm-send-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  transition: all var(--tr);
  box-shadow: 0 3px 12px var(--accent-glow);
  border: none;
  cursor: pointer;
}
.dm-send-btn:hover {
  background: var(--accent-h);
  transform: scale(1.08);
}
.dm-send-btn:disabled {
  opacity: 0.4;
  transform: none;
  cursor: not-allowed;
}
.dm-send-btn svg {
  width: 18px;
  height: 18px;
}

/* New DM Modal */
.dm-new-modal {
  position: fixed;
  inset: 0;
  z-index: 600;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
}
.dm-new-modal.open {
  display: flex;
}
.dm-new-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 380px;
  max-width: 94vw;
  box-shadow: var(--shadow-lg);
  animation: fadeUp 0.22s ease both;
  overflow: hidden;
}
.dm-new-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}
.dm-new-head h3 {
  font-family: var(--font-head);
  font-size: 16px;
  font-weight: 800;
  flex: 1;
}
.dm-new-search-wrap {
  padding: 14px 16px 8px;
}
.dm-new-search-wrap input {
  width: 100%;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 20px;
  padding: 9px 16px;
  font-size: 14px;
  color: var(--txt);
  outline: none;
  font-family: inherit;
  transition: border-color var(--tr);
}
.dm-new-search-wrap input:focus {
  border-color: var(--accent);
}
.dm-new-search-wrap input::placeholder {
  color: var(--txt3);
}
.dm-new-results {
  max-height: 280px;
  overflow-y: auto;
  padding: 4px 0 8px;
}
.dm-new-result {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 16px;
  cursor: pointer;
  transition: background var(--tr);
}
.dm-new-result:hover {
  background: var(--accent-bg);
}
.dm-new-result-info {
  flex: 1;
  min-width: 0;
}
.dm-new-result-name {
  font-size: 14px;
  font-weight: 700;
}
.dm-new-result-email {
  font-size: 12px;
  color: var(--txt2);
  margin-top: 1px;
}
.dm-new-empty {
  text-align: center;
  padding: 28px 16px;
  color: var(--txt3);
  font-size: 13.5px;
}

/* mobile: stack the DM shell */
@media (max-width: 768px) {
  .dm-shell {
    height: calc(100vh - 120px);
    border-radius: 12px;
  }
  .dm-inbox {
    width: 100%;
    border-right: none;
  }
  .dm-inbox.hidden-mobile {
    display: none;
  }
  .dm-chat {
    display: none;
  }
  .dm-chat.visible-mobile {
    display: flex;
  }
  .dm-chat-back {
    display: flex !important;
  }
}
.dm-chat-back {
  display: none;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  align-items: center;
  justify-content: center;
  color: var(--txt2);
  background: var(--accent-bg);
  flex-shrink: 0;
  cursor: pointer;
  border: none;
}
.dm-chat-back svg {
  width: 18px;
  height: 18px;
}

.dm-bubble-wrap {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 4px;
}
.dm-msg.mine .dm-bubble-wrap {
  flex-direction: row-reverse;
}

.dm-msg-menu {
  position: relative;
}
.dm-msg-menu-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--txt3);
  font-size: 16px;
  padding: 2px 6px;
  border-radius: 50%;
  opacity: 0;
  transition: opacity 0.15s;
}
.dm-msg:hover .dm-msg-menu-btn {
  opacity: 1;
}
@media (hover: none) {
  .dm-msg-menu-btn {
    opacity: 1;
  }
} /* always visible on touch */

.dm-msg-menu-dropdown {
  display: none;
  position: absolute;
  bottom: 100%;
  right: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  z-index: 99;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
  min-width: 110px;
  max-height: 200px;
  overflow-y: auto;
}
.dm-msg.mine .dm-msg-menu-dropdown {
  right: 0;
  left: auto;
}
.dm-msg-menu-dropdown.open {
  display: block;
}
.dm-msg-menu-dropdown button {
  display: block;
  width: 100%;
  padding: 9px 16px;
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  font-size: 13.5px;
  color: var(--txt);
}
.dm-msg-menu-dropdown button:hover {
  background: var(--hover);
}

/* FIXED: replaced undefined --bg2 with --bg */
.dm-edit-input {
  width: 100%;
  min-height: 60px;
  background: var(--bg);
  border: 1px solid var(--accent);
  border-radius: 8px;
  color: var(--txt);
  padding: 6px 10px;
  font-size: 14px;
  resize: none;
  font-family: inherit;
}
.dm-edit-actions {
  display: flex;
  gap: 6px;
  margin-top: 6px;
  justify-content: flex-end;
}
.dm-edit-actions button {
  padding: 4px 14px;
  border-radius: 20px;
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}
.dm-edit-actions button:first-child {
  background: var(--accent);
  color: #fff;
}
.dm-edit-actions button:last-child {
  background: var(--hover);
  color: var(--txt);
}

.dm-edited-label {
  font-size: 10px;
  color: var(--txt3);
  margin-left: 4px;
}