/* ===== MAIN PAGE LAYOUT ===== */
.main-page {
  display: flex;
  height: 100%;
  overflow: hidden;
}

/* ===== LEFT PANEL ===== */
.left-panel {
  width: 17.5rem;
  min-width: 10rem;
  max-width: 50vw;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: var(--bg-primary);
  overflow: hidden;
}

.left-panel__header {
  padding: 0;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.left-panel__controls {
  display: flex;
  gap: 0;
  align-items: stretch;
  height: var(--panel-row);
  border-bottom: 1px solid var(--border);
}

.sort-select {
  flex: 1;
  min-width: 0;
  padding: 0 var(--space-sm);
  padding-right: 1.5rem;
  font-size: var(--font-small);
  font-family: inherit;
  color: var(--text-secondary);
  background-color: transparent;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.5rem center;
  border: none;
  border-radius: 0;
  cursor: pointer;
  transition: background-color var(--transition-fast);
  -webkit-appearance: none;
  appearance: none;
}

.sort-select:hover {
  background-color: var(--bg-secondary);
}

.sort-select:focus {
  outline: none;
  background-color: var(--bg-secondary);
}

.slot-filter-btn {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  border-left: 1px solid var(--border);
  border-radius: 0;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0;
  aspect-ratio: 1;
  min-width: var(--panel-row);
  transition: background var(--transition-fast), color var(--transition-fast);
}
#slot-search-toggle-btn {
  border-left: none;
  border-right: 1px solid var(--border);
}

.slot-filter-btn:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.slot-filter-btn--active {
  background: var(--bg-secondary);
  color: var(--accent);
  position: relative;
}
.slot-filter-btn--active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(to right, transparent, var(--accent) 20%, var(--accent) 80%, transparent);
  pointer-events: none;
}

.slot-filter-btn--active:hover {
  color: var(--accent);
}

#slot-priority-filter-btn.slot-filter-btn--active {
  color: var(--warning, orange);
}
#slot-priority-filter-btn.slot-filter-btn--active::after {
  background: linear-gradient(to right, transparent, var(--warning, orange) 20%, var(--warning, orange) 80%, transparent);
}

/* slot-search — плоский встроенный стиль */
.left-panel__header .search-box {
  display: none;
  border-bottom: 1px solid var(--border);
  height: var(--panel-row);
}
.left-panel__header .search-box.slot-search-box--open {
  display: flex;
}

.left-panel__header .search-box__input {
  background: none;
  border: none;
  border-radius: 0;
  padding: 0 var(--space-sm) 0 1.75rem;
  height: 100%;
}

.left-panel__header .search-box:focus-within {
  border-bottom-color: var(--accent);
}

.left-panel__header .search-box__input:focus {
  outline: none;
}

/* Быстрая навигация по группам */
.group-nav-strip {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  overflow-x: overlay;
  flex-shrink: 0;
}
.group-nav-strip:empty,
.group-nav-strip[style*="display: none"] { border-bottom: none; }
.group-nav-btn {
  flex: 1;
  min-width: 0;
  padding: 0 var(--space-sm);
  height: var(--panel-row);
  background: transparent;
  border: none;
  border-right: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background-color 0.15s, color 0.15s;
}
.group-nav-btn:last-child { border-right: none; }
.group-nav-btn:hover {
  background-color: var(--bg-hover);
  color: var(--text-primary);
}
.group-nav-btn:focus {
  outline: none;
}
.group-nav-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.group-nav-btn--dragging {
  opacity: 0.4;
}
.group-nav-btn--dragover {
  background-color: var(--bg-hover);
  box-shadow: inset 0 -2px 0 var(--accent);
}

.left-panel__content {
  flex: 1;
  overflow-y: auto;
  overflow-y: overlay;
  padding: var(--space-sm);
}

/* ===== PANEL DIVIDER ===== */
.panel-divider {
  width: 4px;
  margin-left: -2px;
  margin-right: -2px;
  position: relative;
  z-index: 5;
  cursor: col-resize;
  background: transparent;
  transition: background var(--transition-fast);
}
.panel-divider::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 1px;
  background: var(--border);
  pointer-events: none;
}
.panel-divider:hover {
  background: var(--accent);
}

/* ===== RIGHT PANEL ===== */
.right-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

.right-panel__empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
}

.right-panel__content {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  position: relative;
}

.right-panel__content.drop-active::after {
  content: 'Перетащите файлы сюда';
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-light);
  border: 2px dashed var(--accent);
  border-radius: var(--radius-sm);
  font-size: var(--font-body);
  font-weight: 600;
  color: var(--accent);
  pointer-events: none;
}

/* ===== GROUPS ===== */
.group {
  margin-bottom: var(--space-sm);
}

.group__header {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.group__toggle {
  flex: 1;
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-sm);
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: var(--font-body);
  font-weight: 600;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
  text-align: left;
}

.group__folder-icon {
  display: inline-flex;
  flex-shrink: 0;
  order: 0;
}

.group__name {
  order: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
}

.group__toggle .group__badge {
  order: 2;
  margin-left: var(--space-xs);
}

.group__toggle:hover {
  background: var(--bg-secondary);
}

/* Пустая группа: полупрозрачные иконка и название, клик отключён */
.group--empty .group__folder-icon,
.group--empty .group__name {
  opacity: 0.35;
}
.group--empty .group__toggle {
  cursor: default;
}

.group__slots {
  padding: 0.35rem 0 0 0.75rem;
}
.group--collapsed .group__slots {
  display: none;
}

.group__count {
  color: var(--text-secondary);
  font-size: var(--font-small);
  font-weight: 400;
}

/* .group__badge наследует .unread-badge (добавлен в HTML) */
.group__badge {
  margin-left: var(--space-xs);
}

.group__add-slot {
  width: 1.5rem;
  height: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: var(--font-body);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.group__add-slot:hover {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent);
}

/* Кнопка переключения вида (grid/list) — те же стили что и add-slot */
.group__view-toggle {
  width: 1.5rem;
  height: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: var(--font-body);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.group__view-toggle:hover {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent);
}

/* На desktop показывать кнопки группы только при hover по левой панели */
@media (hover: hover) and (pointer: fine) {
  .group__add-slot,
  .group__view-toggle {
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-fast), background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
  }
  .left-panel:hover .group__add-slot,
  .left-panel:hover .group__view-toggle {
    opacity: 1;
    pointer-events: auto;
  }
}

/* ===== STICKY GROUP HEADER ===== */
.left-panel__scroll-wrapper {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.left-panel__find-selected-btn {
  z-index: 12;
}

.group-sticky-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-sm);
  background: color-mix(in srgb, var(--bg-primary) 85%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--transition-fast);
}
.group-sticky-header:hover {
  background: color-mix(in srgb, var(--bg-secondary) 90%, transparent);
}

.group-sticky-header__name {
  flex: 1;
  font-size: var(--font-body);
  font-weight: 600;
  color: var(--text-primary);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  min-width: 0;
}

/* .group-sticky-header__badge наследует .unread-badge */

/* ===== SLOT CARDS ===== */
.slots-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(5.5rem, 1fr));
  gap: 0.75rem;
  padding: var(--space-xs) 0;
}

.slot-card {
  position: relative;
  overflow: visible;
  cursor: pointer;
  transition: transform 220ms cubic-bezier(0.22, 1, 0.36, 1);
}
.slot-card:hover {
  transform: translateY(-2px);
}

