:root {
  --bg: #F7F8FA;
  --surface: #FFFFFF;
  --border: #E7E9EE;
  --text: #23262F;
  --text-muted: #767C8C;
  --primary: #6C5CE7;
  --primary-hover: #5A4CD6;
  --primary-soft: #EFEBFF;
  --danger: #E4574C;
  --danger-soft: #FDEEEC;
  --success: #2FAE6D;
  --deadline-soft-red: #FBE3E1;
  --card-neutral: var(--bg);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(20, 20, 40, 0.04);
  --shadow-md: 0 8px 24px rgba(20, 20, 40, 0.08);
  --shadow-lg: 0 16px 48px rgba(20, 20, 40, 0.16);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  overflow-x: hidden;
}

h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
p { margin: 0; }

.hidden { display: none !important; }

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  outline: none;
}

input, textarea, select {
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  width: 100%;
  transition: border-color .15s ease, box-shadow .15s ease;
}

input:focus, textarea:focus, select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

input:disabled, textarea:disabled, select:disabled {
  background: var(--bg);
  color: var(--text-muted);
  cursor: not-allowed;
}

textarea { resize: vertical; }

.post-body-editor {
  min-height: 140px;
  max-height: 400px;
  overflow-y: auto;
  line-height: 1.5;
  cursor: text;
}
.post-body-editor:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.post-body-editor:empty::before {
  content: attr(data-placeholder);
  color: var(--text-muted);
  pointer-events: none;
}
.post-body-editor[contenteditable="false"] {
  background: var(--bg);
  color: var(--text-muted);
  cursor: not-allowed;
}
.post-body-editor ul {
  margin: 0 0 8px 20px;
  padding: 0;
}
.post-body-editor a {
  color: var(--primary);
  text-decoration: underline;
}

/* ---------- Цветовые индикаторы и пикер цвета запуска ---------- */

.launch-color-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 6px;
  flex-shrink: 0;
  vertical-align: middle;
}

.calendar-launch-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-left: 3px;
  vertical-align: middle;
  cursor: pointer;
}

.day-num-clickable { cursor: pointer; }
.day-num-clickable:hover { text-decoration: underline; }

.launch-name-view {
  display: flex;
  align-items: center;
  font-weight: 700;
  font-size: 14px;
}

/* ---------- Buttons ---------- */

.btn-primary, .btn-secondary, .btn-ghost, .btn-danger {
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover { background: var(--primary-hover); }

.btn-secondary {
  background: var(--primary-soft);
  color: var(--primary);
}
.btn-secondary:hover { background: #E3DCFF; }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}
.btn-ghost:hover { background: var(--bg); color: var(--text); }

.btn-danger {
  background: var(--danger-soft);
  color: var(--danger);
}
.btn-danger:hover { background: #FBDBD7; }

.full-width { width: 100%; }

.icon-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  width: 34px;
  height: 34px;
  font-size: 18px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
}
.icon-btn:hover { background: var(--bg); color: var(--text); }

/* Кнопки с иконкой + текстом (например «Дублировать» в модалке поста) -
   иконка (SVG, fill="currentColor") и подпись выровнены по центру строки. */
.btn-with-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.btn-with-icon svg { flex-shrink: 0; }

/* Стрелка «Открыть подробнее» у мини-карточек запуска - фирменный
   фиолетовый цвет (соответствует --primary), а не приглушённо-серый, как у
   остальных icon-btn. */
.mini-open-btn { color: var(--primary); }
.mini-open-btn:hover { background: var(--primary-soft); color: var(--primary-hover); }

/* ---------- Login screen ---------- */

.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #F7F8FA 0%, #EFEBFF 100%);
  padding: 20px;
}

.login-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 48px 40px;
  width: 100%;
  max-width: 360px;
  text-align: center;
}

.login-card h1 {
  font-size: 28px;
  color: var(--primary);
}

.login-subtitle {
  color: var(--text-muted);
  margin-top: 6px;
  margin-bottom: 28px;
}

.login-card form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.error-text {
  color: var(--danger);
  font-size: 13px;
  text-align: left;
}

/* ---------- App shell ---------- */

.app { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 14px 28px;
}

.topbar-brand {
  font-weight: 700;
  font-size: 16px;
  color: var(--text);
}
.topbar-brand span {
  font-weight: 400;
  color: var(--text-muted);
  margin-left: 6px;
}

.current-role-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
  background: var(--primary-soft);
  padding: 5px 12px;
  border-radius: 999px;
  white-space: nowrap;
}

.profile-menu { position: relative; }
.profile-menu-trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}
.profile-menu-trigger::after {
  content: '▾';
  font-size: 9px;
}
.profile-menu-trigger:hover { background: #E3DCFF; }

.profile-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  min-width: 140px;
  padding: 6px;
  z-index: 50;
}
.profile-dropdown-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--danger);
  background: transparent;
}
.profile-dropdown-item:hover { background: var(--danger-soft); }

.tabs {
  display: flex;
  gap: 4px;
  flex: 1;
}

.tab-btn {
  background: transparent;
  color: var(--text-muted);
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 14px;
}
.tab-btn:hover { background: var(--bg); }
.tab-btn.active { background: var(--primary-soft); color: var(--primary); }

main {
  flex: 1;
  padding: 24px 28px 48px;
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.tab-panel > h2 { margin-bottom: 16px; }

/* ---------- Dashboard split ---------- */

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 24px;
  align-items: start;
}

.calendar-panel, .sidebar-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  min-width: 0;
}
/* Панель запусков (Предшествующий/Текущие/Следующие) зафиксирована при
   прокрутке страницы - остаётся на экране, пока листается длинный
   календарь слева (см. align-items: start у .dashboard-grid выше). */
.sidebar-panel {
  position: sticky;
  top: 20px;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
}

.calendar-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}
.calendar-header h2 { min-width: 140px; text-align: center; font-size: 16px; text-transform: capitalize; }
.calendar-header-spacer { flex: 1; }

/* Клик по «Июль 2026» открывает попап быстрого перехода на любой месяц/год
   без пролистывания стрелками (см. cal-title-wrap ниже). */
.cal-title-wrap { position: relative; }
.cal-title-clickable {
  cursor: pointer;
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  transition: background .12s ease;
}
.cal-title-clickable:hover { background: var(--bg); }
.cal-month-picker {
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: 12px;
  z-index: 50;
  width: 240px;
}
.cal-month-picker-year-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.cal-month-picker-year-row span {
  font-size: 14px;
  font-weight: 700;
}
.cal-month-picker-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.cal-month-picker-btn {
  padding: 8px 4px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: var(--bg);
  color: var(--text);
  font-size: 12.5px;
  text-align: center;
  cursor: pointer;
  transition: background .12s ease, color .12s ease;
}
.cal-month-picker-btn:hover { background: var(--primary-soft); color: var(--primary); }
.cal-month-picker-btn.active {
  background: var(--primary);
  color: #fff;
  font-weight: 600;
}

/* Панель фильтров календаря дашборда (Module 2) - компактный тулбар из 3
   независимых мульти-select выпадашек прямо над сеткой календаря. Фильтрация
   применяется ЧИСТО на клиенте (см. applyCalendarFilters в app.js) - не
   пересобирает сетку и не ходит на бэкенд, а лишь скрывает/показывает уже
   отрисованные чипы постов и бейджи этапов через .hidden. */
.calendar-filters-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}
.calendar-filter-group { position: relative; }
.calendar-filter-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
}
.calendar-filter-btn:hover { border-color: var(--primary); }
.calendar-filter-group.open .calendar-filter-btn {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-soft);
}
.calendar-filter-btn-count {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--primary);
  min-width: 14px;
}
/* Стрелка-шеврон справа от текста кнопки - визуальный сигнал, что это
   выпадающий список (а не обычная кнопка-действие). Сам символ переключается
   JS'ом между ▾ (закрыто) и ▴ (открыто) при клике по кнопке (см. app.js) -
   текстовый глиф вместо CSS-поворота иконки, чтобы не зависеть от нюансов
   поддержки transform на конкретных элементах в разных браузерах/движках.
   Цвет дополнительно подчёркивает активное состояние. */
