/* ============================================
   FirstWeb Chat — компоненты
   ============================================ */

/* =============================================
   ЭКРАН 1: Авторизация
   ============================================= */
.screen-auth {
  padding: 24px;
  justify-content: center;
  align-items: center;
  background: var(--bg-white);
}

.auth-logo {
  text-align: center;
  margin-bottom: 32px;
}
.auth-logo h1 {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  margin-top: 12px;
}

.logo-circle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.auth-tabs {
  display: flex;
  width: 100%;
  max-width: 360px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}

.auth-tab {
  flex: 1;
  padding: 12px;
  font-size: 15px;
  font-weight: 500;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.15s, border-color 0.15s;
}
.auth-tab.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

.auth-form {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.auth-form input {
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 15px;
  background: var(--bg-white);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.auth-form input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.auth-form .btn-primary {
  margin-top: 8px;
  padding: 14px;
}

.auth-error {
  color: var(--danger);
  font-size: 14px;
  text-align: center;
  min-height: 20px;
  margin-top: 4px;
}

/* =============================================
   ЭКРАН 2: Список чатов
   ============================================= */
.screen-chats {
  background: var(--bg-white);
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-h);
  padding: 0 16px;
  background: var(--bg-white);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.app-header h1 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.app-header h1::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  background: var(--accent);
  border-radius: 50%;
}

/* Поиск */
.search-bar {
  padding: 8px 12px;
  background: var(--bg-white);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.search-bar input {
  width: 100%;
  padding: 8px 14px;
  background: var(--bg-app);
  border-radius: var(--radius-pill);
  font-size: 14px;
  transition: background 0.15s;
}
.search-bar input:focus {
  background: var(--bg-white);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

/* Список чатов */
.chat-list {
  flex: 1;
  overflow-y: auto;
  background: var(--bg-white);
  -webkit-overflow-scrolling: touch;
}

.chat-item {
  display: flex;
  gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  transition: background 0.1s;
  border-bottom: 1px solid var(--border);
  align-items: center;
}
.chat-item:hover { background: #f5f6f6; }
.chat-item:active { background: #ececec; }

.chat-item-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
}

.chat-item-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}
.chat-item-name {
  font-size: 16px;
  font-weight: 500;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-item-time {
  font-size: 12px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.chat-item-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.chat-item-preview {
  font-size: 14px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  line-height: 1.3;
}
.chat-item-preview em {
  color: var(--text-muted);
  font-style: normal;
}

.chat-item-unread {
  background: var(--accent);
  color: var(--accent-text);
  font-size: 12px;
  font-weight: 700;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: var(--radius-pill);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.chat-list-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 24px;
  min-height: 100%;
  gap: 0;
}

.empty-illustration {
  width: 200px;
  height: 200px;
  margin-bottom: 8px;
  animation: empty-float 4s ease-in-out infinite;
}

.empty-illustration-sm {
  width: 120px;
  height: 120px;
}

.empty-illustration svg {
  width: 100%;
  height: 100%;
  display: block;
}

@keyframes empty-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.empty-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 10px;
}

.empty-text {
  font-size: 14.5px;
  color: var(--text-secondary);
  line-height: 1.55;
  margin: 0 0 24px;
  max-width: 320px;
}
.empty-text b {
  color: var(--accent-hover);
  font-weight: 700;
}

.empty-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 22px;
  background: var(--accent);
  color: var(--accent-text);
  border-radius: var(--radius-pill);
  font-size: 15px;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(254, 206, 26, 0.35);
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
  cursor: pointer;
}
.empty-btn:hover {
  background: var(--accent-hover);
  box-shadow: 0 6px 16px rgba(254, 206, 26, 0.45);
}
.empty-btn:active {
  transform: scale(0.97);
}
.empty-btn svg {
  display: block;
}

/* Кнопка «+» */
.fab {
  position: absolute;
  right: 16px;
  bottom: calc(20px + env(safe-area-inset-bottom));
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-text);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s, background 0.15s;
  z-index: 10;
}
.fab:hover { background: var(--accent-hover); }
.fab:active { transform: scale(0.94); }

@media (min-width: 769px) {
  .fab {
    position: fixed;
    right: calc(50vw - 384px + 16px);
  }
}

/* =============================================
   ЭКРАН 3: Переписка
   ============================================= */
.screen-chat {
  background: var(--bg-app);
}

.chat-header {
  display: flex;
  align-items: center;
  height: var(--header-h);
  padding: 0 8px;
  background: var(--bg-dark);
  color: var(--text-on-dark);
  flex-shrink: 0;
  position: relative;
}
.chat-header .icon-btn { color: var(--text-on-dark); }
.chat-header .icon-btn:hover { background: rgba(255, 255, 255, 0.1); }
.chat-header .icon-btn:active { background: rgba(255, 255, 255, 0.15); }
.chat-header .avatar {
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.12);
  margin-right: 10px;
}

.chat-peer-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
}
.chat-peer-name {
  font-size: 16px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.2;
}
.chat-peer-status {
  font-size: 12px;
  color: var(--text-on-dark-muted);
  line-height: 1.2;
  height: 15px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* =============================================
   Сообщения
   ============================================= */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  -webkit-overflow-scrolling: touch;
  background:
    linear-gradient(rgba(240, 242, 245, 0.96), rgba(240, 242, 245, 0.96));
}

.msg-row {
  display: flex;
  margin-bottom: 2px;
  animation: msg-in 0.15s ease-out;
}
.msg-row.own { justify-content: flex-end; }

@keyframes msg-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.bubble {
  max-width: 80%;
  background: var(--bubble-in);
  color: var(--bubble-in-text);
  border-radius: var(--radius);
  padding: 6px 10px;
  font-size: 14.5px;
  line-height: 1.35;
  word-wrap: break-word;
  position: relative;
  box-shadow: var(--shadow-sm);
}
.msg-row.own .bubble {
  background: var(--bubble-out);
  color: var(--bubble-out-text);
}

/* Хвостик пузыря */
.bubble::before {
  content: '';
  position: absolute;
  top: 0;
  width: 10px;
  height: 10px;
}
.msg-row:not(.own) .bubble::before {
  left: -8px;
  background: radial-gradient(circle at 0 0, transparent 70%, var(--bubble-in) 72%);
}
.msg-row.own .bubble::before {
  right: -8px;
  background: radial-gradient(circle at 100% 0, transparent 70%, var(--bubble-out) 72%);
}

.bubble-text {
  white-space: pre-line;
  word-break: break-word;
}

.bubble-meta {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  float: right;
  margin: 4px 0 -2px 8px;
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1;
  white-space: nowrap;
}
.msg-row.own .bubble-meta { color: rgba(0, 0, 0, 0.5); }

.bubble-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
  color: var(--text-muted);
  margin-left: 2px;
}
.bubble-check svg {
  display: block;
}
.bubble-check.read {
  color: var(--check-read);
}
.bubble-check.pending,
.bubble-check.error-icon {
  color: var(--text-muted);
}
.bubble-check.error-icon {
  color: var(--danger);
}

/* На жёлтом фоне (своё сообщение) — цвета галочек темнее */
.msg-row.own .bubble-check {
  color: rgba(0, 0, 0, 0.55);
}
.msg-row.own .bubble-check.read {
  color: var(--check-read);
}

/* Цитата (ответ) — общий стиль */
.bubble-quote {
  border-left: 3px solid #9e9e9e;
  background: #f0f0f0;
  padding: 4px 8px;
  border-radius: 4px;
  margin-bottom: 4px;
  font-size: 13px;
  max-width: 100%;
  overflow: hidden;
  cursor: pointer;
  transition: background 0.15s;
}
.bubble-quote:hover {
  background: rgba(0, 0, 0, 0.08);
}

.bubble-quote-author {
  color: #5a5a5a;
  font-weight: 600;
  margin-bottom: 1px;
  font-size: 12.5px;
}
.bubble-quote-text {
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Цитата внутри своего (жёлтого) сообщения — белая с серой полоской */
.msg-row.own .bubble-quote {
  background: rgba(255, 255, 255, 0.75);
  border-left-color: #b0b0b0;
  cursor: pointer;
  transition: background 0.15s;
}
.msg-row.own .bubble-quote:hover {
  background: rgba(255, 255, 255, 0.85);
}
.msg-row.own .bubble-quote-author {
  color: #444;
}
.msg-row.own .bubble-quote-text {
  color: #666;
}

/* Удалённое */
.bubble.deleted .bubble-text {
  font-style: italic;
  color: var(--text-muted);
}

/* Разделитель «сегодня/вчера» */
.date-divider {
  align-self: center;
  background: rgba(17, 27, 33, 0.15);
  color: #fff;
  font-size: 12px;
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  margin: 8px 0;
  backdrop-filter: blur(4px);
}

/* =============================================
   Индикатор «печатает»
   ============================================= */
.typing-indicator {
  display: inline-flex;
  gap: 3px;
  align-items: center;
  padding: 2px 0;
}
.typing-indicator span {
  width: 5px;
  height: 5px;
  background: currentColor;
  border-radius: 50%;
  opacity: 0.5;
  animation: typing 1.2s infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30%           { opacity: 1;   transform: translateY(-3px); }
}

/* =============================================
   Форма ввода
   ============================================= */
.message-form {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding: 6px 8px;
  padding-bottom: calc(6px + env(safe-area-inset-bottom));
  background: var(--bg-app);
  flex-shrink: 0;
}

/* Когда клавиатура открыта — home indicator скрыт, лишний отступ не нужен */
html.keyboard-open .message-form {
  padding-bottom: 6px;
}

.message-form textarea {
  flex: 1;
  background: var(--bg-white);
  border-radius: 20px;
  padding: 10px 16px;
  font-size: 15px;
  line-height: 1.4;
  min-height: 40px;
  max-height: 84px;
  resize: none;
  overflow-y: auto;
  font-family: inherit;
  box-shadow: var(--shadow-sm);
  border: none;
  outline: none;
  word-wrap: break-word;
  overflow-wrap: break-word;
  white-space: pre-wrap;
}
.message-form textarea::placeholder {
  color: var(--text-muted);
}
.message-form textarea::-webkit-scrollbar {
  width: 4px;
}
.message-form textarea::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,0.15);
  border-radius: 2px;
}

.message-form .icon-btn {
  color: var(--text-secondary);
}

.btn-send {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-text);
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.05s;
  box-shadow: var(--shadow-sm);
  padding: 0;
  line-height: 0;
}
.btn-send svg { display: block; }

/* Компенсация асимметрии ТОЛЬКО для самолётика */
#send-btn svg { margin-left: 3px; }

/* Микрофон — по центру без сдвига */
#voice-btn svg { margin-left: 0; }

#attach-send-btn svg { margin-left: 11px; }

.btn-send:hover { background: var(--accent-hover); }
.btn-send:active { transform: scale(0.95); }
.btn-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: var(--border);
  color: var(--text-muted);
}

/* =============================================
   Список пользователей (модалка «Новый чат»)
   ============================================= */
