.app-page {
  height: 100vh;
  overflow: hidden;
}

.android-install-banner {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  width: min(640px, calc(100% - 16px));
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
  border-radius: 14px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 1200;
  backdrop-filter: blur(12px);
  animation: slideDown 320ms ease-out;
}

.android-install-banner .app-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, #2563eb, #06b6d4);
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 20px;
  font-weight: 700;
  overflow: hidden;
}

.android-install-banner .app-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.android-install-banner .banner-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.android-install-banner .banner-title {
  font-weight: 700;
  color: #fff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.android-install-banner .banner-subtitle {
  color: rgba(255, 255, 255, 0.78);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.android-install-banner .banner-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.android-install-banner .banner-close {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.android-install-banner .banner-close:hover {
  background: rgba(255, 255, 255, 0.12);
}

.android-install-banner .banner-download {
  padding: 10px 14px;
  border-radius: 10px;
  background: #fff;
  color: #0f172a;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  white-space: nowrap;
}

.android-install-banner .banner-download:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.25);
}

@media (max-width: 540px) {
  .android-install-banner {
    flex-direction: column;
    align-items: stretch;
    text-align: left;
    padding: 10px 12px;
    gap: 10px;
    width: calc(100% - 12px);
  }

  .android-install-banner .banner-text {
    text-align: left;
  }

  .android-install-banner .banner-title {
    white-space: normal;
  }

  .android-install-banner .banner-subtitle {
    white-space: normal;
  }

  .android-install-banner .banner-actions {
    justify-content: space-between;
  }

  .android-install-banner .banner-download {
    flex: 1;
    text-align: center;
  }
}

.status-banner {
  position: fixed;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  width: min(680px, calc(100% - 16px));
  background: rgba(30, 41, 59, 0.95);
  color: #e2e8f0;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(12px);
  z-index: 1300;
  animation: slideDown 320ms ease-out;
}

.status-banner .status-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: radial-gradient(circle at 30% 30%, #f43f5e 0, #ef4444 60%, #991b1b 100%);
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 20px;
}

.status-banner .banner-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.status-banner .banner-title {
  font-weight: 700;
  color: #fff;
}

.status-banner .banner-subtitle {
  color: rgba(226, 232, 240, 0.78);
  font-size: 13px;
  line-height: 1.45;
}

.status-banner .banner-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.status-banner .banner-link {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s ease;
}

.status-banner .banner-link:hover {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.24);
}