.calendar-filter-btn-arrow {
  flex-shrink: 0;
  color: var(--text-muted);
  font-size: 9px;
  line-height: 1;
  transition: color .15s ease;
}
.calendar-filter-group.open .calendar-filter-btn-arrow {
  color: var(--primary);
}
.calendar-filter-popover {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 50;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: 10px 12px;
  min-width: 200px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.calendar-filter-popover label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 400;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
}
.calendar-filter-popover label input[type="checkbox"] { width: auto; flex-shrink: 0; cursor: pointer; }
.calendar-filter-reset {
  align-self: flex-start;
  margin-top: 4px;
  padding: 0;
  border: none;
  background: none;
  color: var(--primary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.calendar-filter-reset:hover { text-decoration: underline; }

.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  padding: 0 2px;
  margin-bottom: 4px;
}
.calendar-weekdays span {
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  padding: 6px 0;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
  min-width: 0;
  width: 100%;
}

.calendar-day {
  min-width: 0;
  min-height: 92px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  background: var(--surface);
}
.calendar-day.other-month { background: #FBFBFC; opacity: 0.5; }
.calendar-day.today { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.calendar-day.cell-add-post { cursor: copy; }
.calendar-day.cell-add-post .day-num-clickable,
.calendar-day.cell-add-post .post-chip,
.calendar-day.cell-add-post .calendar-milestone-badge { cursor: pointer; }
.calendar-day.cell-add-post .post-chip[draggable="true"] { cursor: grab; }

/* Drag-and-Drop переноса постов между днями календаря. */
.post-chip[draggable="true"] { cursor: grab; }
.post-chip-dragging {
  opacity: 0.5;
  transform: scale(0.98);
}
.calendar-day.cell-drag-hover {
  border: 2px dotted var(--primary);
  background: var(--primary-soft);
}

/* Плавающая подсказка, следующая за курсором во время переноса поста -
   показывает название этапа, к которому привяжется пост при отпускании над
   текущей ячейкой (или что этап снимется, если ячейка вне этапа). */
.drag-move-hint {
  position: fixed;
  z-index: 10000;
  pointer-events: none;
  background: var(--text);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 6px;
  box-shadow: var(--shadow-md);
  white-space: nowrap;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.calendar-day-number {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 2px;
  min-width: 0;
}
.calendar-day.today .day-num { color: var(--primary); }
.calendar-day-number .day-weekday { display: none; }

.calendar-day-posts {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  overflow: hidden;
}

.post-chip {
  font-size: 10.5px;
  padding: 2px 5px;
  border-radius: 5px;
  min-width: 0;
  max-width: 100%;
  width: 100%;
  box-sizing: border-box;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  border: 1px solid transparent;
  /* Единый нейтральный серый фон для ВСЕХ карточек поста, независимо от
     статуса - статус больше не красит саму карточку (см. .post-chip-status-
     badge ниже), а фон/цвет текста больше не задаются инлайново из JS. */
  background: var(--card-neutral);
  color: var(--text);
}
.post-chip:hover { filter: brightness(0.96); }
/* Пост в основном календаре: маленькие пилюли групп каналов (Канал/Базы/
   Регистрации) над текстовым сниппетом - оператор видит с первого взгляда, в
   какие группы каналов уйдёт публикация, не открывая карточку поста. */
.post-chip.post-chip-detailed {
  display: flex;
  flex-direction: column;
  gap: 6px;
  white-space: normal;
}
.post-chip-badges {
  display: flex;
  gap: 3px;
  flex-wrap: wrap;
}
/* Пилюля группы каналов - тот же светло-фиолетовый акцент, что и у пилюли
   направления продукта под названием запуска в «Текущие запуски»
   (см. .launch-card-direction) - небольшое скругление, без обводки. */
.post-chip-group-badge {
  font-size: 8.5px;
  font-weight: 600;
  line-height: 1.4;
  padding: 0 4px;
  border-radius: 6px;
  background: var(--primary-soft);
  color: var(--primary);
  white-space: nowrap;
}
/* Тематическая окраска бейджа группы «Каналы»/«Базы» по продуктовой
   категории поста (см. groupBadgeThemeClass в app.js): зелёный - только
   «Похудение», розовый - только «Фейслифтинг». Без модификатора (класс не
   добавлен) бейдж остаётся фиолетовым по умолчанию - это и есть состояние
   «смешанного» поста (обе темы одновременно) и группы «Регистрации»
   (тематического деления не имеет вовсе). */
.post-chip-group-badge.theme-weight_loss {
  background: #DCFCE7;
  color: #16A34A;
}
.post-chip-group-badge.theme-facelift {
  background: #FCE7F3;
  color: #DB2777;
}
/* Яркая насыщенная плашка статуса поста (белый текст на цветном фоне) -
   рядом с пилюлями групп каналов в той же строке (см. STATUS_COLORS в
   app.js). Небольшое скругление - то же, что и у пилюль групп выше. */
.post-chip-status-badge {
  font-size: 8.5px;
  font-weight: 700;
  line-height: 1.4;
  padding: 0 4px;
  border-radius: 6px;
  color: #FFFFFF;
  white-space: nowrap;
}
.post-chip-text {
  min-width: 0;
  white-space: normal;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Маленькое инлайн-превью прикреплённых фото - прямо под текстом сниппета,
   тот же приём, что и в карточках матрицы (см. .matrix-post-card-media). */
.post-chip-media {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
}
.post-chip-thumb {
  width: 22px;
  height: 22px;
  border-radius: 4px;
  object-fit: cover;
  border: 1px solid var(--border);
  cursor: zoom-in;
  flex-shrink: 0;
}
.post-chip.deadline-soon {
  background: var(--deadline-soft-red) !important;
  border-color: #F2B3AC;
}
/* Этап запуска внутри общей хронологической ленты дня - тот же формфактор,
   что и у обычной плашки поста (ширина/радиус), но жирным шрифтом и БЕЗ
   сплошной заливки: прозрачный фон, обычный чёрный текст (см. .post-chip) и
   маленькая цветная точка в фирменном цвете запуска перед названием - чтобы
   этап читался как лёгкий заголовок-разделитель, а не как ещё один тяжёлый
   цветной блок поста. */
.calendar-milestone-badge {
  font-weight: 700;
  background: transparent !important;
  border-color: transparent;
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: normal;
}
.calendar-milestone-badge:hover { filter: none; opacity: 0.8; }
.calendar-milestone-dot {
  width: 6px;
  height: 6px;
  min-width: 6px;
  flex-shrink: 0;
  border-radius: 50%;
  display: inline-block;
}
.calendar-milestone-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Sidebar / active launches ---------- */

.sidebar-panel h2 { margin-bottom: 14px; font-size: 16px; }

#preceding-launch-slot:not(:empty) { margin-bottom: 16px; }
#current-launch-slot { margin-bottom: 16px; }

.launch-mini-section-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}

.mini-launch-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #FCFCFD;
  margin-bottom: 8px;
  cursor: pointer;
  transition: box-shadow .15s ease;
}
.mini-launch-item:hover { box-shadow: var(--shadow-md); }
.mini-launch-item:last-child { margin-bottom: 0; }
.mini-launch-title {
  display: flex;
  align-items: center;
  font-size: 13px;
  font-weight: 600;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.next-launches-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px;
  margin-bottom: 16px;
}
.next-launches-box h3 {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 10px;
}
.next-launches-box .mini-launch-item { background: var(--surface); }

.launch-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  background: #FCFCFD;
  cursor: pointer;
  transition: box-shadow .15s ease;
}
.launch-card:hover { box-shadow: var(--shadow-md); }
.launch-card-title { display: flex; align-items: center; font-weight: 700; font-size: 14px; margin-bottom: 2px; }
.launch-card-direction {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  color: var(--primary);
  background: var(--primary-soft);
  border-radius: 6px;
  padding: 2px 8px;
  margin-bottom: 8px;
}
.launch-card-dates { font-size: 12px; color: var(--text-muted); margin-bottom: 10px; }

.progress-track {
  height: 6px;
  border-radius: 3px;
  background: var(--border);
  overflow: hidden;
  margin-bottom: 10px;
}
.progress-fill { height: 100%; background: var(--primary); border-radius: 3px; }

.launch-card-milestones { font-size: 12px; }
.launch-card-milestones-title { font-weight: 600; color: var(--text-muted); margin-bottom: 4px; }
.milestone-item { display: flex; justify-content: space-between; gap: 8px; padding: 3px 0; }
.milestone-item-date { color: var(--text-muted); white-space: nowrap; }

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 32px 16px;
  font-size: 13px;
}

/* ---------- Archive ---------- */

.archive-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.archive-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  cursor: pointer;
  transition: box-shadow .15s ease, transform .15s ease;
}
.archive-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.archive-card-title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.archive-card-title-row .archive-card-title { margin-bottom: 0; }
.archive-card-title { font-weight: 700; margin-bottom: 4px; }
.archive-card-dates { font-size: 12px; color: var(--text-muted); margin-bottom: 10px; }
.archive-card-stats { display: flex; gap: 16px; font-size: 12px; color: var(--text-muted); margin-bottom: 10px; }

/* ---------- Content manager table ---------- */

.filters-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.filters-bar select { width: auto; min-width: 160px; }
.filters-bar input { width: 220px; }
.filter-date-group {
  display: flex;
  align-items: center;
  gap: 4px;
}
.filter-date-group input#filter-date { width: 160px; }
.filter-date-clear-btn {
  width: 30px;
  height: 30px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  line-height: 1;
  flex-shrink: 0;
}

