/* Cometa Messenger — Sleek Cosmic Violet Theme (Telegram + Discord Fusion) */
:root {
  --bg-darkest: #090611;
  --bg-primary: #0e0a1a;
  --bg-secondary: #150f28;
  --bg-sidebar: #120d22;
  --bg-channel: #18112e;
  --bg-card: #1f163b;
  --bg-input: #17102b;
  --bg-hover: rgba(168, 85, 247, 0.14);
  --bg-active: rgba(168, 85, 247, 0.24);

  --accent-purple: #7e22ce;
  --accent-violet: #9333ea;
  --accent-neon: #a855f7;
  --accent-glow: #c084fc;
  --accent-light: #e9d5ff;
  --accent-white: #faf5ff;

  --status-online: #10b981;
  --status-idle: #f59e0b;
  --status-dnd: #ef4444;
  --status-offline: #6b7280;

  --danger-color: #f43f5e;
  --success-color: #10b981;
  --warning-color: #f59e0b;

  --text-main: #f8fafc;
  --text-sub: #cbd5e1;
  --text-muted: #94a3b8;
  --text-purple: #c084fc;

  --border-subtle: rgba(168, 85, 247, 0.18);
  --border-highlight: rgba(192, 132, 252, 0.45);
  --glass-bg: rgba(22, 15, 41, 0.75);
  --glass-border: rgba(168, 85, 247, 0.25);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
  --glow-shadow: 0 0 20px rgba(168, 85, 247, 0.35);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-darkest);
  color: var(--text-main);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(168, 85, 247, 0.25);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(168, 85, 247, 0.5);
}

/* Main Layout Grid */
#app {
  display: flex;
  width: 100vw;
  height: 100vh;
  background: radial-gradient(circle at 10% 20%, #170d2f 0%, #090611 90%);
  overflow: hidden;
}

/* ========================================================
   SERVER / WORKSPACE DOCK (REMOVED - CLEAN UNIFIED SIDEBAR)
   ======================================================== */
.server-dock {
  display: none !important;
}

.dock-item {
  position: relative;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  color: var(--text-purple);
  font-size: 20px;
}

.dock-item:hover, .dock-item.active {
  border-radius: var(--radius-md);
  background: var(--accent-violet);
  color: #ffffff;
  box-shadow: 0 0 15px rgba(168, 85, 247, 0.5);
}

.dock-item.active::before {
  content: '';
  position: absolute;
  left: -12px;
  top: 12px;
  width: 4px;
  height: 24px;
  background: #ffffff;
  border-radius: 0 4px 4px 0;
  box-shadow: 0 0 8px #ffffff;
}

.dock-logo {
  width: 48px;
  height: 48px;
  padding: 4px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #3b0764, #7e22ce);
  box-shadow: 0 0 12px rgba(168, 85, 247, 0.4);
}
.dock-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 0 6px rgba(255,255,255,0.4));
}

.dock-divider {
  width: 32px;
  height: 2px;
  background: var(--border-subtle);
  margin: 4px 0;
}

/* ========================================================
   CHANNELS & DM SIDEBAR (TELEGRAM + DISCORD)
   ======================================================== */
.sidebar {
  width: 305px;
  height: 100%;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: relative;
  z-index: 10;
}

/* Header */
.sidebar-header {
  height: 56px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(18, 13, 34, 0.7);
  backdrop-filter: blur(10px);
}

.header-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 17px;
  letter-spacing: 0.5px;
  color: var(--text-main);
}
.header-comet-badge {
  color: var(--accent-neon);
  text-shadow: 0 0 8px var(--accent-neon);
}

.sidebar-tab-switch {
  display: flex;
  margin: 10px 14px 6px;
  padding: 3px;
  background: var(--bg-darkest);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}
.sidebar-tab-btn {
  flex: 1;
  padding: 6px 0;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 12.5px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  line-height: 1;
}
.sidebar-tab-btn span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  font-size: 13.5px;
}
#tab-btn-dms span {
  transform: translateY(-2px);
}
.sidebar-tab-btn.active {
  background: var(--bg-card);
  color: var(--text-main);
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

/* Search bar */
.sidebar-search-box {
  padding: 6px 14px 10px;
}
.search-input-wrap {
  position: relative;
  width: 100%;
}
.search-input-wrap input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 7px 12px 7px 32px;
  color: var(--text-main);
  font-size: 13px;
  outline: none;
  transition: var(--transition);
}
.search-input-wrap input:focus {
  border-color: var(--accent-neon);
  box-shadow: 0 0 10px rgba(168, 85, 247, 0.25);
}
.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 13px;
  color: var(--text-muted);
}

/* Scrollable channels / DMs list */
.sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 6px 10px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.category-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.category-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  cursor: pointer;
}
.category-header:hover {
  color: var(--text-sub);
}
.add-channel-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 15px;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  transition: var(--transition);
}
.add-channel-btn:hover {
  color: var(--accent-light);
  background: var(--bg-hover);
}

/* Channel / Chat item */
.nav-item {
  display: flex;
  align-items: center;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  cursor: pointer;
  color: var(--text-sub);
  font-size: 14px;
  gap: 10px;
  transition: var(--transition);
  position: relative;
}
.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-main);
}
.nav-item.active {
  background: var(--bg-active);
  color: #ffffff;
  border-left: 3px solid var(--accent-neon);
}
.nav-item .item-icon {
  font-size: 16px;
  color: var(--accent-purple);
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}
.nav-item.active .item-icon {
  color: var(--accent-glow);
}
.nav-item .item-name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
}
.nav-item .unread-badge {
  background: var(--accent-violet);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  box-shadow: 0 0 8px rgba(168, 85, 247, 0.6);
}

