/* ============ Buttons ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  height: 36px; padding: 0 var(--space-4);
  font-size: var(--fs-sm); font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease),
    color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
  white-space: nowrap;
}

/* Долгий тап по элементам управления не должен выделять текст или
   открывать системное меню (Сохранить картинку/Поделиться на iOS) — так
   выглядит нативный UI, не веб-страница. Только сами интерактивные
   элементы, не глобально — текст контента (описания, значения таблиц и
   т.п.) выделяться обязан как обычно. */
.btn, .tab, .segmented-item,
.select-trigger, .select-trigger-multi,
.dropdown-item, .checkbox-row, .table-sort {
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn:not(:disabled):active { transform: scale(.96); }
.btn-sm { height: 30px; padding: 0 var(--space-3); font-size: var(--fs-xs); }
.btn-lg { height: 44px; padding: 0 var(--space-6); font-size: var(--fs-md); }
.btn-icon { width: 36px; padding: 0; }
.btn-icon.btn-sm { width: 30px; }

.btn-primary { background: var(--brand); color: var(--text-on-brand); }
.btn-primary:hover { background: var(--brand-hover); }

.btn-secondary { background: var(--bg-surface-2); color: var(--text-primary); }
.btn-secondary:hover { background: var(--border-subtle); }

.btn-outline { background: transparent; color: var(--text-primary); border-color: var(--border-default); }
.btn-outline:hover { background: var(--bg-surface-2); }

.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--bg-surface-2); color: var(--text-primary); }