.load-more-row {
  display: flex;
  justify-content: center;
  margin-top: 18px;
}

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.content-table { width: 100%; border-collapse: collapse; }
.content-table th {
  text-align: left;
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: #FBFBFC;
}
.content-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  vertical-align: top;
}
.content-table tbody tr:last-child td { border-bottom: none; }
.content-table tbody tr { cursor: pointer; }
.content-table tbody tr:hover { background: #FAFAFC; }
.content-table tbody tr.deadline-soon { background: var(--deadline-soft-red); }
.content-table-snippet {
  max-width: 340px;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  color: var(--text);
  line-height: 1.5;
}

.content-table-images {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.content-table-thumb {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  cursor: zoom-in;
  transition: transform .12s ease;
}
.content-table-thumb:hover { transform: scale(1.08); }
.content-table-no-image {
  color: var(--text-muted);
}
.content-table-no-milestone {
  color: var(--text-muted);
}
.content-table-id {
  color: var(--text-muted);
  font-family: 'Courier New', monospace;
  font-size: 12px;
}
.content-table tbody tr.deadline-soon:hover { background: #F8D8D4; }

/* Менеджер контента: фиксированная раскладка колонок (см. <colgroup> в
   разметке) - «Текст» получает большую часть ширины, остальные метаданные
   сжаты до комфортного минимума. Не затрагивает другие таблицы с классом
   .content-table (например, таблицу настроек каналов). */
.content-manager-table { table-layout: fixed; max-width: none; }
.content-manager-table .content-table-snippet { max-width: none; }

.channel-chip {
  display: inline-block;
  max-width: 100%;
  box-sizing: border-box;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 6px;
  margin: 1px 3px 1px 0;
  white-space: normal;
  overflow-wrap: break-word;
}

.post-type-badge-pink {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: #FCE7F3;
  color: #DB2777;
  white-space: nowrap;
  margin-right: 4px;
}

.status-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 12px;
  border-radius: 999px;
  white-space: nowrap;
}
/* ---------- Settings tab ---------- */

.settings-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
}
.settings-block h3 { font-size: 16px; margin-bottom: 8px; }
.settings-block-spaced { margin-top: 20px; }
.settings-hint {
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.6;
  margin-bottom: 18px;
  max-width: 720px;
}
.settings-hint code {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 12px;
  color: var(--text);
}
.settings-table td { vertical-align: middle; }
.settings-utm-source, .settings-utm-medium {
  min-width: 140px;
  font-size: 13px;
}
.settings-actions {
  margin-top: 18px;
  display: flex;
  justify-content: flex-end;
}

/* ---------- Аналитика ---------- */

.analytics-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}
.analytics-subnav {
  display: flex;
  gap: 4px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 4px;
}
.analytics-subtab-btn {
  background: transparent;
  color: var(--text-muted);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 13px;
}
.analytics-subtab-btn:hover { background: var(--surface); }
.analytics-subtab-btn.active { background: var(--surface); color: var(--primary); box-shadow: 0 1px 2px rgba(0,0,0,0.06); }
.analytics-subtab-panel.hidden { display: none; }
.analytics-history-filter { max-width: 280px; }

.analytics-summary-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.analytics-summary-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
}
.analytics-summary-card-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.analytics-summary-card-value {
  font-size: 20px;
  font-weight: 700;
}

.analytics-overview-delete-actions {
  display: flex;
  gap: 8px;
}

.analytics-report-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  cursor: pointer;
}
.analytics-report-row:hover { background: var(--bg); }
.analytics-report-row-main { display: flex; flex-direction: column; gap: 2px; }
.analytics-report-row-title { font-weight: 600; font-size: 14px; }
.analytics-report-row-meta { font-size: 12px; color: var(--text-muted); }
.analytics-report-row-stats { display: flex; gap: 18px; align-items: center; }
.analytics-report-row-stat { text-align: right; font-size: 13px; }
.analytics-report-row-stat strong { display: block; font-size: 15px; }
.analytics-report-row-delete { color: var(--danger); }

.analytics-dynamics-bars {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 16px 0 24px;
}
.analytics-dynamics-bar-row {
  display: grid;
  grid-template-columns: 220px 1fr 110px;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}
.analytics-dynamics-bar-label { color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.analytics-dynamics-bar-track {
  background: var(--bg);
  border-radius: 4px;
  height: 14px;
  overflow: hidden;
}
.analytics-dynamics-bar-fill {
  background: var(--primary);
  height: 100%;
  border-radius: 4px;
}
.analytics-dynamics-bar-value { text-align: right; font-weight: 600; }

.analytics-top-post-row td { vertical-align: top; }
.analytics-top-post-preview {
  max-width: 420px;
  color: var(--text-muted);
  font-size: 13px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Сетка виджетов "По источникам" (donut / бары вовлечённости / бары
   выручки / таблица) - раньше все графики шли одним стеком друг под
   другом через обычные margin, из-за чего визуально "сливались в кашу".
   Теперь каждый график - отдельная карточка (см. .analytics-widget) в
   CSS grid с auto-fit колонками: на широком экране несколько виджетов
   стоят в ряд, на узком - складываются в один столбец сами по себе, без
   media-query. Таблица и полный UTM-отчёт занимают всю ширину
   (.analytics-widget-full), т.к. это не диаграмма, а плотные данные. */
.analytics-widgets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin: 16px 0 24px;
  align-items: stretch;
}
.analytics-widget {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  min-width: 0;
}
.analytics-widget-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--text-muted);
  margin-bottom: 14px;
}
.analytics-widget-full { grid-column: 1 / -1; }
.analytics-widget-full .content-table { margin: 0; }

.analytics-donut-wrap {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}
.analytics-source-legend {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.analytics-source-legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}
.analytics-source-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.analytics-source-legend-label { min-width: 70px; color: var(--text-muted); }
.analytics-source-legend-value { font-weight: 600; }
.analytics-source-legend-pct { color: var(--text-muted); font-weight: 400; }

.analytics-source-bars {
  flex: 1;
  min-width: 260px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.analytics-source-bar-row {
  display: grid;
  grid-template-columns: 90px 1fr 90px;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}
.analytics-source-bar-label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
}
.analytics-source-bar-track {
  background: var(--bg);
  border-radius: 4px;
  height: 14px;
  overflow: hidden;
}
.analytics-source-bar-fill { height: 100%; border-radius: 4px; }
.analytics-source-bar-value { text-align: right; font-weight: 600; }

/* Воронка запуска (см. buildAnalyticsFunnelHtml) - каждая стадия своим
   цветом из ANALYTICS_FUNNEL_COLORS, ширина бара пропорциональна значению
   относительно первой (самой широкой) стадии. */
.analytics-funnel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 16px 0 24px;
}
.analytics-funnel-row {
  display: grid;
  grid-template-columns: 160px 1fr 130px;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}
.analytics-funnel-label { color: var(--text-muted); }
.analytics-funnel-track {
  background: var(--bg);
  border-radius: 4px;
  height: 20px;
  overflow: hidden;
}
.analytics-funnel-fill { height: 100%; border-radius: 4px; transition: width 0.2s ease; }
.analytics-funnel-value { text-align: right; font-weight: 600; }
.analytics-funnel-pct { color: var(--text-muted); font-weight: 400; }

.analytics-utm-details {
  margin-top: 8px;
}
.analytics-utm-details summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  color: var(--primary);
  padding: 8px 0;
}
.analytics-utm-details[open] summary { margin-bottom: 10px; }
.analytics-utm-table-scroll { overflow-x: auto; }
.analytics-utm-table-scroll .content-table { white-space: nowrap; }

/* ---------- Фотобанк ---------- */

/* Раздел "Инструкция" - боковое меню-навигация слева (sticky) + карточки
   с текстом справа, по аналогии с .media-layout (папки/контент), но
   вместо переключения данных - плавная прокрутка к якорям (см.
   renderInstructions в app.js) и подсветка активного пункта меню через
   IntersectionObserver. */
.instructions-layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}
.instructions-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 10px;
  position: sticky;
  top: 20px;
}
.instructions-nav-link {
  display: block;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
}
.instructions-nav-link:hover { background: var(--bg); color: var(--text); }
.instructions-nav-link.active { background: var(--primary-soft); color: var(--primary); }

.instructions-content {
  display: flex;
  flex-direction: column;
  gap: 32px;
  min-width: 0;
}
.instructions-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  scroll-margin-top: 20px;
}
.instructions-section h3 { font-size: 18px; margin-bottom: 12px; }
.instructions-section p { color: var(--text); line-height: 1.6; margin-bottom: 10px; }
.instructions-section ul { margin: 0 0 10px 20px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.instructions-section li { line-height: 1.6; }
.instructions-screenshot {
  margin-top: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.instructions-screenshot img {
  display: block;
  width: 100%;
  height: auto;
}

.media-layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.media-folders-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  /* Зафиксировано при прокрутке страницы - список папок остаётся на
     экране, пока справа листается длинная сетка изображений (см.
     align-items: start у .media-layout выше, без него sticky растянулся
     бы на всю высоту грид-строки и не имел смысла). Собственный скролл
     (max-height + overflow-y), если папок наберётся больше, чем влезает
     в высоту экрана, - панель не должна вылезать за пределы viewport. */
  position: sticky;
  top: 20px;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
}

.media-folder-create {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}

/* Тулбар фильтра типа файла + сортировки - прямо над списком папок (ТЗ Task
   4: Filter & Sort Utilities Header), общий класс для Фотобанка и пикера
   «Галерея» в модалке поста (там только фильтр типа, без сортировки). */
.media-filter-toolbar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}
.media-filter-toolbar select { width: 100%; }