/* Voice Channel specific item with participants nested list */
.voice-channel-wrap {
  display: flex;
  flex-direction: column;
}
.voice-participants-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-left: 28px;
  margin-bottom: 6px;
}
.voice-participant {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  border-radius: 6px;
  font-size: 12px;
  color: var(--text-sub);
  transition: background 0.15s ease, color 0.15s ease;
}
.voice-participant.speaking {
  color: #fff;
  background: rgba(35, 165, 90, 0.12);
}
.voice-participant.speaking .part-avatar {
  border-color: #23a55a !important;
  box-shadow: 0 0 0 2px #23a55a, 0 0 8px rgba(35, 165, 90, 0.8) !important;
  animation: speakingAvatarPulse 1.4s infinite ease-in-out;
}
.part-avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1.5px solid var(--border-subtle);
  object-fit: cover;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.part-name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.part-status-icons {
  display: flex;
  gap: 4px;
  font-size: 11px;
  color: var(--danger-color);
}

/* DM User Item */
.dm-user-item {
  display: flex;
  align-items: center;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  cursor: pointer;
  gap: 10px;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
  box-sizing: border-box;
  width: 100%;
}
.dm-user-item:hover {
  background: var(--bg-hover);
}
.dm-user-item.active {
  background: var(--bg-active);
  border-left: 3px solid var(--accent-neon);
}
.dm-avatar-wrap {
  position: relative;
  width: 36px;
  height: 36px;
  flex-shrink: 0;
}
.dm-avatar {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--border-subtle);
}
.status-dot {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 2px solid var(--bg-sidebar);
}
.status-dot.online { background: var(--status-online); }
.status-dot.idle { background: var(--status-idle); }
.status-dot.dnd { background: var(--status-dnd); }
.status-dot.offline { background: var(--status-offline); }

.dm-info {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  overflow: hidden;
}
.dm-main-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.25;
}
.dm-sub-title {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}

.dm-name-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
  overflow: hidden;
}
.dm-name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.dm-status-text {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.dm-user-tag {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 0;
}

.dm-actions-wrap {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
  margin-left: auto;
}

.dm-action-icon-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  padding: 0;
  flex-shrink: 0;
}
.dm-action-icon-btn:hover {
  background: rgba(168, 85, 247, 0.25);
  border-color: var(--accent-neon);
  color: #fff;
  transform: translateY(-1px);
}
.dm-action-icon-btn.call:hover {
  background: rgba(34, 197, 94, 0.25);
  border-color: #22c55e;
  color: #4ade80;
}
.dm-action-icon-btn.remove:hover {
  background: rgba(239, 68, 68, 0.25);
  border-color: #ef4444;
  color: #f87171;
}
.dm-close-btn {
  opacity: 0;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: var(--transition);
  margin-left: auto;
}
.dm-user-item:hover .dm-close-btn {
  opacity: 0.7;
}
.dm-close-btn:hover {
  opacity: 1 !important;
  color: var(--danger-color);
  background: rgba(244, 63, 94, 0.15);
}
.find-by-username-card {
  padding: 2px 0 6px;
}
.btn-find-username {
  width: 100%;
  background: rgba(168, 85, 247, 0.12);
  border: 1px dashed rgba(168, 85, 247, 0.45);
  color: var(--accent-light);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  font-size: 12.5px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: var(--transition);
}
.btn-find-username:hover {
  background: rgba(168, 85, 247, 0.22);
  border-color: var(--accent-neon);
  color: #fff;
  box-shadow: 0 0 12px rgba(168, 85, 247, 0.25);
}
.empty-dms-card {
  padding: 24px 16px;
  text-align: center;
  background: rgba(255, 255, 255, 0.02);
  border: 1px dashed var(--border-subtle);
  border-radius: var(--radius-lg);
  margin: 6px 0;
}
.btn-find-username-secondary {
  background: rgba(168, 85, 247, 0.15);
  border: 1px solid var(--accent-primary);
  color: #fff;
  padding: 6px 14px;
  border-radius: var(--radius-md);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}
.btn-find-username-secondary:hover {
  background: var(--accent-primary);
  box-shadow: 0 0 10px rgba(168, 85, 247, 0.4);
}
.search-result-user-item {
  position: relative;
}
.btn-start-chat-pill {
  background: var(--accent-primary);
  border: none;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 20px;
  cursor: pointer;
  transition: var(--transition);
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
}
.btn-start-chat-pill:hover {
  background: var(--accent-neon);
  box-shadow: 0 0 10px rgba(168, 85, 247, 0.6);
  transform: translateY(-1px);
}
.btn-view-profile-pill {
  background: rgba(168, 85, 247, 0.15);
  border: 1px solid rgba(168, 85, 247, 0.4);
  color: var(--accent-light);
  font-size: 11px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 20px;
  cursor: pointer;
  transition: var(--transition);
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.btn-view-profile-pill:hover {
  background: rgba(168, 85, 247, 0.35);
  border-color: var(--accent-neon);
  color: #fff;
  transform: translateY(-1px);
}
.btn-friend-pill {
  background: rgba(34, 197, 94, 0.15);
  border: 1px solid rgba(34, 197, 94, 0.4);
  color: #4ade80;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 9px;
  border-radius: 20px;
  cursor: pointer;
  transition: var(--transition);
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  white-space: nowrap;
}
.btn-friend-pill:hover {
  background: rgba(34, 197, 94, 0.35);
  border-color: #22c55e;
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.4);
}
.btn-is-friend {
  background: rgba(168, 85, 247, 0.15);
  border: 1px solid rgba(168, 85, 247, 0.4);
  color: #c084fc;
  font-size: 10.5px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 20px;
  cursor: default;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
  white-space: nowrap;
}
.btn-remove-friend-pill {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #f87171;
  font-size: 11px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  padding: 0;
}
.btn-remove-friend-pill:hover {
  background: rgba(239, 68, 68, 0.35);
  border-color: #ef4444;
  color: #fff;
  transform: scale(1.1);
}
.btn-delete-chat-header {
  color: #f87171 !important;
  border-color: rgba(239, 68, 68, 0.3) !important;
}
.btn-delete-chat-header:hover {
  background: rgba(239, 68, 68, 0.25) !important;
  border-color: #ef4444 !important;
  color: #fff !important;
}
.friends-empty-hint {
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px dashed rgba(168, 85, 247, 0.25);
  border-radius: var(--radius-md);
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.4;
  margin: 4px 6px 12px;
}
.search-results-header {
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 6px;
}
.empty-search-state {
  background: rgba(255, 255, 255, 0.02);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  margin: 8px 0;
}