.user-list {
  flex: 1;
  overflow-y: auto;
  max-height: 400px;
}
.user-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  cursor: pointer;
  transition: background 0.1s;
  border-bottom: 1px solid var(--border);
}
.user-item:hover { background: #f5f6f6; }
.user-item:active { background: #ececec; }
.user-item-body {
  min-width: 0;
  flex: 1;
}
.user-item-name {
  font-weight: 500;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-item-username {
  font-size: 13px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* =============================================
   Профиль
   ============================================= */
.profile-body {
  padding: 24px 20px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}
.profile-body .avatar {
  margin: 0 auto 16px;
}
.profile-body p {
  margin: 8px 0;
  font-size: 15px;
  color: var(--text);
}
.profile-body p b {
  color: var(--text-secondary);
  font-weight: 500;
  margin-right: 6px;
}

/* =============================================
   Пустые состояния
   ============================================= */
.empty-state {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.5;
}
.empty-state b {
  display: block;
  color: var(--text-secondary);
  font-size: 16px;
  margin-bottom: 6px;
  font-weight: 600;
}

/* =============================================
   Скроллбары (для десктопа)
   ============================================= */
.chat-list::-webkit-scrollbar,
.messages::-webkit-scrollbar,
.user-list::-webkit-scrollbar {
  width: 6px;
}
.chat-list::-webkit-scrollbar-thumb,
.messages::-webkit-scrollbar-thumb,
.user-list::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.15);
  border-radius: 3px;
}
.chat-list::-webkit-scrollbar-track,
.messages::-webkit-scrollbar-track,
.user-list::-webkit-scrollbar-track {
  background: transparent;
}

/* =============================================
   Reply preview (цитата над полем ввода)
   ============================================= */
.reply-preview {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg-white);
  border-top: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  flex-shrink: 0;
}
.reply-preview-body {
  flex: 1;
  min-width: 0;
}
.reply-preview-author {
  color: #8a6500;
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 2px;
}
.reply-preview-text {
  color: var(--text-secondary);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* =============================================
   Контекстное меню на сообщении
   ============================================= */
.bubble-menu {
  position: fixed;
  background: var(--bg-white);
  border-radius: var(--radius);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.18);
  padding: 4px 0;
  z-index: 400;
  min-width: 160px;
  animation: menu-in 0.12s ease-out;
}
.bubble-menu button {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  text-align: left;
  width: 100%;
  min-width: 200px;
}
.bubble-menu .menu-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: var(--text-secondary);
}
.bubble-menu .menu-icon svg { display: block; }
.bubble-menu .menu-label {
  flex: 1;
  min-width: 0;
}
.bubble-menu button.danger .menu-icon,
.bubble-menu button.danger .menu-label {
  color: var(--danger);
}

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

/* =============================================
   Информационная плашка в начале чата
   ============================================= */
.chat-notice {
  align-self: center;
  max-width: 90%;
  background: rgba(255, 255, 255, 0.9);
  color: var(--text-secondary);
  font-size: 12.5px;
  line-height: 1.4;
  text-align: center;
  padding: 8px 14px;
  border-radius: var(--radius);
  margin: 4px 0 12px;
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(2px);
}
.chat-notice b {
  color: var(--text);
  font-weight: 500;
}

/* =============================================
   Точка онлайн на аватаре
   ============================================= */
.avatar-wrap {
  position: relative;
  display: inline-flex;
  flex-shrink: 0;
}

.online-dot {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 12px;
  height: 12px;
  background: #25d366;
  border-radius: 50%;
  border: 2px solid var(--bg-white);
  box-sizing: content-box;
}

/* В шапке чата точка не нужна, статус текстом */
.chat-header .online-dot { display: none; }

/* =============================================
   Поиск по сообщениям
   ============================================= */
.search-modal {
  max-height: 70vh;
  height: 70vh;
}

.search-header {
  padding: 10px 12px;
  gap: 8px;
}

.search-header input {
  flex: 1;
  padding: 10px 14px;
  border: none;
  background: var(--bg-app);
  border-radius: var(--radius-pill);
  font-size: 15px;
  min-width: 0;
}
.search-header input:focus {
  background: var(--bg-white);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.search-results {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
}

.search-result {
  padding: 10px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
.search-result:hover { background: var(--bg-app); }

.search-result-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 12.5px;
  color: var(--text-muted);
  margin-bottom: 3px;
}
.search-result-author {
  font-weight: 600;
  color: var(--text-secondary);
}
.search-result-text {
  font-size: 14px;
  color: var(--text);
  line-height: 1.35;
  word-break: break-word;
}
.search-result-text mark {
  background: var(--accent);
  color: var(--accent-text);
  padding: 0 2px;
  border-radius: 2px;
  font-weight: 500;
}

.search-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  font-size: 14px;
}

/* Подсветка сообщения, к которому перешли из поиска */
.msg-row.highlight .bubble {
  animation: msg-highlight 1.5s ease-out;
}
@keyframes msg-highlight {
  0% { box-shadow: 0 0 0 3px var(--accent); }
  100% { box-shadow: var(--shadow-sm); }
}

/* =============================================
   Эмодзи-пикер
   ============================================= */
.emoji-picker {
  background: var(--bg-white);
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 260px;
  flex-shrink: 0;
}

.emoji-tabs {
  display: flex;
  padding: 4px 8px;
  border-bottom: 1px solid var(--border);
  gap: 2px;
  overflow-x: auto;
  flex-shrink: 0;
}
.emoji-tabs::-webkit-scrollbar { height: 3px; }
.emoji-tabs::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.15); border-radius: 3px; }

.emoji-tab {
  padding: 6px 10px;
  font-size: 18px;
  border-radius: 6px;
  opacity: 0.45;
  transition: opacity 0.12s, background 0.12s;
  flex-shrink: 0;
  line-height: 1;
}
.emoji-tab:hover { opacity: 1; background: var(--bg-app); }
.emoji-tab.active {
  opacity: 1;
  background: var(--accent-soft);
}

.emoji-grid {
  flex: 1;
  overflow-y: auto;
  padding: 6px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(38px, 1fr));
  gap: 2px;
  align-content: start;
}
.emoji-grid::-webkit-scrollbar { width: 6px; }
.emoji-grid::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,0.15);
  border-radius: 3px;
}

.emoji-item {
  width: 100%;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.1s;
  user-select: none;
  line-height: 1;
}
.emoji-item:hover { background: var(--bg-app); }
.emoji-item:active { background: var(--accent-soft); }

/* SVG в кнопке эмодзи */
#emoji-btn svg { display: block; }

/* =============================================
   Голосовые сообщения
   ============================================= */

/* Кнопка отправки текста — скрыта по умолчанию */
#send-btn { display: none; }
#voice-btn { display: flex; }

/* Пузырь голосового */
.voice-bubble {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-width: 200px;
  max-width: 260px;
  padding: 0;
  min-height: 0;
}

.voice-play {
  width: 36px;
  height: 36px;
  min-width: 36px;
  min-height: 36px;
  border-radius: 50%;
  background: rgba(96, 96, 96, 0.85);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
  transition: background 0.15s;
  border: none;
  padding: 0;
}
.voice-play:hover { background: rgba(80, 80, 80, 0.95); }
.voice-play.playing { background: rgba(64, 64, 64, 1); }
.voice-play svg { display: block; }

.voice-body {
  flex: 1;
  min-width: 0;
  display: grid;
  grid-template-rows: 36px auto;
}

.voice-wave {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  height: 22px;
  align-self: center;
  cursor: pointer;
  overflow: hidden;
}

.voice-wave-bar {
  flex: 1;
  background: currentColor;
  opacity: 0.35;
  border-radius: 2px;
  transition: opacity 0.1s, background 0.1s;
  min-width: 2px;
  align-self: center;
}
.voice-wave-bar.played {
  opacity: 1;
  background: var(--accent-hover);
}
.msg-row.own .voice-wave-bar.played {
  background: #8a6500;
}

.voice-meta {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1;
  min-height: 12px;
  text-align: left;
}
.msg-row.own .voice-meta { color: rgba(0, 0, 0, 0.5); }

/* Оверлей записи */
.voice-recording {
  position: fixed;
  inset: 0;
  background: rgba(17, 27, 33, 0.85);
  z-index: 500;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: calc(80px + env(safe-area-inset-bottom));
  animation: fade-in 0.15s ease-out;
}

.voice-recording-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-white);
  padding: 12px 16px;
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-lg);
}

.voice-dot {
  width: 12px;
  height: 12px;
  background: #dc2626;
  border-radius: 50%;
  animation: voice-pulse 1s infinite;
  flex-shrink: 0;
}
@keyframes voice-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

#voice-timer {
  font-size: 16px;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  color: var(--text);
  min-width: 50px;
}

.voice-cancel,
.voice-stop {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.voice-cancel {
  background: var(--bg-app);
  color: var(--text-secondary);
}
.voice-cancel:hover { background: var(--border); }
.voice-stop {
  background: var(--accent);
  color: var(--accent-text);
}
.voice-stop:hover { background: var(--accent-hover); }

.voice-bubble-wrap {
  white-space: normal;
}

/* =============================================
   Офлайн-индикатор
   ============================================= */
.offline-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 900;
  background: #dc2626;
  color: #fff;
  text-align: center;
  padding: 8px 16px;
  font-size: 13.5px;
  font-weight: 500;
  padding-top: calc(8px + env(safe-area-inset-top));
  animation: slide-down 0.2s ease-out;
}
.offline-banner svg {
  display: block;
  flex-shrink: 0;
}

@keyframes slide-down {
  from { transform: translateY(-100%); }
  to { transform: translateY(0); }
}

/* =============================================
   Очередь сообщений (офлайн)
   ============================================= */
.bubble.pending {
  opacity: 0.85;
}
.bubble.pending .bubble-meta {
  opacity: 0.9;
}

.bubble-check.pending {
  display: inline-flex;
  align-items: center;
  opacity: 0.7;
}
.bubble-check.pending svg {
  display: block;
  animation: pending-pulse 1.8s ease-in-out infinite;
}
@keyframes pending-pulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

.bubble-check.error-icon {
  display: inline-flex;
  align-items: center;
  color: #dc2626;
}
.bubble-check.error-icon svg {
  display: block;
}

.bubble.error .bubble-text {
  opacity: 0.7;
}

/* =============================================
   Профиль — новый layout
   ============================================= */