.folders-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Утилитарные моно-иконки (папка/скачивание) - залиты через CSS mask, а не
   вставлены как <img src="...svg">: у img-тега нет доступа к цвету текста
   окружения (currentColor внутри SVG, загруженного через src, не наследует
   CSS страницы и всегда рендерится как чёрный), а эти иконки должны менять
   цвет вместе с текстом (белые на тёмной кнопке скачивания в слоте фото,
   акцентно-фиолетовые у активной папки и т.д.) - см. .folder-item.active
   ниже и .image-slot-download-btn. mask-image + background: currentColor
   решает это одним файлом иконки на все контексты, без отдельных цветовых
   вариантов той же картинки. */
.icon-mask {
  display: inline-block;
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  background-color: currentColor;
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  vertical-align: middle;
}
.icon-folder {
  -webkit-mask-image: url('/icons/folder-icon.svg');
  mask-image: url('/icons/folder-icon.svg');
}
.icon-download {
  -webkit-mask-image: url('/icons/download-icon.svg');
  mask-image: url('/icons/download-icon.svg');
}

.folder-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.folder-item-name {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.folder-item:hover { background: var(--bg); }
.folder-item.active { background: var(--primary-soft); color: var(--primary); }
.folder-item-count {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg);
  border-radius: 999px;
  padding: 2px 8px;
}
.folder-item.active .folder-item-count { background: #fff; color: var(--primary); }
.folder-item.drag-over {
  background: var(--primary-soft);
  outline: 2px dashed var(--primary);
  outline-offset: -2px;
}

.media-image-card[draggable="true"] { cursor: grab; }
.media-image-card[draggable="true"]:active { cursor: grabbing; }

.media-main-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  min-height: 320px;
}

.media-folder-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.media-folder-header h3 { font-size: 16px; }

.media-upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-md);
  padding: 24px;
  text-align: center;
  cursor: pointer;
  margin-bottom: 20px;
  transition: border-color .15s ease, background .15s ease;
}
.media-upload-zone:hover, .media-upload-zone.dragover {
  border-color: var(--primary);
  background: var(--primary-soft);
}
.media-upload-hint {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
}
.media-upload-hint span { font-size: 12px; }

.media-video-upload-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin: 12px 0;
}
.media-video-upload-hint {
  font-size: 12px;
  color: var(--text-muted);
}

/* Полоса прогресса загрузки видео (см. apiUploadWithProgress в app.js) -
   общий компонент для Фотобанка и пикера «Галерея» в модалке поста. */
.upload-progress-bar {
  position: relative;
  width: 100%;
  height: 20px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-top: 8px;
}
.upload-progress-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--primary);
  transition: width .15s ease;
}
.upload-progress-bar-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--text);
  text-shadow: 0 0 3px var(--surface), 0 0 3px var(--surface);
}

.media-images-grid {
  display: grid;
  /* 210px (было 150px) - при 150px карточка слишком узкая, чтобы вместить
     в один ряд действий выпадающий список папки + «Скачать» (иконка+текст)
     + «Удалить» без обрезания кнопок (особенно после добавления иконки
     скачивания рядом с текстом - см. .media-image-actions ниже). Меньше
     фото в ряду, зато кнопки читаются полностью. */
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 14px;
}

.media-image-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--surface);
  display: flex;
  flex-direction: column;
}
.media-image-thumb {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  background: var(--bg);
  display: block;
  cursor: pointer;
}
.media-image-info {
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.media-image-name {
  font-size: 11px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.media-image-actions {
  display: flex;
  gap: 6px;
}
.media-image-actions .btn-ghost, .media-image-actions .btn-danger {
  flex: 1;
  padding: 6px 8px;
  font-size: 11px;
  text-align: center;
}
.media-image-actions a.btn-ghost {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}
.media-image-actions a.btn-ghost .icon-mask { width: 12px; height: 12px; }
.media-image-actions button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.media-move-select {
  flex: 1;
  width: auto;
  min-width: 0;
  padding: 6px 4px;
  font-size: 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  cursor: pointer;
}

/* ---------- Слоты фото в модалке поста ---------- */

.post-images-slots {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.image-slot {
  width: 84px;
  height: 84px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  overflow: hidden;
  position: relative;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity .15s ease, box-shadow .15s ease;
}
/* Drag-and-Drop сортировка прикреплённых фото (см. renderPostImageSlots в
   app.js): перетаскиваемая миниатюра полупрозрачная, а текущая цель наведения
   подсвечивается акцентной рамкой - тот же визуальный язык, что и у
   drag-hover ячеек матрицы контента (.matrix-cell-drag-hover). */
.image-slot.filled[draggable="true"] { cursor: grab; }
.image-slot.filled.dragging { opacity: 0.4; }
.image-slot.filled.drag-over {
  box-shadow: 0 0 0 3px var(--primary);
}

.image-slot.add-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  color: var(--text-muted);
  background: var(--bg);
  border: 2px dashed var(--border);
}
.image-slot.add-slot:hover { border-color: var(--primary); color: var(--primary); }

.image-slot.filled img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  cursor: pointer;
}
.image-slot.filled .image-slot-remove {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(20, 20, 30, 0.65);
  color: #fff;
  font-size: 13px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity .15s ease;
}
.image-slot.filled:hover .image-slot-remove { opacity: 1; }

.image-slot.filled .image-slot-actions {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 2px 4px;
  background: rgba(20, 20, 30, 0.65);
  opacity: 0;
  transition: opacity .15s ease;
}
.image-slot.filled:hover .image-slot-actions { opacity: 1; }

.image-slot-move-select {
  width: auto;
  max-width: 28px;
  height: 20px;
  padding: 0;
  font-size: 11px;
  border: none;
  background: transparent;
  color: #fff;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  text-align: center;
}
.image-slot-move-select option { color: var(--text); }

.image-slot-download-btn {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 12px;
  text-decoration: none;
  border-radius: 4px;
  flex-shrink: 0;
}
.image-slot-download-btn:hover { background: rgba(255, 255, 255, 0.2); }

/* ---------- Overlay-галерея выбора фото ---------- */

.gallery-layout {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  gap: 16px;
  min-height: 360px;
}
.gallery-folders { border-right: 1px solid var(--border); padding-right: 16px; }
.gallery-main { min-width: 0; }

.gallery-upload-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
#gallery-upload-folder-select {
  width: auto;
  max-width: 220px;
  flex-shrink: 0;
}
.gallery-upload-status {
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
}

/* Ровно 4 фото в ряд на десктопе (модалка теперь такой же ширины, что и
   редактирование поста, - см. .modal-gallery-picker) вместо "плавающего"
   auto-fill из общего .media-images-grid (используется в полноэкранном
   Фотобанке, где колонок должно быть заметно больше). Мобильная адаптивность
   (max-width: 640px) переопределяет обратно на auto-fill ниже. */
.gallery-images-grid {
  grid-template-columns: repeat(4, 1fr);
}
.gallery-images-grid .media-image-card {
  cursor: pointer;
  transition: box-shadow .15s ease;
}
.gallery-images-grid .media-image-card:hover { box-shadow: var(--shadow-md); }
.gallery-images-grid .media-image-card.selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary);
}
/* Уже прикреплённое к посту фото - показывается с галочкой, но клик по нему
   в галерее ничего не делает (открепление - только через × на миниатюре в
   самой модалке поста, см. toggleGalleryImage), поэтому курсор и лёгкое
   затемнение сигнализируют "недоступно для повторного действия здесь". */
.gallery-images-grid .media-image-card.locked {
  cursor: default;
  opacity: 0.7;
}
.gallery-images-grid .media-image-card.locked:hover { box-shadow: 0 0 0 2px var(--primary); }
.media-image-thumb-wrap { position: relative; }

/* Play-иконка поверх превью видео (ТЗ Task 4: Visual Grid Indicators) -
   центрированный полупрозрачный кружок с треугольником, общий для Фотобанка,
   пикера «Галерея» и слотов прикреплённых файлов в модалке поста. Не мешает
   клику - клик по всей карточке/слоту уже открывает лайтбокс/тоггл выбора. */
.video-play-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(20, 20, 28, 0.55);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  padding-left: 3px;
  pointer-events: none;
}
.image-slot .video-play-overlay { width: 26px; height: 26px; font-size: 11px; padding-left: 2px; }

/* Заглушка превью для видео, у которых не удалось извлечь кадр (ffmpeg не
   справился - см. saveProcessedVideo на бэкенде) - те же габариты, что и у
   обычного img-превью, чтобы карточка/слот не "прыгали" в вёрстке. */
.media-video-fallback-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  background: var(--bg);
}
.image-slot .media-video-fallback-icon { font-size: 22px; }

.image-slot-thumb-wrap { position: relative; width: 100%; height: 100%; }

/* Мелкие превью видео в календаре/матрице/Менеджере контента (просто <img>
   без play-оверлея, см. app.js) - лёгкая рамка, чтобы отличать кадр видео от
   обычного фото хотя бы по контуру. */