/* User Profile Panel at Sidebar Bottom */
.current-user-bar {
  height: 56px;
  background: rgba(14, 10, 26, 0.95);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  padding: 0 6px 0 8px;
  gap: 4px;
}
.user-bar-profile {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
  cursor: pointer;
  padding: 3px 4px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}
.user-bar-profile:hover {
  background: var(--bg-hover);
}
.bar-avatar-wrap {
  position: relative;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
}
.bar-avatar {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  border: 1.5px solid var(--border-highlight);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.bar-avatar.speaking {
  border-color: #23a55a !important;
  box-shadow: 0 0 0 2px #23a55a, 0 0 8px rgba(35, 165, 90, 0.8) !important;
  animation: speakingAvatarPulse 1.4s infinite ease-in-out;
}
.user-bar-names {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}
.bar-display-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.25;
}
.bar-username {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}

.user-bar-actions {
  display: flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
}
.bar-action-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  font-size: 15px;
  padding: 0;
}
.bar-action-btn:hover {
  background: var(--bg-hover);
  color: var(--text-main);
}
.bar-action-btn.active-muted {
  color: var(--danger-color);
  background: rgba(244, 63, 94, 0.15);
}

/* ========================================================
   MAIN CHAT & CALL CONTAINER
   ======================================================== */
.chat-container {
  flex: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
  min-width: 0;
  position: relative;
}

/* Chat Header */
.chat-header {
  height: 56px;
  padding: 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(14, 10, 26, 0.7);
  backdrop-filter: blur(10px);
  z-index: 10;
  flex-shrink: 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.header-chan-icon {
  font-size: 20px;
  color: var(--accent-neon);
}
.header-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.header-name {
  font-size: 16px;
  font-weight: 700;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.header-topic {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.header-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-sub);
  height: 34px;
  padding: 0 12px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: var(--transition);
}
.header-btn:hover {
  background: var(--bg-hover);
  color: var(--text-main);
  border-color: var(--border-highlight);
}
.header-btn.btn-call {
  background: linear-gradient(135deg, rgba(147, 51, 234, 0.3), rgba(168, 85, 247, 0.4));
  border-color: var(--accent-neon);
  color: #ffffff;
}
.header-btn.btn-call:hover {
  background: var(--accent-violet);
  box-shadow: 0 0 12px rgba(168, 85, 247, 0.6);
}
.header-btn.active {
  background: rgba(168, 85, 247, 0.25);
  border-color: var(--accent-neon);
  color: #ffffff;
}

/* ========================================================
   CALL & VIDEO GRID VIEW
   ======================================================== */
.call-view-area {
  background: #090514;
  border-bottom: 2px solid var(--border-subtle);
  display: none;
  flex-direction: column;
  height: 48%;
  min-height: 280px;
  position: relative;
  overflow: hidden;
  transition: height 0.3s ease;
}
.call-view-area.active {
  display: flex;
}
.call-view-area.fullscreen {
  height: 100%;
}
.call-view-area.minimized {
  display: none !important;
}

/* Floating Minimized Call Widget (PiP) */
.floating-call-pip {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  background: rgba(18, 12, 34, 0.94);
  backdrop-filter: blur(14px);
  border: 1px solid var(--accent-neon);
  box-shadow: 0 10px 35px rgba(0, 0, 0, 0.7), 0 0 24px rgba(168, 85, 247, 0.35);
  border-radius: 16px;
  padding: 8px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  animation: slideInUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
}

.pip-main {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  padding-right: 8px;
  border-right: 1px solid rgba(255, 255, 255, 0.12);
  transition: opacity 0.2s ease;
}
.pip-main:hover {
  opacity: 0.85;
}

.pip-pulse-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 10px #22c55e;
  animation: pipPulse 1.8s infinite;
}

@keyframes pipPulse {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7); }
  70% { transform: scale(1.1); box-shadow: 0 0 0 8px rgba(34, 197, 94, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

.pip-info {
  display: flex;
  flex-direction: column;
}

.pip-title {
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pip-timer {
  font-size: 11px;
  font-family: monospace;
  font-weight: 600;
  color: var(--accent-light);
}

.pip-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.pip-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: all 0.2s ease;
}

.pip-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.08);
}

.pip-btn.active-off {
  background: rgba(239, 68, 68, 0.25);
  border-color: rgba(239, 68, 68, 0.5);
  color: #f87171;
}

.pip-btn.pip-btn-hangup {
  background: rgba(239, 68, 68, 0.3);
  border-color: #ef4444;
}

.pip-btn.pip-btn-hangup:hover {
  background: #ef4444;
}

.pip-btn.pip-btn-expand {
  background: rgba(168, 85, 247, 0.25);
  border-color: var(--accent-neon);
  font-size: 13px;
}