.slot-card__inner {
  background: var(--bg-secondary);
  border: none;
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-card);
  transition: box-shadow 220ms cubic-bezier(0.22, 1, 0.36, 1);
}

.slot-card:hover:not(.slot-card--selected) .slot-card__inner {
  box-shadow: var(--shadow-card-hover);
}
.slot-card--selected .slot-card__inner {
  box-shadow:
    0 0 0 3px var(--accent),
    0 0 0 6px var(--accent-light),
    var(--shadow-card-hover);
}

.slot-card__thumb {
  aspect-ratio: 1 / 1;
  width: 100%;
  position: relative;
  background-size: cover;
  background-position: center;
  background-color: color-mix(in srgb, var(--bg-secondary), white 4%);
  border-bottom: none;
  filter: brightness(0.72) saturate(0.9);
  transition: filter var(--transition-fast);
}
.slot-card:hover .slot-card__thumb,
.slot-card--selected .slot-card__thumb {
  filter: brightness(1) saturate(1);
}
.slot-card__meta {
  padding: 0.375rem 0.5rem 0.45rem;
  background: color-mix(in srgb, var(--bg-primary), white 3%);
}
.slot-card--selected .slot-card__meta {
  background: color-mix(in srgb, color-mix(in srgb, var(--bg-primary), white 3%) 78%, var(--accent) 22%);
}

.slot-card__no-img-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  opacity: 0.28;
  color: var(--text-secondary);
  pointer-events: none;
}
.slot-card__no-img-icon svg {
  width: 2.2rem;
  height: 2.2rem;
}

/* Бейдж как у категории */
/* .slot-card__badge наследует .unread-badge */
.slot-card__badge {
  position: absolute;
  top: -0.3rem;
  right: -0.3rem;
  z-index: 5;
}

.slot-card__name {
  font-size: var(--font-body);
  font-weight: 600;
  line-height: 1.25;
  color: var(--text-primary);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.slot-card:not(.slot-card--selected) .slot-card__name {
  color: color-mix(in srgb, var(--text-primary) 78%, transparent);
}
.slot-card:not(.slot-card--selected):hover .slot-card__name {
  color: var(--text-primary);
}

.slot-card__progress {
  height: 3px;
  background: var(--border);
  overflow: hidden;
}
.slot-card__progress-fill {
  height: 100%;
  background: var(--status-done);
  border-radius: 0;
}
.slot-card--priority .slot-card__progress-fill {
  background: #ff8a00;
}

/* Приоритетные слоты — обводка 2px (grid + list) */
.slot-card--priority .slot-card__inner {
  border: 2px solid var(--warning, #ff8a00);
}
.slot-card--priority.slot-card--selected .slot-card__inner {
  border: none;
}

/* ===== SLOT LIST VIEW ===== */
.slots-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: var(--space-xs) 0;
}

/* ===== SLOT CARD — LIST MODE OVERRIDES ===== */
/* Только layout. Подсветка selected/priority/hover — от базовых стилей .slot-card */
.slot-card--list {
  transform: none !important;
}
.slot-card--list:hover {
  transform: none !important;
}

/* Inner: горизонтальный flex */
.slot-card--list .slot-card__inner {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.375rem 0.5rem;
  border-radius: var(--radius-sm);
}
.slot-card--list:not(.slot-card--selected) .slot-card__inner {
  box-shadow: none;
  background: transparent;
}
.slot-card--list:not(.slot-card--selected):hover .slot-card__inner {
  background: color-mix(in srgb, var(--bg-secondary), white 4%);
}
/* Selected: весь inner тинтится акцентом */
.slot-card--list.slot-card--selected .slot-card__inner {
  background: color-mix(in srgb, var(--bg-secondary) 78%, var(--accent) 22%);
}

/* Thumb wrap: контейнер для аватарки + радиального прогресса */
.slot-card--list .slot-card__thumb-wrap {
  position: relative;
  width: 2.625rem;
  height: 2.625rem;
  flex-shrink: 0;
}

/* Thumb: маленький круг внутри wrap */
.slot-card--list .slot-card__thumb {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  aspect-ratio: auto;
  border-bottom: none;
  filter: none;
}

/* Радиальное кольцо прогресса */
.slot-card__ring {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}
.slot-card__ring-bg {
  fill: none;
  stroke: var(--border);
  stroke-width: 2.5;
}
.slot-card__ring-fill {
  fill: none;
  stroke-width: 2.5;
  stroke-linecap: round;
  transform: rotate(-90deg);
  transform-origin: center;
  transition: stroke-dashoffset 0.3s ease;
}

/* В list-режиме линейный прогресс скрыт (используется радиальный) */
.slot-card--list .slot-card__progress { display: none; }

/* Meta: flex-column, без padding */
.slot-card--list .slot-card__meta {
  flex: 1;
  min-width: 0;
  padding: 0;
}
.slot-card--list .slot-card__meta {
  background: transparent !important;
}

/* Name */
.slot-card--list .slot-card__name {
  margin-bottom: 0.125rem;
}

/* Badge: вертикально по центру справа */
.slot-card--list .slot-card__badge {
  top: 50%;
  right: 0.5rem;
  transform: translateY(-50%);
}

/* No-img icon: меньше (позиция остаётся absolute от базы — центрируется в thumb) */
.slot-card--list .slot-card__no-img-icon svg {
  width: 1rem;
  height: 1rem;
}

/* ===== SLOT COMPACT VIEW ===== */
.slots-compact {
  display: flex;
  flex-direction: column;
  padding: 0;
}

.slot-card--compact {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.5rem;
  cursor: pointer;
  position: relative;
  transform: none !important;
  overflow: visible;
  border-radius: var(--radius-sm);
}
.slot-card--compact:hover {
  background: color-mix(in srgb, var(--bg-secondary), white 4%);
  transform: none !important;
}
.slot-card--compact.slot-card--selected {
  background: color-mix(in srgb, var(--bg-secondary) 78%, var(--accent) 22%);
}
/* Прогресс-полоска ярче при hover / selected */
.slot-card--compact:hover .slot-card__progress-fill {
  background: var(--text-secondary);
}
.slot-card--compact.slot-card--selected .slot-card__progress-fill {
  background: var(--accent);
}
.slot-card--compact.slot-card--priority {
  border-left: 2px solid var(--warning);
}

/* Имя */
.slot-card--compact .slot-card__name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--font-small);
  padding: 0;
  background: transparent !important;
}