.btn-danger { background: var(--c-danger-500); color: #fff; }
.btn-danger:hover { filter: brightness(1.08); }

/* ============ Badges ============ */
.badge {
  display: inline-flex; align-items: center; gap: var(--space-1);
  height: 22px; padding: 0 var(--space-2);
  font-size: var(--fs-xs); font-weight: 600;
  border-radius: var(--radius-pill);
  background: var(--bg-surface-2); color: var(--text-secondary);
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-dot-none::before { display: none; }
.badge-success { background: var(--c-success-100); color: #15803d; }
.badge-warning { background: var(--c-warning-100); color: #b45309; }
.badge-danger  { background: var(--c-danger-100);  color: #b91c1c; }
.badge-info    { background: var(--c-info-100);    color: #0369a1; }
.badge-brand   { background: var(--brand-subtle);  color: var(--brand-subtle-text); }

/* ============ Card ============ */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border-subtle);
}
.card-body { padding: var(--space-5); }
.card-footer {
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--border-subtle);
}

/* ============ Avatar ============ */
.avatar {
  position: relative;
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--brand-subtle); color: var(--brand-subtle-text);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: var(--fs-xs); font-weight: 700; flex-shrink: 0;
  overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-sm { width: 28px; height: 28px; font-size: 11px; }
.avatar-lg { width: 48px; height: 48px; font-size: var(--fs-md); }
.avatar-status {
  position: absolute; right: -1px; bottom: -1px;
  width: 10px; height: 10px; border-radius: 50%;
  border: 2px solid var(--bg-surface); background: var(--c-gray-400);
}
.avatar-status.is-online { background: var(--c-success-500); }
.avatar-status.is-busy { background: var(--c-danger-500); }
.avatar-stack { display: flex; }
.avatar-stack .avatar { margin-left: -8px; border: 2px solid var(--bg-surface); }
.avatar-stack .avatar:first-child { margin-left: 0; }

/* ============ Form controls ============ */
.field { display: flex; flex-direction: column; gap: var(--space-1); }
.field-label { font-size: var(--fs-xs); font-weight: 600; color: var(--text-secondary); }
.input, .select, .textarea {
  width: 100%; height: 38px; padding: 0 var(--space-3);
  background: var(--bg-surface); color: var(--text-primary);
  border: 1px solid var(--border-default); border-radius: var(--radius-md);
  font-size: var(--fs-sm);
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.textarea { height: auto; padding: var(--space-2) var(--space-3); resize: vertical; min-height: 80px; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--brand); box-shadow: var(--focus-ring); }
.input::placeholder { color: var(--text-muted); }

.search-input { position: relative; }
.search-input input { padding-left: var(--space-8); }
.search-input svg { position: absolute; left: var(--space-3); top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--text-muted); }

.switch { position: relative; display: inline-block; width: 38px; height: 22px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch-track {
  position: absolute; inset: 0; background: var(--border-default); border-radius: var(--radius-pill);
  transition: background var(--dur-normal) var(--ease); cursor: pointer;
}
.switch-track::before {
  content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: transform var(--dur-normal) var(--ease);
}
.switch input:checked + .switch-track { background: var(--brand); }
.switch input:checked + .switch-track::before { transform: translateX(16px); }

/* ---- Крупные поля (заголовки задач, hero-формы) ---- */
.input-lg, .select-lg, .textarea-lg {
  height: 48px; padding: 0 var(--space-4);
  font-size: var(--fs-lg); font-weight: 600; border-radius: var(--radius-lg);
}
.textarea-lg { height: auto; min-height: 120px; padding: var(--space-3) var(--space-4); font-size: var(--fs-sm); font-weight: 400; }
.input-lg::placeholder { font-weight: 400; }

/* ---- Стилизованный чекбокс ---- */
.checkbox {
  appearance: none; -webkit-appearance: none; margin: 0;
  width: 18px; height: 18px; flex-shrink: 0; position: relative;
  border: 1.5px solid var(--border-default); border-radius: 5px;
  background: var(--bg-surface); cursor: pointer;
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.checkbox:hover { border-color: var(--text-muted); }
.checkbox:checked { background: var(--brand); border-color: var(--brand); }
.checkbox::after {
  content: ""; position: absolute; left: 5px; top: 1px; width: 5px; height: 9px;
  border: solid #fff; border-width: 0 2px 2px 0;
  transform: rotate(45deg) scale(0); transition: transform var(--dur-fast) var(--ease);
}
.checkbox:checked::after { transform: rotate(45deg) scale(1); }
.checkbox:focus-visible { box-shadow: var(--focus-ring); }
.checkbox-row {
  display: flex; align-items: center; gap: var(--space-2);
  padding: var(--space-2) var(--space-3); border-radius: var(--radius-sm);
  font-size: var(--fs-sm); cursor: pointer;
}
.checkbox-row:hover { background: var(--bg-surface-2); }

/* ---- Select с выпадающим списком (обычный, одиночный выбор) ---- */
.select-trigger {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-2);
  width: 100%; height: 38px; padding: 0 var(--space-3);
  background: var(--bg-surface); color: var(--text-primary);
  border: 1px solid var(--border-default); border-radius: var(--radius-md);
  font-size: var(--fs-sm); text-align: left;
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.select-trigger:hover { border-color: var(--text-muted); }
.dropdown.is-open .select-trigger { border-color: var(--brand); box-shadow: var(--focus-ring); }
/* [data-select-label] — сам текст выбранного значения; без flex:1;min-width:0
   он как flex-элемент не сжимается ниже своей естественной ширины (дефолт
   min-width:auto у flex-детей) и вместо обрезки переносился на 2 строки
   внутри фиксированной высоты триггера (38px) — то же "затухание в 1
   строку", что и у пунктов списка (.dropdown-item выше). */
.select-trigger [data-select-label] {
  flex: 1; min-width: 0; white-space: nowrap; overflow: hidden;
  -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 16px), transparent 100%);
  mask-image: linear-gradient(to right, #000 calc(100% - 16px), transparent 100%);
}
.select-trigger-placeholder { color: var(--text-muted); }
.select-trigger svg { width: 16px; height: 16px; color: var(--text-muted); flex-shrink: 0; transition: transform var(--dur-fast) var(--ease); }
.dropdown.is-open .select-trigger svg { transform: rotate(180deg); }

/* ---- Мультиселект с чекбоксами ---- */
.select-multi { width: 100%; }
.select-multi .dropdown-menu {
  left: 0; right: 0; width: auto; min-width: 0;
  max-height: 280px; overflow-y: auto;
}
.select-multi-search { padding: var(--space-1) var(--space-1) var(--space-2); border-bottom: 1px solid var(--border-subtle); margin-bottom: var(--space-1); }
.select-multi-search input { height: 32px; }
.select-multi-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding-top: var(--space-2); margin-top: var(--space-1); border-top: 1px solid var(--border-subtle);
}

/* Чипсы в триггере — строго одна строка, лишние схлопываются в "+N",
   не переносятся на новую строку и не растягивают триггер. */
.select-chips { display: flex; flex-wrap: nowrap; overflow: hidden; gap: var(--space-1); flex: 1; min-width: 0; }
.select-chip {
  display: inline-flex; align-items: center; gap: 4px; flex-shrink: 0;
  padding: 2px var(--space-2); border-radius: var(--radius-pill);
  background: var(--brand-subtle); color: var(--brand-subtle-text);
  font-size: var(--fs-xs); font-weight: 600; white-space: nowrap;
}
.select-chip-more { background: var(--bg-surface-2); color: var(--text-secondary); }

/* Триггер мультиселекта — не одна <button>, а составной: кликабельная
   область с чипсами (открывает список) + отдельная кнопка сброса всего
   выбора + шеврон. Кнопка сброса — не внутри <button>, чтобы не вложить
   интерактивный элемент в интерактивный и не путать это с открытием списка. */
.select-trigger-multi {
  display: flex; align-items: center; gap: var(--space-1);
  width: 100%; height: 38px; padding: 0 var(--space-2) 0 0;
  background: var(--bg-surface); color: var(--text-primary);
  border: 1px solid var(--border-default); border-radius: var(--radius-md);
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.select-trigger-multi:hover { border-color: var(--text-muted); }
.dropdown.is-open .select-trigger-multi { border-color: var(--brand); box-shadow: var(--focus-ring); }
.select-trigger-toggle {
  flex: 1; min-width: 0; height: 100%;
  display: flex; align-items: center;
  padding: 0 var(--space-3); background: none; border: none; text-align: left;
}
.select-clear-all {
  flex-shrink: 0; width: 22px; height: 22px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.select-clear-all svg { width: 14px; height: 14px; }
.select-clear-all:hover { background: var(--bg-surface-2); color: var(--text-primary); }
.select-trigger-chevron { flex-shrink: 0; display: flex; padding-right: var(--space-2); color: var(--text-muted); }
.select-trigger-chevron svg { width: 16px; height: 16px; transition: transform var(--dur-fast) var(--ease); }
.dropdown.is-open .select-trigger-chevron svg { transform: rotate(180deg); }

/* ============ Table ============ */
.table-wrap { overflow-x: auto; border-radius: var(--radius-lg); border: 1px solid var(--border-subtle); }
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); background: var(--bg-surface); }
.table th {
  text-align: left; padding: var(--space-3) var(--space-4);
  font-size: var(--fs-xs); font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .03em;
  background: var(--bg-surface-2); white-space: nowrap;
  position: sticky; top: 0;
}
.table td { padding: var(--space-3) var(--space-4); border-top: 1px solid var(--border-subtle); vertical-align: middle; }
.table tbody tr { transition: background var(--dur-fast) var(--ease); }
.table tbody tr:hover { background: var(--bg-surface-2); }
.table-sort { display: inline-flex; align-items: center; gap: var(--space-1); cursor: pointer; }
.table-checkbox-col { width: 40px; }

/* ============ Dropdown ============ */
.dropdown { position: relative; display: inline-block; }
.dropdown-menu {
  position: absolute; right: 0; top: calc(100% + var(--space-2));
  min-width: 200px; padding: var(--space-2);
  background: var(--bg-elevated); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md); box-shadow: var(--shadow-lg);
  z-index: var(--z-dropdown);
  opacity: 0; transform: translateY(-4px) scale(.98); pointer-events: none;
  transition: opacity var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.dropdown.is-open .dropdown-menu { opacity: 1; transform: none; pointer-events: auto; }
/* Одиночный select (data-select) — список минимум с шириной триггера
   (min-width:100%, не width:auto с left:0;right:0 как раньше — та версия
   жёстко пришивала ширину списка К ширине триггера, из-за чего длинные
   варианты типа адресов магазинов переносились на 2 строки, даже когда
   места на экране было полно). Если контент шире триггера — список сам
   расширяется (width:max-content) вправо от левого края, до max-width;
   дальше — не перенос, а затухание строки (.dropdown-item ниже). */
.dropdown[data-select] .dropdown-menu { left: 0; right: auto; width: max-content; min-width: 100%; max-width: min(420px, calc(100vw - 24px)); }
.dropdown-item {
  display: flex; align-items: center; gap: var(--space-2);
  width: 100%; padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm); font-size: var(--fs-sm); text-align: left;
  transition: background var(--dur-fast) var(--ease);
  white-space: nowrap; overflow: hidden;
  -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 20px), transparent 100%);
  mask-image: linear-gradient(to right, #000 calc(100% - 20px), transparent 100%);
}
/* НЕ var(--bg-surface-2) — в тёмной теме он совпадает с var(--bg-elevated)
   (фон самого .dropdown-menu, оба = --c-gray-800), из-за чего hover был
   визуально неотличим от фона: непонятно, какой пункт нажмётся. color-mix
   всегда даёт заметную разницу с текущим фоном независимо от темы. */
