.server-error-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
}

.server-error-modal {
  background-color: white;
  border-radius: 12px;
  padding: 32px;
  max-width: 500px;
  width: 90%;
  text-align: center;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
  animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.server-error-icon {
  font-size: 64px;
  margin-bottom: 24px;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
}

.server-error-title {
  margin: 0 0 16px 0;
  color: #1f2937;
  font-size: 24px;
  font-weight: 600;
}

.server-error-message {
  margin: 0 0 32px 0;
  color: #6b7280;
  font-size: 16px;
  line-height: 1.5;
}

.server-error-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.server-error-button {
  border: none;
  border-radius: 8px;
  padding: 12px 24px;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: 140px;
}

.server-error-button-primary {
  background-color: #3b82f6;
  color: white;
}

.server-error-button-primary:hover:not(:disabled) {
  background-color: #2563eb;
  transform: translateY(-1px);
}

.server-error-button-danger {
  background-color: #ef4444;
  color: white;
}

.server-error-button-danger:hover {
  background-color: #dc2626;
  transform: translateY(-1px);
}

.server-error-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none !important;
}

.server-error-tips {
  margin-top: 24px;
  padding: 16px;
  background-color: #f3f4f6;
  border-radius: 8px;
  font-size: 14px;
  color: #6b7280;
}

.server-error-tips strong {
  color: #374151;
}

.server-error-tips ul {
  margin: 8px 0 0 0;
  padding-left: 20px;
  text-align: left;
}

.server-error-tips li {
  margin-bottom: 4px;
}

/* Адаптивность для мобильных устройств */
@media (max-width: 480px) {
  .server-error-modal {
    padding: 24px;
    margin: 16px;
  }
  
  .server-error-icon {
    font-size: 48px;
  }
  
  .server-error-title {
    font-size: 20px;
  }
  
  .server-error-message {
    font-size: 14px;
  }
  
  .server-error-buttons {
    flex-direction: column;
  }
  
  .server-error-button {
    width: 100%;
  }
}
/* =====================================================================
   CHAT — Современный корпоративный дизайн (бирюзовая тема СИТИ)
   ===================================================================== */
:root {
  --teal-50: #f0fdfa;
  --teal-100: #ccfbf1;
  --teal-200: #99f6e4;
  --teal-300: #5eead4;
  --teal-400: #2dd4bf;
  --teal-500: #14b8a6;
  --teal-600: #0d9488;
  --teal-700: #0f766e;
  --ink-950: #020617;
  --ink-900: #0f172a;
  --ink-800: #1e293b;
  --ink-700: #334155;
  --ink-600: #475569;
  --ink-500: #64748b;
  --ink-400: #94a3b8;
  --ink-300: #cbd5e1;
  --ink-200: #e2e8f0;
  --ink-100: #f1f5f9;
  --ink-50:  #f8fafc;
  --white: #ffffff;
  --radius-xl: 20px;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow-soft: 0 4px 20px rgba(15, 23, 42, 0.06);
  --shadow-tiny: 0 1px 3px rgba(15, 23, 42, 0.04);
  --shadow-elevated: 0 8px 32px rgba(15, 23, 42, 0.08);
  --transition-fast: 180ms ease;
  --transition-smooth: 280ms cubic-bezier(0.4, 0, 0.2, 1);
  --chat-header-height: 64px;
}

/* ===== Layout ===== */
.chat-layout {
  display: flex;
  height: 100%;
  width: 100%;
  overflow-x: hidden;
  background: var(--ink-50);
}

/* История загрузки */
.history-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 20px;
  gap: 16px;
  color: var(--ink-500);
}

.loading-spinner {
  width: 28px;
  height: 28px;
  border: 2.5px solid var(--teal-100);
  border-top: 2.5px solid var(--teal-500);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.loading-text {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--ink-500);
}

/* ===== Окно чата ===== */
.chat-window {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  max-height: 100%;
}

/* ===== Chat header ===== */
.chat-header {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 20px;
  background: rgba(255, 255, 255, 0.85);
  border-bottom: 1px solid var(--ink-200);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  min-height: var(--chat-header-height);
  box-sizing: border-box;
  transition: box-shadow var(--transition-fast);
}
.chat-header:hover {
  box-shadow: 0 2px 12px rgba(15, 23, 42, 0.04);
}
.chat-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.chat-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--teal-400), var(--teal-600));
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}
.chat-title-group { min-width: 0; }
.chat-name {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--ink-800);
  letter-spacing: 0.1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--ink-500);
}
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  transition: background var(--transition-fast), box-shadow var(--transition-fast);
}
.status-dot.online {
  background: #22c55e;
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.15);
}
.status-dot.offline {
  background: var(--ink-400);
  box-shadow: 0 0 0 2px rgba(148, 163, 184, 0.12);
}

/* Индикатор статуса в списке чатов */
.user-status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 8px;
  transition: background var(--transition-fast), box-shadow var(--transition-fast);
}
.user-status-dot.online {
  background: #22c55e;
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.15);
}
.user-status-dot.offline {
  background: var(--ink-400);
  box-shadow: 0 0 0 2px rgba(148, 163, 184, 0.12);
}

.chat-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}
.icon-btn {
  -webkit-appearance: none;
  appearance: none;
  border: 1px solid var(--ink-200);
  background: var(--white);
  border-radius: var(--radius-sm);
  padding: 7px;
  cursor: pointer;
  color: var(--ink-600);
  transition: all var(--transition-fast);
}
.icon-btn:hover {
  color: var(--teal-600);
  border-color: var(--teal-300);
  background: var(--teal-50);
  box-shadow: 0 2px 8px rgba(20, 184, 166, 0.1);
  transform: translateY(-1px);
}
.icon-btn:active {
  transform: translateY(0);
}
.icon-btn.end-call {
  background: #ef4444;
  color: white;
  border-color: #ef4444;
}
.icon-btn.end-call:hover {
  background: #dc2626;
  border-color: #dc2626;
}

/* ===== Список чатов — боковая панель ===== */
.chat-sidebar {
  flex: 0 0 clamp(220px, 22vw, 260px);
  background: var(--white);
  border-right: 1px solid var(--ink-200);
  color: var(--ink-800);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ===== Пустой экран ===== */
.empty-chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  min-height: 0;
  gap: var(--space-3);
  padding: var(--space-6);
  background: var(--bg-app);
}

.empty-chat-icon {
  display: grid;
  width: 52px;
  height: 52px;
  place-items: center;
  border-radius: var(--radius-lg);
  background-color: var(--teal-50);
  color: var(--teal-800);
}

.empty-chat-text {
  margin: 0;
  font-size: var(--fs-lg);
  font-weight: var(--fw-semibold);
  color: var(--ink-600);
  line-height: var(--lh-snug);
}

.empty-chat-subtitle {
  font-size: 0.85rem;
  color: var(--ink-400);
  font-weight: 400;
}

@media (max-width: 640px) {
  .empty-chat-icon { width: 44px; height: 44px; }
  .empty-chat-text { font-size: var(--fs-base); }
}

/* ===== Контейнер чатлиста ===== */
.chatlist-container {
  display: flex;
  flex: 1;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

/* ===== Поиск ===== */
.chatlist-search {
  position: relative;
}

.chatlist-search__icon.MuiSvgIcon-root {
  position: absolute;
  top: 50%;
  left: var(--space-2);
  width: 17px;
  height: 17px;
  color: var(--ink-600);
  transform: translateY(-50%);
  pointer-events: none;
}

.chatlist-search__input {
  width: 100%;
  min-height: 36px;
  padding: var(--space-2) var(--space-2) var(--space-2) var(--space-8);
  border: 1px solid var(--ink-500);
  border-radius: var(--radius-sm);
  background: var(--ink-50);
  color: var(--ink-800);
  font: inherit;
  font-size: var(--fs-xs);
}

.chatlist-search__input:not(:placeholder-shown) {
  padding-inline-end: var(--space-8);
}

.chatlist-search__input::-webkit-search-cancel-button {
  display: none;
}

.chatlist-search__input::placeholder {
  color: var(--ink-600);
  opacity: 1;
}

.chatlist-search__clear {
  position: absolute;
  right: var(--space-1);
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--ink-600);
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
}

.chatlist-search__clear:hover {
  background: var(--ink-100);
  color: var(--ink-600);
}

.chatlist-search__input:focus-visible,
.chatlist-search__clear:focus-visible,
.chatlist-item--compact:focus-visible {
  outline: 2px solid var(--teal-800);
}

.chatlist-item--compact:focus-visible,
.chatlist-search__clear:focus-visible {
  outline-offset: -2px;
}

/* ===== Список чатов ===== */
.chatlist {
  list-style: none;
  margin: 0;
  padding: 6px 8px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-gutter: stable;
}

/* Заголовок списка чатов */
.chatlist-heading { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.chatlist-header {
  flex: none;
  padding: var(--space-4) var(--space-3) var(--space-3);
  border-bottom: 1px solid var(--ink-200);
  background: var(--white);
}

.chatlist-title {
  margin: 0 0 var(--space-3);
  font-size: var(--fs-3xl);
  font-weight: var(--fw-semibold);
  color: var(--ink-800);
  line-height: var(--lh-tight);
}

.chatlist-count {
  background: var(--teal-500);
  color: white;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.2px;
}

/* ===== Скроллбар списка чатов ===== */
.chatlist::-webkit-scrollbar { width: 4px; }
.chatlist::-webkit-scrollbar-track { background: transparent; }
.chatlist::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.2);
  border-radius: 4px;
}
.chatlist::-webkit-scrollbar-thumb:hover {
  background: rgba(148, 163, 184, 0.35);
}
.chatlist:hover::-webkit-scrollbar { width: 5px; }
.chatlist:hover::-webkit-scrollbar-thumb {
  background: rgba(20, 184, 166, 0.25);
}
.chatlist {
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, 0.2) transparent;
}

/* «Ничего не найдено» */
.chatlist-no-results {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 36px 16px;
  margin: 12px 4px;
  background: var(--ink-50);
  border: 1px dashed var(--ink-200);
  border-radius: var(--radius-md);
  color: var(--ink-500);
}

.chatlist-no-results__icon {
  font-size: 1.8rem;
  margin-bottom: 12px;
  opacity: 0.6;
}

.chatlist-no-results__text {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--ink-600);
  margin-bottom: 4px;
}

.chatlist-no-results__hint {
  font-size: 0.8rem;
  color: var(--ink-400);
}

/* ===== Карточка собеседника ===== */
.chatlist-item {
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(20px, auto);
  grid-template-columns: minmax(0, 1fr) max-content;
  gap: 2px 10px;
  min-height: 62px;
  padding: 10px 12px 10px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  user-select: none;
  background: var(--white);
  border: 1px solid transparent;
  margin-bottom: 2px;
  transition: all var(--transition-smooth);
}
.chatlist-item:last-child { margin-bottom: 0; }

/* Левая полоска-индикатор */
.chatlist-item::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%) scaleY(0);
  width: 3px;
  height: 24px;
  border-radius: 0 3px 3px 0;
  background: var(--teal-500);
  transition: transform var(--transition-smooth);
}

.chatlist-item:hover {
  background: var(--ink-50);
  border-color: var(--ink-200);
}
.chatlist-item:hover::before {
  transform: translateY(-50%) scaleY(1);
}

.chatlist-item.active {
  background: var(--teal-50);
  border-color: var(--teal-200);
}
.chatlist-item.active::before {
  transform: translateY(-50%) scaleY(1);
  background: var(--teal-500);
  box-shadow: 0 0 6px rgba(20, 184, 166, 0.3);
}

.chatlist-item__name {
  grid-column: 1 / 3;
  grid-row: 1 / 2;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--ink-800);
  letter-spacing: 0.1px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: color var(--transition-fast);
}

.chatlist-item.active .chatlist-item__name {
  color: var(--teal-700);
  font-weight: 700;
}