.profile-body {
  padding: 24px 20px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.profile-top {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.profile-role-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.3px;
  background: var(--bg-app);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.profile-role-badge.admin {
  background: var(--accent);
  color: var(--accent-text);
  border-color: transparent;
}
.profile-role-badge.user {
  background: var(--bg-app);
  color: var(--text-secondary);
}

.profile-top {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.profile-role-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.3px;
  background: var(--bg-app);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.profile-role-badge.admin {
  background: var(--accent);
  color: var(--accent-text);
  border-color: transparent;
}
.profile-role-badge.user {
  background: var(--bg-app);
  color: var(--text-secondary);
}

.profile-fields {
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin: 0 auto 20px;
}

.profile-field {
  display: grid;
  grid-template-columns: 88px 1fr 28px;
  gap: 10px;
  align-items: center;
  background: var(--bg-white);
  padding: 10px 16px;
  min-height: 52px;
}

.profile-field-label {
  font-size: 13px;
  color: var(--text-muted);
  text-align: left;
}

.profile-field-value {
  font-size: 15px;
  color: var(--text);
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.profile-field-value.muted {
  color: var(--text-secondary);
}

.profile-field-edit {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: var(--text-muted);
  background: transparent;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
  padding: 0;
  line-height: 1;
  justify-self: end;
}
.profile-field-edit:hover {
  background: var(--bg-app);
  color: var(--text);
}
.profile-field-edit.hidden {
  visibility: hidden;
  pointer-events: none;
}

.profile-actions {
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0 auto;
}

/* Форма в модалке (используется в профиле) */
.admin-form {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.admin-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
}
.admin-form input,
.admin-form select {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 15px;
  background: var(--bg-white);
  color: var(--text);
}
.admin-form input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  outline: none;
}
.admin-error {
  color: var(--danger);
  font-size: 13px;
  min-height: 18px;
}

/* =============================================
   QR-модалка
   ============================================= */
.qr-modal {
  max-width: 380px;
}

.qr-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.qr-canvas {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: var(--bg-white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}

.qr-canvas svg {
  display: block;
}

.qr-url {
  font-size: 13px;
  color: var(--text-secondary);
  word-break: break-all;
  text-align: center;
  padding: 6px 12px;
  background: var(--bg-app);
  border-radius: var(--radius);
  width: 100%;
}

.qr-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.qr-hint {
  font-size: 12.5px;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.5;
  margin-top: 4px;
}

.user-item-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 600;
  background: var(--accent-soft);
  color: #8a6500;
  vertical-align: middle;
}

/* =============================================
   WELCOME-экран
   ============================================= */
.screen-welcome {
  background: #000;
  align-items: center;
  justify-content: center;
  gap: 32px;
  z-index: 200;
}

.welcome-logo {
  width: 220px;
  height: 220px;
  animation: welcome-pulse 700ms 1000ms ease-out;
}

.welcome-logo .fragment {
  transform-origin: center;
  opacity: 0;
  animation-duration: 900ms;
  animation-timing-function: cubic-bezier(0.22, 1, 0.36, 1);
  animation-fill-mode: forwards;
}

.frag-yellow {
  animation-name: fly-in-yellow;
  animation-delay: 50ms;
}
.frag-white {
  animation-name: fly-in-white;
  animation-delay: 150ms;
}

/* Жёлтая летит слева-снизу */
@keyframes fly-in-yellow {
  0%   { transform: translate(-260px, 260px); opacity: 0; }
  60%  { opacity: 1; }
  100% { transform: translate(0, 0); opacity: 1; }
}

/* Белая летит справа-сверху */
@keyframes fly-in-white {
  0%   { transform: translate(180px, -220px); opacity: 0; }
  60%  { opacity: 1; }
  100% { transform: translate(0, 0); opacity: 1; }
}

@keyframes welcome-pulse {
  0%   { filter: drop-shadow(0 0 0 rgba(254, 206, 26, 0)); }
  50%  { filter: drop-shadow(0 0 30px rgba(254, 206, 26, 0.7)); }
  100% { filter: drop-shadow(0 0 0 rgba(254, 206, 26, 0)); }
}

.welcome-title {
  color: #fff;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 0.5px;
  opacity: 0;
  animation: welcome-title-in 400ms 1050ms ease-out forwards;
}

@keyframes welcome-title-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.screen-welcome.fade-out {
  opacity: 0;
  transition: opacity 500ms ease-out;
}

/* =============================================
   Логотип на экране входа
   ============================================= */
.logo-circle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 88px;
  height: 88px;
  border-radius: 20px;
  background: #000;
  overflow: hidden;
}
.logo-circle svg {
  width: 100%;
  height: 100%;
  display: block;
}


/* =============================================
   Логотип на экране входа
   ============================================= */
.logo-circle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 88px;
  height: 88px;
  border-radius: 20px;
  background: #000;
  overflow: hidden;
}
.logo-circle svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* =============================================
   Форма регистрации — стилизованные поля
   ============================================= */
.register-step {
  display: flex;
  flex-direction: column;
  gap: 14px;
  animation: step-in 0.25s ease-out;
}
@keyframes step-in {
  from { opacity: 0; transform: translateX(8px); }
  to   { opacity: 1; transform: translateX(0); }
}

.register-step-hint {
  font-size: 14px;
  color: var(--text-secondary);
  text-align: center;
  line-height: 1.4;
  padding: 4px 8px 8px;
}

.register-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
  font-size: 14px;
  color: var(--text-secondary);
  background: none;
  border: none;
  cursor: pointer;
  transition: color 0.15s;
  align-self: flex-start;
}
.register-back:hover { color: var(--text); }

/* Поле формы */
.form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
}

.form-field-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  padding-left: 2px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.form-field-optional {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: lowercase;
  font-style: normal;
}

.form-field-input {
  position: relative;
  display: flex;
  align-items: center;
}

.form-field-input input {
  width: 100%;
  padding: 12px 14px;
  padding-right: 44px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 15px;
  background: var(--bg-white);
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
  color: var(--text);
}
.form-field-input input::placeholder {
  color: var(--text-muted);
}
.form-field-input input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* Иконка статуса (галочка / крестик) */
.form-field-icon {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}
.form-field-icon::before {
  content: '';
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background-repeat: no-repeat;
  background-position: center;
  background-size: 12px 12px;
}

/* Валидное состояние */
.form-field.valid .form-field-input input {
  border-color: #16a34a;
  background: #f0fdf4;
}
.form-field.valid .form-field-input input:focus {
  border-color: #16a34a;
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.15);
}
.form-field.valid .form-field-icon {
  opacity: 1;
}
.form-field.valid .form-field-icon::before {
  background-color: #16a34a;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='20 6 9 17 4 12'/></svg>");
}
.form-field.valid .form-field-hint {
  color: #16a34a;
}

/* Невалидное состояние */
.form-field.invalid .form-field-input input {
  border-color: #dc2626;
  background: #fef2f2;
}
.form-field.invalid .form-field-input input:focus {
  border-color: #dc2626;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.15);
}
.form-field.invalid .form-field-icon {
  opacity: 1;
}
.form-field.invalid .form-field-icon::before {
  background-color: #dc2626;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'><line x1='18' y1='6' x2='6' y2='18'/><line x1='6' y1='6' x2='18' y2='18'/></svg>");
}
.form-field.invalid .form-field-hint {
  color: #dc2626;
}

/* Проверка в процессе */
.form-field.checking .form-field-icon {
  opacity: 1;
}
.form-field.checking .form-field-icon::before {
  background-color: transparent;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238696a0' stroke-width='2.5' stroke-linecap='round'><path d='M21 12a9 9 0 1 1-6.219-8.56'/></svg>");
  animation: spin 0.8s linear infinite;
}

/* Подсказка под полем */
.form-field-hint {
  font-size: 12.5px;
  color: var(--text-muted);
  padding-left: 2px;
  min-height: 16px;
  transition: color 0.15s;
}

/* Глазик у пароля */
.form-field-toggle {
  position: absolute;
  right: 40px;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  padding: 0;
}
.form-field-toggle:hover {
  background: var(--bg-app);
  color: var(--text);
}

/* Кнопка submit, когда невалидна */
.btn-primary:disabled {
  background: var(--border);
  color: var(--text-muted);
  cursor: not-allowed;
  box-shadow: none;
}
.btn-primary:disabled:hover {
  background: var(--border);
}

/* Мобильный — компактнее */
@media (max-width: 360px) {
  .form-field-input input {
    padding: 11px 12px;
    padding-right: 40px;
    font-size: 14px;
  }
  .form-field-label {
    font-size: 12.5px;
  }
}

/* Префикс @ у поля логина */
.form-field-input.has-prefix input {
  padding-left: 34px;
}

.form-field-prefix {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 15px;
  font-weight: 600;
  pointer-events: none;
  user-select: none;
  transition: color 0.15s;
}

.form-field-input.has-prefix:focus-within .form-field-prefix {
  color: var(--accent-hover);
}

.form-field.valid .form-field-input.has-prefix:focus-within .form-field-prefix,
.form-field.valid .form-field-input.has-prefix .form-field-prefix {
  color: #16a34a;
}

/* =============================================
   Вложения: изображения и файлы
   ============================================= */

/* Пузырь с картинкой — без паддинга, картинка внутри с рамкой */
.bubble.image-bubble {
  padding: 4px;
  position: relative;
  overflow: hidden;
}

.bubble.image-bubble img {
  display: block;
  max-width: 260px;
  max-height: 340px;
  width: auto;
  height: auto;
  border-radius: 6px;
  cursor: pointer;
  background: #eee;
}

.bubble.image-bubble .bubble-meta {
  position: absolute;
  right: 10px;
  bottom: 8px;
  background: rgba(0, 0, 0, 0.42);
  color: #fff !important;
  padding: 2px 7px;
  border-radius: 10px;
  font-size: 10.5px;
  float: none;
  margin: 0;
  backdrop-filter: blur(2px);
}
.bubble.image-bubble .bubble-meta .bubble-check { color: #fff; }
.bubble.image-bubble .bubble-meta .bubble-check.read { color: #53bdeb; }

/* Пузырь с файлом */
.file-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
  min-width: 200px;
  cursor: pointer;
}

.file-icon {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-hover);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.file-icon svg { width: 20px; height: 20px; }

.file-info {
  flex: 1;
  min-width: 0;
}
.file-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.msg-row.own .file-name { color: var(--bubble-out-text); }
.file-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}
.msg-row.own .file-meta { color: rgba(0, 0, 0, 0.55); }

.file-dl {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: transparent;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
}
.file-dl:hover { background: var(--bg-app); }
.msg-row.own .file-dl { color: var(--bubble-out-text); }
.msg-row.own .file-dl:hover { background: rgba(0,0,0,0.08); }

/* Лайтбокс */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.95);
  z-index: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fade-in 0.15s ease-out;
}
.lightbox img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 4px;
}
.lightbox-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s;
}
.lightbox-close:hover { background: rgba(255, 255, 255, 0.25); }

/* Оверлей загрузки */
.upload-overlay {
  position: fixed;
  inset: 0;
  background: rgba(17, 27, 33, 0.5);
  z-index: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fade-in 0.1s ease-out;
}
.upload-progress {
  background: var(--bg-white);
  padding: 16px 24px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  font-size: 14px;
  color: var(--text);
  font-weight: 500;
}

