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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: #1a1a1a;
  height: 100vh;
  height: 100dvh; /* Динамические viewport единицы для iOS */
  overflow: hidden;
  color: #ffffff;
  font-weight: 400;
  line-height: 1.4;
  -webkit-appearance: none;
  -webkit-user-select: none;
  /* Дополнительные iOS стабилизирующие свойства */
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* Предотвращение bouncing на iOS */
  overscroll-behavior-y: none;
}

html {
  height: 100vh;
  height: 100dvh; /* Динамические viewport единицы для iOS */
  /* Принудительная установка скролла в начало для iOS */
  scroll-behavior: auto;
  /* Дополнительная стабилизация для iOS */
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
}

@media (max-width: 768px) {
  html {
    height: 100%;
    height: 100dvh; /* Использование динамических viewport единиц для iOS */
    overflow: hidden;
  }

  body {
    width: 100%;
    height: 100%;
    height: 100dvh; /* Динамические viewport единицы более стабильны на iOS */
    overflow: hidden;
    position: relative; /* Менее агрессивное позиционирование */
    /* Дополнительные стили для iOS Safari */
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: none;
    /* Стабильное позиционирование без !important */
    margin: 0;
    padding: 0;
  }
}

@supports(padding: max(0px)) {
  /* Правильная обработка safe area для iOS */
  .main-app {
      padding-left: max(0px, env(safe-area-inset-left));
      padding-right: max(0px, env(safe-area-inset-right));
      /* ВАЖНО: Возвращаем top padding для правильного позиционирования в safe zone */
      padding-top: max(0px, env(safe-area-inset-top));
      /* Оставляем bottom без padding для правильной работы с клавиатурой */
  }

  /* Убираем дублирование margin для app-container */
  .app-container {
      /* margin убираем так как padding уже в main-app */
  }

  .sidebar-header,
  .chat-header,
  .settings-header {
      /* Убираем лишние отступы для выравнивания sidebar и chat-area */
      padding-top: 8px;
  }

  .chat-input {
      padding-bottom: max(16px, env(safe-area-inset-bottom) + 16px);
      /* Возвращаем нормальные отступы для home indicator */
      margin-bottom: max(0px, env(safe-area-inset-bottom));
  }

  /* Убираем лишние margin, так как safe area уже учтена в main-app */
  .chat-messages,
  .chats-list {
      /* margin убираем для стабильности */
  }

  @media (max-width: 768px) {
    .chat-input {
        padding-bottom: max(20px, env(safe-area-inset-bottom) + 20px);
        /* Возвращаем нормальные отступы */
    }

    .chat-messages {
        /* Уменьшаем высоту области сообщений чтобы всё поместилось */
        height: calc(100vh - 140px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
        max-height: calc(100vh - 140px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    }

    .sidebar {
        /* Поднимаем sidebar выше на мобильных */
        margin-top: calc(-1 * max(0px, env(safe-area-inset-top)));
        padding-top: max(8px, env(safe-area-inset-top) + 8px);
    }

    .main-app {
        height: 100%;
        height: 100svh; /* Small viewport height - стабильная высота при работе с клавиатурой */
        min-height: 100%;
        /* Удаляем -webkit-fill-available для стабильности */

        /* Специальная обработка для iOS клавиатуры */
        /* При открытии клавиатуры viewport изменяется только снизу */
        position: relative;
        overflow: hidden;
    }

    /* Обеспечиваем что контент адаптируется к изменению viewport ТОЛЬКО снизу */
    .app-container {
        height: 100%;
        max-height: 100%;
        overflow: hidden;
        /* Контейнер адаптируется к изменению высоты viewport */
        position: relative;
    }
  }
}

/* Экран авторизации */
.auth-screen {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  background: #1a1a1a;
  padding: 20px;
  position: relative;
  overflow: hidden;
}

.auth-form {
  background: rgba(35, 35, 35, 0.98);
  padding: 40px;
  border-radius: 32px;
  width: 100%;
  max-width: 400px;
  text-align: center;
  border: none;
}

.auth-form h2 {
  margin-bottom: 32px;
  color: #ffffff;
  font-size: 24px;
  font-weight: 600;
}

.auth-form input {
  width: 100%;
  padding: 14px 16px;
  margin-bottom: 16px;
  border: none;
  border-radius: 20px;
  font-size: 16px;
  transition: all 0.2s ease;
  background: rgba(25, 25, 25, 0.9);
  color: #ffffff;
}

.auth-form input:focus {
  outline: none;
  background: rgba(30, 30, 30, 1);
  transform: scale(1.01);
  transition: all 0.3s ease;
}

.auth-form input::placeholder {
  color: #999999;
}

.auth-form button {
  width: 100%;
  padding: 14px;
  margin-bottom: 16px;
  border: none;
  border-radius: 20px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

#authBtn {
  background: linear-gradient(135deg, #8b45ff 0%, #b565ff 100%);
  color: #ffffff;
  position: relative;
  overflow: hidden;
  transition: all 0.2s ease;
}

#authBtn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: left 0.6s ease;
}

#authBtn:hover {
  background: linear-gradient(135deg, #9555ff 0%, #c575ff 100%);
  transform: translateY(-2px) scale(1.02);
}

#authBtn:hover::before {
  left: 100%;
}

#authBtn:active {
  transform: translateY(-1px) scale(0.98);
  transition: all 0.1s ease;
}

.switch-btn {
  background: rgba(40, 40, 40, 0.6);
  color: #ffffff;
  border: none !important;
  position: relative;
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.switch-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(139, 69, 255, 0.1), transparent);
  transition: left 0.5s ease;
}

.switch-btn:hover {
  background: rgba(50, 50, 50, 0.8);
  transform: scale(1.01);
}

.switch-btn:hover::before {
  left: 100%;
}

.switch-btn:active {
  transform: translateY(0) scale(0.98);
  transition: all 0.1s ease;
}

.error {
  padding: 12px 16px;
  margin-bottom: 16px;
  border-radius: 20px;
  font-size: 14px;
  text-align: center;
  background: rgba(220, 38, 38, 0.15);
  border: none;
  color: #ff6b6b;
}

/* Основное приложение */
.main-app {
  display: none;
  height: 100vh;
  background: #1a1a1a;
}

.app-container {
  display: flex;
  height: 100%;
  max-width: 1400px;
  margin: 0 auto;
  background: #1a1a1a;
}

/* Левая панель */
.sidebar {
  width: 380px;
  background: rgba(35, 35, 35, 0.98);
  border-right: none;
  display: flex;
  flex-direction: column;
  min-width: 320px;
}

.sidebar-header {
  padding: 20px;
  background: rgba(40, 40, 40, 0.98);
  border-bottom: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.user-avatar-container {
  position: relative;
  flex-shrink: 0;
}

.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  display: none;
}

.user-avatar.show {
  display: block;
}