/* Время */
.chatlist-item__time {
  grid-column: 2 / 3;
  grid-row: 2 / 3;
  white-space: nowrap;
  align-self: center;
  font-size: 0.75rem;
  color: var(--ink-400);
  margin-left: 8px;
}

/* Превью сообщения */
.chatlist-item__preview {
  grid-column: 1 / 2;
  grid-row: 2 / 3;
  align-self: center;
  font-size: 0.835rem;
  color: var(--ink-500);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

/* ===== Непрочитанные ===== */
.chatlist-item.unread {
  background: rgba(20, 184, 166, 0.04);
  border-color: rgba(20, 184, 166, 0.1);
}
.chatlist-item.unread .chatlist-item__name {
  color: var(--ink-900);
  font-weight: 700;
}
.chatlist-item.unread .chatlist-item__preview {
  color: var(--ink-700);
  font-weight: 500;
}

.chatlist-item__unread-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  background: var(--teal-500);
  color: white;
  font-size: 0.7rem;
  font-weight: 700;
  border-radius: 9px;
  margin-left: 8px;
  letter-spacing: 0.2px;
}

.chatlist-item.unread.active {
  background: var(--teal-50);
  border-color: var(--teal-200);
}
.chatlist-item.unread.active .chatlist-item__name {
  color: var(--teal-700);
}

.chatlist-item--compact {
  grid-template:
    "indicator name time" auto
    "indicator preview unread" auto / 16px minmax(0, 1fr) max-content;
  align-content: center;
  gap: 2px var(--space-2);
  width: 100%;
  min-height: 49px;
  margin: 0;
  padding: 5px var(--space-2);
  border-bottom-color: var(--ink-200);
  border-radius: 0;
  font: inherit;
  text-align: left;
  transition: background-color var(--transition-fast);
}

.chatlist-item--compact:not(.active)::before {
  content: none;
}

.chatlist-item--compact.active::before {
  inset: 7px auto 7px 0;
  height: auto;
  background-color: var(--teal-700);
  box-shadow: none;
  transform: none;
}

.chatlist-item--compact:hover,
.chatlist-item--compact.unread,
.chatlist-item--compact.active {
  border-radius: var(--radius-sm);
}

.chatlist-item--compact.unread {
  margin-bottom: 3px;
  background-color: var(--teal-50);
}

.chatlist-item--compact.active {
  border-color: var(--teal-200);
  background-color: var(--teal-100);
}

.chatlist-item__indicator {
  display: grid;
  grid-area: indicator;
  place-items: center;
  color: var(--teal-700);
}

.chatlist-item__indicator .MuiSvgIcon-root {
  width: 16px;
  height: 16px;
}

.chatlist-item__indicator .user-status-dot {
  margin: 0;
  background-color: var(--ink-500);
  box-shadow: none;
  transition: none;
}

.chatlist-item__indicator .user-status-dot.online {
  background-color: var(--success-700);
}

.chatlist-item--compact .chatlist-item__name {
  grid-area: name;
  font-size: var(--fs-sm);
  line-height: var(--lh-snug);
}

.chatlist-item--compact .chatlist-item__time {
  grid-area: time;
  justify-self: end;
  max-width: 76px;
  margin: 0;
  overflow: hidden;
  color: var(--ink-600);
  font-size: var(--fs-xxs);
  font-variant-numeric: tabular-nums;
  text-overflow: ellipsis;
}

.chatlist-item--compact .chatlist-item__preview {
  grid-area: preview;
  color: var(--ink-600);
  font-size: var(--fs-xs);
  line-height: var(--lh-snug);
}

.chatlist-item--compact .chatlist-item__unread-badge {
  grid-area: unread;
  justify-self: end;
  margin: 0;
  background-color: var(--teal-100);
  color: var(--teal-900);
  font-size: var(--fs-xxs);
  font-variant-numeric: tabular-nums;
}

/* Tick-статусы в списке */
.chatlist .msg-status { height: 12px; }
.chatlist .msg-status .check { width: 12px; height: 12px; }

/* Непрочитанное (позиционирование) */
.chatlist-item__unread {
  position: absolute;
  right: 10px;
  top: 10px;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  font-size: 0.72rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--teal-500);
  color: #fff;
}

/* ===== Основная панель сообщений ===== */
.chat-main {
  font-size: clamp(14px, 0.9vw, 16px);
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--ink-50);
}

/* Контейнер сообщений */
.messages-container {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: clamp(10px, 1.8vw, 20px);
  padding-bottom: 12px;
  scroll-behavior: auto;
  scrollbar-gutter: stable;
  overscroll-behavior: none;
  contain: layout style;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
.messages-container.smooth { scroll-behavior: smooth; }

/* Скроллбар сообщений */
.messages-container::-webkit-scrollbar,
.chat-sidebar::-webkit-scrollbar {
  width: 4px;
  background: transparent;
}
.messages-container::-webkit-scrollbar-thumb,
.chat-sidebar::-webkit-scrollbar-thumb {
  background: var(--ink-200);
  border-radius: 4px;
}
.messages-container::-webkit-scrollbar-thumb:hover,
.chat-sidebar::-webkit-scrollbar-thumb:hover {
  background: var(--ink-300);
}
.messages-container::-webkit-scrollbar-track,
.chat-sidebar::-webkit-scrollbar-track {
  background: transparent;
}
.messages-container:hover::-webkit-scrollbar-track,
.chat-sidebar:hover::-webkit-scrollbar-track {
  background: var(--ink-100);
}

/* Разделитель новых сообщений */
.new-messages-divider {
  position: relative;
  z-index: 1;
  display: block;
  width: fit-content;
  margin: 12px auto;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  text-align: center;
  color: var(--teal-600);
  background: var(--teal-50);
  border: 1px solid var(--teal-200);
}

/* Индикатор набора */
.typing-placeholder {
  min-height: 22px;
  display: flex;
  align-items: center;
  padding: 0 12px;
}
.typing-indicator {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  opacity: 1;
  transition: opacity 0.2s ease;
}
.typing-indicator:not([data-visible="true"]) { opacity: 0; }
.typing-indicator .dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--teal-400);
  animation: blink 1.1s infinite ease-in-out;
}
.typing-indicator .typing-text {
  font-size: 0.82rem;
  color: var(--ink-500);
}
.typing-indicator .dot:nth-child(1) { animation-delay: 0s; }
.typing-indicator .dot:nth-child(2) { animation-delay: 0.15s; }
.typing-indicator .dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes blink {
  0%, 80%, 100% { opacity: 0.2; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-2px); }
}

/* Кнопка «новые сообщения» */
.new-message-btn {
  position: absolute;
  bottom: 82px;
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid var(--ink-200);
  background: var(--white);
  color: var(--teal-600);
  font-weight: 600;
  font-size: 0.82rem;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
  cursor: pointer;
  transition: var(--transition-smooth);
}
.new-message-btn:hover {
  transform: translateX(-50%) translateY(-1px);
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.12);
  background: var(--teal-50);
}

/* Нижний зазор внутри сообщений */
.messages-container::after {
  content: "";
  display: block;
  height: 10px;
  pointer-events: none;
}

/* ===== Поле ввода сообщений ===== */
.message-input-wrapper-outer {
  position: relative;
  margin: 4px clamp(10px, 1.8vw, 20px) 10px;
  border-radius: var(--radius-xl);
  border: 1px solid var(--ink-200);
  background: var(--white);
  transition: var(--transition-smooth);
}
.message-input-wrapper-outer:focus-within {
  border-color: var(--teal-300);
  box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.08);
}
.message-input-wrapper-outer.editing {
  border-color: var(--teal-400);
  box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.12);
}
.message-input-wrapper-outer.drag-over {
  outline: 2px dashed var(--teal-400);
  outline-offset: 2px;
}

/* Баннер редактирования */
.message-editing-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px 6px;
  font-size: 0.82rem;
  color: var(--teal-700);
  background: var(--teal-50);
  border-bottom: 1px solid var(--teal-100);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}
.message-editing-cancel {
  border: 0;
  background: transparent;
  color: var(--teal-600);
  font-size: 0.8rem;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition-smooth);
}
.message-editing-cancel:hover {
  background: rgba(20, 184, 166, 0.1);
}

/* Внутренняя обёртка инпута */
.message-input-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: inherit;
}

/* Кнопка прикрепления файла */
.file-upload-button {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--ink-50);
  border: 1px solid var(--ink-200);
  cursor: pointer;
  transition: var(--transition-smooth);
  flex-shrink: 0;
}
.file-upload-button:hover {
  background: var(--teal-50);
  border-color: var(--teal-200);
}

/* Поле ввода текста */
.message-textarea {
  flex: 1;
  resize: none;
  border: 0;
  outline: 0;
  background: transparent;
  font: inherit;
  font-size: 0.95rem;
  line-height: 1.4;
  padding: 8px 4px;
  color: var(--ink-800);
}

/* Кнопка отправки */
.message-send-button {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--teal-500);
  color: #fff;
  cursor: pointer;
  flex-shrink: 0;
  transition: var(--transition-smooth);
}
.message-send-button:hover {
  background: var(--teal-600);
  box-shadow: 0 4px 12px rgba(20, 184, 166, 0.2);
}
.message-send-button.clicked { transform: scale(0.95); }
.msg-file-preview-existing { background: rgba(20, 184, 166, 0.06); }

/* ===== Reduced motion ===== */
@media (prefers-reduced-motion: reduce) {
  .chatlist-item,
  .file-upload-button,
  .typing-indicator .dot,
  .new-message-btn,
  .message-send-button,
  .chatlist-header,
  .chatlist-count,
  .empty-chat-icon {
    transition: none !important;
    animation: none !important;
  }
}

/* Разделитель дат */
.messages-date-divider {
  position: relative;
  text-align: center;
  margin: 16px 0;
  color: var(--ink-500);
  font-weight: 600;
  font-size: 0.8rem;
}
.messages-date-divider span {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--white);
  border: 1px solid var(--ink-200);
}

