.dx-root {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
  max-width: 720px;
  margin: 0 auto;
  min-height: calc(100vh - 140px);
}
.dx-list, .dx-thread, .dx-new {
  background: var(--bg-card, #fff);
  border-radius: 16px;
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}
/* majburiy yashirish */
.dx-thread[hidden],
.dx-new[hidden],
.dx-list[hidden] {
  display: none !important;
}

.dx-list-head, .dx-th-head {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.dx-title { font-size: 18px; font-weight: 800; display:flex; align-items:center; gap:8px; }
.dx-icon-btn {
  width: 36px; height: 36px; border-radius: 50%;
  border: none; background: var(--bg-hover, #f1f3f5);
  color: var(--text); cursor: pointer;
  display:flex; align-items:center; justify-content:center; font-size:15px;
}
.dx-icon-btn:hover { filter: brightness(.96); }
.dx-search-wrap {
  position: relative; margin: 10px 12px 6px; flex-shrink: 0;
}
.dx-search-wrap i {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); font-size: 13px;
}
.dx-search-wrap input {
  width: 100%; box-sizing: border-box;
  padding: 11px 14px 11px 38px;
  border-radius: 999px; border: 1px solid var(--border);
  background: var(--bg, #f5f7fa); color: var(--text); font-size: 14px; outline: none;
}
.dx-tabs {
  display: flex; gap: 8px; padding: 8px 12px 10px;
  overflow-x: auto; flex-shrink: 0;
}
.dx-tab {
  border: none; border-radius: 999px;
  padding: 8px 14px; font-size: 13px; font-weight: 700;
  background: var(--bg-hover, #eef2f7); color: var(--text-muted);
  cursor: pointer; white-space: nowrap;
}
.dx-tab.on { background: #2563eb; color: #fff; }
.dx-convs { flex: 1; overflow: auto; padding: 4px 0 12px; }
.dx-conv {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; cursor: pointer;
}
.dx-conv:hover { background: var(--bg-hover); }
.dx-conv img {
  width: 48px; height: 48px; border-radius: 50%; object-fit: cover; flex-shrink: 0;
}
.dx-conv-meta { flex: 1; min-width: 0; }
.dx-conv-top { display:flex; align-items:center; gap:6px; }
.dx-conv-name { font-weight: 700; font-size: 15px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.dx-conv-name img, .dx-conv-name .v-badge img {
  width: 14px !important; height: 14px !important;
}
.dx-conv-preview {
  font-size: 13px; color: var(--text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px;
}
.dx-conv-side { text-align: right; flex-shrink: 0; }
.dx-conv-time { font-size: 12px; color: var(--text-muted); }
.dx-unread {
  display: inline-block; min-width: 18px; padding: 2px 6px;
  border-radius: 999px; background: #2563eb; color: #fff;
  font-size: 11px; font-weight: 700; margin-top: 4px;
}
.dx-pin { color: var(--text-muted); font-size: 12px; margin-left: 4px; }

/* Thread */
.dx-th-peer { display:flex; align-items:center; gap:10px; flex:1; min-width:0; }
.dx-th-av { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; }
.dx-th-name { font-weight: 700; font-size: 15px; display:flex; align-items:center; gap:4px; }
.dx-th-name img { width: 14px !important; height: 14px !important; }
.dx-th-status { font-size: 12px; color: var(--text-muted); }
.dx-msgs {
  flex: 1; overflow-y: auto; padding: 12px 12px 16px;
  display: flex; flex-direction: column; gap: 8px;
  -webkit-overflow-scrolling: touch;
}
.dx-day {
  align-self: center; font-size: 12px; color: var(--text-muted);
  background: var(--bg-hover); padding: 4px 12px; border-radius: 999px; margin: 8px 0;
}
.dx-bubble {
  max-width: 82%; padding: 10px 14px; border-radius: 18px;
  font-size: 15px; line-height: 1.35; word-break: break-word;
  position: relative;
  margin-bottom: 4px;
}
.dx-bubble.mine {
  align-self: flex-end;
  background: #111; color: #fff;
  border-bottom-right-radius: 6px;
}
.dx-bubble.theirs {
  align-self: flex-start;
  background: #f1f3f5; color: var(--text);
  border-bottom-left-radius: 6px;
}
html.dark .dx-bubble.theirs, [data-theme=dark] .dx-bubble.theirs, body.dark .dx-bubble.theirs {
  background: #2a2a2e;
}
html.dark .dx-bubble.mine, [data-theme=dark] .dx-bubble.mine, body.dark .dx-bubble.mine {
  background: #e5e7eb; color: #111;
}
.dx-bubble a { color: #60a5fa; }
.dx-bubble.mine a { color: #93c5fd; }
.dx-bubble img.msg-img { max-width: 100%; border-radius: 12px; display:block; margin-top:4px; }
.dx-bubble .meta {
  font-size: 11px; opacity: .7; margin-top: 4px; text-align: right;
}
.dx-bubble.deleted { opacity: .6; font-style: italic; }
.dx-reply-quote {
  border-left: 3px solid #2563eb;
  padding: 4px 8px;
  margin-bottom: 6px;
  font-size: 13px;
  opacity: .9;
  border-radius: 0 8px 8px 0;
  background: rgba(37,99,235,.1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dx-bubble.mine .dx-reply-quote {
  border-left-color: rgba(255,255,255,.5);
  background: rgba(255,255,255,.12);
}

/* reactions — to'liq ko'rinsin */
.dx-reacts {
  display: flex;
  gap: 4px;
  margin-top: 6px;
  margin-bottom: 2px;
  flex-wrap: wrap;
  position: relative;
  z-index: 1;
}
.dx-react-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-card, #fff);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 13px;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
.dx-bubble.mine .dx-react-chip {
  background: #fff;
  color: #111;
}
.dx-react-chip img { width: 16px; height: 16px; border-radius: 50%; }


/* photo preview above compose */
.dx-photo-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-top: 1px solid var(--border);
  background: var(--bg-hover, #f5f7fa);
  flex-shrink: 0;
  position: relative;
}
.dx-photo-preview[hidden] { display: none !important; }
.dx-photo-preview img {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--border);
}
.dx-photo-x {
  position: absolute;
  top: 4px;
  left: 60px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: none;
  background: #111;
  color: #fff;
  font-size: 11px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.dx-compose {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; border-top: 1px solid var(--border); flex-shrink: 0;
  position: relative;
}
.dx-compose input[type=text] {
  flex: 1; border: none; background: var(--bg, #f1f3f5);
  border-radius: 999px; padding: 12px 16px; font-size: 15px;
  color: var(--text); outline: none;
}
.dx-send {
  width: 42px; height: 42px; border-radius: 50%; border: none;
  background: #2563eb; color: #fff; cursor: pointer; font-size: 16px;
  display:flex; align-items:center; justify-content:center;
}

/* Reply bar — ism + xabar */
.dx-reply-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--bg-hover, #f1f3f5);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.dx-reply-bar::before {
  content: '';
  width: 3px;
  align-self: stretch;
  background: #2563eb;
  border-radius: 2px;
  flex-shrink: 0;
}
.dx-reply-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.dx-reply-info .rn {
  font-size: 12px;
  font-weight: 700;
  color: #2563eb;
}
.dx-reply-info .rt {
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dx-attach-menu {
  position: absolute; bottom: 70px; left: 16px;
  background: var(--bg-card, #fff); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: 0 8px 28px rgba(0,0,0,.12);
  padding: 6px; z-index: 30;
}
.dx-attach-menu button {
  display:flex; align-items:center; gap:10px; width:100%;
  border:none; background:transparent; padding:10px 14px;
  font-size:14px; cursor:pointer; color:var(--text); border-radius:10px;
}
.dx-attach-menu button:hover { background: var(--bg-hover); }

.dx-menu {
  position: fixed; z-index: 6000;
  background: var(--bg-card, #fff); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: 0 12px 40px rgba(0,0,0,.15);
  padding: 6px; min-width: 200px;
}
.dx-menu button {
  display:flex; align-items:center; gap:10px; width:100%;
  border:none; background:transparent; padding:11px 14px;
  font-size:14px; cursor:pointer; color:var(--text); border-radius:10px; text-align:left;
}
.dx-menu button:hover { background: var(--bg-hover); }
.dx-menu button.danger { color: #ef4444; }

.dx-react-picker {
  position: fixed; z-index: 6001;
  background: var(--bg-card,#fff); border:1px solid var(--border);
  border-radius: 999px; padding: 6px 10px;
  display:flex; gap:4px; box-shadow: 0 8px 24px rgba(0,0,0,.15);
}
.dx-react-picker button {
  border:none; background:transparent; font-size:22px; cursor:pointer; padding:4px;
}

.dx-empty {
  text-align:center; color:var(--text-muted); padding:48px 16px;
}
.dx-empty i { font-size: 40px; margin-bottom: 12px; display:block; }
.dx-user-row {
  display:flex; align-items:center; gap:12px; padding:10px 14px; cursor:pointer;
}
.dx-user-row:hover { background: var(--bg-hover); }
.dx-user-row img { width:44px; height:44px; border-radius:50%; object-fit:cover; }
.dx-user-row .n { font-weight:700; }
.dx-user-row .n img { width:14px!important; height:14px!important; }
.dx-user-row .h { font-size:12px; color:var(--text-muted); }

.dx-user-res { flex:1; overflow:auto; }

@media (min-width: 901px) {
  .dx-root {
    max-width: 1000px;
    height: calc(100vh - 100px);
  }
  .dx-root.has-thread {
    grid-template-columns: 360px 1fr;
  }
  .dx-root:not(.has-thread) {
    grid-template-columns: 1fr;
    max-width: 420px;
  }
  .dx-root.has-new {
    grid-template-columns: 1fr;
    max-width: 480px;
  }
  .dx-thread:not([hidden]) { display: flex !important; }
  .dx-new:not([hidden]) { display: flex !important; }
}

@media (max-width: 900px) {
  .dx-root {
    position: fixed;
    left: 0;
    right: 0;
    top: 56px;
    bottom: calc(64px + env(safe-area-inset-bottom, 0px));
    max-width: none;
    margin: 0;
    padding: 0;
    border-radius: 0;
    z-index: 40;
    height: auto;
    min-height: 0;
  }
  .dx-list, .dx-thread, .dx-new {
    border-radius: 0;
    border: none;
    height: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
  }
  .dx-list.hidden { display: none !important; }
  .dx-thread:not([hidden]) { display: flex !important; }
  .dx-new:not([hidden]) { display: flex !important; }

  .dx-msgs {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }

  .dx-compose {
    display: flex !important;
    flex-shrink: 0;
    position: relative;
    z-index: 5;
    background: var(--bg-card, #fff);
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--border);
  }

  /* SMS yozish: title + bottom bar yashiriladi */
  body.dx-chat-open .topbar,
  body.dx-chat-open .site-header,
  body.dx-chat-open header.topbar,
  body.dx-chat-open .bottom-bar,
  body.dx-chat-open nav.bottom-bar,
  body.dx-chat-open .bottom-nav {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
  }
  body.dx-chat-open .dx-root {
    top: 0 !important;
    bottom: 0 !important;
    z-index: 200 !important;
    background: var(--bg-card, #fff);
  }
  body.dx-chat-open {
    overflow: hidden !important;
  }
}

/* photo preview above compose */
.dx-photo-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-top: 1px solid var(--border);
  background: var(--bg-hover, #f5f7fa);
  flex-shrink: 0;
  position: relative;
}
.dx-photo-preview[hidden] { display: none !important; }
.dx-photo-preview img {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--border);
}
.dx-photo-x {
  position: absolute;
  top: 4px;
  left: 60px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: none;
  background: #111;
  color: #fff;
  font-size: 11px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.dx-react-picker[hidden],
.dx-menu[hidden],
.dx-attach-menu[hidden],
.dx-reply-bar[hidden] {
  display: none !important;
}
.dx-react-picker:not([hidden]) {
  display: flex !important;
}

/* Direct online */
.dx-th-av-wrap {
  position: relative;
  display: inline-block;
  flex-shrink: 0;
  width: 40px;
  height: 40px;
}
.dx-th-av-wrap .dx-th-av {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}
.dx-th-av-wrap .online-dot{width:8px;height:8px;right:1px;bottom:1px}
.dx-th-status.on {
  color: #22c55e !important;
  font-weight: 600;
}
.dx-conv {
  display: flex;
  align-items: center;
  gap: 12px;
}
.dx-conv-av {
  position: relative;
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  display: block;
}
.dx-conv-av img {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}
.dx-conv-av .online-dot{width:8px;height:8px;right:1px;bottom:1px}
.dx-conv-status {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dx-conv-status.on {
  color: #22c55e;
  font-weight: 600;
}

/* Direct layout fixes — mobile/PC */
.dm-page, .direct-page, .messages-wrap {
  padding-top: max(8px, env(safe-area-inset-top, 0px));
}
.dm-header, .direct-header, .msg-top {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bg, #fff);
  padding-top: max(8px, env(safe-area-inset-top, 0px));
  margin-top: 0 !important;
}
.dm-title, .direct-title {
  font-size: 20px;
  font-weight: 800;
  margin: 8px 0 12px;
  line-height: 1.2;
}
.dm-search, .direct-search input {
  margin-top: 0 !important;
}
@media (max-width: 768px) {
  .main-wrap .content:has(.dm-list),
  .messages-page .content {
    padding-top: 4px !important;
  }
  .topbar + .content .dm-wrap {
    margin-top: 0;
  }
}


.dx-conv-av,.dx-th-av-wrap{position:relative;overflow:visible}
