/* Общие стили */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body {
  background: #e9edef;
  padding: 0;
  margin: 0;
}

.container {
  max-width: 400px;
  height: 100vh;
  margin: 0 auto;
  background: white;
  display: flex;
  flex-direction: column;
  position: relative;
}

.screen {
  display: none;
  flex: 1;
  flex-direction: column;
}

/* === Экран регистрации === */
#registerScreen {
  display: flex;
  padding: 30px;
  justify-content: center;
  align-items: center;
  background: #f0f2f5;
}

input,
button {
  width: 100%;
  padding: 14px;
  margin: 10px 0;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 16px;
}

button {
  background: #128c7e;
  color: white;
  border: none;
  cursor: pointer;
  font-weight: 500;
}

button:hover {
  background: #0e7a6e;
}

/* === Экран поиска (searchScreen) === */
#searchScreen .header {
  background: #128c7e;
  color: white;
  padding: 12px 16px;
  display: flex;
  align-items: center;
}

#searchScreen .header input {
  background: transparent;
  border: none;
  color: white;
  font-size: 16px;
  outline: none;
  flex: 1;
  margin-left: 12px;
}

/* === Экран чата (chatScreen) === */
/* === Индикатор «печатает» (typing indicator) === */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  font-size: 13px;
  color: #667781;
  background: transparent;
}
.typing-dots {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}
.typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #128c7e;
  animation: typing-bounce 1.4s ease-in-out infinite both;
}
.typing-dots span:nth-child(2) { animation-delay: 0.16s; }
.typing-dots span:nth-child(3) { animation-delay: 0.32s; }
@keyframes typing-bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
  40% { transform: scale(1); opacity: 1; }
}
body.dark-theme .typing-indicator { color: #aebac1; }
body.dark-theme .typing-dots span { background: #00a884; }

.messages {
  flex: 1;
  padding: 16px;
  padding-bottom: 80px;
  background: #e5ddd5;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 120px);
}

/* React/Vite new frontend: the scroll container is #messagesBox.messages.
   Do not clamp max-height here — it breaks chat bottom when the composer grows (reply/edit/multiline). */
#messagesBox.messages {
  max-height: none !important;
}

/* Prevent browser scroll anchoring from fighting chat autoscroll when content/layout changes. */
#messagesBox {
  overflow-anchor: none;
}
#messagesBox .message,
#messagesBox .messages-stack {
  overflow-anchor: none;
}

.message {
  max-width: 70%;
  width: fit-content;
  flex-grow: 0;
  padding: 8px 12px;
  margin-bottom: 4px;
  border-radius: 7.5px;
  word-wrap: break-word;
  font-size: 14.5px;
  line-height: 1.3;
  position: relative;
  padding-right: 65px;
  contain: layout;
}

/* Some browsers: safer fallback for fit-content */
@supports not (width: fit-content) {
  .message {
    display: inline-block;
  }
}

/* Голосовые как отдельная единица (как в WhatsApp), а не обычный текстовый пузырь */
.message.voice-only {
  max-width: 80%;
  display: block;
  padding: 0;
  padding-right: 0;
  background: transparent;
  box-shadow: none;
  margin-bottom: 8px;
}

.message.voice-only.sent,
.message.voice-only.received {
  background: transparent;
  box-shadow: none;
}

.message.voice-only .voice-message {
  width: fit-content;
  max-width: 300px;
}

.message.voice-only .message-time {
  position: static;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  margin-top: 4px;
  margin-left: 0;
  padding-right: 0;
  right: auto;
  bottom: auto;
}

.message.voice-only .message-sender {
  margin-bottom: 6px;
}

.group-message-row {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  margin-bottom: 4px;
}

.group-message-row.voice-row {
  align-items: center;
}

.group-message-row.voice-row .group-avatar {
  align-self: center;
}

.group-message-row .group-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #9e9e9e;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  overflow: hidden;
  cursor: pointer;
  flex-shrink: 0;
}

.group-message-row .group-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.received {
  background: white;
  align-self: flex-start;
  border-top-left-radius: 0;
  box-shadow: 0 1px 0.5px rgba(0, 0, 0, 0.1);
}