/* Контейнер окна чата (legacy) */
.chat-window-container {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* ===== Превью файлов в композере ===== */
.msg-file-preview-container {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  padding: 8px 12px 0;
}
.msg-file-preview {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  background: var(--ink-50);
  border: 1px solid var(--ink-200);
  max-width: 320px;
}
.msg-file-name {
  display: flex;
  align-items: center;
  min-width: 0;
  font-size: 13px;
  line-height: 1.2;
}
.msg-file-base {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.msg-file-ext {
  flex: 0 0 auto;
  margin-left: 2px;
  opacity: 0.7;
  font-weight: 600;
  white-space: nowrap;
}
.remove-file {
  -webkit-appearance: none;
  appearance: none;
  border: 0;
  background: transparent;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  cursor: pointer;
  opacity: 0.7;
}
.remove-file:hover {
  background: var(--ink-100);
  opacity: 1;
}
.remove-file svg {
  width: 14px;
  height: 14px;
  display: block;
}

/* Шрифт чата */
.chat-window,
.chat-window .message-bubble,
.chat-window .message-content,
.chat-window .message-time,
.chat-window .file-bubble,
.chat-window .message-input,
.chat-window textarea,
.chat-window input,
.chat-window button {
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, 'Noto Sans', Arial, sans-serif !important;
}
.chat-window .message-time {
  font-weight: 500;
}

/* Выделение сообщений */
.message-row .message-bubble {
  position: relative;
  overflow: visible;
}
.message-row.selection-mode .message-bubble {
  cursor: pointer;
}
.message-bubble::after {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: inherit;
  border: 2px solid var(--teal-400);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
  z-index: 1;
}
.message-bubble.selected::after {
  opacity: 1;
}

/* ===== Контекстное меню ===== */
.message-context-menu {
  position: fixed;
  z-index: 1100;
  min-width: 180px;
  padding: 4px 0;
  background: var(--white);
  border-radius: var(--radius-sm);
  border: 1px solid var(--ink-200);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
  animation: contextMenuFade 120ms ease-out;
}
.message-context-menu-item {
  width: 100%;
  border: none;
  background: transparent;
  text-align: left;
  padding: 8px 16px;
  font-weight: 500;
  font-size: 13px;
  color: var(--ink-700);
  cursor: pointer;
  transition: background 0.1s ease;
}
.message-context-menu-item:hover,
.message-context-menu-item:focus {
  background: var(--teal-50);
  color: var(--teal-700);
}
@keyframes contextMenuFade {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Пересланные сообщения */
.forwarded-meta {
  background: var(--teal-50);
  border-left: 3px solid var(--teal-400);
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  font-size: 12px;
  color: var(--teal-700);
}
.forwarded-label {
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 10px;
  opacity: 0.6;
}
.forwarded-author { font-weight: 600; }
.forwarded-time { font-size: 11px; opacity: 0.6; }

/* ===== Панель выделения сообщений ===== */
.chat-selection-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 12px;
  min-height: calc(var(--chat-header-height) - 20px);
  animation: selectionBarReveal 150ms ease;
}
.chat-selection-cancel,
.chat-selection-counter,
.chat-selection-actions {
  opacity: 0;
  animation: selectionItemFade 180ms ease forwards;
}
.chat-selection-cancel { animation-delay: 20ms; }
.chat-selection-counter {
  flex: 1;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--ink-700);
  animation-delay: 60ms;
}
.chat-selection-actions {
  display: flex;
  gap: 8px;
  animation-delay: 100ms;
}
.chat-selection-cancel {
  border: none;
  background: var(--ink-100);
  color: var(--ink-700);
  font-weight: 600;
  cursor: pointer;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  transition: var(--transition-smooth);
}
.chat-selection-cancel:hover {
  background: var(--ink-200);
}
.chat-selection-cancel:active {
  transform: scale(0.97);
}
.chat-selection-forward {
  border: none;
  background: var(--teal-500);
  color: white;
  font-weight: 600;
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition-smooth);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.chat-selection-forward:disabled {
  background: var(--ink-300);
  cursor: not-allowed;
}
.chat-selection-forward:not(:disabled):hover {
  background: var(--teal-600);
  box-shadow: 0 4px 12px rgba(20, 184, 166, 0.2);
}
.chat-selection-forward:not(:disabled):active {
  transform: scale(0.97);
}
@keyframes selectionBarReveal {
  from { opacity: 0; transform: translateY(-3px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes selectionItemFade {
  from { opacity: 0; transform: translateY(-3px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== Модальное окно пересылки ===== */
.forward-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  padding: 20px;
  backdrop-filter: blur(4px);
}
.forward-modal {
  background: var(--white);
  border-radius: var(--radius-xl);
  max-width: 400px;
  width: 100%;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.16);
  animation: modalZoom 150ms ease-out;
}
.forward-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 18px 20px 10px;
  gap: 12px;
}
.forward-modal-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}
.forward-modal-subtitle {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--ink-500);
}
.forward-modal-close {
  background: transparent;
  border: none;
  font-size: 18px;
  line-height: 18px;
  cursor: pointer;
  color: var(--ink-500);
}
.forward-modal-close:hover { color: var(--ink-700); }
.forward-modal-search { padding: 0 20px 10px; }
.forward-modal-input {
  width: 100%;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--ink-200);
  font-size: 13px;
  transition: var(--transition-smooth);
}
.forward-modal-input:focus {
  outline: none;
  border-color: var(--teal-300);
}
.forward-modal-list {
  padding: 0 20px 20px;
  overflow-y: auto;
  flex: 1;
  display: grid;
  gap: 6px;
}
.forward-modal-item {
  border: 1px solid var(--ink-100);
  text-align: center;
  background: var(--white);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  cursor: pointer;
  transition: var(--transition-smooth);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}
.forward-modal-item:hover {
  background: var(--teal-50);
  border-color: var(--teal-200);
}
.forward-modal-item-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--ink-800);
}
.forward-modal-item-meta {
  font-size: 11px;
  color: var(--ink-500);
  text-align: center;
}
.forward-modal-empty {
  text-align: center;
  padding: 28px 16px;
  color: var(--ink-500);
}
@keyframes modalZoom {
  from { opacity: 0; transform: translateY(-8px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Уведомление об удалённом пользователе */
.deleted-user-notice {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 18px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: var(--radius-sm);
  color: #991b1b;
  font-size: 0.875rem;
  font-weight: 500;
  margin: 0;
}
.deleted-user-notice svg {
  flex-shrink: 0;
  opacity: 0.7;
}

/* ── Оконная история (windowed history, 2026-07) ─────────────────────────── */

/* Индикатор подгрузки старых сообщений при скролле вверх */
.load-older-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 12px;
  margin: 4px auto;
  font-size: 0.8125rem;
  color: #64748b;
}
.load-older-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid #cbd5e1;
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: load-older-spin 0.7s linear infinite;
}
@keyframes load-older-spin {
  to { transform: rotate(360deg); }
}

/* Панель detached-режима (просмотр окна истории из поиска) */
.history-mode-bar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 14px;
  margin: 0 0 6px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: var(--radius-sm, 8px);
  font-size: 0.8125rem;
  color: #1d4ed8;
}
.history-mode-bar-exit {
  border: none;
  background: #2563eb;
  color: #fff;
  padding: 6px 12px;
  border-radius: var(--radius-sm, 8px);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}
.history-mode-bar-exit:hover {
  background: #1d4ed8;
}

/* Подсветка сообщения-якоря после прыжка из поиска */
.history-anchor-highlight {
  animation: history-anchor-pulse 2.4s ease-out;
  border-radius: var(--radius-sm, 8px);
}
@keyframes history-anchor-pulse {
  0% { background: rgba(59, 130, 246, 0.22); }
  70% { background: rgba(59, 130, 246, 0.12); }
  100% { background: transparent; }
}

/* Секция результатов поиска по сообщениям в списке чатов */
.chatlist-msgresults-header {
  padding: 10px 14px 4px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-600);
  list-style: none;
}
:root {
  /* Палитра — дублирует chat.css; переменные общие */
  --teal-50: #f0fdfa;
  --teal-100: #ccfbf1;
  --teal-200: #99f6e4;
  --teal-300: #5eead4;
  --teal-400: #2dd4bf;
  --teal-500: #14b8a6;
  --teal-600: #0d9488;
  --teal-700: #0f766e;
  --ink-50: #f8fafc;
  --ink-100: #f1f5f9;
  --ink-200: #e2e8f0;
  --ink-300: #cbd5e1;
  --ink-400: #94a3b8;
  --ink-500: #64748b;
  --ink-600: #475569;
  --ink-700: #334155;
  --ink-800: #1e293b;
  --ink-900: #0f172a;
  --ink-950: #020617;
  --white: #ffffff;
  --radius-xl: 16px;
  --radius-lg: 14px;
  --radius-sm: 8px;
  --shadow-soft: 0 1px 2px rgba(0, 0, 0, 0.04);
  --transition-smooth: all 0.15s ease;
  --tick-overlap: 6px;
  --time-right-offset: 6px;
  --time-reserve: 66px;
}

/* Ряд сообщения */
.message-row {
  display: flex;
  margin: 2px 10px;
  word-break: break-word;
  contain: layout style;
}
.message-row.own { justify-content: flex-end; }
.message-row.other { justify-content: flex-start; }

/* ===== Пузырь сообщения ===== */
.message-bubble {
  position: relative;
  max-width: 72%;
  padding: 7px 10px;
  border: 1px solid var(--ink-200);
  border-radius: var(--radius-lg);
  background: var(--white);
  box-shadow: var(--shadow-soft);
  contain: layout style;
  transition: box-shadow 0.12s ease;
}

/* Свои сообщения: мягкий тёплый зелёный */
.message-row.own .message-bubble {
  border-bottom-right-radius: 6px;
  border-color: rgba(20, 184, 166, 0.15);
  background: #f0fdf4 !important;
}
/* Чужие */
.message-row.other .message-bubble {
  border-bottom-left-radius: 6px;
  border-color: var(--ink-200);
  background: var(--white);
}

