/* ============================================================================
   EDITOR — whiteboard scene editor (вторая вкладка приложения).
   ----------------------------------------------------------------------------
   Активируется через body[data-view="editor"]. Префикс .editor-* у всех
   селекторов чтобы не пересекалось с базовым плеером (#stage и т.д.).
   ========================================================================== */

/* ── shadcn-style neutral design tokens ──────────────────────────────── */

:root {
  /* Шкала neutral (shadcn zinc-like) */
  --c-neutral-50:  #fafafa;
  --c-neutral-100: #f5f5f5;
  --c-neutral-200: #e5e5e5;
  --c-neutral-300: #d4d4d4;
  --c-neutral-400: #a3a3a3;
  --c-neutral-500: #737373;
  --c-neutral-600: #525252;
  --c-neutral-700: #404040;
  --c-neutral-800: #262626;
  --c-neutral-900: #171717;
  --c-neutral-950: #0a0a0a;
  --c-accent:        #0071e3;   /* = бренд --accent (был #0070f3 — рассинхрон двух синих) */
  --c-accent-hover:  #0058b8;   /* = бренд --accent-hover (был #0058c4) */
  --c-success:       #16a34a;
  --c-warning:       #d97706;
  --c-danger:        #dc2626;

  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-xl: 10px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 2px 6px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.06);

  /* Surface-токены редактора. Светлые значения — здесь; тёмные переопределяет
     theme.css ([data-app-theme="dark"]). Видео-холст (--canvas-bg/--stage-*) НЕ
     входит сюда: это контент ролика, тема UI его не трогает. */
  --ed-app-bg: #f5f5f7;     /* фон страницы редактора */
  --ed-app-bg-2: #f1f1f3;   /* фон вложенных областей */
  --ed-surface: #ffffff;    /* панели / поля / кнопки / модалки */
}

/* lucide-иконки в кнопках, которые НЕ .editor-btn (загрузка ассета, закрытие модалки) */
.editor-asset-upload-btn svg.lucide { width: 15px; height: 15px; color: #fff; }
.newproject-close svg.lucide { width: 16px; height: 16px; }

body[data-view="editor"] {
  font-family: "InterVariable", "Inter var", "Inter", -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, sans-serif;
  font-feature-settings: "cv02", "cv03", "cv04", "cv11";
}

/* HARD-GUARD для нативных file/checkbox input'ов с атрибутом [hidden].
   В тулбаре `<label class="editor-btn"><input type="file" hidden></label>` —
   display:flex с .editor-btn перебивает default [hidden]{display:none}.
   Аналог фикса для .cmdk-overlay. */
body[data-view="editor"] input[type="file"][hidden],
body[data-view="editor"] input[hidden] {
  display: none !important;
}

/* Lucide-иконки внутри editor-btn — выравниваем по высоте текста. */
.editor-btn i[data-lucide],
.editor-btn svg.lucide {
  width: 14px;
  height: 14px;
  vertical-align: middle;
  margin-right: 6px;
  stroke-width: 2;
  flex-shrink: 0;
}
/* В icon-only кнопке — без отступа справа (текста нет). НЕ используем
   :only-child / :last-child — text nodes не считаются child elements,
   поэтому SVG + текст матчит :only-child и схлопывает gap. */
.editor-btn.icon-only > i[data-lucide],
.editor-btn.icon-only > svg.lucide {
  margin-right: 0;
}

/* ── Editor view: компактная раскладка на весь экран без скролла ─────── */

body[data-view="editor"] {
  overflow: hidden;
  /* Светло-серый фон страницы — отделяет browser chrome от app-контента.
     Тулбар/панели получают белый фон поверх — естественный «приподнятый»
     вид. Раньше был cream #fbfaf6 который сливался со светлым ассет-pane. */
  background: var(--ed-app-bg) !important;
}
body[data-view="editor"] main {
  max-width: 100vw !important;
  height: 100vh !important;
  /* Прибиваем интерфейс к самым краям окна — макс. место холсту и таймлайну */
  padding: 0 4px 0 !important;
  margin: 0 !important;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow: hidden;
  box-sizing: border-box;
}
body[data-view="editor"] {
  margin: 0 !important;
  padding: 0 !important;
}
body[data-view="editor"] header,
body[data-view="editor"] .health {
  display: none !important;
}
/* В editor-режиме верхняя ОТДЕЛЬНАЯ полоса .app-tabs скрыта — табы
   встроены прямо в .editor-toolbar (toolbar-tabs-group + editor-mini-tab).
   Экономит ~36px вертикали и убирает «бурелом» двух полос. */
body[data-view="editor"] .app-topbar {
  display: none !important;
}

/* LEGACY: старый pill-style для .editor-toolbar НЕ-ribbon — оставлен
   только если будут НЕ-ribbon тулбары. Для ribbon стили заданы ниже
   в блоке .ribbon-bar (он переопределяет всё через большую specificity).
   Эти правила НЕ применяются когда #editor-toolbar.editor-ribbon. */
.editor-toolbar:not(.editor-ribbon) .toolbar-tabs-group {
  padding: 0 !important;
  gap: 0 !important;
  background: var(--ed-app-bg-2) !important;
  border-radius: 7px !important;
  margin-right: 6px !important;
  border: 0 !important;
  height: var(--toolbar-control-h, 28px) !important;
  overflow: hidden;
}
.editor-toolbar:not(.editor-ribbon) .toolbar-tabs-group::after {
  display: none !important;
}
.editor-toolbar:not(.editor-ribbon) .editor-mini-tab {
  -webkit-appearance: none !important;
  appearance: none !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  height: var(--toolbar-control-h, 28px) !important;
  padding: 0 14px !important;
  font-family: inherit !important;
  font-size: 12px !important;
  font-weight: 600 !important;
  color: var(--c-neutral-500) !important;
  background-color: transparent !important;
  border: 0 !important;
  border-radius: 6px !important;
}
.editor-toolbar:not(.editor-ribbon) .editor-mini-tab.active {
  background-color: var(--ed-surface) !important;
  color: var(--c-neutral-900) !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12) !important;
}
body[data-view="editor"] #view-editor.active {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
  min-height: 0;
}

/* ── Tab bar ───────────────────────────────────────────────────────────── */

/* Верхний слим-бар (.app-topbar) хаба = тот же уровень/стиль, что лента редактора
   (.ribbon-bar): табы вверху и слева, тот же порядок/вид → единый интерфейс при
   переходе Проекты ⇄ Редактор. Внутри: .app-tabs (табы) слева, .app-topbar-meta
   (бренд + backend) справа. Высота/фон/бордер повторяют ribbon-bar. */
.app-topbar {
  display: flex;
  align-items: stretch;
  gap: 0;
  margin: 0 0 18px;
  padding: 0 6px;          /* как ribbon-bar (0 6px) → табы у левого края */
  height: 40px;            /* как ribbon-bar (40px) */
  min-height: 40px;
  border-bottom: 1px solid var(--c-neutral-100, var(--border));
  background: linear-gradient(180deg, #fbfbfd 0%, #ffffff 100%);
  box-sizing: border-box;
  /* как в ribbon-bar: на узком окне табы скроллятся, а не обрезаются/сжимаются */
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
}
[data-app-theme="dark"] .app-topbar {
  background: linear-gradient(180deg, #1e2024 0%, #191b1f 100%);
  border-bottom-color: #2a2d33;
}
.app-tabs {
  display: flex;
  align-items: stretch;
  gap: 0;
  height: 100%;
  flex-shrink: 0;
}
.app-topbar-spacer { flex: 1 1 auto; min-width: 12px; }
.app-topbar-meta {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-right: 120px;  /* место под fixed avatar+theme (закреплены в правом верхнем углу окна) */
  white-space: nowrap;
  min-width: 0;
}
.app-topbar-meta .health { margin-left: 0; }   /* сброс header-овского margin-left:auto */
.app-topbar-wordmark {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.018em;
  color: var(--ink);
}
.app-topbar-sub { font-weight: 500; color: var(--muted); }
@media (max-width: 760px) {
  .app-topbar-meta { display: none; }   /* узкие экраны: важнее табы, бренд прячем */
}

/* .app-tab = 1-в-1 как .editor-mini-tab в ленте редактора (высота во весь бар,
   12px, padding 0 10, active = «приподнятый» pill). Тот же вид → меню совпадает
   при переходе Проекты ⇄ Редактор. Active дублируется JS-инлайном (safety-net). */
.app-tab {
  -webkit-appearance: none;
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  margin: 0;                 /* сброс глобального button{margin-top:16px} (styles.css):
                                бар теперь body-level, вне #view-editor, где стоял сброс —
                                иначе табы уезжали на 16px вниз и «скакали» при переходе */
  padding: 0 10px;
  line-height: 1;
  box-sizing: border-box;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  color: var(--c-neutral-600, var(--muted));
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  cursor: pointer;
  letter-spacing: normal;
  white-space: nowrap;
  transition: color 120ms ease, background 120ms ease, box-shadow 120ms ease;
}

.app-tab:hover { color: var(--c-neutral-900, var(--ink)); background: rgba(128, 128, 128, 0.16); }

/* Active = синее inset-подчёркивание + лёгкий тинт (как ribbon-tab в ленте). Тот же
   вид дублирует JS-инлайн в setView. --c-accent — глобальный токен (виден в обеих
   темах); raised-pill на --ed-surface сливался с тёмной лентой — не годился. */
.app-tab.active {
  color: var(--c-accent, var(--accent));
  box-shadow: inset 0 -2px 0 var(--c-accent, var(--accent));
  background: rgba(0, 113, 227, 0.06);
}

/* ── View switching ────────────────────────────────────────────────────── */

.app-view { display: none; }
.app-view.active { display: block; }

/* "Auto" view is the legacy upload+player — no extra styling needed, it
   already lives at root of <main>. Editor view gets its own container. */

/* ── Editor layout: toolbar / 3-pane grid / timeline ──────────────────── */

#view-editor {
  display: none;  /* default; .active overrides */
}
#view-editor.active { display: flex; flex-direction: column; gap: 12px; }

/* ── Ribbon: главная панель редактора (Ansys-style) ──────────────────── */
.editor-ribbon {
  --toolbar-control-h: 28px;

  display: flex !important;
  flex-direction: column;
  background: var(--ed-surface);
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 10px;
  flex-shrink: 0;
  font-size: 11px;
  overflow: visible;
  visibility: visible !important;
  height: auto !important;
  min-height: 84px !important;  /* bar 36 + content 48 */
  max-width: 100%;
  box-sizing: border-box;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04),
              0 1px 2px rgba(0, 0, 0, 0.03);
}

/* Одна строка: view-switcher + сохранено + ribbon-tabs + status + cmdk.
   Все элементы одного размера (12px), компактно. */
.ribbon-bar {
  display: flex;
  align-items: center;        /* было stretch — буквы вылезали из-за border-bottom */
  gap: 0;
  padding: 0 6px;
  border-bottom: 1px solid var(--c-neutral-100);
  background: linear-gradient(180deg, #fbfbfd 0%, #ffffff 100%);
  /* 40px — запас, чтобы у активного таба border-bottom 2px не давил текст */
  height: 40px;
  min-height: 40px;
  flex-shrink: 0;
  box-sizing: border-box;
  /* было hidden — при узком окне правые табы (Вид/Консоль/⌘) обрезались и были
     НЕДОСТУПНЫ. Теперь горизонтальный скролл; вертикаль остаётся hidden, чтобы
     border-bottom активного таба не «давил» текст. */
  overflow-x: auto !important;
  overflow-y: hidden !important;
  scrollbar-width: thin;
}
/* Все прямые дочерние элементы ribbon-bar — выравниваем по центру,
   с консистентной высотой через box-sizing. */
.ribbon-bar > * {
  box-sizing: border-box;
}
/* styles.css (база auto-view) вешает глобально `button { margin-top: 16px }`.
   Этот отступ нужен только старому пайплайн-UI (#view-auto). В редакторе он
   течёт во ВСЕ кнопки: табы Ribbon вылезали за 40px-бар («наезжающий текст»),
   а чипы ассетов/инспектор/таймлайн получали лишние 16px сверху. Сбрасываем
   на весь editor view одним правилом. */
#view-editor button {
  margin-top: 0;
}

/* Тонкая вертикальная линия-разделитель между группами */
.ribbon-divider {
  width: 1px;
  height: 16px;
  align-self: center;
  background: var(--c-neutral-200);
  margin: 0 6px;
  flex-shrink: 0;
}

.ribbon-bar .editor-save-indicator {
  display: inline-flex;
  align-items: center;
  font-size: 12px;
  font-weight: 500;
  padding: 0 8px;
  height: 100%;
  line-height: 1;
  box-sizing: border-box;
  white-space: nowrap;
}

.ribbon-top-status {
  margin-left: auto;
  align-self: center;
  font-size: 12px;
  color: var(--c-neutral-500);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
  padding: 0 8px;
}

/* Унификация мини-табов VIEW: тот же стиль что у ribbon-tab, без pill-контейнера */
.ribbon-bar .toolbar-tabs-group {
  display: flex;
  align-items: stretch;
  background: transparent !important;
  border: 0 !important;
  border-radius: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
  gap: 0 !important;
  height: 100% !important;
}
.ribbon-bar .editor-mini-tab {
  -webkit-appearance: none;
  appearance: none;
  padding: 0 10px !important;
  height: 100% !important;
  line-height: 1 !important;
  box-sizing: border-box !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  background: transparent !important;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  cursor: pointer;
  font-family: inherit;
  font-size: 12px !important;
  font-weight: 500 !important;
  color: var(--c-neutral-600) !important;
  white-space: nowrap;
  letter-spacing: normal !important;
  transition: color 120ms ease, box-shadow 120ms ease, background 120ms ease;
}
.ribbon-bar .editor-mini-tab:hover {
  color: var(--c-neutral-900) !important;
  /* нейтральный полупрозрачный тинт — виден и на светлой, и на тёмной ленте
     (чёрный rgba(0,0,0,.04) на тёмной теме был невидим) */
  background: rgba(128, 128, 128, 0.16) !important;
}
/* Active = inset box-shadow вместо border-bottom — НЕ занимает layout-место,
   текст остаётся точно по центру bar. */
.ribbon-bar .editor-mini-tab.active {
  color: var(--c-accent) !important;
  box-shadow: inset 0 -2px 0 var(--c-accent) !important;
  background: rgba(0, 113, 227, 0.06) !important;
}

/* Ribbon tabs — встроены в bar. Тот же визуал что и mini-tab выше. */
.ribbon-tabs {
  display: flex;
  align-items: stretch;
  gap: 0;
  flex-shrink: 0;
  height: 100%;
}
.ribbon-tab {
  -webkit-appearance: none;
  appearance: none;
  padding: 0 10px;
  height: 100%;
  line-height: 1;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 0;
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  color: var(--c-neutral-600);
  white-space: nowrap;
  transition: color 120ms ease, box-shadow 120ms ease, background 120ms ease;
}
.ribbon-tab:hover {
  color: var(--c-neutral-900);
  background: rgba(128, 128, 128, 0.16);  /* нейтральный тинт — виден в обеих темах */
}
/* Active = inset box-shadow вместо border-bottom — НЕ влияет на layout. */
.ribbon-tab.active {
  color: var(--c-accent);
  box-shadow: inset 0 -2px 0 var(--c-accent);
  background: rgba(0, 113, 227, 0.06);
}

/* Cmd+K кнопка-ghost в баре — full height + flex-center */
.ribbon-bar .editor-btn-ghost {
  align-self: stretch;
  height: 100% !important;
  width: 32px !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 !important;
  background: transparent !important;
  border: 0 !important;
}

/* Content panels — без верхнего паддинга чтобы не было зазора.
   overflow: hidden — колесо мыши не прокручивает горизонталь. */
.ribbon-content {
  /* ФИКСИРОВАННАЯ высота для ВСЕХ вкладок — лента не «прыгает» при переключении
     (Главная/Объекты/Анимация/…). Содержимое центрируется по вертикали.
     Подобрано под самую насыщенную панель «Анимация» (компактные карточки). */
  flex: 0 0 auto;
  /* высота вмещает САМУЮ высокую панель (export/objects ≈77px с селектами) —
     иначе нижний ряд (лейблы групп) обрезался по высоте. Едина для всех вкладок,
     чтобы лента не «прыгала» при переключении. */
  height: 80px;
  display: flex;
  align-items: center;
  padding: 0 10px;
  /* Горизонтальный скролл — крайний фолбэк. Основной механизм при узком окне —
     сворачивание лишних групп в меню «⋯ Ещё» (reflowRibbon в editor.js). */
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
}

/* ── Адаптивная лента: меню «⋯ Ещё» для свёрнутых при узком окне кнопок ── */
.rb-overflow-group { position: relative; }
.rb-overflow-btn { white-space: nowrap; }
.rb-overflow-menu {
  /* fixed — чтобы не обрезалось overflow-y:hidden ленты; координаты ставит JS */
  position: fixed;
  z-index: 1200;
  background: var(--ed-surface, #fff);
  border: 1px solid var(--border, var(--c-neutral-200));
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: stretch;
  min-width: 200px;
  max-height: 64vh;
  overflow-y: auto;
}
.rb-overflow-menu > * { flex: 0 0 auto; width: 100%; }
.rb-overflow-menu .editor-btn,
.rb-overflow-menu .editor-cap-toggle { justify-content: flex-start; height: 36px; }
.rb-overflow-menu .editor-select { height: 36px; }
.rb-overflow-menu .ribbon-vsep { display: none; }   /* разделители в меню не нужны */
/* Тонкий горизонтальный скроллбар ленты (виден только при узком окне). */
.ribbon-bar::-webkit-scrollbar,
.ribbon-content::-webkit-scrollbar { height: 6px; }
.ribbon-bar::-webkit-scrollbar-thumb,
.ribbon-content::-webkit-scrollbar-thumb { background: var(--c-neutral-300); border-radius: 3px; }
.ribbon-bar::-webkit-scrollbar-track,
.ribbon-content::-webkit-scrollbar-track { background: transparent; }
.ribbon-panel {
  display: none;
  align-items: stretch;
  gap: 6px;
  width: 100%;
}
.ribbon-panel.active { display: flex; }

/* Категории ассетов живут ТОЛЬКО во вкладке «Объекты» (ribbon-group-assets) —
   горизонтальная лента иконок-only со скроллом, не перекрывает другие вкладки. */
.ribbon-group-assets {
  flex: 1;
  min-width: 0;
  align-items: stretch;
}
.editor-asset-chips.ribbon-asset-chips {
  display: flex !important;
  grid-template-columns: none !important;
  flex-wrap: nowrap;
  gap: 6px !important;
  max-height: none;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 4px 0 2px;
  flex: 1;
  min-width: 0;
}
.ribbon-asset-chips .asset-chip {
  aspect-ratio: auto;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  border-radius: 9px;
}
.ribbon-asset-chips .asset-chip .chip-icon { font-size: 21px; }

/* Group: контент с лейблом снизу */
.ribbon-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 8px;
  border-right: 1px solid var(--c-neutral-100);
}
.ribbon-group:last-child { border-right: 0; }
.ribbon-group-body {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 0 4px;
  flex: 1;
}
.ribbon-group-label {
  font-size: 9px;
  font-weight: 600;
  color: var(--c-neutral-500);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding-bottom: 2px;
  white-space: nowrap;
}

/* ── Консоль (вкладка ribbon «Консоль») ───────────────────────────────── */
/* Вписана в ТЕКУЩУЮ высоту ленты (не расширяет её): панель растягивается на
   всю высоту ribbon-content, журнал прокручивается внутри. */