.call-header-bar {
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(14, 10, 26, 0.85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border-subtle);
}
.call-title-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--accent-light);
}
.call-network-badge {
  font-size: 11px;
  background: rgba(16, 185, 129, 0.15);
  color: var(--status-online);
  padding: 2px 8px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.video-grid-container {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
  padding: 14px;
  overflow-y: auto;
  align-items: center;
  justify-content: center;
}

/* Video / Audio participant card */
/* Voice speaking avatar ring & pulse animation */
@keyframes speakingAvatarPulse {
  0% {
    box-shadow: 0 0 0 3px #23a55a, 0 0 10px rgba(35, 165, 90, 0.6);
  }
  50% {
    box-shadow: 0 0 0 4.5px #2ecc71, 0 0 22px rgba(46, 204, 113, 0.9);
  }
  100% {
    box-shadow: 0 0 0 3px #23a55a, 0 0 10px rgba(35, 165, 90, 0.6);
  }
}

.peer-card {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 180px;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 2px solid var(--border-subtle);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  transition: var(--transition);
}
.peer-card.speaking {
  border-color: #23a55a;
  box-shadow: 0 0 20px rgba(35, 165, 90, 0.35), 0 8px 24px rgba(0,0,0,0.5);
}

.peer-video {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
}
.peer-video.active {
  display: block;
}

.peer-avatar-wrap {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  position: relative;
  z-index: 2;
  box-shadow: 0 0 20px rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.peer-avatar-wrap img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid rgba(168, 85, 247, 0.25);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

/* Outline around player avatar when speaking in voice chat */
.peer-card.speaking .peer-avatar-wrap img,
.peer-avatar-wrap.speaking img {
  border-color: #23a55a !important;
  animation: speakingAvatarPulse 1.4s infinite ease-in-out;
}
.peer-card.speaking .peer-avatar-wrap,
.peer-avatar-wrap.speaking {
  transform: scale(1.05);
}

.peer-info-badge {
  position: absolute;
  bottom: 10px;
  left: 10px;
  background: rgba(14, 10, 26, 0.75);
  backdrop-filter: blur(6px);
  padding: 4px 10px;
  border-radius: var(--radius-md);
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  z-index: 3;
}
.peer-mute-icon {
  color: var(--danger-color);
  font-size: 13px;
}

/* Floating Call Controls Bar */
.call-controls-bar {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(18, 13, 34, 0.88);
  backdrop-filter: blur(12px);
  padding: 8px 16px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-highlight);
  box-shadow: 0 10px 30px rgba(0,0,0,0.6), 0 0 15px rgba(168, 85, 247, 0.3);
  z-index: 10;
}

.ctrl-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--border-subtle);
  background: var(--bg-card);
  color: #ffffff;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}
.ctrl-btn:hover {
  background: var(--bg-hover);
  border-color: var(--accent-neon);
  transform: translateY(-2px);
}
.ctrl-btn.active-off {
  background: var(--danger-color);
  border-color: var(--danger-color);
  color: #ffffff;
}
.ctrl-btn.btn-hangup {
  background: #e11d48;
  border-color: #f43f5e;
}
.ctrl-btn.btn-hangup:hover {
  background: #be123c;
  box-shadow: 0 0 15px rgba(225, 29, 72, 0.6);
}

/* ========================================================
   MESSAGES STREAM
   ======================================================== */