/* Прогресс-бар: вертикальная полоска справа, заполняется снизу вверх */
.slot-card--compact .slot-card__progress {
  position: absolute;
  right: 0;
  top: 0;
  width: 3px;
  height: 100%;
  background: transparent;
  overflow: hidden;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.slot-card--compact .slot-card__progress-fill {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  border-radius: 0;
  background: var(--border);
}

/* Бейдж */
.slot-card--compact .slot-card__badge {
  position: static;
}

/* ===== SLOT PREVIEW TOOLTIP ===== */
.slot-preview-tooltip {
  position: fixed;
  z-index: 9000;
  max-width: 320px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  padding: 0.25rem;
  pointer-events: none;
  opacity: 0;
  transform: scale(0.95);
  transition: opacity 120ms ease, transform 120ms ease;
}
.slot-preview-tooltip--visible {
  opacity: 1;
  transform: scale(1);
}
.slot-preview-tooltip img {
  display: block;
  max-width: 100%;
  border-radius: calc(var(--radius-md) - 2px);
}

/* ===== TABS BAR ===== */
.tabs-bar {
  display: flex;
  flex-wrap: nowrap;
  gap: 0;
  padding: 0;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  height: var(--panel-row);
  align-items: stretch;
  overflow: hidden;
}
.tabs-bar--wrap {
  height: auto;
  min-height: var(--panel-row);
}

.tab {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0 0.75rem;
  height: 100%;
  flex-shrink: 0;
  min-width: max-content;
  background: none;
  border: none;
  border-radius: 0;
  color: var(--text-primary);
  font-size: 0.875rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  position: relative;
  transition: background-color var(--transition-fast), color var(--transition-fast);
  box-shadow: 2px 0 4px rgba(0,0,0,0.2);
}

.tab:hover {
  background: var(--bg-secondary);
}
.tab--selected,
.tab--selected:hover {
  cursor: default;
}

/* === Статусы === */
.tab--done {
  color: var(--status-done);
}
.tab--active {
  color: var(--text-primary);
}
.tab--locked {
  color: var(--status-locked);
}

/* === Выбранный таб === */
.tab--selected {
  background: var(--bg-secondary);
  color: var(--accent);
  text-shadow: 0 0 0.5px currentColor, 0 0 0.5px currentColor;
  box-shadow: 2px 0 4px rgba(0,0,0,0.2), inset 3px 0 4px -3px rgba(0,0,0,0.25);
}
.tab--selected::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(to right, transparent, var(--accent) 20%, var(--accent) 80%, transparent);
  pointer-events: none;
}
.tab--selected .tab__status-icon { color: var(--accent); }

/* === Иконка статуса === */
.tab__status-icon {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  line-height: 0;
}
.tab__status-icon--done { color: var(--status-done); }
.tab__status-icon--locked { color: var(--status-locked); }

.tab__name {
  white-space: nowrap;
}

/* === Бейдж непрочитанных === */
/* .tab__unread наследует .unread-badge */

/* Бейджи участников внутри табов */
.tab .member-badges { margin-left: 4px; }
.tab--done .member-badges,
.tab--locked .member-badges { opacity: 0.25; }
.tab--stacked .member-badges { margin-left: 2px; }

/* Промежуточный режим: бейджи на второй строке */
.tab--wrap {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: auto;
  padding-top: 0.375rem;
  padding-bottom: 0.5rem;
  min-width: 0;
  gap: 5px;
}
.tab__row {
  display: flex;
  align-items: center;
  gap: 0.375rem;
}
.tab--wrap .member-badges {
  margin-left: 0;
}