.sent {
  background: #dcf8c6;
  align-self: flex-end;
  border-top-right-radius: 0;
  box-shadow: 0 1px 0.5px rgba(0, 0, 0, 0.1);
}

.message-sender {
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 4px;
  color: #333;
}

/* Ответ на сторис в ленте сообщений (мини-превью + подпись). Размер как у Instagram — фиксированный тумб, не полноразмерное фото */
.message-story-reply {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  margin: 0 0 8px;
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.045);
  border-left: 3px solid #128c7e;
  max-width: min(240px, 100%);
  box-sizing: border-box;
}

.message.sent .message-story-reply {
  background: rgba(255, 255, 255, 0.45);
}

.message-story-reply-thumb {
  width: 42px;
  height: 56px;
  min-width: 42px;
  max-width: 42px;
  min-height: 56px;
  max-height: 56px;
  flex: 0 0 42px;
  border-radius: 6px;
  overflow: hidden;
  background: #e8e8e8;
  align-self: center;
}

/* Tailwind Preflight задаёт img/video height:auto — ломает маленькое превью */
.message-story-reply-thumb img,
.message-story-reply-thumb video {
  display: block;
  width: 100% !important;
  height: 100% !important;
  max-width: 100% !important;
  max-height: 100% !important;
  min-height: 0 !important;
  object-fit: cover;
  vertical-align: middle;
}

.message-story-reply-thumb-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #9e9e9e;
  font-size: 22px;
}

.message-story-reply-meta {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  min-width: 0;
}

.message-story-reply-title {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: #128c7e;
  line-height: 1.2;
  margin-bottom: 2px;
}

.message-story-reply-author {
  font-size: 12px;
  color: #5a5a5a;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.message-story-reply-unavailable .message-story-reply-title {
  color: #888;
}

.message-text {
  margin-bottom: 2px;
}

.message-time {
  position: absolute;
  right: 8px;
  bottom: 2px;
  font-size: 11px;
  color: #999;
  white-space: nowrap;
  z-index: 2;
}

/* === WhatsApp-style checkmarks === */
.message-checks {
  display: inline-flex;
  align-items: flex-end;
  justify-content: flex-start;
  gap: 0;
  margin-left: 4px;
  vertical-align: text-bottom;
  line-height: 1;
}

.message-checks i {
  font-size: 12px;
  color: #95a5a6; /* серый — отправлено */
}

.message-checks i:nth-of-type(2) {
  font-size: 12px;
  margin-left: -6px; /* плотное перекрытие */
  opacity: 0.85;
}

.message.sent.read .message-checks i {
  color: #42AAFF; /* ваш синий цвет */
}

/* === Сообщения о звонках === */
.message-call .message-call-content {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
}

.message-call .message-call-icon {
  color: #128c7e;
  font-size: 16px;
  flex-shrink: 0;
}

.message-call .message-call-text {
  font-weight: 600;
  flex: 1;
  min-width: 0;
}

/* === Системные сообщения (смена аватара и т.д.) === */
.message-system {
  max-width: 100%;
  margin: 8px auto;
  text-align: center;
  background: none;
  padding: 4px 12px;
}
.message-system .message-system-text {
  font-size: 12px;
  color: #757575;
  background: rgba(0,0,0,0.08);
  padding: 4px 10px;
  border-radius: 7px;
  display: inline-block;
}

/* === Разделитель по дате === */
.message-date-divider {
  text-align: center;
  font-size: 12px;
  color: #757575;
  margin: 16px 0;
  background: white;
  padding: 4px 12px;
  border-radius: 7px;
  display: block;
  width: fit-content;
  margin-left: auto;
  margin-right: auto;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.08);
  font-weight: 500;
}

.loading {
  color: #888;
  font-style: italic;
  padding: 16px;
  text-align: center;
}

/* === Нижняя панель ввода сообщения === */
.input-area {
  position: sticky;
  bottom: 0;
  display: flex;
  align-items: center;
  padding: 8px 12px;
  background: #f0f2f5;
  border-top: 1px solid #e0e0e0;
  z-index: 10;
  gap: 8px;
  min-height: 60px;
  flex-shrink: 0;
  overflow: visible;
}