.is-video-thumb { box-shadow: inset 0 0 0 2px rgba(108, 92, 231, 0.5); }
/* Бейдж «Использовано: X раз» - нижний левый угол миниатюры, полупрозрачная
   тёмная подложка + белый текст, чтобы читаться на любом фото и не
   перекрывать сам снимок (см. ТЗ Task 3: Gallery & Photobank Media Usage
   Labels). Общий для Фотобанка и пикера «Галерея» в модалке поста. */
.media-usage-badge {
  position: absolute;
  left: 6px;
  bottom: 6px;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(20, 20, 28, 0.72);
  color: #FFFFFF;
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
}
.gallery-images-grid .selected-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Яркие насыщенные пилюли статуса (белый текст на цветном фоне) - тот же
   акцентный принцип, что и у .post-chip-status-badge/.matrix-post-card-
   status-badge в календаре/матрице, применён здесь и к инлайн-селекту
   статуса в Менеджере контента для единообразия по всему приложению. */
.status-Черновик { background: #64748B; color: #FFFFFF; }
.status-На-утверждении { background: #EA580C; color: #FFFFFF; }
.status-Готово { background: #2563EB; color: #FFFFFF; }
.status-Опубликовано { background: #16A34A; color: #FFFFFF; }

/* ---------- Modals ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(30, 30, 40, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 24px;
}

.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}
.modal-large { max-width: 720px; }

/* Анимация ожидания, пока ИИ генерирует посты или занимается анализом -
   используется во всех 3 местах, где идёт обращение к OpenRouter: шаг 1
   формы "Написать пост с ИИ" (#ai-wizard-ideas-loading), финальный
   результат "с нуля"/"улучшить"/из формы (#ai-result-loading) и батч-
   генерация постов на весь запуск (#launch-ai-generate-loading). Вращающееся
   кольцо-градиент вокруг пульсирующей иконки волшебной палочки (тот же
   символ, что и на самих ИИ-кнопках) + переливающийся текст + бегущие точки. */
.ai-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 48px 20px;
  text-align: center;
}

.ai-loading-spinner {
  position: relative;
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.ai-loading-spinner::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: conic-gradient(from 0deg, transparent 0%, var(--primary-soft) 45%, var(--primary) 100%);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 3px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 3px));
  animation: ai-loading-rotate 1.1s linear infinite;
}
.ai-loading-spinner::after {
  content: '';
  position: absolute;
  inset: 10px;
  border-radius: 50%;
  border: 1px dashed var(--primary-soft);
  animation: ai-loading-rotate 3s linear infinite reverse;
}
.ai-loading-spinner-icon {
  position: relative;
  color: var(--primary);
  filter: drop-shadow(0 0 6px var(--primary-soft));
  animation: ai-loading-pulse 1.6s ease-in-out infinite;
}

@keyframes ai-loading-rotate {
  to { transform: rotate(360deg); }
}
@keyframes ai-loading-pulse {
  0%, 100% { transform: scale(0.85); opacity: 0.75; }
  50% { transform: scale(1.05); opacity: 1; }
}

.ai-loading-text {
  font-size: 14px;
  font-weight: 500;
  max-width: 380px;
  background: linear-gradient(90deg, var(--text-muted) 0%, var(--primary) 50%, var(--text-muted) 100%);
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  animation: ai-loading-shimmer 2.2s linear infinite;
}
@keyframes ai-loading-shimmer {
  to { background-position: -200% center; }
}

.ai-loading-dots {
  display: flex;
  gap: 6px;
}
.ai-loading-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--primary);
  animation: ai-loading-bounce 1.2s ease-in-out infinite;
}
.ai-loading-dots span:nth-child(2) { animation-delay: 0.15s; }
.ai-loading-dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes ai-loading-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40% { transform: translateY(-6px); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .ai-loading-spinner::before,
  .ai-loading-spinner::after,
  .ai-loading-spinner-icon,
  .ai-loading-text,
  .ai-loading-dots span {
    animation: none;
  }
}

/* Пошаговая форма "Написать пост с ИИ" (#ai-wizard-modal) - шаг 1: список
   выбираемых идей от ИИ (карточка = <label> с радио-кнопкой внутри, клик в
   любом месте карточки выбирает идею). */
.ai-wizard-ideas-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.ai-wizard-idea-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.ai-wizard-idea-card:hover { border-color: var(--primary); }
.ai-wizard-idea-card-selected {
  border-color: var(--primary);
  background: var(--primary-soft);
}
.ai-wizard-idea-card input[type="radio"] {
  width: auto;
  margin-top: 3px;
  padding: 0;
  border: none;
  accent-color: var(--primary);
  flex-shrink: 0;
}
.ai-wizard-idea-card-body { flex: 1; min-width: 0; }
.ai-wizard-idea-title {
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}
.ai-wizard-idea-desc {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.4;
}
.ai-wizard-selected-idea-row { margin-bottom: 16px; }
.ai-wizard-selected-idea {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--primary-soft);
}
/* Та же ширина, что и у модалки редактирования поста (.modal-post-edit) -
   пикер фото из фотобанка открывается ПОВЕРХ неё же (см. стек модалок), и
   ожидаемо занимает столько же места на экране, чтобы сетка миниатюр могла
   показать 4 фото в ряд на десктопе (см. .gallery-images-grid). */
.modal-gallery-picker {
  max-width: 1100px;
  width: 90vw;
}

/* Лайтбокс просмотра изображения - шире обычной модалки и без внутренних
   отступов у тела, чтобы фото могло занять максимум доступного места. */
.image-lightbox-modal {
  max-width: min(90vw, 1100px);
}
.image-lightbox-body {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: #000;
  overflow: hidden;
}
/* max-height раньше был 80vh - доля ОТ ВСЕГО ЭКРАНА, без учёта того, что
   .modal и так ограничена max-height: 90vh И теряет ещё часть этой высоты
   на шапку с заголовком и футер с кнопками. Из-за этого портретное/крупное
   видео (например 720x1280) рендерилось в исходном разрешении и вылезало
   за пределы модалки, а нативные controls (плей/пауза/громкость/
   полноэкранный режим) внизу плеера оказывались за пределами видимой
   области - именно на это жаловался пользователь (аналогичная, хоть и
   менее заметная на глаз, проблема была и у фото). calc(90vh - 150px) - те
   же 90vh, что и у .modal, минус фиксированный (не зависящий от высоты
   экрана) отступ на шапку+футер (их суммарная высота из padding/border у
   .modal-header/.modal-footer примерно постоянна) - так max-height
   гарантированно не превышает реально остающееся внутри модалки место при
   любой высоте экрана. Процентный max-height (100% от .image-lightbox-body)
   здесь не подходит - плеер является flex-айтемом внутри самой
   .image-lightbox-body (display:flex для центрирования), а процентная
   высота на flex-айтеме ненадёжно резолвится через двойную вложенность
   flex-контекстов (снаружи колонка .modal, внутри ряд .image-lightbox-body)
   и на практике не срабатывала вовсе. */
.image-lightbox-body img,
.image-lightbox-body video {
  display: block;
  max-width: 100%;
  max-height: calc(90vh - 150px);
  width: auto;
  height: auto;
  object-fit: contain;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 17px; }

.modal-close {
  background: transparent;
  font-size: 22px;
  line-height: 1;
  color: var(--text-muted);
  padding: 4px 8px;
  border-radius: 6px;
}
.modal-close:hover { background: var(--bg); color: var(--text); }

.modal-body {
  padding: 20px 24px;
  overflow-y: auto;
  flex: 1;
}

/* ---------- Модалка поста: двухколоночная рабочая область ---------- */
/* Шире обычной большой модалки - место под колонку редактора (слева,
   мессенджер-подобная лента) и колонку мета-параметров (справа) рядом,
   без тесноты. */
.modal-post-edit {
  max-width: 1100px;
  width: 90vw;
}

/* Тело модалки поста не скроллится целиком само по себе - скроллятся
   независимо ЛЕВАЯ (сам редактор текста) и ПРАВАЯ (мета-параметры) колонки,
   каждая своим единственным скроллбаром, без вложенной двойной прокрутки. */
.post-modal-body {
  display: flex;
  overflow: hidden;
  padding: 0;
  min-height: 0;
}
.post-modal-grid {
  display: grid;
  grid-template-columns: minmax(320px, 46%) 1fr;
  width: 100%;
  min-height: 0;
}

.post-modal-column-text {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 20px;
  background: #F2F3F6;
  border-right: 1px solid var(--border);
}
.post-modal-column-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.post-modal-column-text .post-body-toolbar { flex-shrink: 0; }

/* Сам редактор откалиброван под ширину мессенджер-ленты (Telegram/VK) и
   растягивается на всю доступную высоту колонки - длинный текст читается
   без неудобной вложенной прокрутки внутри и так уже скроллящейся модалки. */
.post-modal-column-text .post-body-editor {
  flex: 1;
  min-height: 0;
  max-height: none;
  width: 100%;
  max-width: 460px;
  margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
}