.status-banner .banner-close {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.status-banner .banner-close:hover {
  background: rgba(255, 255, 255, 0.12);
}

@media (max-width: 540px) {
  .status-banner {
    flex-direction: column;
    align-items: stretch;
    width: calc(100% - 12px);
    gap: 10px;
  }

  .status-banner .banner-actions {
    justify-content: space-between;
  }

  .status-banner .banner-link {
    flex: 1;
    text-align: center;
  }
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translate(-50%, -10px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

.app-container {
  display: grid;
  grid-template-columns: 72px 320px 1fr;
  height: 100vh;
  background: var(--bg-primary);
}

.app-container.profile-open {
  grid-template-columns: 72px 320px 1fr 380px;
}

/* Sidebar */
.sidebar {
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  padding: 16px 8px;
}

.sidebar-header {
  display: flex;
  justify-content: center;
  margin-bottom: 24px;
}

.sidebar-header .logo {
  flex-direction: column;
  gap: 4px;
}

.sidebar-header .logo-icon {
  width: 44px;
  height: 44px;
}

.sidebar-header .logo-text {
  font-size: 12px;
  cursor: pointer;
  transition: opacity 0.3s ease;
}

.sidebar-header .logo-text:hover {
  opacity: 0.85;
}

.sidebar-header .logo-text.disconnected {
  background: linear-gradient(90deg, #ef4444, #f97316);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.sidebar-header .logo-text.retrying {
  animation: skeleton-shimmer 1.2s infinite;
  background: linear-gradient(90deg, #4a5568 0%, #718096 50%, #4a5568 100%);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

@keyframes skeleton-shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 8px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 10px;
  transition: all var(--transition-fast);
}

.nav-item i {
  font-size: 20px;
}

.nav-item:hover {
  background: var(--bg-glass-light);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--accent-glow);
  color: var(--accent-primary);
}

.sidebar-footer {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.user-profile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.user-profile:hover {
  background: var(--bg-glass-light);
}

.user-profile .avatar {
  width: 36px;
  height: 36px;
  background: var(--bg-tertiary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: var(--text-secondary);
}

.user-profile .user-info {
  display: none;
}

/* Chat List Panel */
.panel {
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  min-height: 0; /* allow children to scroll */
}

.chat-list-panel {
  overflow: hidden; /* keep header/search fixed, chat list scrolls */
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px;
  border-bottom: 1px solid var(--border-color);
}

.panel-header h2 {
  font-size: 20px;
  font-weight: 600;
}

.panel-actions {
  display: flex;
  gap: 8px;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

.icon-btn:hover {
  background: var(--bg-glass-light);
  color: var(--text-primary);
}

.search-box {
  padding: 12px 20px;
  display: none;
}

.search-box.active {
  display: flex;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  background: var(--bg-primary);
  margin: 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.search-box i {
  color: var(--text-muted);
}

.search-box input {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 14px;
}

.search-box input::placeholder {
  color: var(--text-muted);
}

.search-box input:focus {
  outline: none;
}

/* Chat List */
.chat-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.chat-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.chat-item:hover {
  background: var(--bg-glass-light);
}

.chat-item.active {
  background: var(--accent-glow);
}

.chat-item .avatar {
  width: 48px;
  height: 48px;
  min-width: 48px;
  background: var(--bg-tertiary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: var(--text-secondary);
  position: relative;
}

.chat-item .avatar i.fa-robot {
  color: #fff;
}

.chat-item .avatar.online::after {
  content: '';
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 12px;
  height: 12px;
  background: var(--accent-success);
  border: 2px solid var(--bg-secondary);
  border-radius: 50%;
}

.chat-item .chat-details {
  flex: 1;
  min-width: 0;
}

.chat-item .chat-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.chat-item .chat-name {
  font-weight: 500;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-item .chat-time {
  font-size: 11px;
  color: var(--text-muted);
}

.chat-item .chat-bottom {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: space-between;
}

.chat-item .chat-preview {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.chat-item .chat-preview.typing {
  color: var(--accent-primary);
  font-weight: 600;
}

.chat-item .unread-badge {
  background: var(--accent-primary);
  color: white;
  font-size: 12px;
  font-weight: bold;
  padding: 2px 8px;
  border-radius: 12px;
  min-width: 20px;
  text-align: center;
  flex-shrink: 0;
  line-height: 1.4;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  text-align: center;
  padding: 40px;
}

.empty-state i {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state p {
  margin-bottom: 16px;
}

.btn-sm {
  padding: 8px 16px;
  font-size: 13px;
}

/* Main Area */
.main-area {
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
  position: relative;
  flex: 1;
  min-height: 0;
}

.no-chat-selected {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.welcome-content {
  text-align: center;
  color: var(--text-secondary);
}

.welcome-icon {
  width: 80px;
  height: 80px;
  background: var(--bg-glass);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 24px;
  font-size: 32px;
  color: var(--accent-primary);
}

.welcome-content h2 {
  margin-bottom: 8px;
  color: var(--text-primary);
}

/* Chat Area */
.chat-area {
  display: flex;
  flex-direction: column;
  height: 100%;
  flex: 1;
  min-height: 0;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 24px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
}

.mobile-back {
  display: none;
}

.chat-info {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1 1 auto;
  cursor: pointer;
  flex-direction: row;
}

.chat-info .avatar {
  width: 44px;
  height: 44px;
  min-width: 44px;
  background: var(--bg-tertiary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: var(--text-secondary);
}

.chat-info .avatar i.fa-robot {
  color: #fff;
}

.chat-info .info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  overflow: hidden;
}

.chat-info .info .name {
  display: block;
  font-weight: 600;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-info .info .status {
  font-size: 12px;
  color: var(--accent-success);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-info .info .status.offline {
  color: var(--text-muted);
}

.chat-info .info .status.typing {
  color: var(--accent-primary);
  font-weight: 600;
}

.chat-actions {
  display: flex;
  gap: 8px;
}

/* Messages */
.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* Custom scrollbar for message list */
.messages-container::-webkit-scrollbar {
  width: 8px;
}

.messages-container::-webkit-scrollbar-track {
  background: transparent;
}

.messages-container::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #1f2b3a, #111827);
  border-radius: 999px;
  border: 2px solid rgba(12, 18, 33, 0.8);
}

.messages-container::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #273345, #1a2333);
}

/* Reuse scrollbar styles for chat list */
.chat-list::-webkit-scrollbar {
  width: 8px;
}

.chat-list::-webkit-scrollbar-track {
  background: transparent;
}

.chat-list::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #1f2b3a, #111827);
  border-radius: 999px;
  border: 2px solid rgba(12, 18, 33, 0.8);
}

.chat-list::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #273345, #1a2333);
}

.messages-container {
  scrollbar-color: #1f2b3a transparent;
  scrollbar-width: thin;
}

.chat-list {
  scrollbar-color: #1f2b3a transparent;
  scrollbar-width: thin;
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.message {
  display: flex;
  gap: 8px;
  max-width: 70%;
  animation: messageIn 0.2s ease;
  align-items: flex-end;
}

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

.message.outgoing {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.message .avatar {
  width: 32px;
  height: 32px;
  min-width: 32px;
  background: var(--bg-tertiary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
}

.message .avatar-placeholder {
  width: 32px;
  height: 32px;
  min-width: 32px;
  visibility: hidden;
}

.message.outgoing .avatar,
.message.outgoing .avatar-placeholder {
  display: none;
}

.message.no-avatar {
  margin-top: 2px;
}

.message-content {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 12px 16px;
  max-width: min(720px, 80vw);
  width: fit-content;
  margin-left: 0;
}

.message.outgoing .message-content {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
}

.message-text {
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
  max-height: 400px;
  overflow: hidden;
}

.message-text p {
  margin: 0 0 6px;
}

.message-text p:last-child {
  margin-bottom: 0;
}

.message-text ul,
.message-text ol {
  margin: 6px 0;
  padding-left: 20px;
}

.message-text li + li {
  margin-top: 4px;
}

.message-text pre {
  background: #0d1528;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  margin: 8px 0;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.4;
}

.message-text code {
  background: #0d1528;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 2px 6px;
  font-family: var(--font-mono);
  font-size: 13px;
}

.message-text em {
  font-style: italic;
}

.message-text del {
  text-decoration: line-through;
  opacity: 0.7;
}

.message-text u {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.message-text .msg-link {
  color: #58a6ff;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
  transition: opacity 0.15s;
}

.message-text .msg-link:hover {
  opacity: 0.8;
}

.message.outgoing .message-text .msg-link {
  color: #c5d8ff;
}

.message-text .mention {
  color: #58a6ff;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}

.message-text .mention:hover {
  opacity: 0.8;
  text-decoration: underline;
}

.message.outgoing .message-text .mention {
  color: #c5d8ff;
}

.message-text blockquote {
  border-left: 3px solid var(--accent-primary);
  padding-left: 12px;
  margin: 8px 0;
  color: var(--text-secondary);
}

.message-text blockquote p {
  margin: 4px 0;
}

.message.outgoing .message-text blockquote {
  border-left-color: rgba(255, 255, 255, 0.5);
  color: rgba(255, 255, 255, 0.85);
}

/* Spoiler styles */
.message-text .spoiler {
  position: relative;
  display: inline-block;
  cursor: pointer;
  border-radius: 4px;
  vertical-align: bottom;
}

.message-text .spoiler-content {
  visibility: hidden;
  user-select: none;
}

.message-text .spoiler[data-revealed="true"] .spoiler-content {
  visibility: visible;
  user-select: auto;
}

.message-text .spoiler-overlay {
  position: absolute;
  inset: -2px -4px;
  background: #2a3142;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.3s ease;
}

.message-text .spoiler[data-revealed="true"] .spoiler-overlay {
  opacity: 0;
  pointer-events: none;
}

.message-text .spoiler-particles {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.message.outgoing .message-text .spoiler-overlay {
  background: rgba(0, 0, 0, 0.4);
}

/* Link preview card */
.link-preview {
  display: flex;
  gap: 12px;
  background: rgba(0, 0, 0, 0.15);
  border-left: 3px solid var(--accent-primary);
  border-radius: 0 8px 8px 0;
  padding: 10px 12px;
  margin-top: 8px;
  cursor: pointer;
  transition: background 0.15s;
  text-decoration: none;
  color: inherit;
  width: 100%;
  max-width: 100%;
}

.link-preview:hover {
  background: rgba(0, 0, 0, 0.25);
}

.link-preview-image {
  width: 60px;
  height: 60px;
  min-width: 60px;
  border-radius: 6px;
  object-fit: cover;
  background: var(--bg-tertiary);
}

.link-preview-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.link-preview-site {
  font-size: 11px;
  color: var(--accent-primary);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.message.outgoing .link-preview-site {
  color: rgba(255, 255, 255, 0.7);
}

.link-preview-title {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
  display: -webkit-box;
  line-clamp: 2;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.link-preview-description {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
  display: -webkit-box;
  line-clamp: 2;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.message.outgoing .link-preview-description {
  color: rgba(255, 255, 255, 0.7);
}

.message.outgoing .link-preview {
  background: rgba(0, 0, 0, 0.2);
  border-left-color: rgba(255, 255, 255, 0.5);
}

.link-preview.loading {
  min-height: 40px;
  align-items: center;
}

.link-preview.loading::after {
  content: 'Загрузка превью...';
  font-size: 12px;
  color: var(--text-muted);
}

.message-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  font-size: 11px;
  color: var(--text-muted);
}

.message.outgoing .message-meta {
  color: rgba(255, 255, 255, 0.7);
  justify-content: flex-end;
}

.message-status {
  display: inline-flex;
  align-items: center;
  margin-left: 4px;
}

.message-status i {
  font-size: 12px;
  display: inline-block;
  min-width: 12px;
}

.message-status .fa-clock {
  color: rgba(255, 255, 255, 0.5);
}

.message-status .fa-check {
  color: rgba(255, 255, 255, 0.7);
}

.message-status .fa-check-double {
  color: rgba(255, 255, 255, 0.7);
}

.message-status i.fa-check-double.read,
.message-status i.read,
.message-status .read {
  color: #0f1629 !important;
}

.typing-indicator {
  padding: 8px 16px;
  color: var(--text-muted);
  font-size: 13px;
  display: none;
}

.typing-indicator.visible {
  display: block;
}

/* Message Input */
.message-input-area {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  padding: 16px 24px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
}

.input-container {
  flex: 1;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 4px;
}

.input-container textarea {
  width: 100%;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 14px;
  padding: 10px 12px;
  resize: none;
  max-height: 150px;
  line-height: 1.5;
}

/* Match scrollbar with chat list/messages */
.input-container textarea::-webkit-scrollbar {
  width: 8px;
}

.input-container textarea::-webkit-scrollbar-track {
  background: transparent;
}

.input-container textarea::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #1f2b3a, #111827);
  border-radius: 999px;
  border: 2px solid rgba(12, 18, 33, 0.8);
}

.input-container textarea::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #273345, #1a2333);
}

.input-container textarea {
  scrollbar-color: #1f2b3a transparent;
  scrollbar-width: thin;
}

.input-container textarea::placeholder {
  color: var(--text-muted);
}

.input-container textarea:focus {
  outline: none;
}

.send-btn {
  background: var(--accent-primary);
  color: white;
}

.send-btn:hover {
  background: var(--accent-secondary);
}

/* Right Panel */
.right-panel {
  width: 380px;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border-color);
  display: none;
  flex-direction: column;
}

.right-panel.active {
  display: flex;
}

.right-panel-content {
  flex: 1;
  overflow-y: auto;
  padding: 0;
}

/* Profile View */
.profile-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 32px 20px 20px;
  text-align: center;
}

.profile-avatar {
  width: 120px;
  height: 120px;
  background: var(--bg-tertiary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
  color: var(--text-secondary);
  margin-bottom: 20px;
}

.profile-avatar i.fa-robot {
  color: #fff;
}

.profile-avatar.group {
  background: var(--accent-glow);
  color: var(--accent-primary);
}

.profile-view h4 {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--text-primary);
}

.profile-username {
  font-size: 14px;
  color: var(--accent-primary);
  margin-bottom: 12px;
}

.profile-bio {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 24px;
  max-width: 260px;
}

.profile-actions {
  display: flex;
  gap: 12px;
  width: 100%;
  margin-bottom: 24px;
}

.profile-actions .btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 16px;
  font-size: 14px;
}

.members-section {
  width: 100%;
  text-align: left;
  border-top: 1px solid var(--border-color);
  padding-top: 20px;
}

.members-section h5 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 12px;
  padding: 0 20px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.member-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: var(--radius-md);
  transition: background var(--transition-fast);
}

.member-item:hover {
  background: var(--bg-glass-light);
}

.member-item .avatar {
  width: 40px;
  height: 40px;
  min-width: 40px;
  background: var(--bg-tertiary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-secondary);
}

.member-item .member-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.member-item .member-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.member-item .member-role {
  font-size: 12px;
  color: var(--text-muted);
}

.member-item .badge {
  background: var(--accent-glow);
  color: var(--accent-primary);
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 4px;
  font-weight: 600;
  white-space: nowrap;
}

.member-item .member-actions {
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.member-item:hover .member-actions {
  opacity: 1;
}

.member-item .member-actions .icon-btn {
  width: 32px;
  height: 32px;
  font-size: 14px;
}

.group-actions {
  width: 100%;
  padding: 20px;
  border-top: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.group-actions .btn {
  width: 100%;
  justify-content: center;
}

/* Modals */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-normal);
}

.modal.active {
  opacity: 1;
  visibility: visible;
}

.modal-content {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  width: 90%;
  max-width: 440px;
  max-height: 90vh;
  overflow: hidden;
  transform: scale(0.95);
  transition: transform var(--transition-normal);
}

.modal.active .modal-content {
  transform: scale(1);
}

.modal-lg {
  max-width: 700px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px;
  border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
  font-size: 18px;
}

.modal-body {
  padding: 20px;
  max-height: 60vh;
  overflow-y: auto;
}

.modal-divider {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 20px 0;
  color: var(--text-muted);
  font-size: 13px;
}

.modal-divider::before,
.modal-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-color);
}

/* Settings */
.settings-body {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 24px;
  padding: 0;
}

.settings-nav {
  background: var(--bg-primary);
  padding: 16px;
  border-right: 1px solid var(--border-color);
}

.settings-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 14px;
  text-align: left;
  transition: all var(--transition-fast);
}

.settings-nav-item:hover {
  background: var(--bg-glass-light);
}

.settings-nav-item.active {
  background: var(--accent-glow);
  color: var(--accent-primary);
}

.settings-content {
  padding: 24px;
}

.settings-content h4 {
  margin-bottom: 16px;
  font-size: 18px;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

.settings-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  transition: all var(--transition-fast);
}

.settings-card:hover {
  border-color: var(--accent-primary);
  box-shadow: var(--shadow-sm);
}

.settings-card .description {
  color: var(--text-secondary);
  font-size: 13px;
}

.checkbox-label {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 6px 0;
  cursor: pointer;
  user-select: none;
  color: var(--text-primary);
  font-weight: 500;
  min-height: 32px;
}

.checkbox-label input {
  opacity: 0;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
  z-index: 1;
}

.checkmark {
  width: 24px;
  height: 24px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.08), transparent 55%), var(--bg-tertiary);
  display: grid;
  place-items: center;
  transition: all var(--transition-fast);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
  position: relative;
}

.checkbox-label:focus-within .checkmark {
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.checkbox-label input:checked ~ .checkmark {
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  border-color: transparent;
  box-shadow: var(--shadow-glow);
}

.checkmark::after {
  content: '';
  width: 10px;
  height: 6px;
  border-left: 2px solid #fff;
  border-bottom: 2px solid #fff;
  transform: translateY(-1px) rotate(-45deg) scale(0.4);
  opacity: 0;
  transition: transform var(--transition-fast), opacity var(--transition-fast);
}

.checkbox-label input:checked ~ .checkmark::after {
  opacity: 1;
  transform: translateY(-1px) rotate(-45deg) scale(1);
}

.toggle-chip {
  padding: 8px 12px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  font-size: 13px;
}

.form-input {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 14px;
  transition: all var(--transition-fast);
}

.form-input:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 8px;
}

/* User search results */
.user-search-results {
  max-height: 300px;
  overflow-y: auto;
}

.user-result {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.user-result:hover {
  background: var(--bg-glass-light);
}

.user-result .avatar {
  width: 44px;
  height: 44px;
  background: var(--bg-tertiary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: var(--text-secondary);
}

.user-result .user-info {
  flex: 1;
}

.user-result .user-name {
  font-weight: 500;
}

.user-result .user-username {
  font-size: 13px;
  color: var(--text-secondary);
}

/* Call Modal */
/* ========================================
   CALL UI - Primer2 Inspired Design
   Adapted to Uma Messenger Blue Theme
   ======================================== */

.call-modal {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 2000;
  display: none;
}

.call-modal.active {
  display: block;
}

.call-container {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

/* --- Call Toast --- */
.call-toast {
  position: absolute;
  bottom: 120px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.75);
  color: white;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  z-index: 40;
  backdrop-filter: blur(4px);
}

.call-toast.show {
  opacity: 1;
}

/* --- Top UI Overlay --- */
.call-ui-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  padding: 20px 24px;
  background: linear-gradient(to bottom, rgba(15, 23, 42, 0.85) 0%, rgba(15, 23, 42, 0) 100%);
  pointer-events: none;
}

.call-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.call-user-header {
  display: flex;
  align-items: center;
  gap: 16px;
  pointer-events: auto;
}

.call-header-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--accent-primary);
  border: 2px solid rgba(255, 255, 255, 0.2);
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: white;
  overflow: hidden;
}

.call-header-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.call-user-text {
  display: flex;
  flex-direction: column;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.call-user-name {
  font-weight: 600;
  font-size: 18px;
  letter-spacing: 0.3px;
  color: white;
}

.call-timer-row {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.8);
  font-variant-numeric: tabular-nums;
  display: flex;
  align-items: center;
  gap: 6px;
}

.call-status-dot {
  width: 6px;
  height: 6px;
  background: var(--accent-success);
  border-radius: 50%;
}

.call-network-info {
  display: flex;
  gap: 10px;
  pointer-events: auto;
  align-items: center;
}

.call-status-badge {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(8px);
  border-radius: 12px;
  padding: 4px 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.call-status-badge:hover {
  background: rgba(255, 255, 255, 0.15);
}

.turn-icon {
  font-weight: 800;
  font-size: 14px;
  color: #aaa;
  transition: color 0.3s, text-shadow 0.3s;
}

.turn-icon.turn-active {
  color: var(--accent-success);
  text-shadow: 0 0 8px rgba(74, 222, 128, 0.6);
}

.signal-bars {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 12px;
}

.signal-bars .bar {
  width: 3px;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 1px;
  transition: background 0.2s ease;
}

.signal-bars .bar:nth-child(1) { height: 40%; }
.signal-bars .bar:nth-child(2) { height: 70%; }
.signal-bars .bar:nth-child(3) { height: 100%; }

.signal-bars.signal-good .bar { background: var(--accent-success); }
.signal-bars.signal-mid .bar:nth-child(1),
.signal-bars.signal-mid .bar:nth-child(2) { background: #fbbf24; }
.signal-bars.signal-bad .bar:nth-child(1) { background: #f87171; }

/* Ping Badge */
.call-ping-badge {
  gap: 2px;
  font-size: 11px;
  font-weight: 600;
  min-width: 50px;
}

.ping-value {
  color: #fff;
}

.ping-unit {
  color: rgba(255, 255, 255, 0.5);
  font-size: 9px;
}

/* --- Main Video / Avatar Area --- */
.call-video-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  background: radial-gradient(circle at center, rgba(30, 41, 59, 1) 0%, rgba(15, 23, 42, 1) 100%);
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1;
}

.call-avatar-large {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: var(--accent-primary);
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  position: relative;
  font-size: 56px;
  color: white;
  overflow: hidden;
  transition: box-shadow 0.3s ease, border 0.3s ease;
}

.call-avatar-large img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.call-avatar-large.is-speaking {
  animation: soft-pulse-shadow 2s infinite ease-in-out;
  border: 3px solid var(--accent-success);
}

@keyframes soft-pulse-shadow {
  0% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0); }
  50% { box-shadow: 0 0 30px 5px rgba(74, 222, 128, 0.5); }
  100% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0); }
}

.call-video-placeholder #remoteVideo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  z-index: 2;
  display: none;
  background: #000;
}

.call-video-placeholder #remoteVideo.active {
  display: block;
}

/* Video aspect ratio container for pinch-to-zoom */
.call-video-placeholder {
  touch-action: pinch-zoom;
  overflow: hidden;
}

.call-video-placeholder.zoomed #remoteVideo {
  object-fit: cover;
  transform-origin: center center;
}

.call-mute-overlay {
  position: absolute;
  bottom: 20px;
  right: 20px;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  color: #fff;
  padding: 8px;
  border-radius: 50%;
  display: none;
  z-index: 5;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
}

.call-mute-overlay.active {
  display: flex;
}

/* --- PIP Window --- */
.call-pip-window {
  position: absolute;
  width: auto;
  height: auto;
  max-width: 280px;
  max-height: 400px;
  min-width: 120px;
  min-height: 80px;
  background: #1a1a2e;
  border-radius: 16px;
  overflow: hidden;
  z-index: 20;
  cursor: grab;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.15);
  bottom: 110px;
  right: 24px;
  touch-action: none;
  transition: transform 0.1s linear, box-shadow 0.3s ease, border-color 0.3s ease;
}

.call-pip-window:active {
  cursor: grabbing;
  transform: scale(1.02);
  border-color: rgba(255, 255, 255, 0.3);
}

.call-pip-window.is-speaking {
  animation: soft-pulse-border 2s infinite ease-in-out;
}

@keyframes soft-pulse-border {
  0% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0); border-color: rgba(255, 255, 255, 0.15); }
  50% { box-shadow: 0 0 20px 2px rgba(74, 222, 128, 0.4); border-color: var(--accent-success); }
  100% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0); border-color: rgba(255, 255, 255, 0.15); }
}