.messages-viewport {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Channel Welcome Banner */
.channel-welcome-banner {
  margin-bottom: 20px;
  padding: 24px;
  background: linear-gradient(135deg, rgba(59, 7, 100, 0.35), rgba(15, 10, 26, 0.6));
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
}
.welcome-icon {
  font-size: 40px;
  margin-bottom: 10px;
  display: inline-block;
  filter: drop-shadow(0 0 10px var(--accent-neon));
}
.welcome-title {
  font-size: 22px;
  font-weight: 800;
  color: #ffffff;
  margin-bottom: 6px;
}
.welcome-desc {
  font-size: 14px;
  color: var(--text-sub);
  line-height: 1.5;
}

/* DM Interlocutor Profile Banner at Top of Chat */
.dm-welcome-banner {
  margin-bottom: 24px;
  padding: 22px 24px;
  background: linear-gradient(135deg, rgba(88, 28, 135, 0.35), rgba(15, 10, 26, 0.75));
  border-radius: var(--radius-lg);
  border: 1px solid rgba(168, 85, 247, 0.25);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: flex-start;
  gap: 18px;
}
.dm-welcome-avatar-wrap {
  position: relative;
  flex-shrink: 0;
}
.dm-welcome-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 3px solid var(--accent-neon);
  box-shadow: 0 0 16px rgba(168, 85, 247, 0.4);
  object-fit: cover;
  transition: transform 0.2s ease;
}
.dm-welcome-avatar-wrap:hover .dm-welcome-avatar {
  transform: scale(1.05);
}
.dm-welcome-details {
  flex: 1;
  min-width: 0;
}
.dm-welcome-name {
  font-size: 20px;
  font-weight: 800;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.dm-welcome-tag {
  font-size: 13px;
  font-weight: 500;
  color: var(--accent-light);
  background: rgba(168, 85, 247, 0.15);
  padding: 2px 8px;
  border-radius: 12px;
}
.dm-welcome-status {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
  margin-bottom: 8px;
}
.dm-welcome-bio {
  font-size: 13.5px;
  color: var(--text-sub);
  line-height: 1.5;
  margin-bottom: 14px;
  max-width: 600px;
}
.dm-welcome-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.btn-profile-action {
  background: rgba(168, 85, 247, 0.2);
  border: 1px solid var(--accent-neon);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  padding: 7px 16px;
  border-radius: 8px;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn-profile-action * {
  pointer-events: none;
}
.btn-profile-action:hover {
  background: var(--accent-primary);
  box-shadow: 0 0 12px rgba(168, 85, 247, 0.5);
  transform: translateY(-1px);
}
.btn-profile-action.btn-call-action {
  background: rgba(34, 197, 94, 0.2);
  border-color: #22c55e;
  color: #86efac;
}
.btn-profile-action.btn-call-action:hover {
  background: #16a34a;
  color: #fff;
  box-shadow: 0 0 12px rgba(34, 197, 94, 0.5);
}

/* ========================================================
   TELEGRAM-STYLE SPEECH BUBBLES ("ОБЛАЧКА СООБЩЕНИЙ")
   ======================================================== */
.messages-viewport {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Centered date pill divider ("24 сентября") matching screenshot 2 */
.chat-date-separator {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  margin: 16px 0 10px;
  position: relative;
  z-index: 2;
  pointer-events: none;
}

.chat-date-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(18, 9, 28, 0.75);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(168, 85, 247, 0.22);
  color: #ffffff;
  font-size: 13px;
  font-weight: 700;
  padding: 4px 16px;
  border-radius: 18px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
  letter-spacing: 0.2px;
  user-select: none;
  pointer-events: auto;
  transition: transform 0.2s ease, background 0.2s ease;
}

.chat-date-pill:hover {
  background: rgba(30, 15, 45, 0.85);
  border-color: rgba(168, 85, 247, 0.4);
}

.msg-row {
  display: flex;
  width: 100%;
  margin-bottom: 3px;
  position: relative;
}

.msg-row.msg-mine {
  justify-content: flex-end;
}

.msg-row.msg-other {
  justify-content: flex-start;
}

.msg-bubble-wrap {
  position: relative;
  max-width: min(76%, 640px);
  min-width: 80px;
  width: fit-content;
  display: flex;
  flex-direction: column;
}

.msg-row.msg-mine .msg-bubble-wrap {
  align-items: flex-end;
}

.msg-row.msg-other .msg-bubble-wrap {
  align-items: flex-start;
}

/* Base Speech Bubble */
.msg-bubble {
  position: relative;
  width: fit-content;
  max-width: 100%;
  padding: 7px 12px 6px 12px;
  word-break: break-word;
  user-select: text;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
  font-size: 14px;
  line-height: 1.44;
  transition: background 0.15s ease, box-shadow 0.15s ease;
}

/* Outgoing Bubble (Mine) — Right Aligned, Cosmic Violet Gradient */
.msg-bubble.msg-mine {
  background: linear-gradient(135deg, #7026b9 0%, #53168d 100%);
  color: #ffffff;
  border-radius: 16px 16px 4px 16px;
  border: 1px solid rgba(192, 132, 252, 0.28);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3), 0 0 12px rgba(168, 85, 247, 0.12);
}

.msg-bubble.msg-mine:hover {
  background: linear-gradient(135deg, #7c2ec9 0%, #5d1a9e 100%);
  border-color: rgba(192, 132, 252, 0.45);
}

/* Incoming Bubble (Other) — Left Aligned, Deep Cosmic Surface */
.msg-bubble.msg-other {
  background: #1e1333;
  color: #f1f5f9;
  border-radius: 16px 16px 16px 4px;
  border: 1px solid rgba(168, 85, 247, 0.22);
}

.msg-bubble.msg-other:hover {
  background: #24173d;
  border-color: rgba(168, 85, 247, 0.38);
}

/* Author Name on Group/Channel Incoming Bubbles */
.msg-bubble-author {
  font-size: 12.5px;
  font-weight: 700;
  color: #c084fc;
  cursor: pointer;
  margin-bottom: 3px;
  display: block;
}

.msg-bubble-author:hover {
  color: #e9d5ff;
  text-decoration: underline;
}

/* Compact Reply Quote inside Bubble */
.reply-bubble-quote {
  background: rgba(0, 0, 0, 0.24);
  border-left: 3px solid #c084fc;
  border-radius: 4px;
  padding: 4px 8px;
  margin-bottom: 5px;
  cursor: pointer;
  font-size: 11.5px;
  max-width: 100%;
}

.reply-bubble-quote:hover {
  background: rgba(0, 0, 0, 0.34);
}

.reply-bubble-author {
  font-weight: 700;
  color: #e9d5ff;
  margin-bottom: 1px;
}

.reply-bubble-text {
  color: rgba(255, 255, 255, 0.78);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Flow-root container ensures inline metadata sits nicely next to/below text */
.msg-bubble-content {
  display: flow-root;
}

.msg-bubble-text {
  display: inline;
  color: inherit;
  font-size: 14.5px;
  line-height: 1.48;
}

.msg-bubble-meta {
  float: right;
  margin-left: 10px;
  margin-top: 5px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  user-select: none;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.65);
  font-variant-numeric: tabular-nums;
}

.msg-bubble.msg-mine .msg-bubble-meta {
  color: rgba(255, 255, 255, 0.75);
}

.msg-bubble-ticks {
  font-size: 11px;
  font-weight: 800;
  color: #d8b4fe;
}

.msg-bubble-e2ee {
  font-size: 10px;
  opacity: 0.8;
}

.msg-bubble-edited {
  font-size: 10px;
  font-style: italic;
  opacity: 0.7;
}

/* Attachments inside bubble */
.msg-bubble-attachments {
  margin-bottom: 6px;
}

.msg-bubble-img {
  max-width: 100%;
  max-height: 320px;
  border-radius: 10px;
  cursor: pointer;
  display: block;
  object-fit: cover;
}

.msg-bubble-file {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 8px;
  text-decoration: none;
  color: #fff;
  font-size: 12px;
}

/* Reactions under bubble */
.msg-bubble-reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 3px;
}

/* Hover Toolbar on Speech Bubble */
.msg-bubble-wrap .msg-actions-hover {
  position: absolute;
  top: -24px;
  display: none;
  background: #140c24;
  border: 1px solid rgba(168, 85, 247, 0.35);
  border-radius: 20px;
  padding: 2px 6px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.55);
  z-index: 10;
  gap: 4px;
  align-items: center;
}

.msg-row.msg-mine .msg-actions-hover {
  right: 0;
}

.msg-row.msg-other .msg-actions-hover {
  left: 0;
}

.msg-bubble-wrap:hover .msg-actions-hover {
  display: flex;
}

.msg-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--border-subtle);
  flex-shrink: 0;
  cursor: pointer;
}

.msg-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.msg-header-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.msg-author {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
  cursor: pointer;
}
.msg-author:hover {
  color: var(--accent-glow);
  text-decoration: underline;
}
.bot-tag {
  background: var(--accent-violet);
  color: #ffffff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 4px;
  text-transform: uppercase;
}
.msg-time {
  font-size: 11px;
  color: var(--text-muted);
}
.msg-edited-tag {
  font-size: 10px;
  color: var(--text-muted);
  font-style: italic;
}

/* Reply quote */
.reply-quote {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  padding-left: 8px;
  border-left: 2px solid var(--accent-neon);
  margin-bottom: 2px;
  cursor: pointer;
}
.reply-quote:hover {
  color: var(--text-sub);
}

