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

/* User Profile Bar & Popup */
.user-profile-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
}

.user-profile-bar:hover {
  background: rgba(60, 110, 255, 0.1);
}

.user-profile-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 14px;
  font-weight: 600;
  flex-shrink: 0;
  position: relative;
  overflow: visible;
}

.user-profile-avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.user-profile-avatar .avatar-letter {
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
}

.status-indicator {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 3px solid var(--bg-tertiary);
  background: var(--accent-success);
  z-index: 2;
}

.status-indicator.large {
  width: 18px;
  height: 18px;
  border-width: 4px;
  bottom: -3px;
  right: -3px;
}

.status-indicator.online {
  background: var(--accent-success);
}

.status-indicator.idle {
  background: var(--accent-warning);
}

.status-indicator.dnd {
  background: var(--accent-error);
}

.status-indicator.invisible,
.status-indicator.offline {
  background: transparent;
  box-shadow: inset 0 0 0 2px var(--text-muted);
}

.status-indicator.skeleton {
  background: var(--text-muted);
  animation: skeletonPulse 1.5s ease-in-out infinite;
}

@keyframes skeletonPulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

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

.user-profile-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 3px;
  text-align: left;
}

.user-profile-name.skeleton {
  width: 80px;
  height: 14px;
  background: var(--bg-glass-light);
  border-radius: 4px;
  animation: skeletonPulse 1.5s ease-in-out infinite;
}

.user-profile-username {
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-block;
}

.status-dot.online {
  background: var(--accent-success);
}

.status-dot.idle {
  background: var(--accent-warning);
}

.status-dot.dnd {
  background: var(--accent-error);
}

.status-dot.invisible,
.status-dot.offline {
  background: transparent;
  box-shadow: inset 0 0 0 2px var(--text-muted);
}

/* Status icons for selector dropdown */
.status-icon {
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.status-icon i {
  font-size: 10px;
}

.status-icon.online,
.status-icon.online i {
  color: var(--accent-success);
}

.status-icon.idle,
.status-icon.idle i {
  color: var(--accent-warning);
}

.status-icon.dnd,
.status-icon.dnd i {
  color: var(--accent-error);
}

.status-icon.invisible,
.status-icon.invisible i {
  color: var(--text-muted);
}

.user-profile-menu-btn {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

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

/* Profile Popup */
.user-profile-popup {
  position: fixed;
  bottom: 80px;
  left: 12px;
  width: 320px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  transform: translateY(0);
  transition: opacity 200ms ease, visibility 200ms ease;
  overflow: visible;
}

.user-profile-popup.active {
  opacity: 1;
  visibility: visible;
}

.profile-popup-header {
  position: relative;
  height: 80px;
}

.profile-popup-banner {
  width: 100%;
  height: 60px;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  position: relative;
  cursor: pointer;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  overflow: hidden;
}

.profile-popup-banner img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  position: absolute;
  inset: 0;
  z-index: 1;
}

.profile-banner-edit {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 11px;
  opacity: 0;
  transition: opacity var(--transition-fast);
  cursor: pointer;
  z-index: 2;
}

/* Banner edit button always visible, no hover animation */
.profile-banner-edit {
  opacity: 0.7;
}

.profile-popup-avatar-wrap {
  position: absolute;
  bottom: 0;
  left: 16px;
  transform: translateY(50%);
  z-index: 10;
}

.profile-popup-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  border: 4px solid var(--bg-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 24px;
  font-weight: 700;
  position: relative;
  overflow: visible;
}

.profile-popup-avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.profile-popup-avatar .avatar-letter {
  text-transform: uppercase;
}

.profile-avatar-edit {
  position: absolute;
  bottom: 0;
  right: -4px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent-primary);
  border: 2px solid var(--bg-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 10px;
  cursor: pointer;
  transition: all var(--transition-fast);
  z-index: 3;
}

.profile-avatar-edit:hover {
  background: var(--accent-secondary);
  transform: scale(1.1);
}

.profile-popup-body {
  padding: 40px 16px 16px;
}

.profile-popup-name {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 2px;
  word-wrap: break-word;
  overflow-wrap: break-word;
  max-width: 100%;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 4px;
  flex-wrap: wrap;
}

.profile-popup-username {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.profile-popup-bio {
  font-size: 13px;
  color: var(--text-primary);
  line-height: 1.4;
  margin-bottom: 4px;
}

.profile-popup-bio:empty {
  display: none;
}

.user-profile-popup h4 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 12px 0 8px;
  word-wrap: break-word;
  overflow-wrap: break-word;
  max-width: 100%;
}

.profile-popup-divider {
  height: 1px;
  background: var(--border-color);
  margin: 12px 0;
}

/* Status Selector */
.profile-status-selector {
  position: relative;
}

.status-selector-current {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.status-selector-current:hover {
  background: var(--bg-glass-light);
}

.status-selector-current i {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-muted);
  transition: transform var(--transition-fast);
}

.status-selector-dropdown {
  position: absolute;
  left: calc(100% + 8px);
  bottom: auto;
  top: auto;
  min-width: 220px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  opacity: 0;
  visibility: hidden;
  transform: translateX(-10px) translateY(-50%);
  transition: all 150ms ease;
  z-index: 2000;
  /* Center vertically relative to the selector */
  top: 50%;
}

.profile-status-selector:hover .status-selector-dropdown,
.status-selector-dropdown:hover,
.status-selector-dropdown.active {
  opacity: 1;
  visibility: visible;
  transform: translateX(0) translateY(-50%);
}

/* Mobile: position dropdown below instead of to the side */
@media (max-width: 768px) {
  .status-selector-dropdown {
    left: 0;
    right: 0;
    top: calc(100% + 8px);
    min-width: auto;
    transform: translateY(-10px);
  }
  
  .status-selector-dropdown.active {
    transform: translateY(0);
  }
  
  .profile-status-selector:hover .status-selector-dropdown,
  .status-selector-dropdown:hover {
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
  }
  
  .status-selector-dropdown.active,
  .profile-status-selector:hover .status-selector-dropdown.active,
  .status-selector-dropdown.active:hover {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
  }
}

.status-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.status-option:hover {
  background: var(--bg-glass-light);
}

/* Image Cropper Modal */
#cropperModal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(10px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 99999;
}

#cropperModal .image-cropper-dialog {
  position: relative;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  overflow: hidden;
  width: 90%;
  max-width: 600px;
  max-height: 90vh;
}

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

#cropperModal .modal-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

#cropperModal .modal-close {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

#cropperModal .modal-close:hover {
  color: var(--text-primary);
}

#cropperModal .modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 20px;
  border-top: 1px solid var(--border-color);
}

.cropper-image-container {
  max-height: 60vh;
  min-height: 300px;
  overflow: hidden;
  padding: 0;
  background: #1a1a2e;
  position: relative;
}

.cropper-image-container img {
  max-width: 100%;
  display: block;
}

/* Cropper.js library overrides - ensure visibility */
.cropper-container {
  direction: ltr;
  font-size: 0;
  line-height: 0;
  position: relative;
  touch-action: none;
  user-select: none;
}

.cropper-container img {
  display: block;
  height: 100%;
  image-orientation: 0deg;
  max-height: none !important;
  max-width: none !important;
  min-height: 0 !important;
  min-width: 0 !important;
  width: 100%;
}

.cropper-wrap-box,
.cropper-canvas,
.cropper-drag-box,
.cropper-crop-box,
.cropper-modal {
  bottom: 0;
  left: 0;
  position: absolute;
  right: 0;
  top: 0;
}

.cropper-wrap-box,
.cropper-canvas {
  overflow: hidden;
}

.cropper-drag-box {
  background-color: #fff;
  opacity: 0;
}

.cropper-modal {
  background-color: #000;
  opacity: 0.5;
}

.cropper-view-box {
  display: block;
  height: 100%;
  outline: 1px solid #39f;
  outline-color: rgba(51, 153, 255, 0.75);
  overflow: hidden;
  width: 100%;
}

.cropper-dashed {
  border: 0 dashed #eee;
  display: block;
  opacity: 0.5;
  position: absolute;
}

.cropper-center {
  display: block;
  height: 0;
  left: 50%;
  opacity: 0.75;
  position: absolute;
  top: 50%;
  width: 0;
}

.cropper-face,
.cropper-line,
.cropper-point {
  display: block;
  height: 100%;
  opacity: 0.1;
  position: absolute;
  width: 100%;
}

.cropper-face {
  background-color: #fff;
  left: 0;
  top: 0;
}

.cropper-line {
  background-color: #39f;
}

.cropper-point {
  background-color: #39f;
  height: 5px;
  opacity: 0.75;
  width: 5px;
}

.cropper-invisible {
  opacity: 0;
}

.cropper-bg {
  background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAAA3NCSVQICAjb4U/gAAAABlBMVEXMzMz////TjRV2AAAACXBIWXMAAArrAAAK6wGCiw1aAAAAHHRFWHRTb2Z0d2FyZQBBZG9iZSBGaXJld29ya3MgQ1M26LyyjAAAABFJREFUCJlj+M/AgBVhF/0PAH6/D/HkDxOGAAAAAElFTkSuQmCC');
}

.cropper-hide {
  display: block;
  height: 0;
  position: absolute;
  width: 0;
}

.cropper-hidden {
  display: none !important;
}

.cropper-move {
  cursor: move;
}

.cropper-crop {
  cursor: crosshair;
}

.cropper-disabled .cropper-drag-box,
.cropper-disabled .cropper-face,
.cropper-disabled .cropper-line,
.cropper-disabled .cropper-point {
  cursor: not-allowed;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px;
  border-top: 1px solid var(--border-color);
}

/* Settings Banner Section */
.settings-banner-section {
  margin-bottom: 20px;
}

.settings-banner {
  height: 120px;
  border-radius: var(--radius-lg);
  position: relative;
  overflow: hidden;
}

.settings-banner-actions {
  position: absolute;
  bottom: 12px;
  right: 12px;
  display: flex;
  gap: 8px;
}

.settings-banner-edit {
  padding: 8px 14px;
  background: rgba(0, 0, 0, 0.6);
  color: white;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background var(--transition-fast);
  backdrop-filter: blur(4px);
}

.settings-banner-edit:hover {
  background: rgba(0, 0, 0, 0.8);
}

.settings-banner-edit i {
  font-size: 12px;
}

/* Banner Color Picker Modal */
.banner-color-picker-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  backdrop-filter: blur(4px);
}

.banner-color-picker-content {
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  width: 380px;
  max-width: 90vw;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border-color);
}

/* Match global scrollbar style (same as chat/settings) */
.banner-color-picker-content {
  scrollbar-color: #1f2b3a transparent;
  scrollbar-width: thin;
}

.banner-color-picker-content::-webkit-scrollbar {
  width: 8px;
}

.banner-color-picker-content::-webkit-scrollbar-track {
  background: transparent;
}

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

.banner-color-picker-content::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #273345, #1a2333);
}

.banner-color-picker-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  font-weight: 600;
  font-size: 15px;
  color: var(--text-primary);
}

.banner-color-picker-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 16px;
  padding: 4px;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.banner-color-picker-close:hover {
  color: var(--text-primary);
  background: var(--bg-tertiary);
}

.banner-color-picker-section {
  padding: 14px 20px;
}

.banner-color-picker-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
}

.banner-color-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.banner-color-swatch {
  width: 100%;
  aspect-ratio: 1;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  border: 2px solid transparent;
}

.banner-color-swatch:hover {
  transform: scale(1.15);
  border-color: var(--text-primary);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.banner-color-swatch.gradient {
  border-radius: var(--radius-md);
}

.banner-color-avatar-btn {
  width: 100%;
  justify-content: center;
  gap: 8px;
}

.banner-color-custom-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.banner-color-custom-row input[type="color"] {
  width: 44px;
  height: 44px;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  cursor: pointer;
  padding: 2px;
  background: var(--bg-tertiary);
}

.banner-color-custom-row input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 2px;
}

.banner-color-custom-row input[type="color"]::-webkit-color-swatch {
  border: none;
  border-radius: 4px;
}

.banner-color-custom-row .btn {
  flex: 1;
}

.status-option .status-dot {
  margin-top: 4px;
  flex-shrink: 0;
}

.status-option-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.status-option-text span {
  font-size: 14px;
  color: var(--text-primary);
}

.status-option-text small {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.3;
}

.status-option.active {
  background: rgba(60, 110, 255, 0.1);
}

/* Profile Actions */
.profile-popup-actions {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.profile-action-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 14px;
  transition: all var(--transition-fast);
  text-align: left;
}

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

.profile-action-btn i {
  width: 18px;
  text-align: center;
  color: var(--text-secondary);
}

.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: 340px 1fr;
  height: 100vh;
  background: var(--bg-primary);
}

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