.dropdown-item:hover { background: color-mix(in srgb, var(--text-primary) 8%, var(--bg-elevated)); }
.dropdown-item.is-selected { background: var(--brand-subtle); color: var(--brand-subtle-text); font-weight: 600; }
.dropdown-divider { height: 1px; background: var(--border-subtle); margin: var(--space-2) 0; }

/* ============ Modal ============ */
.modal-backdrop {
  position: fixed; inset: 0; background: var(--bg-overlay);
  display: flex; align-items: center; justify-content: center; padding: var(--space-4);
  z-index: var(--z-modal); opacity: 0; pointer-events: none;
  transition: opacity var(--dur-normal) var(--ease);
}
.modal-backdrop.is-open { opacity: 1; pointer-events: auto; }
.modal {
  width: 100%; max-width: 480px; max-height: 85vh; overflow: auto;
  background: var(--bg-elevated); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  transform: translateY(12px) scale(.98); transition: transform var(--dur-normal) var(--ease);
}
.modal-backdrop.is-open .modal { transform: none; }

/* ============ Task detail modal ============ */
.task-modal {
  width: 100%; max-width: 960px; max-height: 88vh;
  display: flex; flex-direction: column; overflow: hidden;
}
.task-modal-header {
  display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-4);
  padding: var(--space-5) var(--space-6); border-bottom: 1px solid var(--border-subtle); flex-shrink: 0;
}
.task-modal-eyebrow { display: flex; align-items: center; gap: var(--space-2); margin-bottom: var(--space-1); }
.task-modal-body { display: grid; grid-template-columns: 1fr 340px; flex: 1; min-height: 0; }