/* Кнопка "+" для добавления этапа */
.tab--add {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 0.625rem;
  height: var(--panel-row);
  flex-shrink: 0;
  background: none;
  border: none;
  border-radius: 0;
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-family: inherit;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.tab--add:hover {
  background: var(--bg-secondary);
  color: var(--accent);
}

/* === Стопка табов === */
.tabs-stack {
  display: flex;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  box-shadow: -3px 0 6px rgba(0,0,0,0.3);
  height: 100%;
}

.tab--stacked {
  flex: 1 1 1.5rem;
  max-width: 8rem;
  min-width: 1.5rem;
  position: relative;
  background: var(--bg-primary);
  box-shadow: -2px 0 4px rgba(0,0,0,0.3);
  overflow: hidden;
}
.tab--stacked .tab__name {
  overflow: visible;
  text-overflow: clip;
  white-space: nowrap;
}
.tab--stacked .tab__status-icon {
  display: none;
}
/* Бейдж непрочитанных в стопке — компактный абсолютный бейдж с цифрой */
.tab--stacked .tab__unread {
  position: absolute;
  top: 2px;
  right: 2px;
  z-index: 2;
}

/* Выбранный таб в стопке — подчёркивание + подсветка как у обычного */
.tab--stacked.tab--selected {
  background: var(--bg-secondary);
  color: var(--accent);
  text-shadow: 0 0 0.5px currentColor, 0 0 0.5px currentColor;
  box-shadow: -2px 0 4px rgba(0,0,0,0.3);
}

/* Плюсик — последняя карта стопки */
.tabs-stack .tab--add {
  flex: 0 0 auto;
  position: relative;
  background: var(--bg-primary);
  box-shadow: -2px 0 4px rgba(0,0,0,0.3);
}

/* Плавающий оверлей при наведении — поверх всего сайта */
.tab-stack-tooltip {
  display: none;
  position: fixed;
  transform: translate(-50%, -110%);
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 0.75rem;
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 0.875rem;
  font-weight: 600;
  white-space: nowrap;
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 20px rgba(0,0,0,0.6);
  pointer-events: none;
  z-index: 99999;
}
.tab-stack-tooltip--done { color: var(--status-done); }
.tab-stack-tooltip--locked { color: var(--status-locked); }
.tab-stack-tooltip .tab__status-icon {
  display: flex;
  align-items: center;
  line-height: 0;
}

/* Перетаскивание табов */
.tab--dragging {
  opacity: 0.4;
}
.tab--dragover {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

/* Пустой слот */
.tabs-empty {
  font-size: var(--font-small);
  color: var(--text-secondary);
  padding: 0.375rem;
  display: flex;
  align-items: center;
}

/* ===== STAGE HEADER ===== */
.stage-header {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  padding: 0;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  height: var(--panel-row);
}

.stage-header__info {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  padding: 0 0.75rem;
}

.stage-header__name {
  font-weight: 400;
  font-size: var(--font-small);
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stage-header__sep {
  color: var(--text-secondary);
  opacity: 0.5;
  font-size: var(--font-small);
}

.stage-header__slot-name {
  color: var(--text-secondary);
  font-size: var(--font-small);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stage-header__actions {
  display: flex;
  align-items: stretch;
  gap: 0;
  flex-shrink: 0;
}

/* Кнопки действий стадии (outlined / ghost) */
.btn--done {
  position: relative;
  background: transparent;
  color: var(--status-done);
  border: none;
  border-radius: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0 0.625rem;
  z-index: 0;
}

.btn--done::before {
  content: '';
  position: absolute;
  inset: 5px 3px;
  border: 1.5px solid var(--status-done);
  background: transparent;
  border-radius: 0.25rem;
  z-index: -1;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}

.btn--done:hover {
  filter: none;
}
.btn--done:hover::before {
  filter: brightness(1.2);
}
.btn--done .icon { display: flex; align-items: center; }

/* Назначить / Вернуть в работу — accent-цвет */
.btn--done--accent,
.btn--done--warning { color: var(--accent); }
.btn--done--accent::before,
.btn--done--warning::before {
  border-color: var(--accent);
}

/* ===== MEMBER BADGES ===== */
.member-badges {
  display: inline-flex;
  gap: 2px;
  flex-wrap: wrap;
  align-items: center;
  vertical-align: middle;
}

.member-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 4px;
  font-size: 8px;
  font-weight: 600;
  color: #fff;
  text-transform: uppercase;
  line-height: 1;
  flex-shrink: 0;
  cursor: default;
}

.member-badge--overflow {
  background: var(--surface-3, #555);
  font-size: 7px;
  letter-spacing: -0.5px;
}

.member-badge--accepted {
  position: relative;
}
.member-badge--accepted::after {
  content: '';
  position: absolute;
  bottom: -3px;
  left: 2px;
  right: 2px;
  height: 2px;
  border-radius: 1px;
  background: currentColor;
  background: inherit;
}

/* ===== CHAT AREA ===== */
.chat-area {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  overflow-y: overlay;
  overflow-x: clip;
  padding: var(--space-sm) 0;
}

/* PNG-паттерны (tropical, floral, christmas и т.д.) применяются через
   inline-стили из patterns.js — им не нужны CSS-правила. */

.chat-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-secondary);
  font-size: var(--font-body);
  text-align: center;
}

/* ===== SYSTEM MESSAGES (compact pill) ===== */
.msg--system {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1px var(--space-sm);
  margin: 0;
  user-select: text;
}

.msg--system:not(.msg--compact) {
  padding-top: 1px;
  padding-bottom: 1px;
}

.msg--system__pill {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  max-width: 90%;
}

.msg--system-done .msg--system__pill {
  background: color-mix(in srgb, var(--status-done) 10%, transparent);
}

.msg--system-priority .msg--system__pill {
  background: color-mix(in srgb, var(--warning, #FF9800) 10%, transparent);
}

.msg--system-reverted .msg--system__pill {
  background: rgba(var(--accent-rgb), 0.08);
}

.msg--system__text {
  font-size: var(--font-micro);
  white-space: normal;
  text-align: center;
}

.msg--system-done .msg--system__text {
  color: var(--status-done);
}

.msg--system-priority .msg--system__text {
  color: var(--warning, #FF9800);
}

.msg--system-reverted .msg--system__text {
  color: var(--accent);
}

.msg--system__time {
  font-size: 0.55rem;
  opacity: 0.5;
  flex-shrink: 0;
}

.msg--system-done .msg--system__time {
  color: var(--status-done);
}

.msg--system-priority .msg--system__time {
  color: var(--warning, #FF9800);
}

.msg--system-reverted .msg--system__time {
  color: var(--accent);
}

.msg--system-assigned .msg--system__pill {
  background: color-mix(in srgb, var(--accent) 8%, transparent);
}

.msg--system-assigned .msg--system__text {
  color: var(--accent);
}

.msg--system-assigned .msg--system__time {
  color: var(--accent);
}

.msg--system-accepted .msg--system__pill {
  background: rgba(var(--accent-rgb), 0.08);
}

.msg--system-accepted .msg--system__text {
  color: var(--accent);
}

.msg--system-accepted .msg--system__time {
  color: var(--accent);
}

.msg--system__link {
  color: inherit;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 2px;
  cursor: pointer;
  transition: opacity var(--transition-fast);
}

.msg--system__link:hover {
  opacity: 0.8;
}

/* ===== MESSAGES ===== */
.msg {
  padding: 2px var(--space-sm) 2px calc(var(--space-sm) + 0.75rem);
  position: relative;
  transition: background var(--transition-fast);
}

.msg:not(.msg--compact) {
  padding-top: 0.5rem;
}

.msg:hover,
.msg.msg--ctx-active {
  background: color-mix(in srgb, var(--bg-secondary) 40%, transparent);
}

.msg--compact {
  padding-top: 1px;
  padding-bottom: 1px;
}

.msg--deleted {
  opacity: 0.5;
}

.msg--highlighted {
  background: rgba(var(--accent-rgb), 0.1);
  border-left: 4px solid var(--accent);
}

.msg__header {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  margin-bottom: 0.125rem;
}

.msg__author {
  font-weight: 700;
  font-size: 0.8125rem;
  letter-spacing: 0.01em;
}

.msg__time {
  color: var(--text-secondary);
  font-size: var(--font-small);
}


.msg__body {
  padding-left: 0.75rem;
}

.msg__text {
  font-size: var(--font-body);
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.msg__text code {
  background: var(--bg-tertiary);
  padding: 0.1rem 0.25rem;
  border-radius: 0.1875rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: var(--font-small);
}

.msg__text a {
  color: var(--accent);
  text-decoration: underline;
}

.msg__text .mention {
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
}

.msg__edited {
  color: var(--text-secondary);
  opacity: 0.4;
}

.msg__edited svg {
  width: 10px;
  height: 10px;
}

.msg__reply {
  border-left: 2px solid var(--text-secondary);
  padding: 0 var(--space-sm);
  margin-bottom: var(--space-xs);
  font-size: var(--font-small);
  color: var(--text-secondary);
  cursor: pointer;
  max-width: 25rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: color var(--transition-fast);
}

.msg__reply:hover {
  color: var(--text-primary);
}

/* ===== COLLAGE ===== */
.msg__collage {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  margin: var(--space-xs) 0;
  max-height: 20rem;
  overflow: hidden;
}

.msg__thumb {
  height: 7.5rem;
  width: auto;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
  object-fit: cover;
  filter: brightness(0.72) saturate(0.9);
  transition: filter var(--transition-fast);
}

.msg__thumb:hover {
  filter: brightness(1) saturate(1);
}

/* ===== FILES ===== */
.msg__file {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-xs) var(--space-sm);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin: var(--space-xs) 0;
  max-width: 20rem;
}

.msg__file-name {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8125rem;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.msg__file-size {
  color: var(--text-secondary);
  font-size: var(--font-small);
  flex-shrink: 0;
}

.msg__file-download {
  font-size: var(--font-small);
  flex-shrink: 0;
}

/* ===== VIDEO MEDIA ===== */
.msg__media-wrap {
  position: relative;
  display: inline-block;
  cursor: pointer;
  line-height: 0;
  min-width: 120px;
  min-height: 7.5rem;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
}

.msg__media-wrap .msg__thumb {
  display: block;
  min-width: 120px;
  min-height: 7.5rem;
  object-fit: cover;
}

.msg__play-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 40px;
  height: 40px;
  background: rgba(0, 0, 0, 0.55);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  pointer-events: none;
}

.msg__play-icon svg {
  width: 18px;
  height: 18px;
  margin-left: 2px;
}

.msg__gif-sticker {
  max-width: 250px;
  max-height: 200px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: block;
  margin: var(--space-xs) 0;
}

/* ===== PENDING UPLOAD ===== */
.msg--pending {
  opacity: 0.6;
}

.msg__spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: var(--space-xs) 0;
}

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

.msg--upload-error {
  opacity: 1;
}

.msg__upload-error-info {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  color: var(--danger);
  font-size: var(--font-small);
  margin: var(--space-xs) 0;
}

.msg__retry-btn {
  background: var(--danger);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.125rem 0.5rem;
  font-size: var(--font-small);
  cursor: pointer;
}

.msg__retry-btn:hover {
  opacity: 0.85;
}

.msg__thumb--placeholder {
  width: 80px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
}

/* ===== DATE SEPARATOR ===== */
.date-separator {
  display: flex;
  justify-content: center;
  margin: var(--space-xs) 0;
  user-select: none;
}
.date-separator span {
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-size: var(--font-micro);
  font-weight: 600;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* ===== UNREAD SEPARATOR ===== */
.unread-separator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.5rem var(--space-sm);
  color: var(--danger);
  font-size: var(--font-micro);
  font-weight: 600;
  user-select: none;
}

.unread-separator::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--danger);
}

/* ===== UNREAD BANNER ===== */
.unread-banner {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 5;
  padding: 0.375rem 0.75rem;
  background: var(--accent);
  color: #fff;
  font-size: var(--font-small);
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  opacity: 0;
  animation: fadeIn 150ms ease forwards;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
}

.unread-banner:hover {
  filter: brightness(1.1);
}

/* (connection-bar удалён — индикатор переподключения теперь в кнопке отправки) */

/* ===== TYPING INDICATOR ===== */
.typing-indicator {
  padding: var(--space-xs) var(--space-sm);
  color: var(--text-secondary);
  font-size: var(--font-small);
  font-style: italic;
  flex-shrink: 0;
  border-top: 1px solid var(--border);
}

/* ===== ATTACHMENTS PREVIEW ===== */
.attachments-preview {
  display: flex;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-sm);
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
  overflow-x: auto;
  overflow-x: overlay;
  flex-shrink: 0;
}
.attach-thumb {
  position: relative;
  flex-shrink: 0;
  width: 4rem;
  height: 4rem;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg-primary);
}
.attach-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.attach-thumb--file {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 5rem;
  padding: var(--space-xs);
}
.attach-thumb__icon {
  font-size: 1.4rem;
}
.attach-thumb__name {
  font-size: 0.6rem;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
  text-align: center;
}
.attach-thumb__remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 1.2rem;
  height: 1.2rem;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.6);
  color: #fff;
  font-size: 0.65rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.attach-thumb__remove:hover {
  background: var(--danger);
}