.pip-content {
  width: 100%;
  height: 100%;
  pointer-events: none;
  position: relative;
}

.pip-video-placeholder {
  width: 100%;
  height: 100%;
  background: #252535;
  display: flex;
  justify-content: center;
  align-items: center;
  color: rgba(255, 255, 255, 0.3);
  font-size: 24px;
}

.pip-content #localVideo {
  display: none;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
  border-radius: 16px;
}

.pip-content #localVideo.active {
  display: block;
}

/* Force PIP to be landscape for 16:9 video */
.call-pip-window.landscape {
  width: 200px;
  height: 112px;
  min-width: 200px;
  min-height: 112px;
}

.pip-mute-overlay {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  color: #fff;
  border-radius: 50%;
  display: none;
  z-index: 5;
  width: 28px;
  height: 28px;
  align-items: center;
  justify-content: center;
  font-size: 12px;
}

.pip-mute-overlay.active {
  display: flex;
}

/* --- Reconnecting Overlay --- */
.call-reconnect-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(5px);
  z-index: 100;
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  color: white;
  text-align: center;
}

.call-reconnect-overlay.active {
  display: flex;
}

.reconnect-spinner {
  width: 50px;
  height: 50px;
  border: 4px solid rgba(255, 255, 255, 0.1);
  border-left-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 20px;
}

