#dm-fab {
  position: fixed;
  left: 1.2rem;
  bottom: 1.2rem;
  z-index: 80;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: #eab300;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s;
  position: fixed;
}
#dm-fab:hover { transform: translateY(-2px); }
#dm-fab:active { transform: translateY(0); }
#dm-badge {
  position: absolute;
  top: -4px; right: -4px;
  min-width: 18px; height: 18px;
  border-radius: 9px;
  background: #d94846;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  border: 2px solid #000;
}

/* [hidden] has to beat display:flex elsewhere in this file */
#dm-panel[hidden],
#dm-people[hidden],
#dm-threads[hidden],
#dm-conv[hidden],
#dm-loggedout[hidden] { display: none !important; }

@media (max-width: 480px) {
  /* Lift above the chat input on narrow screens */
  #dm-fab { bottom: 4.5rem; }
  #dm-panel { left: 0.6rem; right: 0.6rem; width: auto; bottom: 8.5rem; }
}

#dm-panel {
  position: fixed;
  left: 1.2rem;
  bottom: 5.2rem;
  z-index: 80;
  width: 360px;
  max-width: calc(100vw - 2rem);
  height: 520px;
  max-height: calc(100vh - 8rem);
  background: #0a0a0a;
  border: 1px solid #eab300;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  color: #eee;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', monospace;
}

#dm-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0.85rem;
  border-bottom: 1px solid #2a2a2a;
}
#dm-head strong {
  color: #eab300;
  letter-spacing: 0.2em;
  font-size: 0.72rem;
}
#dm-close {
  background: transparent;
  color: #888;
  border: none;
  font-size: 1.3rem;
  cursor: pointer;
  line-height: 1;
}
#dm-close:hover { color: #eab300; }

#dm-tabs {
  display: flex;
  border-bottom: 1px solid #2a2a2a;
}
.dm-tab {
  flex: 1;
  background: transparent;
  color: #888;
  border: none;
  padding: 0.55rem 0.5rem;
  font-family: inherit;
  font-size: 0.72rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  cursor: pointer;
  border-bottom: 2px solid transparent;
}
.dm-tab.active {
  color: #eab300;
  border-bottom-color: #eab300;
}

#dm-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.dm-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.4rem 0;
}
.dm-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.85rem;
  cursor: pointer;
  border-bottom: 1px solid #161616;
}
.dm-row:hover { background: #141414; }
.dm-row .dm-avatar {
  width: 36px; height: 36px;
  border-radius: 4px;
  background: #111;
  border: 1px solid #2a2a2a;
  flex-shrink: 0;
  image-rendering: pixelated;
  object-fit: cover;
}
.dm-row .dm-meta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.dm-row .dm-name { color: #eab300; font-size: 0.82rem; }
.dm-row .dm-sub  { color: #888; font-size: 0.72rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dm-row .dm-unread {
  background: #d94846;
  color: #fff;
  border-radius: 9px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

#dm-conv {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
#dm-conv-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid #2a2a2a;
}
#dm-back {
  background: transparent;
  color: #eab300;
  border: none;
  font-size: 1rem;
  cursor: pointer;
  padding: 0 0.4rem;
}
#dm-conv-avatar {
  width: 28px; height: 28px;
  border-radius: 4px;
  background: #111;
  border: 1px solid #2a2a2a;
  image-rendering: pixelated;
  object-fit: cover;
}
#dm-conv-name {
  color: #eab300;
  font-size: 0.82rem;
}

#dm-conv-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 0.6rem 0.7rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.dm-msg {
  max-width: 78%;
  padding: 0.4rem 0.55rem;
  border-radius: 8px;
  font-size: 0.82rem;
  line-height: 1.35;
  word-wrap: break-word;
}
.dm-msg.me   { align-self: flex-end;   background: #eab300; color: #000; }
.dm-msg.them { align-self: flex-start; background: #1b1b1b; color: #eee; border: 1px solid #2a2a2a; }
.dm-msg time {
  display: block;
  font-size: 10px;
  color: rgba(0,0,0,0.5);
  margin-top: 2px;
}
.dm-msg.them time { color: #555; }

#dm-conv-form {
  display: flex;
  gap: 0.4rem;
  padding: 0.5rem;
  border-top: 1px solid #2a2a2a;
  background: #111;
}
#dm-conv-input {
  flex: 1;
  background: #0a0a0a;
  color: #eee;
  border: 1px solid #333;
  padding: 0.4rem 0.55rem;
  border-radius: 4px;
  font-family: inherit;
  font-size: 0.8rem;
}
#dm-conv-input:focus {
  outline: none;
  border-color: #eab300;
}
#dm-conv-form button {
  background: #eab300;
  color: #000;
  border: none;
  padding: 0.4rem 0.9rem;
  border-radius: 4px;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.8rem;
  cursor: pointer;
}

#dm-loggedout {
  padding: 1rem 0.9rem;
  color: #888;
  font-size: 0.85rem;
  text-align: center;
  border-top: 1px solid #2a2a2a;
}
#dm-loggedout a { color: #eab300; text-decoration: none; }