/* ===== CHAT INPUT ===== */
.chat-input {
  display: flex;
  align-items: flex-end;
  gap: 0;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--bg-secondary);
}

.chat-input__attach {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 3rem;
  align-self: stretch;
  background: none;
  border: none;
  border-radius: 0;
  color: var(--text-secondary);
  cursor: pointer;
  flex-shrink: 0;
  transition: color var(--transition-fast);
}
.chat-input__attach .icon,
.chat-input__attach svg {
  width: 20px;
  height: 20px;
}

.chat-input__attach:hover {
  color: var(--text-primary);
}

.chat-input__field {
  flex: 1;
  padding: 0.625rem 0;
  font-size: var(--font-body);
  font-family: inherit;
  color: var(--text-primary);
  background: transparent;
  border: none;
  border-radius: 0;
  resize: none;
  outline: none;
  overflow-y: auto;
  min-height: 2.75rem;
  line-height: 1.5;
}

.chat-input__field::placeholder {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-input__send {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 3rem;
  align-self: stretch;
  background: none;
  border: none;
  border-radius: 0;
  color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
  transition: color var(--transition-fast), transform 0.25s ease;
}
.chat-input__send .icon,
.chat-input__send svg {
  width: 20px;
  height: 20px;
}

.chat-input__send:hover:not(:disabled) {
  color: var(--accent-hover);
  transform: translate(3px, -3px);
}

.chat-input__send:disabled {
  color: var(--text-secondary);
  opacity: 0;
  cursor: default;
}

.chat-input__send--reconnecting {
  color: var(--warning) !important;
  opacity: 1 !important;
  cursor: default;
}
.chat-input__send--reconnecting .icon {
  animation: spinReconnect 1.5s linear infinite;
}
@keyframes spinReconnect {
  to { transform: rotate(360deg); }
}

/* ===== EMPTY STATES ===== */
.empty-state {
  text-align: center;
  padding: var(--space-2xl);
  color: var(--text-secondary);
}

.empty-state__text {
  font-size: var(--font-body);
  font-weight: 500;
  margin-bottom: var(--space-xs);
}

.empty-state__hint {
  font-size: var(--font-small);
}

.empty-slots {
  padding: var(--space-sm);
  color: var(--text-secondary);
  font-size: var(--font-small);
  text-align: center;
}

/* ===== MODAL ACTIONS ===== */
.modal__actions {
  display: flex;
  gap: var(--space-sm);
  justify-content: flex-end;
  margin-top: var(--space-lg);
}

/* ===== REPLY PREVIEW ===== */
.reply-preview {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-xs) var(--space-sm);
  background: var(--bg-secondary);
  border-left: 3px solid var(--accent);
  flex-shrink: 0;
}

.reply-preview__content {
  flex: 1;
  min-width: 0;
  font-size: var(--font-small);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reply-preview__content strong {
  margin-right: var(--space-xs);
  color: var(--accent);
}

.reply-preview__close {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: var(--font-body);
  padding: var(--space-xs);
}

.reply-preview--edit .reply-preview__content strong {
  color: var(--warning, #ffa000);
}

/* ===== CHAT SEARCH PANEL ===== */
.chat-search-panel {
  display: flex;
  align-items: stretch;
  gap: 0;
  padding: 0;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  height: var(--panel-row);
}

.chat-search-panel .search-box {
  flex: 1;
}

.chat-search-panel .search-box__input {
  background: none;
  border: none;
  border-radius: 0;
  padding: 0 var(--space-sm) 0 1.75rem;
  height: 100%;
}

.chat-search-panel .search-box__input:focus {
  outline: none;
}

.chat-search-panel:focus-within {
  border-bottom-color: var(--accent);
}

#chat-search-count {
  display: flex;
  align-items: center;
  font-size: var(--font-small);
  color: var(--text-secondary);
  white-space: nowrap;
  padding: 0 0.625rem;
  border-left: 1px solid var(--border);
}

#chat-search-count:empty {
  display: none;
}

/* ===== CHAT FILTER BAR ===== */
.chat-filter-bar {
  display: flex;
  gap: 0;
  padding: 0;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  flex-wrap: nowrap;
  align-items: stretch;
  height: var(--panel-row);
}

.filter-btn {
  padding: 0 0.625rem;
  font-size: var(--font-small);
  font-family: inherit;
  background: none;
  border: none;
  border-radius: 0;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.filter-btn:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.filter-btn--active {
  background: var(--bg-secondary);
  color: var(--accent);
  position: relative;
}
.filter-btn--active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(to right, transparent, var(--accent) 20%, var(--accent) 80%, transparent);
  pointer-events: none;
}

/* ===== FAB SCROLL ===== */
.fab-scroll {
  position: absolute;
  bottom: var(--space-lg);
  right: var(--space-lg);
  width: 2.5rem;
  height: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius-full);
  cursor: pointer;
  box-shadow: var(--shadow-card-hover);
  z-index: 10;
  transition: transform var(--transition-fast);
}

.fab-scroll:hover {
  transform: scale(1.1);
}

#fab-count {
  position: absolute;
  top: -0.375rem;
  right: -0.375rem;
  min-width: 1.25rem;
  height: 1.25rem;
  padding: 0 0.3rem;
  background: var(--danger);
  color: #fff;
  font-size: 0.625rem;
  font-weight: 700;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--bg-primary);
  box-shadow: 0 1px 4px rgba(0,0,0,0.5);
}

/* ===== CHAT AREA (relative for FAB + top shadow) ===== */
.chat-area {
  position: relative;
}
.chat-area::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 12px;
  background: linear-gradient(to bottom, rgba(0,0,0,0.13), transparent);
  z-index: 2;
  pointer-events: none;
}
[data-theme="dark"] .chat-area::before {
  background: linear-gradient(to bottom, rgba(0,0,0,0.35), transparent);
}
@media (prefers-color-scheme: dark) {
  [data-theme="system"] .chat-area::before {
    background: linear-gradient(to bottom, rgba(0,0,0,0.35), transparent);
  }
}

/* ===== LIGHTBOX ===== */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  overscroll-behavior: none;
  touch-action: none;   /* все жесты обрабатываем сами */
}

.lightbox__content {
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 90vw;
  max-height: 90vh;
  overflow: visible;
}

.lightbox__img {
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
  border-radius: var(--radius-sm);
  transform-origin: 0 0;
  will-change: transform;
}