/* Sidebar - Discord style */
.sidebar {
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-header {
  display: none;
}

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

/* Sidebar chats section */
.sidebar-chats {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

.sidebar-nav {
  display: none;
}

.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);
}

/* Mobile-only nav items - hidden on desktop */
.nav-item.mobile-only {
  display: none;
}

.sidebar-footer {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-secondary);
  flex-shrink: 0;
}

.sidebar-footer .icon-btn {
  flex-shrink: 0;
}

/* Full profile bar in Discord-style sidebar */
.sidebar .user-profile-bar {
  flex: 1;
  padding: 8px 12px;
}

/* Footer alignment: profile left, settings right */
.sidebar-footer .user-profile-bar {
  flex: 1;
}

.sidebar-footer .settings-btn {
  margin-left: auto;
}

.sidebar .user-profile-info,
.sidebar .user-profile-menu-btn {
  display: flex;
}

/* Profile popup positioning handled globally now */

.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 - now inside sidebar */
.panel {
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.chat-list-panel {
  display: none;
}

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

.panel-header .logo {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 12px;
}

.panel-header .logo-icon {
  width: 36px;
  height: 36px;
}

.panel-header .logo-text {
  font-size: 20px;
  font-weight: 900;
  cursor: pointer;
  transition: opacity 0.3s ease;
}

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

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

.panel-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;
}

.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;
  min-width: 0;
  overflow: hidden;
}

.chat-item .chat-name {
  font-weight: 700;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex: 0 1 auto;
  line-height: 1.2;
  display: flex;
  align-items: center;
}

/* Badge alignment in chat list - center everything vertically */
.chat-item .chat-top > div {
  display: flex;
  align-items: center;
  line-height: 1;
}

.chat-item .chat-top .verified-badge,
.chat-item .chat-top [title="Advanced"],
.chat-item .chat-top [title="Ultimate"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  flex-shrink: 0;
}

/* BOT badge vertical centering */
.chat-item .chat-top > div > span[style*="BOT"],
.chat-item .chat-top > div > span:has(svg) {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
}

.chat-item .chat-time {
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
  white-space: nowrap;
}

.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;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
}

.chat-item .chat-preview .preview-icon {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}

.chat-item .chat-preview .preview-icon i {
  font-size: 14px;
  line-height: 1;
}

.chat-item .chat-preview .preview-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.chat-item .chat-preview.active-call {
  color: var(--accent-success);
  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;
  position: relative;
  overflow: hidden;
  background: var(--bg-primary);
}

.no-chat-selected::before,
.no-chat-selected::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.no-chat-selected::before {
  background-image: var(--chat-wallpaper-url, none);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  filter: blur(var(--chat-wallpaper-blur, 0px));
  transform: scale(1.03);
  z-index: 0;
}

.no-chat-selected::after {
  background: var(--chat-wallpaper-overlay, transparent);
  z-index: 0;
}

.no-chat-selected > * {
  position: relative;
  z-index: 1;
}

/* Animated gradient background */
.welcome-bg {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.welcome-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.4;
  animation: float 20s ease-in-out infinite;
}

.welcome-orb.orb-1 {
  width: 400px;
  height: 400px;
  background: var(--accent-primary);
  top: -100px;
  right: -100px;
  animation-delay: 0s;
}

.welcome-orb.orb-2 {
  width: 300px;
  height: 300px;
  background: var(--accent-secondary);
  bottom: -50px;
  left: -50px;
  animation-delay: -7s;
}

.welcome-orb.orb-3 {
  width: 250px;
  height: 250px;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  animation-delay: -14s;
}

@keyframes float {
  0%, 100% {
    transform: translate(0, 0) scale(1);
  }
  25% {
    transform: translate(30px, -30px) scale(1.05);
  }
  50% {
    transform: translate(-20px, 20px) scale(0.95);
  }
  75% {
    transform: translate(20px, 10px) scale(1.02);
  }
}

.welcome-content {
  text-align: center;
  color: var(--text-secondary);
  position: relative;
  z-index: 1;
  max-width: 480px;
  padding: 24px;
}

.welcome-header {
  margin-bottom: 32px;
}

.welcome-icon {
  width: 72px;
  height: 72px;
  margin: 0 auto 20px;
}

.welcome-logo {
  width: 100%;
  height: 100%;
  border-radius: 16px;
  object-fit: cover;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.welcome-content h2 {
  margin-bottom: 8px;
  color: var(--text-primary);
  font-size: 28px;
  font-weight: 700;
}

.welcome-subtitle {
  color: var(--text-secondary);
  font-size: 15px;
}

/* Quick Action Cards */
.welcome-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-bottom: 28px;
}

.welcome-action-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 20px 24px;
  background: var(--bg-glass);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: 110px;
}

.welcome-action-card:hover {
  background: var(--bg-glass-light);
  transform: translateY(-4px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.15);
  border-color: var(--accent-primary);
}

.welcome-action-card .action-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: white;
}

.welcome-action-card span {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}

/* Tip of the day */
.welcome-tip {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px 20px;
  background: var(--bg-glass);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  text-align: left;
  margin-bottom: 24px;
  animation: tipFadeIn 0.5s ease;
}

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

.welcome-tip .tip-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #f59e0b, #f97316);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: white;
  flex-shrink: 0;
}

.welcome-tip .tip-content {
  flex: 1;
  min-width: 0;
}

.welcome-tip .tip-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--accent-warning);
  margin-bottom: 4px;
  display: block;
}

.welcome-tip .tip-text {
  font-size: 14px;
  color: var(--text-primary);
  line-height: 1.5;
  margin: 0;
}

/* Keyboard shortcuts */
.welcome-shortcuts {
  display: flex;
  gap: 20px;
  justify-content: center;
  flex-wrap: wrap;
}

.shortcut-item {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 12px;
}

.shortcut-item kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  padding: 0 6px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-family: inherit;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  box-shadow: 0 2px 0 var(--border-color);
}

.shortcut-item span {
  color: var(--text-muted);
}

/* Chat Area */
.chat-area {
  display: flex;
  flex-direction: column;
  height: 100%;
  flex: 1;
  min-height: 0;
  position: relative;
  background: var(--bg-primary);
  overflow: hidden;
}

.chat-area::before,
.chat-area::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.chat-area::before {
  background-image: var(--chat-wallpaper-url, none);
  background-size: cover;
  background-position: center;
  filter: blur(var(--chat-wallpaper-blur, 0px));
  transform: scale(1.03);
}

.chat-area::after {
  background: var(--chat-wallpaper-overlay, transparent);
}

.chat-area > * {
  position: relative;
  z-index: 1;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 24px;
  background: var(--chat-surface, 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;
  min-width: 0;
  overflow: hidden;
}

.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: 700;
  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-info .info .status.active-call {
  color: var(--accent-success);
  font-weight: 600;
}

.active-call-status {
  display: flex;
  align-items: center;
  gap: 6px;
}

.active-call-status::before {
  content: '';
  width: 8px;
  height: 8px;
  background: var(--accent-success);
  border-radius: 50%;
  animation: pulse-dot 1.5s infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(0.8); }
}

.join-call-btn {
  background: var(--accent-success) !important;
  color: #fff !important;
  padding: 6px 12px !important;
  border-radius: 8px !important;
  font-size: 13px !important;
  font-weight: 500;
  gap: 6px;
  width: auto !important;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.join-call-btn:hover {
  background: var(--accent-success) !important;
  transform: translateY(-1px);
}

.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;
}

.loading-indicator {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px;
  color: rgba(255, 255, 255, 0.6);
  font-size: 14px;
}

.loading-indicator.active {
  display: flex;
}

.loading-indicator .spinner {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-top-color: #2563eb;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

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

/* Date Separator - WhatsApp style */
.date-separator {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 12px 0;
  margin: 4px 0;
}

.date-separator-label {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: 20px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

/* System Message - Flutter style pill */
.system-message {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 8px 0;
  margin: 4px 0;
}

.system-message-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-tertiary);
  padding: 8px 14px;
  border-radius: 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
  max-width: 80%;
}

.system-message-text {
  color: var(--text-secondary);
  font-size: 12px;
  text-align: center;
}

.system-message-time {
  display: none;
}

.system-message-icon {
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--text-muted);
}

.system-message-icon svg {
  width: 16px;
  height: 16px;
  display: block;
}

.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: 18px 18px 18px 4px;
  padding: 12px 16px;
  max-width: min(720px, 80vw);
  width: fit-content;
  margin-left: 0;
}

.message-sender-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-primary);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
  line-height: 1.2;
}

.message-sender-name .verified-badge,
.message-sender-name [title="Advanced"],
.message-sender-name [title="Ultimate"],
.message-sender-name > span[style*="BOT"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.message-sender-name:hover {
  text-decoration: underline;
}

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

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

.message-text.expandable {
  position: relative;
}

.message-text.expandable[data-expanded="false"] {
  max-height: none;
  overflow: visible;
}

.message-text.expandable[data-expanded="true"] {
  max-height: none;
  overflow: visible;
}

.expand-message-btn {
  display: inline-block;
  background: none;
  border: none;
  color: var(--accent-primary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  padding: 4px 0;
  margin-top: 4px;
  transition: opacity 0.15s;
}

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

.message.outgoing .expand-message-btn {
  color: rgba(255, 255, 255, 0.9);
}

.message-reply {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  margin-bottom: 6px;
  border-left: 3px solid var(--accent-primary);
  background: var(--bg-glass-light);
  border-radius: 6px;
  max-width: 100%;
}

.message-reply.clickable {
  cursor: pointer;
}

.message-reply.clickable:hover {
  background: var(--bg-glass);
}

.message-reply-content {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.message-reply-author {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-primary);
}

.message-reply-text {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.message.outgoing .message-reply {
  border-left-color: rgba(255, 255, 255, 0.7);
  background: rgba(255, 255, 255, 0.12);
}

.message.outgoing .message-reply-author {
  color: rgba(255, 255, 255, 0.95);
}

.message.outgoing .message-reply-text {
  color: rgba(255, 255, 255, 0.7);
}

.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.outgoing .link-preview.loading::after {
  color: rgba(255, 255, 255, 0.7);
}

.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;
}

/* E2E Encryption indicator */
.e2e-indicator {
  display: inline-flex;
  align-items: center;
  font-size: 10px;
  color: var(--accent-success);
  margin-right: 2px;
}

.e2e-indicator i {
  font-size: 9px;
}

.message.outgoing .e2e-indicator {
  color: rgba(255, 255, 255, 0.8);
}

.message-status i {
  font-size: 12px;
  display: inline-block;
  min-width: 12px;
  transition: color 0.2s ease;
}

.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: center;
  gap: 8px;
  padding: 16px 24px;
  background: var(--chat-surface, var(--bg-secondary));
  border-top: 1px solid var(--border-color);
  flex-shrink: 0;
  margin-top: auto;
}

.message-input-area .icon-btn {
  width: 44px;
  height: 44px;
  min-width: 44px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
  font-size: 20px;
}

.message-input-area .icon-btn:hover {
  background: var(--bg-glass-light);
  color: var(--text-primary);
  transform: scale(1.05);
}

.message-input-area .icon-btn i {
  font-size: 20px;
}

.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;
  overflow-x: hidden;
  padding: 0;
}

/* Profile View */
.profile-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 20px 20px;
  text-align: center;
  overflow: hidden;
  max-width: 100%;
}

.profile-banner {
  width: calc(100% + 40px);
  height: 100px;
  margin: 0 -20px 20px;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  background-size: cover;
  background-position: 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;
  margin-top: -60px;
  border: 4px solid var(--bg-secondary);
  overflow: hidden;
  position: relative;
  z-index: 10;
}

.profile-avatar.clickable {
  cursor: pointer;
  transition: transform var(--transition-fast);
}

.profile-avatar.clickable:hover {
  transform: scale(1.05);
}

.profile-avatar.no-banner {
  margin-top: 20px;
}

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

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

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

.profile-avatar.no-banner {
  margin-top: 20px;
}

.profile-view h4 {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--text-primary);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.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: 700;
  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-close {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
  cursor: pointer;
  padding: 0;
  line-height: 1;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.modal-close i {
  font-size: 14px;
}

.modal-close:hover {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.35);
  color: #fff;
}

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

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

.modal-body::-webkit-scrollbar {
  width: 8px;
}

.modal-body::-webkit-scrollbar-track {
  background: transparent;
}

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

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

.modal-body {
  scrollbar-color: #1f2b3a transparent;
  scrollbar-width: thin;
}

.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 - Modern Redesign */
.modal-xl.settings-modal {
  max-width: 900px;
  width: 95vw;
  height: 85vh;
  max-height: 700px;
  padding: 0;
  overflow: hidden;
  border-radius: var(--radius-xl);
}

