.sl-dm {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  border: 1px solid var(--sl-gray-200, #e2e8f0);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
  height: calc(100vh - 150px);
  min-height: 460px;
  max-height: 720px;
  max-width: 100%;
  box-sizing: border-box;
}

.sl-dm * { box-sizing: border-box; }
.sl-dm-list { border-right: 1px solid #e2e8f0; display: flex; flex-direction: column; background: #f8fafc; min-width: 0; }
.sl-dm-listsearch { padding: 8px; border-bottom: 1px solid #e2e8f0; }
.sl-dm-scroll { overflow-y: auto; flex: 1; min-height: 0; }

.sl-dm-conv {
  display: flex;
  width: 100%;
  gap: 10px;
  align-items: flex-start;
  padding: 12px;
  border: 0;
  border-bottom: 1px solid #f1f5f9;
  background: transparent;
  text-align: left;
  font: inherit;
  text-decoration: none;
  color: #334155;
  transition: background .12s;
}

.sl-dm-conv:hover { background: #fff; }
.sl-dm-conv.active { background: #e6f9ee; }
.sl-dm-conv-avatar { width: 38px; height: 38px; border-radius: 50%; background: #e6f9ee; color: #06ad56; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .9rem; flex-shrink: 0; text-transform: uppercase; }
.sl-dm-conv-main { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 2px; }
.sl-dm-conv-top { display: flex; align-items: center; gap: 6px; justify-content: space-between; }
.sl-dm-conv-name { display: block; flex: 1 1 auto; min-width: 0; overflow: hidden; }
.sl-dm-conv-name .sl-user-label {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0;
  width: 100%;
}
.sl-dm-conv-name .sl-user-name {
  display: block;
  max-width: 100%;
  overflow: hidden;
  font-size: .9rem;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sl-dm-conv-name .sl-handle {
  display: block;
  max-width: 100%;
  overflow: hidden;
  font-size: .68rem;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sl-dm-conv-meta { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.sl-dm-conv-time { font-size: .68rem; color: #94a3b8; }
.sl-dm-conv-preview { font-size: .78rem; color: #64748b; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.sl-dm-user { display: block; width: 100%; text-align: left; padding: 10px 12px; background: none; border: none; border-bottom: 1px solid #f1f5f9; color: #334155; }
.sl-dm-user:hover { background: #fff; }
.sl-dm-list-empty,
.sl-dm-search-back {
  padding: 14px;
  color: #64748b;
  font-size: .8rem;
}
.sl-dm-search-back a { color: #078a47; text-decoration: none; }
.sl-dm-search-back a:hover { text-decoration: underline; }
.sl-dm-thread { display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden; }
.sl-dm-threadhead { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid #e2e8f0; background: #fff; min-width: 0; flex: 0 0 auto; }
.sl-dm-threadhead > div { min-width: 0; }
.sl-dm-thread-person { overflow: hidden; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }

.sl-dm-messages { flex: 1 1 auto; overflow-y: auto; overflow-x: hidden; padding: 16px; display: flex; flex-direction: column; gap: 10px; min-height: 0; min-width: 0; }
.sl-dm-message { display: flex; flex-direction: column; max-width: min(82%, 520px); gap: 3px; }
.sl-dm-message.me { align-self: flex-end; align-items: flex-end; }
.sl-dm-message.them { align-self: flex-start; align-items: flex-start; }
.sl-dm-meta { display: flex; align-items: baseline; gap: 6px; max-width: 100%; font-size: .65rem; line-height: 1; color: #94a3b8; }
.sl-dm-message.me .sl-dm-meta { justify-content: flex-end; }
.sl-dm-message.them .sl-dm-meta { justify-content: flex-start; }
.sl-dm-meta .sl-user-label { min-width: 0; overflow: hidden; }
.sl-dm-meta .sl-user-name { font-size: .65rem; font-weight: 600; }
.sl-dm-meta .sl-handle { font-size: .65rem; }
.sl-dm-time { flex: 0 0 auto; white-space: nowrap; }
.sl-dm-bubble { display: block; width: fit-content; max-width: 100%; padding: 8px 12px; border-radius: 16px; font-size: .9rem; line-height: 1.5; overflow-wrap: anywhere; word-break: break-word; }
.sl-dm-bubble.me { align-self: flex-end; background: #07c160; color: #fff; border-bottom-right-radius: 4px; }
.sl-dm-bubble.them { align-self: flex-start; background: #f1f5f9; color: #334155; border-bottom-left-radius: 4px; }
.sl-dm-compose { display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px; border-top: 1px solid #e2e8f0; background: #fff; min-width: 0; flex: 0 0 auto; }
.sl-dm-compose textarea { resize: none; height: 36px; min-height: 36px; max-height: 36px; min-width: 0; flex: 1 1 auto; overflow-y: auto; }
.sl-dm-send { width: 36px; height: 36px; min-height: 36px; padding: 0; gap: 0; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 36px; border-radius: 50%; line-height: 1; }
.sl-dm-send i { display: block; width: 1em; height: 1em; font-size: 1rem; line-height: 1; }
.sl-dm-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; color: #94a3b8; gap: 6px; }
.sl-dm-empty i { font-size: 2rem; line-height: 1; }
.sl-dm-empty p { margin: 0; }
.sl-dm-thread-empty { margin: auto; color: #94a3b8; font-size: .82rem; }
.sl-dm-back { display: none; }

.sl-message-window .sl-dm {
  width: 100%;
  height: 100%;
  min-height: 0;
  max-height: none;
  grid-template-columns: 280px minmax(0, 1fr);
  border: 0;
  border-radius: 0;
}

.sl-message-window .sl-dm-listsearch { padding: 10px; background: #fff; }
.sl-message-window .sl-dm-conv { padding: 11px 12px; }
.sl-message-window .sl-dm-messages { background: #fff; }

@media (max-width: 991.98px) {
  .sl-dm { grid-template-columns: minmax(0, 1fr); width: 100%; height: calc(100vh - 112px); height: calc(100svh - 112px); min-height: 0; max-height: none; border-radius: 0; margin-left: 0; margin-right: 0; border-left: 0; border-right: 0; }
  .sl-dm-thread { display: none; }
  .sl-dm-has-active .sl-dm-list { display: none; }
  .sl-dm-has-active .sl-dm-thread { display: flex; }
  .sl-dm-back { display: inline-flex; }
  .sl-dm-messages { padding: 12px; gap: 8px; }
  .sl-dm-message { max-width: 78%; }
  .sl-dm-bubble { max-width: 100%; font-size: .86rem; }
  .sl-dm-conv-avatar { width: 34px; height: 34px; font-size: .82rem; }
  .sl-dm-compose { padding: 8px 10px; align-items: center; }
  .sl-dm-compose textarea { height: 36px; min-height: 36px; max-height: 36px; font-size: 16px; }
}

@media (max-width: 575.98px) {
  .sl-message-window .sl-dm {
    grid-template-columns: minmax(0, 1fr);
    height: 100%;
    border: 0;
  }
  .sl-message-window .sl-dm-thread { display: none; }
  .sl-message-window .sl-dm-has-active .sl-dm-list { display: none; }
  .sl-message-window .sl-dm-has-active .sl-dm-thread { display: flex; }
}