.post-modal-column-meta {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 20px 24px;
  overflow-y: auto;
}
.post-modal-column-meta .form-row:last-child { margin-bottom: 0; }

/* ---------- Матрица контента (просмотр запуска / просмотр этапа) ---------- */
/* Шире всех остальных модалок - под таблицей матрицы может быть много строк
   (этапов запуска или дней этапа) x 3 колонки-столпа сразу. */
.modal-matrix { max-width: min(96vw, 1400px); width: 96vw; }

.matrix-breadcrumbs {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.matrix-breadcrumb-link {
  color: var(--primary);
  cursor: pointer;
  text-decoration: none;
}
.matrix-breadcrumb-link:hover { text-decoration: underline; }
.matrix-breadcrumb-sep { margin: 0 6px; }

.launch-matrix-layout {
  display: flex;
  gap: 24px;
  align-items: flex-start;
}
.launch-matrix-side {
  flex: 0 0 28%;
  max-width: 340px;
  min-width: 230px;
}
.launch-matrix-main {
  flex: 1;
  min-width: 0;
}

/* max-height + overflow-y: auto ЯВНО обязательны для того, чтобы sticky
   заголовок таблицы (.matrix-table th) вообще мог сработать: overflow-x:
   auto САМ ПО СЕБЕ заставляет браузер вычислить overflow-y тоже как auto
   (нельзя сочетать overflow-x:auto с overflow-y:visible - спецификация
   "продвигает" visible до auto), из-за чего .matrix-table-wrap и так уже
   становится "ближайшим скроллящимся предком" для sticky-позиционирования
   потомков - но без ЯВНО заданной ограниченной высоты его собственный
   scrollHeight всегда равен clientHeight (внутри нечему скроллиться: вся
   реальная прокрутка происходит на .modal-body СНАРУЖИ), поэтому sticky
   привязывался к контейнеру, который сам никогда не скроллится, и
   визуально не прилипал вообще. Ограничение высоты делает эту обёртку
   ДЕЙСТВИТЕЛЬНО скроллящейся сама по себе - и sticky начинает работать. */
.matrix-table-wrap {
  overflow-x: auto;
  overflow-y: auto;
  max-height: 65vh;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.matrix-table {
  width: 100%;
  min-width: 640px;
  border-collapse: collapse;
  table-layout: fixed;
}
.matrix-table th {
  background: var(--bg);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 5;
}
.matrix-table th:first-child, .matrix-table td:first-child {
  width: 140px;
}
.matrix-table td {
  border-bottom: 1px solid var(--border);
  border-left: 1px solid var(--border);
  padding: 8px;
  vertical-align: top;
}
.matrix-table tr:last-child td { border-bottom: none; }
.matrix-row-header {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  background: var(--bg);
}
.matrix-row-date {
  display: block;
  font-size: 11px;
  font-weight: 400;
  color: var(--text-muted);
  margin-top: 2px;
}
/* Тег активного этапа под датой строки матрицы запуска - при пересечении
   нескольких этапов по датам под одной датой выводится сразу несколько
   таких тегов, друг под другом (см. Multi-Stage Multiplexing в
   renderLaunchMatrix). Акцентный фиолетовый - тот же язык, что и у пилюль
   групп каналов (.post-chip-group-badge). */
.matrix-row-stage-tag {
  display: block;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--primary);
  background: var(--primary-soft);
  border-radius: 6px;
  padding: 1px 6px;
  margin-top: 4px;
  white-space: nowrap;
}
.matrix-cell {
  min-height: 54px;
  min-width: 160px;
  transition: background .12s ease;
}
.matrix-cell.matrix-cell-drag-hover { background: var(--primary-soft); }

.matrix-post-card {
  border-radius: 8px;
  padding: 5px 7px;
  margin-bottom: 5px;
  cursor: pointer;
  border: 1px solid transparent;
  display: flex;
  flex-direction: column;
  gap: 7px;
  /* Единый нейтральный серый фон для всех карточек матрицы, независимо от
     статуса поста - см. .matrix-post-card-status-badge ниже. */
  background: var(--card-neutral);
  color: var(--text);
}
.matrix-post-card:last-child { margin-bottom: 0; }
.matrix-post-card:hover { filter: brightness(0.97); }
/* Яркая насыщенная плашка статуса поста - строго под текстом/медиа,
   небольшое скругление (см. .post-chip-status-badge - тот же принцип). */
.matrix-post-card-status-badge {
  align-self: flex-start;
  font-size: 8.5px;
  font-weight: 700;
  line-height: 1.4;
  padding: 1px 6px;
  border-radius: 6px;
  color: #FFFFFF;
  white-space: nowrap;
}
.matrix-post-card-text {
  font-size: 10.5px;
  white-space: normal;
  display: -webkit-box;
  -webkit-line-clamp: 6;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Инлайн-превью прикреплённых фото - компактная сетка миниатюр прямо под
   текстом карточки, без подписей и элементов управления (только просмотр
   в лайтбоксе по клику - см. buildMatrixPostCardEl). */
.matrix-post-card-media {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.matrix-post-card-thumb {
  width: 32px;
  height: 32px;
  border-radius: 4px;
  object-fit: cover;
  border: 1px solid var(--border);
  cursor: zoom-in;
  flex-shrink: 0;
}
.matrix-cell-empty-hint {
  font-size: 11px;
  color: var(--text-muted);
  opacity: 0.5;
  padding: 4px 2px;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
}
.modal-footer-right { display: flex; gap: 10px; margin-left: auto; }
.modal-footer-left { display: flex; gap: 10px; }

.post-body-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}
.post-body-toolbar .toolbar-btn {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  line-height: 1;
}
.post-body-toolbar .toolbar-btn:hover {
  background: var(--primary-soft);
  color: var(--primary);
  border-color: var(--primary);
}
.post-body-toolbar .toolbar-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.post-body-toolbar .toolbar-btn:disabled:hover {
  background: var(--bg);
  color: var(--text);
  border-color: var(--border);
}
.post-body-toolbar .toolbar-btn-link-token {
  font-size: 11px;
  font-family: 'Courier New', monospace;
}
.post-body-toolbar .toolbar-btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  padding: 6px;
  color: var(--text-muted);
}
/* Кнопка «Скопировать текст поста» переехала из отдельного полноширинного
   блока под редактором в правый край тулбара - minimal icon-only. */
.post-body-toolbar .toolbar-btn-copy-spacer { margin-left: auto; }

/* Кнопки ИИ-ассистента ("Написать с нуля" / "Улучшить текст") - выделены
   акцентным фиолетовым, чтобы визуально отличаться от обычных кнопок
   форматирования текста. */
.post-body-toolbar .toolbar-btn-ai {
  background: var(--primary-soft);
  color: var(--primary);
  border-color: var(--primary);
}
.post-body-toolbar .toolbar-btn-ai:hover {
  background: var(--primary);
  color: #fff;
}

/* Кнопка запуска ИИ-генерации постов для целого запуска (детальный
   просмотр запуска) - тот же акцентный фиолетовый стиль, что и у кнопок
   ИИ в редакторе одного поста, но не завязан на .post-body-toolbar. */
#launch-detail-ai-generate-btn.toolbar-btn-ai {
  background: var(--primary-soft);
  color: var(--primary);
  border-color: var(--primary);
}
#launch-detail-ai-generate-btn.toolbar-btn-ai:hover {
  background: var(--primary);
  color: #fff;
}

.launch-ai-generate-row {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
}
.launch-ai-generate-row-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 13px;
  color: var(--text-muted);
}
.launch-ai-generate-text {
  width: 100%;
  resize: vertical;
}

.form-row { margin-bottom: 16px; }
.form-row label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.form-row label .hint { font-weight: 400; text-transform: none; }

/* Module 3: динамические поля дат для «якорных» (Важных) этапов в модалке
   копирования запуска - одно поле на каждый важный этап источника. */
.clone-multi-anchor-rows {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.clone-anchor-row { margin-bottom: 12px; }

/* Кнопка-подсказка в модалке «Вставить ссылку» - подставляет плейсхолдер
   {{LINK}} в поле URL вместо ручного набора (см. #post-link-use-token-btn
   в app.js). Оформлена как обычный текст-ссылка, а не полноценная кнопка -
   второстепенное действие рядом с основным полем ввода. */
.post-link-token-hint {
  display: block;
  margin-top: 6px;
  padding: 0;
  border: none;
  background: none;
  font-size: 12px;
  color: var(--primary);
  cursor: pointer;
  text-align: left;
}
.post-link-token-hint:hover { text-decoration: underline; }
.post-link-token-hint code {
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  background: var(--primary-soft);
  border-radius: 4px;
  padding: 1px 5px;
}

.form-row-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.channel-checkboxes {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.channel-check {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border);
  user-select: none;
}
.channel-check input { width: auto; padding: 0; }

/* ---------- Пилюли каналов в модалке поста (3 группы, аватар/иконка сети) ---------- */

.channel-groups { display: flex; flex-direction: column; gap: 18px; }
.channel-group-title { font-size: 14px; font-weight: 700; margin-bottom: 8px; }
.channel-group-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  align-items: center;
}
/* Специфичность поднята до `.channel-group-grid .channel-pill`, чтобы
   гарантированно перебить `.form-row label { display: block; ... }` (пилюля
   - это <label> внутри .form-row) - иначе браузер применял чужой display:
   block/font-size/color оттуда вместо display:flex здесь, и чекбокс/аватар/
   текст/иконка сети выравнивались не по центру, а по базовой линии текста. */