/* Адаптив для узких экранов */
@media (max-width: 420px) {
  .message-form { padding: 4px 6px calc(4px + env(safe-area-inset-bottom)); gap: 4px; }
  .message-form .icon-btn { width: 36px; height: 36px; }
  .message-form .icon-btn svg { width: 20px; height: 20px; }
  .btn-send { width: 40px; height: 40px; }
  .btn-send svg { width: 20px; height: 20px; }
  .message-form input[type="text"] { padding: 8px 14px; font-size: 14px; }
}

/* =============================================
   Специальные пузыри (голос, файл) — flex-структура
   ============================================= */
.bubble.special-bubble {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 0;
}

.bubble.special-bubble .bubble-text {
  white-space: normal;
  width: 100%;
}

.bubble.special-bubble .bubble-meta {
  align-self: flex-end;
  float: none;
  margin: 0;
}

/* =============================================
   Универсальное пустое состояние
   ============================================= */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 24px;
  gap: 0;
}

.empty-state.compact {
  padding: 32px 20px;
  min-height: 0;
}

.empty-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-hover);
  margin-bottom: 20px;
  flex-shrink: 0;
}
.empty-icon svg {
  width: 40px;
  height: 40px;
  display: block;
  stroke-width: 1.6;
}

.empty-state.compact .empty-icon {
  width: 64px;
  height: 64px;
  margin-bottom: 14px;
}
.empty-state.compact .empty-icon svg {
  width: 28px;
  height: 28px;
}

.empty-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 8px;
  line-height: 1.25;
}
.empty-state.compact .empty-title {
  font-size: 17px;
  margin-bottom: 6px;
}

.empty-text {
  font-size: 14.5px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 0;
  max-width: 320px;
}
.empty-state.compact .empty-text {
  font-size: 13.5px;
  max-width: 260px;
}
.empty-text b {
  color: var(--accent-hover);
  font-weight: 700;
}

.empty-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 20px;
  padding: 11px 20px;
  background: var(--accent);
  color: var(--accent-text);
  border-radius: var(--radius-pill);
  font-size: 14.5px;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(254, 206, 26, 0.35);
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
  cursor: pointer;
  border: none;
}
.empty-btn:hover {
  background: var(--accent-hover);
  box-shadow: 0 6px 16px rgba(254, 206, 26, 0.45);
}
.empty-btn:active {
  transform: scale(0.97);
}
.empty-btn svg {
  width: 16px;
  height: 16px;
  display: block;
}

/* Иконка в чате — большая SVG-иллюстрация (оставляем) */
.chat-list-empty .empty-illustration { margin-bottom: 4px; }

/* =============================================
   Кнопка «вниз» при пролистывании истории
   ============================================= */
.scroll-down-btn {
  position: absolute;
  right: 16px;
  bottom: calc(74px + env(safe-area-inset-bottom));
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--bg-white);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.18);
  cursor: pointer;
  border: none;
  padding: 0;
  z-index: 20;

  /* Скрытое состояние + плавные переходы */
  opacity: 0;
  transform: scale(0.85) translateY(6px);
  pointer-events: none;
  transition:
    opacity 0.22s ease,
    transform 0.22s ease,
    background 0.15s;
}

.scroll-down-btn.visible {
  opacity: 1;
  transform: scale(1) translateY(0);
  pointer-events: auto;
}

.scroll-down-btn:hover { background: #f5f5f5; }
.scroll-down-btn:active { transform: scale(0.94); }
.scroll-down-btn svg { display: block; }

/* Бейдж непрочитанных на кнопке — тоже с плавностью */
.scroll-down-badge {
  position: absolute;
  top: -4px;
  left: -4px;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  border: 2px solid var(--bg-white);
  box-sizing: border-box;
  transition: opacity 0.22s ease, transform 0.22s ease;
}

.scroll-down-badge.hidden {
  display: inline-flex;        /* перебиваем глобальный .hidden */
  opacity: 0;
  transform: scale(0.7);
  pointer-events: none;
}

/* Позиционирование в десктопной раскладке */
@media (min-width: 769px) {
  .scroll-down-btn {
    right: calc(50vw - 384px + 16px);
  }
}

/* =============================================
   Кликабельные элементы в шапке чата
   ============================================= */
.chat-header .clickable {
  cursor: pointer;
  transition: opacity 0.15s;
}
.chat-header .clickable:active {
  opacity: 0.7;
}

/* =============================================
   Пункты меню с SVG-иконками
   ============================================= */
.bubble-menu button {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  text-align: left;
  width: 100%;
}

.bubble-menu .menu-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: var(--text-secondary);
}
.bubble-menu .menu-icon svg {
  display: block;
}

.bubble-menu .menu-label {
  flex: 1;
  min-width: 0;
}

.bubble-menu button.danger .menu-icon {
  color: var(--danger);
}
.bubble-menu button.danger .menu-label {
  color: var(--danger);
}

/* =============================================
   Bottom sheet (меню долгого нажатия)
   ============================================= */
.sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
  animation: sheet-fade-in 0.2s ease-out;
}

.sheet {
  width: 100%;
  max-width: 480px;
  background: var(--bg-white);
  border-radius: 16px 16px 0 0;
  padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
  animation: sheet-slide-in 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.12);
}

@keyframes sheet-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes sheet-slide-in {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.sheet-handle {
  width: 40px;
  height: 4px;
  border-radius: 2px;
  background: rgba(0, 0, 0, 0.15);
  margin: 8px auto 12px;
}

.sheet-title {
  padding: 0 20px 12px;
  font-size: 14px;
  color: var(--text-muted);
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}

.sheet-action {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 14px 20px;
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  text-align: left;
  background: none;
  border: none;
  cursor: pointer;
  transition: background 0.12s;
}
.sheet-action:hover { background: var(--bg-app); }
.sheet-action:active { background: var(--accent-soft); }

.sheet-action svg {
  flex-shrink: 0;
  color: var(--text-secondary);
}

.sheet-action.danger {
  color: var(--danger);
}
.sheet-action.danger svg {
  color: var(--danger);
}

.sheet-action.cancel {
  justify-content: center;
  color: var(--text-secondary);
  border-top: 1px solid var(--border);
  margin-top: 4px;
  padding-top: 14px;
  font-weight: 500;
}

/* =============================================
   Кнопка архива в шапке
   ============================================= */
.app-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

#archive-btn {
  position: relative;
}

.icon-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 10px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--bg-white);
  box-sizing: content-box;
  line-height: 1;
}

.chat-item,
.msg-row,
.bubble {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

/* =============================================
   Модалка пересылки сообщения
   ============================================= */
.forward-preview {
  padding: 12px 20px;
  background: var(--bg-app);
  border-bottom: 1px solid var(--border);
}
.forward-preview-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent-hover);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 4px;
}
.forward-preview-text {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

/* Метка «Переслано» */
.forward-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-style: italic;
  color: var(--text-muted);
  margin-bottom: 4px;
  padding-left: 1px;
}
.msg-row.own .forward-label {
  color: rgba(0, 0, 0, 0.5);
}
.forward-label svg {
  display: block;
  flex-shrink: 0;
}

/* =============================================
   Свайп влево на сообщении → ответ
   ============================================= */
.msg-row {
  position: relative;
}

.bubble {
  position: relative;
  z-index: 1;
  will-change: transform;
}

.swipe-reply-hint {
  position: absolute;
  top: 50%;
  right: 8px;
  transform: translateY(-50%) scale(0.6);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-text);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  z-index: 0;
  transition: opacity 0.15s ease, transform 0.15s ease;
  will-change: opacity, transform;
}

.swipe-reply-hint svg {
  display: block;
}

.msg-row.swiping .swipe-reply-hint {
  opacity: 0.55;
  transform: translateY(-50%) scale(0.9);
}

.msg-row.swiped .swipe-reply-hint {
  opacity: 1;
  transform: translateY(-50%) scale(1.1);
}

.profile-top .avatar {
  transition: transform 0.15s, box-shadow 0.15s;
}
.profile-top .avatar[onclick]:hover {
  transform: scale(1.03);
}

/* =============================================
   Аватар в профиле + кнопка удаления
   ============================================= */
.avatar-wrapper {
  position: relative;
  display: inline-block;
}

.avatar-wrapper .avatar {
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}
.avatar-wrapper .avatar:hover {
  transform: scale(1.03);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

.avatar-remove {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--danger);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--bg-white);
  cursor: pointer;
  padding: 0;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  transition: transform 0.15s, background 0.15s;
}
.avatar-remove:hover {
  background: #b91c1c;
  transform: scale(1.05);
}
.avatar-remove:active {
  transform: scale(0.95);
}
.avatar-remove svg { display: block; }

/* =============================================
   Модалка обрезки аватара
   ============================================= */
.avatar-crop-modal {
  max-width: 460px;
  padding: 0;
  overflow: hidden;
  background: #111;
}

.avatar-crop-header {
  background: var(--bg-white);
  border-bottom: none;
  padding: 10px 12px;
  gap: 8px;
}
.avatar-crop-header h2 {
  flex: 1;
  text-align: center;
  font-size: 16px;
  font-weight: 600;
}

.avatar-crop-save {
  width: auto !important;
  padding: 8px 18px !important;
  font-size: 14px !important;
  border-radius: 20px !important;
  font-weight: 600;
}

.avatar-crop-stage {
  position: relative;
  width: min(100%, 70vh);
  margin: 0 auto;
  aspect-ratio: 1;
  background: #111;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: grab;
}
.avatar-crop-stage:active { cursor: grabbing; }

.avatar-crop-stage img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  transform-origin: center center;
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
  max-width: none;
  max-height: none;
  will-change: transform;
}

.avatar-crop-mask {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 90%;
  height: 90%;
  border-radius: 50%;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.6);
  border: 2px solid rgba(255, 255, 255, 0.9);
  pointer-events: none;
}

.avatar-crop-zoom-wrap {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 20px 24px;
  background: var(--bg-white);
}
.avatar-crop-zoom-wrap svg {
  color: var(--text-muted);
  flex-shrink: 0;
  display: block;
}

.avatar-crop-zoom-wrap input[type="range"] {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  outline: none;
}
.avatar-crop-zoom-wrap input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--bg-white);
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
  cursor: pointer;
}
.avatar-crop-zoom-wrap input[type="range"]::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--bg-white);
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
  cursor: pointer;
}

/* =============================================
   Редактирование сообщения
   ============================================= */
.edit-wrap {
  min-width: 220px;
  max-width: 100%;
}

.edit-textarea {
  width: 100%;
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 14.5px;
  line-height: 1.35;
  resize: none;
  min-height: 40px;
  max-height: 300px;
  font-family: inherit;
  color: var(--text);
  outline: none;
  box-sizing: border-box;
}
.edit-textarea:focus { border-color: var(--accent); }

.edit-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 6px;
}

.edit-actions button {
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: background 0.15s;
}

.edit-save {
  background: var(--accent);
  color: var(--accent-text);
}
.edit-save:hover { background: var(--accent-hover); }