.input-area .emoji-button,
.input-area .attach-button,
.input-area .send-button {
  background: none;
  border: none;
  font-size: 20px;
  color: #666;
  cursor: pointer;
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background-color 0.2s;
}

.input-area .emoji-button:hover,
.input-area .attach-button:hover,
.input-area .send-button:hover {
  background-color: rgba(0, 0, 0, 0.05);
}

.input-area .textarea-wrap {
  flex: 1;
  min-width: 0;
  height: 44px;
  position: relative;
  overflow: visible;
}

.input-area .textarea-wrap textarea {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  border: 1px solid #ddd;
  outline: none;
  padding: 10px 14px;
  border-radius: 24px;
  font-size: 15px;
  font-family: inherit;
  background: white;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
  transition: border-color 0.2s;
  resize: none;
  min-height: 40px;
  max-height: 120px;
  overflow-y: auto;
}

.input-area .textarea-wrap textarea:focus {
  border-color: #128c7e;
  box-shadow: 0 1px 4px rgba(18, 140, 126, 0.2);
}

.input-area .send-button {
  color: #128c7e;
  font-size: 22px;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
}

.input-area .send-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.input-area .send-button.voice-mode {
  color: #128c7e;
  font-size: 24px;
  /* размер 44x44 — без сдвига при смене микрофон ↔ самолёт */
}

.input-area .send-button.voice-mode:hover {
  color: #075e54;
  transform: scale(1.1);
}

.input-area .send-button.recording {
  color: #ff5252;
  animation: pulse 1.5s infinite;
  background: rgba(255, 82, 82, 0.1);
}

/* === Модальное окно создания чата === */
#createChatModal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
}

#createChatModal > div {
  background: white;
  margin: 50px auto;
  padding: 20px;
  max-width: 350px;
  border-radius: 10px;
}

#groupSearchResults {
  max-height: 180px;
  overflow-y: auto;
  margin: 10px 0;
  border: 1px solid #eee;
  border-radius: 5px;
}

#selectedParticipants {
  margin-top: 10px;
  padding: 10px;
  background: #f9f9f9;
  border-radius: 5px;
}

.remove-participant {
  background: #ff4d4d;
  color: white;
  border: none;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 10px;
  cursor: pointer;
  margin-left: 8px;
}

/* === Аватарка === */
.avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #0d7769;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: bold;
  color: white;
  margin-right: 12px;
  flex-shrink: 0;
  position: relative;
}

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

/* === Статус онлайн/оффлайн === */
.status-dot {
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 10px;
  height: 10px;
  border: 1px solid white;
  border-radius: 50%;
  box-sizing: content-box;
  display: none; /* по умолчанию скрыт */
}

.status-dot.online {
  background-color: #4CAF50;
  display: inline-block;
}

.status-dot.offline {
  background-color: #9E9E9E;
  display: inline-block;
}

/* Для шапки чата нужно немного другие отступы */
#chatScreen .avatar-container .status-dot {
  bottom: 0;
  right: 0;
}

/* Убедитесь, что аватар в шапке чата имеет правильные отступы */
#chatScreen .avatar {
  width: 40px;
  height: 40px;
  margin-right: 0;
}

/* === Ссылки в сообщениях === */
.message-text a {
  color: #128c7e;
  text-decoration: underline;
  word-break: break-word;
}

/* === Медиа в чате === */
.chat-media-wrap.chat-media-image {
  position: relative;
  aspect-ratio: 4/3;
  max-width: 240px;
  min-height: 150px;
  max-height: 320px;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 20px;
}
.chat-media-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.6);
  font-size: 24px;
}
.chat-media-wrap.chat-media-image:has(img.chat-media.loaded) .chat-media-placeholder {
  display: none;
}
.chat-media-wrap.chat-media-image:has(img.chat-media.loaded) {
  background: transparent;
}
.chat-media-wrap.chat-media-image img.chat-media {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  transition: opacity 0.25s ease;
  object-fit: cover;
}
.chat-media-wrap.chat-media-image img.chat-media.loaded {
  opacity: 1;
}
.chat-media {
  max-width: 240px;
  max-height: 320px;
  min-height: 150px;
  width: auto;
  height: auto;
  display: block;
  border-radius: 8px;
  background-color: #333; /* Чёрный/серый фон как в WhatsApp */
  object-fit: cover;
}