.task-modal-main { padding: var(--space-6); overflow-y: auto; border-right: 1px solid var(--border-subtle); display: flex; flex-direction: column; gap: var(--space-6); }
.task-modal-desc { font-size: var(--fs-sm); color: var(--text-secondary); line-height: var(--lh-normal); }

.task-meta-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-5); }
.task-meta-item { display: flex; flex-direction: column; gap: var(--space-1); }
.task-meta-item label { font-size: var(--fs-xs); font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .03em; }
.task-meta-value { display: flex; align-items: center; gap: var(--space-2); font-size: var(--fs-sm); font-weight: 500; }

.attachment-list { display: flex; flex-direction: column; gap: var(--space-2); }
.attachment-row {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-2) var(--space-3); border: 1px solid var(--border-subtle); border-radius: var(--radius-md);
}
.attachment-icon {
  width: 34px; height: 34px; border-radius: var(--radius-sm); flex-shrink: 0;
  background: var(--bg-surface-2); color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center;
}
.attachment-icon svg { width: 16px; height: 16px; }
.attachment-meta { flex: 1; min-width: 0; }
.attachment-name { font-size: var(--fs-sm); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.attachment-size { font-size: var(--fs-xs); color: var(--text-muted); }

.task-modal-side { display: flex; flex-direction: column; min-height: 0; background: var(--bg-surface-2); }
.task-modal-side-head { padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--border-subtle); flex-shrink: 0; }
.task-modal-side-scroll { flex: 1; overflow-y: auto; padding: var(--space-4) var(--space-5); display: flex; flex-direction: column; gap: var(--space-4); }
.task-modal-composer { padding: var(--space-3); border-top: 1px solid var(--border-subtle); flex-shrink: 0; }

.activity-event {
  display: flex; align-items: center; gap: var(--space-2);
  font-size: var(--fs-xs); color: var(--text-muted); text-align: center; justify-content: center;
}
.activity-event::before, .activity-event::after { content: ""; flex: 1; height: 1px; background: var(--border-subtle); }

@media (max-width: 760px) {
  .task-modal { max-width: none; max-height: 92vh; }
  .task-modal-body { grid-template-columns: 1fr; overflow-y: auto; }
  .task-modal-main { border-right: none; border-bottom: 1px solid var(--border-subtle); overflow-y: visible; padding: var(--space-4); gap: var(--space-4); }
  .task-meta-grid { grid-template-columns: 1fr; }
  .task-modal-side { min-height: 320px; }
  .task-modal-side-scroll { overflow-y: visible; }
}