.edit-cancel {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.edit-cancel:hover { background: var(--bg-app); }

/* Метка «изменено» */
.edited-label {
  font-size: 10.5px;
  color: var(--text-muted);
  margin-left: 3px;
}
.msg-row.own .edited-label {
  color: rgba(0, 0, 0, 0.45);
}

/* =============================================
   Реакции на сообщения
   ============================================= */

/* =============================================
   Реакции на сообщения (TG-стиль с блюром)
   ============================================= */

/* Затемнение с блюром */
.reaction-backdrop {
  position: fixed;
  inset: 0;
  z-index: 299;
  background: rgba(0, 0, 0, 0.18);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  animation: backdrop-fade-in 0.15s ease-out;
  pointer-events: auto;
}

@keyframes backdrop-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* Плавающая панель эмодзи */
.reaction-bar {
  position: fixed;
  z-index: 300;
  display: flex;
  align-items: center;
  gap: 2px;
  background: var(--bg-white);
  border-radius: 28px;
  padding: 6px;
  box-shadow: 0 6px 28px rgba(0, 0, 0, 0.28);
  animation: reaction-bar-in 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: auto;
  max-width: calc(100vw - 16px);
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
}
.reaction-bar::-webkit-scrollbar { display: none; }

@keyframes reaction-bar-in {
  from { opacity: 0; transform: translateY(6px) scale(0.85); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.reaction-btn {
  width: 40px;
  height: 40px;
  min-width: 40px;
  border-radius: 50%;
  font-size: 22px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
  transition: transform 0.12s, background 0.12s;
  -webkit-tap-highlight-color: transparent;
}
.reaction-btn:hover {
  background: var(--bg-app);
  transform: scale(1.15);
}
.reaction-btn:active {
  transform: scale(0.95);
}
.reaction-btn.selected {
  background: var(--accent-soft);
}

/* Чипы реакций под сообщением */
.reaction-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.06);
  border: 1px solid transparent;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.12s, transform 0.1s;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.reaction-chip:hover { background: rgba(0, 0, 0, 0.1); }
.reaction-chip:active { transform: scale(0.94); }

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

.reaction-chip.me {
  background: var(--accent-soft);
  border-color: var(--accent);
}
.reaction-chip.me .reaction-count {
  color: var(--accent-hover);
}

/* На своём жёлтом пузыре — чипы ярче */
.msg-row.own .reaction-chip {
  background: rgba(255, 255, 255, 0.6);
}
.msg-row.own .reaction-chip:hover {
  background: rgba(255, 255, 255, 0.85);
}
.msg-row.own .reaction-chip.me {
  background: rgba(255, 255, 255, 0.95);
  border-color: rgba(0, 0, 0, 0.2);
}

/* Клон выделенного сообщения поверх блюра */
.bubble-clone {
  position: fixed;
  z-index: 450;
  pointer-events: none;
  margin: 0 !important;
  transform: none !important;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25) !important;
}

/* =============================================
   Реакции внутри bubble (на строке с meta, слева)
   ============================================= */
.bubble-reactions {
  display: inline-flex;
  gap: 3px;
  align-items: center;
  float: left;
  margin: 4px 8px -2px 0;
  max-width: 100%;
  flex-wrap: nowrap;
  overflow: hidden;
}

.bubble-reactions .reaction-chip {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 1px 6px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.06);
  border: 1px solid transparent;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.12s, transform 0.1s;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.bubble-reactions .reaction-chip:hover {
  background: rgba(0, 0, 0, 0.1);
}
.bubble-reactions .reaction-chip:active {
  transform: scale(0.94);
}

.bubble-reactions .reaction-emoji {
  font-size: 14px;
  line-height: 1;
}

.bubble-reactions .reaction-count {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-secondary);
  min-width: 8px;
  text-align: center;
}

/* Своё сообщение (жёлтое) */
.msg-row.own .bubble-reactions .reaction-chip {
  background: rgba(255, 255, 255, 0.75);
}
.msg-row.own .bubble-reactions .reaction-chip:hover {
  background: rgba(255, 255, 255, 0.95);
}
.msg-row.own .bubble-reactions .reaction-chip.me {
  background: rgba(255, 255, 255, 0.95);
  border-color: rgba(0, 0, 0, 0.18);
}
.msg-row.own .bubble-reactions .reaction-chip.me .reaction-count {
  color: rgba(0, 0, 0, 0.55);
}

/* Чужое сообщение (белое) */
.msg-row:not(.own) .bubble-reactions .reaction-chip.me {
  background: var(--accent-soft);
  border-color: var(--accent);
}
.msg-row:not(.own) .bubble-reactions .reaction-chip.me .reaction-count {
  color: var(--accent-hover);
}

/* =============================================
   Full-screen поиск (как в TG)
   ============================================= */
.search-fullscreen {
  position: fixed;
  inset: 0;
  background: var(--bg-white);
  z-index: 500;
  display: flex;
  flex-direction: column;
  animation: search-fs-in 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes search-fs-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.search-fs-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 8px 8px 4px;
  background: var(--bg-white);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.search-fs-header input {
  flex: 1;
  padding: 10px 14px;
  background: var(--bg-app);
  border-radius: 20px;
  font-size: 15px;
  border: none;
  outline: none;
  min-width: 0;
}
.search-fs-header input:focus {
  background: var(--bg-white);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.search-fs-body {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
}

.search-fs-tabs {
  display: flex;
  background: var(--bg-white);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
  flex-shrink: 0;
}

.search-fs-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 10px 4px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 500;
  transition: color 0.15s;
}
.search-fs-tab svg { display: block; }
.search-fs-tab.active {
  color: var(--accent-hover);
  font-weight: 600;
}

.global-search-result {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.12s;
}
.global-search-result:hover { background: var(--bg-app); }
.global-search-result:active { background: #ececec; }

.global-search-result .avatar {
  flex-shrink: 0;
  margin-top: 2px;
}

.global-search-result-body {
  flex: 1;
  min-width: 0;
}

.global-search-author {
  font-weight: 600;
  color: var(--text-secondary);
  margin-right: 4px;
}

.search-section-title {
  padding: 10px 16px 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

/* =============================================
   Оверлей превью выбранных файлов
   ============================================= */
.attach-preview {
  position: fixed;
  inset: 0;
  background: #111;
  z-index: 600;
  display: flex;
  flex-direction: column;
  animation: attach-fs-in 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes attach-fs-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.attach-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 8px;
  color: #fff;
  flex-shrink: 0;
  padding-top: calc(10px + env(safe-area-inset-top));
}
.attach-preview-header .icon-btn {
  color: #fff;
}
.attach-preview-header .icon-btn:hover { background: rgba(255,255,255,0.1); }
.attach-preview-count {
  font-size: 14px;
  font-weight: 500;
  opacity: 0.9;
}

.attach-preview-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

#attach-preview-content {
  width: 100%;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Карусель фото */
.attach-carousel {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  width: 100%;
  height: 100%;
}
.attach-carousel::-webkit-scrollbar { display: none; }

.attach-carousel-item {
  flex: 0 0 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  scroll-snap-align: start;
  position: relative;
  min-width: 0;
  padding: 8px; 
  box-sizing: border-box;
}
.attach-carousel-item img,
.attach-carousel-item video {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.attach-carousel-item .attach-remove {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  cursor: pointer;
  padding: 0;
  backdrop-filter: blur(4px);
  transition: background 0.15s;
  z-index: 10;
}
.attach-carousel-item .attach-remove:hover { background: rgba(220, 38, 38, 0.85); }

.attach-carousel,
.attach-carousel-item,
.attach-video-poster,
.attach-video-poster img {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.attach-carousel-item > img,
.attach-carousel-item > video,
.attach-video-poster {
  border-radius: 12px;
  overflow: hidden;
}

/* Список файлов (не картинок) */
.attach-files-list {
  width: 100%;
  max-width: 500px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
  max-height: 100%;
}
.attach-file-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: rgba(255,255,255,0.08);
  border-radius: 10px;
  color: #fff;
  font-size: 14px;
}
.attach-file-item .file-icon {
  width: 34px;
  height: 34px;
  background: rgba(255,255,255,0.15);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.attach-file-item .file-icon svg { width: 18px; height: 18px; }
.attach-file-item .file-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.attach-file-item .attach-remove-small {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
}
.attach-file-item .attach-remove-small:hover { background: rgba(220, 38, 38, 0.7); }

/* Точки-индикатор */
.attach-preview-dots {
  display: flex;
  gap: 6px;
  justify-content: center;
  padding: 12px 0;
  flex-shrink: 0;
  width: 100%;
}
.attach-preview-dots .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255,255,255,0.3);
  transition: background 0.15s, transform 0.15s;
}
.attach-preview-dots .dot.active {
  background: #fff;
  transform: scale(1.3);
}
.attach-preview-dots:empty { display: none; }

/* Футер с подписью */
.attach-preview-footer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom));
  background: #1e1e1e;
  flex-shrink: 0;
}
.attach-preview-footer textarea {
  flex: 1;
  background: #2a2a2a;
  color: #fff;
  border: none;
  border-radius: 20px;
  padding: 10px 16px;
  font-size: 15px;
  line-height: 1.4;
  resize: none;
  min-height: 42px;
  max-height: 120px;
  outline: none;
  font-family: inherit;
}
.attach-preview-footer textarea::placeholder { color: rgba(255,255,255,0.5); }
.attach-preview-footer .btn-send {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
}


.attach-video-quality {
  position: absolute;
  bottom: 52px;              /* над точками */
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 20;
  pointer-events: auto;
}
.attach-video-quality.hidden { display: none; }

.attach-video-quality-label {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.65);
  margin-right: 2px;
}

.vq-chip {
  border: 0;
  background: rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.9);
  font-size: 12.5px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit;
  transition: all .15s;
}
.vq-chip.active {
  background: var(--accent);
  color: #111;
}
.vq-chip.disabled {
  opacity: 0.35;
  cursor: not-allowed;
}


/* =============================================
   Альбом (несколько фото в чате) — карусель
   ============================================= */
.bubble.album-bubble {
  padding: 4px;
  overflow: hidden;
}

.bubble.album-bubble .album-fan-caption {
  margin-top: 10px;
}

/* =============================================
   Веер-стопка для альбома (как в iMessage)
   ============================================= */
.album-fan {
  position: relative;
  width: 270px;   /* 240 (карта) + 30 (сдвиг) */
  height: 330px;  /* 300 + 30 */
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: pan-y;
}

.album-fan-card {
  position: absolute;
  top: 0;
  left: 0;
  width: 240px;    /* фикс. ширина, не 100% */
  height: 300px;   /* фикс. высота, не 100% */
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
  overflow: hidden;
  will-change: transform;
  transition: transform 0.32s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
  transform-origin: center center;
  backface-visibility: hidden;
}

.album-fan-card.dragging {
  transition: none !important;
}

.album-fan-card.top {
  pointer-events: auto;
}

.album-fan-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
  -webkit-user-drag: none;
}

.album-fan-card > img,
.album-fan-card > video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.video-thumb {
  object-fit: cover;
}