.settings-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  height: 100%;
}

.settings-sidebar {
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.settings-sidebar-header {
  padding: 20px;
  border-bottom: 1px solid var(--border-color);
}

.settings-user-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.settings-user-card:hover {
  background: rgba(60, 110, 255, 0.1);
}

.settings-user-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 20px;
  flex-shrink: 0;
  overflow: hidden;
  box-shadow: 0 4px 12px var(--accent-glow);
}

.settings-user-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.settings-user-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.settings-user-name {
  font-weight: 700;
  font-size: 15px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 4px;
}

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

.settings-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

.settings-nav-section {
  margin-bottom: 20px;
}

.settings-nav-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  padding: 8px 12px 6px;
}

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

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

.settings-nav-item.active {
  background: linear-gradient(135deg, rgba(60, 110, 255, 0.15), rgba(37, 99, 235, 0.1));
  color: var(--accent-primary);
}

.settings-nav-item.active .settings-nav-icon {
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  color: white;
  box-shadow: 0 2px 8px var(--accent-glow);
}

.settings-nav-icon {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.settings-sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border-color);
}

.settings-logout-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  color: var(--accent-error);
  font-size: 14px;
  font-weight: 500;
  transition: all var(--transition-fast);
}

.settings-logout-btn:hover {
  background: rgba(239, 68, 68, 0.1);
}

.settings-main {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-primary);
}

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

.settings-main-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
}

.settings-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  scrollbar-color: #1f2b3a transparent;
  scrollbar-width: thin;
}

.settings-content::-webkit-scrollbar {
  width: 8px;
}

.settings-content::-webkit-scrollbar-track {
  background: transparent;
}

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

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

.settings-nav::-webkit-scrollbar {
  width: 6px;
}

.settings-nav::-webkit-scrollbar-track {
  background: transparent;
}

.settings-nav::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #1f2b3a, #111827);
  border-radius: 999px;
}

.settings-nav {
  scrollbar-color: #1f2b3a transparent;
  scrollbar-width: thin;
}

.settings-section {
  margin-bottom: 32px;
}

.settings-section:last-child {
  margin-bottom: 0;
}

.settings-section-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.settings-group {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.settings-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  transition: background var(--transition-fast);
}

.settings-item:not(:last-child) {
  border-bottom: 1px solid var(--border-color);
}

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

.settings-item-left {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 1;
  min-width: 0;
}

.settings-item-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.settings-item-icon.accent {
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  color: white;
}

.settings-item-icon.success {
  background: linear-gradient(135deg, var(--accent-success), #059669);
  color: white;
}

.settings-item-icon.warning {
  background: linear-gradient(135deg, var(--accent-warning), #d97706);
  color: white;
}

.settings-item-icon.danger {
  background: linear-gradient(135deg, var(--accent-error), #dc2626);
  color: white;
}

.settings-item-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.settings-item-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}

.settings-item-desc {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.settings-item-value {
  font-size: 13px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Settings Select */
.settings-select {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  color: var(--text-primary);
  cursor: pointer;
  min-width: 140px;
  transition: all var(--transition-fast);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%237a8bb7' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}

.settings-select:hover {
  border-color: var(--accent-primary);
  background-color: var(--bg-glass-light);
}

.settings-select:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px rgba(60, 110, 255, 0.2);
}

.settings-select option {
  background: var(--bg-secondary);
  color: var(--text-primary);
  padding: 8px;
}

/* Toggle Switch */
.toggle-switch {
  position: relative;
  width: 48px;
  height: 28px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  transition: all var(--transition-fast);
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 22px;
  height: 22px;
  left: 2px;
  bottom: 2px;
  background: white;
  border-radius: 50%;
  transition: all var(--transition-fast);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.toggle-switch input:checked + .toggle-slider {
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  border-color: transparent;
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(20px);
}

.toggle-switch input:focus + .toggle-slider {
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.toggle-switch input:disabled + .toggle-slider {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Profile Avatar Edit */
.profile-avatar-section {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 24px;
}

.profile-avatar-large {
  position: relative;
  width: 80px;
  height: 80px;
}

.profile-avatar-large .avatar-img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 32px;
  overflow: hidden;
}

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

.profile-avatar-edit {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-primary);
  border: 2px solid var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 12px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.profile-avatar-edit:hover {
  background: var(--accent-secondary);
  transform: scale(1.1);
}

.profile-avatar-info {
  flex: 1;
}

.profile-avatar-info h4 {
  font-size: 15px;
  margin-bottom: 4px;
}

.profile-avatar-info p {
  font-size: 13px;
  color: var(--text-secondary);
}

/* Settings Form */
.settings-form-group {
  margin-bottom: 20px;
}

.settings-form-group:last-child {
  margin-bottom: 0;
}

.settings-form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

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

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

.settings-form-input::placeholder {
  color: var(--text-muted);
}

textarea.settings-form-input {
  resize: vertical;
  min-height: 100px;
}

.settings-form-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
}

/* Settings Actions */
.settings-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border-color);
}

.theme-editor {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.theme-preset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}

.theme-preset-card {
  border: 1px solid var(--preset-border);
  background: var(--preset-bg);
  color: var(--preset-text);
  border-radius: 16px;
  padding: 12px;
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: transform var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.theme-preset-card:hover {
  transform: translateY(-2px);
}

.theme-preset-card.active {
  border-color: var(--preset-accent);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.25);
}

.theme-preset-title {
  font-size: 14px;
  font-weight: 700;
}

.theme-preset-dots {
  display: flex;
  gap: 6px;
}

.theme-preset-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
}

.theme-wallpaper-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.theme-wallpaper-preview {
  position: relative;
  height: 180px;
  border-radius: 14px;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 16px;
}

.theme-wallpaper-preview::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: var(--theme-wallpaper-url, none);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  filter: blur(var(--theme-wallpaper-blur, 0px));
  transform: scale(1.04);
}

.theme-wallpaper-overlay {
  position: absolute;
  inset: 0;
  z-index: 1;
}

.theme-wallpaper-label {
  position: relative;
  z-index: 2;
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
}

.theme-preview-messages {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-width: 400px;
}

.theme-preview-message {
  display: flex;
  max-width: 70%;
}

.theme-preview-message.incoming {
  align-self: flex-start;
}

.theme-preview-message.outgoing {
  align-self: flex-end;
}

.theme-preview-message-content {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 8px 12px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

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

.theme-preview-message-text {
  font-size: 13px;
  line-height: 1.4;
  color: var(--text-primary);
}

.theme-preview-message.outgoing .theme-preview-message-text {
  color: white;
}

.theme-wallpaper-fields {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.theme-slider-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.theme-slider-label {
  min-width: 88px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.theme-slider-row input[type="range"] {
  flex: 1;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: var(--bg-tertiary);
  outline: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 999px;
  background: var(--bg-tertiary);
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent-primary);
  border: 2px solid var(--bg-secondary);
  box-shadow: 0 0 0 4px var(--accent-glow);
  margin-top: -5px;
}

input[type="range"]::-moz-range-track {
  height: 6px;
  border-radius: 999px;
  background: var(--bg-tertiary);
}

input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent-primary);
  border: 2px solid var(--bg-secondary);
  box-shadow: 0 0 0 4px var(--accent-glow);
}

input[type="range"]::-moz-range-progress {
  height: 6px;
  border-radius: 999px;
  background: var(--accent-primary);
}

.theme-slider-value {
  min-width: 48px;
  text-align: right;
  font-size: 13px;
  color: var(--text-secondary);
}

.theme-auto-card {
  overflow: hidden;
}

.theme-seed-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px 16px;
  border-top: 1px solid var(--border-color);
}

.theme-seed-label {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.theme-seed-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.theme-seed-desc {
  font-size: 12px;
  color: var(--text-secondary);
}

.theme-seed-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.theme-seed-controls input[type="color"] {
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  padding: 0;
}

.theme-actions {
  justify-content: flex-end;
}

.theme-editor-disabled {
  opacity: 0.6;
}

.theme-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  margin-bottom: 8px;
}

.theme-toggle-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.theme-toggle-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.theme-toggle-desc {
  font-size: 12px;
  color: var(--text-secondary);
}

.theme-toggle-note {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

/* Keyboard Shortcuts */
.shortcut-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.shortcut-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}

.shortcut-item span {
  font-size: 14px;
  color: var(--text-primary);
}

.shortcut-keys {
  display: flex;
  gap: 6px;
}

.key {
  padding: 4px 10px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--text-secondary);
}

/* Sessions List */
.sessions-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.session-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
}

.session-item:hover {
  border-color: var(--text-muted);
}

.session-item.current {
  border-color: var(--accent-primary);
  background: rgba(60, 110, 255, 0.05);
}

.session-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.session-info i {
  font-size: 20px;
  color: var(--text-secondary);
}

.session-info > div {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.session-device {
  font-size: 14px;
  font-weight: 500;
}

.session-details {
  font-size: 12px;
  color: var(--text-secondary);
}

/* About Section */
.about-logo {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}

.about-logo-img {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  overflow: hidden;
}

.about-logo-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.about-logo-text h3 {
  font-size: 20px;
  background: linear-gradient(90deg, #2563eb, #06b6d4);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.about-logo-text p {
  font-size: 13px;
  color: var(--text-secondary);
}

/* Storage Stats */
.storage-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.storage-stat {
  padding: 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  text-align: center;
}

.storage-stat-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--accent-primary);
  margin-bottom: 4px;
}

.storage-stat-label {
  font-size: 12px;
  color: var(--text-secondary);
}

/* Mobile Responsive for Settings */
@media (max-width: 768px) {
  .modal-xl.settings-modal {
    height: 100vh;
    max-height: none;
    border-radius: 0;
    width: 100%;
    max-width: 100%;
    margin: 0;
  }
  
  .settings-layout {
    grid-template-columns: 1fr;
    height: 100%;
  }
  
  .settings-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 100%;
    z-index: 10;
    transform: translateX(0);
    transition: transform 0.25s ease;
  }
  
  .settings-sidebar.hidden {
    transform: translateX(-100%);
  }
  
  .settings-main {
    position: relative;
  }
  
  .settings-main-header {
    padding: 12px 16px;
    gap: 12px;
  }
  
  /* Show back button on mobile */
  .settings-main-header .settings-back-btn {
    display: inline-flex;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: var(--text-secondary);
    font-size: 16px;
    transition: all var(--transition-fast);
  }
  
  .settings-main-header .settings-back-btn:hover {
    background: var(--bg-glass-light);
    color: var(--text-primary);
  }
  
  /* Title takes remaining space, left-aligned */
  .settings-main-header .settings-main-title {
    flex: 1;
    text-align: left;
    font-size: 18px;
  }
  
  /* Hide X from content pages - close button is in sidebar menu only */
  .settings-main-header .modal-close {
    display: none;
  }
  
  .settings-nav {
    padding: 8px 12px;
  }
  
  .settings-nav-item {
    padding: 14px 16px;
    border-radius: 12px;
  }
  
  .settings-sidebar-footer {
    padding: 16px;
  }
  
  .settings-content {
    padding: 16px;
  }
  
  .settings-sidebar-header .settings-mobile-close {
    display: flex;
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 10;
    width: 38px;
    height: 38px;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    color: var(--text-primary);
    font-size: 18px;
    backdrop-filter: blur(4px);
  }
  
  .settings-sidebar-header {
    position: relative;
  }
}

/* Hide mobile close button on desktop */
.settings-mobile-close {
  display: none;
}

/* Hide settings back button on desktop */
.settings-back-btn {
  display: none;
}

.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);
  overflow: hidden;
}

.user-result .avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

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

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

.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;
  transition: transform 0.3s ease-in-out, opacity 0.2s ease-in-out;
}

.call-ui-overlay.controls-hidden {
  transform: translateY(-100%);
  opacity: 0;
}

/* Keep ping/quality badges always visible */
.call-ui-overlay.controls-hidden .call-network-info {
  position: fixed;
  top: 16px;
  right: 16px;
  transform: none;
  opacity: 1;
}

.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: var(--text-secondary);
  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: var(--accent-warning); }
.signal-bars.signal-bad .bar:nth-child(1) { background: var(--accent-error); }

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

.ping-value {
  color: var(--text-primary);
}

.ping-unit {
  color: var(--text-muted);
  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: speaking-glow 1.5s infinite ease-in-out;
  border: 3px solid var(--accent-success);
}

@keyframes speaking-glow {
  0% { box-shadow: 0 0 24px 8px rgba(74, 222, 128, 0.5), 0 0 48px 12px rgba(74, 222, 128, 0.2); }
  50% { box-shadow: 0 0 32px 12px rgba(74, 222, 128, 0.65), 0 0 64px 20px rgba(74, 222, 128, 0.3); }
  100% { box-shadow: 0 0 24px 8px rgba(74, 222, 128, 0.5), 0 0 48px 12px rgba(74, 222, 128, 0.2); }
}