/* ============ Tabs ============ */
.tabs { display: flex; gap: var(--space-1); border-bottom: 1px solid var(--border-subtle); }
.tab {
  padding: var(--space-3) var(--space-4); font-size: var(--fs-sm); font-weight: 600;
  color: var(--text-secondary); border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.tab:hover { color: var(--text-primary); }
.tab.is-active { color: var(--brand); border-color: var(--brand); }

/* ============ Progress ============ */
.progress { height: 6px; border-radius: var(--radius-pill); background: var(--bg-surface-2); overflow: hidden; }
.progress-bar { height: 100%; background: var(--brand); border-radius: var(--radius-pill); transition: width var(--dur-normal) var(--ease); }

/* ============ Empty state ============ */
.empty-state { display: flex; flex-direction: column; align-items: center; gap: var(--space-3); padding: var(--space-16) var(--space-4); text-align: center; color: var(--text-muted); }
.empty-state svg { width: 48px; height: 48px; opacity: .4; }

/*
 * ============ Error state ============
 * Тот же layout, что .empty-state (список/секция пустая) — но для случая
 * "не удалось загрузить" (обрыв сети, таймаут, 5xx и т.п.): раньше почти
 * везде это была голая строка текста ("Не удалось загрузить..."), без
 * возможности повторить попытку не обновляя всю страницу руками. Кнопка
 * "Обновить" — data-атрибут, а не готовый обработчик: клик должен звать
 * ИМЕННО ту функцию, которая изначально грузила этот блок (повторный
 * fetch, не location.reload() — не сбрасывать всё остальное на странице
 * ради одного неудавшегося списка), поэтому обработчик вешает сам
 * вызывающий код на элемент с data-error-retry после вставки разметки.
 */
.error-state { display: flex; flex-direction: column; align-items: center; gap: var(--space-3); padding: var(--space-16) var(--space-4); text-align: center; }
.error-state svg { width: 44px; height: 44px; color: var(--text-muted); opacity: .5; }
.error-state-title { font-size: var(--fs-md); font-weight: 600; color: var(--text-primary); }
.error-state-text { font-size: var(--fs-sm); color: var(--text-muted); max-width: 320px; }
.error-state [data-error-retry] { margin-top: var(--space-1); }

/* ============ Task card ============ */
.task-card {
  display: flex; flex-direction: column; gap: var(--space-2);
  padding: var(--space-4); background: var(--bg-surface);
  border: 1px solid var(--border-subtle); border-radius: var(--radius-md);
  cursor: pointer; transition: box-shadow var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.task-card:hover { box-shadow: var(--shadow-md); border-color: var(--border-default); }
.task-card-title { font-size: var(--fs-sm); font-weight: 600; }
.task-card-meta { display: flex; align-items: center; justify-content: space-between; }
.priority-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.priority-high { background: var(--c-danger-500); }
.priority-medium { background: var(--c-warning-500); }
.priority-low { background: var(--c-info-500); }

/* Drag & drop state */
.task-card[draggable="true"] { cursor: grab; }
.task-card.is-dragging { opacity: .45; cursor: grabbing; }
.kanban-cards.is-drag-over { background: var(--brand-subtle); border-radius: var(--radius-md); outline: 2px dashed var(--brand); outline-offset: -2px; }

/* Взять в работу / Завершить */
.task-card-actions { display: flex; gap: var(--space-2); margin-top: var(--space-1); }
.task-card-actions .btn { flex: 1; }

/* ============ Chat ============ */
.chat-message { display: flex; gap: var(--space-3); max-width: 720px; }
.chat-message--user { flex-direction: row-reverse; margin-left: auto; }
.chat-bubble {
  padding: var(--space-3) var(--space-4); border-radius: var(--radius-lg);
  background: var(--bg-surface-2); font-size: var(--fs-sm); line-height: var(--lh-normal);
}
.chat-message--user .chat-bubble { background: var(--brand); color: var(--text-on-brand); border-bottom-right-radius: var(--radius-sm); }
.chat-message--ai .chat-bubble { border-bottom-left-radius: var(--radius-sm); }
.chat-composer {
  display: flex; align-items: flex-end; gap: var(--space-2);
  padding: var(--space-3); background: var(--bg-surface);
  border: 1px solid var(--border-default); border-radius: var(--radius-lg);
}
.chat-composer textarea { flex: 1; border: none; resize: none; background: transparent; max-height: 160px; }
.chat-composer textarea:focus { box-shadow: none; }

/* ============ Player ============ */
.player-bar {
  display: grid; grid-template-columns: minmax(0,1fr) auto minmax(0,1fr);
  align-items: center; gap: var(--space-4);
  padding: var(--space-3) var(--space-4);
  background: var(--bg-elevated); border-top: 1px solid var(--border-subtle);
}
.track-row {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-2) var(--space-3); border-radius: var(--radius-md);
}
.track-row:hover { background: var(--bg-surface-2); }
.track-row.is-playing { background: var(--brand-subtle); }
.track-art { width: 40px; height: 40px; border-radius: var(--radius-sm); object-fit: cover; background: var(--bg-surface-2); flex-shrink: 0; }
.player-controls { display: flex; align-items: center; gap: var(--space-3); }
.player-play { width: 36px; height: 36px; border-radius: 50%; background: var(--text-primary); color: var(--bg-surface); display: flex; align-items: center; justify-content: center; }

/* ============ Notification item ============ */
.notif-item {
  display: flex; gap: var(--space-3); padding: var(--space-4);
  border-bottom: 1px solid var(--border-subtle); position: relative;
}
.notif-item.is-unread { background: var(--brand-subtle); }
.notif-item.is-unread::before {
  content: ""; position: absolute; left: 6px; top: 50%; transform: translateY(-50%);
  width: 6px; height: 6px; border-radius: 50%; background: var(--brand);
}
.notif-icon {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-surface-2); color: var(--text-secondary);
}