.album-fan-counter {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  z-index: 100;
  backdrop-filter: blur(4px);
  pointer-events: none;
}

.album-fan-dots {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 5px;
  background: rgba(0, 0, 0, 0.4);
  padding: 5px 10px;
  border-radius: 12px;
  z-index: 100;
  backdrop-filter: blur(4px);
  pointer-events: none;
}
.album-fan-dots .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.5);
  transition: background 0.15s, transform 0.15s;
}
.album-fan-dots .dot.active {
  background: #fff;
  transform: scale(1.2);
}

.album-fan-caption {
  margin-top: 8px;
  padding: 0 4px;
  font-size: 14.5px;
  line-height: 1.35;
  word-break: break-word;
}

.album-fan-play {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 5;
}

.album-fan-duration {
  position: absolute;
  right: 8px;
  bottom: 8px;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  font-size: 11px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  z-index: 5;
}

/* В тёмном оверлее превью — белые названия файлов */
.attach-preview .attach-file-item .file-name {
  color: #fff;
}
.attach-preview .attach-file-item .file-meta {
  color: rgba(255, 255, 255, 0.6);
}

/* Заглушка HEIC в превью */
.attach-heic-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  height: 100%;
  padding: 30px;
  color: rgba(255, 255, 255, 0.75);
  text-align: center;
}
.attach-heic-placeholder svg {
  opacity: 0.5;
}
.attach-heic-name {
  font-size: 14px;
  font-weight: 500;
  color: #fff;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.attach-heic-hint {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.5);
}

/* =============================================
   Сетка альбома
   ============================================= */
.album-grid-modal {
  max-width: 500px;
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: 85vh;
}

/* Задний фон с блюром — только для модалки альбома */
#modal-album-grid {
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

/* Акцент шапки — легкий жёлтый */
#modal-album-grid .modal-header {
  background: rgba(254, 206, 26, 0.14);
  border-bottom: 1px solid rgba(254, 206, 26, 0.28);
}
#modal-album-grid .modal-header h2 {
  color: var(--text);
}

.album-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 10px;
  overflow-y: auto;
  flex: 1;
  background: #ffffff;
  min-height: 200px;
}

.album-grid-item {
  position: relative;
  aspect-ratio: 1;
  background: #222;
  overflow: hidden;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  border-radius: 10px;
}

.album-grid-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
  -webkit-user-drag: none;
  border-radius: 10px; 
}

.album-grid-item.selected::after {
  content: '';
  position: absolute;
  inset: 0;
  border: 3px solid var(--accent);
  background: rgba(254, 206, 26, 0.2);
  pointer-events: none;
  border-radius: 10px; 
}

.album-grid-item.selected .album-grid-check {
  display: flex;
}

.album-grid-check {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-text);
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  z-index: 2;
  pointer-events: none;
}

.album-grid-selection {
  padding: 12px 16px;
  background: var(--bg-white);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.album-grid-selection .btn-primary {
  width: 100%;
}

/* =============================================
   Полноэкранный просмотр фото
   ============================================= */
.photo-viewer {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  z-index: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: photo-viewer-in 0.2s ease-out;
}

@keyframes photo-viewer-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* Кнопка закрытия — справа сверху */
.photo-viewer-close {
  position: absolute;
  top: calc(16px + env(safe-area-inset-top));
  right: 16px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  cursor: pointer;
  z-index: 3;
  backdrop-filter: blur(6px);
  transition: background 0.15s;
}
.photo-viewer-close:hover { background: rgba(255, 255, 255, 0.25); }

/* Кнопка скачивания — по центру внизу, над счётчиком */
.photo-viewer-download {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(72px + env(safe-area-inset-bottom));
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  cursor: pointer;
  z-index: 3;
  backdrop-filter: blur(6px);
  transition: background 0.15s, transform 0.12s;
}
.photo-viewer-download:hover { background: rgba(255, 255, 255, 0.28); }
.photo-viewer-download:active { transform: translateX(-50%) scale(0.94); }
.photo-viewer-download svg { display: block; width: 24px; height: 24px; }

.photo-viewer-carousel {
  display: flex;
  width: 100%;
  height: 100%;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.photo-viewer-carousel::-webkit-scrollbar { display: none; }

.photo-viewer-item {
  flex: 0 0 100%;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  scroll-snap-align: start;
}
.photo-viewer-item img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
}
.photo-viewer-item video {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
}

.photo-viewer-counter {
  position: absolute;
  bottom: calc(20px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  color: #fff;
  background: rgba(0, 0, 0, 0.45);
  padding: 5px 14px;
  border-radius: 14px;
  font-size: 13px;
  font-weight: 500;
  backdrop-filter: blur(6px);
  z-index: 2;
}

.bubble.album-bubble {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 6px 8px 8px;
  overflow: hidden;
  max-width: 320px;
}

.bubble.album-bubble .album-fan {
  align-self: flex-start;
  margin-bottom: 6px;
}

.bubble.album-bubble .bubble-text.album-fan-caption {
  display: block;
  width: 100%;
  float: none;
  clear: both;
  margin: 8px 0 0 0;
  padding: 0 2px;
  white-space: pre-wrap;
  word-break: break-word;
}

.bubble.album-bubble .bubble-meta {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 3px;
  float: none;
  clear: both;
  width: 100%;
  margin: 8px 0 0 0;
  padding: 0 2px;
}

/* Колокольчик уведомлений в шапке чата */
#chat-notify-btn {
  color: var(--text-on-dark);
  position: relative;
}
#chat-notify-btn.muted {
  color: rgba(255, 255, 255, 0.45);
}

/* Скрываем пустое сообщение об ошибке, чтобы не занимало место */
#delete-error:empty {
  display: none;
}
#delete-error {
  margin: 0;
  min-height: 0;
}
/* ==============================================
   PWA Hint (bottom sheet, установка на iOS)
   ============================================== */

.pwa-hint-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease;
}
.pwa-hint-overlay.is-open {
  opacity: 1;
  pointer-events: auto;
}

.pwa-hint-card {
  position: relative;
  width: 100%;
  max-width: 500px;
  max-height: 92vh;
  background: #fff;
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(100%);
  transition: transform .3s cubic-bezier(.3, .7, .4, 1);
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.pwa-hint-overlay.is-open .pwa-hint-card {
  transform: translateY(0);
}

/* Ручка */
.pwa-hint-handle {
  width: 40px;
  height: 4px;
  border-radius: 2px;
  background: #d4d4d8;
  margin: 10px auto 0;
  flex-shrink: 0;
}

.pwa-hint-slides {
  display: flex;
  transition: transform .28s cubic-bezier(.3, .7, .4, 1);
  will-change: transform;
}

.pwa-hint-slide {
  flex: 0 0 100%;
  padding: 12px 20px 4px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

/* Обёртка строго по размеру картинки */
.pwa-hint-image-wrap {
  position: relative;
  display: inline-block;
  max-width: 100%;
  border-radius: 14px;
  overflow: hidden;
  background: transparent;
  line-height: 0;
}
.pwa-hint-image-wrap img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 52vh;
}

/* Подсветка — «вырезает» окно в затемнении через box-shadow */
.pwa-hint-highlight {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: var(--w);
  height: var(--h);
  border-radius: var(--r, 12px);
  background: transparent;
  z-index: 2;
  pointer-events: none;
  animation: pwaHintPulse 1.6s ease-in-out infinite;
}

@keyframes pwaHintPulse {
  0%, 100% {
    box-shadow:
      0 0 0 9999px rgba(0, 0, 0, 0.42),
      0 0 0 0 rgba(254, 206, 26, 0.65);
  }
  50% {
    box-shadow:
      0 0 0 9999px rgba(0, 0, 0, 0.42),
      0 0 0 12px rgba(254, 206, 26, 0);
  }
}

.pwa-hint-title {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: #FECE1A;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.pwa-hint-text {
  margin: 0;
  text-align: center;
  font-size: 16px;
  line-height: 1.35;
  color: #1a1a1a;
}
.pwa-hint-text b { color: #111; }

.pwa-hint-footer {
  padding: 10px 20px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid #eee;
}

.pwa-hint-dots {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.pwa-hint-dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #d4d4d8;
  transition: background .2s, width .2s;
}
.pwa-hint-dots span.active {
  background: #FECE1A;
  width: 20px;
  border-radius: 4px;
}

.pwa-hint-btn {
  border: 0;
  background: #FECE1A;
  color: #111;
  font-weight: 600;
  font-size: 15px;
  padding: 12px 20px;
  border-radius: 12px;
  cursor: pointer;
  min-width: 110px;
}
.pwa-hint-btn:active { transform: scale(.97); }

.pwa-hint-optout {
  padding: 4px 20px 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 13px;
  color: #666;
  cursor: pointer;
  user-select: none;
}
.pwa-hint-optout input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: #FECE1A;
  cursor: pointer;
  flex-shrink: 0;
}

/* ==============================================
   VIDEO: предпросмотр, отправка, плеер
   ============================================== */

/* --- Bubble в чате --- */
.video-bubble { padding: 4px !important; }
.video-thumb-wrap {
  position: relative;
  display: inline-block;
  max-width: 280px;
  border-radius: 12px;
  overflow: hidden;
  background: #000;
  cursor: pointer;
  line-height: 0;
}
.video-thumb {
  display: block;
  max-width: 100%;
  max-height: 400px;
  width: auto;
  height: auto;
}
.video-thumb-empty {
  width: 200px;
  height: 150px;
  background: #1a1a1a;
}
.video-play-btn {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.video-duration {
  position: absolute;
  right: 8px;
  bottom: 8px;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  font-size: 11px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

/* --- Модалка предпросмотра --- */
.video-preview-modal { max-width: 480px; }
.video-preview-body {
  padding: 0 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.video-preview-body video {
  width: 100%;
  max-height: 40vh;
  background: #000;
  border-radius: 12px;
}
.video-preview-info {
  font-size: 13px;
  color: var(--text-secondary);
  padding: 0 4px 4px;
}
.video-quality-picker {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}
.video-quality-title {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}
.video-quality-options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.video-quality-option {
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: #fff;
  padding: 10px 8px;
  cursor: pointer;
  text-align: center;
  font-family: inherit;
  transition: all .15s;
}
.video-quality-option.active {
  border-color: var(--accent);
  background: #fffbe8;
}
.video-quality-option.disabled {
  opacity: .45;
  cursor: not-allowed;
}
.vq-label {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}
.vq-hint {
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}
.vq-size {
  font-size: 11px;
  color: var(--accent);
  font-weight: 500;
}
.video-preview-footer {
  display: flex;
  gap: 10px;
  padding: 12px 16px 16px;
}
.video-preview-footer button { flex: 1; }

/* --- Оверлей прогресса --- */
.video-upload-box {
  background: #fff;
  border-radius: 16px;
  padding: 24px;
  width: calc(100% - 48px);
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: center;
}
.video-upload-text {
  font-size: 15px;
  color: var(--text);
  font-weight: 500;
}
.video-upload-bar-wrap {
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: var(--border);
  overflow: hidden;
}
.video-upload-bar {
  height: 100%;
  width: 0;
  background: var(--accent);
  border-radius: 3px;
  transition: width .2s;
}
.video-upload-box button { width: 100%; }


/* Плейсхолдер видео в превью выбора */
.attach-video-poster {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  aspect-ratio: 4 / 3;
  max-height: 60vh;
  background: #1a1a1a;
  border-radius: 12px;
  overflow: hidden;
}
.attach-video-poster img,
.attach-video-poster video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 12px;
}
.attach-video-poster-placeholder {
  position: absolute;
  inset: 0;
  background: #1a1a1a;
}

.attach-video-poster-img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 12px;
}

.video-preview-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.96);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fade-in 0.15s ease-out;
}
.video-preview-overlay-player {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  display: block;
}
.video-preview-overlay-close {
  position: absolute;
  top: calc(16px + env(safe-area-inset-top));
  right: 16px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  border: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  padding: 0;
}
.video-preview-overlay-close:hover { background: rgba(255, 255, 255, 0.25); }
.video-preview-overlay-close svg { display: block; }