.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;
  max-width: 200px;
  max-height: 280px;
  min-width: 100px;
  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); }
}

.main-video-area.remote-speaking {
  box-shadow: inset 0 0 40px 8px rgba(74, 222, 128, 0.25);
  border: 2px solid rgba(74, 222, 128, 0.4);
  transition: box-shadow 0.3s ease, border 0.3s ease;
}

.main-video-area:not(.remote-speaking) {
  box-shadow: none;
  border: 2px solid transparent;
  transition: box-shadow 0.5s ease, border 0.5s ease;
}

.pip-content {
  display: block;
  pointer-events: none;
  position: relative;
  line-height: 0;
}

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

/* Video in PIP - both local and remote */
.pip-content video {
  display: none;
  width: auto;
  height: auto;
  max-width: 200px;
  max-height: 280px;
  min-width: 100px;
  min-height: 80px;
  border-radius: 14px;
  background: #000;
}

.pip-content video.active,
.pip-content video.pip-video {
  display: block;
}

.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;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  z-index: 25;
  display: none;
  flex-direction: row;
  align-items: center;
  gap: 12px;
  color: white;
  text-align: left;
  padding: 12px 20px;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

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

.reconnect-spinner {
  width: 24px;
  height: 24px;
  border: 3px solid rgba(255, 255, 255, 0.2);
  border-left-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  flex-shrink: 0;
}

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

.call-reconnect-overlay .reconnect-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.call-reconnect-overlay h3 {
  font-size: 14px;
  margin: 0;
  font-weight: 600;
}

.call-reconnect-overlay p {
  opacity: 0.7;
  font-size: 12px;
  margin: 0;
}

/* --- Call Warning --- */
.call-warning {
  position: absolute;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  color: var(--accent-warning);
  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;
  transition: transform 0.3s ease-in-out, opacity 0.2s ease-in-out;
}

.call-controls-wrapper.controls-hidden {
  transform: translateY(150%);
  opacity: 0;
  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: var(--accent-error);
  box-shadow: 0 4px 15px rgba(239, 68, 68, 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;
}

/* Volume Control in Menu */
.call-menu-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.1);
  margin: 8px 12px;
}

.call-menu-volume {
  padding: 12px 16px;
  display: none; /* Hidden by default, shown when remote is screen sharing */
  flex-direction: column;
  gap: 10px;
}

.call-menu-volume .volume-label {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  font-size: 14px;
}

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

.call-menu-volume .volume-label i.muted {
  color: var(--accent-error);
}

.volume-slider-container {
  display: flex;
  align-items: center;
  gap: 10px;
}

.volume-slider {
  flex: 1;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 3px;
  outline: none;
  cursor: pointer;
}

.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  transition: transform 0.15s ease;
}

.volume-slider::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

.volume-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  cursor: pointer;
  border: none;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.volume-value {
  min-width: 36px;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.7);
  text-align: right;
  flex-shrink: 0;
}

/* Device Selection Menu */
.call-ctrl-wrapper {
  position: relative;
}

.device-menu {
  position: absolute;
  bottom: 60px;
  left: 50%;
  transform: translateX(-50%);
  min-width: 220px;
  background: rgba(30, 41, 59, 0.98);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 8px 0;
  display: none;
  flex-direction: column;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  z-index: 100;
}

.device-menu.active {
  display: flex;
}

.device-menu-header {
  padding: 8px 16px;
  font-size: 12px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.5);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.device-menu-list {
  display: flex;
  flex-direction: column;
}

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

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

.device-menu-item.active {
  background: rgba(60, 110, 255, 0.2);
}

.device-menu-item i {
  width: 20px;
  text-align: center;
  font-size: 14px;
  color: #aaa;
}

.device-menu-item.active i {
  color: var(--accent-primary);
}

.device-menu-item .device-name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.device-menu-item .device-check {
  color: var(--accent-success);
  font-size: 12px;
  opacity: 0;
}

.device-menu-item.active .device-check {
  opacity: 1;
}

/* --- 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: 200px;
    min-width: 80px;
    min-height: 60px;
    border-radius: 10px;
    bottom: 95px;
    right: 12px;
  }
  
  .pip-content video {
    max-width: 140px;
    max-height: 200px;
    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: var(--accent-error);
}

.call-mini-btn.call-mini-end:hover {
  background: var(--accent-error);
}

/* Incoming Call - Top Banner Notification */
.incoming-call {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2000;
  display: none;
  animation: slideDown 0.3s ease;
}

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

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

.incoming-call-content {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 12px 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  min-width: 320px;
  max-width: 480px;
}

.incoming-call .call-avatar {
  width: 48px;
  height: 48px;
  font-size: 20px;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
}

.incoming-call .call-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.incoming-call-info {
  flex: 1;
  min-width: 0;
}

.caller-name {
  display: block;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.incoming-call-actions {
  display: flex;
  gap: 12px;
  flex-shrink: 0;
}

.incoming-call-actions .call-btn {
  width: 44px;
  height: 44px;
  font-size: 18px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.incoming-call-actions .call-btn.accept-btn:hover {
  background: var(--accent-success);
  transform: scale(1.1);
}

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

.incoming-call-actions .call-btn.decline-btn:hover {
  background: var(--accent-error);
  transform: scale(1.1);
}

/* 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: var(--accent-success);
}

.rejoin-call-end {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(239, 68, 68, 0.2);
  color: var(--accent-error);
  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: 300px 1fr;
  }
  
  .app-container.profile-open {
    grid-template-columns: 300px 1fr;
  }
  
  .sidebar {
    width: 300px;
  }
  
  .chat-list-panel {
    display: none;
  }
  
  .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;
    position: relative;
  }
  
  /* Sidebar takes full screen on mobile like Flutter */
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    right: 0;
    width: 100%;
    z-index: 50;
    transform: translateX(0);
    transition: transform var(--transition-normal);
    border-right: none;
  }
  
  .sidebar.mobile-hidden {
    transform: translateX(-100%);
  }
  
  .sidebar-chats {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  
  /* Panel header - logo and actions */
  .sidebar-chats .panel-header {
    padding: 16px;
    flex-shrink: 0;
  }
  
  .sidebar-chats .panel-header .logo {
    gap: 10px;
  }
  
  .sidebar-chats .panel-header .logo-icon {
    width: 32px;
    height: 32px;
  }
  
  .sidebar-chats .panel-header .logo-text {
    font-size: 18px;
  }
  
  .sidebar-chats .panel-actions .icon-btn {
    width: 38px;
    height: 38px;
  }
  
  /* Search box full width */
  .sidebar-chats .search-box {
    margin: 0 16px 12px;
    padding: 12px 16px;
    border-radius: 12px;
  }
  
  .sidebar-chats .search-box input {
    font-size: 16px;
  }
  
  /* Chat list takes remaining space */
  .sidebar-chats .chat-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 8px;
  }
  
  /* Sidebar footer - profile and settings */
  .sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border-color);
    gap: 12px;
  }
  
  .sidebar-footer .user-profile-bar {
    flex: 1;
  }
  
  .sidebar-footer .icon-btn {
    width: 44px;
    height: 44px;
  }
  
  .main-area {
    position: fixed;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    transform: translateX(100%);
    transition: transform var(--transition-normal);
  }
  
  .main-area.mobile-visible {
    transform: translateX(0);
  }
  
  .mobile-back {
    display: flex;
  }
  
  .chat-header {
    padding: 14px 16px;
  }
  
  .chat-info .avatar {
    width: 40px;
    height: 40px;
    min-width: 40px;
  }
  
  .chat-info .info .name {
    font-size: 16px;
  }
  
  .chat-info .info .status {
    font-size: 13px;
  }
  
  .message-input-area {
    padding: 12px 16px;
  }
  
  .message-input-area textarea {
    font-size: 16px;
    min-height: 42px;
  }
  
  .message-input-area .icon-btn {
    width: 40px;
    height: 40px;
    font-size: 18px;
  }
  
  .messages-container {
    padding: 16px 12px;
  }
  
  .messages {
    gap: 12px;
  }
  
  .message {
    max-width: 85%;
  }
  
  .message-content {
    max-width: 100%;
    font-size: 15px;
    line-height: 1.5;
    padding: 10px 14px;
  }
  
  .message-text {
    font-size: 15px;
  }
  
  .message-time {
    font-size: 11px;
  }
  
  .right-panel {
    position: fixed;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    z-index: 60;
  }
  
  .panel-header h2 {
    font-size: 18px;
  }
  
  .search-box {
    margin: 8px 12px;
    padding: 10px 12px;
  }
  
  .chat-list {
    padding: 4px 8px;
  }
  
  .chat-item {
    padding: 14px 12px;
    border-radius: 12px;
    margin: 2px 0;
  }
  
  .chat-item .avatar {
    width: 52px;
    height: 52px;
    min-width: 52px;
  }
  
  .chat-item .chat-info {
    gap: 4px;
  }
  
  .chat-item .chat-name {
    font-size: 16px;
    font-weight: 600;
  }
  
  .chat-item .chat-preview {
    font-size: 14px;
  }
  
  .chat-item .chat-time {
    font-size: 12px;
  }
  
  .chat-item .unread-badge {
    font-size: 13px;
    padding: 3px 10px;
    min-width: 22px;
  }
  
  .toast-container {
    bottom: 90px;
    left: 12px;
    right: 12px;
  }
  
  .toast {
    min-width: 280px;
    max-width: calc(100vw - 24px);
  }
  
  .settings-body {
    flex-direction: column;
  }
  
  .settings-nav {
    flex-direction: row;
    overflow-x: auto;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
    padding: 0;
  }
  
  .settings-nav-item {
    padding: 12px 16px;
    white-space: nowrap;
    border-left: none;
    border-bottom: 2px solid transparent;
  }
  
  .settings-nav-item.active {
    border-left: none;
    border-bottom-color: var(--accent-primary);
  }
  
  .modal-content {
    width: 95%;
    max-width: 95%;
    max-height: 90vh;
    margin: 20px auto;
  }
  
  .modal-content.modal-lg {
    width: 95%;
    max-width: 95%;
  }
  
  .incoming-call {
    left: 12px;
    right: 12px;
    bottom: 76px;
    border-radius: 12px;
  }
  
  .incoming-call-content {
    flex-direction: column;
    gap: 12px;
    align-items: stretch;
  }
  
  .incoming-call-info {
    text-align: center;
  }
  
  .incoming-call-actions {
    justify-content: center;
    gap: 24px;
  }
  
  .incoming-call-actions .call-btn {
    width: 56px;
    height: 56px;
    font-size: 22px;
  }
  
  .call-minimized {
    bottom: 76px;
    right: 12px;
  }
  
  .profile-actions {
    flex-direction: column;
  }
  
  .profile-actions .btn {
    width: 100%;
  }
  
  .user-search-results {
    max-height: 40vh;
  }
  
  .no-chat-selected {
    padding: 24px 16px;
  }
  
  .welcome-content {
    max-width: 100%;
    padding: 16px;
  }
  
  .welcome-header {
    margin-bottom: 24px;
  }
  
  .welcome-icon {
    width: 60px;
    height: 60px;
    margin: 0 auto 16px;
  }
  
  .welcome-logo {
    border-radius: 14px;
  }
  
  .welcome-content h2 {
    font-size: 22px;
    margin-bottom: 8px;
  }
  
  .welcome-subtitle {
    font-size: 14px;
  }
  
  /* Mobile: stack action cards */
  .welcome-actions {
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
  }
  
  .welcome-action-card {
    flex-direction: row;
    justify-content: flex-start;
    padding: 14px 18px;
    min-width: auto;
    gap: 14px;
  }
  
  .welcome-action-card .action-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    font-size: 16px;
  }
  
  .welcome-action-card span {
    font-size: 14px;
  }
  
  .welcome-tip {
    padding: 14px 16px;
    margin-bottom: 20px;
  }
  
  .welcome-tip .tip-icon {
    width: 32px;
    height: 32px;
    font-size: 14px;
  }
  
  .welcome-tip .tip-text {
    font-size: 13px;
  }
  
  /* Hide keyboard shortcuts on mobile */
  .welcome-shortcuts {
    display: none;
  }
  
  /* Smaller orbs on mobile */
  .welcome-orb.orb-1 {
    width: 250px;
    height: 250px;
  }
  
  .welcome-orb.orb-2 {
    width: 200px;
    height: 200px;
  }
  
  .welcome-orb.orb-3 {
    width: 150px;
    height: 150px;
  }
  
  /* Profile popup on mobile - full width bottom sheet */
  .user-profile-popup {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-height: 80vh;
    border-radius: 20px 20px 0 0;
    overflow-y: auto;
    overflow-x: hidden;
    transform: translateY(100%);
    transition: opacity 250ms ease, visibility 250ms ease, transform 300ms cubic-bezier(0.32, 0.72, 0, 1);
    z-index: 10001;
    border: none;
    box-shadow: 0 -4px 32px rgba(0, 0, 0, 0.5);
  }
  
  .user-profile-popup.active {
    transform: translateY(0);
  }
  
  /* Backdrop for profile popup on mobile */
  .user-profile-popup-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    opacity: 0;
    transition: opacity 250ms ease;
  }
  
  .user-profile-popup-backdrop.active {
    display: block;
    opacity: 1;
  }
  
  /* Handle indicator for bottom sheet */
  .user-profile-popup::before {
    content: '';
    display: block;
    width: 40px;
    height: 4px;
    background: var(--text-muted);
    border-radius: 2px;
    margin: 10px auto 4px;
    opacity: 0.5;
  }
  
  /* Fix status dropdown clipping inside popup */
  .user-profile-popup .status-selector-dropdown {
    position: relative;
    left: auto;
    right: auto;
    top: auto;
    transform: none;
    margin-top: 8px;
    opacity: 0;
    visibility: hidden;
    max-height: 0;
    overflow: hidden;
    transition: all 200ms ease;
    box-shadow: none;
    border: 1px solid var(--border-color);
  }
  
  /* When active: show regardless of hover state */
  .user-profile-popup .status-selector-dropdown.active,
  .user-profile-popup .profile-status-selector:hover .status-selector-dropdown.active {
    opacity: 1;
    visibility: visible;
    max-height: 300px;
    overflow: visible;
  }
  
  /* Disable hover-only opening completely */
  .user-profile-popup .profile-status-selector:hover .status-selector-dropdown:not(.active) {
    opacity: 0;
    visibility: hidden;
    max-height: 0;
  }
}