.lightbox__video {
  max-width: 90vw;
  max-height: 90vh;
  border-radius: var(--radius-sm);
  outline: none;
}

/* Общий стиль для ВСЕХ overlay-кнопок (лайтбокс + редактор) */
.overlay-btn {
  position: absolute;
  background: rgba(255,255,255,0.15);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: none;
  color: white;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background var(--transition-fast);
  z-index: 1102;
  padding: 0;
}
.overlay-btn:hover {
  background: rgba(255,255,255,0.3);
}
.overlay-btn--green {
  background: rgba(76, 175, 80, 0.5);
}
.overlay-btn--green:hover {
  background: rgba(76, 175, 80, 0.75);
}

/* Позиционирование кнопок лайтбокса */
.lightbox__close { top: var(--space-lg); right: var(--space-lg); }
.lightbox__nav   { top: 50%; transform: translateY(-50%); }
.lightbox__prev  { left: var(--space-lg); }
.lightbox__next  { right: var(--space-lg); }
.lightbox__edit-btn,
.lightbox__capture-btn {
  top: var(--space-lg);
  left: 50%;
  transform: translateX(-50%);
}

/* ===== ANNOTATION EDITOR ===== */
.annotation-editor {
  position: fixed;
  inset: 0;
  z-index: 1100;
  background: rgba(0, 0, 0, 0.95);
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow: hidden;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

/* Позиционирование кнопок редактора */
.ae-cancel { top: var(--space-lg); right: var(--space-lg); }
.ae-done   { top: var(--space-lg); left: var(--space-lg); }

/* Zoom indicator */
.ae-zoom-indicator {
  position: absolute;
  top: calc(var(--space-lg) + 3.5rem);
  right: var(--space-lg);
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  color: white;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  z-index: 1102;
  pointer-events: none;
  transition: opacity 0.3s;
}

/* Canvas wrapper */
.ae-canvas-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  overflow: hidden;
  position: relative;
}
.ae-canvas-wrap .canvas-container {
  touch-action: none;
}

/* Общий стиль нижних панелей (лайтбокс tray + редактор toolbar) */
.overlay-bottom-bar {
  background: rgba(30, 30, 30, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: 1rem 1rem 0 0;
  padding: 0.5rem 0.75rem;
  padding-bottom: max(0.5rem, env(safe-area-inset-bottom));
  box-sizing: border-box;
  width: 100%;
  max-width: 100vw;
}

/* Toolbar — two rows, centred */
.ae-toolbar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  z-index: 1102;
  flex-shrink: 0;
  overflow: visible;
}

.ae-toolbar__row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.ae-toolbar__tools {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  flex-wrap: wrap;
}

.ae-toolbar__actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  flex-wrap: wrap;
}

.ae-toolbar__sep {
  width: 1px;
  height: 1.5rem;
  background: rgba(255,255,255,0.15);
  flex-shrink: 0;
}

/* Tool buttons */
.ae-tool {
  flex-shrink: 0;
  width: 2.25rem;
  height: 2.25rem;
  min-width: 2.25rem;
  border-radius: 0.5rem;
  border: none;
  background: transparent;
  color: rgba(255,255,255,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}
.ae-tool:hover { background: rgba(255,255,255,0.1); color: white; }
.ae-tool--active {
  background: var(--accent, #3399ff);
  color: white;
}

/* Color buttons */
.ae-toolbar__colors {
  display: flex;
  gap: 0.3rem;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
}
.ae-color {
  width: 1.4rem;
  height: 1.4rem;
  min-width: 1.4rem;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: border-color var(--transition-fast), transform var(--transition-fast);
}
.ae-color:hover { transform: scale(1.15); }
.ae-color--active {
  border-color: white;
  transform: scale(1.2);
  box-shadow: 0 0 0 2px rgba(255,255,255,0.3);
}

/* Width slider */
.ae-toolbar__width {
  display: flex;
  align-items: center;
}
.ae-width-slider {
  width: 4rem;
  height: 1.5rem;
  accent-color: var(--accent, #3399ff);
  cursor: pointer;
}

/* Action buttons (undo, redo, clear) */
.ae-action {
  flex-shrink: 0;
  width: 2.25rem;
  height: 2.25rem;
  min-width: 2.25rem;
  border-radius: 0.5rem;
  border: none;
  background: transparent;
  color: rgba(255,255,255,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}
.ae-action:hover { background: rgba(255,255,255,0.1); color: white; }
.ae-action:disabled {
  opacity: 0.25;
  cursor: default;
  pointer-events: none;
}

/* ===== REVIEW TRAY (корзина отложенных) ===== */
.review-tray {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  overflow-x: auto;
  overflow-y: hidden;
  z-index: 1050;
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.review-tray::-webkit-scrollbar { display: none; }

.review-tray__items {
  display: flex;
  gap: 0.4rem;
  flex-shrink: 0;
}

.review-tray__item {
  position: relative;
  cursor: pointer;
  flex-shrink: 0;
  border-radius: 0.5rem;
  overflow: hidden;
  border: 2px solid rgba(255,255,255,0.15);
  transition: border-color var(--transition-fast);
}
.review-tray__item:hover {
  border-color: rgba(255,255,255,0.4);
}

.review-tray__thumb {
  width: 3.25rem;
  height: 3.25rem;
  object-fit: cover;
  display: block;
}

.review-tray__remove {
  position: absolute;
  top: -0.125rem;
  right: -0.125rem;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 50%;
  background: rgba(0,0,0,0.7);
  color: white;
  border: none;
  font-size: 0.75rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.review-tray__remove:hover { background: var(--danger, #e53935); }

.review-tray__attach {
  position: absolute;
  right: 0.75rem;
  flex-shrink: 0;
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  border: none;
  background: var(--accent, #3399ff);
  color: white;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--transition-fast);
}
.review-tray__attach:hover { filter: brightness(1.15); }

/* ===== BABYLON SCREENSHOT BUTTON ===== */
.babylon-modal__screenshot {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-xs) var(--space-sm);
  cursor: pointer;
  color: var(--text-primary);
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  transition: background var(--transition-fast);
}
.babylon-modal__screenshot:hover { background: var(--bg-hover); }
.babylon-modal__screenshot svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
}

/* ===== RESPONSIVE (Mobile) ===== */
@media (max-width: 640px) {
  /* Все overlay-кнопки сдвигаются к краю на мобильных */
  .lightbox__close,
  .lightbox__edit-btn,
  .lightbox__capture-btn,
  .ae-cancel,
  .ae-done {
    top: var(--space-sm);
  }
  .lightbox__close,
  .ae-cancel { right: var(--space-sm); }
  .ae-done { left: var(--space-sm); }
  .lightbox__prev { left: var(--space-sm); }
  .lightbox__next { right: var(--space-sm); }

  .ae-zoom-indicator {
    top: calc(var(--space-sm) + 3rem);
    right: var(--space-sm);
  }

  .overlay-bottom-bar {
    border-radius: 0.75rem 0.75rem 0 0;
    padding: 0.4rem 0.5rem;
    padding-bottom: max(0.4rem, env(safe-area-inset-bottom));
  }

  .ae-tool,
  .ae-action {
    width: 2.5rem;
    height: 2.5rem;
    min-width: 2.5rem;
  }

  .ae-width-slider { width: 3.5rem; }

  .review-tray__thumb {
    width: 2.75rem;
    height: 2.75rem;
  }
}

/* ===== MESSAGE CONTEXT MENU DANGER ===== */
.context-menu__item--danger {
  color: var(--danger);
}

/* ===== SEARCH HIGHLIGHT ===== */
.msg__text mark {
  background: var(--warning-light);
  color: var(--text-primary);
  padding: 0 0.125rem;
  border-radius: 0.125rem;
}

/* ===== MEMBERS CHECKBOXES ===== */
.members-checkboxes {
  max-height: 12rem;
  overflow-y: auto;
  overflow-y: overlay;
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  padding: var(--space-sm);
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
}

/* ===== RESIZING STATE ===== */
body.resizing {
  user-select: none !important;
  cursor: col-resize !important;
}

body.resizing * {
  cursor: col-resize !important;
}

/* ===== CONTEXT MENU ===== */
.context-menu {
  position: fixed;
  z-index: 10000;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-dropdown);
  padding: var(--space-xs) 0;
  min-width: 12rem;
}

.context-menu__item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: var(--space-sm) var(--space-lg);
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: var(--font-body);
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  transition: background var(--transition-fast);
}

.context-menu__item .icon {
  display: inline-flex;
  opacity: 0.5;
  flex-shrink: 0;
}

.context-menu__item:hover {
  background: var(--bg-secondary);
}

.context-menu__separator {
  height: 1px;
  background: var(--border);
  margin: 0.25rem 0;
}

.context-menu__title {
  padding: var(--space-xs) var(--space-lg) var(--space-sm);
  font-size: var(--font-small);
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--space-xs);
}

/* ===== MOBILE ===== */
@media (max-width: 48em) {
  .left-panel {
    position: fixed;
    top: var(--panels-top);
    left: 0;
    bottom: 0;
    width: 80vw !important;
    max-width: none;
    min-width: 0;
    z-index: 200;
    transform: translateX(-100%);
    transition: transform var(--transition-normal);
    box-shadow: var(--shadow-modal);
  }

  .left-panel.open {
    transform: translateX(0);
  }

  .left-panel-overlay {
    display: none;
    position: fixed;
    inset: var(--panels-top) 0 0 0;
    z-index: 199;
    background: rgba(0, 0, 0, 0.3);
  }

  .left-panel-overlay.visible {
    display: block;
  }

  .panel-divider {
    display: none;
  }

  .right-panel {
    width: 100%;
  }

  .slots-grid {
    grid-template-columns: repeat(auto-fill, minmax(5.5rem, 1fr));
  }


  .msg__thumb {
    height: 5rem;
  }

  .tab__name {
    max-width: 5rem;
    font-size: var(--font-small);
  }

  .tab {
    padding: 0.375rem 0.5rem;
  }

  .btn--done__label {
    display: none;
  }

}

@media (hover: none) {
  .msg-hover-toolbar {
    display: none !important;
  }
}

/* ===== INLINE FILTER BUTTONS ===== */
.stage-filter-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  border-radius: 0;
  cursor: pointer;
  padding: 0 0.5rem;
  transition: background var(--transition-fast), color var(--transition-fast);
  color: var(--text-secondary);
}

.stage-filter-btn:hover {
  color: var(--text-primary);
  background: var(--bg-secondary);
}

.stage-filter-btn--active {
  color: var(--accent);
  background: var(--bg-secondary);
  position: relative;
}
.stage-filter-btn--active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(to right, transparent, var(--accent) 20%, var(--accent) 80%, transparent);
  pointer-events: none;
}

/* ===== MESSAGE HOVER TOOLBAR ===== */
.msg-hover-toolbar {
  position: absolute;
  bottom: 100%;
  right: 0;
  display: flex;
  align-items: stretch;
  gap: 0;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  box-shadow: 0 4px 16px rgba(0,0,0,0.35), 0 1px 4px rgba(0,0,0,0.2);
  z-index: 10;
  opacity: 0;
  animation: fadeIn 100ms ease forwards;
  pointer-events: auto;
  margin-bottom: -2px;
  height: var(--panel-row);
  overflow: hidden;
}

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

.msg-hover-time {
  display: flex;
  align-items: center;
  font-size: var(--font-small);
  color: var(--text-secondary);
  padding: 0 0.625rem;
  white-space: nowrap;
  user-select: none;
  border-left: 1px solid var(--border);
}

.msg-hover-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  border-radius: 0;
  cursor: pointer;
  padding: 0;
  aspect-ratio: 1;
  min-width: var(--panel-row);
  color: var(--text-secondary);
  transition: background-color var(--transition-fast), color var(--transition-fast);
}