.user-avatar.default {
  background: #555555;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: #ffffff;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.user-avatar:hover,
.user-avatar.default:hover {
  border-color: #8b45ff;
  transform: scale(1.05);
}

.chat-avatar-container {
  cursor: pointer;
  transition: all 0.2s ease;
}

.chat-avatar-container:hover {
  transform: scale(1.05);
}

.chat-avatar-container .chat-avatar {
  transition: all 0.3s ease;
}

.chat-avatar-container:hover .chat-avatar {
  border-color: #8b45ff;
}

.user-avatar-container {
  cursor: pointer;
  transition: transform 0.2s ease;
}

.user-avatar-container:hover {
  transform: scale(1.05);
}

.sidebar-header h3 {
  color: #ffffff;
  font-size: 20px;
  font-weight: 600;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-buttons {
  display: flex;
  gap: 8px;
}

.profile-btn {
  background: linear-gradient(135deg, #8b45ff 0%, #b565ff 100%);
  color: #ffffff;
  border: none;
  padding: 8px 12px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
}

.profile-btn img {
  width: 18px;
  height: 18px;
  filter: brightness(0) invert(1);
}

.profile-btn:hover {
  background: linear-gradient(135deg, #9555ff 0%, #c575ff 100%);
  transform: translateY(-2px) rotate(5deg);
}

.profile-btn:active {
  transform: translateY(-1px) rotate(0deg) scale(0.95);
  transition: all 0.1s ease;
}

.search-container {
  padding: 16px 20px;
  background: rgba(30, 30, 30, 0.9);
}

.search-container input {
  width: 100%;
  padding: 12px 20px;
  border: none;
  border-radius: 50px;
  font-size: 15px;
  background: rgba(25, 25, 25, 0.9);
  color: #ffffff;
  transition: all 0.2s ease;
}

.search-container input:focus {
  outline: none;
  background: rgba(30, 30, 30, 1);
  transform: scale(1.01);
  transition: all 0.3s ease;
}

.search-container input::placeholder {
  color: #999999;
}

.chats-list {
  flex: 1;
  overflow-y: auto;
  background: rgba(30, 30, 30, 0.9);
}

.chat-item {
  padding: 12px 20px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: none;
}

.chat-item:hover {
  background: rgba(50, 50, 50, 0.4);
}

.chat-item.active {
  background: #8b45ff;
  color: #ffffff;
}

.chat-item.active .username {
  color: rgba(255, 255, 255, 0.9);
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.3);
}

.chat-item.active .user-status-text {
  color: rgba(255, 255, 255, 0.8);
}

.chat-item.active .last-message {
  color: rgba(255, 255, 255, 0.8);
}

.chat-item.active .chat-name strong {
  color: #ffffff;
}

/* Аватарки в списке чатов с индикатором статуса */
.chat-item-avatar-container {
  position: relative;
  flex-shrink: 0;
}

.chat-item-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: none;
  transition: all 0.2s ease;
}

.chat-item.active .chat-item-avatar {
  border-color: rgba(255, 255, 255, 0.6);
}

.chat-item-avatar.default {
  background: #555555;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: #ffffff;
  font-weight: 500;
}

/* Индикатор статуса на аватарке - ЗЕЛЕНЫЙ для онлайна */
.avatar-status-indicator {
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #666666;
  border: 2px solid rgba(35, 35, 35, 0.98);
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  transform: scale(0);
  opacity: 0;
}

.avatar-status-indicator.online {
  background: #00ff88;
  transform: scale(1);
  opacity: 1;
}

.chat-item.active .avatar-status-indicator {
  border-color: #8b45ff;
}

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

.chat-name {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.chat-name strong {
  font-size: 16px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 1;
  min-width: 0;
  color: #ffffff;
}

.username {
  font-size: 12px;
  color: #bbbbbb;
  font-weight: 400;
  white-space: nowrap;
  flex-shrink: 0;
  background: rgba(45, 45, 45, 0.9);
  padding: 2px 6px;
  border-radius: 6px;
  font-family: 'SF Mono', 'Monaco', monospace;
  border: none;
  transition: all 0.2s ease;
}

.user-status-text {
  font-size: 13px;
  color: #aaaaaa;
  font-weight: 400;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.last-message {
  font-size: 13px;
  color: #aaaaaa;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

/* Правая панель - чат */
.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #1a1a1a;
}

/* Контейнер для индикаторов над сообщениями */
.chat-indicators {
  background: rgba(40, 40, 40, 0.98);
  border-bottom: none;
  flex-shrink: 0;
}

.chat-header {
  display: none;
  padding: 20px;
  background: rgba(40, 40, 40, 0.98);
  border-bottom: none;
  justify-content: space-between;
  align-items: center;
}

.chat-header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.chat-header-right {
  display: flex;
  gap: 8px;
  align-items: center;
}

.back-btn {
  background: linear-gradient(135deg, #8b45ff 0%, #b565ff 100%);
  border: none;
  cursor: pointer;
  color: #ffffff;
  display: none;
  padding: 8px;
  border-radius: 50%;
  transition: all 0.2s ease;
  font-weight: 500;
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
}

.back-btn img {
  width: 18px;
  height: 18px;
  filter: brightness(0) invert(1);
}

.back-btn:hover {
  background: linear-gradient(135deg, #9555ff 0%, #c575ff 100%);
  transform: translateY(-2px) translateX(-2px);
}

.back-btn:active {
  transform: translateY(-1px) translateX(-1px) scale(0.95);
  transition: all 0.1s ease;
}

/* Аватарка в заголовке чата без индикатора статуса */
.chat-avatar-container {
  flex-shrink: 0;
}

.chat-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  border: none;
}

.chat-avatar.default {
  background: #555555;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: #ffffff;
  font-weight: 500;
}

.chat-title-container {
  flex: 1;
  min-width: 0;
}

/* Стили для заголовка чата БЕЗ АНИМАЦИИ */
.chat-title-name .gradient-name,
.chat-title-name .gradient-tag {
  /* Без анимации */
}

.chat-title {
  font-size: 18px;
  font-weight: 600;
  color: #ffffff;
  display: block;
}

.chat-messages {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  background: #1a1a1a;
}

.no-chat {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100%;
  color: #aaaaaa;
  font-size: 16px;
  text-align: center;
  font-weight: 400;
}

.message {
  max-width: 70%;
  margin-bottom: 12px;
  animation: messageSlide 0.3s ease;
  float: left;
  clear: both;
  position: relative;
  cursor: pointer;
  transition: all 0.2s ease;
}

.message:hover .message-content {
  background: rgba(50, 50, 50, 0.8);
  transform: translateY(-1px);
  transition: all 0.2s ease;
}

.message:active .message-content {
  transform: translateY(0) scale(0.99);
  transition: all 0.1s ease;
}

.message.deleting {
  animation: messageDelete 0.5s ease forwards;
}

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

@keyframes messageDelete {
  from {
      opacity: 1;
      transform: scale(1);
  }
  to {
      opacity: 0;
      transform: scale(0.95);
  }
}

.message.own {
  float: right;
}

.message-content {
  background: rgba(40, 40, 40, 0.95);
  padding: 12px 16px;
  border-radius: 24px;
  position: relative;
  color: #ffffff;
  word-wrap: break-word;
  border: none;
}

/* Умные скругления как в Telegram для входящих сообщений */
.message:not(.own) .message-content {
  border-bottom-left-radius: 8px;
}

/* Умные скругления как в Telegram для исходящих сообщений */
.message.own .message-content {
  background: #8b45ff;
  color: #ffffff;
  border: none;
  border-bottom-right-radius: 8px;
}

.message-wrapper {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 8px;
  min-height: auto;
}

.message-text {
  font-size: 15px;
  line-height: 1.4;
  word-wrap: break-word;
  flex: 1;
}

.message-info {
  font-size: 11px;
  opacity: 0.7;
  white-space: nowrap;
  flex-shrink: 0;
  align-self: flex-end;
  font-weight: 400;
}

.message-wrapper.multiline {
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.message-wrapper.multiline .message-info {
  align-self: flex-end;
}

/* Контекстное меню сообщений */
.message-context-menu {
  position: fixed;
  background: rgba(40, 40, 40, 0.98);
  border: none;
  border-radius: 20px;
  padding: 8px 0;
  z-index: 1000;
  min-width: 140px;
  display: none;
}

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

.menu-item img {
  width: 16px;
  height: 16px;
  filter: brightness(0) invert(1);
}

.menu-item:hover {
  background: rgba(60, 60, 60, 0.5);
}

.menu-item:first-child {
  margin-top: 0;
}

.menu-item:last-child {
  margin-bottom: 0;
}

.menu-item.destructive {
  color: #ff6b6b;
}

.menu-item.destructive:hover {
  background: rgba(220, 38, 38, 0.2);
}

.menu-item.destructive img {
  filter: brightness(0) saturate(100%) invert(27%) sepia(51%) saturate(2878%) hue-rotate(346deg) brightness(104%) contrast(97%);
}

/* Стили для ответа на сообщение */
.message-reply {
  border-left: 3px solid #8b45ff;
  padding-left: 12px;
  margin-bottom: 8px;
  background: rgba(139, 69, 255, 0.1);
  border-radius: 12px;
  padding: 8px 12px;
}

/* Белые рамки для ответов в собственных сообщениях */
.message.own .message-reply {
  border-left: 3px solid rgba(255, 255, 255, 0.8);
  background: rgba(255, 255, 255, 0.1);
}

.message.own .reply-author {
  color: rgba(255, 255, 255, 0.9);
}

.reply-author {
  font-size: 12px;
  color: #8b45ff;
  font-weight: 500;
  margin-bottom: 4px;
}

.reply-text {
  font-size: 13px;
  color: #cccccc;
  opacity: 0.8;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Индикатор редактирования */
.message-edited {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.7);
  font-style: italic;
  margin-left: 8px;
  opacity: 0.7;
}

/* Стили для области ответа - теперь над чатом */
.reply-preview {
  background: rgba(139, 69, 255, 0.1);
  border-left: 3px solid #8b45ff;
  padding: 8px 12px;
  margin: 8px 16px;
  border-radius: 12px;
  display: none;
  position: relative;
  border-top: 1px solid rgba(139, 69, 255, 0.3);
}

/* Стили для индикатора редактирования - теперь над чатом */
.editing-indicator {
  background: rgba(255, 193, 7, 0.1);
  border-left: 3px solid #ffc107;
  padding: 8px 12px;
  margin: 8px 16px;
  border-radius: 6px;
  display: none;
  position: relative;
  align-items: center;
  justify-content: space-between;
  color: #ffc107;
  font-size: 13px;
  font-weight: 500;
  border-top: 1px solid rgba(255, 193, 7, 0.3);
}

.cancel-edit-btn {
  background: linear-gradient(135deg, rgba(255, 193, 7, 0.2) 0%, rgba(255, 193, 7, 0.3) 100%);
  border: 1px solid rgba(255, 193, 7, 0.4);
  color: #ffc107;
  cursor: pointer;
  font-size: 14px;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  padding: 0;
  margin-left: 8px;
  font-weight: 600;
}

.cancel-edit-btn:hover {
  background: linear-gradient(135deg, rgba(255, 193, 7, 0.3) 0%, rgba(255, 193, 7, 0.4) 100%);
  transform: scale(1.2) rotate(90deg);
}

.cancel-edit-btn:active {
  transform: scale(1.1) rotate(90deg);
  transition: all 0.1s ease;
}

.reply-preview-author {
  font-size: 12px;
  color: #8b45ff;
  font-weight: 500;
  margin-bottom: 4px;
}

.reply-preview-text {
  font-size: 13px;
  color: #cccccc;
  opacity: 0.8;
}

.cancel-reply {
  position: absolute;
  top: 8px;
  right: 8px;
  background: linear-gradient(135deg, rgba(136, 136, 136, 0.2) 0%, rgba(136, 136, 136, 0.3) 100%);
  border: 1px solid rgba(136, 136, 136, 0.3);
  color: #aaaaaa;
  cursor: pointer;
  font-size: 16px;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  font-weight: 600;
}

.cancel-reply:hover {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.15) 0%, rgba(255, 255, 255, 0.25) 100%);
  color: #ffffff;
  transform: scale(1.2) rotate(90deg);
}

.cancel-reply:active {
  transform: scale(1.1) rotate(90deg);
  transition: all 0.1s ease;
}

/* Стили для input области */
.chat-input {
  display: none;
  padding: 16px 20px;
  background: rgba(40, 40, 40, 0.98);
  border-top: none;
  flex-shrink: 0;
}

.input-container {
  display: flex;
  align-items: stretch;
  gap: 12px;
  width: 100%;
  max-width: 100%;
}

.input-container input {
  flex: 1;
  padding: 12px 16px;
  border: none;
  border-radius: 24px;
  font-size: 15px;
  resize: none;
  transition: all 0.2s ease;
  background: rgba(25, 25, 25, 0.9);
  color: #ffffff;
  min-height: 44px;
  height: auto;
  max-height: 120px;
  overflow-y: auto;
  line-height: 1.4;
  font-family: inherit;
}

.input-container input:focus {
  outline: none;
  background: rgba(30, 30, 30, 1);
  transform: scale(1.01);
  transition: all 0.3s ease;
}

.input-container input::placeholder {
  color: #999999;
}

.send-btn {
  background: linear-gradient(135deg, #8b45ff 0%, #b565ff 100%);
  color: #ffffff;
  border: none;
  padding: 0;
  border-radius: 50%;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  transition: all 0.2s ease;
  white-space: nowrap;
  flex-shrink: 0;
  align-self: flex-end;
  width: 44px;
  height: 44px;
  min-height: 44px;
  min-width: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.send-btn img {
  width: 20px;
  height: 20px;
  filter: brightness(0) invert(1);
  image-rendering: auto;
  image-rendering: -webkit-optimize-contrast;
  -ms-interpolation-mode: bicubic;
  object-fit: contain;
}

.send-btn:hover {
  background: linear-gradient(135deg, #9555ff 0%, #c575ff 100%);
  transform: translateY(-2px) scale(1.05);
}

.send-btn:active {
  transform: translateY(-1px) scale(1.02);
  transition: all 0.1s ease;
}

/* Стили для кнопки вложений */
.attach-btn {
  background: linear-gradient(135deg, #8b45ff 0%, #b565ff 100%);
  color: #ffffff;
  border: none;
  padding: 0;
  border-radius: 50%;
  cursor: pointer;
  font-size: 20px;
  transition: all 0.2s ease;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  min-height: 44px;
  min-width: 44px;
}

.attach-btn:hover {
  background: linear-gradient(135deg, #9555ff 0%, #c575ff 100%);
  transform: translateY(-2px) scale(1.05);
}

.attach-btn:active {
  transform: translateY(-1px) scale(1.02);
  transition: all 0.1s ease;
}

.attach-btn img {
  width: 20px;
  height: 20px;
  filter: brightness(0) invert(1);
}

/* Стили для превью вложения - над панелью ввода */
.attachment-preview {
  padding: 12px 16px;
  margin: 0 20px 12px 20px;
  background: rgba(40, 40, 40, 0.98);
  border: none;
  border-radius: 20px;
  position: relative;
}

.attachment-preview-content {
  display: flex;
  align-items: center;
  gap: 10px;
}

.attachment-preview-icon {
  font-size: 20px;
  color: #8b45ff;
}

.attachment-preview-name {
  flex: 1;
  color: #ffffff;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-preview-size {
  color: #999999;
  font-size: 12px;
  flex-shrink: 0;
}

.attachment-preview-remove {
  background: rgba(255, 70, 70, 0.2);
  color: #ff4646;
  border: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 600;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.attachment-preview-remove:hover {
  background: rgba(255, 70, 70, 0.4);
  transform: scale(1.1);
}

/* Стили для отображения вложений в сообщениях - над текстом */
.message-attachment {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  margin-bottom: 8px;
  background: rgba(139, 69, 255, 0.15);
  border: 1px solid rgba(139, 69, 255, 0.3);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  max-width: 100%;
  overflow: hidden;
}

.message-attachment:hover {
  background: rgba(139, 69, 255, 0.25);
  border-color: rgba(139, 69, 255, 0.5);
  transform: translateY(-2px);
}

/* Белая граница слева для вложений в собственных сообщениях */
.message.own .message-attachment {
  border-left: 3px solid rgba(255, 255, 255, 0.8);
  background: rgba(255, 255, 255, 0.1);
}

.message-attachment-icon {
  font-size: 24px;
  flex-shrink: 0;
}

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

.message-attachment-name {
  color: #ffffff;
  font-size: 14px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: block;
}

.message-attachment-size {
  color: #999999;
  font-size: 12px;
  margin-top: 2px;
}

.message-attachment-download {
  color: #8b45ff;
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
}

/* Стили для медиа-предпросмотра в сообщениях */
.message-media {
  position: relative;
  margin-bottom: 8px;
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  max-width: 100%;
  background: rgba(0, 0, 0, 0.2);
}

.message-media-image {
  max-width: 300px;
  transition: transform 0.2s ease;
}

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

.message-media-video {
  max-width: 300px;
  transition: transform 0.2s ease;
}

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

.media-preview-image {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 12px;
  max-height: 400px;
  object-fit: cover;
}

.media-preview-video {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 12px;
  max-height: 300px;
  object-fit: cover;
  pointer-events: none;
}

.media-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: all 0.2s ease;
  border-radius: 12px;
}

.message-media:hover .media-overlay {
  background: rgba(0, 0, 0, 0.3);
  opacity: 1;
}

.media-overlay-icon {
  font-size: 48px;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
}

/* Стили для аудио предпросмотра */
.message-media-audio {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  background: rgba(139, 69, 255, 0.15);
  border: 1px solid rgba(139, 69, 255, 0.3);
  border-radius: 12px;
  max-width: 350px;
}

.message.own .message-media-audio {
  border-left: 3px solid rgba(255, 255, 255, 0.8);
  background: rgba(255, 255, 255, 0.1);
}

.audio-preview-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.audio-preview-icon {
  font-size: 24px;
  flex-shrink: 0;
}

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

.audio-preview-name {
  color: #ffffff;
  font-size: 14px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.audio-preview-size {
  color: #999999;
  font-size: 12px;
  margin-top: 2px;
}

.audio-preview-player {
  width: 100%;
  height: 32px;
  border-radius: 8px;
  outline: none;
}

.audio-preview-player::-webkit-media-controls-panel {
  background: rgba(139, 69, 255, 0.2);
  border-radius: 8px;
}

/* Стили для модального окна медиа */
.media-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10000;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

.media-modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.95);
  backdrop-filter: blur(10px);
}

.media-modal-content {
  position: relative;
  z-index: 10001;
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: scaleIn 0.3s ease;
}

.modal-media-image {
  max-width: 100%;
  max-height: 90vh;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.modal-media-video {
  max-width: 100%;
  max-height: 90vh;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.modal-media-audio {
  width: 400px;
  max-width: 90vw;
  padding: 20px;
  background: rgba(35, 35, 35, 0.98);
  border-radius: 20px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.media-modal-close {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 10002;
  width: 48px;
  height: 48px;
  border: none;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  color: #ffffff;
  font-size: 32px;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  padding: 0;
}

.media-modal-close:hover {
  background: rgba(255, 70, 70, 0.3);
  transform: scale(1.1);
}

.media-modal-close:active {
  transform: scale(0.95);
}

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

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.8);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Мобильные адаптации для медиа */
@media (max-width: 768px) {
  .message-media-image,
  .message-media-video {
    max-width: 250px;
  }

  .media-preview-image,
  .media-preview-video {
    max-height: 300px;
  }

  .media-overlay-icon {
    font-size: 36px;
  }

  .media-modal-close {
    top: 10px;
    right: 10px;
    width: 40px;
    height: 40px;
    font-size: 28px;
  }

  .modal-media-audio {
    width: 90vw;
  }
}

/* Стили для экрана настроек */
.settings-area {
  flex: 1;
  display: none;
  flex-direction: column;
  background: #1a1a1a;
}

.settings-area.active {
  display: flex;
}

.settings-header {
  padding: 20px;
  background: rgba(40, 40, 40, 0.98);
  border-bottom: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.settings-header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.settings-title {
  font-size: 18px;
  font-weight: 600;
  color: #ffffff;
}

.settings-content {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.settings-category {
  display: flex;
  align-items: center;
  padding: 16px 20px;
  margin-bottom: 8px;
  background: rgba(35, 35, 35, 0.98);
  border-radius: 16px;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
}

.settings-category:hover {
  background: rgba(50, 50, 50, 0.8);
  transform: translateY(-2px) translateX(4px);
}

.settings-category:active {
  transform: translateY(-1px) translateX(2px) scale(0.98);
  transition: all 0.1s ease;
}

.settings-category[data-category="profile"],
.settings-category[data-category="password"] {
  cursor: pointer;
}

.category-icon {
  font-size: 20px;
  margin-right: 16px;
  width: 32px;
  text-align: center;
  color: #8b45ff;
  display: flex;
  align-items: center;
  justify-content: center;
}

.category-icon img {
  width: 20px;
  height: 20px;
  filter: hue-rotate(240deg) saturate(2) brightness(1.2);
}

.category-info {
  flex: 1;
}

.category-title {
  font-size: 16px;
  font-weight: 600;
  color: #ffffff;
  margin-bottom: 2px;
}

.category-description {
  font-size: 14px;
  color: #aaaaaa;
  line-height: 1.3;
}

.category-arrow {
  font-size: 16px;
  color: #8b45ff;
  font-weight: normal;
}

.settings-bottom {
  margin-top: auto;
  padding-top: 20px;
}

.settings-credits {
  text-align: center;
  padding: 16px;
  margin-bottom: 20px;
}

.logout-btn {
  width: 100%;
  background: transparent;
  color: #dc2626;
  border: 2px solid rgba(220, 38, 38, 0.5);
  padding: 14px;
  border-radius: 16px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-bottom: max(10px, env(safe-area-inset-bottom) + 10px);
}

.logout-btn:hover {
  background: rgba(220, 38, 38, 0.1);
  border-color: rgba(220, 38, 38, 0.6);
  transform: translateY(-2px);
}

.logout-btn:active {
  transform: translateY(-1px) scale(0.98);
  transition: all 0.1s ease;
}

.credits-title {
  font-size: 12px;
  color: #aaaaaa;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 500;
}

.credits-names {
  font-size: 14px;
  color: #ffffff;
  font-weight: 600;
}

/* Модальные окна */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
  background: rgba(0, 0, 0, 0.5);
  animation: modalFadeIn 0.3s ease-out;
  padding: 0;
}

@keyframes modalFadeIn {
  from {
    opacity: 0;
    backdrop-filter: blur(0px);
  }
  to {
    opacity: 1;
    backdrop-filter: blur(4px);
  }
}

.modal-content {
  background: rgba(35, 35, 35, 0.98);
  border-radius: 24px !important;
  width: 100%;
  max-width: 500px;
  max-height: 80vh;
  overflow-y: auto;
  border: none;
  margin: 0;
  animation: modalContentSlideIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-content h3 {
  font-size: 20px;
  font-weight: 600;
  color: #ffffff;
  margin-bottom: 8px;
}

.modal-content p {
  color: rgba(255, 255, 255, 0.7);
  margin-bottom: 20px;
  font-size: 14px;
}

.modal-content input[type="text"] {
  width: 100%;
  padding: 12px;
  background: rgba(25, 25, 25, 0.8);
  border: none;
  border-radius: 16px;
  color: #ffffff;
  font-size: 16px;
  margin-bottom: 12px;
  transition: all 0.2s ease;
}

.modal-content input[type="text"]:focus {
  outline: none;
  background: rgba(30, 30, 30, 1);
}

@keyframes modalContentSlideIn {
  from {
    opacity: 0;
    transform: translateY(-30px) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal-header {
  padding: 20px;
  border-bottom: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-buttons {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.modal-buttons button {
  flex: 1;
}

.modal-buttons button.secondary {
  background: rgba(60, 60, 60, 0.5);
  border: none;
}

.modal-buttons button.secondary:hover {
  background: rgba(70, 70, 70, 0.6);
  transform: translateY(-1px);
}

.modal-buttons button.secondary:active {
  transform: translateY(0) scale(0.98);
  transition: all 0.1s ease;
}

/* Стили для кнопок регистрационного ключа */
#regKeySubmit {
  background: linear-gradient(135deg, #8b45ff 0%, #b565ff 100%);
  color: #ffffff;
  border: none;
  padding: 14px;
  border-radius: 16px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

#regKeySubmit:hover {
  background: linear-gradient(135deg, #9555ff 0%, #c575ff 100%);
  transform: translateY(-2px);
}

#regKeySubmit:active {
  transform: translateY(-1px) scale(0.98);
  transition: all 0.1s ease;
}

#regKeyCancel {
  background: rgba(60, 60, 60, 0.5);
  color: #ffffff;
  border: none;
  padding: 14px;
  border-radius: 16px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

#regKeyCancel:hover {
  background: rgba(70, 70, 70, 0.6);
  transform: translateY(-1px);
}

#regKeyCancel:active {
  transform: translateY(0) scale(0.98);
  transition: all 0.1s ease;
}

.modal-header h3 {
  font-size: 18px;
  font-weight: 600;
  color: #ffffff;
}

.close-btn {
  background: linear-gradient(135deg, #8b45ff 0%, #b565ff 100%);
  border: none;
  cursor: pointer;
  color: #ffffff;
  padding: 6px;
  border-radius: 50%;
  transition: all 0.2s ease;
  font-weight: 500;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.close-btn img {
  width: 16px;
  height: 16px;
  filter: brightness(0) invert(1);
}

.close-btn:hover {
  background: linear-gradient(135deg, #9555ff 0%, #c575ff 100%);
  transform: translateY(-1px) rotate(90deg);
}

.close-btn:active {
  transform: translateY(0) rotate(90deg) scale(0.9);
  transition: all 0.1s ease;
}

.profile-info {
  padding: 0;
  margin: 0;
  overflow: hidden;
  background: rgba(35, 35, 35, 0.98);
}

/* Главная секция профиля - оригинальная структура с анимациями */
.profile-main-section {
  display: flex;
  align-items: flex-start;
  padding: 24px;
  background: rgba(35, 35, 35, 0.98);
  position: relative;
  overflow: hidden;
  animation: sectionSlideIn 0.8s ease-out;
}

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

.profile-avatar-container {
  flex-shrink: 0;
  margin-right: 20px;
  position: relative;
  animation: avatarBounce 1s ease-out 0.3s both;
}

@keyframes avatarBounce {
  0% {
    opacity: 0;
    transform: scale(0.3) rotate(-180deg);
  }
  50% {
    transform: scale(1.1) rotate(-10deg);
  }
  100% {
    opacity: 1;
    transform: scale(1) rotate(0deg);
  }
}

.profile-avatar {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(80, 80, 80, 0.6);
}

.profile-avatar.default {
  background: #555555;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
  color: #ffffff;
  font-weight: 600;
}

/* Основная информация профиля */
.profile-main-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  animation: infoFadeIn 1s ease-out 0.5s both;
}

@keyframes infoFadeIn {
  from {
    opacity: 0;
    transform: translateX(30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.profile-top-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 12px;
}

.profile-name-container {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.profile-display-name {
  font-size: 28px;
  font-weight: 700;
  color: #ffffff;
  word-wrap: break-word;
  line-height: 1.2;
  margin: 0;
}

.profile-status-container {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  text-align: right;
}

.profile-status-text {
  font-size: 16px;
  color: #cccccc;
  margin: 0;
  font-weight: 400;
  letter-spacing: 0.5px;
}

.profile-description {
  font-size: 15px;
  color: #ffffff;
  line-height: 1.5;
  word-wrap: break-word;
  margin: 16px 0 0 0;
  max-width: 100%;
  animation: descriptionSlide 1s ease-out 0.7s both;
  position: relative;
}

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

/* Секция дополнительной информации - карточки с анимациями */
.profile-details-section {
  background: rgba(0, 0, 0, 0);
  padding: 24px;
}

.profile-detail-item {
  display: flex;
  align-items: center;
  padding: 18px 20px;
  margin-bottom: 12px;
  background: rgba(50, 50, 50, 0.9);
  border-radius: 16px;
  border: none;
  transition: background 0.2s ease;
}

.profile-detail-item:last-child {
  margin-bottom: 0;
}

.profile-detail-item:hover {
  background: rgba(60, 60, 60, 0.9);
}

.profile-detail-icon {
  width: 28px;
  height: 28px;
  margin-right: 18px;
  flex-shrink: 0;
  font-size: 18px;
  color: #8b45ff;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(139, 69, 255, 0.15);
  border-radius: 8px;
}

.profile-detail-content {
  flex: 1;
  min-width: 0;
  width: 100%;
  position: relative;
}

.profile-detail-label {
  font-size: 12px;
  color: #999999;
  margin-bottom: 4px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.profile-detail-value {
  font-size: 16px;
  color: #ffffff;
  font-weight: 500;
  word-wrap: break-word;
  font-family: 'SF Mono', 'Monaco', monospace;
  width: 100%;
}

.profile-username-display {
  font-size: 16px;
  color: #ffffff;
  font-weight: 600;
  font-family: 'SF Mono', 'Monaco', monospace;
  width: 100%;
  display: block;
}

.profile-registered-date {
  font-size: 16px;
  color: #ffffff;
  font-weight: 500;
  width: 100%;
  display: block;
}

.settings-form {
  padding: 20px;
}

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

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
  color: #ffffff;
  font-size: 14px;
}

.form-group input,
.form-group textarea {
  width: 100%;
  padding: 12px 16px;
  border: none;
  border-radius: 16px;
  font-size: 15px;
  transition: all 0.2s ease;
  font-family: inherit;
  background: rgba(25, 25, 25, 0.9);
  color: #ffffff;
}

.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  background: rgba(30, 30, 30, 1);
  box-shadow: 0 0 0 2px rgba(139, 69, 255, 0.3);
  transform: scale(1.01);
  transition: all 0.3s ease;
}

.form-group input::placeholder,
.form-group textarea::placeholder {
  color: #999999;
}

.form-group textarea {
  resize: vertical;
  min-height: 80px;
  line-height: 1.4;
}

/* Новые стили для подсказок */
.input-hint {
  font-size: 12px;
  color: #aaaaaa;
  margin-top: 12px;
  line-height: 1.3;
}

.character-count {
  text-align: right;
  font-family: 'SF Mono', 'Monaco', monospace;
}

.character-count.warning {
  color: #ff9500;
}

.character-count.danger {
  color: #ff3b30;
}

/* Стили для аватарки в настройках */
.avatar-group {
  margin-bottom: 30px;
}

.avatar-upload-container {
  display: flex;
  justify-content: center;
  position: relative;
  cursor: pointer;
}

.avatar-preview {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid rgba(80, 80, 80, 0.6);
  transition: filter 0.2s ease;
}

.avatar-preview.default {
  background: #555555;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  color: #ffffff;
  font-weight: 500;
}

.avatar-overlay {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: rgba(139, 69, 255, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s ease;
  color: #ffffff;
  font-size: 12px;
  font-weight: 500;
  text-align: center;
  padding: 8px;
}

.avatar-upload-container:hover .avatar-overlay {
  opacity: 0.85;
}

.avatar-upload-container:hover .avatar-preview {
  filter: brightness(0.5);
}

.save-btn {
  width: 100%;
  background: linear-gradient(135deg, #8b45ff 0%, #b565ff 100%);
  color: #ffffff;
  border: 1px solid #8b45ff;
  padding: 14px;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.save-btn:hover {
  background: linear-gradient(135deg, #9555ff 0%, #c575ff 100%);
  transform: translateY(-2px);
}

.save-btn:active {
  transform: translateY(-1px) scale(0.98);
  transition: all 0.1s ease;
}

/* Стили для градиентных элементов */
.gradient-picker-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.gradient-colors {
  display: flex;
  gap: 12px;
  align-items: flex-end;
}

.gradient-color-input {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.gradient-color-input label {
  font-size: 12px;
  color: #95A5A6;
  margin: 0;
}

.gradient-color-input input[type="color"] {
  width: 100%;
  height: 40px;
  border: 2px solid #3a3a3a;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  transition: all 0.2s ease;
}

.gradient-color-input input[type="color"]:hover {
  border-color: #8b45ff;
}

.gradient-preview {
  background: linear-gradient(90deg, #8b45ff 0%, #b565ff 50%, #ff45b5 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-size: 18px;
  font-weight: 600;
  text-align: center;
  padding: 12px;
  border: 2px solid #3a3a3a;
  border-radius: 8px;
  min-height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  box-sizing: border-box;
}

/* Специфичные стили для превью градиента имени */
#nameGradientPreview {
  /* Точное соответствие реальным градиентным именам */
  color: transparent !important;
  background-size: 100% 100% !important;
  background-position: center !important;
  -webkit-background-clip: text !important;
  -webkit-text-fill-color: transparent !important;
  background-clip: text !important;
  white-space: nowrap;
  overflow: hidden;
}

#nameGradientPreview.gradient-name {
  /* Убеждаемся что градиент применяется правильно */
  -webkit-background-clip: text !important;
  -webkit-text-fill-color: transparent !important;
  background-clip: text !important;
  color: transparent !important;
  background-size: 100% 100% !important;
}

/* Превью градиента тега в настройках - точная копия реального тега */
#tagGradientPreview {
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #ffffff !important;
  -webkit-text-fill-color: #ffffff !important;
  background-clip: padding-box !important;
  -webkit-background-clip: padding-box !important;
  font-size: 12px !important;
  padding: 3px 8px !important;
  border-radius: 6px !important;
}

/* Стили для тегов в списке чатов */
.chat-tag {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  background: linear-gradient(90deg, #8b45ff 0%, #b565ff 50%, #ff45b5 100%);
  color: #ffffff;
  margin-left: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: inline-block;
  vertical-align: middle;
}

/* Градиентные теги с равномерным распределением цветов без анимации */
.gradient-tag {
  color: #ffffff !important;
  -webkit-text-fill-color: #ffffff !important;
  background-clip: padding-box !important;
  -webkit-background-clip: padding-box !important;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Стили для градиентных имен с равномерным распределением цветов без анимации */
.gradient-name {
  -webkit-background-clip: text !important;
  -webkit-text-fill-color: transparent !important;
  background-clip: text !important;
  font-weight: 600;
}

/* Обновляем отображение чатов */
.chat-name {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

/* Стили для мобильных устройств */
@media (max-width: 768px) {
  .gradient-colors {
    flex-direction: row;
    gap: 10px;
    justify-content: space-between;
  }

  .gradient-color-input {
    flex: 1;
    min-width: 0;
  }

  .gradient-color-input label {
    font-size: 11px;
    margin-bottom: 4px;
  }

  .gradient-color-input input[type="color"] {
    height: 44px;
    width: 100%;
  }

  .gradient-preview {
    font-size: 16px;
    padding: 12px;
  }
}

/* Мобильная адаптация */
@media (max-width: 768px) {
  .app-container {
      position: relative;
  }

  .sidebar {
      width: 100%;
      min-width: 100%;
  }

  .chat-area {
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      background: #1a1a1a;
      transform: translateX(100%);
      transition: transform 0.3s ease;
  }

  .chat-area.active {
      transform: translateX(0);
  }

  .settings-area {
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      background: #1a1a1a;
      transform: translateX(100%);
      transition: transform 0.3s ease;
      display: flex;
  }

  .settings-area.active {
      transform: translateX(0);
      display: flex;
  }

  .back-btn {
      display: flex !important;
      /* ИСПРАВЛЕНО: Круглая кнопка как на desktop */
      width: 36px;
      height: 36px;
      min-width: 36px;
      min-height: 36px;
      border-radius: 50% !important;
      padding: 0 !important;
      align-items: center;
      justify-content: center;
  }

  .sidebar-header {
      padding: 8px 20px 16px 20px;
      /* Уменьшаем верхний padding чтобы поднять sidebar выше */
  }

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

  .user-info {
      gap: 10px;
  }

  .user-avatar {
      width: 36px;
      height: 36px;
  }

  .user-avatar.default {
      font-size: 16px;
  }

  .chat-item {
      padding: 14px 20px;
      gap: 12px;
  }

  .chat-item-avatar {
      width: 44px;
      height: 44px;
  }

  .avatar-status-indicator {
      width: 12px;
      height: 12px;
      bottom: 2px;
      right: 2px;
  }

  .chat-avatar {
      width: 42px;
      height: 42px;
  }

  .search-container {
      padding: 16px 20px;
  }

  .chat-header {
      padding: 16px 20px;
  }

  .chat-header-left {
      gap: 12px;
  }

  .chat-title {
      font-size: 16px;
  }

  .chat-messages {
      padding: 16px 20px;
  }

  .message {
      max-width: 82%;
  }

  /* ИСПРАВЛЕНО: Безопасная зона для панели ввода на iPhone */
  .chat-input {
      padding: 16px 20px;
      /* Увеличиваем нижний отступ для компенсации скругленных граней iPhone */
      padding-bottom: max(20px, env(safe-area-inset-bottom) + 16px) !important;
      position: relative;
      flex-shrink: 0;
  }

  .input-container {
      gap: 10px;
      align-items: center;
  }

  .input-container input {
      padding: 12px 16px;
      font-size: 16px;
      min-height: 44px;
      /* ИСПРАВЛЕНО: Круглый input как на desktop */
      border-radius: 24px !important;
  }

  /* ИСПРАВЛЕНО: Круглые кнопки как на desktop */
  .send-btn {
      width: 44px;
      height: 44px;
      min-width: 44px;
      min-height: 44px;
      padding: 0 !important;
      border-radius: 50% !important;
      font-size: 14px;
  }

  .attach-btn {
      width: 44px;
      height: 44px;
      min-width: 44px;
      min-height: 44px;
      padding: 0 !important;
      border-radius: 50% !important;
  }

  /* ИСПРАВЛЕНО: Безопасная зона для модальных окон */
  .modal-content {
      width: calc(100% - 40px) !important;
      margin: 20px !important;
      max-height: calc(100vh - 40px) !important;
      border-radius: 24px !important;
      border: 1px solid rgba(80, 80, 80, 0.6);
  }

  /* ИСПРАВЛЕНО: Правильные отступы для модальных окон */
  .modal-header, .profile-info, .settings-form {
      padding: 20px !important;
  }

  .profile-main-section {
      padding: 24px 20px !important;
      flex-direction: column;
      align-items: center;
      text-align: center;
  }

  .profile-avatar-container {
      margin-right: 0;
      margin-bottom: 16px;
  }

  .profile-avatar {
      width: 90px;
      height: 90px;
  }

  .profile-avatar.default {
      font-size: 36px;
  }

  .profile-main-info {
      width: 100%;
      text-align: center;
  }

  .profile-top-info {
      flex-direction: column;
      align-items: center;
      gap: 8px;
  }

  .profile-name-container {
      justify-content: center;
  }

  .profile-display-name {
      font-size: 22px;
  }

  .profile-status-container {
      align-items: center;
      text-align: center;
  }

  .profile-status-text {
      font-size: 14px;
  }

  .profile-description {
      font-size: 14px;
      text-align: center;
      margin-top: 12px;
  }

  .profile-details-section {
      padding: 20px !important;
  }

  .profile-detail-item {
      padding: 16px 18px;
      margin-bottom: 10px;
      /* ИСПРАВЛЕНО: Скругление как на desktop */
      border-radius: 16px !important;
  }

  .profile-detail-icon {
      width: 24px;
      height: 24px;
      margin-right: 16px;
      margin-left: 0;
  }

  .profile-detail-label {
      font-size: 11px;
  }

  .profile-detail-value,
  .profile-username-display,
  .profile-registered-date {
      font-size: 15px;
  }

  .avatar-preview {
      width: 80px;
      height: 80px;
  }

  .avatar-overlay {
      width: 80px;
      height: 80px;
  }

  .auth-screen {
      padding: 20px 16px;
  }

  .auth-form {
      max-width: 350px;
      padding: 30px;
      /* ИСПРАВЛЕНО: Скругление как на desktop */
      border-radius: 32px !important;
  }

  .auth-form h2 {
      font-size: 22px;
      margin-bottom: 24px;
  }

  .auth-form input {
      padding: 12px 14px;
      font-size: 16px;
      margin-bottom: 14px;
      /* ИСПРАВЛЕНО: Скругление как на desktop */
      border-radius: 20px !important;
  }

  .auth-form button {
      padding: 12px;
      font-size: 15px;
      margin-bottom: 12px;
      /* ИСПРАВЛЕНО: Скругление как на desktop */
      border-radius: 20px !important;
  }

  .error {
      font-size: 13px;
      padding: 8px 10px;
      margin-bottom: 10px;
      /* ИСПРАВЛЕНО: Скругление как на desktop */
      border-radius: 20px !important;
  }

  .settings-category {
      padding: 14px 16px;
      margin-bottom: 6px;
      /* ИСПРАВЛЕНО: Скругление как на desktop */
      border-radius: 16px !important;
  }

  .category-icon {
      font-size: 18px;
      width: 28px;
      margin-right: 12px;
  }

  .category-icon img {
      width: 16px;
      height: 16px;
  }

  .category-title {
      font-size: 15px;
  }

  .category-description {
      font-size: 13px;
  }

  .logout-btn {
      padding: 12px;
      font-size: 15px;
      margin-bottom: max(26px, env(safe-area-inset-bottom) + 26px);
      /* ИСПРАВЛЕНО: Скругление как на desktop */
      border-radius: 16px !important;
  }

  .settings-credits {
      padding: 12px;
  }

  /* ИСПРАВЛЕНО: Профессиональные настройки - градиентные превью */
  .gradient-preview {
      padding: 12px !important;
      border-radius: 12px !important;
      font-size: 16px !important;
  }

  /* ИСПРАВЛЕНО: Поля ввода в настройках */
  .form-group input,
  .form-group textarea {
      border-radius: 16px !important;
  }

  /* ИСПРАВЛЕНО: Кнопка сохранения настроек */
  .save-btn {
      border-radius: 16px !important;
  }

  /* ИСПРАВЛЕНО: Цветовые пикеры */
  .gradient-color-input input[type="color"] {
      border-radius: 12px !important;
  }
}

/* Десктопные стили - показываем кнопку назад в настройках */
@media (min-width: 769px) {
  .settings-header .back-btn {
      display: flex !important;
  }
}

/* Pro аккаунты - только градиенты без эффектов свечения */
.pro-username {
  font-weight: 600;
  position: relative;
  display: inline-block;
}

.pro-username.custom-color {
  /* Кастомный цвет будет установлен через JavaScript */
}

.pro-username:not(.custom-color) {
  background: linear-gradient(45deg, #8b45ff, #e645ff, #45b7ff, #45ffb7, #b7ff45, #ffb745, #ff4545, #8b45ff);
  background-size: 800% 800%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: proGradient 4s ease-in-out infinite;
}

@keyframes proGradient {
  0%, 100% {
      background-position: 0% 50%;
  }
  25% {
      background-position: 100% 0%;
  }
  50% {
      background-position: 100% 100%;
  }
  75% {
      background-position: 0% 100%;
  }
}

/* Эффект переливания для кастомных цветов - только градиент без эффектов */
.pro-username.custom-color {
  background: linear-gradient(45deg, currentColor, color-mix(in srgb, currentColor 70%, white 30%), currentColor, color-mix(in srgb, currentColor 60%, white 40%), currentColor);
  background-size: 400% 400%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: customColorGradient 3s ease-in-out infinite;
}

@keyframes customColorGradient {
  0%, 100% {
      background-position: 0% 50%;
  }
  25% {
      background-position: 100% 0%;
  }
  50% {
      background-position: 100% 100%;
  }
  75% {
      background-position: 0% 100%;
  }
}

@keyframes shine {
  0% {
      transform: translateX(-100%) skewX(-15deg);
  }
  100% {
      transform: translateX(200%) skewX(-15deg);
  }
}

/* Настройки активности - минималистичный дизайн без теней */
.activity-setting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  margin-bottom: 12px;
  background: rgba(40, 40, 40, 0.8);
  border-radius: 12px;
  border: 1px solid rgba(60, 60, 60, 0.4);
  transition: all 0.2s ease;
}

.activity-setting:hover {
  background: rgba(50, 50, 50, 0.9);
  border-color: rgba(80, 80, 80, 0.6);
}

.activity-setting-info {
  flex: 1;
  margin-right: 16px;
}

.activity-setting-title {
  display: block;
  font-size: 16px;
  font-weight: 600;
  color: #ffffff;
  margin-bottom: 4px;
}

.activity-setting-description {
  font-size: 14px;
  color: #aaaaaa;
  line-height: 1.4;
}

/* Минималистичный переключатель режима призрака */
.ghost-mode-toggle {
  position: relative;
  width: 54px;
  height: 30px;
  background: rgba(55, 55, 55, 0.9);
  border: 1px solid rgba(80, 80, 80, 0.6);
  border-radius: 15px;
  cursor: pointer;
  transition: all 0.3s ease;
  padding: 0;
  flex-shrink: 0;
}

.ghost-mode-toggle:hover {
  border-color: rgba(120, 120, 120, 0.8);
}

.ghost-mode-toggle.active {
  background: #8b45ff;
  border-color: #8b45ff;
}

.toggle-slider {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 24px;
  height: 24px;
  background: #ffffff;
  border-radius: 50%;
  transition: all 0.3s ease;
}

.ghost-mode-toggle.active .toggle-slider {
  transform: translateX(24px);
}

/* Минималистичные настройки кастомного цвета */
.color-picker-container {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.color-picker-container input[type="color"] {
  width: 50px;
  height: 50px;
  border: 2px solid rgba(80, 80, 80, 0.6);
  border-radius: 50%;
  cursor: pointer;
  background: none;
  padding: 0;
  transition: all 0.2s ease;
}

.color-picker-container input[type="color"]:hover {
  border-color: #8b45ff;
}

.color-picker-container input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
  border-radius: 50%;
  overflow: hidden;
}

.color-picker-container input[type="color"]::-webkit-color-swatch {
  border: none;
  border-radius: 50%;
}

.color-preview {
  flex: 1;
  min-width: 120px;
  padding: 10px 14px;
  background: rgba(30, 30, 30, 0.9);
  border: 1px solid rgba(80, 80, 80, 0.6);
  border-radius: 10px;
  text-align: center;
  transition: border-color 0.2s ease;
}

.color-preview:hover {
  border-color: rgba(139, 69, 255, 0.6);
}

.color-preview-text {
  font-weight: 600;
  font-size: 16px;
  background: linear-gradient(45deg, currentColor, color-mix(in srgb, currentColor 70%, white 30%), currentColor, color-mix(in srgb, currentColor 60%, white 40%), currentColor);
  background-size: 400% 400%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: customColorGradient 3s ease-in-out infinite;
}

.reset-color-btn {
  background: rgba(50, 50, 50, 0.9);
  color: #ffffff;
  border: 1px solid rgba(80, 80, 80, 0.6);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.reset-color-btn:hover {
  background: rgba(70, 70, 70, 0.9);
  border-color: rgba(120, 120, 120, 0.8);
}

/* Показываем Pro функции только для Pro пользователей */
.user-is-pro .pro-only {
  display: flex !important;
}

/* Скрываем Pro функции для обычных пользователей */
.pro-only {
  display: none !important;
}

.pro-only {
  display: none !important;
}

.user-is-pro .pro-only {
  display: flex !important;
}

/* Pro тег - базовые стили БЕЗ ТЕНИ */
.pro-tag {
  background: linear-gradient(135deg, #6a36bf 0%, #b565ff 100%);
  color: #ffffff !important;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  vertical-align: middle;
  display: inline-block;
  border-radius: 4px;
  -webkit-text-fill-color: #ffffff !important;
  background-clip: padding-box !important;
  -webkit-background-clip: padding-box !important;
}

/* Pro тег в шапке панели чатов */
.header-pro-tag {
  font-size: 10px;
  padding: 3px 6px;
  margin-left: 6px;
  border-radius: 4px;
}

/* Pro тег в заголовке чата */
.chat-pro-tag {
  font-size: 9px;
  padding: 2px 5px;
  margin-left: 4px;
  border-radius: 3px;
}

/* Pro тег в профиле */
.profile-pro-tag {
  font-size: 12px;
  padding: 3px 8px;
  margin-left: 8px;
  border-radius: 6px;
  display: inline-block;
}

/* Pro тег в сайдбаре */
.sidebar-pro-tag {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: 4px;
  transform: translateY(-1px);
}

/* Pro тег в чате */
.chat-pro-tag {
  font-size: 9px;
  padding: 2px 5px;
  border-radius: 3px;
  margin-left: 4px;
  transform: translateY(-1px);
}

/* Дополнительные стили для очень маленьких экранов */
@media (max-width: 480px) {
  .sidebar-header {
      padding: 14px 18px;
  }

  .sidebar-header h3 {
      font-size: 17px;
  }

  .header-buttons {
      gap: 8px;
  }

  /* ИСПРАВЛЕНО: Круглая кнопка настроек */
  .profile-btn {
      padding: 0 !important;
      font-size: 13px;
      border-radius: 50% !important;
      width: 36px;
      height: 36px;
      min-width: 36px;
      min-height: 36px;
  }

  .profile-btn img {
      width: 18px;
      height: 18px;
  }

  .chat-item {
      padding: 12px 18px;
      gap: 10px;
  }

  .chat-item-avatar {
      width: 40px;
      height: 40px;
  }

  .avatar-status-indicator {
      width: 11px;
      height: 11px;
      bottom: 1px;
      right: 1px;
      border-width: 2px;
  }

  .chat-name strong {
      font-size: 15px;
  }

  .username {
      font-size: 11px;
      padding: 2px 6px;
      border-radius: 6px !important;
  }

  .user-status-text {
      font-size: 12px;
  }

  .last-message {
      font-size: 12px;
  }

  .message-content {
      padding: 11px 14px;
      border-radius: 20px !important;
  }

  /* Скругления для маленьких экранов */
  .message:not(.own) .message-content {
      border-bottom-left-radius: 8px !important;
  }

  .message.own .message-content {
      border-bottom-right-radius: 8px !important;
  }

  .message-text {
      font-size: 14px;
      line-height: 1.4;
  }

  .chat-avatar {
      width: 40px;
      height: 40px;
  }

  .search-container {
      padding: 14px 18px;
  }

  .search-container input {
      border-radius: 50px !important;
  }

  .chat-header {
      padding: 14px 18px;
  }

  .chat-messages {
      padding: 14px 18px;
  }

  /* ИСПРАВЛЕНО: Безопасная зона для маленьких экранов */
  .chat-input {
      padding: 14px 18px;
      padding-bottom: max(18px, env(safe-area-inset-bottom) + 14px) !important;
  }

  .input-container input {
      padding: 11px 15px;
      border-radius: 24px !important;
  }

  /* ИСПРАВЛЕНО: Круглые кнопки */
  .send-btn {
      padding: 0 !important;
      border-radius: 50% !important;
      width: 40px;
      height: 40px;
      min-width: 40px;
      min-height: 40px;
  }

  .attach-btn {
      padding: 0 !important;
      border-radius: 50% !important;
      width: 40px;
      height: 40px;
      min-width: 40px;
      min-height: 40px;
  }

  .auth-screen {
      padding: 16px 12px;
  }

  .auth-form {
      max-width: 300px;
      padding: 24px;
      border-radius: 32px !important;
  }

  .auth-form h2 {
      font-size: 20px;
      margin-bottom: 20px;
  }

  .auth-form input {
      padding: 10px 12px;
      font-size: 15px;
      margin-bottom: 12px;
      border-radius: 20px !important;
  }

  .auth-form button {
      padding: 10px;
      font-size: 14px;
      margin-bottom: 10px;
      border-radius: 20px !important;
  }

  .error {
      font-size: 13px;
      padding: 8px 10px;
      margin-bottom: 10px;
      border-radius: 20px !important;
  }

  .settings-category {
      padding: 12px 14px;
      border-radius: 16px !important;
  }

  .category-icon {
      font-size: 16px;
      width: 24px;
      margin-right: 10px;
  }

  .category-icon img {
      width: 16px;
      height: 16px;
  }

  .category-title {
      font-size: 14px;
  }

  .category-description {
      font-size: 12px;
  }

  .logout-btn {
      padding: 10px;
      font-size: 14px;
      margin-bottom: max(26px, env(safe-area-inset-bottom) + 26px);
      border-radius: 16px !important;
  }

  .credits-title {
      font-size: 11px;
  }

  .credits-names {
      font-size: 12px;
  }

  .profile-main-section {
      padding: 20px !important;
      flex-direction: column;
      align-items: center;
      text-align: center;
  }

  .profile-avatar-container {
      margin-right: 0;
      margin-bottom: 12px;
  }

  .profile-avatar {
      width: 70px;
      height: 70px;
  }

  .profile-avatar.default {
      font-size: 28px;
  }

  .profile-display-name {
      font-size: 18px;
  }

  .profile-status-text {
      font-size: 12px;
  }

  .profile-description {
      font-size: 12px;
      margin-top: 8px;
  }

  .profile-details-section {
      padding: 20px !important;
  }

  .profile-detail-item {
      padding: 14px 16px;
      margin-bottom: 8px;
      border-radius: 16px !important;
  }

  .profile-detail-icon {
      width: 22px;
      height: 22px;
      margin-right: 14px;
      margin-left: 0;
  }

  .profile-detail-label {
      font-size: 10px;
  }

  .profile-detail-value,
  .profile-username-display,
  .profile-registered-date {
      font-size: 14px;
  }

  .avatar-preview {
      width: 70px;
      height: 70px;
  }

  .avatar-overlay {
      width: 70px;
      height: 70px;
      font-size: 11px;
  }

  /* ИСПРАВЛЕНО: Круглые кнопки */
  .back-btn {
      width: 32px;
      height: 32px;
      min-width: 32px;
      min-height: 32px;
      border-radius: 50% !important;
      padding: 0 !important;
  }

  .back-btn img {
      width: 16px;
      height: 16px;
  }

  .close-btn {
      width: 28px;
      height: 28px;
      min-width: 28px;
      min-height: 28px;
      border-radius: 50% !important;
      padding: 0 !important;
  }

  .close-btn img {
      width: 14px;
      height: 14px;
  }
}

/* Стили для скроллбара */
.chats-list::-webkit-scrollbar,
.chat-messages::-webkit-scrollbar,
.settings-content::-webkit-scrollbar,
.modal-content::-webkit-scrollbar {
  width: 6px;
}

.chats-list::-webkit-scrollbar-track,
.chat-messages::-webkit-scrollbar-track,
.settings-content::-webkit-scrollbar-track,
.modal-content::-webkit-scrollbar-track {
  background: rgba(25, 25, 25, 0.5);
}

.chats-list::-webkit-scrollbar-thumb,
.chat-messages::-webkit-scrollbar-thumb,
.settings-content::-webkit-scrollbar-thumb,
.modal-content::-webkit-scrollbar-thumb {
  background: rgba(139, 69, 255, 0.6);
  border-radius: 3px;
}

.chats-list::-webkit-scrollbar-thumb:hover,
.chat-messages::-webkit-scrollbar-thumb:hover,
.settings-content::-webkit-scrollbar-thumb:hover,
.modal-content::-webkit-scrollbar-thumb:hover {
  background: rgba(139, 69, 255, 0.8);
}

/* Стили для улучшения доступности */
@media (prefers-reduced-motion: reduce) {
  * {
      animation-duration: 0.01ms !important;
      animation-iteration-count: 1 !important;
      transition-duration: 0.01ms !important;
  }
}

.loading {
  opacity: 0.6;
  pointer-events: none;
}

.settings-form .error {
  margin-bottom: 16px;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 14px;
  text-align: left;
  background: rgba(220, 38, 38, 0.15);
  border: 1px solid rgba(220, 38, 38, 0.4);
  color: #ff6b6b;
}

/* Улучшенные focus состояния для доступности */
button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid #8b45ff;
  outline-offset: 2px;
}

/* Специальные стили для состояния когда клавиатура открыта на iOS */
body.keyboard-open {
  /* Дополнительная стабилизация когда клавиатура активна */
  position: relative;
  overflow: hidden;
}

body.keyboard-open .main-app {
  /* При открытой клавиатуре - строго контролируем высоту */
  height: 100svh !important; /* Small viewport - не изменяется при открытии клавиатуры */
  max-height: 100svh !important;
  overflow: hidden;
}

/* Дополнительная стабилизация для iOS keyboard handling */
@supports (height: 100svh) {
  @media (max-width: 768px) {
    body.keyboard-open .app-container {
      height: 100% !important;
      max-height: 100% !important;
      overflow: hidden;
    }

    body.keyboard-open .chat-area,
    body.keyboard-open .settings-area {
      height: 100% !important;
      max-height: 100% !important;
    }
  }
}

/* Минималистичное модальное окно для регистрационного ключа */
#regKeyModal .modal-content {
  background: rgba(35, 35, 35, 0.98);
  border-radius: 24px !important;
  padding: 24px;
  border: none;
  max-width: 450px;
}

#regKeyModal .modal-content h3 {
  font-size: 22px;
  font-weight: 600;
  color: #ffffff;
  margin: 0 0 8px 0;
  text-align: left;
}

#regKeyModal .modal-content > p {
  margin: 0 0 20px 0;
  color: rgba(255, 255, 255, 0.7);
  font-size: 14px;
  line-height: 1.5;
  text-align: left;
}

#regKeyModal .modal-content .error {
  margin-bottom: 16px;
}

#regKeyModal .modal-content input[type="text"] {
  width: 100%;
  padding: 14px 16px;
  background: rgba(25, 25, 25, 0.9);
  border: none;
  border-radius: 20px;
  color: #ffffff;
  font-size: 16px;
  transition: all 0.2s ease;
  margin-bottom: 20px;
}

#regKeyModal .modal-content input[type="text"]:focus {
  outline: none;
  background: rgba(30, 30, 30, 1);
  transform: scale(1.01);
  transition: all 0.3s ease;
}

#regKeyModal .modal-buttons {
  display: flex;
  gap: 12px;
  margin: 0;
}

#regKeyModal .modal-buttons button {
  flex: 1;
  padding: 14px;
  border-radius: 20px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

#regKeySubmit {
  background: linear-gradient(135deg, #8b45ff 0%, #b565ff 100%);
  color: #ffffff;
  border: none;
}

#regKeySubmit:hover {
  background: linear-gradient(135deg, #9555ff 0%, #c575ff 100%);
  transform: translateY(-2px) scale(1.02);
}

#regKeySubmit:active {
  transform: translateY(-1px) scale(0.98);
  transition: all 0.1s ease;
}

#regKeyCancel {
  background: rgba(60, 60, 60, 0.5);
  color: #ffffff;
  border: none;
}

#regKeyCancel:hover {
  background: rgba(70, 70, 70, 0.6);
  transform: translateY(-1px);
}

#regKeyCancel:active {
  transform: translateY(0) scale(0.98);
  transition: all 0.1s ease;
}

/* Стили для модального окна ошибок */
.error-modal-content {
  background: rgba(35, 35, 35, 0.98) !important;
  border-radius: 24px !important;
  padding: 32px 28px 24px !important;
  border: none !important;
  max-width: 450px !important;
  text-align: left !important;
  animation: errorModalSlideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

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

.error-modal-icon {
  display: none !important;
}

.error-modal-content h3 {
  font-size: 20px !important;
  font-weight: 600 !important;
  color: #ffffff !important;
  margin: 0 0 8px 0 !important;
  text-align: left !important;
  letter-spacing: -0.5px !important;
  display: block !important;
}

.error-modal-content p {
  margin: 12px 0 24px 0 !important; /* Adjusted margin */
  color: rgba(255, 255, 255, 0.65) !important;
  font-size: 14px !important; /* Reduced size */
  line-height: 1.7 !important;
  text-align: left !important; /* Aligned left */
  max-width: 400px !important;
}

.error-modal-content .modal-buttons {
  display: flex !important;
  gap: 12px !important;
  margin: 0 !important;
  justify-content: flex-start !important; /* Aligned left */
}

.error-modal-content .modal-buttons button {
  min-width: 120px !important; /* Adjusted width */
  padding: 12px 20px !important; /* Adjusted padding */
  border-radius: 16px !important;
  font-size: 15px !important; /* Adjusted size */
  font-weight: 600 !important;
  cursor: pointer !important;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1) !important;
  border: none !important;
}

#errorModalOk,
#callErrorModalOk {
  background: linear-gradient(135deg, #8b45ff 0%, #b565ff 100%) !important;
  color: #ffffff !important;
  box-shadow: 0 4px 16px rgba(139, 69, 255, 0.35) !important;
}

#errorModalOk:hover,
#callErrorModalOk:hover {
  background: linear-gradient(135deg, #9555ff 0%, #c575ff 100%) !important;
  transform: translateY(-2px) !important;
  box-shadow: 0 6px 20px rgba(139, 69, 255, 0.45) !important;
}

#errorModalOk:active,
#callErrorModalOk:active {
  transform: translateY(0) !important;
  box-shadow: 0 2px 8px rgba(139, 69, 255, 0.3) !important;
  transition: all 0.1s ease !important;
}

.chat-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-right: 8px;
}

.call-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: linear-gradient(135deg, #8b45ff 0%, #b565ff 100%);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  padding: 0;
}

.call-btn:hover {
  background: linear-gradient(135deg, #9555ff 0%, #c575ff 100%);
  transform: translateY(-2px) scale(1.05);
}

.call-btn:active {
  transform: translateY(-1px) scale(1.02);
  transition: all 0.1s ease;
}

.call-btn img {
  width: 18px;
  height: 18px;
  filter: brightness(0) invert(1);
}

.call-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #000000;
  z-index: 10000;
  animation: fadeIn 0.3s ease;
}

.call-modal.active {
  display: flex;
  align-items: center;
  justify-content: center;
}

.call-container {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.call-videos {
  position: relative;
  width: 100%;
  height: 100%;
  background: #000000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.remote-video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #1a1a1a;
  cursor: pointer;
}

.local-video {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 240px;
  height: 180px;
  object-fit: cover;
  border-radius: 16px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  background: #2a2a2a;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  z-index: 10;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.local-video.viewer-mode {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.8);
}

@media (max-width: 768px) {
  .remote-video {
    object-fit: contain;
  }
  
  .local-video {
    width: 120px;
    height: 90px;
    top: 20px;
    right: 12px;
    border-radius: 12px;
  }
}

@media (max-width: 768px) and (orientation: landscape) {
  .local-video {
    width: 120px;
    height: 90px;
    top: 16px;
    right: 16px;
  }
  
  .remote-video {
    object-fit: contain;
  }
}

@media (max-width: 768px) and (orientation: portrait) {
  .local-video {
    width: 90px;
    height: 120px;
    top: 16px;
    right: 12px;
  }
  
  .remote-video {
    object-fit: contain;
  }
}

.call-info {
  position: absolute;
  top: 20px;
  left: 20px;
  right: 20px;
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  z-index: 10;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.call-info.viewer-mode {
  opacity: 0;
  pointer-events: none;
  transform: translateY(-20px);
}

.call-info-content {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.call-status {
  color: rgba(255, 255, 255, 0.9);
  font-size: 14px;
  font-weight: 500;
  background: rgba(0, 0, 0, 0.6);
  padding: 8px 16px;
  border-radius: 20px;
  backdrop-filter: blur(10px);
}

.call-username {
  color: #ffffff;
  font-size: 20px;
  font-weight: 600;
  background: rgba(0, 0, 0, 0.6);
  padding: 8px 16px;
  border-radius: 20px;
  backdrop-filter: blur(10px);
}

.call-timer {
  color: rgba(255, 255, 255, 0.7);
  font-size: 16px;
  font-weight: 500;
  background: rgba(0, 0, 0, 0.6);
  padding: 8px 16px;
  border-radius: 20px;
  backdrop-filter: blur(10px);
  font-variant-numeric: tabular-nums;
}

.call-controls-panel {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: transparent;
  padding: 30px 20px;
  z-index: 10;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.call-controls-panel.viewer-mode {
  opacity: 0;
  pointer-events: none;
  transform: translateY(20px);
}

.call-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  max-width: 100%;
  margin: 0 auto;
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: visible;
  padding: 0 10px;
}

@media (max-width: 768px) {
  .call-info {
    top: 12px;
    left: 12px;
    gap: 6px;
  }
  
  .call-status {
    font-size: 12px;
    padding: 6px 12px;
  }
  
  .call-username {
    font-size: 16px;
    padding: 6px 12px;
  }
  
  .call-timer {
    font-size: 14px;
    padding: 6px 12px;
  }
  
  .call-controls {
    bottom: 30px;
    gap: 16px;
  }
}

@media (max-width: 768px) and (orientation: landscape) {
  .call-info {
    top: 10px;
    left: 10px;
  }
  
  .call-controls {
    bottom: 20px;
    gap: 12px;
  }
}

.control-btn {
  border: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.2s ease;
  background: transparent;
  color: #ffffff;
  padding: 0;
}

.control-btn svg {
  width: 48px;
  height: 48px;
  padding: 13px;
  border-radius: 65%;
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(10px);
  transition: all 0.2s ease;
}

.control-btn:hover svg {
  transform: scale(1.1);
  background: rgba(255, 255, 255, 0.25);
}

.control-btn:active svg {
  transform: scale(0.95);
}

.control-label {
  font-size: 12px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.9);
  white-space: nowrap;
}

.mic-btn.muted svg {
  background: rgba(255, 59, 48, 0.8);
}

.camera-btn.disabled svg {
  background: rgba(255, 59, 48, 0.8);
}

.screen-share-btn.sharing svg {
  background: rgba(52, 199, 89, 0.8);
}

.end-call-btn svg {
  background: rgba(255, 59, 48, 0.9);
  width: 54px;
  height: 54px;
  border-radius: 50%;
}

.end-call-btn:hover svg {
  background: rgba(255, 59, 48, 1);
  transform: scale(1.1) rotate(135deg);
}

.end-call-btn .control-label {
  color: rgba(255, 59, 48, 0.9);
  font-weight: 600;
}

@media (max-width: 768px) {
  .control-btn {
    width: auto;
    height: auto;
    flex-shrink: 0;
  }
  
  .control-btn svg {
    width: 44px;
    height: 44px;
    padding: 12px;
  }
  
  .end-call-btn svg {
    width: 48px;
    height: 48px;
    padding: 14px;
  }
  
  .control-label {
    font-size: 11px;
  }
  
  .call-controls {
    gap: 8px;
    padding: 0 8px;
  }
}

@media (max-width: 768px) and (orientation: landscape) {
  .control-btn svg {
    width: 40px;
    height: 40px;
    padding: 11px;
  }
  
  .end-call-btn svg {
    width: 44px;
    height: 44px;
    padding: 13px;
  }
  
  .control-label {
    font-size: 10px;
  }
  
  .call-controls {
    gap: 6px;
    padding: 0 5px;
  }
}

.switch-camera-btn {
  display: none;
}

.incoming-call-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.95);
  z-index: 10001;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.3s ease;
}

.incoming-call-modal.active {
  display: flex;
}

.incoming-call-container {
  background: rgba(35, 35, 35, 0.98);
  border-radius: 32px;
  padding: 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  max-width: 400px;
  width: 90%;
  animation: slideUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.incoming-call-avatar {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  overflow: hidden;
  background: #2a2a2a;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

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

.incoming-call-info {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.incoming-call-username {
  font-size: 24px;
  font-weight: 600;
  color: #ffffff;
}

.incoming-call-status {
  font-size: 16px;
  color: rgba(255, 255, 255, 0.6);
}

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

.incoming-accept-btn,
.incoming-decline-btn {
  width: 70px;
  height: 70px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s ease;
  color: #ffffff;
}

.incoming-accept-btn {
  background: #34C759;
}

.incoming-accept-btn:hover {
  background: #30D158;
  transform: scale(1.1);
}

.incoming-decline-btn {
  background: #FF3B30;
}

.incoming-decline-btn:hover {
  background: #FF453A;
  transform: scale(1.1);
}

.incoming-decline-btn:active {
  transform: scale(0.95);
}

.incoming-accept-btn:active {
  transform: scale(0.95);
}

.incoming-accept-btn svg,
.incoming-decline-btn svg {
  pointer-events: none;
}

.minimized-call-float {
  display: none;
  position: fixed;
  bottom: 90px;
  right: 20px;
  z-index: 9999;
  cursor: pointer;
  animation: slideInFromRight 0.3s ease;
}

.minimized-call-float.active {
  display: block;
}

@keyframes slideInFromRight {
  from {
    opacity: 0;
    transform: translateX(100px) scale(0.8);
  }
  to {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

.minimized-call-content {
  background: rgba(35, 35, 35, 0.95);
  border-radius: 16px;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: all 0.2s ease;
  min-width: 180px;
}

.minimized-call-content:hover {
  background: rgba(40, 40, 40, 0.95);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.minimized-call-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  overflow: hidden;
  background: #555555;
  flex-shrink: 0;
  position: relative;
}

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

.minimized-call-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.minimized-call-username {
  font-size: 14px;
  font-weight: 600;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.minimized-call-timer {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.7);
  font-variant-numeric: tabular-nums;
}

.minimized-call-status-indicator {
  width: 12px;
  height: 12px;
  position: relative;
  flex-shrink: 0;
}

.call-pulse {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #34C759;
  position: absolute;
  top: 0;
  left: 0;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.3);
    opacity: 0.7;
  }
}

.call-pulse::before {
  content: '';
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: #34C759;
  opacity: 0.4;
  animation: pulseRing 2s ease-in-out infinite;
}

@keyframes pulseRing {
  0% {
    transform: scale(1);
    opacity: 0.4;
  }
  100% {
    transform: scale(2);
    opacity: 0;
  }
}

@media (max-width: 768px) {
  .minimized-call-float {
    bottom: 95px;
    left: 50%;
    right: auto;
    transform: translateX(-50%);
  }
  
  .minimized-call-float.active {
    display: flex;
    justify-content: center;
  }

  .minimized-call-content {
    padding: 8px 14px;
    min-width: 160px;
  }

  .minimized-call-avatar {
    width: 36px;
    height: 36px;
  }

  .minimized-call-username {
    font-size: 13px;
  }

  .minimized-call-timer {
    font-size: 11px;
  }
  
  @keyframes slideInFromRight {
    from {
      opacity: 0;
      transform: translateX(-50%) translateY(20px);
    }
    to {
      opacity: 1;
      transform: translateX(-50%) translateY(0);
    }
  }
}