.channel-group-grid .channel-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  cursor: pointer;
  user-select: none;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  min-width: 0;
  height: 100%;
  box-sizing: border-box;
}
.channel-pill.theme-weight_loss { background: #DCFCE7; }
.channel-pill.theme-facelift { background: #FCE7F3; }
.channel-pill.theme-neutral { background: #DBEAFE; }
/* Product Distribution Presets (TASK 1): канал, не входящий в пресет
   распространения текущего Продукта ("Лицо"/"Тело"), скрывается целиком -
   вместе с чекбоксом, чтобы его нельзя было случайно выбрать вслепую. */
.channel-pill.channel-pill-hidden { display: none !important; }
.channel-pill input[type="checkbox"] { width: auto; flex-shrink: 0; vertical-align: middle; }
.channel-pill-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--surface);
}
.channel-pill-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.channel-pill-network {
  width: 20px;
  height: 20px;
  border-radius: 5px;
  flex-shrink: 0;
  object-fit: cover;
}

/* Менеджер контента: та же насыщенная пилюля канала (аватар/логотип +
   подписанное имя + иконка сети), что и в модалке поста, но статичная (см.
   channelPillStaticHtml) - несколько штук в ряд с переносом внутри ячейки
   таблицы вместо плоских текстовых чипов. */
.content-table-channel-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.content-table-channel-pills .channel-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  min-width: 0;
  box-sizing: border-box;
}

/* ---------- Настройки: список продуктов ---------- */

.products-list { display: flex; flex-direction: column; gap: 8px; }
.product-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.product-row .product-name-input { flex: 1; }
.product-row .product-color-input { width: 40px; flex-shrink: 0; padding: 2px; }
.product-row .product-distribution-target-select { width: 160px; flex-shrink: 0; }

/* ---------- Настройки: заголовки групп внутри таблицы каналов ---------- */

.channel-settings-group-row td {
  font-weight: 700;
  font-size: 13px;
  background: var(--bg);
  padding-top: 14px;
  border-bottom: 1px solid var(--border);
}

.publication-links-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.publication-links-placeholder {
  font-size: 12px;
  color: var(--text-muted);
  padding: 10px;
  background: var(--bg);
  border-radius: var(--radius-sm);
}
/* Инверсия иерархии (Task M1): канал (полная пилюля - аватар/логотип +
   имя + иконка сети) - главный заголовок карточки ссылки, вместо плоского
   зелёного тега снизу. Карточка стала выше (пилюля + вторичная строка + URL),
   поэтому выравнивание по верхнему краю - и сама пилюля, и кнопка справа
   стартуют на одной высоте, вместо визуально "проваленной" в центр кнопки. */
.publication-link-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.publication-link-info { flex: 1; min-width: 0; }
.publication-link-channel-header { margin-bottom: 6px; }
/* Пилюля канала здесь не внутри .channel-group-grid/.content-table-channel-
   pills (единственные контексты, где ей уже задан display:flex - см. выше),
   поэтому явно повторяем те же правила для этого нового контекста. */
.publication-link-channel-header .channel-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  max-width: 100%;
  box-sizing: border-box;
}
.publication-link-channel-header .channel-pill-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* Вторичная строка - прежнее "название ссылки" (например, «Подписная
   страница Salebot»), теперь просто приглушённая подпись прямо над URL,
   а не главный заголовок. */
.publication-link-secondary {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 2px;
}
/* Фолбэк-бейдж (см. channelHeaderHtml в app.js) - используется только если
   канал не найден в channelMap; сохраняет старый плоский стиль, чтобы карточка
   не осталась пустой в этом маловероятном случае. */
.publication-link-channel-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 8px;
  border-radius: 6px;
  white-space: nowrap;
  margin-bottom: 6px;
}
.publication-link-url {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 2px;
  cursor: pointer;
}
.publication-link-url:hover { color: var(--primary); text-decoration: underline; }
.publication-link-copy {
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  flex-shrink: 0;
  margin-top: 2px;
}
.publication-link-copy:hover { background: #E3DCFF; }

/* «Запись + Курс» (Task 5.2) - строка с ДВУМЯ ссылками одного канала сразу
   (запись + курс), каждая на своей подстроке с коротким тегом-названием. */
.publication-link-row-multi { align-items: flex-start; }
.publication-link-url-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-top: 3px;
}
.publication-link-target-tag {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}
.publication-link-url-row .publication-link-url { margin-top: 0; }

.template-row { display: flex; flex-wrap: wrap; gap: 10px; }
.template-row select { flex: 1; min-width: 160px; }

.template-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.template-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
}
.template-list-item:hover { background: var(--bg); }
.template-list-item-name { font-weight: 600; }
.template-list-item-count { color: var(--text-muted); font-size: 12px; }

.template-item-row {
  display: grid;
  grid-template-columns: 2fr 90px 90px 1fr 32px;
  gap: 8px;
  align-items: start;
  margin-bottom: 10px;
  padding: 10px;
  background: var(--bg);
  border-radius: var(--radius-sm);
}
.template-item-row input[type="text"] { font-size: 13px; }
.template-item-row input[type="number"] { font-size: 13px; text-align: center; }
.template-item-remove {
  background: var(--danger-soft);
  color: var(--danger);
  border-radius: var(--radius-sm);
  width: 32px;
  height: 32px;
  font-size: 16px;
}
.template-item-channels {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.template-item-channels label {
  font-size: 10px;
  padding: 3px 7px;
  border-radius: 999px;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  white-space: nowrap;
}
.template-item-channels input { width: auto; padding: 0; }
.template-item-col-label {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 4px;
  display: block;
}

/* ---------- Launch detail (archive view) ---------- */

.detail-section { margin-bottom: 20px; }
.detail-section-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 8px;
}
.detail-section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.detail-section-title-row .detail-section-title { margin-bottom: 0; }

.stage-date-edit-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.stage-date-edit-row input[type="date"] { width: 140px; }
.stage-date-edit-sep { color: var(--text-muted); }

.tech-info-view {
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 6px 14px;
}
.tech-info-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.tech-info-row:last-child { border-bottom: none; }
.tech-info-label { color: var(--text-muted); font-weight: 600; flex-shrink: 0; }
.tech-info-link {
  color: var(--primary);
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 60%;
}
.tech-info-link:hover { text-decoration: underline; }
.tech-info-empty { color: var(--text-muted); font-style: italic; }

.tech-info-edit { margin-top: 12px; }
.tech-info-edit-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 4px;
}

.schedule-stage-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}
.schedule-stage-row .schedule-stage-title { flex: 1; min-width: 160px; }
.schedule-stage-row .schedule-stage-start-date,
.schedule-stage-row .schedule-stage-end-date { width: 150px; flex-shrink: 0; }

/* Чекбокс «Важный этап» - и в строке редактора этапов, и в форме быстрого
   добавления этапа (см. new-milestone-important). Флажок 🚩 перед названием
   в бейджах/списках этапов появляется только когда он отмечен. */