.ribbon-panel[data-panel="console"] { align-self: stretch; }
.editor-console-group { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
/* Командная строка: слева — узкая колонка действий, справа — журнал во всю
   ширину/высоту. Минимализм, в пределах высоты ленты (не растягиваем). */
.editor-console-body { flex: 1; display: flex; flex-direction: row; align-items: stretch; min-height: 0; gap: 8px; padding: 2px 0; }
.editor-console-actions { display: flex; flex-direction: column; align-items: center; gap: 3px; flex: 0 0 auto; }
.editor-console-actions .editor-btn.icon-only { width: 22px; height: 22px; }
.editor-console-count { font-size: 10px; color: var(--muted); font-variant-numeric: tabular-nums; line-height: 1; }
.editor-console-list {
  flex: 1; min-width: 0; min-height: 0; overflow-y: auto; margin: 0; padding: 3px 6px;
  list-style: none; border: 1px solid var(--border); border-radius: 6px;
  background: var(--page-bg); font-size: 11.5px; line-height: 1.5;
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}
.editor-console-list:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.editor-console-row {
  display: flex; gap: 8px; padding: 2px 6px; border-radius: 4px; cursor: pointer;
  white-space: nowrap; user-select: none;
}
.editor-console-row:hover { background: var(--c-neutral-100); }
.editor-console-row.selected { background: rgba(0, 113, 227, 0.18); }
.editor-console-row .cc-time { color: var(--muted); flex: 0 0 auto; font-variant-numeric: tabular-nums; }
.editor-console-row .cc-text { color: var(--ink); overflow: hidden; text-overflow: ellipsis; }
.editor-console-row.lvl-ok .cc-text { color: #15803d; }
.editor-console-row.lvl-error .cc-text { color: var(--c-danger); }
.editor-console-row .cc-rep { color: var(--muted); font-size: 10px; }
/* Записи, связанные с отменяемым действием — лёгкий акцент + глиф ↶ справа. */
.editor-console-row.revertible { border-left: 2px solid rgba(0, 113, 227, 0.5); padding-left: 6px; }
.editor-console-row .cc-undo {
  flex: 0 0 auto; margin-left: auto; padding-left: 8px;
  color: var(--accent); font-size: 13px; line-height: 1; opacity: 0.55;
}
.editor-console-row:hover .cc-undo { opacity: 1; }
.editor-console-empty { color: var(--muted); padding: 8px; font-style: italic; list-style: none; }

/* ── Вкладка «Вид»: кнопки управления + наложения холста ─────────────── */
.editor-view-tools { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; padding: 2px 0; }
.editor-view-btn {
  width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); border-radius: 8px; background: var(--ed-surface, #fff);
  color: var(--ink); cursor: pointer; flex: 0 0 auto; padding: 0;
  transition: background 100ms, border-color 100ms, color 100ms;
}
.editor-view-btn:hover { border-color: var(--accent); background: var(--c-neutral-100); }
.editor-view-btn.active { background: rgba(0, 113, 227, 0.14); border-color: var(--accent); color: var(--accent); }
.editor-view-btn svg { width: 17px; height: 17px; }
.editor-view-sep { width: 1px; height: 22px; background: var(--c-neutral-100); margin: 0 4px; flex: 0 0 auto; }

/* Наложения холста (классы на #editor-canvas-wrap; canvas масштабируется → grid в world-px) */
#editor-canvas-wrap.vw-grid #editor-canvas {
  background-image:
    linear-gradient(to right, rgba(0, 0, 0, 0.07) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(0, 0, 0, 0.07) 1px, transparent 1px);
  background-size: 80px 80px;
}
#editor-canvas-wrap.vw-checker #editor-canvas {
  background-image:
    linear-gradient(45deg, rgba(0, 0, 0, 0.06) 25%, transparent 25%, transparent 75%, rgba(0, 0, 0, 0.06) 75%),
    linear-gradient(45deg, rgba(0, 0, 0, 0.06) 25%, transparent 25%, transparent 75%, rgba(0, 0, 0, 0.06) 75%);
  background-size: 40px 40px; background-position: 0 0, 20px 20px;
}
#editor-canvas-wrap.vw-bounds .editor-scene { outline: 1px dashed rgba(0, 113, 227, 0.55); outline-offset: 1px; }
#editor-canvas-wrap.vw-dark { background: #26262b; }
/* Кадр вьюпорта + направляющие центра (позиционируются JS в screen-координатах) */
.editor-view-overlay { position: absolute; inset: 0; pointer-events: none; z-index: 6; overflow: hidden; }
.editor-view-frame { position: absolute; border: 2px dashed rgba(255, 57, 164, 0.75); box-sizing: border-box; border-radius: 2px; }
.editor-view-guide-v, .editor-view-guide-h { position: absolute; background: rgba(255, 57, 164, 0.55); }
.editor-view-guide-v { width: 1px; top: 0; bottom: 0; }
.editor-view-guide-h { height: 1px; left: 0; right: 0; }

.ribbon-hint {
  font-size: 11px;
  color: var(--c-neutral-500);
  max-width: 320px;
  line-height: 1.4;
  padding: 4px 8px;
}
.ribbon-hint kbd {
  background: var(--c-neutral-100);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 10px;
  font-family: var(--font-mono, monospace);
}

/* legacy .editor-toolbar класс ещё используется selector'ами — оставим
   alias через комбо. */
.editor-ribbon[id="editor-toolbar"] {
  /* Унаследовано выше. Этот блок просто для документации. */
}

/* Legacy .editor-toolbar (на случай если что-то ещё использует) */
.editor-toolbar {
  --toolbar-control-h: 28px;
  display: flex !important;
  align-items: center;
  gap: 2px;
  flex-wrap: nowrap;
  padding: 5px 8px;
  background: var(--ed-surface);
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 10px;
  flex-shrink: 0;
  font-size: 11px;
  white-space: nowrap;
  height: max(40px, var(--toolbar-h, 42px)) !important;
  min-height: 40px !important;
  overflow-x: auto;
  overflow-y: visible;
  max-width: 100%;
  box-sizing: border-box;
  visibility: visible !important;
  /* Чуть более заметная тень — тулбар «приподнят» над серым background.
     Это решает «бурелом» на стыке Chrome UI и приложения. */
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04),
              0 1px 2px rgba(0, 0, 0, 0.03);
}
/* Тонкий горизонтальный scroll внутри тулбара — не пожирает высоту */
.editor-toolbar::-webkit-scrollbar { height: 4px; }
.editor-toolbar::-webkit-scrollbar-track { background: transparent; }
.editor-toolbar::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.15);
  border-radius: 2px;
}
.editor-toolbar::-webkit-scrollbar-thumb:hover { background: rgba(0, 0, 0, 0.3); }

.editor-toolbar .toolbar-group {
  position: relative;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0 6px;
  flex-shrink: 0;
}
/* Лёгкий вертикальный разделитель ПОСЛЕ каждой группы (кроме последней). */
.editor-toolbar .toolbar-group:not(:last-child)::after {
  content: "";
  position: absolute;
  right: 0;
  top: 6px;
  bottom: 6px;
  width: 1px;
  background: var(--c-neutral-200);
  pointer-events: none;
}

/* Inline group-label СКРЫТ по умолчанию (data-label осталось ради a11y/
   воспоминаний); если хочется показать снова — снимаем display:none ниже. */
.editor-toolbar .toolbar-group[data-label]::before {
  content: attr(data-label);
  display: none;
}
.editor-toolbar[data-labels="1"] .toolbar-group[data-label]::before {
  display: inline;
  font-size: 9px;
  font-weight: 600;
  color: var(--c-neutral-400);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
  margin-right: 4px;
  pointer-events: none;
}

.editor-toolbar label.toolbar-label {
  font-size: 10px;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: -0.01em;
}

.editor-btn {
  /* appearance:none — иначе native button render на Windows dark-mode
     перебивает background/color. */
  -webkit-appearance: none;
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: var(--toolbar-control-h, 28px);
  padding: 0 10px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  color: var(--c-neutral-700);
  background: var(--ed-surface);
  border: 1px solid var(--c-neutral-200);
  border-radius: 6px;
  cursor: pointer;
  letter-spacing: -0.005em;
  transition: background 120ms var(--ease-quick),
              border-color 120ms var(--ease-quick),
              color 120ms var(--ease-quick),
              box-shadow 120ms var(--ease-quick);
  line-height: 1;
  flex-shrink: 0;
  white-space: nowrap;
  box-sizing: border-box;
  vertical-align: middle;
}
.editor-btn:hover {
  background: var(--c-neutral-50);
  border-color: var(--c-neutral-300);
  color: var(--c-neutral-900);
}
.editor-btn:active { transform: translateY(1px); }
.editor-btn:focus-visible {
  outline: 2px solid var(--c-accent);
  outline-offset: 1px;
}
/* Disabled — приглушённая. pointer-events НЕ убираем, иначе браузер не
   показывает title-тултип при наведении. Клик и так блокирует HTML-disabled. */
.editor-btn:disabled,
.editor-btn[disabled] {
  opacity: 0.38;
  cursor: default;
}
/* «Мягкое» неактивное состояние: визуально приглушено, но кликабельно
   (по клику покажем подсказку в статусе) и с рабочим тултипом. Для
   ribbon-группы «Правка» — undo/redo/copy/paste/дубль. */
.editor-btn.btn-off { opacity: 0.4; }
.editor-btn.btn-off:hover { opacity: 0.6; }

/* Трансформация (morph) — превью цели + слоты длительности/at. */
.morph-row { display: flex; align-items: flex-end; gap: 8px; flex-wrap: wrap; }
.morph-thumb {
  width: 46px; height: 46px; object-fit: contain; flex-shrink: 0;
  border: 1px solid var(--border); border-radius: 8px; background: var(--page-bg);
}
/* Pick-mode: подсветка панели ассетов, курсор-«копировать» на плитках. */
body.morph-picking #editor-assets-list {
  outline: 2px dashed var(--accent); outline-offset: -2px; border-radius: 6px;
}
body.morph-picking #editor-assets-list * { cursor: copy; }
/* Тонкий вертикальный разделитель внутри ribbon-group-body
   (например между undo/redo и буфером обмена). */
.ribbon-vsep {
  width: 1px;
  align-self: stretch;
  margin: 2px 4px;
  background: var(--c-neutral-200);
  flex-shrink: 0;
}
/* Поля разрешения W×H в ленте «Главная» (перенесены из инспектора). */
.ribbon-dim {
  width: 58px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}
.ribbon-dim-x {
  color: var(--c-neutral-500);
  font-size: 12px;
  padding: 0 1px;
  align-self: center;
  flex-shrink: 0;
}
/* Icon-only кнопка (только иконка внутри, без текста) — квадратная.
   ВНИМАНИЕ: НЕ использовать `:has(> svg.lucide:only-child)` — text nodes
   не считаются child elements, поэтому правило ошибочно матчит кнопки
   вида <button><svg>Текст</svg></button> и схлопывает их до 28px.
   Используем только явный класс. */
.editor-btn.icon-only {
  width: var(--toolbar-control-h, 28px);
  padding: 0;
}
.editor-btn.icon-only > i[data-lucide],
.editor-btn.icon-only > svg.lucide {
  margin-right: 0;
}
.editor-btn.primary {
  background: var(--c-neutral-900);
  color: #fff;
  border-color: var(--c-neutral-900);
}
.editor-btn.primary:hover {
  background: var(--c-neutral-800);
  border-color: var(--c-neutral-800);
  color: #fff;
}
.editor-btn.accent {
  background: var(--c-accent);
  color: #fff;
  border-color: var(--c-accent);
}
.editor-btn.accent:hover {
  background: var(--c-accent-hover);
  border-color: var(--c-accent-hover);
  color: #fff;
}
.editor-btn.danger { color: var(--c-danger); }

.editor-select {
  padding: 0 8px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  color: var(--c-neutral-700);
  background: var(--ed-surface);
  border: 1px solid var(--c-neutral-200);
  border-radius: 6px;
  cursor: pointer;
  height: var(--toolbar-control-h, 28px);
  transition: border-color 120ms var(--ease-quick);
}
.editor-select:hover { border-color: var(--c-neutral-300); }
.editor-select:focus-visible {
  outline: 2px solid var(--c-accent);
  outline-offset: 1px;
}

/* Текстовый инпут в тулбаре (id_проекта) */
.editor-input {
  height: var(--toolbar-control-h, 28px);
  width: 120px;
  padding: 0 10px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  color: var(--c-neutral-700);
  background: var(--ed-surface);
  border: 1px solid var(--c-neutral-200);
  border-radius: 6px;
  outline: none;
  transition: border-color 120ms var(--ease-quick);
  box-sizing: border-box;
}
.editor-input::placeholder { color: var(--c-neutral-400); font-weight: 400; }
.editor-input:hover { border-color: var(--c-neutral-300); }
.editor-input:focus { border-color: var(--c-accent); }

/* Zoom-label между − и + : компактная плашка с процентом. */
.editor-zoom-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 42px;
  height: var(--toolbar-control-h, 28px);
  padding: 0 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--c-neutral-600);
  background: var(--c-neutral-100);
  border-radius: 6px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  user-select: none;
}

/* Аудио-pill в тулбаре: имя файла + время + крестик. Появляется после
   загрузки .mp3/.wav, скрыт пока src нет. */