/* ============ Toast ============ */
.toast-stack {
  position: fixed; top: var(--space-4); right: var(--space-4);
  z-index: var(--z-toast); width: 100%; max-width: 360px;
  display: flex; flex-direction: column; gap: var(--space-2);
  pointer-events: none;
}
.toast {
  display: flex; align-items: flex-start; gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--bg-elevated); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md); box-shadow: var(--shadow-lg);
  font-size: var(--fs-sm); pointer-events: auto;
  animation: toast-in var(--dur-normal) var(--ease);
}
.toast.is-leaving { animation: toast-out var(--dur-fast) var(--ease) forwards; }
.toast-icon { width: 20px; height: 20px; flex-shrink: 0; margin-top: 1px; }
.toast-body { flex: 1; min-width: 0; }
.toast-title { font-weight: 600; }
.toast-desc { color: var(--text-secondary); }
.toast-close { flex-shrink: 0; width: 24px; height: 24px; color: var(--text-muted); }
.toast-success .toast-icon { color: var(--c-success-500); }
.toast-warning .toast-icon { color: var(--c-warning-500); }
.toast-danger  .toast-icon { color: var(--c-danger-500); }
.toast-info    .toast-icon { color: var(--c-info-500); }
@keyframes toast-in  { from { opacity: 0; transform: translateY(-8px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to   { opacity: 0; transform: translateX(16px); } }

/* ============ Skeleton ============ */
.skeleton {
  position: relative; overflow: hidden;
  background: var(--bg-surface-2); border-radius: var(--radius-sm);
}
.skeleton::after {
  content: ""; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgb(255 255 255 / 35%), transparent);
  animation: skeleton-shimmer 1.4s infinite;
}
:root[data-theme="dark"] .skeleton::after {
  background: linear-gradient(90deg, transparent, rgb(255 255 255 / 8%), transparent);
}
@keyframes skeleton-shimmer { 100% { transform: translateX(100%); } }
.skeleton-text   { height: 12px; border-radius: 4px; }
.skeleton-text + .skeleton-text { margin-top: var(--space-2); }
.skeleton-text.is-60 { width: 60%; }
.skeleton-text.is-80 { width: 80%; }
.skeleton-avatar { width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0; }
.skeleton-card   { height: 120px; border-radius: var(--radius-lg); }
.skeleton-row    { display: flex; align-items: center; gap: var(--space-3); }

/* ============ Spinner ============ */
.spinner {
  width: 20px; height: 20px; border-radius: 50%; flex-shrink: 0;
  border: 2px solid var(--border-subtle); border-top-color: var(--brand);
  animation: spinner-spin .6s linear infinite;
}
.spinner-sm { width: 14px; height: 14px; border-width: 2px; }
.spinner-lg { width: 32px; height: 32px; border-width: 3px; }
.spinner-on-brand { border-color: rgb(255 255 255 / 35%); border-top-color: #fff; }
@keyframes spinner-spin { to { transform: rotate(360deg); } }

/* ============ Incident / status bar ============ */
.status-bar {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-2) var(--space-4);
  font-size: var(--fs-sm); font-weight: 600;
}
.status-bar-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.status-bar-action { margin-left: auto; }
.status-bar-info     { background: var(--c-info-100);    color: #0369a1; }
.status-bar-warning  { background: var(--c-warning-100); color: #b45309; }
.status-bar-critical { background: var(--c-danger-100);  color: #b91c1c; }
:root[data-theme="dark"] .status-bar-info     { background: rgb(14 165 233 / 16%); color: var(--c-info-500); }
:root[data-theme="dark"] .status-bar-warning  { background: rgb(245 158 11 / 16%); color: var(--c-warning-500); }
:root[data-theme="dark"] .status-bar-critical { background: rgb(239 68 68 / 16%);  color: var(--c-danger-500); }

/* ============ Error boundary / offline banner ============ */
.error-boundary {
  display: flex; flex-direction: column; align-items: center; gap: var(--space-3);
  padding: var(--space-16) var(--space-4); text-align: center; color: var(--text-muted);
}
.error-boundary svg { width: 48px; height: 48px; color: var(--c-danger-500); opacity: .7; }
.error-boundary-title { font-size: var(--fs-lg); font-weight: 600; color: var(--text-primary); }
.error-boundary-desc { max-width: 420px; }
.error-boundary-actions { display: flex; gap: var(--space-2); margin-top: var(--space-1); }

.offline-banner {
  display: flex; align-items: center; justify-content: center; gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  background: var(--c-warning-100); color: #b45309;
  font-size: var(--fs-sm); font-weight: 600;
}
:root[data-theme="dark"] .offline-banner { background: rgb(245 158 11 / 16%); color: var(--c-warning-500); }

/* ============ Tooltip ============ */
.tooltip { position: relative; display: inline-flex; }
.tooltip::after {
  content: attr(data-tooltip);
  position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%) translateY(2px);
  padding: 4px 8px; border-radius: var(--radius-sm);
  background: var(--c-gray-900); color: #fff;
  font-size: var(--fs-xs); font-weight: 500; white-space: nowrap;
  opacity: 0; pointer-events: none;
  transition: opacity var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
  z-index: var(--z-dropdown);
}
:root[data-theme="dark"] .tooltip::after { background: var(--c-gray-700); }
.tooltip:hover::after, .tooltip:focus-visible::after { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ============ Pagination / Load more ============ */
.pagination { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
.pagination-info { font-size: var(--fs-sm); color: var(--text-muted); }
.pagination-controls { display: flex; align-items: center; gap: var(--space-2); }
.load-more { display: flex; justify-content: center; padding: var(--space-4) 0; }

/* ============ Upload / Dropzone ============ */
.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: var(--space-2);
  padding: var(--space-8) var(--space-4); text-align: center;
  border: 1.5px dashed var(--border-default); border-radius: var(--radius-lg);
  color: var(--text-muted); cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}
.dropzone svg { width: 32px; height: 32px; opacity: .6; }
.dropzone:hover, .dropzone.is-dragover { border-color: var(--brand); background: var(--brand-subtle); color: var(--brand-subtle-text); }
.dropzone-hint { font-size: var(--fs-xs); }
.dropzone-preview { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-2) var(--space-3); border: 1px solid var(--border-subtle); border-radius: var(--radius-md); }
.dropzone-preview img { width: 36px; height: 36px; border-radius: var(--radius-sm); object-fit: cover; }

/* ============ Icon picker ============ */
.icon-picker { display: flex; flex-direction: column; gap: var(--space-3); }
.icon-picker-search { max-width: 280px; }
.icon-picker-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: var(--space-2);
  max-height: 200px; overflow-y: auto; padding: var(--space-1);
}
.icon-picker-item {
  display: flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle); background: var(--bg-surface);
  color: var(--text-secondary);
}
.icon-picker-item svg { width: 18px; height: 18px; }
.icon-picker-item:hover { border-color: var(--border-default); color: var(--text-primary); }
.icon-picker-item.is-selected { border-color: var(--brand); background: var(--brand-subtle); color: var(--brand-subtle-text); }
.icon-picker-custom { display: flex; align-items: center; gap: var(--space-3); padding-top: var(--space-2); border-top: 1px solid var(--border-subtle); }

/* ============ Профиль: обложка + аватар с наложением ============ */
.profile-cover {
  position: relative; height: 160px; border-radius: var(--radius-lg);
  background: var(--brand-subtle); overflow: hidden;
}
.profile-cover img { width: 100%; height: 100%; object-fit: cover; }
.profile-cover-edit {
  position: absolute; top: var(--space-3); right: var(--space-3);
  background: rgb(0 0 0 / 40%); color: #fff;
}
.profile-cover-edit:hover { background: rgb(0 0 0 / 55%); }

.profile-header {
  display: flex; align-items: flex-end; gap: var(--space-4);
  margin-top: -40px; padding: 0 var(--space-4);
  position: relative;
}
.profile-avatar-wrap { position: relative; flex-shrink: 0; }
.avatar-xl { width: 88px; height: 88px; font-size: var(--fs-2xl); border: 4px solid var(--bg-body); }
.profile-avatar-edit {
  position: absolute; right: -2px; bottom: -2px; width: 28px; height: 28px;
  background: var(--bg-surface); border: 2px solid var(--bg-body); border-radius: 50%;
  box-shadow: var(--shadow-sm); color: var(--text-secondary);
}
.profile-avatar-edit svg { width: 14px; height: 14px; }
.profile-avatar-edit:hover { color: var(--text-primary); }
.profile-header-meta { padding-bottom: var(--space-2); min-width: 0; }
.profile-header-meta h2 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ============ User list item (аватар + имя/мета + кебаб-меню справа) ============ */
.user-list { display: flex; flex-direction: column; }
.user-row {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-3) var(--space-2);
  border-bottom: 1px solid var(--border-subtle);
  transition: background var(--dur-fast) var(--ease);
}
.user-row:last-child { border-bottom: none; }
.user-row:hover { background: var(--bg-surface-2); }
.user-row-meta { flex: 1; min-width: 0; }
.user-row-name { font-size: var(--fs-sm); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-row-sub { font-size: var(--fs-xs); color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-row-actions { flex-shrink: 0; }

/* ============ Segmented control (переключатель страниц/видов —
   pill-группа, в отличие от .tabs это не подчёркивание, а капсулы) ============ */
.segmented {
  display: inline-flex; align-items: center; gap: 2px;
  padding: 3px; border-radius: var(--radius-pill);
  background: var(--bg-surface-2);
}
.segmented-item {
  display: inline-flex; align-items: center; gap: var(--space-1);
  padding: var(--space-2) var(--space-4); border-radius: var(--radius-pill);
  font-size: var(--fs-sm); font-weight: 600; color: var(--text-secondary);
  white-space: nowrap;
  transition: background var(--dur-normal) var(--ease), color var(--dur-fast) var(--ease), box-shadow var(--dur-normal) var(--ease);
}
.segmented-item:hover { color: var(--text-primary); }
.segmented-item.is-active { background: var(--bg-surface); color: var(--text-primary); box-shadow: var(--shadow-sm); }
.segmented-item .badge { margin-left: 2px; }

/* ============ Section nav (вложенная навигация внутри раздела,
   не весь App Shell — например, меню профиля: Профиль/Мои приложения/
   Мои сессии/Настройки) ============ */
.section-nav { display: flex; flex-direction: column; gap: 2px; min-width: 200px; }
.section-nav-item {
  display: flex; align-items: center; gap: var(--space-2);
  padding: var(--space-2) var(--space-3); border-radius: var(--radius-md);
  font-size: var(--fs-sm); font-weight: 500; color: var(--text-secondary);
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.section-nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.section-nav-item:hover { background: var(--bg-surface-2); color: var(--text-primary); }
.section-nav-item.is-active { background: var(--brand-subtle); color: var(--brand-subtle-text); font-weight: 600; }

/* ============ ConfirmDialog (Modal + danger-акцент, см. 7.3) ============ */
.modal-danger-icon {
  width: 44px; height: 44px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--c-danger-100); color: var(--c-danger-500);
}
:root[data-theme="dark"] .modal-danger-icon { background: rgb(239 68 68 / 16%); }
.modal-danger-icon svg { width: 22px; height: 22px; }

/* ============ Reduced motion ============ */
@media (prefers-reduced-motion: reduce) {
  .skeleton::after { animation: none; }
  .toast, .toast.is-leaving { animation: none; }
}