.chat-media video,
.video-tap-wrap video {
  width: 100%;
  max-height: 320px;
  min-height: 120px;
  border-radius: 8px;
}

.video-tap-wrap {
  min-height: 120px;
  background: #333;
}

/* === Video preview in chat (new UI): keep stable 16:9, no black bands === */
.video-tap-wrap {
  position: relative;
  display: inline-block;
  width: 240px;
  max-width: 100%;
  aspect-ratio: 3 / 2;
  border-radius: 8px;
  overflow: hidden;
  background: transparent !important;
  min-height: 0 !important;
}

.video-tap-wrap > video.chat-media {
  display: block;
  width: 100% !important;
  height: 100% !important;
  max-height: none !important;
  min-height: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  object-fit: cover;
}

/* === Реакции на сообщения === */
.message-reactions-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  align-items: center;
  margin-top: 4px;
  margin-bottom: 2px;
}

.message-reaction {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 14px;
  padding: 2px 6px;
  background: rgba(0,0,0,0.06);
  border-radius: 12px;
  line-height: 1.2;
  cursor: pointer;
}

.message.sent .message-reaction {
  background: rgba(0,0,0,0.08);
}

.reaction-count {
  font-size: 10px;
  color: #666;
  font-weight: 500;
}

/* Ряд эмодзи в контекстном меню */
.context-menu-reactions {
  -webkit-tap-highlight-color: transparent;
}

.reaction-emoji-btn:hover,
.reaction-emoji-btn:focus,
.reaction-emoji-btn:active {
  background-color: transparent !important;
  outline: none;
}

/* === Контекстное меню (удаление) === */
.context-menu {
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* React: × в модалке «Просмотры» — иначе глобальные input,button / button дают width:100% и зелёный hover */
button.message-readers-close {
  width: 32px !important;
  height: 32px !important;
  min-width: 32px !important;
  max-width: 32px !important;
  padding: 0 !important;
  margin: 0 !important;
  border: none !important;
  font-weight: 400 !important;
}
button.message-readers-close:hover {
  background: rgba(0, 0, 0, 0.06) !important;
}

/* === Окно просмотров (кто посмотрел в группе) === */
.readers-popup {
  background: #fff;
  border: 1px solid #ddd;
}
.readers-popup-loading,
.readers-popup-empty {
  color: #666;
  font-size: 13px;
}
.readers-popup-error {
  color: #d32f2f;
  font-size: 13px;
}
.readers-popup-item {
  display: flex;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid #f0f0f0;
}
.readers-popup-item:last-child {
  border-bottom: none;
}
.readers-popup-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  margin-right: 10px;
  flex-shrink: 0;
}
.readers-popup-avatar-initial {
  background: #128c7e;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}
.readers-popup-info {
  min-width: 0;
}
.readers-popup-name {
  font-weight: 500;
}
.readers-popup-time {
  font-size: 12px;
  color: #888;
}
.readers-popup-time i {
  margin-right: 4px;
}

/* === Режим выбора сообщений === */
/* Панель на месте шапки чата — тот же размер, без смещений (как в WhatsApp/Telegram) */
.selection-action-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  height: 64px;
  box-sizing: border-box;
  position: sticky;
  top: 0;
  z-index: 10;
  background: #128c7e;
  color: white;
  flex-shrink: 0;
}

.selection-btn {
  padding: 6px 12px;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.2s, background 0.2s;
  line-height: 1.3;
}

.selection-forward,
.selection-delete {
  background: rgba(255,255,255,0.25);
  color: white;
}

.selection-forward:hover:not(:disabled),
.selection-delete:hover:not(:disabled) {
  background: rgba(255,255,255,0.4);
}

.selection-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.selection-cancel {
  background: transparent;
  color: rgba(255,255,255,0.9);
  margin-left: auto;
}

.selection-cancel:hover {
  background: rgba(255,255,255,0.2);
}

/* Обёртка: чекбокс отдельно на фоне, рядом с пузырем. БЕЗ доп. фона — только чат-фон */
.selection-message-wrap {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  cursor: pointer;
  background: transparent !important;
  margin-bottom: 4px;
  border: none;
  box-shadow: none;
}