.msg-hover-btn:hover {
  background-color: var(--bg-secondary);
  color: var(--text-primary);
}

.msg-hover-btn[data-hover-action="delete"]:hover {
  color: var(--danger);
}

/* ===== MSG HIGHLIGHT (from search) ===== */
.msg--highlight {
  animation: msgHighlight 4s ease;
}

@keyframes msgHighlight {
  0%, 50% { background: rgba(var(--accent-rgb), 0.15); }
  100% { background: transparent; }
}

/* ===== MENTION POPUP ===== */
.mention-popup {
  position: absolute;
  bottom: 100%;
  left: var(--space-sm);
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-card-hover);
  max-height: 12rem;
  overflow-y: auto;
  overflow-y: overlay;
  z-index: 20;
  min-width: 12rem;
}

.mention-popup__item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: var(--font-body);
  text-align: left;
  transition: background var(--transition-fast);
}

.mention-popup__item:hover,
.mention-popup__item--active {
  background: var(--bg-secondary);
}

/* ===== 3D FILE BUTTON ===== */
.msg__file-3d {
  background: var(--accent-light);
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 0.125rem 0.375rem;
  font-size: var(--font-small);
  cursor: pointer;
  font-family: inherit;
  transition: background var(--transition-fast);
}

.msg__file-3d:hover {
  background: var(--accent);
  color: white;
}

/* ===== BABYLON MODAL ===== */
.babylon-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: var(--bg-primary);
  display: flex;
  flex-direction: column;
}

.babylon-modal__header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-lg);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}
.babylon-modal__header > span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.babylon-modal__ao-toggle {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-xs) var(--space-sm);
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 600;
  margin-left: auto;
  margin-right: var(--space-sm);
  transition: background 0.15s, color 0.15s;
}
.babylon-modal__ao-toggle:hover {
  background: var(--bg-hover);
}
.babylon-modal__ao-toggle.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.babylon-modal__close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-secondary);
  padding: var(--space-xs);
}

.babylon-modal__viewer {
  flex: 1;
  overflow: hidden;
}

/* ===== DM CONTACTS (кружочки в левой панели) ===== */
/* dm-contacts теперь живёт в шапке — стили в style.css */

.dm-contact {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  align-self: stretch;
  background: none;
  border: none;
  padding: 0 0.35rem;
  cursor: pointer;
}
.dm-contact:hover .dm-contact__avatar {
  transform: scale(1.12);
}
.dm-contact--active .dm-contact__avatar {
  box-shadow: 0 0 0 2px var(--accent);
}

.dm-contact__avatar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  font-size: 0.55rem;
  font-weight: 700;
  color: #fff;
  line-height: 1;
  text-transform: uppercase;
  flex-shrink: 0;
  transition: transform var(--transition-fast);
}

