/* ── OVERLAY ── */
#viewer-overlay {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  z-index: 9999; background: #0e1621; overflow: hidden;
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.4,0,0.2,1);
}
#viewer-overlay.open { transform: translateX(0); }

/* ── PANELS (two full-width screens side by side) ── */
#vapp {
  display: flex; width: 200%; height: 100%;
  transition: transform 0.28s cubic-bezier(0.4,0,0.2,1);
}
#vapp.in-chat { transform: translateX(-50%); }

#vscreen-dialogs, #vscreen-chat {
  width: 50%; height: 100%;
  display: flex; flex-direction: column;
  font-family: -apple-system, 'Segoe UI', Roboto, sans-serif;
}
#vscreen-dialogs { background: #17212b; }
#vscreen-chat    { background: #0e1621; }

/* ── TOP BAR ── */
.vtop-bar {
  height: 56px; padding: 0 8px 0 4px;
  display: flex; align-items: center; gap: 4px;
  background: #17212b;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  flex-shrink: 0;
}
.vback-btn {
  background: none; border: none; color: #71bafa;
  font-size: 32px; line-height: 1; cursor: pointer;
  padding: 4px 8px; border-radius: 50%;
  transition: background 0.15s; flex-shrink: 0;
}
.vback-btn:hover, .vback-btn:active { background: rgba(255,255,255,0.1); }
.chat-name-link { cursor: pointer; }
.chat-name-link:active { opacity: 0.7; }
#account-title, #chat-name {
  font-size: 16px; font-weight: 600; color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ── DIALOGS LIST ── */
/* ── TABS ── */
#dialog-tabs {
  display: flex; overflow-x: auto; gap: 4px; padding: 8px 10px;
  background: #17212b; border-bottom: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0; scrollbar-width: none;
}
#dialog-tabs::-webkit-scrollbar { display: none; }
.dtab {
  background: rgba(255,255,255,0.07); border: none; color: #aaa;
  padding: 5px 12px; border-radius: 14px; font-size: 12px; cursor: pointer;
  white-space: nowrap; transition: background 0.15s, color 0.15s; flex-shrink: 0;
}
.dtab.active { background: #2b5278; color: #fff; }
.dtab:active { opacity: 0.8; }

#dialogs-list { flex: 1; overflow-y: auto; }
#dialogs-list::-webkit-scrollbar { width: 3px; }
#dialogs-list::-webkit-scrollbar-thumb { background: #2b3c4e; }

.dialog-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; cursor: pointer;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  transition: background 0.12s;
  min-height: 64px;
}
.dialog-item:active { background: #1f2f3d; }
.dialog-avatar {
  width: 46px; height: 46px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; background: #2b3c4e;
}
.dialog-info { flex: 1; min-width: 0; }
.dialog-row1 { display: flex; justify-content: space-between; align-items: center; margin-bottom: 3px; }
.dialog-dname { font-size: 15px; font-weight: 500; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 70%; }
.dialog-date  { font-size: 12px; color: #708499; flex-shrink: 0; }
.dialog-row2  { display: flex; justify-content: space-between; align-items: center; }
.dialog-last  { font-size: 13px; color: #708499; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.unread-badge { background: #5288c1; color: #fff; font-size: 11px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; margin-left: 6px; }

/* ── MESSAGES ── */
#messages-wrap {
  flex: 1; overflow-y: auto; padding: 10px 12px;
  display: flex; flex-direction: column; gap: 3px;
}
#messages-wrap::-webkit-scrollbar { width: 3px; }
#messages-wrap::-webkit-scrollbar-thumb { background: #1f2f3d; }

#load-more-wrap { text-align: center; padding: 8px 0; }
#btn-load-more {
  background: #17212b; border: 1px solid #2b3c4e; color: #71bafa;
  padding: 6px 18px; border-radius: 16px; cursor: pointer; font-size: 13px;
}

.msg-wrap { display: flex; margin: 1px 0; }
.date-sep { display: flex; align-items: center; justify-content: center; margin: 10px 0; }
.date-sep span { background: rgba(255,255,255,0.10); color: rgba(255,255,255,0.55); font-size: 12px; padding: 3px 10px; border-radius: 10px; }
.msg-wrap.out { justify-content: flex-end; }
.msg-wrap.in  { justify-content: flex-start; }
.msg {
  max-width: 78%; padding: 8px 12px; border-radius: 18px;
  font-size: 14px; line-height: 1.5; word-break: break-word; color: #fff;
}
.msg.out { background: #2b5278; border-bottom-right-radius: 4px; }
.msg.in  { background: #182533; border-bottom-left-radius: 4px; }
.msg-sender { font-size: 12px; color: #71bafa; margin-bottom: 3px; font-weight: 600; }
.msg-meta   { font-size: 11px; color: rgba(255,255,255,0.38); margin-top: 4px; text-align: right; }
.msg-file-card {
  display: flex; align-items: center; gap: 10px;
  background: rgba(255,255,255,0.07); border-radius: 10px;
  padding: 10px 12px; margin-top: 4px; min-width: 180px;
}
.msg-file-card > :first-child { font-size: 24px; flex-shrink: 0; }
.file-meta { flex: 1; min-width: 0; }
.file-name { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-size { font-size: 11px; color: rgba(255,255,255,0.45); margin-top: 2px; }
.file-dl-btn {
  background: none; border: none; color: #71bafa; font-size: 20px;
  cursor: pointer; padding: 4px; border-radius: 50%; flex-shrink: 0;
  transition: background 0.15s;
}
.file-dl-btn:hover { background: rgba(255,255,255,0.1); }
.msg-voice-card {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 0; min-width: 180px;
}
.voice-play-btn {
  width: 36px; height: 36px; border-radius: 50%; border: none;
  background: rgba(255,255,255,0.15); color: #fff; font-size: 14px;
  cursor: pointer; flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
}
.voice-play-btn:active { background: rgba(255,255,255,0.25); }
.voice-meta { flex: 1; min-width: 0; }
.voice-bar { height: 16px; background: rgba(255,255,255,0.12); border-radius: 4px; overflow: hidden; margin-bottom: 3px; }
.voice-wave { height: 100%; width: 30%; background: rgba(255,255,255,0.3); border-radius: 4px; }
.voice-dur { font-size: 11px; color: rgba(255,255,255,0.5); }

.msg-sticker { width: 120px; height: 120px; object-fit: contain; cursor: pointer; display: block; }
.msg-photo  {
  max-width: 240px; max-height: 300px; border-radius: 12px;
  margin-top: 4px; cursor: pointer; display: block;
  width: 100%; object-fit: cover;
}

/* ── PHOTO LIGHTBOX ── */
#photo-lb {
  display: none; position: absolute; inset: 0;
  background: rgba(0,0,0,0.92); z-index: 100;
  align-items: center; justify-content: center;
  cursor: zoom-out;
}
#photo-lb.show { display: flex; }
#photo-lb-img {
  max-width: 96%; max-height: 92vh;
  border-radius: 8px; object-fit: contain;
}

/* ── SPINNER ── */
.spinner { text-align: center; padding: 28px 16px; color: #708499; font-size: 14px; }
