/* DM header tools */
.dm-head {
  display: flex; align-items: center; justify-content: space-between; gap: .75rem;
  width: 100%;
}
.dm-head-left {
  min-width: 0; font-weight: 700; font-size: .95rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.dm-head-actions { display: flex; align-items: center; gap: .2rem; flex: 0 0 auto; }
.dm-tool-btn {
  width: 36px; height: 36px; border: none; border-radius: 8px;
  background: transparent; color: var(--muted); cursor: pointer;
  display: grid; place-items: center;
}
.dm-tool-btn svg { display: block; width: 20px; height: 20px; }
.dm-tool-btn:hover, .dm-tool-btn.active { background: var(--surface-2); color: var(--text); }
.dm-search-field {
  display: flex; align-items: center; gap: .35rem;
  margin-left: .35rem; padding: .3rem .55rem;
  border-radius: 8px; background: var(--surface-2); border: 1px solid var(--border);
  min-width: 180px; max-width: 240px;
}
.dm-search-field input {
  flex: 1; border: none; background: transparent; color: var(--text);
  font-family: inherit; font-size: .82rem; padding: .2rem 0; outline: none;
  min-width: 0;
}
.dm-search-field svg { color: var(--muted); flex: 0 0 auto; }

/* DM search / pins panels */
.dm-side-panel {
  flex: 0 0 auto; max-height: 42%; overflow: hidden;
  display: flex; flex-direction: column;
  border-bottom: 1px solid var(--border); background: var(--bg-2, var(--surface));
}
.dm-side-panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: .65rem 1rem; font-weight: 700; font-size: .9rem;
}
.dm-side-panel-sub {
  padding: 0 1rem .45rem; font-size: .78rem; color: var(--muted); font-weight: 650;
}
.dm-search-results {
  overflow-y: auto; padding: .35rem .85rem 1rem;
  display: flex; flex-direction: column; gap: .45rem; scrollbar-width: thin;
}
.dm-result-card {
  border: 1px solid var(--border); border-radius: 10px;
  padding: .65rem .75rem; background: var(--surface); cursor: pointer; text-align: left;
  color: var(--text); font-family: inherit; width: 100%;
}
.dm-result-card:hover { background: var(--surface-2); }
.dm-result-top {
  display: flex; align-items: center; gap: .55rem; margin-bottom: .3rem;
}
.dm-result-meta { min-width: 0; flex: 1; }
.dm-result-name { font-weight: 700; font-size: .85rem; }
.dm-result-time { font-size: .72rem; color: var(--muted); }
.dm-result-text { font-size: .88rem; line-height: 1.35; word-break: break-word; }
.dm-result-text mark {
  background: color-mix(in srgb, var(--accent) 45%, transparent);
  color: inherit; border-radius: 3px; padding: 0 .1rem;
}