.editor-audio-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: var(--toolbar-control-h, 28px);
  padding: 0 4px 0 10px;
  background: linear-gradient(180deg, rgba(0, 113, 227, 0.055) 0%, rgba(0, 113, 227, 0.12) 100%);
  border: 1px solid rgba(0, 113, 227, 0.28);
  border-radius: 6px;
  font-size: 11px;
  font-weight: 500;
  color: var(--accent-hover);
  max-width: 240px;
}
.editor-audio-pill[hidden] { display: none; }
.editor-audio-pill .editor-audio-name {
  font-weight: 500;
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.editor-audio-pill .editor-audio-time {
  font-variant-numeric: tabular-nums;
  color: var(--accent-hover);
  font-size: 10px;
  font-weight: 600;
}
.editor-audio-pill .editor-audio-clear {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 4px;
  color: var(--accent-hover);
  cursor: pointer;
}
.editor-audio-pill .editor-audio-clear:hover {
  background: rgba(0, 113, 227, 0.12);
  color: var(--c-accent);
}
.editor-audio-pill .editor-audio-clear i[data-lucide],
.editor-audio-pill .editor-audio-clear svg.lucide {
  width: 12px;
  height: 12px;
  margin: 0;
}

/* Audio-strip на таймлайне: тонкая горизонтальная полоса показывающая
   длительность аудио относительно сценария. Лежит над линейкой времени. */
.editor-audio-strip {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 4px;
  background: linear-gradient(90deg, #4ca0ff 0%, #0071e3 100%);
  border-radius: 2px;
  opacity: 0.55;
  pointer-events: none;
  z-index: 1;
}
.editor-audio-strip[hidden] { display: none; }

/* ── Волновой фронт аудио (нижняя полоса таймлайна) ───────────────────── */
.editor-audio-wave {
  /* top задаётся из renderTimeline (сразу под плитками сцен); bottom фиксирован
     — волна заполняет остаток высоты таймлайна, без большого зазора над ней. */
  position: absolute; left: 0; right: 0; bottom: 6px;
  z-index: 2; cursor: pointer;
  border-top: 1px dashed var(--border, rgba(0, 0, 0, 0.12));
  background: rgba(91, 155, 232, 0.04);
}
.editor-audio-wave[hidden] { display: none; }
.editor-audio-wave canvas { display: block; width: 100%; height: 100%; }
.editor-wave-menu {
  position: fixed; z-index: 10000; min-width: 190px;
  background: var(--ed-surface, #fff); border: 1px solid var(--border, rgba(0, 0, 0, 0.1));
  border-radius: 10px; box-shadow: var(--shadow-3, 0 14px 40px rgba(0, 0, 0, 0.22));
  padding: 5px; display: flex; flex-direction: column; gap: 2px;
}
.editor-wave-menu[hidden] { display: none; }
.editor-wave-menu button {
  text-align: left; padding: 7px 10px; border: none; background: none;
  border-radius: 6px; font: inherit; font-size: 12.5px; color: var(--ink, #1d1d1f); cursor: pointer;
}
.editor-wave-menu button:hover { background: var(--c-neutral-100, #f0f3f8); }
.editor-wave-menu button:disabled { opacity: 0.45; cursor: default; }
.editor-wave-menu button:disabled:hover { background: none; }
/* Громкость аудиодорожки (шапка таймлайна) */
.editor-audio-vol { display: inline-flex; align-items: center; gap: 6px; margin-left: auto; }
.editor-audio-vol[hidden] { display: none; }
.editor-audio-vol .eav-ico { font-size: 14px; }
.editor-audio-vol input[type=range] { width: 92px; accent-color: var(--accent, #0071e3); cursor: pointer; }
.editor-audio-vol .eav-val { font-size: 11px; color: var(--muted, #888); min-width: 36px; font-variant-numeric: tabular-nums; }

/* ── Управление аудиодорожкой (шапка таймлайна) ───────────────────────── */
.editor-tl-audio { display: inline-flex; align-items: center; gap: 5px; margin-left: 14px; font-size: 11px; }
.editor-tl-audio .tlA-label { color: var(--muted, #888); }
.editor-tl-audio .tlA-name { color: var(--ink, #1d1d1f); font-weight: 600; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.editor-tl-audio .tlA-btn {
  border: 1px solid var(--border, rgba(0, 0, 0, 0.12)); background: var(--page-bg); color: var(--ink, #1d1d1f);
  border-radius: 6px; padding: 2px 8px; font-size: 11px; cursor: pointer; font-family: inherit; line-height: 1.5;
}
.editor-tl-audio .tlA-btn:hover { border-color: var(--accent, #0071e3); }
.editor-tl-audio .tlA-btn.danger { color: var(--c-danger); }
.editor-tl-audio .tlA-btn[hidden] { display: none; }

/* Пустая аудиодорожка (плейсхолдер — видно, что место под аудио есть) */
.editor-audio-empty {
  position: absolute; left: 0; right: 0; bottom: 6px;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  border: 1px dashed var(--border, rgba(0, 0, 0, 0.18)); border-radius: 6px;
  background: repeating-linear-gradient(45deg, rgba(0, 0, 0, 0.014) 0 8px, transparent 8px 16px);
  color: var(--muted, #888); font-size: 12px; z-index: 2;
}
.editor-audio-empty[hidden] { display: none; }
.editor-audio-empty .editor-btn { padding: 3px 10px; font-size: 11px; }

/* Модалка «Библиотека аудио» */
.editor-audio-lib-overlay { position: fixed; inset: 0; z-index: 10001; background: rgba(0, 0, 0, 0.4); display: flex; align-items: center; justify-content: center; }
.editor-audio-lib-overlay[hidden] { display: none; }
.editor-audio-lib { width: min(680px, 92vw); max-height: 80vh; display: flex; flex-direction: column; background: var(--ed-surface, #fff); border-radius: 14px; box-shadow: 0 24px 60px rgba(0, 0, 0, 0.3); overflow: hidden; }
.eal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.eal-head h3 { margin: 0; font-size: 16px; color: var(--ink); }
.eal-head button { border: none; background: none; font-size: 18px; cursor: pointer; color: var(--muted); }
.eal-toolbar { display: flex; gap: 10px; padding: 12px 18px; align-items: center; }
.eal-toolbar input[type=search] { flex: 1; padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; font: inherit; background: var(--page-bg); color: var(--ink); }
.eal-toolbar select.eal-sort { flex: 0 0 auto; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font: inherit; background: var(--page-bg); color: var(--ink); cursor: pointer; }
/* Вкладки «Мои треки» / «Библиотека» */
.eal-tabs { display: flex; gap: 4px; padding: 0 18px; border-bottom: 1px solid var(--border); }
.eal-tab { padding: 9px 14px; border: none; background: none; font: inherit; font-weight: 600; font-size: 13px; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.eal-tab:hover { color: var(--ink); }
.eal-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.eal-list { list-style: none; margin: 0; padding: 10px 14px 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; flex: 1; min-height: 0; }
.eal-row { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--page-bg); cursor: pointer; transition: border-color .12s, box-shadow .12s, background .12s; }
.eal-row:hover { border-color: var(--accent); }
.eal-row.playing { border-color: var(--accent); }
/* Выбранный трек — кандидат на «Добавить на таймлайн» (галочка слева) */
.eal-row.selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); background: rgba(0, 113, 227, 0.06); }
.eal-row.selected .eal-name::before { content: "✓ "; color: var(--accent); font-weight: 800; }
/* Мини-плеер: слушать/пауза, стоп, заново */
.eal-player { display: flex; align-items: center; gap: 1px; flex: 0 0 auto; }
.eal-player button { border: none; background: none; cursor: pointer; color: var(--accent); width: 26px; height: 26px; border-radius: 6px; font-size: 13px; line-height: 1; display: inline-flex; align-items: center; justify-content: center; }
.eal-player button:hover { background: var(--c-neutral-100); }
.eal-player .eal-pp { font-size: 13px; }
.eal-wave { width: 180px; height: 28px; flex: 0 0 auto; background: var(--surface, #fff); border-radius: 4px; }
.eal-info { flex: 1; min-width: 0; }
.eal-name { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); }
.eal-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 3px; }
.eal-tag { font-size: 10px; padding: 1px 7px; border-radius: 999px; background: var(--c-neutral-100); color: var(--muted); white-space: nowrap; }
.eal-tag.mood { background: rgba(88, 86, 214, 0.12); color: #5856d6; }
.eal-tag.tempo { background: rgba(52, 199, 89, 0.14); color: #1f9d4d; }
.eal-tag.dur { background: rgba(0, 113, 227, 0.12); color: var(--accent); }
/* Подвал модалки: подсказка о выбранном треке + «Добавить на таймлайн» */
.eal-foot { display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-top: 1px solid var(--border); background: var(--ed-surface, #fff); }
.eal-foot-sel { flex: 1; min-width: 0; font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.eal-foot-sel.has-sel { color: var(--ink); font-weight: 600; }
.eal-foot-actions { display: flex; gap: 8px; flex: 0 0 auto; }
#eal-add-to-timeline:disabled { opacity: .45; cursor: not-allowed; }

/* ── Редакция local|web (config.js → html.edition-web|local) ──────────────
   .local-only — студийные фичи (автогенератор, серверный рендер, alignment):
   скрыты в web. .web-only — браузерный экспорт: скрыт в local. См. EDITIONS.md. */
html.edition-web .local-only { display: none !important; }
html:not(.edition-web) .web-only { display: none !important; }
.eal-empty { color: var(--muted); padding: 24px 12px; text-align: center; font-size: 13px; line-height: 1.5; }
.eal-empty { grid-column: 1 / -1; text-align: center; color: var(--muted); padding: 28px 16px; font-size: 13px; line-height: 1.5; }

/* Статус: справа от групп через margin-left:auto, но НЕ создаёт пустоту
   если в нём нет текста (visually invisible until populated). */
.editor-toolbar .editor-status {
  margin-left: auto;
  padding: 0 8px;
  font-size: 11px;
  color: var(--c-neutral-500);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 260px;
}
/* Когда статус пуст — скрыт полностью, чтобы groups+cmdk были плотно
   прижаты. Cmd+K сам имеет margin-left:auto (правило ниже). */
.editor-toolbar .editor-status:empty {
  display: none;
}
/* Cmd+K кнопка всегда прижата к правому краю независимо от editor-status. */
.editor-toolbar .editor-btn-ghost {
  margin-left: auto;
}

/* Ghost-кнопка (Cmd+K в самом правом краю) — без border, только при hover. */
.editor-btn.editor-btn-ghost {
  border-color: transparent;
  background: transparent;
  color: var(--c-neutral-500);
}
.editor-btn.editor-btn-ghost:hover {
  background: var(--c-neutral-100);
  border-color: transparent;
  color: var(--c-neutral-800);
}

/* ── 3-pane grid: assets | canvas | inspector ─────────────────────────── */

.editor-grid {
  display: grid;
  grid-template-columns: var(--assets-w, 180px) 4px 1fr 4px var(--inspector-w, 220px);
  gap: 0;
  flex: 1;
  min-height: 0;
}

/* ── Splitter — drag-перетаскивание границ панелей с magnet-snap ─────── */

.editor-splitter {
  background: transparent;
  position: relative;
  z-index: 5;
  transition: background 100ms var(--ease-quick);
}
.editor-splitter:hover,
.editor-splitter.active {
  background: rgba(0, 113, 227, 0.35);
}
.editor-splitter-v {
  width: 4px;
  cursor: ew-resize;
}
.editor-splitter-v::before {
  content: "";
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 2px;
  height: 32px;
  background: var(--border-strong);
  border-radius: 2px;
}
.editor-splitter-h {
  height: 4px;
  cursor: ns-resize;
  flex-shrink: 0;
  margin: 0;
}
.editor-splitter-h::before {
  content: "";
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  height: 2px;
  width: 32px;
  background: var(--border-strong);
  border-radius: 2px;
}

.editor-pane {
  background: var(--ed-surface);
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04),
              0 1px 2px rgba(0, 0, 0, 0.03);
}

.editor-pane-header {
  padding: 6px 10px;
  font-size: 10px;
  font-weight: 600;
  color: var(--c-neutral-500);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--c-neutral-100);
  background: var(--c-neutral-50);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.editor-pane-body {
  padding: 6px;
  overflow: auto;
  flex: 1;
}

/* ── Assets pane (left) ──────────────────────────────────────────────── */

.editor-assets-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
}

.editor-asset-tile {
  position: relative;  /* anchor для ✕ */
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 4px 2px;
  background: var(--page-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: grab;
  text-align: center;
  font-size: 9px;
  color: var(--muted);
  word-break: break-all;
  line-height: 1.05;
  transition: border-color 120ms var(--ease-quick), transform 120ms var(--ease-quick);
}
.editor-asset-tile:hover { border-color: var(--accent); transform: translateY(-1px); }
.editor-asset-tile:active { cursor: grabbing; }

/* Кнопка ✕ — только админу (body.sp-admin), появляется при hover на ассет.
   Не-админ видит общую библиотеку, но удалять из неё не может (бэк = 403),
   поэтому и кнопку ему не показываем. */
.editor-asset-delete {
  display: none;            /* по умолчанию скрыта; админу включаем ниже */
  -webkit-appearance: none;
  appearance: none;
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  padding: 0;
  background: rgba(220, 38, 38, 0.92);
  color: #fff;
  border: 0;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 100ms ease, transform 100ms ease, background 100ms ease;
  z-index: 5;
}
body.sp-admin .editor-asset-delete { display: block; }   /* удаление — только админу */
.editor-asset-tile:hover .editor-asset-delete { opacity: 1; }

/* Рамка-лассо (мультивыделение по пустому холсту, как Figma/PowerPoint). */
.editor-marquee {
  position: fixed;
  z-index: 9999;
  border: 1.5px solid var(--accent, #0071E3);
  background: rgba(0, 113, 227, 0.12);
  border-radius: 2px;
  pointer-events: none;
}
/* Мульти-выделение (>1): показываем только рамки, ручки resize/rotate прячем —
   групповой перенос поддержан, групповой ресайз/поворот пока нет. */
.editor-scene.selected.multi .editor-scene-handle,
.editor-scene.selected.multi .editor-rotate-handle { display: none !important; }

/* Групповая рамка (одна на всё мульти-выделение): масштаб (4 угла) + поворот. */
.editor-group-box {
  position: absolute;
  pointer-events: none;            /* саму рамку не цепляем — только ручки */
  outline: 2px dashed var(--accent, #0071E3);
  outline-offset: 2px;
  z-index: 200;
}
.editor-group-handle {
  position: absolute;
  width: calc(var(--handle-screen, 14px) * var(--inv-scale, 1));
  height: calc(var(--handle-screen, 14px) * var(--inv-scale, 1));
  background: #fff;
  border: calc(2px * var(--inv-scale, 1)) solid var(--accent, #0071E3);
  border-radius: 50%;
  pointer-events: auto;
  cursor: nwse-resize;
}
.editor-group-handle.handle-nw { left: 0; top: 0; transform: translate(-50%, -50%); }
.editor-group-handle.handle-ne { right: 0; top: 0; transform: translate(50%, -50%); cursor: nesw-resize; }
.editor-group-handle.handle-se { right: 0; bottom: 0; transform: translate(50%, 50%); }
.editor-group-handle.handle-sw { left: 0; bottom: 0; transform: translate(-50%, 50%); cursor: nesw-resize; }
.editor-group-rotate {
  position: absolute;
  left: 50%; top: 0;
  width: calc(var(--handle-screen, 14px) * var(--inv-scale, 1));
  height: calc(var(--handle-screen, 14px) * var(--inv-scale, 1));
  transform: translate(-50%, calc(-180% * var(--inv-scale, 1)));
  background: var(--accent, #0071E3);
  border: calc(2px * var(--inv-scale, 1)) solid #fff;
  border-radius: 50%;
  pointer-events: auto;
  cursor: grab;
}
.editor-asset-delete:hover {
  background: rgba(220, 38, 38, 1);
  transform: scale(1.15);
}
.editor-asset-tile img,
.editor-asset-tile svg {
  width: 40px;
  height: 40px;
  object-fit: contain;
}

/* Поисковая строка + кнопка загрузки рядом. !important чтобы старые
   правила .editor-asset-search { width: 100% } не перебивали flex:1. */
.editor-asset-search-row {
  display: flex !important;
  gap: 4px !important;
  margin: 0 0 4px !important;
  align-items: stretch !important;
  width: 100% !important;
}
.editor-asset-search-row .editor-asset-search {
  flex: 1 1 auto !important;
  width: auto !important;
  margin: 0 !important;
  padding: 4px 8px;
  font-family: inherit;
  font-size: 11px;
  background: var(--ed-surface);
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  outline: none;
  min-width: 0;  /* позволяет input ужиматься в flex */
}
.editor-asset-search-row .editor-asset-search:focus {
  border-color: var(--c-accent);
}
/* fallback правило (если row не применилось — input один в строке) */
.editor-asset-search {
  width: 100%;
  margin: 0 0 4px;
  padding: 4px 8px;
  font-family: inherit;
  font-size: 11px;
  background: var(--ed-surface);
  border: 1px solid var(--border-strong);
  border-radius: 4px;
}

/* Кнопка [↑] для загрузки своих картинок — text-fallback "↑" если
   Lucide иконка не подгрузится. */
.editor-asset-upload-btn {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  width: 32px !important;
  min-width: 32px;
  height: 26px;
  padding: 0;
  background: var(--c-accent);
  border: 1px solid var(--c-accent);
  border-radius: 4px;
  cursor: pointer;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  transition: background 120ms var(--ease-quick),
              border-color 120ms var(--ease-quick);
  flex-shrink: 0;
}
.editor-asset-upload-btn:hover {
  background: var(--c-accent-hover);
  border-color: var(--c-accent-hover);
  color: #fff;
}
.editor-asset-upload-btn i[data-lucide],
.editor-asset-upload-btn svg.lucide {
  width: 14px;
  height: 14px;
  margin: 0;
  stroke-width: 2.5;
  color: #fff;
}

/* Drag&Drop оверлей на pane Ассеты — подсветка во время dragover. */
#editor-pane-assets.dropzone-active {
  position: relative;
}
#editor-pane-assets.dropzone-active::after {
  content: "↓ Отпусти чтобы загрузить";
  position: absolute;
  inset: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 113, 227, 0.08);
  border: 3px dashed var(--c-accent);
  border-radius: 8px;
  font-size: 14px;
  font-weight: 700;
  color: var(--c-accent);
  pointer-events: none;
  z-index: 50;
}

/* Модалка выбора категории при upload */
.editor-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: cmdk-fadein 120ms ease-out;
}
.editor-modal {
  width: min(560px, 96vw);
  max-height: 80vh;
  overflow-y: auto;
  background: var(--ed-surface);
  border-radius: 12px;
  padding: 22px 24px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.25);
  /* мягкий вход окна (не только затемнение фона) — «премиальное» ощущение */
  animation: modal-pop 180ms var(--ease-apple, cubic-bezier(0.32, 0.72, 0, 1));
}
@keyframes modal-pop {
  from { opacity: 0; transform: translateY(10px) scale(0.975); }
  to   { opacity: 1; transform: none; }
}
/* Единое кольцо фокуса для клавиатурной навигации (доступность + полировка) —
   показывается ТОЛЬКО при :focus-visible (клавиатура), не по клику мышью. */
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible,
textarea:focus-visible, [tabindex]:focus-visible, .editor-btn:focus-visible,
.hub-trash-btn:focus-visible, .app-tab:focus-visible {
  outline: 2px solid var(--accent, #0071e3);
  outline-offset: 2px;
  border-radius: 6px;
}
/* Уважаем «меньше движения» — гасим вход модалок для таких пользователей. */
@media (prefers-reduced-motion: reduce) {
  .editor-modal, .editor-modal-overlay { animation: none !important; }
}

/* ── Скелетоны загрузки (вместо «Загрузка…») — современный неотрывный UX ── */
@keyframes sp-shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.sp-skel {
  background: linear-gradient(90deg,
    var(--c-neutral-100) 25%, var(--c-neutral-200) 37%, var(--c-neutral-100) 63%);
  background-size: 200% 100%;
  animation: sp-shimmer 1.3s ease-in-out infinite;
  border-radius: 8px;
}
.sp-skel-card {
  border: 1px solid var(--c-neutral-200);
  border-radius: 10px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sp-skel.line { height: 12px; border-radius: 6px; }
@media (prefers-reduced-motion: reduce) { .sp-skel { animation: none; } }

/* ── Интерактивный тур по редактору (coachmarks: прожектор + подсказка) ── */
#sp-tour { position: fixed; inset: 0; z-index: 12000; pointer-events: none; }
#sp-tour .sp-tour-spot {
  position: absolute; border-radius: 10px;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.55);
  outline: 2px solid var(--accent, #0071e3); outline-offset: 0;
  transition: all 240ms var(--ease-apple, cubic-bezier(0.32, 0.72, 0, 1));
}
#sp-tour .sp-tour-tip {
  position: absolute; width: 300px; max-width: 92vw;
  background: var(--ed-surface, #fff); color: var(--ink, #1d1d1f);
  border: 1px solid var(--border, #e6e6e6); border-radius: 12px; padding: 14px 16px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.34); pointer-events: auto;
  transition: top 240ms var(--ease-apple, ease), left 240ms var(--ease-apple, ease);
}
#sp-tour .sp-tour-tip h4 { margin: 0 0 6px; font-size: 15px; font-weight: 700; }
#sp-tour .sp-tour-tip p { margin: 0 0 12px; font-size: 13px; color: var(--muted, #86868b); line-height: 1.5; }
#sp-tour .sp-tour-row { display: flex; align-items: center; gap: 8px; }
#sp-tour .sp-tour-count { font-size: 12px; color: var(--muted, #86868b); margin-right: auto; }
@media (prefers-reduced-motion: reduce) { #sp-tour .sp-tour-spot, #sp-tour .sp-tour-tip { transition: none; } }
.editor-modal h3 {
  margin: 0 0 6px;
  font-size: 16px;
  font-weight: 600;
  color: var(--c-neutral-900);
}
.editor-modal-hint {
  font-size: 12px;
  color: var(--c-neutral-500);
  margin: 0 0 16px;
  line-height: 1.5;
}
.editor-modal-hint code {
  background: var(--c-neutral-100);
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 11px;
}
/* ── Загрузчик сценария (простой JSON objects[]) ── */
.editor-modal.scn-loader { width: min(720px, 96vw); }
/* ИИ-раскадровка в загрузчике сценария */
.scn-ai { border: 1px solid #cfe0fb; background: #f4f9ff; border-radius: 12px; padding: 12px 14px; margin: 4px 0 14px; }
.scn-ai .editor-modal-hint { margin: 0 0 8px; }
.scn-ai-badge { display: inline-block; background: #0071e3; color: #fff; font-size: 10.5px; font-weight: 700;
  border-radius: 6px; padding: 1px 7px; vertical-align: middle; }
.scn-ai-topic { width: 100%; box-sizing: border-box; min-height: 56px; resize: vertical;
  font: 13px/1.45 inherit; padding: 9px 11px; border: 1px solid var(--c-neutral-200, #ddd);
  border-radius: 8px; background: #fff; color: var(--ink, #1e1e1e); margin-bottom: 9px; }
[data-app-theme="dark"] .scn-ai { background: #14243c; border-color: #1f3a5f; }
[data-app-theme="dark"] .scn-ai-topic { background: #1c1c1e; }
.scn-json {
  width: 100%; box-sizing: border-box; min-height: 150px; resize: vertical;
  font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12px;
  line-height: 1.45; padding: 10px 12px; border: 1px solid var(--c-neutral-200, #ddd);
  border-radius: 8px; background: var(--ed-app-bg-2, #fafafa); color: var(--ink, #1e1e1e);
}
.scn-row { display: flex; align-items: center; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.scn-grow { flex: 1 1 auto; }
.scn-fit { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; font-weight: 600;
  color: var(--ink, #1e1e1e); cursor: pointer; padding: 6px 10px; border-radius: 9px;
  border: 1px solid #cfe0fb; background: #f4f9ff; user-select: none; }
.scn-fit input { margin: 0; cursor: pointer; }
.scn-fit.disabled { opacity: .5; cursor: not-allowed; }
.scn-fit.disabled input { cursor: not-allowed; }
[data-app-theme="dark"] .scn-fit { background: #14243c; border-color: #1f3a5f; color: #dce8f7; }
.scn-prompt-wrap { margin-top: 14px; border-top: 1px solid var(--c-neutral-200, #eee); padding-top: 12px; }
.scn-prompt {
  max-height: 260px; overflow: auto; white-space: pre-wrap; word-break: break-word;
  font-family: ui-monospace, Menlo, monospace; font-size: 11px; line-height: 1.5;
  padding: 10px 12px; border-radius: 8px; background: var(--c-neutral-100, #f4f4f5);
  color: var(--ink, #1e1e1e); margin: 0 0 8px;
}
.scn-msg { font-size: 12px; margin: 12px 0 0; }
.scn-msg.ok { color: #16a34a; }
.scn-msg.warn { color: #d97706; }
.scn-msg.error { color: #dc2626; }
/* ── Улучшить озвучку (audio enhancer) ── */
.editor-modal.aenh { width: min(560px, 96vw); }
.aenh-src { display: flex; align-items: center; gap: 8px; margin: 4px 0 10px; flex-wrap: wrap; }
.aenh-src .editor-btn { cursor: pointer; }
.aenh-rec-time { font-variant-numeric: tabular-nums; font-size: 13px; color: #dc2626; font-weight: 600; }
#aenh-rec.recording { background: #dc2626; color: #fff; border-color: #dc2626; }
.aenh-srcname { font-size: 12px; color: var(--c-neutral-500, #777); margin-bottom: 8px; }
/* Волнограмма-плеер (источник + A/B «до/после») */
.aenh-wp { display: flex; align-items: center; gap: 9px; margin-top: 4px;
  padding: 6px 10px; background: var(--ed-app-bg-2, #f4f6fa); border-radius: 10px; }
.aenh-wp audio { display: none; }
/* Объёмная Apple-кнопка play/record: радиальный градиент + внутренний блик + мягкая тень */
.aenh-wp-play { flex: 0 0 auto; width: 36px; height: 36px; border-radius: 50%; border: 0; padding: 0; margin: 0;
  display: flex; align-items: center; justify-content: center; color: #fff; font-size: 13px; line-height: 1; cursor: pointer;
  background: radial-gradient(120% 120% at 50% 22%, #f3c074 0%, #e3a544 46%, #c8861f 100%);
  box-shadow: inset 0 1.4px .5px rgba(255,255,255,.65), inset 0 -2px 4px rgba(120,70,0,.32),
    0 4px 10px rgba(200,134,31,.42), 0 1.5px 3px rgba(0,0,0,.2);
  transition: transform .14s cubic-bezier(.2,.7,.3,1), box-shadow .14s ease, filter .14s ease; }
.aenh-wp-play:hover { transform: translateY(-1.5px); filter: saturate(1.08) brightness(1.05); }
.aenh-wp-play:active { transform: translateY(0) scale(.94);
  box-shadow: inset 0 2px 4px rgba(120,70,0,.4), 0 2px 5px rgba(200,134,31,.35); }
.aenh-wp-wave { flex: 1 1 auto; width: 100%; height: 34px; min-width: 50px; cursor: pointer; display: block; }
.aenh-wp-time { flex: 0 0 auto; font-variant-numeric: tabular-nums; font-size: 11px;
  color: var(--c-neutral-500, #777); white-space: nowrap; }
/* ИИ-улучшение текста надписи (инспектор текста) */
.text-improve { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.text-improve-btn { border: 1px solid #cfe0fb; background: #f4f9ff; color: #1f4fa3; border-radius: 7px;
  padding: 4px 9px; font-size: 11.5px; cursor: pointer; }
.text-improve-btn:hover { background: #e7f1ff; }
.text-improve-btn:disabled { opacity: .6; cursor: default; }
[data-app-theme="dark"] .text-improve-btn { background: #14243c; border-color: #1f3a5f; color: #9cc0ef; }
/* Ряд действий объекта в инспекторе (размножить / пипетка стиля) */
.inspector-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.inspector-actions .editor-btn { flex: 1 1 auto; font-size: 12px; padding: 7px 8px; }
/* Трассировка PNG→SVG */
.trace-modal { max-width: 460px; }
.trace-preview { display: flex; align-items: center; justify-content: center; margin: 10px 0; padding: 10px;
  background: #fff; border: 1px solid var(--c-neutral-200, #e6e6e6); border-radius: 10px; min-height: 180px; }
.trace-preview svg { max-width: 100%; max-height: 240px; }
[data-app-theme="dark"] .trace-preview { background: #f4f4f4; }
/* Онлайн-иконки (Iconify) */
.icons-modal { max-width: 520px; }
.icons-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; margin: 10px 0; max-height: 46vh; overflow: auto; min-height: 40px; }
.icon-cell { aspect-ratio: 1; border: 1px solid var(--c-neutral-200, #e6e6e6); border-radius: 8px; background: #fff;
  display: flex; align-items: center; justify-content: center; cursor: pointer; padding: 5px; }
.icon-cell:hover { border-color: var(--c-accent, #0071e3); background: #f4f9ff; }
.icon-cell.added { border-color: #15803d; background: #eafaef; }
.icon-cell img { width: 100%; height: 100%; object-fit: contain; }
[data-app-theme="dark"] .icon-cell { background: #1c1c1e; border-color: #3a3f4a; }
/* Брендбук */
.brand-modal { max-width: 440px; }
.brand-input { width: 100%; box-sizing: border-box; padding: 8px 10px; border: 1px solid var(--c-neutral-200, #e6e6e6);
  border-radius: 8px; background: var(--ed-app-bg-2, #f4f6fa); color: var(--ink, #1e1e1e); font: 13px ui-monospace, Menlo, monospace; }
.brand-preview { display: flex; flex-wrap: wrap; gap: 5px; margin: 8px 0; min-height: 22px; }
.brand-sw { width: 22px; height: 22px; border-radius: 5px; border: 1px solid rgba(0,0,0,.15); }
.brand-swrow { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 6px; padding-bottom: 6px; border-bottom: 1px dashed var(--c-neutral-200, #e0e0e0); }
/* Модалка «Размножить рядом» (массив объектов) */
.array-modal { max-width: 420px; }
.array-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 8px 0; }
.array-row label { font-size: 13px; color: var(--ink, #1e1e1e); }
.array-row input, .array-row select { width: 150px; padding: 7px 9px; border: 1px solid var(--c-neutral-200, #e6e6e6);
  border-radius: 8px; background: var(--ed-app-bg-2, #f4f6fa); color: var(--ink, #1e1e1e); font-size: 13px; }
.array-chk { display: flex; align-items: center; gap: 7px; font-size: 13px; margin: 8px 0; cursor: pointer; color: var(--ink, #1e1e1e); }
.array-chk input { margin: 0; }
/* Тумблер «Субтитры в видео» (лента «Рендер») */
.editor-cap-toggle { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; cursor: pointer;
  padding: 6px 9px; border: 1px solid var(--c-neutral-200, #e0e0e0); border-radius: 9px;
  background: var(--ed-app-bg-2, #f4f6fa); color: var(--ink, #1e1e1e); white-space: nowrap; user-select: none; }
.editor-cap-toggle input { margin: 0; cursor: pointer; }
[data-app-theme="dark"] .editor-cap-toggle { background: #24262b; border-color: #3a3f4a; color: #e6e6e6; }
/* Синтез голоса (TTS) в окне «Озвучить» */
.aenh-tts { border: 1px solid #cfe0fb; background: #f4f9ff; border-radius: 11px; padding: 10px 12px; margin: 4px 0 12px; }
[data-app-theme="dark"] .aenh-tts { background: #14243c; border-color: #1f3a5f; }
.aenh-tts-h { font-size: 12.5px; font-weight: 600; color: var(--ink, #1e1e1e); margin-bottom: 7px; display: flex; align-items: center; gap: 6px; }
.aenh-tts textarea { width: 100%; box-sizing: border-box; min-height: 54px; resize: vertical; margin-bottom: 7px; }
.aenh-tts-row { display: flex; gap: 7px; align-items: center; flex-wrap: wrap; }
.aenh-tts-row .editor-select { padding: 7px 9px; }
.aenh-steps { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 16px; margin: 12px 0; }
.aenh-steps label { display: flex; align-items: center; gap: 7px; font-size: 13px; cursor: pointer; color: var(--ink, #1e1e1e); }
.aenh-actions { display: flex; align-items: center; gap: 8px; }
.aenh-grow { flex: 1 1 auto; }
.aenh-result { margin-top: 14px; border-top: 1px solid var(--c-neutral-200, #eee); padding-top: 12px; }
.aenh-ab { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.aenh-ab-lbl { font-size: 12px; font-weight: 600; color: var(--c-neutral-500, #777); margin-bottom: 2px; }
/* Идёт запись: объёмная красная Apple record-кнопка (tap = стоп) с дышащим ореолом + белый стоп-квадрат */
.aenh-wp.recording .aenh-wp-play { cursor: pointer; pointer-events: auto; font-size: 0;
  background: radial-gradient(120% 120% at 50% 22%, #ff8a8a 0%, #f4524f 46%, #cc1f1f 100%);
  box-shadow: inset 0 1.4px .5px rgba(255,255,255,.6), inset 0 -2px 4px rgba(120,0,0,.4),
    0 0 0 0 rgba(244,82,79,.5), 0 4px 12px rgba(220,38,38,.5), 0 1.5px 3px rgba(0,0,0,.22);
  animation: aenh-rec-halo 1.5s ease-in-out infinite; }
.aenh-wp.recording .aenh-wp-play::before { content: ""; width: 11px; height: 11px; border-radius: 3px;
  background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.28); }
.aenh-wp.recording .aenh-wp-time { color: #dc2626; font-weight: 600; font-size: 12px; }
@keyframes aenh-rec-halo {
  0%, 100% { box-shadow: inset 0 1.4px .5px rgba(255,255,255,.6), inset 0 -2px 4px rgba(120,0,0,.4), 0 0 0 0 rgba(244,82,79,.5), 0 4px 12px rgba(220,38,38,.5), 0 1.5px 3px rgba(0,0,0,.22); }
  50% { box-shadow: inset 0 1.4px .5px rgba(255,255,255,.6), inset 0 -2px 4px rgba(120,0,0,.4), 0 0 0 7px rgba(244,82,79,.12), 0 5px 15px rgba(220,38,38,.55), 0 1.5px 3px rgba(0,0,0,.22); }
}
/* «Поканеактивная» красная кнопка записи (idle): мягкий красный record-кружок с белой
   точкой, без ореола — стоит слева от пустой полоски-волнограммы сразу при открытии. */
.aenh-wp.idle-rec .aenh-wp-play { cursor: pointer; pointer-events: auto; font-size: 0;
  background: radial-gradient(120% 120% at 50% 22%, #ff9a9a 0%, #ef6a6a 48%, #d83a3a 100%);
  box-shadow: inset 0 1.4px .5px rgba(255,255,255,.55), inset 0 -2px 4px rgba(120,0,0,.3),
    0 3px 8px rgba(220,38,38,.3), 0 1.5px 3px rgba(0,0,0,.18); }
.aenh-wp.idle-rec .aenh-wp-play::before { content: ""; width: 12px; height: 12px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.22); }
.aenh-wp.idle-rec .aenh-wp-play:hover { transform: translateY(-1.5px); filter: brightness(1.05); }
.aenh-wp.idle-rec .aenh-wp-play:active { transform: translateY(0) scale(.94); }
/* Список сохранённых записей (живут 24 ч в браузере, голос не уходит на сервер) */
.aenh-recs { margin-top: 14px; border-top: 1px solid var(--c-neutral-200, #eee); padding-top: 10px; }
.aenh-recs-h { font-size: 12px; font-weight: 600; color: var(--c-neutral-500, #777); margin-bottom: 6px; }
.aenh-recs-list { display: flex; flex-direction: column; gap: 5px; max-height: 168px; overflow-y: auto; }
.aenh-rec-row { display: flex; align-items: center; gap: 6px; }
.aenh-rec-pick { flex: 1 1 auto; margin: 0; display: flex; align-items: center; gap: 6px; text-align: left;
  padding: 6px 10px; border: 1px solid var(--c-neutral-200, #e6e6e6); border-radius: 8px;
  background: var(--ed-app-bg-2, #f4f6fa); color: var(--ink, #1e1e1e); font-size: 13px; cursor: pointer; }
.aenh-rec-pick:hover { border-color: #e0a03c; background: #fff7ec; }
.aenh-rec-meta { color: var(--c-neutral-500, #999); font-size: 11px; font-variant-numeric: tabular-nums; }
.aenh-rec-del { flex: 0 0 auto; margin: 0; width: 30px; height: 30px; border: 1px solid var(--c-neutral-200, #e6e6e6);
  border-radius: 8px; background: #fff; cursor: pointer; font-size: 13px; color: #b4232a; }
.aenh-rec-del:hover { background: #fdecec; border-color: #f0b4b4; }
.editor-modal-cats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 6px;
  margin-bottom: 18px;
  max-height: 240px;
  overflow-y: auto;
}
.editor-modal-cat {
  -webkit-appearance: none;
  appearance: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 10px 6px;
  background: var(--c-neutral-50);
  border: 1px solid var(--c-neutral-200);
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  font-size: 11px;
  font-weight: 500;
  color: var(--c-neutral-800);
  transition: background 100ms ease, border-color 100ms ease, color 100ms ease;
}
.editor-modal-cat > span:first-child { font-size: 22px; line-height: 1; }
.editor-modal-cat .cat-count {
  font-size: 9px;
  color: var(--c-neutral-500);
  font-variant-numeric: tabular-nums;
}
.editor-modal-cat:hover {
  background: var(--ed-surface);
  border-color: var(--c-accent);
  color: var(--c-neutral-900);
}

.editor-modal-newcat {
  display: flex;
  gap: 6px;
  align-items: center;
  padding: 14px 0;
  border-top: 1px solid var(--c-neutral-100);
  flex-wrap: wrap;
}
.editor-modal-newcat label {
  font-size: 12px;
  color: var(--c-neutral-700);
  font-weight: 500;
  white-space: nowrap;
}
.editor-modal-newcat input {
  flex: 1 1 180px;
  height: 32px;
  padding: 0 10px;
  font-family: inherit;
  font-size: 13px;
  background: var(--ed-surface);
  border: 1px solid var(--c-neutral-300);
  border-radius: 6px;
  outline: none;
}
.editor-modal-newcat input:focus { border-color: var(--c-accent); }

.editor-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  padding-top: 6px;
}

/* ── Render-progress modal (экспорт MP4) ─────────────────────────────────── */
.render-overlay {
  position: fixed;
  inset: 0;
  z-index: 4000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.5);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}
.render-overlay[hidden] { display: none; }
.render-modal {
  width: min(440px, calc(100vw - 32px));
  background: var(--ed-surface);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-3, 0 16px 40px rgba(0, 0, 0, 0.35));
  overflow: hidden;
}
.render-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.render-modal-head h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.render-modal-head h3 svg.lucide { width: 18px; height: 18px; }
.render-modal-close {
  background: transparent;
  border: 0;
  color: var(--muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  display: inline-flex;
}
.render-modal-close:hover { background: var(--ed-app-bg-2); color: var(--ink); }
.render-modal-body { padding: 20px 18px 8px; text-align: center; }

.render-stage {
  width: 56px;
  height: 56px;
  margin: 0 auto 12px;
  position: relative;
}
.render-stage svg.lucide { width: 56px; height: 56px; }
.render-spinner { color: var(--accent, #0071e3); animation: render-spin 1s linear infinite; }
.render-check { color: #34c759; display: none; }
.render-cross { color: #ff3b30; display: none; }
.render-stage[data-state="done"] .render-spinner,
.render-stage[data-state="error"] .render-spinner { display: none; }
.render-stage[data-state="done"] .render-check { display: block; }
.render-stage[data-state="error"] .render-cross { display: block; }
@keyframes render-spin { to { transform: rotate(360deg); } }

.render-phase {
  margin: 0 0 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  min-height: 18px;
}
.render-bar {
  height: 8px;
  background: var(--ed-app-bg-2);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.render-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #0071e3, #34c759);
  border-radius: 999px;
  transition: width 0.3s ease;
}
.render-modal[data-state="error"] .render-fill { background: #ff3b30; }
.render-meta {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--muted);
  margin-top: 6px;
  font-variant-numeric: tabular-nums;
}
.render-note {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-start;
  margin: 16px 0 4px;
  padding: 8px 10px;
  font-size: 12px;
  color: var(--ink-2, var(--muted));
  background: var(--ed-app-bg-2);
  border-radius: 8px;
  text-align: left;
}
.render-note svg.lucide { width: 15px; height: 15px; flex-shrink: 0; color: var(--accent, #0071e3); }
.render-note.is-error { color: #ff3b30; }
.render-note.is-error svg.lucide { color: #ff3b30; }
.render-modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 16px 16px;
}

/* Большая кнопка в empty-state Uploads — основной CTA */
.editor-uploads-upload-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  margin: 12px 0 8px;
  background: var(--c-accent);
  border: 1px solid var(--c-accent);
  border-radius: 6px;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 120ms var(--ease-quick);
}
.editor-uploads-upload-btn:hover {
  background: var(--c-accent-hover);
  border-color: var(--c-accent-hover);
}

/* Empty-state в категории Uploads и Recent. */
.editor-uploads-empty {
  padding: 24px 12px;
  text-align: center;
  font-size: 12px;
  color: var(--c-neutral-500);
  line-height: 1.5;
}
.editor-uploads-empty p { margin: 0 0 8px; }
.editor-uploads-empty .hint {
  font-size: 11px;
  color: var(--c-neutral-400);
}
.editor-uploads-empty i[data-lucide],
.editor-uploads-empty svg.lucide {
  width: 13px;
  height: 13px;
  vertical-align: -2px;
  stroke-width: 2;
  color: var(--c-neutral-700);
}
.editor-uploads-empty code {
  background: var(--c-neutral-100);
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 10px;
}

/* ── Category chips (VideoScribe-style) ──────────────────────────────── */

/* Категории — сетка квадратиков 3 в ряд. Compact: иконка сверху, лейбл
   и счётчик внизу, всё в одной плашке-квадрате. */
.editor-asset-chips {
  display: grid !important;
  grid-template-columns: repeat(3, 1fr) !important;
  gap: 10px !important;        /* отступ между плашками, чтобы не налезали */
  margin: 0 0 6px !important;
  max-height: 260px;
  overflow-y: auto;
  padding: 3px 2px;
}
.asset-chip {
  -webkit-appearance: none;
  appearance: none;
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
  aspect-ratio: 1 / 1;
  padding: 4px 2px !important;
  font-family: inherit;
  font-size: 9px;
  font-weight: 600;
  background: var(--c-neutral-50);
  border: 1px solid var(--c-neutral-200);
  border-radius: 8px;
  cursor: pointer;
  color: var(--c-neutral-700);
  white-space: normal;
  text-align: center;
  line-height: 1.15;
  letter-spacing: -0.005em;
  gap: 2px;
  transition: background 100ms var(--ease-quick),
              border-color 100ms var(--ease-quick),
              color 100ms var(--ease-quick),
              box-shadow 100ms var(--ease-quick);
  overflow: hidden;
}
/* Только значок по центру плашки. Подпись и счётчик — в тултипе (title),
   видны при наведении мышкой. */
.asset-chip .chip-icon {
  font-size: 30px;
  line-height: 1;
}
.asset-chip .chip-label,
.asset-chip .chip-count {
  display: none !important;
}
.asset-chip:hover {
  background: var(--ed-surface);
  border-color: var(--c-neutral-300);
  color: var(--c-neutral-900);
}
.asset-chip.active {
  background: var(--c-accent) !important;
  border-color: var(--c-accent) !important;
  color: #fff !important;
  box-shadow: 0 1px 3px rgba(0, 113, 227, 0.25);
}
.asset-chip.active .chip-count { color: rgba(255, 255, 255, 0.85); }

/* ── SVG color swatches в инспекторе ─────────────────────────────────── */

.svg-color-swatches {
  display: grid;
  grid-template-columns: repeat(12, 1fr);  /* 11 цветов + ∅ (сброс на библиотеку) */
  gap: 3px;
  padding: 4px 0;
}
/* ∅ — «цвет из библиотеки» (сброс перекраски канала) */
.svg-color-swatch.swatch-none {
  background: var(--page-bg);
  color: var(--muted);
  font-size: 11px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.svg-color-swatch {
  aspect-ratio: 1 / 1;
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  padding: 0;
  transition: transform 100ms var(--ease-quick);
}
.svg-color-swatch:hover { transform: scale(1.1); }
.svg-color-swatch.active {
  box-shadow: 0 0 0 2px var(--accent);
  transform: scale(1.08);
}

/* ── Canvas pane (center) ────────────────────────────────────────────── */

/* Холст занимает всё рабочее поле — один цвет, без serого канта/точек.
   Цвет берётся из --canvas-bg (управляется инспектором «Фон холста»). */
.editor-canvas-wrap {
  position: relative;
  padding: 0;
  background-color: var(--canvas-bg, #fdfaf2);
  background-image: none;
  flex: 1;
  overflow: hidden;
  /* По умолчанию курсор «grab» — намёк что можно зажать ЛКМ и тащить.
     Сцены/ручки переопределяют на свои cursor'ы. */
  cursor: grab;
}
.editor-canvas-wrap[data-pan="active"] { cursor: grabbing !important; }

/* ── PREVIEW MODE (нажата «Превью») ── холст показывает ровно то, что попадёт
   в MP4: letterbox-рамка камеры по центру + скрыт весь дизайн-хром. */
.editor-canvas-wrap.preview-on {
  background: #14141a;            /* тёмные поля вокруг кадра (letterbox) */
  cursor: default;
}
.editor-canvas-wrap.preview-on .editor-canvas-frame {
  box-shadow: 0 10px 44px rgba(0, 0, 0, 0.5);
  border-radius: 2px;
}
.editor-canvas-wrap.preview-on .editor-camera-scene,
.editor-canvas-wrap.preview-on .editor-scene-handle,
.editor-canvas-wrap.preview-on .editor-rotate-handle,
.editor-canvas-wrap.preview-on #editor-minimap,
.editor-canvas-wrap.preview-on #editor-scroll-h,
.editor-canvas-wrap.preview-on #editor-scroll-v {
  display: none !important;
}
.editor-canvas-wrap.preview-on .editor-scene.selected {
  outline: none !important;
  filter: none !important;
}

/* Кастомные скроллбары — горизонтальный сверху, вертикальный справа.
   Появляются автоматически когда world-контент шире/выше viewport (зум). */
.editor-scroll {
  position: absolute;
  background: rgba(0, 0, 0, 0.04);
  z-index: 20;
  display: none;
  user-select: none;
}
.editor-scroll[data-active="1"] { display: block; }
.editor-scroll-h {
  top: 0;
  left: 0;
  right: 10px;  /* оставляем угол под вертикальную */
  height: 10px;
}
.editor-scroll-v {
  top: 0;
  right: 0;
  bottom: 10px;
  width: 10px;
}
.editor-scroll-thumb {
  position: absolute;
  background: rgba(0, 0, 0, 0.28);
  border-radius: 5px;
  transition: background 100ms ease;
  cursor: grab;
}
.editor-scroll-thumb:hover { background: rgba(0, 0, 0, 0.45); }
.editor-scroll-thumb:active { background: rgba(0, 0, 0, 0.55); cursor: grabbing; }
.editor-scroll-h .editor-scroll-thumb {
  top: 1px; bottom: 1px;
  min-width: 24px;
}
.editor-scroll-v .editor-scroll-thumb {
  left: 1px; right: 1px;
  min-height: 24px;
}

/* Frame — это visual-size обёртка. В world-mode заполняет весь wrap, не
   ограничивает canvas — canvas position'ится через transform-translate. */
.editor-canvas-frame {
  position: absolute;
  inset: 0;
  overflow: visible;
}

#editor-canvas {
  position: absolute;
  top: 0;
  left: 0;
  background-color: var(--canvas-bg, #fdfaf2);
  background-image: none;
  transform-origin: top left;
  overflow: visible;
  /* border убран — wrap и canvas одного цвета, visual seam не нужен */
  border: 0;
}

/* Editor scenes use the SAME class names as the player (.scene, .scene-text,
   .scene-raster, .scene-draw_svg) so styles.css / styles_hype.css apply.
   We add .editor-scene for draggability + selection state. */
.editor-scene {
  position: absolute;
  cursor: move;
  user-select: none;
  -webkit-user-drag: none;
  outline: 2px dashed transparent;
  outline-offset: 4px;
  transition: outline-color 120ms var(--ease-quick);
}
.editor-scene:hover { outline-color: rgba(0, 113, 227, 0.4); }
.editor-scene.selected {
  outline-color: var(--accent);
  outline-style: solid;
  outline-width: 3px;
  z-index: 100;  /* поверх всех overlap'ающих сцен — drag доступен всегда */
  filter: drop-shadow(0 0 8px rgba(0, 113, 227, 0.6));
}
.editor-scene.editor-camera-scene.selected {
  outline-color: #ff39a4;
  filter: drop-shadow(0 0 12px rgba(255, 57, 164, 0.7));
}
/* Группа: фиолетовое кольцо-метка (box-shadow, чтобы не конфликтовать с outline
   выделения/ховера). Видно сразу, что объект в группе и двигается со «своими». */
.editor-scene.grouped {
  box-shadow: 0 0 0 2px rgba(124, 92, 224, 0.55);
  border-radius: 3px;
}
.editor-scene.grouped.selected {
  box-shadow: 0 0 0 2px rgba(124, 92, 224, 0.9);
}

/* Дети сцены (img/svg/text) НЕ должны перехватывать mousedown — иначе native
   HTML5 drag блокирует наш custom drag (курсор no-entry, mousedown не идёт).
   pointer-events:none пробрасывает событие на родительский .editor-scene. */
.editor-scene > svg,
.editor-scene > img {
  pointer-events: none;
  -webkit-user-drag: none;
  user-select: none;
}
.editor-scene.dragging {
  cursor: grabbing;
  outline-color: var(--accent) !important;
  outline-style: solid !important;
}

/* Hand drag indicator for image assets being dragged from sidebar */
#editor-canvas.drop-target {
  outline: 3px dashed var(--accent);
  outline-offset: -8px;
}

/* ── Inspector pane (right) ──────────────────────────────────────────── */

.editor-inspector-empty {
  font-size: 12px;
  color: var(--c-neutral-500);
  text-align: center;
  padding: 24px 8px;
}

/* Подсказка под палитрой фона: «Кликни сцену…» — тонкая, лево-выровненная. */
.editor-inspector-hint {
  font-size: 11px;
  color: var(--c-neutral-500);
  line-height: 1.5;
  margin: 4px 0 12px;
  padding: 8px 10px;
  background: var(--c-neutral-50);
  border-radius: 6px;
  border-left: 2px solid var(--c-neutral-200);
}

/* Lucide-иконки в <summary> разделов инспектора — иконка слева от названия. */
.editor-pane-body summary i[data-lucide],
.editor-pane-body summary svg.lucide {
  width: 13px;
  height: 13px;
  vertical-align: -2px;
  margin-right: 6px;
  stroke-width: 2;
  color: var(--c-neutral-500);
}

.editor-field {
  margin-bottom: 6px;
}
.editor-field label {
  display: block;
  font-size: 10px;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 2px;
}
.editor-field input[type="text"],
.editor-field input[type="number"],
.editor-field input[type="color"],
.editor-field textarea,
.editor-field select {
  width: 100%;
  padding: 4px 8px;
  font-family: inherit;
  font-size: 12px;
  background: var(--page-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--ink);
}
.editor-field textarea { min-height: 36px; resize: vertical; }
.editor-field input[type="color"] { height: 24px; padding: 2px 2px; }

/* ── Inspector tabs: Изменить / Анимация ─────────────────────────────── */
.editor-inspector-tabs {
  display: flex;
  gap: 2px;
  margin: 0 0 10px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--ed-surface, var(--page-bg));
  z-index: 3;
}
.editor-inspector-tab {
  flex: 1;
  padding: 9px 4px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-family: inherit;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
}
.editor-inspector-tab:hover { color: var(--ink); }
.editor-inspector-tab.active { color: var(--ink); border-bottom-color: var(--accent); }

/* Группа тогл-кнопок (B/I, выравнивание) */
.editor-btn-group { display: flex; gap: 4px; }
.editor-toggle-btn {
  flex: 1;
  padding: 5px 0;
  border: 1px solid var(--border);
  background: var(--page-bg);
  border-radius: 5px;
  color: var(--ink-2);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
}
.editor-toggle-btn:hover { border-color: var(--c-neutral-300); color: var(--ink); }
.editor-toggle-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Плитка-меню типов анимации (вместо выпадающего списка) */
.editor-anim-types {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-top: 2px;
}
.editor-anim-type {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 2px 5px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--page-bg);
  color: var(--ink-2);
  font-family: inherit;
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 100ms, background 100ms, color 100ms;
}
.editor-anim-type svg { width: 26px; height: 26px; }
.editor-anim-type span { white-space: nowrap; }
.editor-anim-type:hover { border-color: var(--c-neutral-300); color: var(--ink); }
.editor-anim-type.active {
  border-color: var(--accent);
  background: rgba(0, 113, 227, 0.10);
  color: var(--accent);
}

/* ── 3 контекстных слота анимации (Тип / подтип / направление-стиль) ──── */
.editor-anim-cards { display: flex; gap: 8px; margin: 2px 0 10px; }
.editor-anim-slot { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.editor-anim-slot > label {
  font-size: 9px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.04em;
}
.editor-anim-card {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; aspect-ratio: 1 / 1; padding: 6px 2px;
  border: 1px solid var(--border); border-radius: 9px;
  background: var(--page-bg); color: var(--ink); cursor: pointer;
  transition: border-color 100ms;
}
.editor-anim-card:hover { border-color: var(--accent); }
.editor-anim-card-ico { display: flex; align-items: center; justify-content: center; height: 28px; }
.editor-anim-card-ico svg { width: 26px; height: 26px; }
.editor-anim-card-ico .anim-arrow,
.editor-anim-card-ico .anim-emoji { font-size: 22px; line-height: 1; }
.editor-anim-card-lbl { font-size: 10px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }

/* Действия анимации, продублированные в ленту (вкладка «Анимация»).
   Хост прозрачен для layout — группы становятся прямыми flex-детьми панели.
   Карточки делаем фиксированно-компактными, чтобы влезли в невысокую ленту. */
.ribbon-anim-host { display: contents; }
.ribbon-panel .editor-anim-cards { gap: 5px; margin: 0; align-items: flex-end; }
/* Слот ленты — фикс-высота, контент прижат вниз (детерминированно компактно). */
.ribbon-panel .editor-anim-slot { flex: 0 0 auto; width: 58px; gap: 2px; height: 50px; justify-content: flex-end; }
/* Подпись слота — строго одна строка (иначе «ЧЕМ РИСОВАТЬ» переносится на 2
   строки и раздувает высоту панели). Полный текст — в тултипе карточки. */
.ribbon-panel .editor-anim-slot > label {
  font-size: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 100%; line-height: 1.2;
  flex: 0 0 auto;   /* не сжимать подпись в 2px (иначе ДЛИТ/ПАУЗА не видно) */
}
.ribbon-panel .editor-anim-card {
  aspect-ratio: auto; width: 56px; height: 30px; padding: 1px 2px; gap: 1px;
}
.ribbon-panel .editor-anim-card-ico { height: 15px; }
.ribbon-panel .editor-anim-card-ico svg { width: 16px; height: 16px; }
.ribbon-panel .editor-anim-card-ico .anim-arrow,
.ribbon-panel .editor-anim-card-ico .anim-emoji { font-size: 13px; }
.ribbon-panel .editor-anim-card-ico img.anim-hand-ico { height: 16px; }
.ribbon-panel .editor-anim-card-lbl { font-size: 9px; }
.ribbon-panel .editor-anim-slot > input {
  width: 56px; height: 22px; text-align: center; box-sizing: border-box;
}
/* Компактные группы ленты — чтобы панель «Анимация» влезала в фикс-высоту.
   Тело группы НЕ растягиваем (flex:0) — иначе оно заполняет фикс-высоту и
   панель раздувается. Высота группы = её контент + подпись. */
.ribbon-anim-host .ribbon-group-body { flex: 0 0 auto; padding: 1px 0; }
.ribbon-panel .morph-thumb { width: 38px; height: 38px; }
.ribbon-panel .morph-row { gap: 5px; }

/* Попап-меню выбора (тёмное, как в VideoScribe) */
.editor-anim-backdrop { position: fixed; inset: 0; z-index: 9998; }
/* Попап-пикер слотов анимации — через ТОКЕНЫ: light по умолчанию, dark
   автоматически (data-app-theme="dark" переворачивает токены). Никаких
   хардкод-цветов, чтобы не было разнотемья со светлым редактором. */
.editor-anim-popup {
  position: fixed; z-index: 9999; max-width: 340px;
  background: var(--ed-surface, #fff); color: var(--ink, #1d1d1f);
  border: 1px solid var(--border, rgba(0, 0, 0, 0.08));
  border-radius: 14px; padding: 14px;
  box-shadow: var(--shadow-3, 0 18px 50px rgba(0, 0, 0, 0.22));
}
.editor-anim-popup-title { font-size: 15px; font-weight: 700; margin: 0 0 10px; color: var(--ink, #1d1d1f); }
.editor-anim-popup-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.editor-anim-opt {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 7px; padding: 13px 6px; min-width: 84px;
  border: 1px solid var(--border, rgba(0, 0, 0, 0.10)); border-radius: 10px;
  background: var(--c-neutral-100, #f5f5f5); color: var(--ink, #1d1d1f); cursor: pointer;
  font-size: 12px; font-weight: 600; font-family: inherit;
}
.editor-anim-opt:hover { border-color: var(--accent, #0071e3); }
.editor-anim-opt.active { border-color: var(--accent, #0071e3); color: var(--accent, #0071e3); background: var(--c-neutral-200, #e9eef6); }
.editor-anim-opt-ico { height: 34px; display: flex; align-items: center; justify-content: center; }
.editor-anim-opt-ico svg { width: 32px; height: 32px; }
.editor-anim-opt-ico .anim-arrow { font-size: 30px; line-height: 1; }
.editor-anim-opt-ico .anim-emoji { font-size: 28px; line-height: 1; }
.editor-anim-opt-ico img.anim-hand-ico { height: 38px; width: auto; object-fit: contain; }
.editor-anim-card-ico img.anim-hand-ico { height: 26px; width: auto; object-fit: contain; }

/* ── Пикер направления 3×3 (VideoScribe-стиль): центр — вид активной сцены,
   вокруг — 8 стрелок по своим сторонам (позиция = откуда/куда). ───────────── */
.editor-anim-popup.anim-dir-popup { max-width: none; }
.anim-dir-grid {
  display: grid;
  grid-template-columns: repeat(3, 100px);
  grid-template-rows: repeat(3, 100px);
  gap: 8px;
}
.anim-dir-cell { gap: 5px; padding: 6px 4px; min-width: 0; }    /* наследует .editor-anim-opt */
.anim-dir-cell.empty { border: none; background: transparent; cursor: default; }
.anim-dir-arrow { font-size: 36px; line-height: 1; display: flex; align-items: center; justify-content: center; }
.anim-dir-arrow .anim-arrow { font-size: 36px; line-height: 1; font-weight: 700; }
.anim-dir-lbl {
  font-size: 10px; font-weight: 600; color: var(--muted, #888);
  text-align: center; line-height: 1.1; max-width: 92px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.anim-dir-cell.active .anim-dir-lbl { color: var(--accent, #0071e3); }
.anim-dir-center {
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border, rgba(0, 0, 0, 0.12)); border-radius: 10px;
  overflow: hidden; background: var(--c-neutral-100, #f5f5f5);
}
.anim-dir-preview { position: relative; width: 96px; height: 96px; overflow: hidden; border-radius: 8px; }
.anim-dir-preview-world { position: absolute; left: 50%; top: 50%; transform-origin: center center; overflow: hidden; }

.editor-field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
}

.editor-checkbox-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--ink-2);
  margin-bottom: 8px;
}

/* ── Timeline (bottom) ───────────────────────────────────────────────── */

.editor-timeline {
  background: var(--ed-surface);
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 10px;
  padding: 4px 8px;
  flex-shrink: 0;
  height: var(--timeline-h, 220px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04),
              0 1px 2px rgba(0, 0, 0, 0.03);
}

.editor-timeline-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  font-size: 10px;
  height: 24px;
}
.editor-timeline-header .time-display {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--ink-2);
  margin-left: auto;
}
.editor-timeline-header .duration-input {
  width: 60px;
}
/* Цифры не «прыгают» при изменении (моноширинные фигуры) */
body[data-view="editor"] input[type="number"],
.editor-timeline-header .time-display { font-variant-numeric: tabular-nums; }

#editor-timeline-track {
  position: relative;
  flex: 1;              /* заполнить нижнюю панель целиком (прижато к низу) */
  min-height: 44px;
  background: var(--page-bg);
  border-radius: 4px;
  border: 1px solid var(--border);
  overflow: auto;
  margin-top: 2px;
}

/* ── Транспорт-бар плеера (виден во время превью) ──────────────────────
   Пауза/воспроизведение + перетаскиваемая шкала времени + таймкод. */
.editor-preview-transport { display: none; transition: opacity .25s ease; }
/* Авто-скрытие во время проигрывания (чтобы не перекрывать рисующую руку);
   появляется по движению мыши; на паузе виден всегда. */
.editor-canvas-wrap.preview-on.transport-idle .editor-preview-transport {
  opacity: 0; pointer-events: none;
}
.editor-canvas-wrap.preview-on .editor-preview-transport {
  display: flex; align-items: center; gap: 12px;
  position: absolute; left: 50%; transform: translateX(-50%);
  bottom: 18px; z-index: 30; width: min(72%, 780px);
  padding: 8px 14px; border-radius: 999px;
  background: rgba(20, 20, 26, 0.82);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
}
.ept-btn {
  background: transparent; border: 0; color: #fff; font-size: 15px;
  cursor: pointer; width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  line-height: 1;
}
.ept-btn:hover { background: rgba(255, 255, 255, 0.16); }
.ept-bar {
  position: relative; flex: 1; height: 6px; border-radius: 3px;
  background: rgba(255, 255, 255, 0.26); cursor: pointer;
}
.ept-fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0;
  background: #4c8dff; border-radius: 3px; }
.ept-knob { position: absolute; top: 50%; left: 0; width: 14px; height: 14px;
  margin-left: -7px; transform: translateY(-50%); background: #fff;
  border-radius: 50%; box-shadow: 0 1px 5px rgba(0, 0, 0, 0.45); pointer-events: none; }
.ept-time { color: #fff; font-size: 12px; font-variant-numeric: tabular-nums;
  white-space: nowrap; min-width: 88px; text-align: center; }

/* Громкость: кнопка mute + ползунок (тёмный транспорт). */
.ept-vol-wrap { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.ept-vol-btn { font-size: 15px; }
/* Высокая «зона захвата» (18px) с тонким видимым треком в псевдоэлементе —
   иначе 4px-input с appearance:none фактически не кликается/не тянется. */
.ept-vol {
  -webkit-appearance: none; appearance: none;
  width: 80px; height: 18px; background: transparent; margin: 0;
  cursor: pointer; outline: none;
}
.ept-vol::-webkit-slider-runnable-track {
  height: 5px; border-radius: 3px;
  background: linear-gradient(to right, #4c8dff 0%, #4c8dff var(--vol-pct, 100%),
              rgba(255, 255, 255, 0.26) var(--vol-pct, 100%), rgba(255, 255, 255, 0.26) 100%);
}
.ept-vol::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 14px; height: 14px; border-radius: 50%; background: #fff;
  margin-top: -4.5px;   /* центрируем 14px-бегунок на 5px-треке */
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5); cursor: pointer;
}
.ept-vol::-moz-range-track { height: 5px; border-radius: 3px; background: rgba(255, 255, 255, 0.26); }
.ept-vol::-moz-range-progress { height: 5px; border-radius: 3px; background: #4c8dff; }
.ept-vol::-moz-range-thumb {
  width: 14px; height: 14px; border: 0; border-radius: 50%; background: #fff; cursor: pointer;
}

/* Элементы ленты, видимые только во время показа (превью): кнопка «Стоп». */
.preview-only { display: none !important; }
body.preview-running .preview-only { display: inline-flex !important; }

.editor-time-ruler {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 16px;
  background:
    repeating-linear-gradient(to right,
      transparent 0, transparent calc(10% - 1px),
      rgba(0, 0, 0, 0.08) calc(10% - 1px), rgba(0, 0, 0, 0.08) 10%);
  border-bottom: 1px solid var(--border);
}

.editor-time-ruler-labels {
  position: absolute;
  top: 1px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--muted);
  font-family: var(--font-mono);
  pointer-events: none;
  padding: 0 4px;
}

.editor-time-cursor {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--accent);
  pointer-events: none;
  z-index: 6;
}
/* Невидимая зона захвата палочки — ТОЛЬКО в верхней полосе (линейка), чтобы не
   перехватывать клики по плиткам/волне/клипам под палочкой (иначе край клипа у
   палочки не «схватить»). Сама линия — тонкая 2px на всю высоту (pointer:none). */
.editor-time-cursor::before {
  content: "";
  position: absolute;
  top: 0;
  height: 22px;
  left: -6px;
  width: 14px;
  pointer-events: auto;
  cursor: ew-resize;
}
/* Кнопка-ручка сверху палочки (видимый аффорданс перетаскивания). */
.editor-time-cursor::after {
  content: "";
  position: absolute;
  top: -2px;
  left: 50%;
  transform: translateX(-50%);
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  pointer-events: auto;
  cursor: ew-resize;
}

.editor-timeline-scene {
  position: absolute;
  height: 22px;
  background: rgba(0, 113, 227, 0.18);
  border: 1px solid var(--accent);
  border-radius: 4px;
  font-size: 11px;
  color: var(--ink);
  padding: 2px 8px 2px 6px;
  white-space: nowrap;
  overflow: hidden;
  cursor: grab;
  z-index: 2;
  transition: background 120ms var(--ease-quick);
  display: flex;
  align-items: center;
  gap: 4px;
}
.editor-timeline-scene:active { cursor: grabbing; }
.editor-timeline-scene:hover { background: rgba(0, 113, 227, 0.28); }
/* Мини-превью сцены на плитке (#5): картинка/контур/заливка слева от иконки. */
.ttl-thumb {
  flex: none;
  height: 18px;
  width: 24px;
  object-fit: contain;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.65);
  vertical-align: middle;
}
.ttl-thumb-fill { display: inline-block; border: 1px solid rgba(0, 0, 0, 0.15); }
[data-app-theme="dark"] .ttl-thumb { background: rgba(255, 255, 255, 0.12); }

/* .floating-back-btn удалён: верхний слим-бар (.app-topbar) с табом «Проекты»
   виден во всех не-editor вкладках, а в editor есть мини-таб «Проекты» в ленте —
   плавающая кнопка была лишней (дублировала навигацию на Тарифах/Уроках). */

/* ── Модалка «Let's get started!» — создание нового проекта ──────────── */
.newproject-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
  z-index: 10001;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: cmdk-fadein 140ms ease-out;
}
.newproject-overlay[hidden] { display: none; }
.newproject-modal {
  width: min(720px, 96vw);
  background: var(--ed-surface);
  border-radius: 14px;
  padding: 28px 32px 24px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.22);
}
.newproject-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--c-neutral-100);
}
.newproject-header h3 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  color: var(--c-neutral-900);
  letter-spacing: -0.01em;
}
.newproject-close {
  background: transparent;
  border: 0;
  font-size: 18px;
  color: var(--c-neutral-500);
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 6px;
  transition: background 100ms ease, color 100ms ease;
}
.newproject-close:hover {
  background: var(--c-neutral-50);
  color: var(--c-neutral-900);
}

.newproject-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--c-neutral-800);
  margin-bottom: 8px;
}
.newproject-input {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  font-family: inherit;
  font-size: 15px;
  background: var(--ed-surface);
  border: 2px solid var(--c-neutral-200);
  border-radius: 8px;
  outline: none;
  margin-bottom: 24px;
  box-sizing: border-box;
  transition: border-color 100ms ease;
}
.newproject-input:focus { border-color: var(--c-accent); }

.newproject-formats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}
.np-format {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 18px 12px 16px;
  background: var(--ed-surface);
  border: 2px solid var(--c-neutral-200);
  border-radius: 10px;
  cursor: pointer;
  font-family: inherit;
  transition: border-color 120ms ease, background 120ms ease, transform 80ms ease;
}
.np-format:hover { border-color: var(--c-neutral-300); }
.np-format.selected {
  border-color: var(--c-accent);
  background: var(--c-accent);   /* сплошной акцент: выделение чёткое (4% было почти незаметно) */
}
.np-format.selected .np-format-name { color: #fff; }
.np-format.selected .np-format-desc { color: rgba(255, 255, 255, 0.85); }
.np-format-icon {
  background: var(--c-neutral-200);
  border-radius: 6px;
}
.np-format.selected .np-format-icon { background: rgba(255, 255, 255, 0.92); }
.np-format-icon[data-aspect="16-9"] { width: 96px; height: 54px; }
.np-format-icon[data-aspect="1-1"]  { width: 72px; height: 72px; }
.np-format-icon[data-aspect="9-16"] { width: 40px; height: 72px; }
.np-format-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--c-neutral-900);
}
.np-format-desc {
  font-size: 11px;
  /* Было --c-neutral-500 → ~3.6:1 на карточке (провал AA для 11px текста).
     --c-neutral-600 (#525252 в светлой, #b4b9bf в тёмной) даёт >7:1 / ~AA. */
  color: var(--c-neutral-600);
  text-align: center;
  font-weight: 500;
}

.newproject-create {
  display: block;
  width: 100%;
  height: 52px;
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 10px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background 100ms ease;
}
.newproject-create:hover { background: var(--accent-hover); }
.newproject-create:disabled {
  background: var(--c-neutral-300);
  cursor: not-allowed;
}

/* ── Hub: стартовая страница со списком проектов ─────────────────────── */

#view-hub {
  padding: 24px 32px;
  max-width: 1280px;
  margin: 0 auto;
}
.hub-header { position: relative; }
.hub-header h2 {
  font-size: 22px;
  font-weight: 700;
  color: var(--c-neutral-900);
  margin: 0 0 4px;
  letter-spacing: -0.01em;
}
.hub-header .hub-subtitle {
  font-size: 13px;
  color: var(--c-neutral-500);
  margin: 0 0 20px;
}

/* 🔥 Серия дней — чип в правом верхнем углу карточки «Мои проекты». */
.hub-streak {
  position: absolute;
  top: 0; right: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid var(--c-neutral-200);
  border-radius: 999px;
  background: linear-gradient(180deg, #fff7ed 0%, #ffedd5 100%);
  color: #9a3412;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform 120ms var(--ease-quick, ease), box-shadow 120ms ease;
  white-space: nowrap;
}
.hub-streak:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.hub-streak b { font-size: 15px; font-weight: 800; }
.hub-streak-lbl { font-weight: 500; opacity: .85; }
.hub-streak.is-record { border-color: #f59e0b; box-shadow: 0 0 0 1px rgba(245, 158, 11, 0.35), var(--shadow-sm); }
[data-app-theme="dark"] .hub-streak {
  background: linear-gradient(180deg, #3a2a1a 0%, #2e2115 100%);
  color: #fdba74;
  border-color: #4a3520;
}
@media (max-width: 620px) {
  .hub-streak-lbl { display: none; }
}

/* SFX-пресеты в ленте «Анимация» — компактная сетка 2×2 (фикс. ширина, чтобы не
   схлопывалась в min-content и не раздувала ленту по ширине; как .anim-presets). */
.sfx-preset-row { display: flex; gap: 6px; flex-wrap: wrap; width: 224px; align-items: center; }
.sfx-preset-btn { white-space: nowrap; }
.hub-search-row {
  display: flex;
  flex-wrap: wrap;          /* кнопки переносятся на 2-ю строку, а не вылезают за край */
  gap: 8px;
  row-gap: 8px;
  margin-bottom: 16px;
  align-items: center;
}
.hub-search {
  flex: 1 1 240px;          /* тянется, но может ужаться/перенести кнопки на след. строку */
  min-width: 200px;
  height: 36px;
  padding: 0 12px;
  font-family: inherit;
  font-size: 13px;
  background: var(--ed-surface);
  border: 1px solid var(--c-neutral-200);
  border-radius: 8px;
  outline: none;
  transition: border-color 120ms ease;
}
.hub-search:focus { border-color: var(--c-accent); }
.hub-sort {
  height: 36px;
  padding: 0 8px;
  font-family: inherit;
  font-size: 13px;
  background: var(--ed-surface);
  border: 1px solid var(--c-neutral-200);
  border-radius: 8px;
  cursor: pointer;
}
.hub-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}
.hub-card {
  position: relative;
  display: flex;
  flex-direction: column;
  aspect-ratio: 16 / 11;
  background: var(--ed-surface);
  border: 1px solid var(--c-neutral-200);
  border-radius: 10px;
  cursor: pointer;
  /* НЕ overflow:hidden — иначе меню (⋯) с 4 пунктами выше карточки и последний
     пункт «Удалить» обрезается её краем (баг: пропал после добавления «Дублировать»).
     Скругление верха даёт сам .hub-card-preview; низ (info) того же цвета, что
     карточка, поэтому в скруглении не нуждается. */
  overflow: visible;
  transition: transform 140ms ease, box-shadow 140ms ease, border-color 140ms ease;
  box-shadow: var(--shadow-sm);
}
.hub-card:hover {
  transform: translateY(-2px);
  border-color: var(--c-accent);
  box-shadow: 0 4px 12px rgba(0,113,227,0.1), var(--shadow-sm);
}
/* Открытое меню (⋯) поднимает карточку НАД соседями. Поповер вылезает за нижний
   край карточки (overflow:visible выше); без подъёма z-index карточка СНИЗУ
   перекрывала бы его («Удалить» налезал на нижний блок). z-index у
   позиционированной карточки → весь её stacking-контекст (с меню z:10) выше
   соседних карточек (z:auto). */
.hub-card:has(.hub-card-menu-popup.open) { z-index: 30; }
.hub-card-preview {
  flex: 1;
  background: var(--c-neutral-50);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 42px;
  color: var(--c-neutral-300);
  /* верхние углы скругляем сами (карточка больше не overflow:hidden) */
  border-radius: 10px 10px 0 0;
}
.hub-card-info {
  padding: 10px 12px;
  background: var(--ed-surface);
  border-top: 1px solid var(--c-neutral-100);
}
.hub-card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--c-neutral-900);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 0;
}
.hub-card-meta {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--c-neutral-500);
  margin-top: 2px;
}
/* Бейдж общего проекта + лёгкая рамка на карточке */
.hub-card-shared { color: #0071e3; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 150px; }
.hub-card.hub-card-is-shared { border-color: #cfe0fb; }
[data-app-theme="dark"] .hub-card-shared { color: #6aa8ff; }
/* Модалка «Поделиться» */
.share-modal { max-width: 560px; }
.share-link-row { display: flex; gap: 8px; margin: 6px 0 14px; }
.share-link-row input { flex: 1 1 auto; min-width: 0; padding: 9px 11px; border: 1px solid var(--c-neutral-200, #e6e6e6);
  border-radius: 9px; font: 13px ui-monospace, Menlo, monospace; background: var(--ed-app-bg-2, #f4f6fa); color: var(--ink, #1e1e1e); }
.share-members-h { font-size: 12px; font-weight: 600; color: var(--c-neutral-500, #777); margin-bottom: 6px; }
.share-member { display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 7px 11px; border: 1px solid var(--c-neutral-200, #e6e6e6); border-radius: 8px; margin-bottom: 5px; font-size: 13px; color: var(--ink, #1e1e1e); }
.share-remove { width: 26px; height: 26px; border: 0; border-radius: 7px; background: #fdecec; color: #b4232a; cursor: pointer; font-size: 12px; }
.share-remove:hover { background: #fbdada; }
.share-empty { font-size: 12.5px; color: var(--c-neutral-500, #999); padding: 4px 2px; }
/* Корзина проектов */
.hub-trash-btn { border: 1px solid var(--c-neutral-200, #e6e6e6); background: var(--ed-app-bg-2, #f4f6fa);
  border-radius: 9px; padding: 0 13px; font-size: 13px; color: var(--ink, #1e1e1e); cursor: pointer; white-space: nowrap; }
.hub-trash-btn:hover { background: var(--c-neutral-100, #eef0f4); }
[data-app-theme="dark"] .hub-trash-btn { background: #24262b; border-color: #3a3f4a; color: #e6e6e6; }
.hub-stats { margin-top: 8px; font-size: 12.5px; color: var(--c-neutral-500, #888);
  display: flex; flex-wrap: wrap; gap: 2px; }
/* Пакетные операции в хабе (мультивыбор) */
.hub-trash-btn.active { background: var(--c-accent, #0071e3); border-color: var(--c-accent, #0071e3); color: #fff; }
.hub-bulk-bar { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; padding: 8px 12px;
  border: 1px solid var(--c-accent, #0071e3); border-radius: 10px; background: #eef4ff; font-size: 13px; color: var(--ink, #1e1e1e); }
[data-app-theme="dark"] .hub-bulk-bar { background: #14233c; border-color: #2a4f7f; color: #dce8f7; }
.hub-card.selectmode { cursor: pointer; }
.hub-card.selectmode.selected { outline: 2px solid var(--c-accent, #0071e3); outline-offset: 1px; }
.hub-card-check { position: absolute; top: 8px; left: 8px; z-index: 5; font-size: 18px; line-height: 1; }
/* Метки (теги) проектов */
.hub-tag-filter { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 10px; }
.hub-tag-chip { font-size: 12px; padding: 4px 11px; border-radius: 999px; cursor: pointer; user-select: none;
  border: 1px solid var(--c-neutral-200, #e0e0e0); background: var(--ed-app-bg-2, #f4f6fa); color: var(--c-neutral-600, #555); }
.hub-tag-chip:hover { border-color: var(--c-accent, #0071e3); }
.hub-tag-chip.active { background: var(--c-accent, #0071e3); border-color: var(--c-accent, #0071e3); color: #fff; }
[data-app-theme="dark"] .hub-tag-chip { background: #24262b; border-color: #3a3f4a; color: #c8c8c8; }
.hub-card-snippet { margin-top: 5px; font-size: 11px; line-height: 1.35; color: var(--c-neutral-500, #777);
  background: #fbf6e9; border: 1px solid #ece0c0; border-radius: 6px; padding: 4px 7px;
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
[data-app-theme="dark"] .hub-card-snippet { background: #2a2414; border-color: #4a4128; color: #c8bb95; }
.hub-card-note { margin-top: 5px; font-size: 11.5px; line-height: 1.35; color: #8a6d1a;
  background: #fdf7e3; border: 1px solid #ece0bd; border-radius: 6px; padding: 4px 7px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
[data-app-theme="dark"] .hub-card-note { background: #2a2414; border-color: #4a4128; color: #d8c692; }
.hub-card-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.hub-tag { font-size: 10.5px; padding: 2px 7px; border-radius: 6px; cursor: pointer;
  background: #eef3fb; color: #3868a8; border: 1px solid #d8e3f3; }
.hub-tag:hover { background: #e2ecfa; }
[data-app-theme="dark"] .hub-tag { background: #1d2a3d; color: #9cc0ef; border-color: #2a3f5f; }
.trash-modal { max-width: 560px; }
.trash-list { display: flex; flex-direction: column; gap: 7px; margin: 8px 0 4px; max-height: 52vh; overflow: auto; }
.trash-row { display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 9px 12px; border: 1px solid var(--c-neutral-200, #e6e6e6); border-radius: 9px; }
.trash-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.trash-info b { font-size: 13.5px; color: var(--ink, #1e1e1e); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trash-info span { font-size: 11.5px; color: var(--c-neutral-500, #888); }
.trash-acts { display: flex; gap: 6px; flex: 0 0 auto; }
.trash-acts .editor-btn { padding: 6px 11px; font-size: 12.5px; }
.trash-acts .restore { color: #15803d; }
.trash-acts .danger { color: var(--c-danger, #b4232a); }
/* Готовые блоки-сцены */
.blocks-modal { max-width: 520px; }
.blocks-list { display: flex; flex-direction: column; gap: 7px; margin: 8px 0 4px; }
.blocks-row { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 12px; border: 1px solid var(--c-neutral-200, #e6e6e6); border-radius: 9px; }
.blocks-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.blocks-info b { font-size: 13.5px; color: var(--ink, #1e1e1e); }
.blocks-info span { font-size: 11.5px; color: var(--c-neutral-500, #888); }
.blocks-add { flex: 0 0 auto; padding: 6px 14px; font-size: 12.5px; }
/* Проверка сценария (lint) */
.lint-modal { max-width: 540px; }
.lint-list { display: flex; flex-direction: column; gap: 6px; margin: 8px 0 4px; max-height: 50vh; overflow: auto; }
.lint-row { display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 11px; border: 1px solid #f0d8a8; background: #fff7ea; border-radius: 9px; font-size: 13px; color: #7a5a12; }
.lint-row.error { border-color: #f0c0c0; background: #fdecec; color: #8a1f1f; }
.lint-row span { min-width: 0; }
.lint-go { padding: 5px 10px; font-size: 12px; flex: 0 0 auto; }
[data-app-theme="dark"] .lint-row { background: #2a2114; border-color: #5a4a2a; color: #ffe0a8; }
[data-app-theme="dark"] .lint-row.error { background: #2a1414; border-color: #5a2a2a; color: #ffb4b4; }
/* v3: переключатель роли ссылки (редактор / просмотр) */
.share-role-seg { display: inline-flex; gap: 4px; padding: 3px; border-radius: 10px;
  background: var(--ed-app-bg-2, #f1f3f7); margin: 4px 0 2px; }
.share-role-btn { border: 0; background: transparent; padding: 6px 13px; border-radius: 8px;
  font-size: 12.5px; font-weight: 600; color: var(--c-neutral-500, #777); cursor: pointer; }
.share-role-btn.selected { background: #fff; color: var(--ink, #1e1e1e); box-shadow: 0 1px 4px rgba(0,0,0,.12); }
[data-app-theme="dark"] .share-role-btn.selected { background: #3a3f4a; color: #f4f4f4; }
/* v3: пред-приглашение по e-mail */
.share-invite { margin: 8px 0 14px; padding-top: 12px; border-top: 1px solid var(--c-neutral-200, #eee); }
.share-invite-row { display: flex; gap: 7px; margin: 7px 0; }
.share-invite-row input[type=email] { flex: 1 1 auto; min-width: 0; padding: 9px 11px; border: 1px solid var(--c-neutral-200, #e6e6e6);
  border-radius: 9px; font-size: 13px; background: var(--ed-app-bg-2, #f4f6fa); color: var(--ink, #1e1e1e); }
.share-invite-row select { padding: 0 8px; border: 1px solid var(--c-neutral-200, #e6e6e6); border-radius: 9px;
  background: var(--ed-app-bg-2, #f4f6fa); color: var(--ink, #1e1e1e); font-size: 12.5px; }
.share-member.pending { background: #fcfbf2; border-color: #ece4c0; color: #7a6a2a; }
.share-member.pending i { color: var(--c-neutral-500, #999); font-style: normal; opacity: .8; }
.share-uninvite { width: 26px; height: 26px; border: 0; border-radius: 7px; background: #f3eccf; color: #8a6d1a; cursor: pointer; font-size: 12px; }
.share-uninvite:hover { background: #ece0b6; }
/* Presence / soft-lock баннер (v3): зелёный — соседи; янтарный — замок занят; синий — read-only */
.editor-presence { position: fixed; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 99997;
  background: #f0f9f1; border: 1px solid #bfe3c4; color: #1f6a2c; border-radius: 11px;
  padding: 8px 15px; font-size: 12.5px; max-width: 640px; text-align: center; line-height: 1.4;
  box-shadow: 0 6px 22px rgba(0,0,0,.16); pointer-events: none; }
.editor-presence b { color: #15803d; }
.editor-presence.locked { background: #fff7ea; border-color: #f0d8a8; color: #8a5a12; pointer-events: auto; }
.editor-presence.locked b { color: #b46a09; }
.editor-presence.readonly { background: #eef4ff; border-color: #c3d6f5; color: #28477e; }
.editor-presence.readonly b { color: #1f4fa3; }
.editor-claim-btn { margin-left: 10px; border: 0; border-radius: 8px; padding: 5px 12px; cursor: pointer;
  background: #b46a09; color: #fff; font-size: 12px; font-weight: 700; pointer-events: auto; }
.editor-claim-btn:hover { background: #97590a; }
[data-app-theme="dark"] .editor-presence { background: #14241a; border-color: #2c5a36; color: #b4ffc0; }
[data-app-theme="dark"] .editor-presence b { color: #9affb0; }
[data-app-theme="dark"] .editor-presence.locked { background: #2a2114; border-color: #5a4a2a; color: #ffe0a8; }
[data-app-theme="dark"] .editor-presence.readonly { background: #141d2a; border-color: #2a3f5a; color: #aecbff; }
.editor-save-indicator.readonly { color: #1f4fa3; font-weight: 600; }

/* New project tile — пунктирная рамка */
.hub-card-new {
  aspect-ratio: 16 / 11;
  background: var(--c-neutral-50);
  border: 2px dashed var(--c-neutral-300);
  align-items: center;
  justify-content: center;
  flex-direction: column;
  /* у «нового проекта» нет меню (⋯) — клип возвращаем, чтобы пунктирная рамка
     красиво скруглялась (его фон отличается от обычной карточки) */
  overflow: hidden;
}
.hub-card-new:hover {
  background: var(--ed-surface);
  border-color: var(--c-accent);
  border-style: dashed;
}
.hub-card-new-plus {
  font-size: 64px;
  font-weight: 200;
  color: var(--c-accent);
  line-height: 1;
}
.hub-card-new-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--c-neutral-700);
  margin-top: 8px;
}

/* Кнопки действий на карточке (rename/delete) — три точки в углу */
.hub-card-menu {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--c-neutral-200);
  border-radius: 5px;
  color: var(--c-neutral-600);
  font-weight: 700;
  cursor: pointer;
  font-size: 14px;
  opacity: 0;
  transition: opacity 120ms ease, background 120ms ease;
  z-index: 2;
}
.hub-card:hover .hub-card-menu { opacity: 1; }
.hub-card-menu:hover { background: #fff; color: var(--c-neutral-900); }

.hub-card-menu-popup {
  position: absolute;
  top: 32px;
  right: 6px;
  min-width: 140px;
  background: var(--ed-surface);
  border: 1px solid var(--c-neutral-200);
  border-radius: 6px;
  box-shadow: var(--shadow-md);
  padding: 4px;
  z-index: 10;
  display: none;
}
.hub-card-menu-popup.open { display: block; }
.hub-card-menu-popup button {
  display: block;
  width: 100%;
  padding: 7px 10px;
  background: transparent;
  border: 0;
  border-radius: 4px;
  text-align: left;
  font-family: inherit;
  font-size: 12px;
  color: var(--c-neutral-800);
  cursor: pointer;
}
.hub-card-menu-popup button:hover { background: var(--c-neutral-50); }
.hub-card-menu-popup button.danger { color: var(--c-danger); }

/* «+ Новый проект» → выпадающее меню «Пустой» / «Из проекта». Появляется по центру
   карточки поверх «+». Карточке даём overflow:visible, чтобы меню не срезалось. */
.hub-card:has(.hub-newmenu-popup.open) { z-index: 30; }
.hub-card-new { position: relative; }
/* обычно overflow:hidden (скругление пунктира), но с открытым меню — visible,
   чтобы тень поповера не срезалась краем карточки */
.hub-card-new:has(.hub-newmenu-popup.open) { overflow: visible; }
.hub-newmenu-popup {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  min-width: 168px;
  background: var(--ed-surface);
  border: 1px solid var(--c-neutral-200);
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  padding: 6px;
  z-index: 12;
  display: none;
}
.hub-newmenu-popup.open { display: block; animation: newmenu-in 130ms var(--ease-quick, ease); }
@keyframes newmenu-in { from { opacity: 0; } to { opacity: 1; } }
.hub-newmenu-popup button {
  display: block; width: 100%;
  padding: 10px 12px;
  background: transparent; border: 0; border-radius: 8px;
  text-align: left; font-family: inherit; font-size: 13px; font-weight: 500;
  color: var(--c-neutral-800); cursor: pointer; white-space: nowrap;
}
.hub-newmenu-popup button:hover:not(:disabled) { background: var(--c-neutral-50); }
.hub-newmenu-popup button:disabled { opacity: .45; cursor: not-allowed; }
@media (prefers-reduced-motion: reduce) { .hub-newmenu-popup.open { animation: none; } }

/* «Из проекта» — строки списка проектов-источников в модалке-пикере */
.np-src-item {
  display: flex; align-items: center; gap: 12px;
  text-align: left; width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--c-neutral-200); border-radius: 10px;
  background: var(--ed-surface); cursor: pointer; font-family: inherit;
  transition: border-color 120ms ease, background 120ms ease;
}
.np-src-item:hover { border-color: var(--c-accent); background: var(--c-neutral-50); }
.np-src-ico { font-size: 22px; }
.np-src-body { flex: 1; min-width: 0; }
.np-src-title { display: block; font-weight: 600; font-size: 14px; color: var(--c-neutral-900); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.np-src-meta { display: block; font-size: 12px; color: #8a8a90; }
.np-src-cta { font-size: 12px; color: var(--c-accent); font-weight: 600; white-space: nowrap; }

/* Save-indicator в editor toolbar */
.editor-save-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 8px;
  padding: 0 8px;
  font-size: 11px;
  color: var(--c-neutral-500);
  font-weight: 500;
}
.editor-save-indicator.saving { color: var(--c-accent); }
/* «✓ Сохранено»: --c-success (#16a34a) на белой ленте = только 3.3:1 (провал AA).
   Затемняем до #15803d (≈5.0:1 на белом, ≥4.6:1 даже на off-white ленте) и
   усиливаем вес — галочка остаётся читаемой. Тост (--c-success) не трогаем. */
.editor-save-indicator.saved { color: #15803d; font-weight: 600; }
.editor-save-indicator.error { color: var(--c-danger); }

/* В hub-view убираем editor's flex-column body padding */
body[data-view="hub"] main {
  display: block !important;
  height: auto !important;
  padding: 0 !important;
  overflow: auto !important;
}
body[data-view="hub"] {
  overflow: auto !important;
  background: var(--c-neutral-50);
}
/* Бар — body-level, во всю ширину окна, прижат к САМОМУ верху (тот же уровень и
   позиция, что лента редактора). Верхний отступ убираем через body padding-top:0
   (ниже). Табы у левого края (~38px = body padding 20 + отступ бара 18) ≈ позиция
   табов в редакторе. */
body[data-view="hub"] .app-topbar,
body[data-view="tariffs"] .app-topbar,
body[data-view="lessons"] .app-topbar,
body[data-view="auto"] .app-topbar {
  /* -20px по бокам «съедают» боковой padding body (20px) → бар во всю ширину,
     край-в-край, как лента редактора; табы у левого края на той же позиции.
     Контент ниже (main/#view-*) сохраняет свои поля. */
  margin: 0 -20px 18px;
  max-width: none;
  /* «прибито сверху» — липнет к верху при прокрутке (в редакторе лента всегда
     видна благодаря 100vh-раскладке; здесь эффект даёт sticky). */
  position: sticky;
  top: 0;
  z-index: 40;
}
/* Раньше padding-top:40 давал воздух под большую шапку <header>. Шапки больше нет —
   бар должен быть у верхнего края (как лента редактора). Горизонтальный/нижний
   отступы body сохраняем — они держат поля контента. */
body[data-view="hub"],
body[data-view="tariffs"],
body[data-view="lessons"],
body[data-view="auto"] {
  padding-top: 0 !important;
}

/* Inline edit text-сцены — пока user печатает прямо на холсте. */
.editor-text-editing {
  outline: 2px dashed var(--c-accent) !important;
  outline-offset: 6px;
  caret-color: var(--c-accent);
  cursor: text !important;
  user-select: text !important;
  /* Чуть подсветим фон чтобы было ясно что в edit-mode */
  background: rgba(0, 113, 227, 0.04);
  border-radius: 4px;
}
.editor-text-editing:focus {
  outline-color: var(--c-accent) !important;
}

/* Drag-reorder mode (VideoScribe-style): tile следует за курсором,
   полупрозрачный + тень. */
.editor-timeline-scene.ttl-dragging {
  cursor: grabbing;
  opacity: 0.97;
  z-index: 100 !important;
  /* «приподнятая карта» — выраженная тень, плитка остаётся яркой/непрозрачной */
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.30), 0 3px 8px rgba(0, 0, 0, 0.18);
  pointer-events: none;
  will-change: transform;
  transform-origin: center bottom;
}

/* Visual indicator drop-position между tiles. */
.ttl-drop-indicator {
  position: absolute;
  top: 28px;
  bottom: 4px;
  width: 3px;
  background: var(--c-accent);
  border-radius: 2px;
  pointer-events: none;
  z-index: 50;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.6);
  transition: left 80ms ease-out;
}
.editor-timeline-scene.selected {
  background: rgba(0, 113, 227, 0.5);
  z-index: 3;
  box-shadow: 0 0 0 2px var(--accent);
}
/* Сцена, на которую «прилипнет» перетаскиваемая плитка (= появятся одновременно). */
.editor-timeline-scene.ttl-parallel-target {
  box-shadow: 0 0 0 2px #ff9f0a, 0 0 12px rgba(255, 159, 10, 0.6) !important;
  z-index: 4;
}
/* Полоса-подсветка НОВОЙ ДОРОЖКИ (2-3 линия) при перетаскивании — во всю
   длину таймлайна: видно, что объект можно бросить в любую точку ряда. */
.ttl-lane-band {
  position: absolute;
  left: 0;
  right: 0;
  border-top: 2px dashed var(--accent);
  border-bottom: 2px dashed var(--accent);
  background: rgba(0, 113, 227, 0.10);
  pointer-events: none;
  z-index: 40;
  animation: ttlGhostPulse 1.1s ease-in-out infinite;
}
@keyframes ttlGhostPulse { 0%, 100% { opacity: 0.45; } 50% { opacity: 0.8; } }
/* Направляющая магнита аудио-клипа (прилипание к границе плитки выше). */
.ttl-snap-guide {
  position: absolute;
  top: 0; bottom: 0;
  width: 2px;
  margin-left: -1px;
  background: #ff9f0a;
  pointer-events: none;
  z-index: 45;
  box-shadow: 0 0 6px rgba(255, 159, 10, 0.85);
}
/* Выравнивание/распределение объектов (инспектор мультивыбора) */
.align-tools { display: flex; flex-direction: column; gap: 6px; }
.align-row { display: flex; gap: 6px; }
.align-btn { flex: 1 1 auto; border: 1px solid var(--c-neutral-200, #e0e0e0); background: var(--ed-app-bg-2, #f4f6fa);
  color: var(--ink, #1e1e1e); border-radius: 8px; padding: 8px 6px; font-size: 14px; cursor: pointer; line-height: 1; }
.align-btn:hover { border-color: var(--c-accent, #0071e3); background: var(--c-neutral-100, #eef0f4); }
[data-app-theme="dark"] .align-btn { background: #24262b; border-color: #3a3f4a; color: #e6e6e6; }
[data-app-theme="dark"] .align-btn:hover { background: #2c2f36; }
/* Чипы-пресеты анимации появления (лента «Анимация») */
/* width (не max-width!): вложенный flex-wrap внутри flex-ленты иначе схлопывается
   до min-content (1 чип/строку) и растёт вверх на 6 строк → вылезает за 80px-ленту
   и виден только средний огрызок («Зум/Выезд»). Фикс: жёсткая ширина → 2 ряда по 3. */
.anim-presets { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; width: 280px; flex: 0 0 auto; }
.anim-preset { border: 1px solid var(--c-neutral-200, #e0e0e0); background: var(--ed-app-bg-2, #f4f6fa);
  color: var(--ink, #1e1e1e); border-radius: 8px; padding: 5px 9px; font-size: 12px; cursor: pointer; white-space: nowrap; }
.anim-preset:hover { border-color: var(--c-accent, #0071e3); }
.anim-preset.active { background: var(--c-accent, #0071e3); border-color: var(--c-accent, #0071e3); color: #fff; }
[data-app-theme="dark"] .anim-preset { background: #24262b; border-color: #3a3f4a; color: #e6e6e6; }
/* Гайд режима ВСТАВКИ между сценами (ripple) — зелёный, шире: «тут раздвинется». */
.ttl-snap-guide.ttl-insert {
  width: 3px; margin-left: -1.5px;
  background: #15803d;
  box-shadow: 0 0 7px rgba(21, 128, 61, 0.75);
}
/* Параллельная сцена (появляется ОДНОВРЕМЕННО с предыдущей) — жёлтый акцент слева. */
.editor-timeline-scene.ttl-parallel { border-left: 3px solid #ff9f0a; }
.editor-timeline-scene.ttl-parallel::after {
  content: "∥";
  position: absolute;
  right: 3px; top: 1px;
  font-size: 11px; font-weight: 700;
  color: #ff9f0a;
  pointer-events: none;
}
/* Цвета по типу */
.editor-timeline-scene.type-camera     { background: rgba(255, 57, 164, 0.22); border-color: #ff39a4; }
.editor-timeline-scene.type-camera.selected { background: rgba(255, 57, 164, 0.55); box-shadow: 0 0 0 2px #ff39a4; }
.editor-timeline-scene.type-text       { background: rgba(0, 113, 227, 0.22); border-color: var(--accent); }
.editor-timeline-scene.type-draw_svg   { background: rgba(52, 199, 89, 0.22); border-color: #34c759; }
.editor-timeline-scene.type-draw_svg.selected { background: rgba(52, 199, 89, 0.55); box-shadow: 0 0 0 2px #34c759; }
.editor-timeline-scene.type-fade_image { background: rgba(255, 149, 0, 0.22); border-color: #ff9500; }

.editor-timeline-scene .ttl-icon {
  font-size: 11px;
  flex-shrink: 0;
}
.editor-timeline-scene .ttl-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  font-weight: 600;
}
.editor-timeline-scene .ttl-time {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-2);
  flex-shrink: 0;
}
.editor-timeline-scene .ttl-handle {
  position: absolute;
  top: 0; bottom: 0;
  width: 5px;
  background: transparent;
  cursor: ew-resize;
}
.editor-timeline-scene .ttl-handle-l { left: 0; }
.editor-timeline-scene .ttl-handle-r { right: 0; }
.editor-timeline-scene:hover .ttl-handle-l,
.editor-timeline-scene:hover .ttl-handle-r {
  background: rgba(0, 0, 0, 0.18);
}

/* ── Status bar / messages ───────────────────────────────────────────── */

.editor-status {
  font-size: 12px;
  color: var(--muted);
  padding: 0 4px;
}
.editor-status.ok { color: var(--success); }
.editor-status.error { color: var(--error); }

/* ── Inspector: BG palette section (всегда видна сверху) ──────────────── */

.editor-bg-section {
  margin: 0 0 6px;
  padding: 4px 8px 6px;
  background: var(--page-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
}
.editor-bg-section > summary {
  cursor: pointer;
  font-size: 10px;
  font-weight: 600;
  color: var(--ink-2);
  letter-spacing: 0.02em;
  text-transform: uppercase;
  margin: 0 0 4px;
  list-style: none;
}
.editor-bg-section > summary::after {
  content: "▾";
  float: right;
  color: var(--muted);
  transition: transform 180ms var(--ease-quick);
}
.editor-bg-section[open] > summary::after {
  transform: rotate(-180deg);
}

.bg-swatches {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 4px;
  padding: 4px 0 0;
}
.bg-swatch {
  aspect-ratio: 1 / 1;
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  padding: 0;
  transition: transform 100ms var(--ease-quick), box-shadow 100ms var(--ease-quick);
}
.bg-swatch:hover { transform: scale(1.08); }
.bg-swatch.active {
  box-shadow: 0 0 0 2px var(--accent);
  transform: scale(1.06);
}

/* ── Текстура «мятая бумага» (6 плиток: Нет + 5 уровней) ───────────────── */
.editor-bg-texlabel {
  margin: 12px 0 5px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.paper-swatches {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 5px;
}
.paper-swatch {
  aspect-ratio: 1 / 1;
  border: 1px solid var(--border);
  border-radius: 5px;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background-position: center;
  transition: transform 100ms var(--ease-quick), box-shadow 100ms var(--ease-quick);
}
.paper-swatch:hover { transform: scale(1.08); }
.paper-swatch.active {
  box-shadow: 0 0 0 2px var(--accent);
  transform: scale(1.06);
}
.paper-swatch .paper-none { font-size: 15px; color: var(--muted); line-height: 1; }
.paper-swatch .paper-lvl {
  font-size: 12px; font-weight: 700; line-height: 1;
  color: #5a4a32;                       /* тёмно-крафт — читается на любом уровне */
  text-shadow: 0 1px 1px rgba(255, 255, 255, 0.55);
}

/* ── Фото-бумага (world.paper) — плитки-превью пошире, чтобы текстура читалась ── */
.paper-photo-swatches {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  align-items: center;
}
.paper-photo-swatch {
  aspect-ratio: 16 / 10;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-color: var(--page-bg);
  transition: transform 100ms var(--ease-quick), box-shadow 100ms var(--ease-quick);
}
.paper-photo-swatch:hover { transform: scale(1.05); }
.paper-photo-swatch.active { box-shadow: 0 0 0 2px var(--accent); transform: scale(1.04); }
.paper-photo-swatch .paper-none { font-size: 16px; color: var(--muted); line-height: 1; }
.paper-photo-hint {
  grid-column: 1 / -1;
  font-size: 10.5px;
  color: var(--muted);
  line-height: 1.3;
  align-self: center;
}

/* ── Tex/LaTeX-сцена (KaTeX) + плавающий редактор формулы ───────────── */
.editor-tex-scene { user-select: none; }
.katex-wrap { display: inline-block; }
.katex-wrap .katex { font-size: 1em; }     /* масштаб = font-size контейнера */
.tex-ed-preview .katex { font-size: 1em; }
.tex-source-input {
  width: 100%; box-sizing: border-box; resize: vertical; min-height: 42px;
  font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px;
}
.editor-tex-editor {
  position: fixed; z-index: 9000; width: 340px; max-width: calc(100vw - 16px);
  background: var(--panel-bg, #fff); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: 0 16px 42px rgba(0, 0, 0, 0.22);
  padding: 12px; display: flex; flex-direction: column; gap: 8px;
}
.tex-ed-title { font-weight: 700; font-size: 13px; color: var(--text); }
.tex-ed-input {
  width: 100%; box-sizing: border-box; resize: vertical; min-height: 46px;
  font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px;
  padding: 8px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--page-bg); color: var(--text);
}
.tex-ed-prevlabel { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.tex-ed-preview {
  min-height: 56px; display: flex; align-items: center; justify-content: center;
  padding: 8px; border: 1px dashed var(--border); border-radius: 8px;
  background: #fdfaf2; color: #1e1e1e; overflow: auto;
}
.tex-ed-preview.error { color: #c0392b; font-size: 12px; }
.tex-ed-hint { font-size: 10.5px; color: var(--muted); }
.tex-ed-actions { display: flex; justify-content: flex-end; gap: 8px; }
.editor-btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ── Inspector details блоки (анимация появления/выхода) ────────────── */

.editor-anim-block {
  margin-top: 4px;
  padding: 4px 8px;
  background: var(--page-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
}
.editor-anim-block > summary {
  cursor: pointer;
  font-size: 10px;
  font-weight: 600;
  color: var(--ink-2);
  letter-spacing: 0.02em;
  text-transform: uppercase;
  margin: 0 0 4px;
  list-style: none;
}
.editor-anim-block > summary::after {
  content: "▾";
  float: right;
  color: var(--muted);
  transition: transform 180ms var(--ease-quick);
}
.editor-anim-block[open] > summary::after {
  transform: rotate(-180deg);
}

/* ── Camera scene (VideoScribe-style draggable + resizable camera rect) ─ */

.editor-camera-scene {
  border: 3px dashed #ff39a4;
  background: rgba(255, 57, 164, 0.05);
  box-sizing: border-box;
  z-index: 5;
  /* Кадр камеры НЕ перехватывает клики по своему телу — клик проходит к объектам
     внутри (как слой-«рамка» в стандартных редакторах). Камера выбирается/двигается
     за ярлык и ресайзится за хэндлы (у них pointer-events:auto ниже). */
  pointer-events: none;
}
.editor-camera-scene-label {
  position: absolute;
  top: 8px;
  left: 8px;
  pointer-events: auto;   /* ярлык = захват/выбор камеры */
  cursor: move;
  background: #ff39a4;
  color: #fff;
  font-size: 28px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 6px;
}
.editor-camera-handle {
  position: absolute;
  pointer-events: auto;   /* хэндлы кликабельны, хотя у камеры pointer-events:none */
  /* Размер/зона захвата — как у картинок: доля экранного размера объекта
     (--handle-screen задаётся в updateSelectedHandleSize) × --inv-scale, чтобы
     при любом зуме хэндл оставался удобным и не зависел от масштаба world. */
  width: calc(var(--handle-screen, 22px) * var(--inv-scale, 1));
  height: calc(var(--handle-screen, 22px) * var(--inv-scale, 1));
  background: #fff;          /* canvas-overlay handle — не зависит от темы UI */
  border: calc(2.5px * var(--inv-scale, 1)) solid #ff39a4;
  border-radius: calc(5px * var(--inv-scale, 1));
  z-index: 6;
}
/* невидимая зона клика +10px со всех сторон — удобнее захватывать */
.editor-camera-handle::before {
  content: "";
  position: absolute;
  inset: calc(-10px * var(--inv-scale, 1));
}
.editor-camera-handle.handle-nw { top: calc(var(--handle-screen, 22px) * -0.5 * var(--inv-scale, 1)); left: calc(var(--handle-screen, 22px) * -0.5 * var(--inv-scale, 1));  cursor: nwse-resize; }
.editor-camera-handle.handle-ne { top: calc(var(--handle-screen, 22px) * -0.5 * var(--inv-scale, 1)); right: calc(var(--handle-screen, 22px) * -0.5 * var(--inv-scale, 1)); cursor: nesw-resize; }
.editor-camera-handle.handle-sw { bottom: calc(var(--handle-screen, 22px) * -0.5 * var(--inv-scale, 1)); left: calc(var(--handle-screen, 22px) * -0.5 * var(--inv-scale, 1));  cursor: nesw-resize; }
.editor-camera-handle.handle-se { bottom: calc(var(--handle-screen, 22px) * -0.5 * var(--inv-scale, 1)); right: calc(var(--handle-screen, 22px) * -0.5 * var(--inv-scale, 1)); cursor: nwse-resize; }

/* ── Resize handles для обычных сцен (text, draw_svg, fade_image, freehand).
   8 handles: 4 угла + 4 стороны. Видны только когда сцена выделена.
   Крупные + ::before invisible hit-area для удобного попадания мышью. ── */
.editor-scene-handle {
  position: absolute;
  background: #fff;          /* canvas-overlay handle — не зависит от темы UI */
  border: calc(2px * var(--inv-scale, 1)) solid var(--c-accent);
  border-radius: calc(5px * var(--inv-scale, 1));
  /* Размер хэндла = доля экранного размера объекта (var задаётся в JS:
     updateSelectedHandleSize), а не фикс — иначе на мелком/отдалённом объекте
     хэндлы закрывают его целиком. --inv-scale конвертит экранные px в world. */
  width: calc(var(--handle-screen, 22px) * var(--inv-scale, 1));
  height: calc(var(--handle-screen, 22px) * var(--inv-scale, 1));
  z-index: 8;
  box-shadow: 0 calc(2px * var(--inv-scale, 1)) calc(6px * var(--inv-scale, 1)) rgba(0, 0, 0, 0.22);
  display: none;
  cursor: pointer;
}
/* ::before — невидимая зона клика +12px со всех сторон для удобства */
.editor-scene-handle::before {
  content: "";
  position: absolute;
  inset: calc(-10px * var(--inv-scale, 1));
}
/* Показываем handles на выделенной сцене */
.scene.selected .editor-scene-handle,
.scene.editor-scene-selected .editor-scene-handle {
  display: block;
}
/* Боковые ручки — прямоугольные, удобно тянуть за грань */
.editor-scene-handle.handle-n,
.editor-scene-handle.handle-s {
  width: calc(var(--handle-screen, 22px) * 1.5 * var(--inv-scale, 1));
  height: calc(var(--handle-screen, 22px) * 0.58 * var(--inv-scale, 1));
  border-radius: calc(5px * var(--inv-scale, 1));
}
.editor-scene-handle.handle-e,
.editor-scene-handle.handle-w {
  width: calc(var(--handle-screen, 22px) * 0.58 * var(--inv-scale, 1));
  height: calc(var(--handle-screen, 22px) * 1.5 * var(--inv-scale, 1));
  border-radius: calc(5px * var(--inv-scale, 1));
}
/* Позиции — относительно scene-element (который сам translate(-50%, -50%) */
.editor-scene-handle.handle-nw { top: calc(var(--handle-screen, 22px) * -0.5 * var(--inv-scale, 1)); left: calc(var(--handle-screen, 22px) * -0.5 * var(--inv-scale, 1)); cursor: nwse-resize; }
.editor-scene-handle.handle-ne { top: calc(var(--handle-screen, 22px) * -0.5 * var(--inv-scale, 1)); right: calc(var(--handle-screen, 22px) * -0.5 * var(--inv-scale, 1)); cursor: nesw-resize; }
.editor-scene-handle.handle-sw { bottom: calc(var(--handle-screen, 22px) * -0.5 * var(--inv-scale, 1)); left: calc(var(--handle-screen, 22px) * -0.5 * var(--inv-scale, 1)); cursor: nesw-resize; }
.editor-scene-handle.handle-se { bottom: calc(var(--handle-screen, 22px) * -0.5 * var(--inv-scale, 1)); right: calc(var(--handle-screen, 22px) * -0.5 * var(--inv-scale, 1)); cursor: nwse-resize; }
.editor-scene-handle.handle-n  { top: calc(var(--handle-screen, 22px) * -0.29 * var(--inv-scale, 1)); left: 50%; transform: translateX(-50%); cursor: ns-resize; }
.editor-scene-handle.handle-s  { bottom: calc(var(--handle-screen, 22px) * -0.29 * var(--inv-scale, 1)); left: 50%; transform: translateX(-50%); cursor: ns-resize; }
.editor-scene-handle.handle-e  { right: calc(var(--handle-screen, 22px) * -0.29 * var(--inv-scale, 1)); top: 50%; transform: translateY(-50%); cursor: ew-resize; }
.editor-scene-handle.handle-w  { left: calc(var(--handle-screen, 22px) * -0.29 * var(--inv-scale, 1)); top: 50%; transform: translateY(-50%); cursor: ew-resize; }

/* Hover/active — увеличение для feedback */
.editor-scene-handle:hover {
  background: var(--c-accent);
  transform: scale(1.1);
}

/* ── Ручка ПОВОРОТА — кружок над верхним краем по центру (Word/Visio) ──── */
.editor-rotate-handle {
  position: absolute;
  left: 50%;
  top: calc(var(--handle-screen, 22px) * -1.7 * var(--inv-scale, 1));
  margin-left: calc(var(--handle-screen, 22px) * -0.5 * var(--inv-scale, 1));
  width: calc(var(--handle-screen, 22px) * var(--inv-scale, 1));
  height: calc(var(--handle-screen, 22px) * var(--inv-scale, 1));
  background: #fff;
  border: calc(2px * var(--inv-scale, 1)) solid var(--c-accent);
  border-radius: 50%;
  box-shadow: 0 calc(2px * var(--inv-scale, 1)) calc(6px * var(--inv-scale, 1)) rgba(0, 0, 0, 0.22);
  z-index: 9;
  display: none;
  cursor: grab;
}
.editor-rotate-handle:active { cursor: grabbing; }
.editor-rotate-handle:hover { background: var(--c-accent); }
.scene.selected .editor-rotate-handle,
.scene.editor-scene-selected .editor-rotate-handle { display: block; }
/* стебель — линия от кружка к верхнему краю объекта */
.editor-rotate-stem {
  position: absolute;
  left: 50%;
  top: 100%;
  width: calc(2px * var(--inv-scale, 1));
  height: calc(var(--handle-screen, 22px) * 1.2 * var(--inv-scale, 1));
  margin-left: calc(-1px * var(--inv-scale, 1));
  background: var(--c-accent);
}

/* ── Панель свойств: поворот/отражение — плашки-иконки (Word/Visio) ────── */
.obj-transform-row { display: flex; gap: 6px; margin: 4px 0 10px; }
.obj-transform-btn {
  width: 34px; height: 34px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); border-radius: 7px;
  background: var(--ed-surface); color: var(--ink-2); cursor: pointer;
  transition: background 120ms var(--ease-quick), color 120ms var(--ease-quick), border-color 120ms var(--ease-quick);
}
.obj-transform-btn:hover { color: var(--accent); border-color: var(--accent); background: var(--c-neutral-100); }
.obj-transform-btn.active { color: var(--accent); border-color: var(--accent); background: var(--c-neutral-200); }
.obj-transform-btn i, .obj-transform-btn svg { width: 18px; height: 18px; }
.editor-scene-handle.handle-n:hover,
.editor-scene-handle.handle-s:hover { transform: translateX(-50%) scale(1.1); }
.editor-scene-handle.handle-e:hover,
.editor-scene-handle.handle-w:hover { transform: translateY(-50%) scale(1.1); }

/* ── Snap guides (pink dashed во время drag, snap-line) ───────────────── */

/* Smart-guide отрезки (рисуются только между выровненными объектами). */
.editor-snap-seg {
  position: absolute;
  pointer-events: none;
  z-index: 99;
}
.editor-snap-seg.seg-v { width: 0; border-left: 2px dashed #ff39a4; }
.editor-snap-seg.seg-h { height: 0; border-top: 2px dashed #ff39a4; }

/* ── Кнопки управления видом холста (низ-право, над мини-картой) ──────── */
/* Прибиты к НИЗУ холста, в один ряд слева от мини-карты (как кнопка
   сворачивания). right зависит от состояния мини-карты: развёрнута (220px) —
   сдвигаемся левее; свёрнута (34px) — встаём вплотную к ней. */
.editor-canvas-tools {
  position: absolute;
  right: 236px;                  /* 8 (отступ карты) + 220 (карта) + 8 (зазор) */
  bottom: 8px;                   /* та же нижняя линия, что у мини-карты */
  z-index: 51;
  display: flex;
  flex-direction: row;
  gap: 6px;
}
.editor-canvas-wrap.minimap-collapsed .editor-canvas-tools {
  right: 50px;                   /* 8 + 34 (свёрнутая карта) + 8 */
}
.editor-canvas-tool {
  width: 34px; height: 34px; padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--ed-surface);        /* токены → следует теме UI */
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  color: var(--ink-2);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 120ms var(--ease-quick), color 120ms var(--ease-quick), border-color 120ms var(--ease-quick);
}
.editor-canvas-tool:hover { color: var(--accent); border-color: var(--accent); }
.editor-canvas-tool:active { transform: translateY(1px); }
.editor-canvas-tool i, .editor-canvas-tool svg { width: 18px; height: 18px; }
/* В превью (камера-режим) дизайн-хром скрыт. */
.editor-canvas-wrap.preview-on .editor-canvas-tools { display: none; }

/* ── Mini-map (overview всего world в углу canvas) ───────────────────── */

.editor-minimap {
  position: absolute;
  right: 8px;
  bottom: 8px;
  width: 220px;
  background: var(--c-neutral-50);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.12);
  overflow: hidden;
  z-index: 50;
  cursor: crosshair;
  aspect-ratio: 16 / 9;
}
.editor-minimap:hover { border-color: var(--accent); }
/* Авто-скрытие на узком холсте (<400px) — иначе 220px-карта занимает почти весь
   вьюпорт и наезжает на подсказку/объекты. Ставит renderMiniMap; !important
   перебивает inline display от тумблера «Вид». */
.editor-minimap.auto-hidden { display: none !important; }
.editor-minimap svg {
  width: 100%;
  height: 100%;
  display: block;
}
/* Кнопка свернуть/развернуть мини-карту (правый верхний угол). */
.editor-minimap-toggle {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 18px;
  height: 18px;
  padding: 0;
  border: none;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  color: var(--ink-2);
  cursor: pointer;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
}
.editor-minimap-toggle:hover { background: #fff; color: var(--accent); }
.editor-minimap-toggle i,
.editor-minimap-toggle svg { width: 12px; height: 12px; }
/* Свёрнутое состояние — маленький квадрат (~10% ширины), карта скрыта,
   кнопка занимает весь квадрат и разворачивает по клику. */
.editor-minimap.collapsed {
  width: 34px;                   /* = размеру кнопок .editor-canvas-tool (один ряд) */
  aspect-ratio: 1 / 1;
  cursor: pointer;
}
.editor-minimap.collapsed > svg { display: none; }  /* прячем только саму карту, не иконку кнопки */
.editor-minimap.collapsed .editor-minimap-toggle {
  inset: 0;
  width: auto;
  height: auto;
  border-radius: 6px;
  background: var(--c-neutral-50);
  box-shadow: none;
  color: var(--accent);
}
.editor-minimap.collapsed .editor-minimap-toggle i,
.editor-minimap.collapsed .editor-minimap-toggle svg { width: 16px; height: 16px; stroke-width: 2.4; }

/* ── Cmd+K command palette ────────────────────────────────────────────── */

/* CSS-защита: palette НЕ показывается на вкладке "Автогенерация" даже если
   JS почему-то поставил hidden=false. Это hard-guard поверх JS-проверок. */
body:not([data-view="editor"]) .cmdk-overlay,
body:not([data-view="editor"]) #cmdk-overlay {
  display: none !important;
}

/* HARD-GUARD: hidden-атрибут должен скрывать overlay даже когда
   .cmdk-overlay { display: flex } применилось. Без !important `display:flex`
   ниже побеждает `[hidden] { display: none }` (атрибут vs класс — равный
   specificity, последний выигрывает в каскаде). Из-за этого Esc «не работал»:
   `hidden = true` ставился, но overlay оставался виден. */
.cmdk-overlay[hidden],
#cmdk-overlay[hidden] {
  display: none !important;
}

.cmdk-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(4px);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding-top: 12vh;
  animation: cmdk-fadein 120ms ease-out;
}
@keyframes cmdk-fadein {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.cmdk-panel {
  width: 600px;
  max-width: 92vw;
  background: var(--ed-surface);
  border: 1px solid var(--c-neutral-200);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: cmdk-slidein 160ms cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes cmdk-slidein {
  from { transform: translateY(-8px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
.cmdk-search {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--c-neutral-200);
}
.cmdk-search-icon {
  width: 16px; height: 16px;
  color: var(--c-neutral-500);
  flex-shrink: 0;
}
.cmdk-search input {
  flex: 1;
  border: 0;
  outline: 0;
  font-family: inherit;
  font-size: 14px;
  background: transparent;
  color: var(--c-neutral-900);
}
.cmdk-search input::placeholder { color: var(--c-neutral-400); }
.cmdk-search kbd {
  padding: 1px 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--c-neutral-100);
  border: 1px solid var(--c-neutral-200);
  border-radius: 4px;
  color: var(--c-neutral-600);
  cursor: pointer;
}
.cmdk-search kbd:hover {
  background: var(--c-neutral-200);
  color: var(--c-neutral-800);
}
.cmdk-list {
  list-style: none;
  margin: 0;
  padding: 4px;
  max-height: 50vh;
  overflow-y: auto;
}
.cmdk-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  color: var(--c-neutral-700);
}
.cmdk-list li.active {
  background: var(--c-neutral-100);
  color: var(--c-neutral-900);
}
.cmdk-list li i.lucide,
.cmdk-list li svg.lucide {
  width: 14px;
  height: 14px;
  color: var(--c-neutral-500);
  flex-shrink: 0;
}
.cmdk-list li .cmd-name { flex: 1; }
.cmdk-list li .cmd-shortcut {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--c-neutral-400);
}
.cmdk-list .cmdk-empty {
  padding: 20px;
  text-align: center;
  color: var(--c-neutral-400);
  font-size: 13px;
}
.cmdk-footer {
  display: flex;
  gap: 16px;
  padding: 8px 14px;
  border-top: 1px solid var(--c-neutral-200);
  background: var(--c-neutral-50);
  font-size: 11px;
  color: var(--c-neutral-500);
}
.cmdk-footer kbd {
  padding: 1px 5px;
  font-family: var(--font-mono);
  font-size: 10px;
  background: var(--ed-surface);
  border: 1px solid var(--c-neutral-200);
  border-radius: 3px;
  color: var(--c-neutral-700);
}

/* ── Toast notifications ──────────────────────────────────────────────── */

.toast-container {
  position: fixed;
  /* Верх-право (ниже ленты ribbon), а НЕ низ: снизу тосты перекрывали таймлайн
     и мешали с ним работать. column-reverse → новый тост у верхнего края. */
  top: 150px;
  right: 16px;
  z-index: 999;
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  min-width: 280px;
  max-width: 420px;
  padding: 10px 14px;
  background: var(--ed-surface);
  border: 1px solid var(--c-neutral-200);
  border-left: 4px solid var(--c-accent);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  font-size: 12px;
  color: var(--c-neutral-800);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: toast-in 200ms cubic-bezier(0.16, 1, 0.3, 1);
}
.toast.ok    { border-left-color: var(--c-success); }
.toast.warn  { border-left-color: var(--c-warning); }
.toast.error { border-left-color: var(--c-danger);  }
.toast i.lucide, .toast svg.lucide {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}
.toast.ok    svg.lucide { color: var(--c-success); }
.toast.warn  svg.lucide { color: var(--c-warning); }
.toast.error svg.lucide { color: var(--c-danger);  }
.toast.removing { animation: toast-out 200ms ease-in forwards; }
@keyframes toast-in {
  from { transform: translateX(20px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}
@keyframes toast-out {
  from { transform: translateX(0);    opacity: 1; }
  to   { transform: translateX(20px); opacity: 0; }
}

/* ── Onboarding hint поверх пустого холста ────────────────────────────── */

.editor-empty-hint {
  position: absolute;
  top: 16px;
  left: 16px;
  max-width: 480px;
  padding: 16px 44px 16px 22px;  /* 44px справа — место под крестик */
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.10);
  z-index: 40;
  pointer-events: auto;  /* было none — нужно auto чтобы крестик кликался */
  font-size: 12px;
  line-height: 1.5;
  color: var(--ink);
}
/* Крестик в правом-верхнем углу подсказки. */
.editor-empty-hint-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 6px;
  color: var(--c-neutral-500);
  cursor: pointer;
  transition: background 120ms var(--ease-quick),
              color 120ms var(--ease-quick);
}
.editor-empty-hint-close:hover {
  background: var(--c-neutral-100);
  color: var(--c-neutral-900);
}
.editor-empty-hint-close i[data-lucide],
.editor-empty-hint-close svg.lucide {
  width: 14px;
  height: 14px;
  margin: 0;
  stroke-width: 2;
}
.editor-empty-hint h3 {
  margin: 0 0 10px;
  font-size: 14px;
  font-weight: 600;
}
.editor-empty-hint ol {
  margin: 0 0 8px;
  padding-left: 18px;
}
.editor-empty-hint ol li {
  margin-bottom: 8px;
}
.editor-empty-hint .small {
  margin: 6px 0 0;
  font-size: 11px;
  color: var(--muted);
}
.editor-empty-hint kbd {
  display: inline-block;
  padding: 0 5px;
  font-family: var(--font-mono);
  font-size: 10px;
  background: var(--page-bg);
  border: 1px solid var(--border-strong);
  border-radius: 3px;
}

/* ── Drawing cursor (emoji-рука над сценой во время animation_in.type=draw) */

.editor-draw-cursor {
  position: absolute;
  font-size: 56px;
  line-height: 1;
  pointer-events: none;
  z-index: 10;
  /* NB: НЕ добавлять transform: rotate() — наклон уводит остриё пера (tipx,tipy)
     с линии рисунка. Спрайт руки уже под естественным углом. Паритет с
     player.js (там руку не поворачиваем). */
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  transition: opacity 100ms linear;
}

/* ═══ Мобильная адаптация (A): CapCut-стиль ═══════════════════════════════
   Холст на всю ширину; «Ассеты»/«Свойства» — выезжающие нижние шторки; нижний
   док с кнопками открыть; затемнение-подложка. Десктоп (>820px) не затрагивается. */
.editor-mobile-dock { display: none; }
.editor-sheet-backdrop { display: none; }
.editor-pane-header .sheet-close { display: none; }
.ribbon-collapse-btn { display: none; }

@media (max-width: 820px) {
  #view-editor.active { gap: 6px; --timeline-h: 168px; }
  /* единственная колонка — холст; сплиттеры и боковые панели уходят из сетки */
  .editor-grid { grid-template-columns: 1fr; }
  .editor-grid > .editor-splitter-v { display: none; }
  /* боковые панели → выезжающие нижние шторки (поверх всего) */
  #editor-pane-assets, #editor-pane-inspector {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto;
    height: 58vh; max-height: 74vh; margin: 0; z-index: 600;
    border-radius: 16px 16px 0 0;
    transform: translateY(103%); transition: transform .26s ease;
    box-shadow: 0 -10px 36px rgba(0, 0, 0, .32);
  }
  #editor-pane-assets.sheet-open, #editor-pane-inspector.sheet-open { transform: translateY(0); }
  .editor-pane-header .sheet-close {
    display: inline-flex; margin-left: auto; border: none; background: none;
    font-size: 19px; line-height: 1; color: var(--c-neutral-500); cursor: pointer; padding: 2px 6px;
  }
  /* подложка-затемнение под открытой шторкой */
  .editor-sheet-backdrop {
    display: block; position: fixed; inset: 0; z-index: 590;
    background: rgba(10, 12, 18, .42); opacity: 0; pointer-events: none; transition: opacity .26s;
  }
  .editor-sheet-backdrop.show { opacity: 1; pointer-events: auto; }
  /* нижний док (только в редакторе) — кнопки открыть шторки */
  body[data-view="editor"] .editor-mobile-dock {
    display: flex; gap: 8px; position: fixed; left: 8px; right: 8px;
    bottom: 178px; z-index: 500; pointer-events: none;
  }
  .editor-mobile-dock button {
    pointer-events: auto; flex: 1; padding: 11px 8px; border: 1px solid var(--border, #d6dae2);
    border-radius: 13px; background: var(--ed-surface, #fff); color: var(--ink, #1c2230);
    font: 600 13px/1 inherit; box-shadow: 0 5px 16px rgba(0, 0, 0, .16); cursor: pointer;
  }
  .editor-mobile-dock button.active { background: #0071e3; color: #fff; border-color: #0071e3; }
  /* A3: миникарта/скроллбары на тач не нужны (есть пинч/пан) */
  .editor-minimap, .editor-scroll { display: none !important; }
  /* A3: компактный верхний тулбар — сворачиваемый ribbon-content + шеврон */
  .editor-ribbon.ribbon-collapsed { min-height: 0 !important; }
  .editor-ribbon.ribbon-collapsed .ribbon-content { display: none !important; }
  .ribbon-collapse-btn {
    display: inline-flex !important; align-items: center; justify-content: center;
    position: sticky; right: 2px; margin-left: auto; flex-shrink: 0;
    width: 32px; height: 28px; border: 1px solid var(--border, #d6dae2); border-radius: 8px;
    background: var(--ed-surface, #fff); color: var(--ink, #555); font-size: 14px; cursor: pointer;
  }
}
