/* ─── Модальные окна ───────────────────────────────── */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  animation: backdropFadeIn 0.25s var(--spring) both;
}

.modal.hidden {
  display: none;
}

.modal-content {
  backdrop-filter: blur(var(--glass-blur)) saturate(180%);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(180%);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  width: 90%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
  animation: scaleIn 0.3s var(--spring) both;
}

.modal-wide {
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-content h3 {
  margin-bottom: 1rem;
  font: var(--font-headline);
  letter-spacing: var(--tracking-headline);
}

.modal-content input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text-primary);
  font: var(--font-body);
  outline: none;
  margin-bottom: 1rem;
  transition: var(--transition);
}

.modal-content input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(10, 132, 255, 0.15);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.modal-actions .btn-primary {
  width: auto;
  padding: 0.625rem 1.5rem;
  font-size: 0.95rem;
}

/* Room name edit row */
.room-name-edit-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.room-name-edit-row h3 {
  flex: 1;
  margin: 0;
}
.room-name-edit-row .icon-btn {
  font-size: 1rem;
  opacity: 0.6;
  transition: opacity 0.2s;
}
.room-name-edit-row .icon-btn:hover {
  opacity: 1;
}

/* Invite code display */

.invite-code-display {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--bg-primary);
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
}

.invite-code-display span {
  color: var(--text-secondary);
  font: var(--font-body);
}

.invite-code-display code {
  font-family: 'Courier New', monospace;
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: 4px;
  color: var(--accent);
  flex: 1;
}

/* Members list */

.members-list {
  max-height: 200px;
  overflow-y: auto;
}

.member-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}

.member-emoji {
  font-size: 1.3rem;
}

.member-name {
  flex: 1;
  font: var(--font-body);
}

.member-status {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
}

.member-status.online {
  background: var(--success);
  box-shadow: 0 0 6px rgba(46,204,113,0.5);
}

/* ─── Image viewer ─────────────────────────────────── */

.image-viewer {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  cursor: zoom-out;
}

.image-viewer.hidden {
  display: none;
}

.image-viewer img {
  max-width: 95vw;
  max-height: 95vh;
  object-fit: contain;
  border-radius: var(--radius-xs);
}

/* ─── File viewer (PDF и др.) — B-022.02 (c003) ────── */

.file-viewer {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.95);
  display: flex;
  flex-direction: column;
  z-index: 310;
}

.file-viewer.hidden {
  display: none;
}

.file-viewer-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--bg-secondary, #1c1c1c);
  border-bottom: 1px solid var(--border, #2a2a2a);
  flex-shrink: 0;
}

.file-viewer-title {
  flex: 1;
  color: var(--text, #fff);
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.file-viewer-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  color: var(--text, #fff);
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s;
}

.file-viewer-btn:hover {
  background: rgba(255,255,255,0.1);
}

#file-viewer-frame {
  flex: 1;
  width: 100%;
  border: none;
  background: #fff;
}

/* P-03: на мобиле кнопки шапки больше (тач), header гарантированно поверх iframe */
@media (max-width: 768px) {
  .file-viewer-header {
    position: relative;
    z-index: 2;
    padding: 12px 14px;
    padding-top: max(12px, env(safe-area-inset-top));
  }
  .file-viewer-btn {
    width: 44px;
    height: 44px;
    border-radius: 10px;
  }
  #file-viewer-close {
    background: rgba(255,255,255,0.08);
  }
  #file-viewer-close:active {
    background: rgba(255,255,255,0.18);
  }
}

/* ─── Скроллбар ────────────────────────────────────── */

::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ─── Мобильная адаптация ──────────────────────────── */

.mobile-only {
  display: none;
}