/* DM call stage */
.dm-call-stage {
  flex: 0 0 auto;
  display: flex; flex-direction: column; align-items: stretch; justify-content: flex-start;
  gap: .55rem; padding: .75rem .75rem .65rem;
  background: linear-gradient(180deg, var(--surface) 0%, var(--bg) 100%);
  border-bottom: 1px solid var(--border);
  min-height: 240px;
  max-height: min(52vh, 520px);
}
.dm-call-stage.ringing { min-height: 260px; }
.dm-call-banner {
  display: flex; align-items: center; gap: .75rem;
  padding: .35rem .25rem 0;
}
.dm-call-banner.hidden { display: none; }
.dm-call-avatar {
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--accent); color: #fff; flex-shrink: 0;
  display: grid; place-items: center; font-size: 1.15rem; font-weight: 800;
}
.dm-call-banner-text { min-width: 0; }
.dm-call-name { font-weight: 800; font-size: 1rem; }
.dm-call-status { color: var(--muted); font-size: .85rem; }
/* voice-grid flex:1 sunucu görünümüne ait — DM'de sabit yükseklik, boş siyah alan olmasın */
#dm-voice-grid.voice-grid,
.dm-voice-grid {
  flex: 0 0 auto !important;
  width: 100%;
  height: min(36vh, 340px);
  min-height: 200px;
  max-height: min(42vh, 420px);
  padding: .35rem .15rem;
  background: transparent;
}
.dm-call-controls {
  display: flex; align-items: center; justify-content: center; gap: .5rem;
  margin-top: .15rem; padding: .45rem .7rem;
  background: var(--surface-3); border: 1px solid var(--border); border-radius: 999px;
  align-self: center;
}
.dm-call-ctrl {
  width: 42px; height: 42px; border: none; border-radius: 50%;
  background: var(--surface-2); color: var(--text); cursor: pointer;
  display: grid; place-items: center;
}
.dm-call-ctrl:hover { background: var(--surface); }
.dm-call-ctrl.off { color: var(--danger); }
.dm-call-ctrl.on { color: var(--accent); }
.dm-call-ctrl--end { background: var(--danger); color: #fff; }
.dm-call-ctrl--end:hover { filter: 1.05; }

/* Gelen arama overlay */
.dm-incoming-overlay {
  position: fixed; z-index: 80; left: 0; right: 0; bottom: 1.25rem;
  display: flex; justify-content: center; pointer-events: none;
  padding: 0 1rem;
}
.dm-incoming-overlay.hidden { display: none; }
.dm-incoming-card {
  pointer-events: auto;
  display: flex; align-items: center; gap: .85rem;
  width: min(420px, 100%);
  padding: .85rem 1rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0,0,0,.35);
  animation: dm-incoming-pulse 1.6s ease-in-out infinite;
}
@keyframes dm-incoming-pulse {
  0%, 100% { box-shadow: 0 12px 40px rgba(0,0,0,.35); }
  50% { box-shadow: 0 12px 40px rgba(0,0,0,.35), 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent); }
}
.dm-incoming-avatar {
  width: 48px; height: 48px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: grid; place-items: center; font-weight: 800; flex-shrink: 0;
}
.dm-incoming-meta { flex: 1; min-width: 0; }
.dm-incoming-name { font-weight: 800; }
.dm-incoming-sub { color: var(--muted); font-size: .82rem; }
.dm-incoming-actions { display: flex; gap: .4rem; flex-shrink: 0; }
.dm-incoming-btn {
  border: none; border-radius: 8px; padding: .45rem .7rem;
  font-weight: 700; cursor: pointer; font-size: .82rem;
}
.dm-incoming-btn--accept { background: #23a559; color: #fff; }
.dm-incoming-btn--reject { background: var(--danger); color: #fff; }

/* Group DM modal */
.group-dm-modal { width: min(440px, 94vw); max-height: min(80vh, 640px); display: flex; flex-direction: column; }
.group-dm-modal-head { display: flex; justify-content: space-between; gap: .75rem; margin-bottom: .75rem; }
.group-dm-modal-head h3 { margin: 0; }
.group-dm-hint { margin: .25rem 0 0; color: var(--muted); font-size: .85rem; }
.group-dm-help { color: var(--muted); font-size: .8rem; margin: .45rem 0 .55rem; }
.group-dm-list {
  list-style: none; overflow-y: auto; flex: 1; min-height: 180px; max-height: 320px;
  margin: 0 0 .85rem; padding: 0; display: flex; flex-direction: column; gap: .15rem;
}
.group-dm-row {
  display: flex; align-items: center; gap: .65rem;
  padding: .45rem .5rem; border-radius: 8px; cursor: pointer;
}
.group-dm-row:hover, .group-dm-row.selected { background: var(--surface-2); }
.group-dm-row .user-chip-meta { flex: 1; min-width: 0; }
.group-dm-check {
  width: 20px; height: 20px; border-radius: 5px; border: 2px solid var(--border);
  flex: 0 0 auto; display: grid; place-items: center;
}
.group-dm-check.on {
  background: var(--accent); border-color: var(--accent);
}
.group-dm-check.on::after {
  content: '';
  width: 5px; height: 9px;
  border: solid #fff; border-width: 0 2px 2px 0;
  transform: rotate(45deg); margin-bottom: 2px;
}
.dm-tool-btn svg { display: block; width: 20px; height: 20px; }

.dm-reply-bar {
  display: flex; align-items: center; gap: .65rem;
  margin: 0 1rem; padding: .45rem .7rem;
  border: 1px solid var(--border); border-bottom: none;
  border-radius: 10px 10px 0 0; background: var(--surface);
}
.dm-reply-bar-body { flex: 1; min-width: 0; }
.dm-reply-bar-label {
  display: block; font-size: .7rem; font-weight: 700;
  color: var(--accent); text-transform: uppercase; letter-spacing: .04em;
}
.dm-reply-bar-text {
  display: block; font-size: .82rem; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.dm-emoji-btn {
  width: 40px; height: 40px; border: none; border-radius: 10px;
  background: var(--surface-2); color: var(--muted); cursor: pointer;
  display: grid; place-items: center; flex: 0 0 auto;
}
.dm-emoji-btn:hover { color: var(--text); background: var(--surface-3); }

.emoji-panel {
  position: absolute; z-index: 40;
  width: 260px; max-height: 200px; overflow-y: auto;
  display: grid; grid-template-columns: repeat(6, 1fr); gap: .2rem;
  padding: .45rem; border-radius: 12px;
  background: var(--surface-3); border: 1px solid var(--border);
  box-shadow: 0 12px 28px rgba(0,0,0,.35);
}
.emoji-cell {
  border: none; background: transparent; border-radius: 8px;
  font-size: 1.25rem; line-height: 1; padding: .35rem; cursor: pointer;
}
.emoji-cell:hover { background: var(--surface-2); }

#view-dm { position: relative; }

.msg-reply {
  font-size: .78rem; color: var(--muted);
  border-left: 2px solid var(--accent);
  padding: .15rem .55rem; margin: .2rem 0 .35rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.msg-reply-author { color: var(--accent); font-weight: 700; margin-right: .25rem; }

.msg-reactions {
  display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .35rem;
}
.msg-reaction {
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text); border-radius: 999px;
  padding: .1rem .45rem; font-size: .8rem; cursor: pointer;
  font-family: inherit;
}
.msg-reaction:hover { background: var(--surface-2); }
.msg-reaction.mine {
  border-color: var(--accent); background: var(--accent-soft);
}

#panel-dm-search, #panel-dm-pins {
  display: flex; flex-direction: column; min-height: 0; flex: 1;
}
#panel-dm-search.hidden, #panel-dm-pins.hidden { display: none !important; }
#panel-dm-search .dm-search-results,
#panel-dm-pins .dm-search-results {
  flex: 1; overflow-y: auto;
}

.sidebar-item--group .user-chip-avatar {
  background: var(--surface-3);
}
.msg-flash { outline: 2px solid var(--accent); border-radius: 8px; }
.msg[data-msg-id] { cursor: context-menu; }

.group-dm-check {
  width: 20px; height: 20px; border-radius: 5px; border: 2px solid var(--border);
  flex: 0 0 auto; display: grid; place-items: center;
}
.group-dm-check.on {
  background: var(--accent); border-color: var(--accent);
}
.group-dm-check.on::after {
  content: '';
  width: 5px; height: 9px;
  border: solid #fff; border-width: 0 2px 2px 0;
  transform: rotate(45deg); margin-bottom: 2px;
}