/* ==================== MOBILE PROFILE MODAL ==================== */
.mobile-profile-modal {
  z-index: 1100;
}

.mobile-profile-modal .modal-content.mobile-profile-content {
  width: 100%;
  max-width: 100%;
  height: 100%;
  max-height: 100%;
  margin: 0;
  border-radius: 0;
  background: var(--bg-primary);
  display: flex;
  flex-direction: column;
}

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

.mobile-profile-header h3 {
  font-size: 18px;
  font-weight: 600;
  margin: 0;
}

.mobile-profile-body {
  flex: 1;
  overflow-y: auto;
  padding-bottom: 80px;
}

.mobile-profile-banner {
  height: 120px;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  position: relative;
}

.mobile-profile-banner img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.mobile-profile-avatar-wrap {
  display: flex;
  justify-content: center;
  margin-top: -50px;
  position: relative;
  z-index: 2;
}

.mobile-profile-avatar {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  border: 4px solid var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 36px;
  font-weight: 700;
  position: relative;
  overflow: visible;
}

.mobile-profile-avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.mobile-profile-avatar .avatar-letter {
  font-size: 36px;
  font-weight: 700;
  text-transform: uppercase;
}

.mobile-profile-avatar .status-indicator {
  position: absolute;
  bottom: 2px;
  right: 2px;
}

.mobile-profile-info {
  text-align: center;
  padding: 16px 20px 24px;
}

.mobile-profile-info h2 {
  font-size: 24px;
  font-weight: 700;
  margin: 0 0 4px;
  color: var(--text-primary);
  word-wrap: break-word;
  overflow-wrap: break-word;
  max-width: 100%;
}

.mobile-profile-username {
  font-size: 14px;
  color: var(--text-secondary);
  margin: 0 0 8px;
}

.mobile-profile-bio {
  font-size: 14px;
  color: var(--text-primary);
  margin: 8px 0 0;
  line-height: 1.4;
}

.mobile-profile-status-section {
  padding: 0 16px 24px;
}

.mobile-profile-section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
  padding: 0 4px;
}

.mobile-status-options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.mobile-status-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  color: var(--text-primary);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.mobile-status-option:hover {
  background: var(--bg-tertiary);
}

.mobile-status-option.active {
  background: rgba(37, 99, 235, 0.1);
  border-color: var(--accent-primary);
}

.mobile-status-option .status-dot {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
}

.mobile-profile-actions {
  padding: 0 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mobile-profile-action-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  color: var(--text-primary);
  font-size: 15px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.mobile-profile-action-btn:hover {
  background: var(--bg-tertiary);
}

.mobile-profile-action-btn i:first-child {
  width: 20px;
  text-align: center;
  color: var(--text-secondary);
}

.mobile-profile-action-btn span {
  flex: 1;
  text-align: left;
}

.mobile-profile-action-btn i:last-child {
  color: var(--text-muted);
  font-size: 12px;
}

.mobile-profile-action-btn.danger {
  color: var(--accent-error);
}

.mobile-profile-action-btn.danger i:first-child {
  color: var(--accent-error);
}

/* 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;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* Voice Messages */
.voice-message {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-width: 200px;
  max-width: 320px;
  position: relative;
}

.voice-message.missing {
  opacity: 0.8;
  pointer-events: none;
}

.voice-play-btn {
  width: 40px;
  height: 40px;
  min-width: 40px;
  border-radius: 50%;
  background: var(--accent-primary);
  border: none;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: transform 0.15s ease, background 0.15s ease;
}

.voice-play-btn:hover {
  background: var(--accent-primary-hover);
  transform: scale(1.05);
}

.message.outgoing .voice-play-btn {
  background: rgba(255, 255, 255, 0.2); /* match app: white 20% */
  color: #fff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
}

.message.outgoing .voice-play-btn i {
  color: #fff;
}

.voice-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.voice-waveform {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 28px;
  cursor: pointer;
}

.voice-bar {
  width: 3px;
  min-height: 4px;
  background: var(--text-muted);
  border-radius: 2px;
  transition: background 0.15s ease;
}

.voice-bar.played {
  background: var(--accent-primary);
}

.message.outgoing .voice-bar {
  background: rgba(255, 255, 255, 0.4) !important; /* inactive */
}

.message.outgoing .voice-bar.played {
  background: #ffffff !important; /* active */
}

.voice-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.voice-time {
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* Lighten text in own voice messages */
.message.outgoing .voice-time {
  color: rgba(255, 255, 255, 0.7) !important;
}

.message.own .voice-transcription {
  color: rgba(255, 255, 255, 0.9);
  background: rgba(255, 255, 255, 0.15);
}

.voice-transcription {
  font-size: 13px;
  color: var(--text-secondary);
  background: var(--bg-glass-light);
  padding: 8px 10px;
  border-radius: 8px;
  margin-top: 4px;
  line-height: 1.4;
}

/* Voice Waveform Row (waveform + transcribe button) */
.voice-waveform-row {
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  overflow: hidden;
}

.voice-waveform-row .voice-waveform {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

/* Voice Transcribe Button */
.voice-transcribe-btn {
  background: rgba(0, 0, 0, 0.06);
  border: none;
  color: var(--accent-primary);
  font-size: 12px;
  font-weight: 600;
  padding: 4px 6px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 2px;
  white-space: nowrap;
}

.voice-transcribe-btn i {
  font-size: 10px;
}

.voice-transcribe-btn .transcribe-letter {
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  font-size: 13px;
}

.voice-transcribe-btn:hover {
  background: rgba(0, 0, 0, 0.12);
}

.voice-transcribe-btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.voice-transcribe-btn.loading {
  padding: 4px 8px;
}

.voice-transcribe-btn.loading i {
  font-size: 14px;
}

.message.own .voice-transcribe-btn,
.message.outgoing .voice-transcribe-btn {
  background: rgba(255, 255, 255, 0.2);
  color: white;
}

.message.own .voice-transcribe-btn:hover,
.message.outgoing .voice-transcribe-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  color: white;
}

.voice-transcribe-btn.error {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
  cursor: default;
}

.voice-transcribe-btn.error i {
  font-size: 14px;
}

.message.own .voice-transcribe-btn.error,
.message.outgoing .voice-transcribe-btn.error {
  background: rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.7);
}

/* Voice Recording UI */
.voice-recording-overlay {
  position: absolute;
  inset: 0;
  background: var(--bg-secondary);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  z-index: 10;
  animation: fadeIn 0.2s ease;
}

.voice-recording-cancel {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent-danger);
  border: none;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: transform 0.15s ease;
}

.voice-recording-cancel:hover {
  transform: scale(1.1);
}

.voice-recording-waveform {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  height: 36px;
}

.voice-recording-bar {
  width: 4px;
  background: var(--accent-primary);
  border-radius: 2px;
  transition: height 0.1s ease;
  animation: voicePulse 0.5s ease-in-out infinite alternate;
}

@keyframes voicePulse {
  from { opacity: 0.6; }
  to { opacity: 1; }
}

.voice-recording-time {
  font-size: 14px;
  color: var(--accent-danger);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  display: flex;
  align-items: center;
  gap: 6px;
}

.voice-recording-time::before {
  content: '';
  width: 8px;
  height: 8px;
  background: var(--accent-danger);
  border-radius: 50%;
  animation: recordingPulse 1s ease-in-out infinite;
}

@keyframes recordingPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.voice-recording-send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent-primary);
  border: none;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: transform 0.15s ease, background 0.15s ease;
}

.voice-recording-send:hover {
  background: var(--accent-primary-hover);
  transform: scale(1.05);
}

/* Mic button styling */
.mic-btn {
  transition: all 0.2s ease;
}

.mic-btn.recording {
  background: var(--accent-danger) !important;
  animation: micPulse 1s ease-in-out infinite;
}

@keyframes micPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Message input area adjustments for voice */
.message-input-area {
  position: relative;
}

.input-container {
  position: relative;
}

/* ===== Attachment Picker Modal ===== */
.attachment-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

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

.attachment-modal-content {
  background: var(--bg-secondary);
  border-radius: 16px;
  width: min(560px, 90vw);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
  animation: modalSlideIn 0.25s ease-out;
}

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

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

.attachment-modal-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.attachment-modal-close {
  opacity: 0.7;
}

.attachment-modal-close:hover {
  opacity: 1;
}

/* Drop Zone */
.attachment-drop-zone {
  margin: 20px;
  padding: 40px 20px;
  border: 2px dashed var(--border-color);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  background: var(--bg-tertiary);
}

.attachment-drop-zone.drag-over {
  border-color: var(--accent-primary);
  background: rgba(37, 99, 235, 0.1);
}

.drop-zone-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
}

.drop-zone-content i {
  font-size: 48px;
  color: var(--accent-primary);
  opacity: 0.8;
}

.drop-zone-content p {
  margin: 0;
  font-size: 16px;
  color: var(--text-primary);
}

.drop-zone-content span {
  color: var(--text-muted);
  font-size: 13px;
}

/* Preview Container */
.attachment-preview-container {
  display: none;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 12px;
  padding: 16px 20px;
  max-height: 280px;
  overflow-y: auto;
}

/* Custom scrollbar for attachment preview */
.attachment-preview-container::-webkit-scrollbar {
  width: 8px;
}

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

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

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

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

.attachment-preview-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}

.attachment-preview-item img,
.attachment-preview-item video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

.preview-play-icon {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.3);
}

.preview-play-icon i {
  font-size: 24px;
  color: white;
}

.preview-file-icon {
  font-size: 32px;
  margin-bottom: 8px;
}

.preview-file-name {
  font-size: 10px;
  color: var(--text-secondary);
  text-align: center;
  padding: 0 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.preview-size-badge {
  position: absolute;
  bottom: 4px;
  left: 4px;
  background: rgba(0, 0, 0, 0.6);
  color: white;
  font-size: 9px;
  padding: 2px 5px;
  border-radius: 4px;
}

.preview-remove-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  border: none;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.attachment-preview-item:hover .preview-remove-btn {
  opacity: 1;
}

.preview-remove-btn:hover {
  background: rgba(239, 68, 68, 0.8);
}

/* Caption Input */
.attachment-caption-container {
  padding: 0 20px 16px;
}

.attachment-caption-input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 14px;
  transition: border-color 0.2s ease;
}

.attachment-caption-input:focus {
  outline: none;
  border-color: var(--accent-primary);
}

.attachment-caption-input::placeholder {
  color: var(--text-muted);
}

/* Actions */
.attachment-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-top: 1px solid var(--border-color);
}

.attachment-count {
  color: var(--text-muted);
  font-size: 13px;
}