@keyframes spin { 100% { transform: rotate(360deg); } }

.call-reconnect-overlay h3 {
  font-size: 18px;
  margin-bottom: 8px;
}

.call-reconnect-overlay p {
  opacity: 0.6;
  font-size: 14px;
}

/* --- Call Warning --- */
.call-warning {
  position: absolute;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  color: #fbbf24;
  font-size: 13px;
  text-align: center;
  z-index: 25;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

/* --- Controls Bar --- */
.call-controls-wrapper {
  position: absolute;
  bottom: 30px;
  left: 0;
  width: 100%;
  display: flex;
  justify-content: center;
  z-index: 30;
  pointer-events: none;
}

.call-controls-container {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(30, 41, 59, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  padding: 10px 20px;
  border-radius: 28px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
  transition: all 0.3s ease;
  position: relative;
}

.call-ctrl-btn {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
}

.call-ctrl-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: translateY(-2px);
}

.call-ctrl-btn:active {
  transform: translateY(0) scale(0.95);
}

.call-ctrl-btn.btn-off {
  background: #fff;
  color: #000;
}

.call-ctrl-btn.btn-off:hover {
  background: #eee;
}

.call-ctrl-btn.btn-danger {
  background: var(--accent-error);
  width: 60px;
  border-radius: 24px;
}

.call-ctrl-btn.btn-danger:hover {
  background: #ff5252;
  box-shadow: 0 4px 15px rgba(234, 67, 53, 0.4);
}

.call-ctrl-btn.btn-active-feature {
  background: var(--accent-success);
  color: white;
}

/* --- Popup Menu --- */
.call-popup-menu {
  position: absolute;
  bottom: 70px;
  left: 10px;
  width: 200px;
  background: rgba(30, 41, 59, 0.95);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transform-origin: bottom left;
  transform: scale(0.95);
  opacity: 0;
  pointer-events: none;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.call-popup-menu.active {
  transform: scale(1);
  opacity: 1;
  pointer-events: auto;
}

.call-menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  color: #fff;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.2s;
  font-size: 14px;
}

.call-menu-item:hover {
  background: rgba(255, 255, 255, 0.1);
}

.call-menu-item i {
  width: 20px;
  text-align: center;
  font-size: 16px;
  color: #ccc;
}

/* --- Call Mobile Adaptations --- */
@media (max-width: 768px) {
  /* Hide top bar user info on mobile - show centered instead */
  .call-ui-overlay {
    padding: 12px 16px;
    background: linear-gradient(to bottom, rgba(15, 23, 42, 0.6) 0%, rgba(15, 23, 42, 0) 100%);
  }

  .call-top-bar {
    justify-content: flex-end;
  }

  .call-user-header {
    display: none;
  }

  /* Centered user info above avatar (WhatsApp style) */
  .call-video-placeholder {
    flex-direction: column;
    gap: 16px;
  }

  .call-video-placeholder::before {
    content: attr(data-user-name);
    font-size: 22px;
    font-weight: 600;
    color: white;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
    order: -2;
  }

  .call-video-placeholder::after {
    content: attr(data-call-status);
    font-size: 14px;
    color: rgba(255, 255, 255, 0.7);
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
    order: -1;
    margin-bottom: 8px;
  }

  .call-avatar-large {
    width: 120px;
    height: 120px;
    font-size: 48px;
  }

  /* Mobile mute overlay - make it visible */
  .call-mute-overlay {
    bottom: auto;
    right: auto;
    top: 50%;
    left: 50%;
    transform: translate(-50%, 60px);
    width: 48px;
    height: 48px;
    font-size: 20px;
  }

  .call-pip-window {
    max-width: 140px;
    max-height: 250px;
    min-width: 80px;
    min-height: 60px;
    border-radius: 10px;
    bottom: 95px;
    right: 12px;
  }
  
  .pip-content #localVideo {
    max-width: 140px;
    max-height: 250px;
    min-width: 80px;
    min-height: 60px;
  }

  /* Bigger controls on mobile */
  .call-controls-wrapper {
    bottom: 20px;
  }

  .call-controls-container {
    padding: 12px 16px;
    gap: 12px;
    border-radius: 28px;
    width: calc(100% - 24px);
    max-width: 400px;
    justify-content: center;
  }

  .call-ctrl-btn {
    width: 52px;
    height: 52px;
    font-size: 20px;
  }

  .call-ctrl-btn.btn-danger {
    width: 64px;
    border-radius: 26px;
  }

  .call-popup-menu {
    left: 12px;
    bottom: 75px;
    width: 180px;
  }

  .call-toast {
    bottom: 100px;
  }

  .call-warning {
    bottom: 90px;
  }
}