.attach-video-poster-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 12px;
}

/* =============================================
   Закреплённое сообщение
   ============================================= */
.chat-pinned {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  flex-shrink: 0;
  cursor: pointer;
  transition: background 0.1s;
}
.chat-pinned:active { background: #f5f5f5; }
.chat-pinned.hidden { display: none; }

.chat-pinned-icon {
  flex-shrink: 0;
  color: var(--accent-hover);
  display: flex;
  align-items: center;
  justify-content: center;
}
.chat-pinned-icon svg { display: block; }

.chat-pinned-body {
  flex: 1;
  min-width: 0;
}
.chat-pinned-title {
  font-size: 11.5px;
  color: var(--accent-hover);
  font-weight: 600;
  margin-bottom: 1px;
}
.chat-pinned-text {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 13.5px;
  color: var(--text);
  min-width: 0;
}
.chat-pinned-text > svg {
  flex-shrink: 0;
  color: var(--text-secondary);
}
.chat-pinned-text > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  flex: 1;
}

.chat-pinned-close {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: transparent;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  cursor: pointer;
  transition: background 0.1s;
}
.chat-pinned-close:hover { background: var(--bg-app); }
.chat-pinned-close svg { display: block; }

/* =============================================
   ЭКРАНЫ НАСТРОЕК
   ============================================= */
.screen-settings,
.screen-my-profile {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  max-width: none !important;
  height: 100dvh !important;
  background: var(--bg-white);
}

#screen-my-profile     { z-index: 80; }
#screen-settings       { z-index: 90; }
#screen-privacy        { z-index: 95; }
#screen-data           { z-index: 95; }
#screen-profile-edit   { z-index: 100; }

@media (min-width: 769px) {
  .screen-settings,
  .screen-my-profile {
    left: 50% !important;
    right: auto !important;
    width: 768px;
    transform: translateX(-50%);
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.08);
  }
}

.settings-header {
  display: flex;
  align-items: center;
  gap: 8px;
  height: var(--header-h);
  padding: 0 4px 0 4px;
  background: var(--bg-white);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.settings-header h2 {
  flex: 1;
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  text-align: left;
  padding-left: 4px;
}
.settings-header-spacer {
  width: 40px;
  flex-shrink: 0;
}

.settings-list {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 4px 0 24px;
}

.settings-item {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 14px 16px;
  background: transparent;
  border: none;
  text-align: left;
  cursor: pointer;
  transition: background 0.12s;
  border-bottom: 1px solid var(--border);
}
.settings-item:hover { background: #f5f6f6; }
.settings-item:active { background: #ececec; }
.settings-item.settings-item-static {
  cursor: default;
}
.settings-item.settings-item-static:hover { background: transparent; }

.settings-item-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  color: var(--text-secondary);
  flex-shrink: 0;
}
.settings-item-icon svg { display: block; }

.settings-item-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.settings-item-label {
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
}
.settings-item-hint {
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.3;
}

.settings-item-chevron {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  flex-shrink: 0;
}
.settings-item-chevron svg { display: block; }

.settings-note {
  padding: 16px 20px 8px;
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 0;
}

/* =============================================
   Тумблер
   ============================================= */
.toggle {
  position: relative;
  width: 48px;
  height: 28px;
  border-radius: 14px;
  background: var(--border);
  border: none;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: background 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}
.toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s ease;
}
.toggle.on {
  background: var(--accent);
}
.toggle.on::after {
  transform: translateX(20px);
}
.toggle.disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

/* =============================================
   МОДАЛКА «О ПРИЛОЖЕНИИ»
   ============================================= */
.about-modal {
  max-width: 360px;
}
.about-body {
  padding: 28px 24px 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.about-logo {
  width: 80px;
  height: 80px;
  border-radius: 20px;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  margin-bottom: 4px;
}
.about-logo svg {
  width: 100%;
  height: 100%;
  display: block;
}
.about-name {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.3px;
}
.about-version {
  font-size: 14px;
  color: var(--text-secondary);
}
.about-company {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* =============================================
   ЭКРАН: Мой профиль
   ============================================= */
.screen-my-profile {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  max-width: none !important;
  height: 100dvh !important;
  background: var(--bg-white);
  z-index: 80;
}

@media (min-width: 769px) {
  .screen-my-profile {
    left: 50% !important;
    right: auto !important;
    width: 768px;
    transform: translateX(-50%);
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.08);
  }
}

.my-profile-body {
  flex: 1;
  overflow-y: auto;
  padding: 28px 20px 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.my-profile-top {
  margin-bottom: 18px;
}

.my-profile-top .avatar {
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}
.my-profile-top .avatar:hover {
  transform: scale(1.03);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

/* Имя — крупно */
.my-profile-name {
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
  text-align: center;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0 12px;
}

/* @ник · телефон — серым, мельче */
.my-profile-meta {
  font-size: 14px;
  color: var(--text-muted);
  text-align: center;
  margin-top: 4px;
  padding: 0 12px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.my-profile-actions {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 28px;
}

/* Карандаш-бейдж на аватарке (когда фото нет) */
.avatar-edit-badge {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-text);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--bg-white);
  cursor: pointer;
  padding: 0;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  transition: transform 0.15s, background 0.15s;
}
.avatar-edit-badge:hover {
  background: var(--accent-hover);
  transform: scale(1.05);
}
.avatar-edit-badge svg { display: block; }

/* =============================================
   МОДАЛКА: Профиль (fullscreen, чужой)
   ============================================= */
.modal-profile-full {
  padding: 0;
  background: var(--bg-white);
  align-items: stretch;
  justify-content: stretch;
}

.modal-profile-full .profile-fullscreen {
  max-width: none;
  width: 100%;
  height: 100%;
  border-radius: 0;
  background: var(--bg-white);
}

@media (min-width: 769px) {
  .modal-profile-full .profile-fullscreen {
    max-width: 768px;
    margin: 0 auto;
    height: 100vh;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.08);
  }
}

.profile-fs-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px 20px 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.profile-fs-top {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.profile-fs-username {
  font-size: 14px;
  color: var(--text-muted);
}

.profile-fs-name {
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
  text-align: center;
}

.profile-fs-phone {
  font-size: 15px;
  color: var(--text);
  text-align: center;
  margin-top: 2px;
}
.profile-fs-phone.muted {
  color: var(--text-muted);
}

.profile-fs-actions {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 24px;
}

/* =============================================
   ЭКРАН: Редактирование профиля
   ============================================= */
.profile-edit-save-btn {
  width: auto !important;
  padding: 8px 16px !important;
  font-size: 14px !important;
  border-radius: 18px !important;
  font-weight: 600;
  margin-right: 4px;
}

.profile-edit-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0 24px;
}

.form-field-row {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
}

.form-field-row label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
  letter-spacing: 0.2px;
}

.form-field-row input {
  width: 100%;
  font-size: 16px;
  color: var(--text);
  background: transparent;
  border: none;
  outline: none;
  padding: 0;
  font-family: inherit;
}

.form-field-row input::placeholder {
  color: var(--text-muted);
  opacity: 0.6;
}

.profile-edit-error {
  padding: 12px 20px;
  color: var(--danger);
  font-size: 13.5px;
  margin: 0;
  min-height: 18px;
}

/* Разделитель между @ником и телефоном */
.my-profile-meta .meta-dot {
  display: inline-block;
  font-size: 1.15em;
  line-height: 1;
  vertical-align: middle;
  margin: 0 6px;
  opacity: 0.5;
  transform: translateY(-2px);
}

/* =============================================
   BOTTOM SHEET: запрос уведомлений
   ============================================= */
.notif-prompt-overlay {
  position: fixed;
  inset: 0;
  z-index: 9998;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.notif-prompt-overlay.is-open {
  opacity: 1;
  pointer-events: auto;
}

.notif-prompt-sheet {
  position: relative;
  width: 100%;
  max-width: 500px;
  background: #fff;
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.25);
  padding: 12px 24px calc(24px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(.3, .7, .4, 1);
}
.notif-prompt-overlay.is-open .notif-prompt-sheet {
  transform: translateY(0);
}

.notif-prompt-handle {
  width: 40px;
  height: 4px;
  border-radius: 2px;
  background: #d4d4d8;
  margin-bottom: 20px;
  flex-shrink: 0;
}

.notif-prompt-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 84px;
  height: 84px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-hover);
  margin-bottom: 16px;
  flex-shrink: 0;
}
.notif-prompt-icon svg {
  display: block;
  width: 44px;
  height: 44px;
}

.notif-prompt-title {
  margin: 0 0 8px;
  font-size: 19px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.25;
}

.notif-prompt-text {
  margin: 0 0 24px;
  font-size: 14.5px;
  line-height: 1.45;
  color: var(--text-secondary);
  max-width: 340px;
}

.notif-prompt-actions {
  display: flex;
  gap: 10px;
  width: 100%;
  max-width: 360px;
}

.notif-prompt-btn {
  flex: 1;
  padding: 13px 16px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: background 0.15s, transform 0.08s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
}
.notif-prompt-btn:active {
  transform: scale(0.98);
}