@media (max-width: 768px) {
  .mobile-only {
    display: flex;
  }

  #sidebar {
    width: 100%;
    min-width: 100%;
    position: absolute;
    z-index: 10;
    transition: transform 0.3s ease;
    /* На мобиле сайдбар занимает весь экран и лежит ПОВЕРХ chat-area (z-5).
       Стеклянный полупрозрачный фон давал просвечивание «Выбери чат» сквозь
       список чатов — делаем фон непрозрачным. */
    background: var(--bg-primary);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  #sidebar.hidden-mobile {
    transform: translateX(-100%);
  }

  #chat-area {
    position: absolute;
    inset: 0;
    z-index: 5;
  }

  .message {
    max-width: 85%;
  }

  .msg-image {
    max-width: 250px;
  }

  .msg-video {
    max-width: 100%;
  }

  .sidebar-header {
    gap: 0.4rem;
    padding: 0.5rem 0.75rem;
    padding-top: max(0.5rem, env(safe-area-inset-top, 0px));
    padding-left: max(0.75rem, env(safe-area-inset-left, 0px));
    padding-right: max(0.75rem, env(safe-area-inset-right, 0px));
  }

  .sidebar-nickname {
    font-size: 0.9rem;
  }

  .modal-content {
    width: 95%;
    max-height: 85vh;
    overflow-y: auto;
  }

  /* Область ввода на мобильных */
  .message-input-area {
    padding: 0.5rem;
    gap: 0.35rem;
    /* safe-area со всех «нижних» сторон — чтобы кнопки не уходили под home-indicator
       и за скруглённые углы экрана (требует viewport-fit=cover в meta viewport). */
    padding-bottom: calc(0.5rem + env(safe-area-inset-bottom, 0px));
    padding-left: calc(0.5rem + env(safe-area-inset-left, 0px));
    padding-right: calc(0.5rem + env(safe-area-inset-right, 0px));
    position: relative;
  }

  /* Шапка чата — ниже «чёлки»/Dynamic Island */
  .chat-header {
    padding-top: max(0.75rem, env(safe-area-inset-top, 0px));
    padding-left: max(1rem, env(safe-area-inset-left, 0px));
    padding-right: max(1rem, env(safe-area-inset-right, 0px));
  }

  /* На мобильных: показать кнопку "+", спрятать дополнительные кнопки за меню */
  .mobile-more-btn {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    /* B-017: высота как у voice/send (44px), иначе из-за align-items:flex-end "+" съезжает */
    min-width: 44px;
    min-height: 44px;
    font-size: 1.3rem;
  }
  .message-input-area .secondary-btn {
    display: none !important;
  }

  .message-input-area .icon-btn {
    min-width: 42px;
    min-height: 42px;
    font-size: 1.3rem;
    flex-shrink: 0;
  }

  .message-input-area .voice-btn {
    background: var(--bg-hover);
    border-radius: 50%;
    min-width: 44px;
    min-height: 44px;
    font-size: 1.4rem;
  }

  .message-input-area .send-btn {
    min-width: 44px;
    min-height: 44px;
  }

  .input-wrapper {
    min-width: 0;
  }

  #message-input {
    padding: 0.6rem 0.8rem;
    font-size: 1rem; /* 16px — важно для iOS чтобы не зумило при фокусе */
    border-radius: 22px;
    min-height: 44px;
  }

  /* Всплывающее меню "+": стикер над input-area */
  .mobile-attach-menu {
    display: none;
    position: absolute;
    left: 0.5rem;
    bottom: calc(100% + 6px);
    background: var(--bg-secondary, #1a1a2e);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md, 12px);
    padding: 0.4rem;
    box-shadow: 0 8px 28px rgba(0,0,0,0.35);
    z-index: 20;
    min-width: 200px;
    backdrop-filter: blur(12px) saturate(150%);
    -webkit-backdrop-filter: blur(12px) saturate(150%);
  }
  .mobile-attach-menu:not(.hidden) {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    animation: attachMenuIn 0.15s ease-out;
  }
  @keyframes attachMenuIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
  }
  .mobile-attach-menu .attach-action {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 0.85rem;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 0.95rem;
    text-align: left;
    cursor: pointer;
    border-radius: var(--radius-sm, 8px);
    transition: background 0.15s;
  }
  .mobile-attach-menu .attach-action:hover,
  .mobile-attach-menu .attach-action:active {
    background: var(--bg-hover);
  }
  .mobile-attach-menu .attach-action i {
    width: 20px;
    height: 20px;
    color: var(--accent);
  }
}

/* ─── Видео-кружочки ──────────────────────────────── */