@media (min-width: 769px) and (max-width: 1024px) {
  .call-controls-container {
    gap: 16px;
    padding: 12px 24px;
  }

  .call-pip-window {
    width: 240px;
  }
}

/* Legacy compatibility */
.speaking-ring {
  box-shadow: 0 0 0 2px rgba(74, 222, 128, 0.45), 0 0 18px rgba(74, 222, 128, 0.35);
}

/* --- Minimized Call Window --- */
.call-minimized {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 280px;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(20px);
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  z-index: 1500;
  display: none;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.call-minimized.active {
  display: block;
  animation: slideUp 0.3s ease;
}

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

.call-minimized:hover {
  transform: scale(1.02);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}

.call-mini-video {
  width: 100%;
  aspect-ratio: 16/9;
  background: #000;
  position: relative;
}

.call-mini-video video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.call-mini-avatar {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e3a5f 0%, #0f172a 100%);
  color: rgba(255, 255, 255, 0.5);
  font-size: 32px;
}

.call-mini-avatar.hidden {
  display: none;
}

.call-mini-info {
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.call-mini-name {
  font-weight: 600;
  color: #fff;
  font-size: 14px;
}

.call-mini-timer {
  font-size: 13px;
  color: var(--accent-success);
  font-weight: 500;
}

.call-mini-controls {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  gap: 8px;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.call-minimized:hover .call-mini-controls {
  opacity: 1;
}

.call-mini-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(4px);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  transition: all 0.2s ease;
}

.call-mini-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.1);
}