.notif-prompt-btn.skip {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.notif-prompt-btn.skip:hover {
  background: var(--bg-app);
}

.notif-prompt-btn.enable {
  background: var(--accent);
  color: var(--accent-text);
}
.notif-prompt-btn.enable:hover {
  background: var(--accent-hover);
}
.notif-prompt-btn.enable svg {
  display: block;
  flex-shrink: 0;
}

/* =============================================
   PWA Hint — Android-версия (короткий bottom-sheet)
   ============================================= */
.pwa-hint-card-android {
  padding-bottom: calc(8px + env(safe-area-inset-bottom, 0));
}

.pwa-hint-android-body {
  padding: 8px 24px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.pwa-hint-android-icon {
  width: 80px;
  height: 80px;
  border-radius: 20px;
  overflow: hidden;
  margin-bottom: 16px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
  flex-shrink: 0;
  background: #000;
}
.pwa-hint-android-icon img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.pwa-hint-android-title {
  margin: 0 0 8px;
  font-size: 19px;
  font-weight: 700;
  color: #1a1a1a;
  line-height: 1.25;
}

.pwa-hint-android-text {
  margin: 0;
  font-size: 14.5px;
  line-height: 1.45;
  color: #666;
  max-width: 320px;
}

.pwa-hint-android-actions {
  display: flex;
  gap: 10px;
  padding: 12px 20px 16px;
}

.pwa-hint-android-btn-cancel,
.pwa-hint-android-btn-install {
  flex: 1;
  padding: 13px 16px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background 0.15s, transform 0.08s;
  -webkit-tap-highlight-color: transparent;
}
.pwa-hint-android-btn-cancel:active,
.pwa-hint-android-btn-install:active {
  transform: scale(0.98);
}

.pwa-hint-android-btn-cancel {
  background: transparent;
  color: #666;
  border: 1px solid #e0e0e0;
}
.pwa-hint-android-btn-cancel:hover {
  background: #f5f5f5;
}

.pwa-hint-android-btn-install {
  background: #FECE1A;
  color: #111;
}
.pwa-hint-android-btn-install:hover {
  background: #e5b800;
}
.pwa-hint-android-btn-install svg {
  display: block;
  flex-shrink: 0;
}

/* =============================================
   Фото-просмотрщик: pinch-zoom
   ============================================= */
.photo-viewer-carousel {
  overflow-y: hidden;   /* убираем неявный вертикальный скролл */
}

.photo-viewer-item {
  overflow: hidden;     /* обрезаем увеличенное фото по краям слайда */
  position: relative;
}

.photo-viewer-item img {
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
  -webkit-touch-callout: none;
  transition: none;
  will-change: transform;
}

/* =============================================
   Тёмная тема — точечные переопределения app.css
   ============================================= */

/* Список чатов */
[data-theme="dark"] .screen-chats,
[data-theme="dark"] .chat-list,
[data-theme="dark"] .app-header,
[data-theme="dark"] .search-bar {
  background: var(--bg-white);
}

[data-theme="dark"] .chat-item {
  border-bottom-color: var(--border);
}
[data-theme="dark"] .chat-item:hover { background: #232730; }
[data-theme="dark"] .chat-item:active { background: #2a2f38; }

[data-theme="dark"] .search-bar input {
  background: var(--bg-app);
  color: var(--text);
}
[data-theme="dark"] .search-bar input:focus {
  background: #232730;
}

/* Сообщения */
[data-theme="dark"] .messages {
  background: var(--bg-app);
}
[data-theme="dark"] .bubble {
  box-shadow: 0 1px 0.5px rgba(0, 0, 0, 0.5);
}
[data-theme="dark"] .msg-row:not(.own) .bubble::before {
  background: radial-gradient(circle at 0 0, transparent 70%, var(--bubble-in) 72%);
}
[data-theme="dark"] .msg-row.own .bubble::before {
  background: radial-gradient(circle at 100% 0, transparent 70%, var(--bubble-out) 72%);
}

[data-theme="dark"] .date-divider {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

[data-theme="dark"] .chat-notice {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-secondary);
}
[data-theme="dark"] .chat-notice b {
  color: var(--text);
}

[data-theme="dark"] .bubble-quote {
  background: rgba(255, 255, 255, 0.06);
  border-left-color: #555;
}
[data-theme="dark"] .bubble-quote-author { color: #aaa; }
[data-theme="dark"] .bubble-quote-text { color: var(--text-secondary); }

[data-theme="dark"] .msg-row.own .bubble-quote {
  background: rgba(255, 255, 255, 0.65);
}
[data-theme="dark"] .msg-row.own .bubble-quote-author { color: #333; }
[data-theme="dark"] .msg-row.own .bubble-quote-text { color: #555; }

/* Поле ввода */
[data-theme="dark"] .message-form {
  background: var(--bg-app);
}
[data-theme="dark"] .message-form textarea {
  background: var(--bg-white);
  color: var(--text);
}
[data-theme="dark"] .message-form textarea::placeholder {
  color: var(--text-muted);
}
[data-theme="dark"] .message-form .icon-btn {
  color: var(--text-secondary);
}

/* Reply preview */
[data-theme="dark"] .reply-preview {
  background: var(--bg-white);
  border-top-color: var(--border);
}
[data-theme="dark"] .reply-preview-author {
  color: var(--accent);
}
[data-theme="dark"] .reply-preview-text {
  color: var(--text-secondary);
}

/* Эмодзи */
[data-theme="dark"] .emoji-picker {
  background: var(--bg-white);
  border-top-color: var(--border);
}
[data-theme="dark"] .emoji-tabs {
  border-bottom-color: var(--border);
}
[data-theme="dark"] .emoji-tab:hover,
[data-theme="dark"] .emoji-item:hover {
  background: #232730;
}
[data-theme="dark"] .emoji-tab.active {
  background: var(--accent-soft);
}

/* Модалки */
[data-theme="dark"] .modal-header {
  border-bottom-color: var(--border);
}
[data-theme="dark"] .user-item:hover { background: #232730; }
[data-theme="dark"] .user-item:active { background: #2a2f38; }
[data-theme="dark"] .user-item { border-bottom-color: var(--border); }

/* Профиль */
[data-theme="dark"] .profile-field {
  background: var(--bg-white);
}
[data-theme="dark"] .profile-field-edit:hover {
  background: rgba(255, 255, 255, 0.06);
}
[data-theme="dark"] .admin-form input,
[data-theme="dark"] .admin-form select {
  background: var(--bg-white);
  color: var(--text);
  border-color: var(--border);
}

/* QR */
[data-theme="dark"] .qr-canvas {
  background: #fff; /* QR должен быть на белом */
}
[data-theme="dark"] .qr-url {
  background: var(--bg-app);
  color: var(--text-secondary);
}

/* Настройки */
[data-theme="dark"] .screen-settings,
[data-theme="dark"] .screen-my-profile {
  background: var(--bg-white);
}
[data-theme="dark"] .settings-header {
  background: var(--bg-white);
  border-bottom-color: var(--border);
}
[data-theme="dark"] .settings-item {
  border-bottom-color: var(--border);
}
[data-theme="dark"] .settings-item:hover { background: #232730; }
[data-theme="dark"] .settings-item:active { background: #2a2f38; }

/* Тумблер в тёмной теме */
[data-theme="dark"] .toggle {
  background: #3a4048;
}
[data-theme="dark"] .toggle.on {
  background: var(--accent);
}

/* Выбор темы */
[data-theme="dark"] .theme-option:hover { background: #232730; }
[data-theme="dark"] .theme-option { border-bottom-color: var(--border); }

/* Профиль-инфо */
[data-theme="dark"] .profile-role-badge {
  background: var(--bg-app);
  color: var(--text-secondary);
  border-color: var(--border);
}

/* Форма редактирования профиля */
[data-theme="dark"] .form-field-row {
  border-bottom-color: var(--border);
}
[data-theme="dark"] .form-field-row input {
  color: var(--text);
}
[data-theme="dark"] .form-field-row input::placeholder {
  color: var(--text-muted);
}
[data-theme="dark"] .form-field-row input[type="date"] {
  color-scheme: dark;
}

/* Оффлайн-баннер */
[data-theme="dark"] .offline-banner {
  background: #b91c1c;
}

/* Скролл-бар (десктоп) */
[data-theme="dark"] .chat-list::-webkit-scrollbar-thumb,
[data-theme="dark"] .messages::-webkit-scrollbar-thumb,
[data-theme="dark"] .user-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
}

/* Пустое состояние */
[data-theme="dark"] .empty-btn {
  box-shadow: 0 4px 12px rgba(245, 197, 24, 0.2);
}

/* Нижняя кнопка «вниз» */
[data-theme="dark"] .scroll-down-btn {
  background: var(--bg-white);
  color: var(--text);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.5);
}
[data-theme="dark"] .scroll-down-btn:hover { background: #232730; }

/* Ещё цвета в списке чатов */
[data-theme="dark"] .chat-item-preview em {
  color: var(--text-muted);
}

/* Плавающая панель реакций */
[data-theme="dark"] .reaction-bar {
  background: #2a2e34;
  box-shadow: 0 6px 28px rgba(0, 0, 0, 0.6);
}
[data-theme="dark"] .reaction-btn:hover { background: rgba(255, 255, 255, 0.08); }

/* Bottom sheet */
[data-theme="dark"] .sheet {
  background: var(--bg-white);
}
[data-theme="dark"] .sheet-title {
  color: var(--text-muted);
  border-bottom-color: var(--border);
}
[data-theme="dark"] .sheet-action {
  color: var(--text);
}
[data-theme="dark"] .sheet-action:hover { background: #232730; }
[data-theme="dark"] .sheet-action:active { background: var(--accent-soft); }

/* Печатает индикатор */
[data-theme="dark"] .typing-indicator span {
  background: currentColor;
}

/* Стили превью тем в настройках — общие, не зависят от data-theme */
.theme-option {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 14px 16px;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  text-align: left;
  cursor: pointer;
  transition: background 0.12s;
  font-family: inherit;
}
.theme-option:hover { background: #f5f6f6; }
.theme-option:active { background: #ececec; }

.theme-preview {
  width: 54px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--border);
  overflow: hidden;
  position: relative;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  padding: 4px 5px;
  box-sizing: border-box;
}
.theme-preview-light { background: #f0f2f5; }
.theme-preview-dark  { background: #0f1115; }
.theme-preview-system {
  background: linear-gradient(135deg, #f0f2f5 0%, #f0f2f5 49%, #0f1115 51%, #0f1115 100%);
}

.theme-preview-bubble {
  display: block;
  width: 60%;
  height: 8px;
  border-radius: 4px;
  background: #ffffff;
}
.theme-preview-bubble.own {
  background: #fece1a;
  align-self: flex-end;
}
.theme-preview-dark .theme-preview-bubble {
  background: #262a30;
}
.theme-preview-dark .theme-preview-bubble.own {
  background: #f5c518;
}

.theme-option-label {
  flex: 1;
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
}

.theme-option-check {
  width: 22px;
  height: 22px;
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s;
  flex-shrink: 0;
}
.theme-option.selected .theme-option-check {
  opacity: 1;
}
.theme-option-check svg { display: block; }

/* z-index для нового экрана */
#screen-theme { z-index: 95; }

/* Закреплённое сообщение в тёмной теме */
[data-theme="dark"] .chat-pinned {
  background: var(--bg-white);
}
[data-theme="dark"] .chat-pinned:active {
  background: #232730;
}
[data-theme="dark"] .chat-pinned-close:hover {
  background: rgba(255, 255, 255, 0.08);
}
[data-theme="dark"] .chat-pinned-title {
  color: var(--accent);
}