.message-bubble:hover {
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

/* На узких — шире */
@media (max-width: 900px) {
  .message-bubble {
    max-width: 82%;
  }
}
@media (max-width: 600px) {
  .message-bubble {
    max-width: 90%;
  }
}

/* Текст сообщения */
.message-content {
  color: var(--ink-800);
  font-size: 15px;
  line-height: 1.35;
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, 'Noto Color Emoji', 'Apple Color Emoji', Arial, sans-serif;
  white-space: pre-wrap;
}
.message-content::after {
  /* Telegram-like: резервируем место только на ПОСЛЕДНЕЙ визуальной строке */
  content: "";
  display: inline-block;
  width: var(--time-reserve);
  height: 0;
}
/* Если внутри есть блочные элементы (параграфы/коды/списки),
   не добавляем дубликат на самом контейнере */
.message-content:has(> p, > pre, > blockquote, > ul, > ol)::after { content: none; }

/* Резерв только на последней строке последнего параграфа/блока */
.message-content > p:last-child::after,
.message-content > pre:last-child::after,
.message-content > blockquote:last-child::after { 
  content: ""; display: inline-block; width: var(--time-reserve); height: 0; 
}
/* Для списков — добавляем резерв к последнему пункту списка */
.message-content > ul:last-child > li:last-child::after,
.message-content > ol:last-child > li:last-child::after {
  content: ""; display: inline-block; width: var(--time-reserve); height: 0;
}

/* Для ВХОДЯЩИХ: резерв равен «исходящий резерв минус ширина галочек и их зазор»,
   чтобы зазор между текстом и временем совпадал с исходящими */
.message-row.other .message-content::after,
.message-row.other .message-content > p:last-child::after,
.message-row.other .message-content > pre:last-child::after,
.message-row.other .message-content > blockquote:last-child::after,
.message-row.other .message-content > ul:last-child > li:last-child::after,
.message-row.other .message-content > ol:last-child > li:last-child::after {
  width: calc(var(--time-reserve) - (24px - var(--tick-overlap)) - 5px);
}
.message-content p {
  margin: 0 0 0.35em 0;
}
.message-content strong {
  font-weight: 700;
}
.message-content em {
  font-style: italic;
}
.message-content ul,
.message-content ol {
  margin: 0.3em 0 0.3em 1.1em;
}
.message-content code,
.message-content pre {
  padding: 0.2em 0.4em;
  border: 1px solid var(--ink-200);
  border-radius: var(--radius-sm);
  background: var(--ink-50);
  font-size: 0.9em;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
}

/* Время */
.message-time {
  position: absolute;
  right: var(--time-right-offset);
  bottom: 3px;
  font-size: 11px;
  line-height: 1;
  color: var(--ink-400);
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

/* Для входящих выравниваем время симметрично от правого края,
   как отступ текста от левого в исходящих (10px) */
.message-row.other .message-time {
  right: 10px;
}

/* Для входящих — добавляем невидимый «эквивалент галочек», чтобы зазор совпадал с исходящими */
.message-row.other .message-time::after {
  content: "";
  display: inline-block;
  flex: 0 0 auto;
  width: calc(24px - var(--tick-overlap));
  height: 12px;
}

/* Но в нашем случае отступ должен равняться внутреннему паддингу слева у исходящих,
   поэтому убираем дополнительный «хвост» справа для входящих */
.message-row.other .message-time::after {
  display: none;
  width: 0;
  height: 0;
}

.message-content.emoji-only {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font-size: clamp(32px, 5vw, 44px);
  line-height: 1.1;
  white-space: normal;
  letter-spacing: 0.02em;
}

.message-content.emoji-only::after {
  width: var(--time-reserve);
}

.message-content.emoji-only[data-emoji-count="1"] {
  font-size: clamp(42px, 7vw, 56px);
}

.message-content.emoji-only[data-emoji-count="2"] {
  font-size: clamp(36px, 6vw, 50px);
}

.message-content.emoji-only[data-emoji-count="3"] {
  font-size: clamp(34px, 5.5vw, 46px);
}

.message-content.emoji-only[data-emoji-count="4"] {
  font-size: clamp(32px, 5vw, 44px);
}

/* Статусы доставки */
.msg-status {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0;
  height: 12px;
  color: var(--ink-400);
  opacity: 1;
  transition: color 0.12s ease;
}
.msg-status .check { width: 12px; height: 12px; transform: translateY(1px); }
.msg-status .one { margin-right: calc(-1 * var(--tick-overlap)); z-index: 1; }
.msg-status .two { z-index: 2; opacity: 0; transition: opacity 0.12s ease; }
.msg-status.sent .one { opacity: 1; }
.msg-status.sent .two { opacity: 0; }
.msg-status.delivered { color: var(--ink-400); }
.msg-status.delivered .two { opacity: 1; }
.msg-status.read { color: #3B82F6; }
.msg-status.read .two { opacity: 1; }

@media (prefers-color-scheme: dark) {
  .msg-status { color: #8A8F98; }
  .msg-status.read { color: #60A5FA; }
}

/* ===== Вложения ===== */
.attachments {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  max-width: 100%;
  margin-top: 4px;
  gap: 6px;
}

/* ─── Время внизу для сообщений с файлами ─── */
.message-bubble.has-attachments .message-time {
  position: static;
  display: flex;
  justify-content: flex-end;
  margin-top: 4px;
}

/* Для сообщений только с картинками — время поверх картинки внизу справа */
.message-bubble.has-images .message-time {
  position: absolute;
  bottom: 6px;
  right: 8px;
  margin-top: 0;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  padding: 1px 6px;
  border-radius: 8px;
  font-size: 10px;
  backdrop-filter: blur(4px);
}
.message-bubble.has-images .message-time .msg-status {
  color: #fff;
}

.msg-file-bubble {
  display: flex;
  align-items: center;
  max-width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--ink-50);
  gap: 6px;
}
.message-row.own .msg-file-bubble {
  background: rgba(20, 184, 166, 0.06);
}

/* Кнопка скачивания на файл-бабле */
.msg-file-download-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: inherit;
  opacity: 0.4;
  cursor: pointer;
  transition: opacity 0.15s, background 0.15s;
  padding: 0;
  margin-left: auto;
}
.msg-file-download-btn:hover {
  opacity: 0.85;
  background: rgba(255, 255, 255, 0.1);
}

/* Курсор «preview» для файлового блока */
.msg-file-info {
  cursor: pointer;
}

/* Строка файла */
.msg-file-info {
  display: flex;
  align-items: center;
  min-width: 0;
  max-width: 100%;
  gap: 10px;
  color: inherit;
  text-decoration: none;
}

/* --- важные фиксации ширины/выравнивания внутри бабла --- */
.message-bubble .attachments .msg-file-name {
  /* некоторые глобальные стили могли навешать space-between; запрещаем */
  display: inline-flex !important;
  align-items: center;
  justify-content: flex-start !important;
  min-width: 0;
  max-width: 100%;
  gap: 4px;
  font-weight: 600;
  font-size: 14px;
}
/* -------------------------------------------------------- */

.msg-file-info:hover .msg-file-name {
  text-decoration: underline;
}

.msg-file-icon {
  display: grid;
  flex: 0 0 26px;
  place-items: center;
  width: 26px;
  height: 26px;
  border: 1px solid var(--ink-200);
  border-radius: 6px;
  background: var(--white);
}
.msg-file-icon-img {
  width: 16px;
  height: 16px;
  opacity: 0.85;
}

/* ===== Upload progress circle for optimistic file messages ===== */
.msg-file-bubble.uploading {
  position: relative;
  background: rgba(0,0,0,0.05);
}
.upload-progress-circle {
  width: 42px;
  height: 42px;
  margin-right: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.circular-chart {
  width: 42px;
  height: 42px;
}
.circular-chart .circle-bg {
  fill: none;
  stroke: #eee;
  stroke-width: 3.8;
}
.circular-chart .circle {
  fill: none;
  stroke-width: 3.8;
  stroke-linecap: round;
  stroke: #14b8a6; /* teal */
  transition: stroke-dasharray .25s ease;
}
.circular-chart .percentage {
  fill: #333;
  font-size: 10px;
  text-anchor: middle;
  font-weight: 600;
}
.msg-file-bubble.upload-failed {
  background: rgba(255,0,0,0.08);
  border: 1px solid rgba(255,0,0,0.2);
}
.msg-file-bubble.upload-failed .msg-file-name { color: #b00020; }
.retry-upload-btn {
  margin-top: 4px;
  background: #fff;
  border: 1px solid #b00020;
  color: #b00020;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
}
.retry-upload-btn:hover { background: #b00020; color: #fff; }

/* Текстовая часть */
.msg-file-meta {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-width: 0;
}

/* делим имя на базу и расширение, обрезаем только базу */
.msg-file-base {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.msg-file-ext {
  flex: 0 0 auto;
  margin-left: 2px;
  font-weight: 700;
  white-space: nowrap;
  opacity: 0.85;
}

.msg-file-size {
  color: var(--ink-500);
  font-size: 0.78rem;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .message-bubble {
    transition: none !important;
  }
}

/* FIX: lock file-name layout inside attachments so long filenames don't stretch the bubble */
.message-bubble .attachments .msg-file-name {
  display: inline-flex !important;
  align-items: center;
  justify-content: flex-start !important;
  width: 100%;
  min-width: 0;
  gap: 4px;
  font-weight: 600;
  font-size: 14px;
}
/* base part shrinks and ellipsizes; extension always visible */
.message-bubble .attachments .msg-file-base {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.message-bubble .attachments .msg-file-ext {
  flex: 0 0 auto;
  margin-left: 2px;
  font-weight: 700;
  white-space: nowrap;
  opacity: 0.85;
}

/* ─── Inline image thumbnails ─── */
.msg-image-thumb {
  max-width: 280px;
  min-height: 60px;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  position: relative;
  background: var(--ink-100);
}

/* Для чисто-картиночных сообщений — убираем лишние отступы */
.message-bubble.has-images {
  padding: 3px;
}
.message-bubble.has-images .attachments {
  margin-top: 0;
  border-radius: 10px;
  overflow: hidden;
}

/* ─── Multi-image: Telegram-style uniform-width grid ─── */
.message-bubble.multi-images .attachments {
  width: 280px;
  align-items: stretch;
  gap: 2px;
}

/* Каждая картинка занимает полную ширину контейнера */
.message-bubble.multi-images .msg-image-thumb {
  max-width: none;
  width: 100%;
  max-height: 200px;
  border-radius: 0;
  min-height: 50px;
}

/* Изображения обрезаются по высоте, заполняя ширину */
.message-bubble.multi-images .msg-image-thumb .msg-image-thumb-img {
  width: 100%;
  max-height: 200px;
  object-fit: cover;
  border-radius: 0;
}

/* Скелетон для мульти-картинок */
.message-bubble.multi-images .msg-image-thumb .msg-image-thumb-skeleton {
  width: 100%;
  height: 140px;
  border-radius: 0;
}

/* Заглушка ошибки в мульти тоже занимает полную ширину */
.message-bubble.multi-images .msg-image-thumb.msg-image-thumb-failed {
  width: 100%;
  border-radius: 0;
  border: none;
  border-top: 1px dashed var(--ink-200);
  border-bottom: 1px dashed var(--ink-200);
}

.msg-image-thumb-img {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: 6px;
  transition: opacity 0.2s;
}

.msg-image-thumb-img:hover {
  opacity: 0.9;
}

.msg-image-thumb-failed {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 120px;
  height: 80px;
  border: 1px dashed var(--ink-200);
  border-radius: 8px;
}

.msg-image-thumb-skeleton {
  width: 200px;
  height: 140px;
  border-radius: 8px;
  background: linear-gradient(
    90deg,
    var(--ink-100) 25%,
    var(--ink-200) 50%,
    var(--ink-100) 75%
  );
  background-size: 200% 100%;
  animation: msg-thumb-shimmer 1.5s ease-in-out infinite;
}

@keyframes msg-thumb-shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* end */.emoji-toggle-button {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 999px;
  border: 1px solid rgba(20, 184, 166, 0.25);
  background: linear-gradient(180deg, #f8fffd, #ecfeff);
  color: var(--ink-600);
  cursor: pointer;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast),
    border-color var(--transition-fast), background-color var(--transition-fast);
}

.emoji-toggle-button span {
  font-size: 22px;
  line-height: 1;
}

.emoji-toggle-button:hover {
  transform: translateY(-1px);
  border-color: rgba(20, 184, 166, 0.45);
  box-shadow: 0 6px 16px rgba(20, 184, 166, 0.18);
}

.emoji-toggle-button.active {
  background: linear-gradient(180deg, #ecfeff, #d5f5ee);
  border-color: rgba(20, 184, 166, 0.55);
  box-shadow: inset 0 0 0 1px rgba(20, 184, 166, 0.25);
}

.emoji-picker-popover {
  position: absolute;
  bottom: calc(100% + 12px);
  left: 0;
  right: auto;
  z-index: 30;
  max-width: 100%;
}

.emoji-picker {
  width: min(360px, 88vw);
  max-height: 420px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  border-radius: 18px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  background: linear-gradient(180deg, #ffffff, #f9fffe);
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.18);
}

.emoji-picker__header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.emoji-picker__search {
  flex: 1;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(236, 254, 255, 0.7);
  padding: 8px 12px;
  font-size: 0.95rem;
  color: var(--ink-700);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.emoji-picker__search:focus {
  outline: none;
  border-color: rgba(20, 184, 166, 0.65);
  box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.18);
  background: #ffffff;
}

.emoji-picker__close {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: linear-gradient(180deg, #ffffff, #f4fbfa);
  cursor: pointer;
  color: var(--ink-600);
  font-size: 20px;
  line-height: 1;
  display: grid;
  place-items: center;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast),
    border-color var(--transition-fast);
}

.emoji-picker__close:hover {
  transform: translateY(-1px);
  border-color: rgba(20, 184, 166, 0.45);
  box-shadow: 0 6px 16px rgba(20, 184, 166, 0.18);
}

.emoji-picker__categories {
  display: grid;
  grid-auto-flow: column;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: thin;
}

.emoji-picker__categories::-webkit-scrollbar {
  height: 6px;
}

.emoji-picker__categories::-webkit-scrollbar-thumb {
  background: rgba(20, 184, 166, 0.3);
  border-radius: 999px;
}

.emoji-picker__category {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border: none;
  border-radius: 14px;
  padding: 0;
  display: grid;
  place-items: center;
  font-size: 22px;
  color: var(--ink-600);
  background: rgba(15, 23, 42, 0.06);
  cursor: pointer;
  transition: background-color var(--transition-fast), color var(--transition-fast),
    transform var(--transition-fast), box-shadow var(--transition-fast);
}

.emoji-picker__category:hover {
  transform: translateY(-1px);
  background: rgba(20, 184, 166, 0.18);
  color: var(--ink-800);
  box-shadow: 0 6px 12px rgba(20, 184, 166, 0.18);
}

.emoji-picker__category.active {
  background: linear-gradient(180deg, #14b8a6, #0d9488);
  color: white;
  box-shadow: 0 10px 18px rgba(20, 184, 166, 0.25);
}

.emoji-picker__body {
  position: relative;
  border-radius: 14px;
  background: rgba(248, 255, 253, 0.75);
  border: 1px solid rgba(148, 163, 184, 0.25);
  padding: 10px;
  max-height: 260px;
  overflow-y: auto;
}

.emoji-picker__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(36px, 1fr));
  gap: 6px;
}

.emoji-picker__item {
  height: 38px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.8);
  display: grid;
  place-items: center;
  font-size: 22px;
  cursor: pointer;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast),
    border-color var(--transition-fast), background-color var(--transition-fast);
}

.emoji-picker__item:hover {
  transform: translateY(-2px);
  border-color: rgba(20, 184, 166, 0.4);
  background: #ffffff;
  box-shadow: 0 8px 14px rgba(20, 184, 166, 0.18);
}

.emoji-picker__state {
  padding: 16px;
  text-align: center;
  font-size: 0.9rem;
  color: var(--ink-600);
}

.emoji-picker__state--error {
  color: #b91c1c;
}

@media (max-width: 520px) {
  .emoji-picker-popover {
    left: 0;
    right: auto;
  }

  .emoji-picker {
    width: min(360px, calc(100vw - 32px));
    margin: 0 auto;
  }
}
/* Базовые стили для плашки с датой */
.date-badge {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 4px 0;
  position: relative;
  z-index: 10;
}

.date-badge__text {
  background: rgba(0, 0, 0, 0.6);
  color: rgba(255, 255, 255, 0.9);
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.5px;
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  transition: all 0.2s ease;
}

/* Стили для inline-даты (между сообщениями) */
.date-badge--inline {
  margin: 16px 0 8px 0;
}

/* Стили для sticky-даты (плавающая сверху) */
.date-badge--sticky {
  position: sticky;
  top: 0;
  margin: 0;
  padding: 4px 0;
  background: transparent;
  z-index: 100;
}

/* Общий стиль для текста (одинаковый для inline и sticky) */
.date-badge__text {
  background: rgba(0, 0, 0, 0.6);
  color: rgba(255, 255, 255, 0.9);
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.5px;
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  transition: all 0.2s ease;
}

/* Анимации видимости */
.date-badge--visible {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.date-badge--hidden {
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
}

/* Анимация появления sticky-даты */
.date-badge--sticky.date-badge--visible {
  animation: slideDownFade 0.3s ease-out;
}

@keyframes slideDownFade {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Анимация исчезновения sticky-даты */
.date-badge--sticky.date-badge--hidden {
  animation: slideUpFade 0.3s ease-in;
}

@keyframes slideUpFade {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(-20px);
  }
}

/* Hover эффект для лучшего UX */
.date-badge__text:hover {
  background: rgba(0, 0, 0, 0.7);
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* Стили для первой даты в чате (уменьшенный верхний отступ) */
.date-badge--first {
  margin-top: 4px !important;
}

/* Адаптация под светлую тему (если она есть) */
@media (prefers-color-scheme: light) {
  .date-badge__text {
    background: rgba(255, 255, 255, 0.9);
    color: rgba(0, 0, 0, 0.8);
    border: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  }
  
  .date-badge--sticky {
    background: transparent;
  }
  
  .date-badge__text:hover {
    background: rgba(255, 255, 255, 1);
    border-color: rgba(0, 0, 0, 0.2);
  }
}

/* ─── FilePreviewModal ──────────────────────────────── */
.fp-dialog-paper {
  width: 90vw !important;
  max-width: 1100px !important;
  height: 85vh !important;
  max-height: 85vh !important;
  display: flex !important;
  flex-direction: column !important;
  border-radius: 12px !important;
  overflow: hidden !important;
  background: var(--bg-primary, #1e1e2e) !important;
  color: var(--text-primary, #e0e0e0) !important;
}

/* ─── Заголовок ─── */
.fp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg-secondary, #2a2a3e);
  border-bottom: 1px solid var(--border-color, rgba(255, 255, 255, 0.08));
  flex-shrink: 0;
  min-height: 48px;
}

.fp-header-info {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
  overflow: hidden;
}

.fp-header-name {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 600px;
}

.fp-header-size {
  font-size: 12px;
  opacity: 0.55;
  white-space: nowrap;
}

.fp-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.fp-header-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-primary, #e0e0e0);
  cursor: pointer;
  transition: background 0.15s;
}

.fp-header-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.fp-close-btn:hover {
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
}

/* ─── Тело ─── */
.fp-body {
  flex: 1;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  min-height: 0;
}

/* ─── Загрузка / ошибка ─── */
.fp-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  opacity: 0.7;
}

.fp-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(255, 255, 255, 0.15);
  border-top-color: var(--accent-color, #6366f1);
  border-radius: 50%;
  animation: fp-spin 0.8s linear infinite;
}

@keyframes fp-spin {
  to {
    transform: rotate(360deg);
  }
}

.fp-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  color: #ef4444;
  text-align: center;
}

/* ─── Кнопка скачивания ─── */
.fp-download-btn {
  padding: 10px 24px;
  border: none;
  border-radius: 8px;
  background: var(--accent-color, #6366f1);
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

.fp-download-btn:hover {
  background: var(--accent-hover, #4f46e5);
}

.fp-download-btn:active {
  transform: scale(0.97);
}

/* ─── Изображения ─── */
.fp-image-container {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  cursor: zoom-in;
  transition: align-items 0.15s, justify-content 0.15s;
}

.fp-image-zoomed-container {
  overflow: auto;
  cursor: zoom-out;
  align-items: flex-start;
  justify-content: flex-start;
}

.fp-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 6px;
  user-select: none;
  transition: max-width 0.2s, max-height 0.2s;
}

.fp-image-zoomed {
  max-width: none;
  max-height: none;
  border-radius: 0;
}

/* ─── Download button states ─── */
.fp-header-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.fp-btn-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: fp-spin 0.7s linear infinite;
}

/* ─── PDF ─── */
.fp-pdf-frame {
  width: 100%;
  height: 100%;
  border: none;
  border-radius: 6px;
  background: #fff;
}

.fp-pdf-viewer {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  background: #f0f0f0;
  border-radius: 6px;
  overflow: hidden;
}

.fp-pdf-toolbar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 6px 12px;
  background: #2c2c2c;
  color: #fff;
  font-size: 13px;
  flex-shrink: 0;
  user-select: none;
}

.fp-pdf-btn {
  background: rgba(255, 255, 255, 0.12);
  border: none;
  color: #fff;
  font-size: 14px;
  width: 28px;
  height: 28px;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.fp-pdf-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.25);
}

.fp-pdf-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.fp-pdf-page-info,
.fp-pdf-scale-info {
  min-width: 50px;
  text-align: center;
}

.fp-pdf-canvas-container {
  flex: 1;
  overflow: auto;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 12px;
  background: #525659;
}

.fp-pdf-canvas-container canvas {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  border-radius: 2px;
}

/* ─── Видео ─── */
.fp-video-container {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

.fp-video {
  max-width: 100%;
  max-height: 100%;
  border-radius: 6px;
  background: #000;
}

/* ─── Аудио ─── */
.fp-audio-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 32px;
}

.fp-audio-icon {
  font-size: 64px;
  line-height: 1;
}

.fp-audio-name {
  font-size: 16px;
  font-weight: 500;
  text-align: center;
  word-break: break-all;
  max-width: 400px;
}

.fp-audio {
  width: 100%;
  max-width: 420px;
}

/* ─── Текст / Код ─── */
.fp-text-container {
  width: 100%;
  height: 100%;
  overflow: auto;
  border-radius: 6px;
  background: var(--bg-tertiary, #171726);
}

.fp-text-content {
  margin: 0;
  padding: 16px 20px;
  font-family: "JetBrains Mono", "Fira Code", "Consolas", monospace;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-primary, #e0e0e0);
  tab-size: 4;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ─── DOCX (docx-preview рендерит со стилями) ─── */
.fp-docx-container {
  width: 100%;
  height: 100%;
  overflow: auto;
  border-radius: 6px;
  background: #fff;
  color: #222;
}

.fp-docx-content {
  min-height: 100%;
}

/* docx-preview wrapper стили — обеспечиваем корректное отображение страниц */
.fp-docx-content .docx-wrapper {
  background: #e8e8e8 !important;
  padding: 16px !important;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.fp-docx-content .docx-wrapper > section.docx {
  background: #fff !important;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15) !important;
  border-radius: 4px;
  margin: 0 auto;
  min-height: 200px;
}

/* ─── Excel ─── */
.fp-excel-container {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.fp-excel-tabs {
  display: flex;
  gap: 2px;
  padding: 6px 8px 0;
  background: var(--bg-secondary, #2a2a3e);
  flex-shrink: 0;
  overflow-x: auto;
}

.fp-excel-tab {
  padding: 6px 14px;
  border: none;
  border-radius: 6px 6px 0 0;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary, #e0e0e0);
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}

.fp-excel-tab:hover {
  background: rgba(255, 255, 255, 0.1);
}

.fp-excel-tab.active {
  background: var(--accent-color, #6366f1);
  color: #fff;
}

.fp-excel-table-wrap {
  flex: 1;
  overflow: auto;
  border-radius: 6px;
  background: #fff;
}

.fp-excel-table {
  border-collapse: collapse;
  font-size: 12px;
  color: #222;
  min-width: 100%;
}

.fp-excel-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f0f0f0;
  font-weight: 600;
  text-align: left;
}

.fp-excel-table th,
.fp-excel-table td {
  border: 1px solid #ddd;
  padding: 5px 10px;
  white-space: nowrap;
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fp-excel-table tr:hover td {
  background: #f8f8ff;
}

.fp-excel-truncated {
  padding: 10px;
  text-align: center;
  font-size: 12px;
  opacity: 0.5;
  background: #fff;
  color: #333;
}

/* ─── Неподдерживаемый ─── */
.fp-unsupported {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 32px;
  text-align: center;
}

.fp-unsupported-icon {
  font-size: 56px;
  line-height: 1;
  opacity: 0.5;
}

.fp-unsupported-text {
  font-size: 15px;
  opacity: 0.65;
}

.fp-unsupported-name {
  font-size: 13px;
  opacity: 0.4;
  word-break: break-all;
  max-width: 400px;
}

/* ─── Адаптивность ─── */
@media (max-width: 640px) {
  .fp-dialog-paper {
    width: 100vw !important;
    height: 100vh !important;
    max-height: 100vh !important;
    border-radius: 0 !important;
    margin: 0 !important;
  }

  .fp-header-name {
    max-width: 200px;
  }

  .fp-docx-content {
    padding: 16px;
  }
}
/**
 * Design tokens — CSS-переменные для использования во всех CSS-файлах проекта.
 * Синхронизированы с src/theme/tokens.js.
 *
 * Бирюзовая корпоративная палитра СИТИ.
 */

:root {
  /* === Teal (primary) === */
  --teal-50: #f0fdfa;
  --teal-100: #ccfbf1;
  --teal-200: #99f6e4;
  --teal-300: #5eead4;
  --teal-400: #2dd4bf;
  --teal-500: #14b8a6;
  --teal-600: #0d9488;
  --teal-700: #0f766e;
  --teal-800: #115e59;
  --teal-900: #134e4a;
  --teal-950: #042f2e;

  /* === Slate (neutral) === */
  --slate-50: #f8fafc;
  --slate-100: #f1f5f9;
  --slate-200: #e2e8f0;
  --slate-300: #cbd5e1;
  --slate-400: #94a3b8;
  --slate-500: #64748b;
  --slate-600: #475569;
  --slate-700: #334155;
  --slate-800: #1e293b;
  --slate-900: #0f172a;
  --slate-950: #020617;

  /* Backwards-compat для старых файлов (чат, сайдбар) */
  --ink-900: #0f172a;
  --ink-800: #1e293b;
  --ink-700: #334155;
  --ink-600: #475569;
  --ink-500: #64748b;
  --ink-400: #94a3b8;
  --ink-300: #cbd5e1;
  --ink-200: #e2e8f0;
  --ink-100: #f1f5f9;
  --ink-50: #f8fafc;

  /* === Semantic === */
  --success-50: #ecfdf5;
  --success-100: #d1fae5;
  --success-500: #10b981;
  --success-600: #059669;
  --success-700: #047857;

  --warning-50: #fffbeb;
  --warning-100: #fef3c7;
  --warning-500: #f59e0b;
  --warning-600: #d97706;
  --warning-700: #b45309;

  --danger-50: #fef2f2;
  --danger-100: #fee2e2;
  --danger-500: #ef4444;
  --danger-600: #dc2626;
  --danger-700: #b91c1c;

  --info-50: #ecfeff;
  --info-100: #cffafe;
  --info-500: #06b6d4;
  --info-600: #0891b2;
  --info-700: #0e7490;

  /* === Semantic tokens (light) === */
  --bg-app: var(--slate-50);
  --bg-surface: #ffffff;
  --bg-surface-alt: var(--slate-50);
  --bg-surface-hover: var(--slate-100);
  --bg-elevated: #ffffff;
  --bg-inverse: var(--slate-900);
  --bg-brand: var(--teal-500);
  --bg-brand-soft: var(--teal-50);
  --bg-brand-hover: var(--teal-600);

  --text-primary: var(--slate-900);
  --text-secondary: var(--slate-600);
  --text-tertiary: var(--slate-500);
  --text-disabled: var(--slate-400);
  --text-inverse: #ffffff;
  --text-brand: var(--teal-700);
  --text-on-brand: #ffffff;

  --border: var(--slate-200);
  --border-strong: var(--slate-300);
  --border-brand: var(--teal-500);
  --border-focus: var(--teal-500);

  /* === Radii === */
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --radius-2xl: 28px;
  --radius-full: 9999px;

  /* === Shadows === */
  --shadow-xs: 0 1px 2px 0 rgba(15, 23, 42, 0.05);
  --shadow-sm: 0 1px 3px 0 rgba(15, 23, 42, 0.08), 0 1px 2px -1px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.08), 0 2px 4px -2px rgba(15, 23, 42, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -4px rgba(15, 23, 42, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(15, 23, 42, 0.10), 0 8px 10px -6px rgba(15, 23, 42, 0.06);
  --shadow-2xl: 0 25px 50px -12px rgba(15, 23, 42, 0.18);
  --shadow-teal-sm: 0 2px 8px -2px rgba(20, 184, 166, 0.20);
  --shadow-teal-md: 0 8px 20px -6px rgba(20, 184, 166, 0.28);
  --shadow-teal-lg: 0 14px 40px -10px rgba(20, 184, 166, 0.35);
  --shadow-ring: 0 0 0 3px rgba(20, 184, 166, 0.25);

  /* === Spacing === */
  --space-0: 0px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 28px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-14: 56px;
  --space-16: 64px;

  /* === Typography === */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'SF Mono', Consolas, 'Courier New', monospace;

  --fs-xxs: 11px;
  --fs-xs: 12px;
  --fs-sm: 13px;
  --fs-base: 14px;
  --fs-md: 15px;
  --fs-lg: 16px;
  --fs-xl: 18px;
  --fs-2xl: 20px;
  --fs-3xl: 24px;
  --fs-4xl: 30px;
  --fs-5xl: 36px;

  --fw-regular: 400;
  --fw-medium: 500;
  --fw-semibold: 600;
  --fw-bold: 700;

  --lh-tight: 1.2;
  --lh-snug: 1.35;
  --lh-normal: 1.5;
  --lh-relaxed: 1.7;

  /* === Transitions === */
  --t-fast: 120ms cubic-bezier(0.4, 0, 0.2, 1);
  --t-base: 180ms cubic-bezier(0.4, 0, 0.2, 1);
  --t-slow: 260ms cubic-bezier(0.4, 0, 0.2, 1);
  --t-spring: 320ms cubic-bezier(0.34, 1.56, 0.64, 1);

  /* === Z-index === */
  --z-dropdown: 1000;
  --z-sticky: 1100;
  --z-navbar: 1150;
  --z-modal-backdrop: 1300;
  --z-modal: 1400;
  --z-popover: 1500;
  --z-tooltip: 1600;
  --z-toast: 1700;

  /* === Gradients === */
  --gradient-brand: linear-gradient(135deg, var(--teal-500) 0%, var(--teal-600) 100%);
  --gradient-brand-soft: linear-gradient(135deg, var(--teal-50) 0%, var(--teal-100) 100%);
  --gradient-surface: linear-gradient(180deg, rgba(255, 255, 255, 0.9) 0%, rgba(255, 255, 255, 0.7) 100%);
  --gradient-ink: linear-gradient(135deg, var(--slate-800) 0%, var(--slate-950) 100%);
  --gradient-teal-ink: linear-gradient(160deg, var(--teal-900) 0%, var(--slate-900) 70%, #031a20 100%);
}

/* === Utility primitives === */

.u-glass {
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(14px) saturate(180%);
  -webkit-backdrop-filter: blur(14px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.6);
}

.u-glass-dark {
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(14px) saturate(180%);
  -webkit-backdrop-filter: blur(14px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.u-focus-ring:focus-visible {
  outline: none;
  box-shadow: var(--shadow-ring);
}

.u-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* === Page enter animations === */

@keyframes u-page-fade-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

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

.u-animate-page-in {
  animation: u-page-fade-in 320ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.u-animate-fade-in {
  animation: u-fade-in 240ms ease-out both;
}

.u-animate-scale-in {
  animation: u-scale-in 280ms cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@media (prefers-reduced-motion: reduce) {
  .u-animate-page-in,
  .u-animate-fade-in,
  .u-animate-scale-in {
    animation: none !important;
  }
}

/* Scrollbar базовый */

.u-scroll {
  scrollbar-width: thin;
  scrollbar-color: var(--slate-300) transparent;
}

.u-scroll::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.u-scroll::-webkit-scrollbar-track {
  background: transparent;
}

.u-scroll::-webkit-scrollbar-thumb {
  background: var(--slate-300);
  border-radius: var(--radius-full);
}

.u-scroll::-webkit-scrollbar-thumb:hover {
  background: var(--slate-400);
}

.city-call {
  --call-theater: #13282b;
  --call-theater-raised: #1d4142;
  --call-theater-text: #e8f7f5;
  --call-theater-muted: #bddbd7;
  --call-theater-border: #2e5050;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  height: 100dvh;
  min-height: 0;
  padding: clamp(14px, 2.2vw, 24px);
  overflow: hidden;
  color: var(--text-primary);
  background: var(--bg-app);
  color-scheme: light;
  font: var(--fs-base)/var(--lh-normal) var(--font-sans);
}

.city-call *,
.city-call *::before,
.city-call *::after { box-sizing: border-box; }

.city-call--loading {
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
}

.city-call :is(p, h1, h2) { margin: 0; }

.city-call-heading,
.city-call-identity,
.city-call-mode,
.city-call-status {
  display: flex;
  align-items: center;
}

.city-call-heading {
  justify-content: space-between;
  flex: none;
  gap: var(--space-4);
  min-height: 64px;
}

.city-call-identity { gap: var(--space-3); min-width: 0; }

.city-call-person { min-width: 0; }

.city-call-person h1 {
  font-size: clamp(21px, 3vw, 30px);
  line-height: var(--lh-tight);
  font-weight: var(--fw-bold);
  letter-spacing: -.035em;
  overflow-wrap: anywhere;
}

.city-call .city-call-mode {
  gap: var(--space-1);
  margin-bottom: var(--space-1);
  color: var(--text-brand);
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
}

.city-call-mode svg { font-size: 16px; }

.city-call-avatar {
  display: grid;
  place-items: center;
  width: 52px;
  aspect-ratio: 1;
  flex: none;
  border-radius: 50%;
  color: var(--teal-900);
  background: var(--teal-100);
  font-size: var(--fs-lg);
  font-weight: var(--fw-bold);
  letter-spacing: -.03em;
}

.city-call-status {
  flex: none;
  gap: var(--space-2);
  padding: 6px 11px;
  border: 1px solid var(--teal-200);
  border-radius: var(--radius-full);
  color: var(--teal-900);
  background: var(--teal-50);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
}

.city-call-status-dot {
  flex: none;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--teal-700);
}

.city-call-clock {
  padding-inline-start: var(--space-2);
  border-inline-start: 1px solid var(--teal-200);
  font-variant-numeric: tabular-nums;
}

.city-call-content {
  display: grid;
  flex: 1 1 0;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
}

.city-call-preview-layout,
.city-call-share-layout {
  display: grid;
  min-height: 0;
  gap: var(--space-4);
}

.city-call-preview-layout { grid-template-columns: minmax(0, 1.8fr) minmax(300px, 1fr); }

.city-call-preview-layout[data-audio="true"] {
  align-self: center;
  justify-self: center;
  width: min(100%, 790px);
  grid-template-columns: minmax(0, .9fr) minmax(300px, 1fr);
}

.city-call-stage,
.city-call-tile {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  isolation: isolate;
  border-radius: var(--radius-lg);
  background: var(--call-theater);
  color: var(--call-theater-text);
}

.city-call-stage { min-height: 180px; }

.city-call-stage > video,
.city-call-tile > video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.city-call-stage > video[data-mirrored="true"],
.city-call-tile > video[data-mirrored="true"] { transform: scaleX(-1); }

.city-call-preview-stage > video,
.city-call-tile[data-compact="true"] > video { object-fit: cover; }

.city-call-stage-message {
  position: relative;
  display: grid;
  justify-items: center;
  gap: var(--space-3);
  max-width: 54ch;
  padding: var(--space-5);
  color: var(--call-theater-muted);
  font-weight: var(--fw-medium);
  text-align: center;
}

.city-call-stage-message p[role="alert"] { color: var(--call-theater-text); }

.city-call-stage-message h2 {
  color: var(--call-theater-text);
  font-size: clamp(20px, 3.2vw, 30px);
  font-weight: var(--fw-semibold);
  letter-spacing: -.025em;
}

.city-call-stage-message .city-call-avatar,
.city-call-media-placeholder {
  width: clamp(64px, 11vw, 108px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--call-theater-text);
  background: var(--call-theater-raised);
  box-shadow: 0 0 0 7px #c5f9ec17, 0 0 0 17px #c5f9ec0a;
  font-size: clamp(21px, 4vw, 36px);
}

.city-call-media-placeholder {
  width: 62px;
  box-shadow: none;
}

.city-call-media-placeholder svg { font-size: 27px; }

.city-call-waiting,
.city-call-gallery > .city-call-tile:first-child:last-child {
  background: radial-gradient(ellipse at center, var(--call-theater-raised), var(--call-theater) 72%);
}

.city-call-waiting::before,
.city-call-gallery > .city-call-tile:first-child:last-child:not(:has(video))::before {
  content: "";
  position: absolute;
  width: min(48%, 390px);
  aspect-ratio: 1;
  border-radius: 50%;
  border: 1px solid #c5f9ec14;
  box-shadow: 0 0 0 46px #c5f9ec08, 0 0 0 92px #c5f9ec04;
}

.city-call-waiting [role="timer"] { font-size: var(--fs-xs); font-variant-numeric: tabular-nums; }

.city-call-video-label {
  position: absolute;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  inset: auto auto 12px 12px;
  max-width: calc(100% - 24px);
  padding: 5px 8px;
  border-radius: var(--radius-sm);
  background: #102323ed;
  color: var(--call-theater-text);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  overflow-wrap: anywhere;
}

.city-call-stage > .city-call-video-label { inset: 12px auto auto 12px; }

.city-call-video-label svg { font-size: 16px; }

.city-call-video-label .city-call-status-dot { background: var(--teal-300); }

.city-call-audio-preview {
  display: grid;
  place-items: center;
  min-height: 170px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: radial-gradient(ellipse at center, var(--teal-100), var(--teal-50) 80%);
}

.city-call-audio-preview .city-call-avatar {
  width: 92px;
  border: 1px solid var(--teal-200);
  background: var(--bg-surface);
  font-size: var(--fs-4xl);
  box-shadow: var(--shadow-teal-md);
}

.city-call-gallery {
  display: grid;
  position: absolute;
  inset: 0;
}

.city-call-gallery[data-multiple="true"] {
  grid-template-columns: repeat(auto-fit, minmax(min(230px, 100%), 1fr));
  gap: var(--space-2);
  padding: var(--space-2);
  overflow: auto;
}

.city-call-gallery[data-multiple="true"] .city-call-tile { min-height: 150px; }

.city-call-tile[data-speaking="true"] { outline: 2px solid var(--teal-400); outline-offset: -2px; }

.city-call-speaking { color: var(--teal-200); }

.city-call-self {
  position: absolute;
  z-index: 2;
  bottom: 14px;
  right: 14px;
  width: clamp(100px, 18%, 192px);
  aspect-ratio: 16 / 10;
  border: 1px solid var(--call-theater-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
}

.city-call-self > .city-call-tile { height: 100%; }

.city-call-tile[data-compact="true"] { border-radius: var(--radius-md); }

.city-call-tile[data-compact="true"] .city-call-stage-message .city-call-avatar { width: 38px; font-size: var(--fs-sm); }

.city-call-tile[data-compact="true"] .city-call-video-label {
  inset: auto auto 6px 6px;
  max-width: calc(100% - 12px);
  font-size: var(--fs-xxs);
}

.city-call-share-layout { grid-template-columns: minmax(0, 1fr) clamp(135px, 17%, 194px); }

.city-call-filmstrip {
  display: flex;
  flex-direction: column;
  justify-content: safe center;
  gap: var(--space-2);
  min-height: 0;
  overflow: auto;
}

.city-call-filmstrip > .city-call-tile { flex: none; aspect-ratio: 16 / 10; }

.city-call-settings {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  min-width: 0;
  padding: var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
}

.city-call-settings h2 {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--fs-lg);
  font-weight: var(--fw-bold);
}

.city-call-settings h2 svg { color: var(--text-brand); font-size: 19px; }

.city-call-device-options,
.city-call-device-row,
.city-call-device { display: grid; min-width: 0; gap: var(--space-1); }

.city-call-device-options { gap: var(--space-3); }

.city-call-device {
  color: var(--text-secondary);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
}

.city-call-device > span { display: flex; align-items: center; gap: var(--space-1); }

.city-call-device svg { font-size: 15px; color: var(--text-brand); }

.city-call-device select { width: 100%; min-width: 0; }

.city-call-device-error { font-size: var(--fs-xs); color: var(--danger-700); }

.city-call-mic-level { display: block; width: 100%; height: 6px; margin-block: 4px; }

.city-call-mic-level::-webkit-meter-bar { background: var(--slate-100); border: 0; border-radius: var(--radius-full); }

.city-call-mic-level::-webkit-meter-optimum-value { background: var(--teal-700); border-radius: var(--radius-full); }

.city-call :is(button, select, summary) {
  min-height: 42px;
  padding: 7px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  background: var(--bg-surface);
  font: inherit;
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
}

.city-call :is(button, summary) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  cursor: pointer;
}

.city-call :is(button, summary) svg { flex: none; font-size: 18px; }

.city-call :is(button, select):disabled { opacity: .6; cursor: default; }

.city-call :is(button:not(:disabled), summary):hover { background: var(--bg-surface-hover); }

.city-call :is(button, select, summary):focus-visible,
.city-call-history :is(button, summary):focus-visible {
  outline: 2px solid var(--teal-700);
  outline-offset: 2px;
}

.city-call button.city-call-test,
.city-call button.city-call-cancel {
  width: fit-content;
  min-height: 38px;
  border-color: transparent;
  background: transparent;
  color: var(--text-brand);
}

.city-call button.city-call-cancel { color: var(--text-secondary); }

.city-call button.city-call-primary,
.city-call button.city-call-end {
  min-width: 128px;
  border-color: transparent;
  color: var(--text-on-brand);
  background: var(--teal-700);
}

.city-call button.city-call-primary:not(:disabled):hover { background: var(--teal-800); }

.city-call button.city-call-end { background: var(--danger-700); }

.city-call button.city-call-end:not(:disabled):hover { background: var(--danger-600); }

.city-call button.city-call-reject {
  color: var(--danger-700);
  border-color: var(--danger-100);
  background: var(--danger-50);
}

.city-call-media-controls {
  display: inline-flex;
  justify-content: center;
  gap: var(--space-2);
}

.city-call-settings > .city-call-media-controls {
  margin-top: auto;
  padding-top: var(--space-3);
  border-top: 1px solid var(--border);
}

.city-call button.city-call-media-toggle {
  width: 48px;
  min-height: 48px;
  padding: 0;
  border-radius: var(--radius-lg);
}

.city-call button.city-call-media-toggle svg { font-size: 23px; }

.city-call button.city-call-media-toggle[aria-pressed="true"] {
  color: var(--teal-800);
  background: var(--teal-50);
  border-color: var(--teal-200);
}

.city-call button.city-call-media-toggle[aria-pressed="false"] {
  color: var(--danger-700);
  background: var(--danger-50);
  border-color: var(--danger-100);
}

.city-call button.city-call-media-toggle[aria-pressed="true"]:not(:disabled):hover { background: var(--teal-100); }

.city-call button.city-call-media-toggle[aria-pressed="false"]:not(:disabled):hover,
.city-call button.city-call-reject:not(:disabled):hover { background: var(--danger-100); }

.city-call button.city-call-share-toggle[aria-pressed="true"] {
  color: var(--warning-700);
  border-color: var(--warning-100);
  background: var(--warning-50);
}

.city-call button.city-call-share-toggle[aria-pressed="true"]:not(:disabled):hover { background: var(--warning-100); }

.city-call-actions {
  display: flex;
  flex: none;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.city-call[data-phase="preview"] .city-call-actions { justify-content: flex-end; }

.city-call-error {
  flex: none;
  padding: 7px 10px;
  border: 1px solid var(--danger-100);
  border-radius: var(--radius-md);
  color: var(--danger-700);
  background: var(--danger-50);
  font-size: var(--fs-sm);
}

.city-call-playback { align-self: center; }

.city-call-devices-menu { position: relative; }

.city-call-devices-menu summary { list-style: none; }

.city-call-devices-menu summary::-webkit-details-marker { display: none; }

.city-call-devices-menu[open] .city-call-settings {
  position: absolute;
  z-index: 3;
  bottom: calc(100% + var(--space-2));
  right: 0;
  width: min(270px, 80vw);
  max-height: min(360px, 60dvh);
  overflow: auto;
  box-shadow: var(--shadow-lg);
}

.city-call[data-phase="incoming"] { padding: var(--space-2); }

.city-call-incoming {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
  overflow: hidden;
}

.city-call-incoming-body {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  align-items: center;
  justify-content: safe center;
  gap: var(--space-3);
  min-height: 0;
  padding: var(--space-4);
  text-align: center;
  overflow: auto;
}

.city-call-incoming-body > .city-call-avatar {
  width: 70px;
  margin-block: var(--space-1);
  font-size: var(--fs-3xl);
  box-shadow: 0 0 0 5px var(--teal-50);
}

.city-call-incoming-body .city-call-mode { justify-content: center; }

.city-call-incoming-body h1 { font-size: clamp(20px, 6vw, 26px); }

.city-call .city-call-group-organizer { margin-top: 5px; color: var(--text-secondary); font-size: var(--fs-xs); overflow-wrap: anywhere; }

.city-call-incoming-body > .city-call-test { flex: none; }

.city-call-incoming-devices { width: min(100%, 400px); text-align: left; }

.city-call-incoming-devices > .city-call-preview-stage { min-height: 154px; margin-bottom: var(--space-3); }

.city-call-incoming > .city-call-actions {
  padding: var(--space-3);
  border-top: 1px solid var(--border);
  background: var(--bg-surface-alt);
}

.city-call-incoming > .city-call-actions > button { flex: 1 1 120px; }

.city-call-incoming .city-call-stage-message { padding-top: 36px; }

@media (max-width: 695px) {
  .city-call { gap: var(--space-2); }
  .city-call-heading { min-height: 54px; }
  .city-call-identity { gap: var(--space-2); }
  .city-call-identity > .city-call-avatar { width: 38px; font-size: var(--fs-sm); }
  .city-call-preview-layout, .city-call-preview-layout[data-audio="true"] { grid-template-columns: 1fr; }
  .city-call[data-phase="preview"] .city-call-status { display: none; }
  .city-call-share-layout { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) 92px; }
  .city-call-filmstrip { flex-direction: row; overflow: auto hidden; }
  .city-call-filmstrip > .city-call-tile { height: 100%; }
}

@media (max-height: 580px) {
  .city-call { gap: var(--space-2); padding-block: var(--space-2); }
  .city-call-heading { min-height: 48px; }
  .city-call-settings { padding: var(--space-3); }
}

.city-call-history { padding: 6px 16px; color: var(--text-secondary); }

.city-call-history summary { cursor: pointer; width: fit-content; padding-block: 5px; font-weight: 600; color: var(--teal-800); }

.city-call-history ul { max-height: 180px; overflow: auto; list-style: none; margin: 5px 0 0; padding: 0; }

.city-call-history li { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 12px; padding: 7px 0; }

.city-call-history time { color: var(--text-secondary); font-size: 12px; }

.city-call-history button {
  cursor: pointer;
  padding: 4px 8px;
  border: 1px solid var(--teal-200);
  border-radius: var(--radius-sm);
  background: var(--teal-50);
  color: var(--teal-900);
  font: inherit;
}

.city-call-gallery[data-multiple="true"] {
  grid-template-columns: repeat(var(--gallery-columns, 2), minmax(0, 1fr));
  grid-auto-rows: minmax(110px, 1fr);
  border-radius: var(--radius-lg);
  padding: var(--space-2);
  overflow: auto;
}

.city-call-gallery[data-multiple="true"] > .city-call-tile { background: var(--call-theater-raised); }

.city-call-gallery[data-multiple="true"] > .city-call-tile > video { object-fit: contain; }

@media (max-width: 695px) {
  .city-call-gallery[data-multiple="true"] { grid-template-columns: repeat(min(2, var(--gallery-columns, 2)), minmax(0, 1fr)); }
}

.city-call-conversation[data-group="true"] {
  grid-template-rows: minmax(0, 1fr) auto;
  place-items: stretch;
}

.city-call-conversation[data-group="true"] > .city-call-gallery {
  position: relative;
  min-height: 0;
}

.city-call-filmstrip-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.city-call-filmstrip-panel > .city-call-filmstrip { flex: 1 1 0; }

.city-call-share-layout[data-group="true"] .city-call-filmstrip {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-auto-rows: minmax(65px, 1fr);
  justify-content: stretch;
}

.city-call-share-layout[data-group="true"] .city-call-filmstrip > .city-call-tile {
  aspect-ratio: auto;
  width: 100%;
  height: 100%;
  max-height: 120px;
}

.city-call-participant-pages {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: var(--space-1);
  padding: 6px var(--space-2);
  color: var(--text-secondary);
  background: var(--bg-app);
  font-size: var(--fs-xs);
  font-variant-numeric: tabular-nums;
}

.city-call .city-call-participant-pages button {
  min-height: 34px;
  padding: 4px 8px;
}

.city-call .city-call-participant-pages button[aria-disabled="true"] {
  color: var(--text-tertiary);
  background: var(--bg-surface);
  cursor: default;
}

@media (max-width: 695px) {
  .city-call-share-layout[data-group="true"] { grid-template-rows: minmax(0, 1fr) auto; }
  .city-call-share-layout[data-group="true"] .city-call-filmstrip {
    display: flex;
    height: 92px;
    flex: none;
  }
  .city-call-share-layout[data-group="true"] .city-call-filmstrip > .city-call-tile {
    width: min(145px, 29vw);
  }
}

.city-call-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
/**
 * Design tokens — CSS-переменные для использования во всех CSS-файлах проекта.
 * Синхронизированы с src/theme/tokens.js.
 *
 * Бирюзовая корпоративная палитра СИТИ.
 */

:root {
  /* === Teal (primary) === */
  --teal-50: #f0fdfa;
  --teal-100: #ccfbf1;
  --teal-200: #99f6e4;
  --teal-300: #5eead4;
  --teal-400: #2dd4bf;
  --teal-500: #14b8a6;
  --teal-600: #0d9488;
  --teal-700: #0f766e;
  --teal-800: #115e59;
  --teal-900: #134e4a;
  --teal-950: #042f2e;

  /* === Slate (neutral) === */
  --slate-50: #f8fafc;
  --slate-100: #f1f5f9;
  --slate-200: #e2e8f0;
  --slate-300: #cbd5e1;
  --slate-400: #94a3b8;
  --slate-500: #64748b;
  --slate-600: #475569;
  --slate-700: #334155;
  --slate-800: #1e293b;
  --slate-900: #0f172a;
  --slate-950: #020617;

  /* Backwards-compat для старых файлов (чат, сайдбар) */
  --ink-900: #0f172a;
  --ink-800: #1e293b;
  --ink-700: #334155;
  --ink-600: #475569;
  --ink-500: #64748b;
  --ink-400: #94a3b8;
  --ink-300: #cbd5e1;
  --ink-200: #e2e8f0;
  --ink-100: #f1f5f9;
  --ink-50: #f8fafc;

  /* === Semantic === */
  --success-50: #ecfdf5;
  --success-100: #d1fae5;
  --success-500: #10b981;
  --success-600: #059669;
  --success-700: #047857;

  --warning-50: #fffbeb;
  --warning-100: #fef3c7;
  --warning-500: #f59e0b;
  --warning-600: #d97706;
  --warning-700: #b45309;

  --danger-50: #fef2f2;
  --danger-100: #fee2e2;
  --danger-500: #ef4444;
  --danger-600: #dc2626;
  --danger-700: #b91c1c;

  --info-50: #ecfeff;
  --info-100: #cffafe;
  --info-500: #06b6d4;
  --info-600: #0891b2;
  --info-700: #0e7490;

  /* === Semantic tokens (light) === */
  --bg-app: var(--slate-50);
  --bg-surface: #ffffff;
  --bg-surface-alt: var(--slate-50);
  --bg-surface-hover: var(--slate-100);
  --bg-elevated: #ffffff;
  --bg-inverse: var(--slate-900);
  --bg-brand: var(--teal-500);
  --bg-brand-soft: var(--teal-50);
  --bg-brand-hover: var(--teal-600);

  --text-primary: var(--slate-900);
  --text-secondary: var(--slate-600);
  --text-tertiary: var(--slate-500);
  --text-disabled: var(--slate-400);
  --text-inverse: #ffffff;
  --text-brand: var(--teal-700);
  --text-on-brand: #ffffff;

  --border: var(--slate-200);
  --border-strong: var(--slate-300);
  --border-brand: var(--teal-500);
  --border-focus: var(--teal-500);

  /* === Radii === */
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --radius-2xl: 28px;
  --radius-full: 9999px;

  /* === Shadows === */
  --shadow-xs: 0 1px 2px 0 rgba(15, 23, 42, 0.05);
  --shadow-sm: 0 1px 3px 0 rgba(15, 23, 42, 0.08), 0 1px 2px -1px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.08), 0 2px 4px -2px rgba(15, 23, 42, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -4px rgba(15, 23, 42, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(15, 23, 42, 0.10), 0 8px 10px -6px rgba(15, 23, 42, 0.06);
  --shadow-2xl: 0 25px 50px -12px rgba(15, 23, 42, 0.18);
  --shadow-teal-sm: 0 2px 8px -2px rgba(20, 184, 166, 0.20);
  --shadow-teal-md: 0 8px 20px -6px rgba(20, 184, 166, 0.28);
  --shadow-teal-lg: 0 14px 40px -10px rgba(20, 184, 166, 0.35);
  --shadow-ring: 0 0 0 3px rgba(20, 184, 166, 0.25);

  /* === Spacing === */
  --space-0: 0px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 28px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-14: 56px;
  --space-16: 64px;

  /* === Typography === */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'SF Mono', Consolas, 'Courier New', monospace;

  --fs-xxs: 11px;
  --fs-xs: 12px;
  --fs-sm: 13px;
  --fs-base: 14px;
  --fs-md: 15px;
  --fs-lg: 16px;
  --fs-xl: 18px;
  --fs-2xl: 20px;
  --fs-3xl: 24px;
  --fs-4xl: 30px;
  --fs-5xl: 36px;

  --fw-regular: 400;
  --fw-medium: 500;
  --fw-semibold: 600;
  --fw-bold: 700;

  --lh-tight: 1.2;
  --lh-snug: 1.35;
  --lh-normal: 1.5;
  --lh-relaxed: 1.7;

  /* === Transitions === */
  --t-fast: 120ms cubic-bezier(0.4, 0, 0.2, 1);
  --t-base: 180ms cubic-bezier(0.4, 0, 0.2, 1);
  --t-slow: 260ms cubic-bezier(0.4, 0, 0.2, 1);
  --t-spring: 320ms cubic-bezier(0.34, 1.56, 0.64, 1);

  /* === Z-index === */
  --z-dropdown: 1000;
  --z-sticky: 1100;
  --z-navbar: 1150;
  --z-modal-backdrop: 1300;
  --z-modal: 1400;
  --z-popover: 1500;
  --z-tooltip: 1600;
  --z-toast: 1700;

  /* === Gradients === */
  --gradient-brand: linear-gradient(135deg, var(--teal-500) 0%, var(--teal-600) 100%);
  --gradient-brand-soft: linear-gradient(135deg, var(--teal-50) 0%, var(--teal-100) 100%);
  --gradient-surface: linear-gradient(180deg, rgba(255, 255, 255, 0.9) 0%, rgba(255, 255, 255, 0.7) 100%);
  --gradient-ink: linear-gradient(135deg, var(--slate-800) 0%, var(--slate-950) 100%);
  --gradient-teal-ink: linear-gradient(160deg, var(--teal-900) 0%, var(--slate-900) 70%, #031a20 100%);
}

/* === Utility primitives === */

.u-glass {
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(14px) saturate(180%);
  -webkit-backdrop-filter: blur(14px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.6);
}

.u-glass-dark {
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(14px) saturate(180%);
  -webkit-backdrop-filter: blur(14px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.u-focus-ring:focus-visible {
  outline: none;
  box-shadow: var(--shadow-ring);
}

.u-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* === Page enter animations === */

@keyframes u-page-fade-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

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

.u-animate-page-in {
  animation: u-page-fade-in 320ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.u-animate-fade-in {
  animation: u-fade-in 240ms ease-out both;
}

.u-animate-scale-in {
  animation: u-scale-in 280ms cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@media (prefers-reduced-motion: reduce) {
  .u-animate-page-in,
  .u-animate-fade-in,
  .u-animate-scale-in {
    animation: none !important;
  }
}

/* Scrollbar базовый */

.u-scroll {
  scrollbar-width: thin;
  scrollbar-color: var(--slate-300) transparent;
}

.u-scroll::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.u-scroll::-webkit-scrollbar-track {
  background: transparent;
}

.u-scroll::-webkit-scrollbar-thumb {
  background: var(--slate-300);
  border-radius: var(--radius-full);
}

.u-scroll::-webkit-scrollbar-thumb:hover {
  background: var(--slate-400);
}

.city-group-call-panel {
  flex: none;
  padding: 5px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-size: var(--fs-sm);
}

.city-group-call-list {
  display: grid;
  gap: var(--space-1);
  max-height: 180px;
  margin: 0;
  padding: 0;
  overflow: auto;
  list-style: none;
}

.city-group-call-list li {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) 0;
}

.city-group-call-list li > svg { color: var(--teal-700); }

.city-group-call-name { display: grid; flex: 1; min-width: 0; gap: 2px; }

.city-group-call-name strong { color: var(--text-primary); overflow-wrap: anywhere; }

.city-group-call-name small,
.city-group-call-count,
.city-group-call-history time { color: var(--text-secondary); font-size: var(--fs-xs); }

.city-group-call-panel summary { width: fit-content; padding: 4px 0; color: var(--teal-800); cursor: pointer; }

.city-group-call-panel p { margin: 2px 0 6px; }

.city-group-call-join,
.city-group-call-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 5px 10px;
  border: 1px solid var(--teal-200);
  border-radius: var(--radius-md);
  color: var(--teal-900);
  background: var(--teal-50);
  font: inherit;
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  cursor: pointer;
}

.city-group-call-icon { min-width: 40px; }

.city-group-call-icon svg { font-size: 19px; }

.city-group-call-count { padding-inline: var(--space-2); white-space: nowrap; }

:is(.city-group-call-join, .city-group-call-icon):enabled:hover { background: var(--teal-100); }

:is(.city-group-call-join, .city-group-call-icon):disabled { opacity: .65; cursor: default; }

:is(.city-group-call-join, .city-group-call-icon, .city-group-call-panel summary):focus-visible {
  outline: 2px solid var(--teal-700);
  outline-offset: 2px;
}
:root {
  --spacing-1: 0.5rem;
  --spacing-2: 1rem;
}

.h1 {
  margin-bottom: var(--spacing-2);
  font-weight: 700;
  font-size: 2rem;
}

.h2 {
  margin-bottom: var(--spacing-2);
  font-weight: 600;
  font-size: 1.5rem;
}

.text-sm {
  font-size: 0.875rem;
}

.table-common {
  width: 100%;
  border-radius: 8px;
  border-collapse: collapse;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

.table-common th,
.table-common td {
  padding: 8px;
  border: 1px solid #ddd;
}

.table-common tbody tr:nth-child(even) {
  background: #f8f8f8;
}

.table-common tbody tr:hover {
  background: #eaf2ff;
}

.btn-success {
  background-color: #27ae60;
  color: white;
  border: 1px solid #27ae60;
}

.btn-success:hover {
  background-color: #229954;
  border-color: #229954;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0 !important;
  padding: 0;
  overflow: hidden;
  overscroll-behavior: none;
  font-family: "Inter", sans-serif;
}

#root {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  overflow: hidden;
}
.web-login { min-height:100dvh; display:grid; place-items:center; background:#edf5f4; color:#183c42 }
.web-login form { box-sizing:border-box; width:min(400px,94vw); padding:32px; border-radius:16px; background:white; box-shadow:0 12px 40px #13393418; }
.web-login label { display:grid; gap:5px; margin:14px 0; font-weight:600 }
.web-login input { border:1px solid #879d9c; padding:10px; font:inherit; border-radius:6px; }
.web-login button,.web-workspace header button { cursor:pointer; padding:8px 12px; font:inherit; border:1px solid #799592; border-radius:6px; background:white; color:#174f4d }
.web-login .web-primary { width:100%; background:#195f59; color:white; }
.web-login :focus-visible,.web-workspace :focus-visible { outline:3px solid #136c99; outline-offset:2px }
.web-challenge,.web-workspace>header { display:flex; align-items:center; justify-content:space-between; }
.web-workspace {height:100dvh;display:flex;flex-direction:column;min-width:0}
.web-workspace>header {padding:8px 18px;gap:12px;border-bottom:1px solid #b9cdca;}
.web-workspace>header span {margin-left:auto}
.web-workspace .chat-layout {flex:1;min-height:0;height:auto}
.web-call { border:0;padding:0;margin:0;width:100%;height:100%;max-width:none;max-height:none;box-sizing:border-box;color:inherit;position:fixed;inset:0;z-index:1400;background:#101b22;overflow:auto; }
@media(max-width:700px){.web-workspace .chat-sidebar{min-width:100px;width:32%}.web-workspace .chat-main{min-width:0;flex:1}.web-login form{padding:22px}}