.call-mini-btn.call-mini-end {
  background: rgba(239, 68, 68, 0.8);
}

.call-mini-btn.call-mini-end:hover {
  background: rgba(239, 68, 68, 1);
}

/* Incoming Call */
.incoming-call {
  position: fixed;
  top: 24px;
  right: 24px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 24px;
  z-index: 2000;
  display: none;
  animation: slideIn 0.3s ease;
}

.incoming-call.active {
  display: block;
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.incoming-call-content {
  text-align: center;
}

.incoming-call .call-avatar {
  width: 80px;
  height: 80px;
  font-size: 32px;
  margin-bottom: 16px;
}

.caller-name {
  display: block;
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 4px;
}

.call-type {
  color: var(--text-secondary);
  font-size: 14px;
}

.incoming-call-actions {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-top: 24px;
}

.incoming-call-actions .call-btn {
  width: 56px;
  height: 56px;
  font-size: 20px;
  border-radius: 50%;
}

.incoming-call-actions .call-btn.accept-btn {
  background: var(--accent-success);
  color: #fff;
}

.incoming-call-actions .call-btn.accept-btn:hover {
  background: #22c55e;
}

.incoming-call-actions .call-btn.decline-btn {
  background: #ef4444;
  color: #fff;
}

.incoming-call-actions .call-btn.decline-btn:hover {
  background: #dc2626;
}

/* Active Call Indicator in Chat List */
.chat-item.has-active-call .chat-preview {
  color: var(--accent-success) !important;
}

.active-call-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--accent-success);
  font-weight: 500;
  font-size: 13px;
}