/* Сообщение не сжимается — буквы не переносятся некорректно */
.selection-message-wrap .message {
  flex-shrink: 0;
  min-width: min-content;
}

/* Убираем тень пузыря в режиме выбора — она может выглядеть как линия под сообщением */
.selection-message-wrap .message.received,
.selection-message-wrap .message.sent {
  box-shadow: none;
}

.selection-message-wrap.sent {
  align-self: flex-end;
  flex-direction: row;
}

.selection-message-wrap.received {
  align-self: flex-start;
  flex-direction: row;
}

/* Чекбокс на фоне чата — без доп. фона, только обводка */
.message-select-checkbox {
  width: 26px;
  height: 26px;
  min-width: 26px;
  border-radius: 50%;
  border: 2px solid #95a5a6;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 12px;
  flex-shrink: 0;
  pointer-events: auto;
}

.message-select-checkbox.selected {
  background: #128c7e;
  border-color: #128c7e;
}

.message-select-checkbox i {
  opacity: 0;
}

.message-select-checkbox.selected i {
  opacity: 1;
}

/* Стили для экрана информации о контакте */
#contactInfoScreen {
  display: none;
  flex-direction: column;
  background: #f0f0f0;
}

.contact-info-container {
  flex: 1;
  overflow-y: auto;
}

.contact-header {
  background: white;
  padding: 30px 20px;
  text-align: center;
  border-bottom: 1px solid #e0e0e0;
}

.big-avatar {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: #128c7e;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  font-weight: bold;
  margin: 0 auto 15px;
  overflow: hidden;
}

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

.contact-main-info h2 {
  margin: 0 0 5px 0;
  font-size: 20px;
  color: #333;
}

.contact-main-info p {
  margin: 0;
  color: #666;
  font-size: 16px;
}

.contact-actions {
  margin-top: 20px;
  background: white;
}

.action-item {
  display: flex;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid #e0e0e0;
  cursor: pointer;
  transition: background 0.2s;
}

.action-item:hover {
  background: #f5f5f5;
}

.action-item i:first-child {
  margin-right: 20px;
  font-size: 20px;
  width: 24px;
  text-align: center;
}

.action-item span {
  flex: 1;
  font-size: 16px;
  color: #333;
}

.action-item i:last-child {
  color: #888;
  font-size: 14px;
}

/* Toggle switch */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 24px;
}

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

.toggle-switch label {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  transition: .4s;
  border-radius: 34px;
}

.toggle-switch label:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
}

.toggle-switch input:checked + label {
  background-color: #128c7e;
}

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

/* 🔉 СТИЛИ ДЛЯ ГОЛОСОВЫХ СООБЩЕНИЙ */
.voice-message {
  display: flex;
  align-items: center;
  gap: 10px;
  border-radius: 14px;
  padding: 8px 10px;
  min-width: 0;
  max-width: 300px;
  cursor: pointer;
  user-select: none;
  box-shadow: 0 1px 0.5px rgba(0, 0, 0, 0.08);
}

.voice-message-sent {
  background: #d9fdd3;
  border: 1px solid #c5e7bd;
}

.voice-message-received {
  background: #ffffff;
  border: 1px solid #ececec;
}

.voice-message-placeholder {
  opacity: 0.8;
  cursor: default;
}

.voice-message audio {
  display: none;
}

.voice-message .voice-play-btn {
  width: 36px;
  height: 36px;
  min-width: 36px;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: #25d366;
  cursor: pointer;
  box-shadow: none;
}

.voice-message .voice-play-btn i {
  font-size: 14px;
  line-height: 1;
}

.voice-message-placeholder .voice-play-btn {
  background: #9e9e9e;
  cursor: default;
}

.voice-wave-wrap {
  flex: 1;
  min-width: 120px;
}

.voice-waveform {
  height: 14px;
  border-radius: 8px;
  opacity: 1;
  background:
    repeating-linear-gradient(
      90deg,
      rgba(85, 85, 85, 0.35) 0 2px,
      transparent 2px 4px
    );
}

.voice-progress {
  margin-top: 4px;
  height: 4px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.2);
  overflow: hidden;
}

.voice-progress-bar {
  display: block;
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #25d366 0%, #20b85a 100%);
  transition: width 0.08s linear;
}