.attachment-actions .btn {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Chat Area Drag Active State */
.chat-area.drag-active::after {
  content: 'Перетащите файлы сюда';
  position: absolute;
  inset: 0;
  background: rgba(37, 99, 235, 0.15);
  border: 3px dashed var(--accent-primary);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 600;
  color: var(--accent-primary);
  z-index: 100;
  pointer-events: none;
}

/* Message Attachments Display */
.message-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 8px;
  max-width: 320px;
}

.message-attachment {
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.15s ease;
}

.attachment-missing {
  position: relative;
  pointer-events: none;
  opacity: 0.8;
}

.attachment-missing-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #f59e0b;
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
  z-index: 2;
}

.message-attachment:hover {
  transform: scale(1.02);
}

.message-attachment img {
  max-width: 100%;
  max-height: 300px;
  display: block;
}

/* Media loading state with NovaLoader */
.message-attachment.media-loading {
  min-width: 120px;
  min-height: 120px;
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.message-attachment.media-loading img {
  opacity: 0;
  position: absolute;
}

.message-attachment .media-loader {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.message-attachment.media-loaded .media-loader {
  display: none;
}

.message-attachment.media-loaded img {
  opacity: 1;
  transition: opacity 0.2s ease;
}

.message-media-group-item.media-loading {
  min-width: 80px;
  min-height: 80px;
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.message-media-group-item.media-loading img {
  opacity: 0;
  position: absolute;
}

.message-media-group-item .media-loader {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.message-media-group-item.media-loaded .media-loader {
  display: none;
}

.message-media-group-item.media-loaded img {
  opacity: 1;
  transition: opacity 0.2s ease;
}

/* Video loading states */
.message-attachment-video.media-loading video,
.message-attachment-video.media-loading .video-thumbnail {
  opacity: 0;
  position: absolute;
}

.message-attachment-video.media-loaded video,
.message-attachment-video.media-loaded .video-thumbnail {
  opacity: 1;
  transition: opacity 0.2s ease;
}

.message-attachment-video.media-loaded .media-loader {
  display: none;
}

/* Grid item video loading states */
.message-media-group-item.media-loading video,
.message-media-group-item.media-loading .video-thumbnail {
  opacity: 0;
  position: absolute;
}

.message-media-group-item.media-loaded video,
.message-media-group-item.media-loaded .video-thumbnail {
  opacity: 1;
  transition: opacity 0.2s ease;
}

.message-attachment-video {
  position: relative;
}

.message-attachment-video video {
  max-width: 100%;
  max-height: 300px;
  display: block;
}

.message-attachment-play {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.3);
}

.message-attachment-play i {
  font-size: 36px;
  color: white;
}

.message-attachment-document {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--bg-tertiary);
  border-radius: 10px;
  min-width: 200px;
}

.message-attachment-document-icon {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.message-attachment-document-info {
  flex: 1;
  min-width: 0;
}

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

.message-attachment-document-size {
  font-size: 12px;
  color: var(--text-muted);
}

/* Media Group (multiple images/videos) */
.message-media-group {
  display: grid;
  gap: 2px;
  border-radius: 12px;
  overflow: hidden;
  max-width: 320px;
}

.message-media-group.count-2 {
  grid-template-columns: 1fr 1fr;
}

.message-media-group.count-3 {
  grid-template-columns: 2fr 1fr;
  grid-template-rows: 1fr 1fr;
}

.message-media-group.count-3 > :first-child {
  grid-row: span 2;
}

.message-media-group.count-4 {
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
}

.message-media-group-item {
  position: relative;
  overflow: hidden;
  cursor: pointer;
}

.message-media-group-item img,
.message-media-group-item video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.message-media-group-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 24px;
  font-weight: bold;
}

/* Location Message */
.message-location {
  width: 240px;
  height: 140px;
  border-radius: 12px;
  overflow: hidden;
  position: relative;
  background: var(--bg-tertiary);
  cursor: pointer;
}

.message-location-map {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.message-location-pin {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -100%);
  font-size: 28px;
  color: #ef4444;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.message-location-address {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 8px 10px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
  color: white;
  font-size: 12px;
}

/* Poll Message */
.message-poll {
  min-width: 260px;
  max-width: 320px;
}

.message-poll-question {
  font-weight: 600;
  font-size: 15px;
  margin-bottom: 12px;
}

/* Spoiler styles */
.has-spoiler {
  position: relative;
}

.has-spoiler img,
.has-spoiler video {
  filter: blur(30px);
  transition: filter 0.3s ease;
}

.spoiler-revealed img,
.spoiler-revealed video {
  filter: none;
}

.spoiler-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  z-index: 5;
  border-radius: 12px;
}

.spoiler-overlay i {
  font-size: 28px;
  color: rgba(255, 255, 255, 0.9);
}

.spoiler-overlay span {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.8);
  font-weight: 500;
}

.spoiler-overlay .spoiler-particles {
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: 12px;
}

/* Edit button in attachment preview */
.preview-edit-btn {
  position: absolute;
  top: 28px;
  left: 4px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  border: none;
  color: rgba(255, 255, 255, 0.8);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  transition: all 0.2s ease;
  z-index: 3;
}

.preview-edit-btn:hover {
  background: var(--accent-primary);
  color: white;
}

/* Spoiler button in attachment preview */
.preview-spoiler-btn {
  position: absolute;
  bottom: 28px;
  left: 4px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  border: none;
  color: rgba(255, 255, 255, 0.7);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  transition: all 0.2s ease;
  z-index: 3;
}

.preview-spoiler-btn:hover {
  background: rgba(0, 0, 0, 0.8);
  color: white;
}

.preview-spoiler-btn.active {
  background: var(--accent-primary);
  color: white;
}

.attachment-preview-item.has-spoiler img,
.attachment-preview-item.has-spoiler video {
  filter: blur(10px);
}

.message-poll-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.message-poll-option {
  position: relative;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--bg-tertiary);
  cursor: pointer;
  transition: background 0.15s ease;
  overflow: hidden;
}

.message-poll-option:hover {
  background: var(--bg-primary);
}

.message-poll-option.selected {
  border: 2px solid var(--accent-primary);
}

.message-poll-option-bar {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  background: var(--accent-primary);
  opacity: 0.15;
  transition: width 0.3s ease;
}

.message-poll-option-text {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.message-poll-option-percent {
  font-weight: 600;
  font-size: 13px;
  color: var(--accent-primary);
}

.message-poll-footer {
  margin-top: 12px;
  font-size: 12px;
  color: var(--text-muted);
}

/* Audio Attachment */
.message-attachment-audio {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--bg-tertiary);
  border-radius: 12px;
  min-width: 220px;
}

.audio-play-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent-primary);
  border: none;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
  transition: transform 0.15s ease, background 0.15s ease;
}

.audio-play-btn:hover {
  background: var(--accent-primary-hover);
  transform: scale(1.05);
}

.audio-content {
  flex: 1;
  min-width: 0;
}

.audio-name {
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.audio-progress {
  height: 4px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 4px;
}

.audio-progress-bar {
  height: 100%;
  background: var(--accent-primary);
  width: 0%;
  transition: width 0.1s linear;
}

.audio-info {
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  gap: 2px;
}

.audio-current-time {
  color: var(--text-secondary);
}

.audio-duration {
  color: var(--text-muted);
}

.audio-progress {
  cursor: pointer;
}

.audio-download-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  flex-shrink: 0;
  transition: all 0.15s ease;
}

.audio-download-btn:hover {
  background: var(--bg-primary);
  color: var(--accent-primary);
}

.message.own .audio-download-btn {
  color: rgba(255, 255, 255, 0.6);
}

.message.own .audio-download-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  color: white;
}

/* Document Download Button */
.message-attachment-document-download {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  flex-shrink: 0;
  transition: background 0.15s ease, color 0.15s ease;
}

.message-attachment-document:hover .message-attachment-document-download {
  background: var(--accent-primary);
  color: white;
}

/* Media Viewer Overlay */
.media-viewer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

.media-viewer-content {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
}

.media-viewer-content img,
.media-viewer-content video {
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
  border-radius: 8px;
}

.media-viewer-close {
  position: absolute;
  top: -40px;
  right: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: background 0.15s ease;
}

.media-viewer-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Own message attachment styles */
.message.own .message-attachment-document {
  background: rgba(255, 255, 255, 0.15);
}

.message.own .message-attachment-document-download {
  background: rgba(255, 255, 255, 0.2);
}

.message.own .message-attachment-audio {
  background: rgba(255, 255, 255, 0.15);
}

.message.own .audio-play-btn {
  background: rgba(255, 255, 255, 0.25);
  color: #0f172a;
}

.message.own .audio-progress {
  background: rgba(255, 255, 255, 0.3);
}

.message.own .audio-progress-bar {
  background: white;
}

/* Poll Creator Modal */
.poll-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

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

.poll-modal-content {
  background: var(--bg-secondary);
  border-radius: 16px;
  width: min(480px, 90vw);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
  animation: modalSlideIn 0.25s ease-out;
}

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

.poll-modal-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.poll-modal-close {
  opacity: 0.7;
}

.poll-modal-close:hover {
  opacity: 1;
}

.poll-form {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.poll-question-container {
  margin-bottom: 20px;
}

.poll-question-input {
  width: 100%;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 16px;
  font-weight: 500;
  transition: border-color 0.2s ease;
}

.poll-question-input:focus {
  outline: none;
  border-color: var(--accent-primary);
}

.poll-question-input::placeholder {
  color: var(--text-muted);
}

.poll-options-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}

.poll-option-input-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
}

.poll-option-input {
  flex: 1;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 14px;
  transition: border-color 0.2s ease;
}

.poll-option-input:focus {
  outline: none;
  border-color: var(--accent-primary);
}

.poll-option-input::placeholder {
  color: var(--text-muted);
}

.poll-option-remove {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, color 0.15s ease;
}

.poll-option-remove:hover {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
}

.poll-add-option-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 10px;
  background: transparent;
  border: 1px dashed var(--border-color);
  color: var(--accent-primary);
  cursor: pointer;
  font-size: 14px;
  transition: background 0.15s ease, border-color 0.15s ease;
  margin-bottom: 20px;
}

.poll-add-option-btn:hover {
  background: rgba(37, 99, 235, 0.05);
  border-color: var(--accent-primary);
}

.poll-settings {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.poll-setting {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-secondary);
}

.poll-setting input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent-primary);
}

.poll-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 20px;
  border-top: 1px solid var(--border-color);
}

.poll-actions .btn {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: var(--bg-primary);
}

/* Saved Messages Button */
.btn-saved-messages {
  background: linear-gradient(135deg, #5B8DEF, #7C6AEF);
  color: white;
  border: none;
  padding: 14px 20px;
  border-radius: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-saved-messages:hover {
  background: linear-gradient(135deg, #4A7CE0, #6B59E0);
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(91, 141, 239, 0.4);
}

.btn-saved-messages i {
  font-size: 16px;
}

/* Attachment Type Buttons */
.attachment-type-buttons {
  display: flex;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
}

.attachment-type-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px 12px;
  border-radius: 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.15s ease;
}

.attachment-type-btn:hover {
  background: var(--bg-primary);
  border-color: var(--accent-primary);
}

.attachment-type-btn i {
  font-size: 24px;
  color: var(--accent-primary);
}

.attachment-type-btn span {
  font-size: 12px;
  font-weight: 500;
}

/* Upload Progress Overlay - Telegram-style */
.upload-progress-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: inherit;
  backdrop-filter: blur(2px);
  z-index: 10;
}

.upload-progress-circle {
  position: relative;
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.upload-progress-circle svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.upload-progress-circle .progress-bg {
  fill: none;
  stroke: rgba(255, 255, 255, 0.2);
  stroke-width: 3;
}

.upload-progress-circle .progress-bar {
  fill: none;
  stroke: #fff;
  stroke-width: 3;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.2s ease;
}

.upload-progress-text {
  position: absolute;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
}

/* Video thumbnail during upload */
.message-attachment-video {
  position: relative;
  cursor: pointer;
  border-radius: 12px;
  overflow: hidden;
  background: var(--bg-tertiary);
}

.message-attachment-video video {
  width: 100%;
  max-width: 320px;
  max-height: 240px;
  object-fit: cover;
  display: block;
  border-radius: 12px;
}

.message-attachment-video .message-attachment-play {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 48px;
  height: 48px;
  background: rgba(0, 0, 0, 0.6);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 18px;
  transition: transform 0.2s ease, background 0.2s ease;
}

.message-attachment-video:hover .message-attachment-play {
  background: rgba(0, 0, 0, 0.8);
  transform: translate(-50%, -50%) scale(1.1);
}

.video-placeholder {
  width: 200px;
  height: 150px;
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
}

.video-placeholder i {
  font-size: 40px;
  color: var(--text-muted);
}

/* Video duration badge */
.message-attachment-video .video-duration {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
}

/* Toast animations for attachment errors */
@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

@keyframes toastOut {
  from {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
  to {
    opacity: 0;
    transform: translateX(-50%) translateY(20px);
  }
}

/* Video loading and error states */
.video-loading-container {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 300px;
  width: 100%;
}

.video-loading-container video {
  max-width: 90vw;
  max-height: 80vh;
  border-radius: 12px;
  background: #000;
}

.video-loading-spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  z-index: 10;
  pointer-events: none;
}

.video-loading-spinner i {
  font-size: 48px;
  color: var(--accent-primary);
  animation: spin 1s linear infinite;
}

.video-loading-spinner .loading-text {
  color: rgba(255, 255, 255, 0.8);
  font-size: 14px;
  font-weight: 500;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.video-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 48px;
  color: #fff;
  text-align: center;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 16px;
  backdrop-filter: blur(10px);
  max-width: 360px;
  margin: 0 auto;
}

.video-error i {
  font-size: 56px;
  color: #ef4444;
  background: rgba(239, 68, 68, 0.15);
  width: 96px;
  height: 96px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.video-error p {
  font-size: 16px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.95);
  line-height: 1.5;
}

.video-error .btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--accent-primary);
  color: #fff;
  padding: 12px 24px;
  border-radius: 12px;
  border: none;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.video-error .btn:hover {
  background: #1d4ed8;
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.4);
}