.active-call-indicator i {
  font-size: 11px;
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Active Call Header */
.active-call-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.active-call-label {
  color: var(--accent-success);
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
}

.active-call-label i {
  animation: pulse 1.5s ease-in-out infinite;
}

.rejoin-btn {
  background: var(--accent-success);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}

.rejoin-btn:hover {
  background: #22c55e;
}

/* Rejoin Call Banner */
.rejoin-call-banner {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 12px 16px;
  z-index: 2000;
  display: none;
  animation: slideDown 0.3s ease;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.rejoin-call-banner.active {
  display: block;
}

@keyframes slideDown {
  from {
    transform: translateX(-50%) translateY(-100%);
    opacity: 0;
  }
  to {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
  }
}

.rejoin-call-content {
  display: flex;
  align-items: center;
  gap: 12px;
}

.rejoin-call-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  overflow: hidden;
}

.rejoin-call-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.rejoin-call-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.rejoin-call-name {
  font-weight: 600;
  font-size: 14px;
}

.rejoin-call-status {
  font-size: 12px;
  color: var(--text-secondary);
}

.rejoin-call-btn {
  background: var(--accent-success);
  color: #fff;
  border: none;
  border-radius: var(--radius-lg);
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background 0.2s;
}

.rejoin-call-btn:hover {
  background: #22c55e;
}

.rejoin-call-end {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.rejoin-call-end:hover {
  background: rgba(239, 68, 68, 0.4);
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 3000;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.toast {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  animation: toastIn 0.3s ease;
  min-width: 300px;
}

@keyframes toastIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.toast.success { border-left: 4px solid var(--accent-success); }
.toast.error { border-left: 4px solid var(--accent-error); }
.toast.warning { border-left: 4px solid var(--accent-warning); }

.toast i {
  font-size: 20px;
}

.toast.success i { color: var(--accent-success); }
.toast.error i { color: var(--accent-error); }
.toast.warning i { color: var(--accent-warning); }

/* Responsive */
@media (max-width: 1024px) {
  .app-container {
    grid-template-columns: 72px 1fr;
  }
  
  .app-container.profile-open {
    grid-template-columns: 72px 1fr;
  }
  
  .chat-list-panel {
    position: fixed;
    left: 72px;
    top: 0;
    bottom: 0;
    width: 320px;
    z-index: 10;
    transform: translateX(-100%);
    transition: transform var(--transition-normal);
  }
  
  .chat-list-panel.active {
    transform: translateX(0);
  }
  
  .right-panel {
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    width: 320px;
    z-index: 20;
  }
}

@media (max-width: 768px) {
  .app-container {
    grid-template-columns: 1fr;
  }
  
  .sidebar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    flex-direction: row;
    padding: 8px 16px;
    border-right: none;
    border-top: 1px solid var(--border-color);
    z-index: 100;
  }
  
  .sidebar-header,
  .sidebar-footer {
    display: none;
  }
  
  .sidebar-nav {
    flex-direction: row;
    justify-content: space-around;
    width: 100%;
  }
  
  .chat-list-panel {
    position: fixed;
    left: 0;
    width: 100%;
    transform: translateX(0);
    bottom: 60px;
  }
  
  .main-area {
    margin-bottom: 60px;
  }
  
  .mobile-back {
    display: flex;
  }
  
  .chat-header {
    padding: 12px 16px;
  }
  
  .message-input-area {
    padding: 12px 16px;
  }
  
  .messages-container {
    padding: 16px;
  }
  
  .message {
    max-width: 85%;
  }
}

/* Context Menu */
.context-menu {
  position: fixed;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 6px 0;
  min-width: 200px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  transform: scale(0.95);
  transition: all 0.15s ease;
}

.context-menu.active {
  opacity: 1;
  visibility: visible;
  transform: scale(1);
}

.context-menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  color: var(--text-primary);
  font-size: 14px;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.context-menu-item:hover {
  background: var(--bg-glass-light);
}

.context-menu-item i {
  width: 18px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 14px;
}

.context-menu-item.danger {
  color: var(--accent-danger);
}

.context-menu-item.danger i {
  color: var(--accent-danger);
}

.context-menu-divider {
  height: 1px;
  background: var(--border-color);
  margin: 6px 0;
}

/* Pinned chat indicator */
.chat-item .pinned-icon {
  color: var(--text-muted);
  font-size: 12px;
  margin-left: 6px;
}