.msg-text {
  font-size: 14.5px;
  color: #e2e8f0;
  line-height: 1.55;
  word-break: break-word;
  user-select: text;
}
.msg-text p {
  margin-bottom: 6px;
}
.msg-text strong {
  color: #ffffff;
}
.msg-text code {
  background: #110c22;
  border: 1px solid var(--border-subtle);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'Consolas', monospace;
  font-size: 13px;
  color: var(--accent-glow);
}
.msg-text pre {
  background: #0d091a;
  border: 1px solid var(--border-subtle);
  padding: 10px;
  border-radius: var(--radius-sm);
  margin: 6px 0;
  overflow-x: auto;
}

/* Attachments */
.msg-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 6px;
}
.msg-img-attachment {
  max-width: 380px;
  max-height: 280px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: var(--transition);
  object-fit: cover;
}
.msg-img-attachment:hover {
  transform: scale(1.02);
  border-color: var(--accent-neon);
  box-shadow: 0 4px 16px rgba(168, 85, 247, 0.3);
}

.msg-file-attachment {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: var(--text-main);
  max-width: 320px;
}
.msg-file-attachment:hover {
  border-color: var(--accent-neon);
}

/* Voice message player */
.voice-note-player {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: linear-gradient(135deg, rgba(59, 7, 100, 0.4), rgba(22, 15, 41, 0.7));
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  width: fit-content;
  min-width: 240px;
  margin-top: 4px;
}
.voice-play-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent-violet);
  border: none;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  transition: var(--transition);
}
.voice-play-btn:hover {
  background: var(--accent-neon);
  box-shadow: 0 0 10px rgba(168, 85, 247, 0.5);
}
.voice-waveform-canvas {
  height: 24px;
  flex: 1;
}
.voice-duration {
  font-size: 11px;
  color: var(--text-muted);
}

/* Reactions */
.msg-reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}
.reaction-pill {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  font-size: 12px;
  cursor: pointer;
  transition: var(--transition);
}
.reaction-pill:hover {
  border-color: var(--accent-neon);
  background: var(--bg-hover);
}
.reaction-pill.reacted {
  background: rgba(168, 85, 247, 0.2);
  border-color: var(--accent-neon);
}
.reaction-pill .r-count {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-sub);
}

/* Floating message actions on hover */
.msg-actions-hover {
  position: absolute;
  top: -12px;
  right: 18px;
  display: none;
  align-items: center;
  gap: 2px;
  background: var(--bg-card);
  border: 1px solid var(--border-highlight);
  border-radius: var(--radius-md);
  padding: 3px 6px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.5);
  z-index: 5;
}
.msg-act-btn {
  background: transparent;
  border: none;
  color: var(--text-sub);
  padding: 4px 6px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  transition: var(--transition);
}
.msg-act-btn:hover {
  background: var(--bg-hover);
  color: #fff;
}

/* ========================================================
   CHAT INPUT AREA
   ======================================================== */
.chat-bottom-area {
  padding: 0 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--bg-primary);
  flex-shrink: 0;
}

.typing-indicator-bar {
  min-height: 24px;
  font-size: 12px;
  color: var(--accent-light);
  display: flex;
  align-items: center;
  transition: all 0.2s ease;
}

.typing-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px;
  background: rgba(168, 85, 247, 0.12);
  border: 1px solid rgba(168, 85, 247, 0.25);
  border-radius: var(--radius-full);
  font-size: 12px;
  color: var(--accent-light);
  animation: fadeIn 0.2s ease;
}

.typing-label strong {
  color: #ffffff;
  font-weight: 700;
}

.typing-wave {
  display: flex;
  align-items: center;
  gap: 3px;
}

.typing-wave .dot {
  width: 5px;
  height: 5px;
  background: var(--accent-neon);
  border-radius: 50%;
  animation: typingBounce 1.4s infinite ease-in-out both;
}

.typing-wave .dot:nth-child(1) {
  animation-delay: -0.32s;
}

.typing-wave .dot:nth-child(2) {
  animation-delay: -0.16s;
}

.typing-wave .dot:nth-child(3) {
  animation-delay: 0s;
}

@keyframes typingBounce {
  0%, 80%, 100% {
    transform: scale(0.6);
    opacity: 0.4;
  }
  40% {
    transform: scale(1.15);
    opacity: 1;
  }
}

.reply-preview-bar {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  background: var(--bg-card);
  border-left: 3px solid var(--accent-neon);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text-sub);
}
.reply-preview-bar.active {
  display: flex;
}
.cancel-reply-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
}
.cancel-reply-btn:hover {
  color: #fff;
}

.input-box-wrapper {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 8px 12px;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  transition: var(--transition);
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
}
.input-box-wrapper:focus-within {
  border-color: var(--accent-neon);
  box-shadow: 0 0 16px rgba(168, 85, 247, 0.25);
}

.input-action-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  flex-shrink: 0;
}
.input-action-btn:hover {
  background: var(--bg-hover);
  color: var(--accent-light);
}
.input-action-btn.recording {
  color: var(--danger-color);
  animation: pulseRecording 1.5s infinite;
}

.chat-textarea {
  flex: 1;
  background: transparent;
  border: none;
  color: #ffffff;
  font-family: var(--font-sans);
  font-size: 14.5px;
  line-height: 20px;
  resize: none;
  max-height: 140px;
  min-height: 22px;
  outline: none;
  padding: 6px 0;
  user-select: text;
}
.chat-textarea::placeholder {
  color: var(--text-muted);
}

.btn-send-message {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--accent-violet), var(--accent-neon));
  color: #ffffff;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  flex-shrink: 0;
  box-shadow: 0 0 10px rgba(168, 85, 247, 0.4);
}
.btn-send-message:hover {
  transform: scale(1.05);
  box-shadow: 0 0 16px rgba(168, 85, 247, 0.7);
}

/* Voice recording overlay inside input */
.recording-tray {
  display: none;
  align-items: center;
  gap: 12px;
  flex: 1;
  padding: 4px 8px;
}
.recording-tray.active {
  display: flex;
}
.rec-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--danger-color);
  animation: pulseRecording 1s infinite;
}
.rec-timer {
  font-size: 13px;
  font-weight: 600;
  color: var(--danger-color);
}
.rec-cancel-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  margin-left: auto;
}
.rec-cancel-btn:hover {
  color: #ffffff;
}