/* Video Player Container */
.video-player-container {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 90vw;
  background: #000;
  border-radius: 12px;
  overflow: hidden;
}

.video-player-container video {
  width: 100%;
  max-height: 80vh;
  display: block;
}

.video-loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.video-loading-overlay.active {
  display: flex;
}

.video-spinner {
  font-size: 48px;
  color: white;
  opacity: 0.9;
}

.video-spinner i {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.video-player-controls {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.8) 0%, rgba(0,0,0,0.4) 70%, transparent 100%);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.video-player-container:hover .video-player-controls {
  opacity: 1;
}

.video-play-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(10px);
  border: none;
  color: #fff;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

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

/* Video progress wrapper with buffer bar */
.video-progress-wrapper {
  flex: 1;
  height: 6px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 3px;
  cursor: pointer;
  position: relative;
  min-width: 100px;
}

.video-buffer-bar {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background: rgba(255, 255, 255, 0.4);
  border-radius: 3px;
  width: 0%;
  transition: width 0.3s ease;
  z-index: 1;
}

.video-progress-bar {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
}

.video-progress-filled {
  height: 100%;
  background: var(--accent-primary);
  border-radius: 3px;
  width: 0%;
  position: relative;
}

.video-progress-handle {
  position: absolute;
  left: 0%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 12px;
  height: 12px;
  background: #fff;
  border-radius: 50%;
  opacity: 0;
  transition: opacity 0.2s ease, left 0.1s linear;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  pointer-events: none;
  z-index: 5;
}

.video-progress-wrapper:hover .video-progress-handle {
  opacity: 1;
}

.video-progress-wrapper:hover {
  height: 8px;
}

.video-time {
  font-size: 12px;
  color: #fff;
  font-weight: 500;
  white-space: nowrap;
}

.video-download-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(10px);
  border: none;
  color: #fff;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.video-download-btn:hover {
  background: var(--accent-primary);
  transform: scale(1.1);
}

.media-viewer-download {
  position: absolute;
  top: 80px;
  right: 24px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(10px);
  border: none;
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  z-index: 10;
}

.media-viewer-download:hover {
  background: var(--accent-primary);
  transform: scale(1.1);
}

/* Media gallery navigation */
.media-viewer-main {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

.media-nav-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(10px);
  border: none;
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  z-index: 20;
}

.media-nav-btn:hover:not(:disabled) {
  background: var(--accent-primary);
  transform: translateY(-50%) scale(1.1);
}

.media-nav-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.media-nav-prev {
  left: 24px;
}

.media-nav-next {
  right: 24px;
}

.media-counter {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(10px);
  padding: 8px 16px;
  border-radius: 20px;
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  z-index: 20;
}

/* ============ MESSAGE REACTIONS ============ */
.message-reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

.reaction-bubble {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
  font-size: 14px;
}

.reaction-bubble:hover {
  background: var(--bg-glass-light);
  transform: scale(1.05);
}

.reaction-bubble.own {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: white;
}

.reaction-bubble.own:hover {
  background: var(--accent-secondary);
  border-color: var(--accent-secondary);
}

.reaction-emoji {
  font-size: 16px;
  line-height: 1;
}

.reaction-count {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  min-width: 12px;
  text-align: center;
}

.reaction-bubble.own .reaction-count {
  color: white;
}

/* Reactions in outgoing messages - contrasting style */
.message.outgoing .reaction-bubble {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.25);
  backdrop-filter: blur(10px);
}

.message.outgoing .reaction-bubble:hover {
  background: rgba(255, 255, 255, 0.25);
  border-color: rgba(255, 255, 255, 0.35);
}

.message.outgoing .reaction-bubble .reaction-count {
  color: rgba(255, 255, 255, 0.85);
}

.message.outgoing .reaction-bubble.own {
  background: rgba(255, 255, 255, 0.3);
  border-color: rgba(255, 255, 255, 0.45);
}

.message.outgoing .reaction-bubble.own:hover {
  background: rgba(255, 255, 255, 0.4);
  border-color: rgba(255, 255, 255, 0.55);
}

.message.outgoing .reaction-bubble.own .reaction-count {
  color: white;
}

/* Message reactions picker in context menu */
.message-reactions-picker {
  display: flex;
  gap: 4px;
  padding: 8px;
  justify-content: center;
}

.reaction-picker-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  cursor: pointer;
  font-size: 20px;
  transition: all 0.15s ease;
}

.reaction-picker-btn:hover {
  background: var(--bg-glass-light);
  transform: scale(1.1);
}

.reaction-picker-btn.picker-more {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: white;
  font-size: 14px;
}

.reaction-picker-btn.picker-more:hover {
  background: var(--accent-secondary);
  border-color: var(--accent-secondary);
}

/* Emoji Picker Dialog */
.emoji-picker-dialog {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.emoji-picker-dialog.active {
  opacity: 1;
}

.emoji-picker-content {
  background: var(--bg-secondary);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  max-width: 400px;
  width: 90%;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

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

.emoji-picker-header span {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.emoji-picker-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: all 0.15s ease;
}

.emoji-picker-close:hover {
  background: var(--bg-glass-light);
  color: var(--text-primary);
}

.emoji-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
  gap: 4px;
  padding: 16px;
  overflow-y: auto;
  max-height: 60vh;
}

.emoji-picker-item {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-tertiary);
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  font-size: 24px;
  transition: all 0.15s ease;
}

.emoji-picker-item:hover {
  background: var(--bg-glass-light);
  border-color: var(--accent-primary);
  transform: scale(1.1);
}

.emoji-picker-grid::-webkit-scrollbar {
  width: 8px;
}

.emoji-picker-grid::-webkit-scrollbar-track {
  background: transparent;
}

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

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

/* ============ MESSAGE CONTEXT MENU ============ */
.message-context-menu {
  min-width: 180px;
}

/* ============ MESSAGE PIN ICON ============ */
.message-pin-icon {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: var(--accent-primary);
  opacity: 0.8;
}

.message.outgoing .message-pin-icon {
  color: rgba(255, 255, 255, 0.8);
}

.message .message-content {
  position: relative;
}

/* ============ DELETED MESSAGE ============ */
.message.deleted .message-content {
  opacity: 1;
}

.message.deleted .message-text {
  font-style: italic;
  color: var(--text-secondary);
}

.message.outgoing.deleted .message-text {
  color: rgba(255, 255, 255, 0.9);
}

/* ============ MESSAGE HIGHLIGHT (for scroll to) ============ */
.message.highlight .message-content {
  animation: messageHighlight 2s ease-out;
}

@keyframes messageHighlight {
  0% {
    background: rgba(60, 110, 255, 0.3);
    box-shadow: 0 0 20px rgba(60, 110, 255, 0.4);
  }
  100% {
    background: transparent;
    box-shadow: none;
  }
}

/* ============ REPLY PREVIEW ============ */
.reply-preview {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--bg-glass);
  border-left: 3px solid var(--accent-primary);
  border-radius: 0 8px 8px 0;
  margin-bottom: 8px;
  animation: slideUp 0.2s ease-out;
}

.reply-preview-content {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.reply-preview-content i {
  color: var(--accent-primary);
  font-size: 14px;
}

.reply-preview-content span {
  color: var(--text-secondary);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reply-preview-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: all 0.15s ease;
}

.reply-preview-close:hover {
  background: var(--bg-glass-light);
  color: var(--text-primary);
}

/* ============ EDIT PREVIEW ============ */
.edit-preview {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--bg-glass);
  border-left: 3px solid var(--accent-warning);
  border-radius: 0 8px 8px 0;
  margin-bottom: 8px;
  animation: slideUp 0.2s ease-out;
}

.edit-preview-content {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
}

.edit-preview-content i {
  color: var(--accent-warning);
  font-size: 14px;
}

.edit-preview-content span {
  color: var(--text-secondary);
  font-size: 13px;
}

.edit-preview-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: all 0.15s ease;
}

.edit-preview-close:hover {
  background: var(--bg-glass-light);
  color: var(--text-primary);
}

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

/* ============ PINNED MESSAGES BAR ============ */
.pinned-messages-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--bg-glass);
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
  transition: background 0.15s ease;
}

.pinned-messages-bar:hover {
  background: var(--bg-glass-light);
}

.pinned-bar-content {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.pinned-bar-content > i {
  color: var(--accent-primary);
  font-size: 14px;
}

.pinned-bar-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.pinned-bar-label {
  font-size: 12px;
  color: var(--accent-primary);
  font-weight: 600;
}

.pinned-bar-message {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pinned-bar-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 4px;
  transition: all 0.15s ease;
}

.pinned-bar-close:hover {
  background: var(--bg-glass-light);
  color: var(--text-primary);
}

/* ============ FORWARD MESSAGE MODAL ============ */
.forward-preview {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg-glass);
  border-radius: 10px;
  margin-bottom: 16px;
  border-left: 3px solid var(--accent-primary);
}

.forward-preview i {
  color: var(--accent-primary);
  font-size: 14px;
  margin-top: 2px;
}

.forward-preview span {
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.4;
}

.forward-chat-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 300px;
  overflow-y: auto;
}

.forward-chat-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s ease;
}

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

.forward-chat-item .avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bg-glass);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: var(--text-secondary);
}

.forward-chat-name {
  flex: 1;
  font-size: 14px;
  color: var(--text-primary);
}

.forward-chat-item .current-badge {
  font-size: 11px;
  color: var(--accent-primary);
  background: rgba(60, 110, 255, 0.15);
  padding: 3px 8px;
  border-radius: 4px;
}

.forward-chat-item.current {
  background: rgba(60, 110, 255, 0.1);
}

/* ============ MESSAGE MULTI-SELECT ============ */
.messages.selection-mode .message {
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
  position: relative;
  width: 50%;
  max-width: 50%;
}

.messages.selection-mode .message:hover {
  background: rgba(60, 110, 255, 0.05);
}

.messages.selection-mode .message.incoming {
  align-self: flex-start;
  margin-right: auto;
}

.messages.selection-mode .message.outgoing {
  align-self: flex-end;
  margin-left: auto;
}

.message.selected {
  background: rgba(60, 110, 255, 0.15) !important;
}

.message.selected .message-content {
  background: rgba(60, 110, 255, 0.2) !important;
}

.message.outgoing.selected .message-content {
  background: var(--accent-primary) !important;
  border-color: rgba(255, 255, 255, 0.55);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.25);
}

.selection-checkbox {
  position: absolute;
  left: -24px;
  top: 50%;
  transform: translateY(-50%);
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  color: var(--accent-primary);
  font-size: 16px;
  animation: checkIn 0.2s ease-out;
  z-index: 2;
}

.message.outgoing .selection-checkbox {
  left: auto;
  right: -24px;
  border-color: rgba(255, 255, 255, 0.55);
  color: #fff;
}

@keyframes checkIn {
  from {
    opacity: 0;
    transform: translateY(-50%) scale(0.5);
  }
  to {
    opacity: 1;
    transform: translateY(-50%) scale(1);
  }
}

.selection-toolbar {
  position: absolute;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  z-index: 100;
  animation: slideUp 0.2s ease-out;
}

.selection-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

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

.selection-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.selection-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 8px;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.15s ease;
}

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

.selection-btn.danger:hover {
  background: var(--accent-danger);
}

/* ==================== APP LOCK SCREEN ==================== */

.app-container.app-locked {
  filter: blur(20px);
  pointer-events: none;
  user-select: none;
  opacity: 0;
  visibility: hidden;
}