/* Обёртка-фон поверх всего экрана (как у голосовухи) */
.video-circle-modal-wrap {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  animation: vrFadeIn 0.18s ease-out;
}
.video-circle-modal-wrap.hidden { display: none; }

.video-circle-modal {
  text-align: center;
  max-width: 360px;
  /* Карточка использует .voice-rec-card стили: тот же градиент,
     радиус, тень и анимация появления — единый язык. */
  padding: 1.75rem 1.5rem 1.5rem;
  gap: 1rem;
}

.vc-header {
  display: flex; align-items: center; justify-content: center;
  gap: 0.5rem;
  color: rgba(255, 255, 255, 0.85);
  font-size: 0.95rem; font-weight: 500;
}
.vc-header-icon { width: 18px; height: 18px; }

.video-circle-preview-wrap {
  position: relative;
  width: 220px;
  height: 220px;
  margin: 0.25rem auto 0;
  border-radius: 50%;
  overflow: hidden;
  border: 3px solid rgba(255, 255, 255, 0.10);
  background: #000;
  transition: border-color 0.2s ease, filter 0.2s ease;
}
.video-circle-preview-wrap.vc-recording {
  border-color: rgba(231, 76, 60, 0.85);
  box-shadow: 0 0 0 4px rgba(231, 76, 60, 0.18);
}
.video-circle-preview-wrap.vc-paused {
  border-color: rgba(241, 196, 15, 0.85);
  box-shadow: 0 0 0 4px rgba(241, 196, 15, 0.18);
  filter: grayscale(0.6) brightness(0.55);
}

.video-circle-preview-wrap video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#video-circle-timer-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  /* P-13 (B-024.06): defensive clip — даже если родительский overflow:hidden
     не сработает на каком-то браузере (или компоновщик покажет прямоугольную
     границу слоя на 1 кадр при перерисовке), сам canvas всегда круглый. */
  background: transparent;
  clip-path: circle(50% at 50% 50%);
  -webkit-clip-path: circle(50% at 50% 50%);
}

/* Большая иконка паузы поверх затемнённого превью */
.vc-pause-overlay {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
  color: #fff;
  text-shadow: 0 2px 12px rgba(0,0,0,0.6);
}
.vc-pause-overlay.hidden { display: none; }
.vc-pause-overlay i, .vc-pause-overlay svg { width: 56px; height: 56px; }

/* Таймер — крупный, моноширинный, как в голосовухе */
.vc-timer {
  font-size: 1.5rem; font-weight: 600; color: #fff;
  font-variant-numeric: tabular-nums; letter-spacing: 0.05em;
  margin: 0;
}

.vc-hint {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.55);
  text-align: center;
  margin: 0;
}

.video-circle-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 0.25rem;
}