.schedule-stage-important-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
  cursor: pointer;
  flex-shrink: 0;
}
.schedule-stage-important-label input[type="checkbox"] { width: auto; }
.schedule-stage-remove {
  background: var(--danger-soft);
  color: var(--danger);
  border-radius: var(--radius-sm);
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  font-size: 16px;
}
.schedule-stage-remove:hover { background: #FBDBD7; }
.detail-post-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.detail-post-row:last-child { border-bottom: none; }
.detail-post-row:hover { background: var(--bg); }
.detail-post-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.detail-post-title { font-weight: 600; font-size: 13px; }
.detail-post-date { font-size: 12px; color: var(--text-muted); }

.detail-post-text {
  font-size: 13px;
  color: var(--text);
  white-space: pre-wrap;
  overflow-wrap: break-word;
  line-height: 1.5;
}

.detail-post-images {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.detail-post-image-thumb {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.content-table-status-select {
  width: auto;
  border: none;
  cursor: pointer;
  flex-shrink: 0;
  appearance: none;
  -webkit-appearance: none;
  padding-right: 26px;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 12px) center, calc(100% - 8px) center;
  background-size: 4px 4px, 4px 4px;
  background-repeat: no-repeat;
}
.content-table-status-select:focus {
  box-shadow: 0 0 0 2px rgba(108, 92, 231, 0.35);
}

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: #fff;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-md);
  z-index: 200;
}
/* Ошибка сохранения и т.п. - визуально отличается от обычного нейтрального
   тоста (см. showToast(message, { isError: true })) и держится на экране
   дольше, чтобы её нельзя было случайно не заметить и уйти, думая, что всё
   сохранилось. */
.toast-error {
  background: var(--danger);
}

/* Индикатор автосохранения в модалке поста (см. scheduleAutosave в app.js) -
   молча показывает "Сохраняем…"/"Сохранено"/ошибку рядом с кнопками формы,
   без отдельного тоста на каждое автосохранение (тосты остаются только для
   явного клика на "Сохранить" и для сбоя, который нельзя не заметить). */
.post-save-status {
  font-size: 12px;
  color: var(--text-muted);
  margin-right: 4px;
  align-self: center;
}
.post-save-status.post-save-status-error { color: var(--danger); font-weight: 600; }

/* ---------- Responsive ---------- */

@media (max-width: 980px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  /* Один столбец - панель запусков в потоке над/под календарём, sticky
     здесь неуместен. */
  .sidebar-panel { position: static; max-height: none; overflow-y: visible; }
  .form-row-group { grid-template-columns: 1fr; }
  .channel-group-grid { grid-template-columns: 1fr; }

  /* Модалка поста: на планшетных/узких экранах колонки уже не помещаются
     рядом без тесноты - складываются друг под другом, и вместо двух
     независимо скроллящихся колонок вся модалка снова скроллится целиком
     одним общим скроллбаром (как обычная модалка). */
  .modal-post-edit { width: 100%; max-width: 640px; }
  .post-modal-body {
    display: block;
    overflow-y: auto;
    padding: 20px 24px;
  }
  .post-modal-grid { display: block; }
  .post-modal-column-text {
    padding: 0;
    margin: 0 0 20px;
    background: transparent;
    border-right: none;
  }
  .post-modal-column-text .post-body-editor {
    max-width: none;
    max-height: 320px;
    margin: 0;
  }
  .post-modal-column-meta {
    padding: 0;
    overflow: visible;
  }
}

@media (max-width: 640px) {
  /* Шапка: бренд + кнопка выхода на первой строке, вкладки — на второй,
     во всю ширину, с горизонтальной прокруткой на случай совсем узких экранов. */
  .topbar {
    flex-wrap: wrap;
    row-gap: 8px;
    padding: 10px 14px;
  }
  .topbar-brand { font-size: 14px; }
  .tabs {
    order: 3;
    flex: 1 1 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tab-btn { padding: 8px 12px; font-size: 13px; white-space: nowrap; }

  main { padding: 16px 12px 32px; }
  .calendar-panel, .sidebar-panel { padding: 14px; }

  /* Заголовок календаря: месяц/стрелки на первой строке,
     кнопка "+ Новый пост" переносится на отдельную полноширинную строку. */
  .calendar-header { flex-wrap: wrap; row-gap: 10px; }
  .calendar-header h2 { flex: 1; min-width: 0; font-size: 15px; }
  .calendar-header-spacer { display: none; }
  #btn-new-post { flex: 1 1 100%; }

  /* Сетка календаря превращается в вертикальную повестку дня —
     7 узких колонок на телефоне нечитаемы, список по дням удобнее. */
  .calendar-weekdays { display: none; }
  .calendar-grid { display: flex; flex-direction: column; gap: 6px; }
  .calendar-day.other-month:not(.has-content) { display: none; }
  .calendar-day {
    flex-direction: row;
    align-items: flex-start;
    min-height: auto;
    padding: 10px 12px;
    gap: 12px;
  }
  .calendar-day-number {
    flex: 0 1 auto;
    max-width: 45%;
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
  }
  .calendar-day-number .day-num { display: block; font-size: 16px; font-weight: 700; color: var(--text); }
  .calendar-day.today .day-num { color: var(--primary); }
  .calendar-day-number .day-weekday {
    display: block;
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
  }
  .calendar-day-posts { flex: 1; min-width: 0; }
  .post-chip {
    white-space: normal;
    font-size: 12px;
    padding: 6px 8px;
  }

  /* Архив: одна карточка в ряд */
  .archive-list { grid-template-columns: 1fr; }

  /* Менеджер контента: таблица превращается в стопку карточек */
  .content-table thead { display: none; }
  .content-table, .content-table tbody, .content-table tr, .content-table td {
    display: block;
    width: 100%;
  }
  .content-table tr {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
  }
  .content-table td {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 3px;
    padding: 6px 0;
    border: none;
    text-align: left;
  }
  .content-table td[data-label]::before {
    content: attr(data-label) ":";
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
  }
  .content-table:not(.settings-table) td:last-child { display: none; }
  .settings-table td { flex-direction: row; justify-content: space-between; align-items: center; }
  .settings-table td:last-child { justify-content: flex-end; }

  /* На мобильном сниппет текста уже не обрезается (см. базовое правило
     .content-table-snippet), карточка вертикальная - места достаточно. */
  .content-table-snippet { max-width: none; }

  /* Матрица контента (просмотр запуска / просмотр этапа): на телефоне
     4-колоночная таблица не помещается без горизонтальной прокрутки -
     сначала укладываем левую колонку с мета-информацией НАД матрицей (было
     рядом, flex-row), затем саму таблицу превращаем в стопку блоков "одна
     строка за другой": каждая строка (этап или день) - отдельный блок с
     рамкой, а 3 колонки-столпа внутри неё идут друг под другом с подписью
     (тот же приём data-label + td::before, что и у .content-table выше). */
  /* align-items:flex-start (десктопный базовый стиль) в колоночном режиме
     означает выравнивание по НАЧАЛУ поперечной оси без растяжения - обе
     колонки садятся на свою собственную (min-content/fit-content) ширину
     вместо 100% модалки, из-за чего внутренний контент (например, форма
     добавления этапа с датами) раздувает всю модалку по горизонтали.
     stretch возвращает им полную ширину контейнера. */
  .launch-matrix-layout { flex-direction: column; align-items: stretch; }
  .launch-matrix-side { max-width: none; min-width: 0; width: 100%; }
  .launch-matrix-main { min-width: 0; width: 100%; }
  .matrix-table-wrap { overflow-x: visible; overflow-y: visible; max-height: none; }
  .matrix-table { min-width: 0; }
  .matrix-table thead { display: none; }
  .matrix-table, .matrix-table tbody, .matrix-table tr, .matrix-table td {
    display: block;
    width: 100%;
  }
  .matrix-table td:first-child { width: 100%; }
  .matrix-table tr {
    margin-bottom: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
  }
  .matrix-table tr:last-child { margin-bottom: 0; }
  .matrix-table td {
    border-left: none;
    border-bottom: 1px solid var(--border);
    padding: 10px 12px;
  }
  .matrix-table tr td:last-child { border-bottom: none; }
  .matrix-cell[data-label]::before {
    content: attr(data-label);
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 6px;
  }

  /* Техническая информация запуска/этапа: на десктопе лейбл и ссылка стоят
     в одну строку (space-between, ссылка max-width:60%) - на узком экране
     длинный лейбл (flex-shrink:0) + 60%-ширины ссылка вместе не помещаются
     и растягивают всю модалку по горизонтали. Укладываем лейбл НАД
     значением, ссылке отдаём всю ширину строки. */
  .tech-info-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
  }
  .tech-info-link { max-width: 100%; }

  /* Поиск по менеджеру контента - на всю ширину экрана */
  .filters-bar input#filter-search { width: 100%; flex: 1 1 100%; }

  /* Модалки: меньше внешних отступов - больше полезной ширины */
  .modal-overlay { padding: 10px; }
  .modal-footer { flex-wrap: wrap; row-gap: 10px; }
  .modal-footer-right { flex: 1 1 100%; justify-content: flex-end; }

  /* Модалка поста: кнопки футера перестают горизонтально вылезать за экран -
     складываются в 2 ряда: [Удалить][Дублировать] 50/50, [Отмена][Сохранить]
     50/50. */
  #post-modal .modal-footer {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  #post-modal .modal-footer-left {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    width: 100%;
    margin: 0;
  }
  #post-modal .modal-footer-right {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    width: 100%;
    flex: none;
    margin: 0;
  }
  #post-modal .modal-footer-left button,
  #post-modal .modal-footer-right button {
    width: 100%;
    text-align: center;
  }

  /* Пункт спринт-шаблона: 5 колонок в ряд не умещаются - складываем в столбец */
  .template-item-row {
    grid-template-columns: 1fr;
  }
  .template-item-remove { justify-self: end; }

  /* Фотобанк: папки над сеткой изображений вместо колонок - sticky здесь
     неуместен (список папок в потоке над сеткой, а не сбоку) и мог бы
     наплывать на изображения при прокрутке. */
  .media-layout { grid-template-columns: 1fr; }
  .media-folders-panel { position: static; max-height: none; overflow-y: visible; }
  .media-images-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }

  /* Инструкция: то же самое - меню-навигация над текстом, не sticky-сбоку */
  .instructions-layout { grid-template-columns: 1fr; }
  .instructions-nav { position: static; flex-direction: row; flex-wrap: wrap; }

  /* Overlay-галерея: папки над сеткой */
  .gallery-layout { grid-template-columns: 1fr; }
  .gallery-folders {
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding-right: 0;
    padding-bottom: 12px;
  }
}