.voice-meta {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  min-width: 64px;
  font-size: 11px;
  color: #6b6b6b;
  font-variant-numeric: tabular-nums;
}

.voice-current {
  font-weight: 600;
  color: #444;
}

.voice-sep {
  opacity: 0.5;
}

.voice-button {
  background: none;
  border: none;
  color: #128c7e;
  font-size: 24px;
  cursor: pointer;
  padding: 8px;
  margin: 0 4px;
  transition: all 0.2s ease;
  border-radius: 50%;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.voice-button:hover {
  color: #075e54;
  transform: scale(1.1);
}

.voice-button.recording {
  color: #ff5252;
  animation: pulse 1.5s infinite;
  background: rgba(255, 82, 82, 0.1);
}

/* 📎 Файлы в чате */
.file-attachment {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  background: #f4f6f8;
  max-width: 260px;
}

.file-attachment .file-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: #128c7e;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.file-attachment .file-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
}

.file-attachment .file-name {
  font-size: 14px;
  color: #222;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-attachment .file-name a {
  color: inherit;
  text-decoration: none;
}

.file-attachment .file-size {
  font-size: 12px;
  color: #777;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(255, 82, 82, 0.4); }
  70% { box-shadow: 0 0 0 10px rgba(255, 82, 82, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 82, 82, 0); }
}

/* Визуализация волн при записи */
#recordingWaves {
  position: absolute;
  bottom: 70px;
  left: 50%;
  transform: translateX(-50%);
  display: none;
  gap: 4px;
  padding: 8px 16px;
  background: rgba(0,0,0,0.7);
  border-radius: 20px;
  color: white;
  font-size: 14px;
  z-index: 100;
}

.wave {
  width: 4px;
  height: 20px;
  background: #4CAF50;
  border-radius: 2px;
  animation: wave 1.2s infinite ease-in-out;
}

.wave:nth-child(2) { animation-delay: -1.1s; }
.wave:nth-child(3) { animation-delay: -1.0s; }
.wave:nth-child(4) { animation-delay: -0.9s; }
.wave:nth-child(5) { animation-delay: -0.8s; }

@keyframes wave {
  0%, 40%, 100% { height: 10px; }
  20% { height: 24px; }
} 

    /* Стили для блока цитаты */
    #replyPreview {
      display: none;
      padding: 8px 12px;
      background: #e9e9e9;
      border-radius: 8px;
      margin-bottom: 8px;
      position: relative;
      max-width: 100%;
      font-size: 14px;
      color: #333;
      word-break: break-word;
    }
    #replyPreview .reply-cancel {
      position: absolute;
      top: 4px;
      right: 4px;
      cursor: pointer;
      font-size: 12px;
      color: #777;
    }
    .message-reply {
      padding: 4px 8px;
      background: #f0f0f0;
      border-radius: 6px;
      margin-bottom: 6px;
      cursor: pointer;
      font-size: 13px;
      color: #555;
    }
    .message-reply:hover {
      background: #e8e8e8;
    }

/* === Поиск в чате === */
.chat-search-bar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: #128c7e;
  color: white;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.chat-search-bar input {
  flex: 1;
  min-width: 0;
  padding: 8px 12px;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  background: rgba(255,255,255,0.2);
  color: white;
  outline: none;
}
.chat-search-bar input::placeholder {
  color: rgba(255,255,255,0.7);
}
.chat-search-btn {
  cursor: pointer;
  padding: 6px;
  font-size: 16px;
  opacity: 0.9;
}
.chat-search-btn:hover {
  opacity: 1;
}
.chat-search-counter {
  font-size: 13px;
  opacity: 0.9;
  white-space: nowrap;
}
.chat-search-nav {
  display: flex;
  gap: 4px;
}
.chat-search-nav i,
.chat-search-close {
  cursor: pointer;
  padding: 6px;
  font-size: 16px;
  opacity: 0.9;
}
.chat-search-nav i:hover,
.chat-search-close:hover {
  opacity: 1;
}
.chat-search-highlight {
  background: rgba(255,235,59,0.6);
  color: #1a1a1a;
  padding: 0 1px;
  border-radius: 2px;
}