/* Главная кнопка по центру (REC / Pause / Send) — как .vr-btn */
.vc-main-btn {
  width: 60px; height: 60px; border-radius: 50%; border: none;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: #fff;
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s;
  background: linear-gradient(135deg, #4a90e2, #2d6cb6);
  box-shadow: 0 6px 18px rgba(74, 144, 226, 0.40);
}
.vc-main-btn:hover { transform: translateY(-2px); filter: brightness(1.1); }
.vc-main-btn:active { transform: translateY(0); }
.vc-main-btn i, .vc-main-btn svg { width: 24px; height: 24px; }
.vc-main-btn.hidden { display: none; }

/* Красный кружок REC */
.vc-main-rec {
  background: linear-gradient(135deg, #ff5b5b, #c0392b);
  box-shadow: 0 6px 18px rgba(231, 76, 60, 0.45);
}
.vc-main-dot {
  width: 22px; height: 22px; border-radius: 50%;
  background: #fff;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,0.4);
}

/* Пауза — жёлтая (как у голосовухи). На паузе — синий «play» */
.vc-main-pause {
  background: linear-gradient(135deg, #f1c40f, #d4a307);
  box-shadow: 0 6px 18px rgba(241, 196, 15, 0.40);
}
.vc-main-pause.is-paused {
  background: linear-gradient(135deg, #4a90e2, #2d6cb6);
  box-shadow: 0 6px 18px rgba(74, 144, 226, 0.40);
}

/* Отправить — синяя (как .vr-send в голосовухе, единый язык) */
.vc-main-send {
  background: linear-gradient(135deg, #4a90e2, #2d6cb6);
  box-shadow: 0 6px 18px rgba(74, 144, 226, 0.40);
}

/* P-04: боковые кнопки (flip/close/cancel) — теперь того же размера 60×60,
   что и главные. В видимом ряду всегда ровно 3 кнопки одинакового веса:
   до записи [close][rec][flip], во время записи [cancel][pause][stop]. */
.vc-side-btn {
  width: 60px; height: 60px; border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.85);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease, color 0.15s ease;
}
.vc-side-btn:hover { background: rgba(255,255,255,0.12); transform: translateY(-1px); }
.vc-side-btn.hidden { display: none; }
.vc-side-btn i, .vc-side-btn svg { width: 24px; height: 24px; }
.vc-side-danger {
  color: #ff8c8c;
  border-color: rgba(231, 76, 60, 0.35);
  background: rgba(231, 76, 60, 0.10);
}
.vc-side-danger:hover { background: rgba(231, 76, 60, 0.20); color: #fff; }

/* Видео-кружочки в чате */
.msg-video-circle {
  width: 200px;
  height: 200px;
  border-radius: 50%;
  overflow: hidden;
  position: relative;
  cursor: pointer;
  border: 2px solid var(--accent);
  flex-shrink: 0;
}

.video-circle-player {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* B-005: круговой прогресс по периметру (как в Telegram) */
.video-circle-progress {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: auto;
  cursor: pointer;
  transform: rotate(-90deg);
  overflow: visible;
}
.vc-progress-track {
  fill: none;
  stroke: rgba(255, 255, 255, 0.18);
  stroke-width: 3;
}
.vc-progress-fill {
  fill: none;
  stroke: var(--accent);
  stroke-width: 4;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.1s linear;
  filter: drop-shadow(0 0 6px rgba(0, 122, 255, 0.6))
          drop-shadow(0 0 12px rgba(0, 122, 255, 0.3));
}

.video-circle-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 2rem;
  color: white;
  text-shadow: 0 1px 4px rgba(0,0,0,0.6);
  pointer-events: none;
  transition: opacity 0.2s;
}

.msg-video-circle:hover .video-circle-overlay {
  opacity: 0.7;
}

/* ─── In-app Notification Popups (Telegram-style) ──── */

.notification-popup-container {
  position: fixed;
  /* safe-area: не залезаем под чёлку/статус-бар (viewport-fit=cover + black-translucent) */
  top: max(0.75rem, env(safe-area-inset-top, 0px));
  right: max(0.75rem, env(safe-area-inset-right, 0px));
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
  max-width: 380px;
  width: calc(100vw - 1.5rem);
}

.notification-popup {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.75rem 0.85rem;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 32px rgba(0,0,0,0.4), 0 2px 8px rgba(0,0,0,0.3);
  cursor: pointer;
  pointer-events: auto;
  animation: notifPopupIn 0.3s var(--spring);
  transition: opacity 0.3s var(--spring), transform 0.3s var(--spring);
  backdrop-filter: blur(var(--glass-blur-thin)) saturate(150%);
  -webkit-backdrop-filter: blur(var(--glass-blur-thin)) saturate(150%);
  position: relative;
  overflow: hidden;
}

.notification-popup:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
}

.notification-popup.notif-popup-exit {
  opacity: 0;
  transform: translateX(100%);
}

.notif-popup-icon {
  font-size: 1.4rem;
  flex-shrink: 0;
  margin-top: 2px;
}

.notif-popup-body {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.notif-popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 2px;
}

.notif-popup-room {
  font: var(--font-callout);
  font-weight: 700;
  color: var(--accent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.notif-popup-time {
  font: var(--font-caption);
  color: var(--text-secondary);
  flex-shrink: 0;
}

.notif-popup-text {
  font: var(--font-callout);
  color: var(--text-secondary);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.notif-popup-text b {
  color: var(--text-primary);
  font-weight: 600;
}

.notif-popup-close {
  position: absolute;
  top: 4px;
  right: 6px;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  opacity: 0;
  transition: opacity 0.2s, color 0.2s;
  line-height: 1;
}

.notification-popup:hover .notif-popup-close {
  opacity: 1;
}

.notif-popup-close:hover {
  color: var(--danger);
  background: rgba(255,255,255,0.05);
}

@keyframes notifPopupIn {
  from { opacity: 0; transform: translateX(30%) scale(0.95); }
  to   { opacity: 1; transform: translateX(0) scale(1); }
}

/* ─── Уведомления (toast) ──────────────────────────── */

.toast-container {
  position: fixed;
  top: max(1rem, env(safe-area-inset-top, 0px));
  right: max(1rem, env(safe-area-inset-right, 0px));
  z-index: 400;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1rem;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 15px var(--shadow);
  font: var(--font-callout);
  animation: toastIn 0.3s var(--spring);
  max-width: 380px;
  pointer-events: auto;
  transition: opacity 0.3s var(--spring), transform 0.3s var(--spring);
  backdrop-filter: blur(var(--glass-blur-thin)) saturate(150%);
  -webkit-backdrop-filter: blur(var(--glass-blur-thin)) saturate(150%);
}

.toast-icon {
  font-size: 1rem;
  flex-shrink: 0;
}

.toast-text {
  flex: 1;
  min-width: 0;
}

.toast-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
  opacity: 0.5;
  transition: opacity 0.2s;
}

.toast-close:hover {
  opacity: 1;
}

.toast.success {
  border-left: 4px solid var(--success);
}

.toast.error {
  border-left: 4px solid var(--danger);
}

.toast.info {
  border-left: 4px solid var(--accent);
}

.toast.warning {
  border-left: 4px solid var(--warning);
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ─── Скелетон загрузки сообщений ──────────────────── */

.loading-skeleton {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 1rem 0;
}

.skel-msg {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.skel-msg.self {
  justify-content: flex-end;
}

.skel-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--border);
  animation: skelPulse 1.2s ease-in-out infinite;
  flex-shrink: 0;
}

.skel-lines {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.skel-line {
  height: 12px;
  border-radius: var(--radius-xs);
  background: var(--border);
  animation: skelPulse 1.2s ease-in-out infinite;
}

.skel-line.w30 { width: 100px; }
.skel-line.w40 { width: 140px; }
.skel-line.w50 { width: 180px; }
.skel-line.w60 { width: 220px; }
.skel-line.w70 { width: 260px; }
.skel-line.w80 { width: 300px; }
.skel-line.w90 { width: 340px; }

@keyframes skelPulse {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 0.6; }
}

/* ─── Загрузка ─────────────────────────────────────── */

.upload-progress {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: rgba(0,0,0,0.2);
  border-radius: var(--radius-sm);
  margin: 4px 0;
}

.upload-bar {
  flex: 1;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.upload-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.3s ease;
}

.hidden {
  display: none !important;
}

/* ─── Install PWA banner ───────────────────────────── */

.install-banner {
  margin-top: 1.5rem;
  padding: 1rem;
  background: linear-gradient(135deg, rgba(10, 132, 255, 0.2), rgba(48, 209, 88, 0.15));
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  text-align: center;
  animation: fadeIn 0.5s ease;
}

.install-banner p {
  font: var(--font-body);
  margin-bottom: 0.75rem;
  color: var(--text-primary);
}

.btn-install {
  padding: 0.625rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--success), var(--accent));
  color: white;
  cursor: pointer;
  transition: var(--transition);
}

.btn-install:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 15px rgba(48, 209, 88, 0.4);
}

.btn-install:active {
  transform: translateY(0);
}

/* ─── Push hint banner (в области чата) ─────────────── */
.push-hint-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  margin: 8px 12px 0;
  background: linear-gradient(135deg, rgba(10, 132, 255, 0.18), rgba(255, 159, 10, 0.12));
  border: 1px solid rgba(10, 132, 255, 0.45);
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--text-primary);
  animation: fadeIn .4s ease;
}
.push-hint-banner.hidden { display: none; }
.push-hint-banner .push-hint-icon {
  flex: 0 0 auto;
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: rgba(10, 132, 255, 0.25);
  color: #0a84ff;
}
.push-hint-banner .push-hint-icon i { width: 18px; height: 18px; }
.push-hint-banner .push-hint-text {
  flex: 1 1 auto;
  display: flex; flex-direction: column; gap: 2px;
  min-width: 0;
}
.push-hint-banner .push-hint-text strong { font-weight: 600; }
.push-hint-banner .push-hint-text span { opacity: .85; font-size: 12.5px; }
.push-hint-banner .btn-sm { flex: 0 0 auto; white-space: nowrap; }
.push-hint-banner .push-hint-close {
  flex: 0 0 auto;
  background: transparent;
  border: none;
  color: var(--text-primary);
  opacity: .55;
  font-size: 20px; line-height: 1;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
}
.push-hint-banner .push-hint-close:hover { opacity: 1; background: rgba(255,255,255,.08); }

/* На мобиле — выносим баннер из chat-area на верхний уровень,
   чтобы он был виден всегда (даже на экране списка чатов),
   и чтобы ничто не перекрывало кнопки «Включить» / «×». */
@media (max-width: 768px) {
  .push-hint-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    margin: 0;
    border-radius: 0;
    border-left: none;
    border-right: none;
    z-index: 100; /* выше sidebar (z-index: 10) и chat-area (z-index: 5) */
    padding: 12px 14px;
    padding-top: calc(12px + env(safe-area-inset-top, 0px));
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
    background: linear-gradient(135deg, rgba(10, 132, 255, 0.95), rgba(255, 159, 10, 0.85));
    border: none;
    color: #fff;
  }
  .push-hint-banner .push-hint-icon { background: rgba(255, 255, 255, 0.2); color: #fff; }
  .push-hint-banner .push-hint-close { color: #fff; opacity: 0.85; }

  /* Большие тап-таргеты (Apple HIG: минимум 44×44px) */
  .push-hint-banner .btn-sm,
  .push-hint-banner .push-hint-close {
    min-width: 44px;
    min-height: 44px;
    touch-action: manipulation; /* убираем 300ms задержку на iOS */
  }
  .push-hint-banner .push-hint-close { font-size: 26px; padding: 8px 12px; }

  /* Когда баннер виден — сдвигаем сайдбар и чат вниз, чтобы он не перекрывал шапки.
     Учитываем чёлку (env safe-area): баннер выше на эту величину, иначе шапки перекрыты. */
  body.has-push-hint #sidebar,
  body.has-push-hint #chat-area {
    padding-top: calc(64px + env(safe-area-inset-top, 0px));
  }
}
@media (max-width: 520px) {
  .push-hint-banner { flex-wrap: wrap; }
  .push-hint-banner .push-hint-text { flex: 1 1 100%; order: 2; }
  .push-hint-banner .btn-sm { order: 3; }
  .push-hint-banner .push-hint-close { order: 1; margin-left: auto; }
}

/* PWA install instructions modal */

.ios-install-instructions,
.pwa-install-guide {
  text-align: left;
  line-height: 1.6;
}

.ios-install-instructions ol,
.pwa-install-guide ol {
  padding-left: 1.25rem;
  margin: 0.75rem 0;
}

.ios-install-instructions li,
.pwa-install-guide li {
  margin-bottom: 0.5rem;
  font-size: 0.95rem;
}

.install-step {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  padding: 0.6rem 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.install-step:last-of-type {
  border-bottom: none;
}

.install-step-num {
  width: 28px;
  height: 28px;
  min-width: 28px;
  background: var(--accent);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.875rem;
  flex-shrink: 0;
}

.install-step > div:last-child {
  font: var(--font-body);
  line-height: 1.5;
  color: var(--text-primary);
}

.install-result {
  margin-top: 0.75rem;
  padding: 0.5rem 0.75rem;
  background: rgba(46, 204, 113, 0.1);
  border-radius: var(--radius-sm);
  color: var(--success);
  font: var(--font-callout);
  text-align: center;
}

/* Date separator */
.date-separator {
  text-align: center;
  padding: 0.5rem 0;
  color: var(--text-muted);
  font-size: 0.75rem;
  position: relative;
}

.date-separator::before,
.date-separator::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 30%;
  height: 1px;
  background: var(--border);
}

.date-separator::before { left: 5%; }
.date-separator::after { right: 5%; }