/* Групповой аватар: прямоугольник с закруглёнными краями + сетка участников */
.dm-contact__avatar--group {
  border-radius: 6px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  background: var(--bg-tertiary, #2a2a2e);
  padding: 1px;
  font-size: 0;
}
.dm-contact__avatar--group.dm-contact__avatar--group-1 {
  grid-template-columns: 1fr;
}

.dm-contact__avatar-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.45rem;
  font-weight: 700;
  line-height: 1;
  text-transform: uppercase;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}
.dm-contact__avatar-cell--more {
  font-size: 0.4rem;
  color: var(--text-muted, rgba(255,255,255,0.5));
}

/* .dm-contact__badge наследует .unread-badge--sm */
.dm-contact__badge {
  position: absolute;
  top: -4px;
  right: -4px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.4);
}

.dm-contact--add {
  font-size: 0;
  color: transparent;
}
.dm-contacts-bar .dm-contact--add {
  order: 999;
}
.dm-contact--add::before {
  content: '+';
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  border: 1.5px dashed var(--text-muted, var(--border));
  border-radius: 50%;
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 400;
  line-height: 1;
  transition: border-color var(--transition-fast), color var(--transition-fast);
}
.dm-contact--add:hover::before {
  border-color: var(--accent);
  color: var(--accent);
}

/* На desktop пунктирная кнопка "новый чат" появляется только при hover шапки */
@media (hover: hover) and (pointer: fine) {
  .header__dm-contacts .dm-contact--add,
  .dm-contacts-bar .dm-contact--add {
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-fast);
  }
  .header__dm-contacts:hover .dm-contact--add,
  .dm-contacts-bar:hover .dm-contact--add {
    opacity: 1;
    pointer-events: auto;
  }
}

/* ===== SLOT CARD HIGHLIGHT (при навигации назад/вперёд) ===== */
@keyframes slotCardHighlight {
  0%   { box-shadow: 0 0 0 3px var(--accent); }
  100% { box-shadow: 0 0 0 3px transparent; }
}
.slot-card--highlight {
  animation: slotCardHighlight 1.5s ease-out;
}

/* ===== DM CHAT HEADER ===== */
.chat-header--dm {
  display: flex;
  align-items: stretch;
  gap: 0;
  flex-shrink: 0;
  flex: 1;
  min-width: 0;
}

.chat-header--dm__avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  font-size: 0.5rem;
  font-weight: 700;
  color: #fff;
  line-height: 1;
  text-transform: uppercase;
  flex-shrink: 0;
  align-self: center;
}

/* Групповой аватар в заголовке чата */
.chat-header--dm__avatar--group {
  border-radius: 5px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  background: var(--bg-tertiary, #2a2a2e);
  padding: 1px;
  font-size: 0;
  overflow: hidden;
}
.chat-header--dm__avatar--group.chat-header--dm__avatar--group-1 {
  grid-template-columns: 1fr;
}

.chat-header--dm__avatar-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.4rem;
  font-weight: 700;
  line-height: 1;
  text-transform: uppercase;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}
.chat-header--dm__avatar-cell--more {
  font-size: 0.35rem;
  color: var(--text-muted, rgba(255,255,255,0.5));
}

.chat-header--dm__name {
  display: flex;
  align-items: center;
  font-weight: 600;
  font-size: var(--font-body);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0 0.5rem;
}

.chat-header--dm__count {
  display: flex;
  align-items: center;
  font-size: var(--font-small);
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0 0.625rem;
  border: none;
  border-radius: 0;
  background: none;
  transition: background var(--transition-fast), color var(--transition-fast);
  flex-shrink: 0;
}
.chat-header--dm__count:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.chat-header--dm__back {
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  border-radius: 0;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0;
  aspect-ratio: 1;
  min-width: var(--panel-row);
  transition: color var(--transition-fast), background var(--transition-fast);
  flex-shrink: 0;
}
.chat-header--dm__back:hover {
  color: var(--text-primary);
  background: var(--bg-secondary);
}

/* ===== NEW CHAT MODAL ===== */
.new-chat-modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.5);
}

.new-chat-modal__content {
  background: var(--bg-primary);
  border-radius: var(--radius-md);
  width: 24rem;
  max-width: 90vw;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}

.new-chat-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md);
  border-bottom: 1px solid var(--border);
}

.new-chat-modal__title {
  font-weight: 600;
  font-size: var(--font-body);
}

.new-chat-modal__close {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 1.25rem;
  padding: var(--space-xs);
  line-height: 1;
}
.new-chat-modal__close:hover {
  color: var(--text-primary);
}

.new-chat-modal__tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
}

.new-chat-modal__tab {
  flex: 1;
  padding: var(--space-sm) var(--space-md);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-weight: 500;
  font-size: var(--font-small);
  transition: color var(--transition-fast), border-color var(--transition-fast);
}
.new-chat-modal__tab:hover {
  color: var(--text-primary);
}
.new-chat-modal__tab--active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.new-chat-modal__search {
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--border);
}

.new-chat-modal__search input {
  width: 100%;
  padding: var(--space-xs) var(--space-sm);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: var(--font-small);
  font-family: inherit;
}
.new-chat-modal__search input:focus {
  border-color: var(--accent);
  outline: none;
}

.new-chat-modal__group-name {
  padding: var(--space-xs) var(--space-md);
}
.new-chat-modal__group-name input {
  width: 100%;
  padding: var(--space-xs) var(--space-sm);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: var(--font-small);
  font-family: inherit;
}
.new-chat-modal__group-name input:focus {
  border-color: var(--accent);
  outline: none;
}

.new-chat-modal__list {
  flex: 1;
  overflow-y: auto;
  overflow-y: overlay;
  padding: var(--space-xs) 0;
}

.new-chat-modal__user {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-xs) var(--space-md);
  cursor: pointer;
  transition: background var(--transition-fast);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  color: var(--text-primary);
  font-size: var(--font-small);
  font-family: inherit;
}
.new-chat-modal__user:hover {
  background: var(--bg-hover);
}

.new-chat-modal__user-avatar {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.625rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.new-chat-modal__user-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.new-chat-modal__user-check {
  width: 1.25rem;
  height: 1.25rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}
.new-chat-modal__user--selected .new-chat-modal__user-check {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.new-chat-modal__footer {
  padding: var(--space-sm) var(--space-md);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
}

.new-chat-modal__create-btn {
  padding: var(--space-xs) var(--space-lg);
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 600;
  font-size: var(--font-small);
  font-family: inherit;
  transition: background var(--transition-fast);
}
.new-chat-modal__create-btn:hover {
  background: var(--accent-hover);
}
.new-chat-modal__create-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ===== DM MEMBERS PANEL ===== */
.dm-members-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: 16rem;
  max-height: 100%;
  background: var(--bg-primary);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 10;
  box-shadow: -4px 0 12px rgba(0,0,0,0.1);
}

.dm-members-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: var(--font-small);
}

.dm-members-panel__close {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: var(--space-xs);
}

.dm-members-panel__list {
  flex: 1;
  overflow-y: auto;
  overflow-y: overlay;
  padding: var(--space-xs) 0;
}

.dm-members-panel__user {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-xs) var(--space-md);
  font-size: var(--font-small);
}

.dm-members-panel__user-avatar {
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.5625rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.dm-members-panel__user-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dm-members-panel__user-remove {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0.125rem;
  font-size: 0.875rem;
  line-height: 1;
  opacity: 0.5;
  transition: opacity var(--transition-fast), color var(--transition-fast);
}
.dm-members-panel__user-remove:hover {
  opacity: 1;
  color: var(--danger);
}