/* ========================================================
   RIGHT MEMBERS SIDEBAR
   ======================================================== */
.members-sidebar {
  width: 240px;
  height: 100%;
  background: var(--bg-sidebar);
  border-left: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.members-sidebar.hidden {
  display: none !important;
}
.members-header {
  height: 56px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  font-size: 14px;
  font-weight: 700;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-main);
  gap: 8px;
}
.members-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.member-group-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 0 8px;
  letter-spacing: 0.6px;
}
.member-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition);
}
.member-item:hover {
  background: var(--bg-hover);
}
.member-avatar-wrap {
  position: relative;
  width: 32px;
  height: 32px;
}
.member-avatar {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}
.member-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.member-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.member-status-note {
  font-size: 10.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Interactive Highlighted Profile Tag with Copy to Clipboard */
.view-prof-tag-wrapper {
  display: flex;
  align-items: center;
}

.view-prof-tag {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: rgba(168, 85, 247, 0.14);
  border: 1px solid rgba(168, 85, 247, 0.35);
  color: #d8b4fe;
  padding: 4px 12px;
  border-radius: 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  user-select: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.view-prof-tag:hover {
  background: rgba(168, 85, 247, 0.28);
  border-color: var(--accent-neon, #a855f7);
  color: #ffffff;
  box-shadow: 0 0 12px rgba(168, 85, 247, 0.5);
  transform: translateY(-1px);
}

.view-prof-tag:active {
  transform: scale(0.97);
}

.view-prof-tag.copied {
  background: rgba(34, 197, 94, 0.22) !important;
  border-color: #22c55e !important;
  color: #86efac !important;
  box-shadow: 0 0 14px rgba(34, 197, 94, 0.45) !important;
}

.view-prof-tag-copy-icon {
  font-size: 12px;
  opacity: 0.8;
  transition: transform 0.2s, opacity 0.2s;
}

.view-prof-tag:hover .view-prof-tag-copy-icon {
  opacity: 1;
  transform: scale(1.15);
}

/* ========================================================
   MOBILE & DESKTOP MULTIPLATFORM RESPONSIVE STYLES
   ======================================================== */

/* Mobile Nav Toggle Button (Hidden on Desktop by default) */
.mobile-nav-toggle-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: var(--bg-hover);
  border: 1px solid var(--border-subtle);
  color: #ffffff;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  margin-right: 4px;
  flex-shrink: 0;
  transition: var(--transition);
}

.mobile-nav-toggle-btn:hover {
  background: var(--accent-violet);
  box-shadow: 0 0 10px rgba(168, 85, 247, 0.4);
}

/* PWA Install Button */
.pwa-install-btn {
  background: linear-gradient(135deg, rgba(168, 85, 247, 0.25), rgba(126, 34, 206, 0.35)) !important;
  border: 1px solid rgba(168, 85, 247, 0.5) !important;
  color: #f3e8ff !important;
  font-weight: 700 !important;
  font-size: 12px !important;
  padding: 5px 10px !important;
  border-radius: 8px !important;
  transition: all 0.2s ease !important;
}

.pwa-install-btn:hover {
  background: var(--accent-violet) !important;
  color: #fff !important;
  box-shadow: 0 0 12px rgba(168, 85, 247, 0.6) !important;
}

/* Mobile Members Close Button */
.members-mobile-close-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  margin-left: auto;
}

.members-mobile-close-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

/* Floating Update Notification Banner */
.update-banner {
  position: fixed;
  bottom: 24px;
  right: 24px;
  max-width: 420px;
  background: linear-gradient(135deg, #1b0d36, #2d1254);
  border: 1px solid var(--accent-neon);
  border-radius: var(--radius-lg);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6), 0 0 20px rgba(168, 85, 247, 0.3);
  padding: 16px;
  z-index: 9999;
  animation: slideUpUpdate 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUpUpdate {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.update-banner-content {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.update-banner-icon {
  font-size: 26px;
  flex-shrink: 0;
}

.update-banner-info {
  flex: 1;
}

.update-banner-title {
  font-size: 14px;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 3px;
}

.update-banner-desc {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}

.update-banner-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.btn-update-apply {
  background: var(--accent-violet);
  border: none;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  transition: var(--transition);
}

.btn-update-apply:hover {
  background: #a855f7;
  box-shadow: 0 0 10px rgba(168, 85, 247, 0.6);
}

.btn-update-dismiss {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
}

.btn-update-dismiss:hover {
  color: #fff;
}

/* About & Updates Card in Settings */
.about-app-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 18px;
}

.about-app-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 14px;
}

.badge-status-update {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  background: rgba(34, 197, 94, 0.18);
  border: 1px solid #22c55e;
  color: #86efac;
  padding: 2px 7px;
  border-radius: 10px;
  margin-left: 6px;
}

.about-app-info-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.info-row {
  display: flex;
  justify-content: space-between;
  font-size: 12.5px;
}

.info-label {
  color: var(--text-muted);
}

.info-val {
  color: var(--text-main);
  font-weight: 600;
}

/* ========================================================
   TABLET & MOBILE BREAKPOINTS (max-width: 768px)
   ======================================================== */
@media (max-width: 768px) {
  html, body {
    position: fixed;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
  }

  #app {
    position: relative;
    width: 100vw;
    height: 100vh;
    display: flex;
    overflow: hidden;
  }

  /* Default on mobile: Show Sidebar view (chats & servers list) */
  #app.mobile-view-sidebar .server-dock {
    display: none !important;
  }

  #app.mobile-view-sidebar .sidebar {
    width: 100vw !important;
    display: flex;
    flex-shrink: 0;
  }

  #app.mobile-view-sidebar .chat-container {
    display: none !important;
  }

  /* When a chat or channel is open on mobile: Fullscreen Chat View */
  #app.mobile-view-chat .server-dock {
    display: none !important;
  }

  #app.mobile-view-chat .sidebar {
    display: none !important;
  }

  #app.mobile-view-chat .chat-container {
    display: flex !important;
    width: 100vw !important;
    height: 100vh !important;
  }

  #app.mobile-view-chat .mobile-nav-toggle-btn {
    display: inline-flex !important;
  }

  /* Chat Header on Mobile */
  .chat-header {
    padding: 0 10px;
    height: 52px;
  }

  .btn-call-label {
    display: none;
  }

  .header-btn.btn-call {
    padding: 6px 9px;
  }

  /* Members Sidebar as Overlay on Mobile */
  .members-sidebar {
    position: fixed !important;
    top: 0;
    right: -100%;
    bottom: 0;
    width: min(85vw, 300px) !important;
    z-index: 200 !important;
    background: #110b22 !important;
    border-left: 1px solid var(--border-subtle);
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.85);
    transition: right 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  }

  .members-sidebar.mobile-open {
    right: 0 !important;
    display: flex !important;
  }

  .members-mobile-close-btn {
    display: inline-block;
  }

  /* Chat text input ergonomics (16px to prevent iOS auto-zoom) */
  .chat-textarea {
    font-size: 16px !important;
  }

  .chat-bottom-area {
    padding: 6px 8px;
    gap: 6px;
  }

  .input-action-btn {
    width: 34px;
    height: 34px;
    font-size: 17px;
  }

  .btn-send-message {
    width: 36px;
    height: 36px;
    font-size: 15px;
  }

  /* Emoji Picker on Mobile */
  .emoji-picker-container {
    left: 8px !important;
    right: 8px !important;
    width: auto !important;
    bottom: 60px !important;
  }

  /* Modals on Mobile */
  .modal-dialog {
    width: 94vw !important;
    max-width: 94vw !important;
    margin: 8px auto !important;
    padding: 16px !important;
  }

  .settings-dialog {
    width: 96vw !important;
    max-width: 96vw !important;
    height: 92vh !important;
    max-height: 92vh !important;
    flex-direction: column !important;
  }

  .settings-sidebar {
    width: 100% !important;
    height: auto !important;
    flex-direction: row !important;
    overflow-x: auto !important;
    padding: 8px !important;
    gap: 6px !important;
    border-right: none !important;
    border-bottom: 1px solid var(--border-subtle);
    flex-shrink: 0;
  }

  .settings-sidebar-title {
    display: none;
  }

  .settings-tab-btn {
    white-space: nowrap;
    padding: 8px 12px;
    font-size: 12px;
  }

  .settings-content-pane {
    padding: 16px 12px !important;
  }

  /* Update banner mobile */
  .update-banner {
    left: 12px;
    right: 12px;
    bottom: 12px;
    max-width: none;
  }
}