.app-lock-screen {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  max-width: 100vw !important;
  max-height: 100vh !important;
  min-width: 100vw !important;
  min-height: 100vh !important;
  background: var(--bg-primary);
  z-index: 10000 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  animation: lockScreenFadeIn 0.3s ease-out;
  box-sizing: border-box !important;
  overflow: auto !important;
  transform: none !important;
  margin: 0 !important;
  padding: 0 !important;
}

.app-lock-screen.unlocking {
  animation: lockScreenFadeOut 0.3s ease-out forwards;
}

@keyframes lockScreenFadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes lockScreenFadeOut {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

.lock-screen-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 400px;
  width: 100%;
  padding: 40px 24px;
  text-align: center;
  margin: 0 auto;
  box-sizing: border-box;
  background: transparent;
}

.lock-screen-avatar {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(37, 99, 235, 0.3);
}

.lock-screen-name {
  font-size: 24px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.lock-screen-message {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 32px;
  max-width: 320px;
  line-height: 1.5;
}

.lock-screen-pin-container {
  width: 100%;
  max-width: 280px;
  margin-bottom: 24px;
}

.lock-screen-pin-display {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-bottom: 16px;
}

.pin-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  border: 2px solid var(--border-color);
  transition: all 0.15s ease;
}

.pin-dot.filled {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  box-shadow: 0 0 8px rgba(37, 99, 235, 0.4);
}

.lock-screen-pin-input {
  width: 100%;
  padding: 16px;
  font-size: 24px;
  letter-spacing: 8px;
  text-align: center;
  background: var(--bg-secondary);
  border: 2px solid var(--border-color);
  border-radius: 12px;
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.2s ease;
}

.lock-screen-pin-input:focus {
  border-color: var(--accent-primary);
}

.lock-screen-pin-input::placeholder {
  letter-spacing: normal;
  font-size: 14px;
}

.lock-screen-error {
  color: var(--accent-error);
  font-size: 13px;
  margin-top: 12px;
  min-height: 20px;
}

.lock-screen-unlock-btn {
  width: 100%;
  max-width: 280px;
  padding: 14px 24px;
  font-size: 16px;
  margin-bottom: 24px;
}

.lock-screen-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
}

.lock-screen-link {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 14px;
  cursor: pointer;
  padding: 8px 16px;
  transition: color 0.2s ease;
}

.lock-screen-link:hover {
  color: var(--accent-primary);
}

/* Timeout options in settings */
.timeout-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s ease;
  color: var(--text-primary);
}

.timeout-option:hover {
  background: var(--bg-tertiary);
}

.timeout-option.active {
  background: rgba(37, 99, 235, 0.1);
  color: var(--accent-primary);
}

.timeout-option i {
  color: var(--accent-primary);
}

/* PIN input styling for modals */
.pin-input {
  background: var(--bg-secondary);
  border: 2px solid var(--border-color);
  border-radius: 12px;
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.2s ease;
}

.pin-input:focus {
  border-color: var(--accent-primary);
}

/* ==================== PIN MODAL WITH NUMPAD ==================== */

.pin-modal-content {
  max-width: 380px;
  padding: 0;
  background: var(--bg-primary);
  border-radius: 20px;
  position: relative;
  overflow: hidden;
}

.pin-modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 10;
  background: var(--bg-secondary);
  border-radius: 50%;
  width: 36px;
  height: 36px;
}

.pin-modal-body {
  padding: 40px 24px 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.pin-modal-icon {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 24px;
  box-shadow: 0 8px 32px rgba(37, 99, 235, 0.3);
}

.pin-modal-icon i {
  font-size: 28px;
  color: white;
}

.pin-modal-title {
  font-size: 22px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 8px;
}

.pin-modal-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin: 0 0 28px;
  text-align: center;
}

.pin-error {
  color: var(--accent-error);
  font-size: 13px;
  min-height: 20px;
  margin-bottom: 20px;
  text-align: center;
}

/* PC Lock Screen Styles */
.lock-screen-pc .lock-screen-pin-container {
  max-width: 320px;
}

.lock-screen-pc .pin-input-wrapper {
  position: relative;
}

.lock-screen-pc .lock-pin-input {
  width: 100%;
  padding: 16px 20px;
  font-size: 24px;
  text-align: center;
  letter-spacing: 12px;
  background: var(--bg-secondary);
  border: 2px solid var(--border-color);
  border-radius: 12px;
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.lock-screen-pc .lock-pin-input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

.lock-screen-pc .lock-pin-input::placeholder {
  letter-spacing: 8px;
  font-size: 18px;
  color: var(--text-muted);
}

/* PC PIN Modal Styles */
.pin-modal-pc .pin-input-wrapper {
  margin-bottom: 8px;
}

.pin-modal-pc .pin-text-input,
.pin-text-input {
  width: 100%;
  padding: 16px 20px;
  font-size: 24px;
  text-align: center;
  letter-spacing: 12px;
  background: var(--bg-tertiary);
  border: 2px solid var(--border-color);
  border-radius: 12px;
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.pin-modal-pc .pin-text-input:focus,
.pin-text-input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

.pin-modal-pc .pin-text-input::placeholder,
.pin-text-input::placeholder {
  letter-spacing: 8px;
  font-size: 18px;
  color: var(--text-muted);
}

.btn-danger {
  background: linear-gradient(135deg, var(--accent-error), #dc2626);
  color: #fff;
  border: none;
}

.btn-danger:hover {
  background: linear-gradient(135deg, #dc2626, #b91c1c);
}

.app-lock-screen .lock-screen-error {
  color: var(--accent-error);
  font-size: 13px;
  min-height: 20px;
  margin-bottom: 20px;
  text-align: center;
}

/* Mobile responsive for lock screen */
@media (max-width: 768px) {
  .app-lock-screen {
    padding: 0 !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    transform: none !important;
  }
  
  .app-lock-screen .lock-screen-content {
    max-width: 100% !important;
    width: 100% !important;
    height: 100% !important;
    padding: 20px 16px !important;
    margin: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    transform: none !important;
    background: transparent !important;
  }
  
  .lock-screen-avatar {
    width: 80px;
    height: 80px;
    margin-bottom: 12px;
  }
  
  .lock-screen-avatar span {
    font-size: 28px !important;
  }
  
  .lock-screen-name {
    font-size: 20px;
  }
  
  .lock-screen-message {
    font-size: 14px;
    margin-bottom: 24px;
    text-align: center;
  }
  
  .lock-screen-actions {
    flex-direction: column;
    gap: 8px;
  }
  
  .lock-screen-pin-container {
    margin-bottom: 12px;
  }
}

/* PIN modal mobile responsive */
@media (max-width: 768px) {
  .pin-modal-content {
    max-width: 100%;
    margin: 16px;
    border-radius: 16px;
  }
  
  .pin-modal-body {
    padding: 32px 16px 24px;
  }
  
  .pin-modal-icon {
    width: 56px;
    height: 56px;
    margin-bottom: 16px;
  }
  
  .pin-modal-icon i {
    font-size: 22px;
  }
  
  .pin-modal-title {
    font-size: 18px;
  }
  
  .pin-modal-subtitle {
    font-size: 13px;
    margin-bottom: 20px;
  }
}

/* ==================== MOBILE PIN SCREEN WITH NUMPAD ==================== */

/* PIN Dots Container */
.pin-dots {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-bottom: 16px;
}

.pin-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  border: 2px solid rgba(255, 255, 255, 0.4);
  transition: all 0.2s ease;
}

.pin-dot.filled {
  background: #fff;
  border-color: #fff;
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.5);
}

/* Numpad Styles */
.pin-numpad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  width: 100%;
  max-width: 280px;
  margin: 0 auto;
}

.pin-key {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  font-size: 28px;
  font-weight: 500;
  color: #fff;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.pin-key:hover {
  background: rgba(255, 255, 255, 0.2);
}

.pin-key:active {
  transform: scale(0.92);
  background: rgba(255, 255, 255, 0.3);
}

.pin-key-empty {
  background: transparent;
  border: none;
  cursor: default;
  pointer-events: none;
}

.pin-key-back {
  font-size: 22px;
  color: rgba(255, 255, 255, 0.8);
}

.pin-key-back:hover {
  color: #fff;
}

/* Mobile PIN Modal */
.pin-modal-mobile {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  min-width: 100vw !important;
  min-height: 100vh !important;
  transform: none !important;
  margin: 0 !important;
  padding: 0 !important;
  z-index: 10001 !important;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%) !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

.pin-modal-mobile .pin-modal-content {
  background: transparent !important;
  max-width: 100% !important;
  width: 100% !important;
  height: 100% !important;
  max-height: 100% !important;
  border-radius: 0 !important;
  margin: 0 !important;
  display: flex !important;
  flex-direction: column !important;
  transform: none !important;
  position: relative !important;
}

.pin-modal-mobile .pin-modal-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  width: 100%;
  box-sizing: border-box;
}

.pin-modal-mobile .pin-modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  z-index: 10;
}

.pin-modal-mobile .pin-modal-icon {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea, #764ba2);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 24px;
  box-shadow: 0 8px 32px rgba(102, 126, 234, 0.4);
}

.pin-modal-mobile .pin-modal-icon i {
  font-size: 32px;
  color: #fff;
}

.pin-modal-mobile .pin-modal-title {
  font-size: 24px;
  font-weight: 600;
  color: #fff;
  margin: 0 0 8px;
  text-align: center;
}

.pin-modal-mobile .pin-modal-subtitle {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.7);
  margin: 0 0 32px;
  text-align: center;
}

.pin-modal-mobile .pin-error {
  color: #ff6b6b;
  font-size: 13px;
  min-height: 20px;
  margin-bottom: 24px;
  text-align: center;
}

/* Mobile Lock Screen */
.app-lock-screen.lock-screen-mobile {
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%) !important;
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  min-width: 100vw !important;
  min-height: 100vh !important;
  transform: none !important;
  margin: 0 !important;
  padding: 0 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

.lock-screen-mobile .lock-screen-content {
  padding: 40px 24px !important;
  width: 100% !important;
  max-width: none !important;
  height: 100% !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
  transform: none !important;
  margin: 0 !important;
  box-sizing: border-box !important;
  background: transparent !important;
}

.lock-screen-mobile .lock-screen-avatar {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea, #764ba2);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  box-shadow: 0 8px 32px rgba(102, 126, 234, 0.3);
  overflow: hidden;
}

.lock-screen-mobile .lock-screen-name {
  font-size: 22px;
  font-weight: 600;
  color: #fff;
  margin-bottom: 4px;
}

.lock-screen-mobile .lock-screen-message {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.6);
  margin-bottom: 32px;
}

.lock-screen-mobile .lock-screen-error {
  color: #ff6b6b;
  font-size: 13px;
  min-height: 20px;
  margin-bottom: 16px;
  text-align: center;
}

.lock-screen-mobile .lock-screen-actions {
  margin-top: 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.lock-screen-mobile .lock-screen-link {
  color: rgba(255, 255, 255, 0.6);
  font-size: 14px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px 16px;
  transition: color 0.2s;
}

.lock-screen-mobile .lock-screen-link:hover {
  color: #fff;
}

/* Shake animation */
@keyframes pinShake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-10px); }
  40%, 80% { transform: translateX(10px); }
}

.pin-dots.shake {
  animation: pinShake 0.4s ease-in-out;
}

/* Mobile responsive adjustments */
@media (max-width: 768px) {
  .pin-numpad {
    gap: 12px;
    max-width: 260px;
  }
  
  .pin-key {
    width: 64px;
    height: 64px;
    font-size: 24px;
  }
  
  .pin-dot {
    width: 14px;
    height: 14px;
  }
}

@media (max-height: 700px) {
  .pin-modal-mobile .pin-modal-body {
    padding: 24px 20px;
    justify-content: flex-start;
    padding-top: 60px;
  }
  
  .pin-modal-mobile .pin-modal-icon {
    width: 64px;
    height: 64px;
    margin-bottom: 16px;
  }
  
  .pin-modal-mobile .pin-modal-icon i {
    font-size: 26px;
  }
  
  .pin-modal-mobile .pin-modal-title {
    font-size: 20px;
  }
  
  .pin-modal-mobile .pin-modal-subtitle {
    margin-bottom: 20px;
  }
  
  .pin-numpad {
    gap: 10px;
  }
  
  .pin-key {
    width: 58px;
    height: 58px;
    font-size: 22px;
  }
  
  .lock-screen-mobile .lock-screen-content {
    padding-top: 40px;
    justify-content: flex-start;
  }
  
  .lock-screen-mobile .lock-screen-avatar {
    width: 80px;
    height: 80px;
  }
}