/* Extra small screens (< 480px) */
@media (max-width: 480px) {
  #app.mobile-view-sidebar .sidebar {
    width: 100vw !important;
  }

  .header-topic {
    display: none !important;
  }
}

/* ==========================================================================
   TOAST NOTIFICATIONS (Standard & Interactive)
   ========================================================================== */
.toast-container {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
  max-width: 420px;
  width: calc(100vw - 32px);
}

.toast-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: rgba(22, 23, 38, 0.96);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(139, 92, 246, 0.35);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), 0 0 20px rgba(139, 92, 246, 0.2);
  color: #fff;
  font-size: 13.5px;
  font-weight: 500;
  pointer-events: auto;
  transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1), transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  animation: toastSlideIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes toastSlideIn {
  from {
    opacity: 0;
    transform: translateY(-20px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.toast-item.toast-interactive {
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  padding: 14px 16px;
  border-color: rgba(168, 85, 247, 0.5);
  background: linear-gradient(135deg, rgba(26, 16, 48, 0.96), rgba(35, 20, 65, 0.96));
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.6), 0 0 25px rgba(168, 85, 247, 0.3);
}

.toast-item .toast-content {
  display: flex;
  align-items: center;
  gap: 10px;
}

.toast-item .toast-icon {
  font-size: 20px;
  flex-shrink: 0;
}

.toast-item .toast-text {
  flex: 1;
  line-height: 1.4;
  word-break: break-word;
}

.toast-item .toast-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.toast-btn-action {
  background: linear-gradient(135deg, #7c3aed, #a855f7);
  border: none;
  color: #fff;
  padding: 7px 16px;
  font-size: 12.5px;
  font-weight: 700;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  box-shadow: 0 2px 10px rgba(124, 58, 237, 0.4);
}

.toast-btn-action:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 15px rgba(168, 85, 247, 0.6);
}

.toast-btn-close {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #94a3b8;
  padding: 6px 10px;
  font-size: 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.toast-btn-close:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.15);
}

@media (max-width: 480px) {
  .toast-container {
    top: 12px;
    right: 12px;
    left: 12px;
    width: auto;
  }
}

/* ==========================================================================
   TERMS OF SERVICE / ПОЛЬЗОВАТЕЛЬСКОЕ СОГЛАШЕНИЕ
   ========================================================================== */
.terms-agreement-box {
  margin: 12px 0 8px 0;
  font-size: 12px;
  color: #94a3b8;
  line-height: 1.5;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 10px 12px;
  border-radius: 8px;
  transition: border-color 0.2s ease;
}

.terms-agreement-box:hover {
  border-color: rgba(168, 85, 247, 0.4);
}

.terms-section-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.terms-section-card:hover {
  border-color: rgba(56, 189, 248, 0.3);
  background: rgba(255, 255, 255, 0.045);
}

.terms-section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.terms-section-num {
  font-size: 14px;
  font-weight: 800;
  color: #38bdf8;
}

.terms-section-title {
  font-size: 14px;
  font-weight: 700;
  color: #ffffff;
}

.terms-section-body {
  font-size: 12.5px;
  color: #cbd5e1;
  line-height: 1.6;
}

.terms-section-body ul {
  margin: 6px 0 6px 18px;
  padding: 0;
}

.terms-section-body li {
  margin-bottom: 4px;
}

.terms-modal-scroll::-webkit-scrollbar {
  width: 6px;
}

.terms-modal-scroll::-webkit-scrollbar-thumb {
  background: rgba(168, 85, 247, 0.4);
  border-radius: 4px;
}


