/* «Чик Чик», стиль «Плакат на чёрном» (23.10.2026, выбран Владиславом из макетов sketches/002-poster-on-black):
   одна тёмная тема — «чёрная бумага»; лайм с логотипа — плакатная шапка, действие и выбранное;
   заголовки и главные кнопки — Unbounded капсом, текст — Onest. Без кнопок-таблеток (скругление 8–18 px). */
:root {
  --bg: #0B0B0C;
  --surface: #151517;
  --surface-2: #1D1D20;
  --ink: #F3F3EF;
  --ink-2: #A3A39E;
  --ink-3: #6B6B6F;
  --line: rgba(255,255,255,.08);
  --line-2: rgba(255,255,255,.14);
  --lime: #DDFB2D;
  --on-lime: #0A0A0A;
  --lime-tint: rgba(221,251,45,.10);
  --danger: #FF5A5F;

  /* старые имена — их ещё читают разметка и скрипты */
  --accent: var(--lime);
  --accent-ink: var(--lime);
  --on-accent: var(--on-lime);
  --accent-tint: var(--lime-tint);
  --border-soft: var(--line);
  --ring: var(--line);
  --ring-strong: var(--line-2);

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 18px;
  --tabbar-h: 78px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --display: 'Unbounded', 'Onest', -apple-system, sans-serif;

  --shadow-ring: inset 0 0 0 1px var(--line);
  --shadow-card: inset 0 0 0 1px var(--line);
  --shadow-lift: inset 0 0 0 1px var(--line-2), 0 12px 30px -12px rgba(0,0,0,.8);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
/* НЕ display:none — на iOS в вебвью Telegram скрытый через display:none
   <input type=file> иногда не отдаёт событие change после выбора файла */
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0; padding: 0; margin: -1px;
}

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Onest', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  padding-bottom: calc(var(--tabbar-h) + var(--safe-b) + 20px);
  min-height: 100vh;
}

/* ---------- плакатная шапка ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; background: var(--lime); color: var(--on-lime);
  border-radius: 0 0 22px 22px;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--display); font-size: 18px; font-weight: 900; letter-spacing: -0.03em; text-transform: uppercase;
}
.chip {
  background: var(--on-lime); color: var(--lime);
  border-radius: 10px; padding: 7px 10px;
  font-size: 12.5px; font-weight: 700;
  font-variant-numeric: tabular-nums;
}
/* на «Монтаже» шапка продолжается плакатом со слоганом и переключателем режима */
body[data-screen="montage"] .topbar { border-radius: 0; padding-bottom: 0; }
.poster-hero {
  margin: -12px -16px 0; padding: 16px 18px 20px;
  background: var(--lime); color: var(--on-lime); border-radius: 0 0 26px 26px;
}
.poster-hero h1 {
  margin: 0; font-family: var(--display); font-size: 29px; line-height: 1.04; font-weight: 900;
  letter-spacing: -0.03em; text-transform: uppercase;
}
.poster-hero p { margin: 8px 0 0; font-size: 14.5px; font-weight: 500; color: #3A4700; }

.screen { padding: 12px 16px 8px; display: flex; flex-direction: column; gap: 12px; }

.card {
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-card);
  padding: 16px;
}
.card-title {
  font-family: var(--display); font-size: 12.5px; font-weight: 800; text-transform: uppercase;
  letter-spacing: -0.01em; margin-bottom: 12px; color: var(--ink);
}

/* режим экрана «Монтаж»: субтитры или уникализатор (Этап 5) — внутри плаката */
.mode-switch {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; margin-top: 16px;
  border-radius: var(--r-md); background: rgba(0,0,0,.08);
}
.mode-btn {
  border: none; background: none; cursor: pointer; padding: 10px 8px;
  border-radius: 9px; font: inherit; font-size: 14px; font-weight: 700; color: #3A4700;
  transition: background .12s ease, color .12s ease;
}
.mode-btn.active { background: var(--on-lime); color: var(--lime); }
.card-hint { margin: 12px 0 0; font-size: 12.5px; line-height: 1.45; color: var(--ink-3); }
.uniq-note { margin: 0 4px; font-size: 12.5px; line-height: 1.45; color: var(--ink-3); }
.reel-copies { display: flex; gap: 6px; flex-shrink: 0; }
.reel-copies .reel-action { width: 34px; padding-left: 0; padding-right: 0; justify-content: center; }

/* ---------- загрузка видео ---------- */
.upload { padding: 14px; }
/* примерка: карточка с кадром прилипает к верху, пока листаешь настройки под ней */
.upload.has-tryon { position: sticky; top: 0; z-index: 5; box-shadow: 0 10px 24px rgba(0,0,0,.6); }
.tryon { display: flex; gap: 14px; align-items: center; margin-top: 12px; }
.tryon-frame {
  position: relative; flex: none; width: 42%; max-width: 170px; aspect-ratio: 9 / 16;
  border-radius: var(--r-md); overflow: hidden; background: #000;
}
.tryon-frame img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; display: block; }
.tryon-busy { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,.35); }
.tryon-title { font-family: 'Unbounded', sans-serif; font-weight: 700; font-size: 13px; text-transform: uppercase; color: var(--lime); }
.tryon-text .card-hint { margin-top: 8px; }
.dropzone {
  display: flex; align-items: center; gap: 14px;
  border-radius: var(--r-md); padding: 2px; cursor: pointer;
}
.dropzone:active { opacity: .85; }
.dz-icon {
  width: 48px; height: 48px; border-radius: 13px; flex-shrink: 0;
  background: var(--surface-2); color: var(--lime); box-shadow: inset 0 0 0 1.5px rgba(221,251,45,.4);
  display: flex; align-items: center; justify-content: center;
}
.dz-text { display: flex; flex-direction: column; gap: 2px; }
.dz-title { font-size: 16px; font-weight: 700; letter-spacing: -0.01em; }
.dz-hint { font-size: 12.5px; color: var(--ink-3); }

.file-picked {
  display: flex; align-items: center; gap: 12px;
  border-radius: var(--r-md); padding: 2px;
}
.file-ico {
  width: 48px; height: 48px; border-radius: 13px; flex-shrink: 0;
  background: var(--lime); color: var(--on-lime); display: flex; align-items: center; justify-content: center;
}
.file-name {
  font-size: 15px; font-weight: 700; color: var(--ink);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1;
}
.btn-icon {
  border: none; background: transparent; color: var(--ink-3);
  cursor: pointer; padding: 6px; display: flex; border-radius: var(--r-sm);
  flex-shrink: 0;
}
.btn-icon:active { background: var(--surface-2); color: var(--ink); }

/* ---------- выбор вариантов ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-opt {
  display: flex; align-items: center; gap: 8px;
  border-radius: 10px; padding: 9px 13px 9px 11px;
  font-size: 13.5px; font-weight: 600;
  background: var(--surface-2); cursor: pointer; color: var(--ink-2);
  box-shadow: inset 0 0 0 1px var(--line);
  transition: box-shadow .12s ease, color .12s ease;
}
.chip-opt .swatch {
  width: 16px; height: 16px; border-radius: 5px; flex-shrink: 0;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.25);
}
.chip-opt.active { color: var(--ink); box-shadow: inset 0 0 0 2px var(--lime); }

/* ---------- кнопки ---------- */
.btn-primary {
  border: none; border-radius: 16px;
  padding: 17px; font-family: var(--display); font-size: 14.5px; font-weight: 800;
  letter-spacing: -0.01em; text-transform: uppercase;
  color: var(--on-lime); background: var(--lime);
  cursor: pointer; transition: transform .08s ease, opacity .12s ease;
}
.btn-primary:active { transform: translateY(1px); }
.btn-primary:disabled {
  background: var(--surface); color: var(--ink-3); box-shadow: inset 0 0 0 1px var(--line); cursor: default; transform: none;
}
.btn-outline {
  font: inherit; font-size: 14.5px; font-weight: 600; color: var(--ink);
  background: var(--surface-2); border: none; box-shadow: inset 0 0 0 1px var(--line-2);
  border-radius: var(--r-md); padding: 12px; cursor: pointer;
}
.btn-outline:disabled { color: var(--ink-3); cursor: default; }

/* ---------- прогресс ---------- */
.progress-card { display: flex; flex-direction: column; gap: 10px; }
.progress-row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.progress-step { font-size: 15px; font-weight: 700; color: var(--ink); }
.progress-pct {
  font-family: var(--display); font-size: 22px; font-weight: 900; color: var(--lime);
  font-variant-numeric: tabular-nums;
}
.progress-track { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.progress-fill { height: 100%; width: 0%; border-radius: 4px; background: var(--lime); transition: width .5s ease; }
.progress-note { font-size: 12.5px; color: var(--ink-3); }

/* ---------- нижнее меню ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0;
  height: calc(var(--tabbar-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  background: rgba(11,11,12,.92);
  -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px);
  box-shadow: inset 0 1px 0 var(--line);
  display: flex; align-items: center; justify-content: space-around;
}
.tab {
  border: none; background: none; display: flex; flex-direction: column;
  align-items: center; gap: 5px; font-size: 10.5px; color: var(--ink-3);
  font-weight: 600; padding: 6px 8px; cursor: pointer; font-family: inherit;
}
.tab-ico { display: block; }
.tab-active { color: var(--lime); }

.toast {
  position: fixed; left: 16px; right: 16px;
  bottom: calc(var(--tabbar-h) + var(--safe-b) + 14px);
  background: var(--surface-2); color: var(--ink); box-shadow: var(--shadow-lift); text-align: center;
  padding: 12px 16px; border-radius: var(--r-md); font-size: 13.5px; font-weight: 600;
  opacity: 0; pointer-events: none; transform: translateY(6px);
  transition: opacity .2s ease, transform .2s ease;
}
.toast.show { opacity: 1; transform: translateY(0); }

/* ---------- экран «Ролики» ---------- */
.reel-list { display: flex; flex-direction: column; gap: 10px; }
.reel-card {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); box-shadow: var(--shadow-card);
  border-radius: var(--r-lg); padding: 10px;
}
.reel-thumb {
  width: 54px; height: 54px; border-radius: 11px;
  background: var(--surface-2);
  flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  color: var(--ink-3); overflow: hidden; position: relative;
}
.reel-thumb img { width: 100%; height: 100%; object-fit: cover; position: absolute; inset: 0; }
.reel-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.reel-top { display: flex; align-items: center; gap: 7px; }
.reel-dot { width: 8px; height: 8px; border-radius: 3px; flex-shrink: 0; }
.reel-date { font-size: 12.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.reel-status { font-size: 14px; font-weight: 700; color: var(--ink); }
.reel-status.is-muted { color: var(--ink-3); font-weight: 500; }
.reel-status.is-danger { color: var(--danger); }
.reel-action {
  flex-shrink: 0; border: none; border-radius: 10px;
  padding: 9px 13px; font: inherit; font-size: 13px; font-weight: 700;
  background: var(--lime); color: var(--on-lime); cursor: pointer;
  text-decoration: none; display: inline-flex; align-items: center;
}
.reel-action.is-ghost { background: var(--surface-2); color: var(--ink-2); box-shadow: inset 0 0 0 1px var(--line); }
.reel-actions { display: flex; gap: 6px; flex-shrink: 0; }

.empty-state { padding: 60px 20px; text-align: center; }
.empty-title { font-family: var(--display); font-size: 15px; font-weight: 800; text-transform: uppercase; margin-bottom: 8px; }
.empty-hint { font-size: 13.5px; color: var(--ink-3); }

/* ---------- экран «Профиль» ---------- */
.profile-head { display: flex; align-items: center; gap: 14px; }
.avatar {
  width: 52px; height: 52px; border-radius: 15px;
  background: var(--lime); color: var(--on-lime);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--display); font-size: 20px; font-weight: 900; flex-shrink: 0;
}
.profile-name { min-width: 0; }
.profile-fullname {
  font-size: 17px; font-weight: 700; letter-spacing: -0.01em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.profile-username { font-size: 13px; color: var(--ink-3); margin-top: 2px; }

.stat-row { display: flex; gap: 12px; }
.stat-tile { flex: 1; background: var(--surface); box-shadow: var(--shadow-card); border-radius: var(--r-lg); padding: 16px; }
.stat-num {
  font-family: var(--display); font-size: 28px; font-weight: 900; color: var(--lime);
  letter-spacing: -0.02em; font-variant-numeric: tabular-nums;
}
.stat-label { font-size: 12.5px; color: var(--ink-3); margin-top: 4px; }
/* суммы в рублях с копейками длиннее счётчиков — мельче и в одну строку */
.stat-num.money { font-size: 21px; white-space: nowrap; }

.action-list { padding: 4px; }
.action-row {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 12px; border-radius: var(--r-md);
  text-decoration: none; color: var(--ink);
}
.action-row:active { background: var(--surface-2); }
.action-ico {
  width: 34px; height: 34px; border-radius: 10px;
  background: var(--surface-2); color: var(--lime);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.action-label { flex: 1; font-size: 15px; font-weight: 600; }
.action-chev { color: var(--ink-3); display: flex; flex-shrink: 0; }
button.action-row { width: 100%; border: none; background: none; font: inherit; text-align: left; cursor: pointer; }

/* ---------- экран «Баланс» ---------- */
.price-card { display: flex; flex-direction: column; gap: 10px; }
.price-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.price-name { font-size: 15.5px; font-weight: 700; letter-spacing: -0.01em; }
.price-tag {
  flex-shrink: 0; background: var(--surface-2); color: var(--ink);
  border-radius: var(--r-sm); padding: 6px 10px;
  font-family: var(--display); font-size: 13.5px; font-weight: 800; font-variant-numeric: tabular-nums;
}
.price-tag-free { background: var(--lime); color: var(--on-lime); }
.price-desc { font-size: 13.5px; line-height: 1.45; color: var(--ink-2); margin: 0; }
.btn-price { margin-top: 2px; }
.price-offer { font-size: 12.5px; line-height: 1.45; color: var(--ink-3); margin: 0 4px; }
.price-offer a { color: var(--ink-2); }

/* ---------- «Пригласить» ---------- */
.referral-hero .card-title { margin-bottom: 8px; }
.referral-hint { font-size: 13.5px; line-height: 1.45; color: var(--ink-2); margin: 0; }
.referral-link-row {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface-2); border-radius: var(--r-md); padding: 10px 10px 10px 13px;
}
.referral-link {
  font-size: 13.5px; font-weight: 600; color: var(--ink-2);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1;
}

/* ---------- выбор хука ---------- */
.hook-card { display: flex; flex-direction: column; gap: 12px; }
.hook-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.hook-title { font-family: var(--display); font-size: 15px; font-weight: 800; text-transform: uppercase; letter-spacing: -0.01em; }
.hook-timer { font-size: 12.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; flex-shrink: 0; }
.hook-hint { font-size: 13px; line-height: 1.4; color: var(--ink-2); margin: -4px 0 0; }
.hook-list { display: flex; flex-direction: column; gap: 8px; }
.hook-opt {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  width: 100%; text-align: left; border: none; cursor: pointer;
  background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line);
  border-radius: var(--r-md); padding: 12px 14px; color: var(--ink);
  font-family: inherit; transition: box-shadow .12s ease;
}
.hook-opt.active { box-shadow: inset 0 0 0 2px var(--lime); }
.hook-l1 { font-size: 13px; color: var(--ink-2); }
.hook-l2 { font-family: var(--display); font-size: 19px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.15; }
.hook-opt.is-plain .hook-l2 { font-family: inherit; font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.hook-own { display: flex; flex-direction: column; gap: 10px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field-label { font-size: 12.5px; color: var(--ink-3); }
.field-input {
  font: inherit; font-size: 15px; color: var(--ink);
  background: var(--surface-2); border: none; box-shadow: inset 0 0 0 1px var(--line);
  border-radius: var(--r-md); padding: 12px 13px; outline: none;
}
.field-input::placeholder { color: var(--ink-3); }
.field-input:focus { box-shadow: inset 0 0 0 2px var(--lime); }

/* ---------- настройки ролика ---------- */
.settings-area { display: flex; flex-direction: column; gap: 12px; }
.group-title {
  font-family: var(--display); font-size: 13px; font-weight: 800; text-transform: uppercase;
  letter-spacing: -0.01em; color: var(--ink-3); margin: 10px 4px -2px;
}
/* шаблоны — лента карточек с превью во всю ширину карточки настроек */
.tpl-rail {
  display: flex; gap: 10px; overflow-x: auto; margin: 0 -16px; padding: 2px 16px 4px;
  scroll-snap-type: x mandatory; scrollbar-width: none;
}
.tpl-rail::-webkit-scrollbar { display: none; }
.tpl-card {
  flex: none; width: 128px; scroll-snap-align: start; border: none; cursor: pointer; text-align: left;
  border-radius: 15px; background: var(--surface-2); padding: 6px; font: inherit; color: var(--ink-2);
  box-shadow: inset 0 0 0 1px var(--line); transition: box-shadow .12s ease, color .12s ease;
}
.tpl-card img { display: block; width: 100%; aspect-ratio: 9 / 16; object-fit: cover; border-radius: 10px; background: #18161E; }
.tpl-card span { display: block; padding: 9px 4px 4px; font-size: 14px; font-weight: 700; }
.tpl-card.active { box-shadow: inset 0 0 0 2px var(--lime); color: var(--ink); }
.tpl-card.active span { color: var(--lime); }
/* «Шрифт и цвет» одной карточкой (макет sketches/003-carousel): превью — кадр рилса 9:16 между стрелками,
   название и деления под ним (.font-step раскрыт в сетку карточки через display: contents) */
.fc-part[data-key="style"] { display: grid; grid-template-columns: 40px 1fr 40px; align-items: center; column-gap: 10px; }
.style-preview {
  grid-column: 2; grid-row: 1; justify-self: center;
  display: block; width: min(100%, 200px); aspect-ratio: 9 / 16; object-fit: cover;
  border-radius: var(--r-md); background: #18161E;
}
.font-step { display: contents; }
.fs-arrow[data-d="-1"] { grid-column: 1; grid-row: 1; }
.fs-arrow[data-d="1"] { grid-column: 3; grid-row: 1; }
.fs-mid { grid-column: 1 / -1; grid-row: 2; margin-top: 12px; }
.fs-arrow {
  flex: none; width: 40px; height: 40px; border: none; border-radius: 11px; cursor: pointer;
  background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line-2); color: var(--ink);
  font: inherit; font-size: 22px; line-height: 1; display: flex; align-items: center; justify-content: center;
}
.fs-arrow:active { background: var(--lime); color: var(--on-lime); }
.fs-mid { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 7px; }
.fs-name { font-family: var(--display); font-size: 15px; font-weight: 800; text-transform: uppercase; }
.fs-ticks { display: flex; gap: 4px; }
.fs-ticks i { width: 14px; height: 4px; border-radius: 2px; background: var(--line-2); }
.fs-ticks i.on { background: var(--lime); }
.dots { display: flex; justify-content: space-between; }
.dot {
  width: 34px; height: 34px; border: none; border-radius: 50%; padding: 0; cursor: pointer; position: relative;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.3); transition: transform .12s ease;
}
.dot:active { transform: scale(.9); }
.dot.active::after { content: ""; position: absolute; inset: -5px; border-radius: 50%; box-shadow: 0 0 0 2px var(--lime); }
.font-color.both .fc-part + .fc-part { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }

/* ---------- правка текста субтитров (Этап 4) ---------- */
.text-edit { display: flex; flex-direction: column; gap: 10px; }
.text-edit-toggle {
  align-self: flex-start; border: none; background: none; padding: 2px 0; cursor: pointer;
  font: inherit; font-size: 14px; font-weight: 600; color: var(--ink-2);
  text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--line-2);
}
.text-edit-body { display: flex; flex-direction: column; gap: 10px; }
.text-area { resize: vertical; min-height: 140px; line-height: 1.45; }

/* ---------- редактор готового ролика: таймлайн как в CapCut (A1) ---------- */
/* экран на всю высоту без прокрутки страницы: превью сверху, таймлайн и инструменты снизу, карточки — шторкой */
body.is-editor { padding-bottom: 0; overflow: hidden; }
body.is-editor .tabbar, body.is-editor .topbar { display: none; }
.editor {
  position: fixed; inset: 0; padding: 6px 0 var(--safe-b); gap: 0;
  height: var(--tg-viewport-height, 100dvh); overflow: hidden; background: var(--bg);
}

.ed-head { display: flex; align-items: center; gap: 2px; min-height: 46px; padding: 0 10px 0 6px; flex-shrink: 0; }
.ed-head .btn-icon:disabled { opacity: .35; }
.ed-back { color: var(--ink); }
.ed-draft { flex: 1; min-width: 0; font-size: 12px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 4px; }
.ed-build {
  border: none; border-radius: var(--r-md); padding: 10px 13px; cursor: pointer; margin-left: 4px; white-space: nowrap;
  font: inherit; font-size: 13.5px; font-weight: 700; color: var(--on-lime); background: var(--lime);
  transition: opacity .12s ease;
}
.ed-build:disabled { background: var(--surface-2); color: var(--ink-3); cursor: default; }
.ed-build:not(:disabled):active { opacity: .85; }

.ed-stage { flex: 1; min-height: 120px; display: flex; justify-content: center; padding: 2px 0 6px; background: #000; }
.ed-viewer {
  position: relative; height: 100%; aspect-ratio: 9 / 16; max-width: 100%;
  border-radius: var(--r-md); overflow: hidden; background: #000;
}
.ed-viewer video, .ed-viewer img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.ed-viewer img { opacity: 0; }
.ed-viewer img.on { opacity: 1; }
.ed-busy {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; background: rgba(0,0,0,.45); color: #fff; font-size: 13px; font-weight: 600;
}
.ed-spin {
  width: 26px; height: 26px; border-radius: 50%;
  border: 2.5px solid rgba(255,255,255,.2); border-top-color: var(--lime);
  animation: ed-spin .8s linear infinite;
}
@keyframes ed-spin { to { transform: rotate(360deg); } }
.ed-badge {
  position: absolute; left: 8px; top: 8px; background: var(--lime); color: var(--on-lime);
  font-size: 11.5px; font-weight: 700; padding: 4px 8px; border-radius: var(--r-sm);
}

.ed-transport { display: flex; align-items: center; gap: 10px; height: 50px; padding: 0 14px; flex-shrink: 0; }
.ed-transport > .ed-time, .ed-transport-end { flex: 1; }
.ed-transport-end { display: flex; justify-content: flex-end; }
.ed-play {
  width: 40px; height: 40px; border-radius: 50%; border: none; flex-shrink: 0; cursor: pointer;
  background: var(--ink); color: #000; display: flex; align-items: center; justify-content: center;
}
.ed-play .i-pause, .ed-play.playing .i-play { display: none; }
.ed-play.playing .i-pause { display: block; }
.ed-time { font-size: 12.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.ed-time b { color: var(--ink); font-weight: 600; }
.ed-zoom {
  height: 30px; min-width: 40px; padding: 0 9px; border: none; border-radius: var(--r-sm); cursor: pointer;
  font: inherit; font-size: 12px; font-weight: 700; background: var(--surface-2); color: var(--ink-2);
}
.ed-cutveil {
  position: absolute; inset: 0; display: flex; align-items: flex-end; justify-content: center; padding-bottom: 14px;
  background: rgba(0,0,0,.55); pointer-events: none;
}
.ed-cutveil span { background: var(--danger); color: #fff; font-size: 12px; font-weight: 700; padding: 5px 10px; border-radius: var(--r-sm); }

/* таймлайн: ряды кладёт editor.js (renderTimeline), высота — по рядам */
.ed-tlwrap { position: relative; flex-shrink: 0; border-top: 1px solid var(--line); }
.ed-tl { position: absolute; inset: 0; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; overscroll-behavior-x: contain; }
.ed-tl::-webkit-scrollbar { display: none; }
.ed-tl-in { position: relative; height: 100%; }
.ed-lane { position: absolute; }
.ed-ruler { font-size: 9.5px; color: var(--ink-3); }
.ed-ruler span { position: absolute; top: 0; transform: translateX(-50%); font-variant-numeric: tabular-nums; }
.ed-ruler i { position: absolute; bottom: 0; width: 1px; height: 4px; background: var(--ink-3); }
.ed-tl-head {
  position: absolute; top: 4px; bottom: 4px; left: 50%; width: 2px; margin-left: -1px; border-radius: 1px;
  background: var(--ink); z-index: 8; pointer-events: none; box-shadow: 0 0 0 1px rgba(0,0,0,.45);
}
.ed-tl-head::before { content: ""; position: absolute; top: -2px; left: -4px; width: 10px; height: 10px; border-radius: 3px; background: var(--ink); }
.ed-tl-labels {
  position: absolute; left: 0; top: 0; bottom: 0; width: 34px; z-index: 6; pointer-events: none;
  background: linear-gradient(90deg, var(--bg) 55%, transparent);
}
.ed-tl-labels svg {
  position: absolute; left: 5px; color: var(--ink-3); box-sizing: content-box; padding: 3px;
  background: var(--bg); border-radius: 6px;          /* кусок, уехавший под иконку, её не перекрывает */
}
.ed-clip {
  position: absolute; top: 0; bottom: 0; border-radius: 6px; overflow: hidden; cursor: pointer;
  display: flex; align-items: center; gap: 4px; padding: 0 7px; white-space: nowrap;
  font-size: 11.5px; font-weight: 600; border: none; font-family: inherit; text-align: left;
}
.ed-clip.sub { background: rgba(221,251,45,.15); color: #E9F98C; box-shadow: inset 0 0 0 1px rgba(221,251,45,.28); }
.ed-clip-t { display: block; min-width: 0; flex: 1; overflow: hidden; white-space: nowrap; pointer-events: none; }
.ed-clip.sub b { color: var(--lime); font-weight: 800; }
.ed-clip.sub s { opacity: .5; }
.ed-clip.sub.changed::after { content: ""; position: absolute; right: 4px; top: 4px; width: 6px; height: 6px; border-radius: 50%; background: var(--danger); }
.ed-clip.hook { background: rgba(255,255,255,.12); color: var(--ink); box-shadow: inset 0 0 0 1px rgba(255,255,255,.22); }
.ed-clip.ins { background: rgba(255,143,216,.15); color: #FF9BDC; box-shadow: inset 0 0 0 1px rgba(255,143,216,.3); }
.ed-clip.snd { background: rgba(111,211,255,.14); color: #7FD8FF; box-shadow: inset 0 0 0 1px rgba(111,211,255,.28); font-size: 10.5px; padding: 0 5px; cursor: default; }
.ed-clip.sel { box-shadow: inset 0 0 0 2px var(--lime); z-index: 3; }
.ed-vid { position: absolute; inset: 0; border-radius: 6px; overflow: hidden; background: var(--surface-2); }
.ed-thumb { position: absolute; top: 0; bottom: 0; background-repeat: no-repeat; }
.ed-shotcut { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: var(--bg); z-index: 2; }
.ed-still { position: absolute; top: 0; bottom: 0; border-radius: 6px; background: repeating-linear-gradient(90deg, var(--surface-2) 0 6px, var(--surface) 6px 12px); }
/* Р8: куски, которые уйдут при «Собрать» */
.ed-cutzone {
  position: absolute; top: 0; bottom: 0; min-width: 3px; z-index: 4; cursor: pointer;
  background: repeating-linear-gradient(135deg, rgba(255,90,95,.8) 0 4px, rgba(0,0,0,.55) 4px 8px);
}
.ed-cutzone.sel { box-shadow: inset 0 0 0 2px var(--lime); }
.ed-wave { position: absolute; inset: 0; border-radius: 6px; background: rgba(111,211,255,.07); overflow: hidden; cursor: pointer; border: none; padding: 0; }
.ed-wave path { stroke: #6FD3FF; stroke-width: 1.5; opacity: .7; }
.ed-wave.sel { box-shadow: inset 0 0 0 2px var(--lime); }
/* A2/A4: выбранный кусок тянут пальцем — лента под ним не прокручивается */
.ed-clip.sel, .ed-shot.sel { touch-action: none; overflow: visible; }
.ed-clip.snd { cursor: pointer; }
.ed-h {
  position: absolute; top: 0; bottom: 0; width: 16px; background: var(--lime); z-index: 4; touch-action: none; cursor: ew-resize;
}
.ed-h::after { content: ""; position: absolute; left: 7px; top: 28%; bottom: 28%; width: 2px; border-radius: 1px; background: var(--on-lime); }
.ed-h.l { left: -14px; border-radius: 6px 0 0 6px; }
.ed-h.r { right: -14px; border-radius: 0 6px 6px 0; }
.ed-shot { position: absolute; top: 0; bottom: 0; z-index: 3; border: none; padding: 0; background: none; cursor: pointer; border-radius: 6px; }
.ed-shot.sel { box-shadow: inset 0 0 0 2px var(--lime); }
.ed-shot .ed-h.l { left: 0; border-radius: 6px 0 0 6px; }
.ed-shot .ed-h.r { right: 0; border-radius: 0 6px 6px 0; }
.ed-clip.dragging, .ed-shot.dragging { opacity: .85; }
.ed-trim { position: absolute; top: 0; bottom: 0; z-index: 4; pointer-events: none;
  background: repeating-linear-gradient(135deg, rgba(255,90,95,.8) 0 4px, rgba(0,0,0,.55) 4px 8px); }
/* A3: рамка выбранного титра на превью — тянуть по вертикали */
.ed-box {
  position: absolute; z-index: 5; border: 1.5px dashed var(--lime); border-radius: 6px; touch-action: none; cursor: grab;
  box-shadow: 0 0 0 9999px rgba(0,0,0,.18);
}
.ed-box.dragging { cursor: grabbing; box-shadow: 0 0 0 9999px rgba(0,0,0,.32); }
.ed-box span {
  position: absolute; left: 50%; bottom: -26px; transform: translateX(-50%); white-space: nowrap; pointer-events: none;
  font-size: 11px; font-weight: 700; color: var(--on-lime); background: var(--lime); padding: 3px 7px; border-radius: 6px;
}
.ed-vol { display: flex; align-items: center; gap: 12px; }
.ed-vol input { flex: 1; accent-color: var(--lime); }
.ed-vol b { width: 48px; text-align: right; font-variant-numeric: tabular-nums; font-size: 14px; }

.ed-tools-box { position: relative; flex-shrink: 0; border-top: 1px solid var(--line); }
.ed-ctx {
  position: absolute; left: 12px; top: -30px; z-index: 9; font-size: 11.5px; font-weight: 700;
  color: var(--on-lime); background: var(--lime); padding: 3px 8px; border-radius: 6px; white-space: nowrap;
}
.ed-tools { display: flex; height: 70px; overflow-x: auto; scrollbar-width: none; padding: 0 4px; }
.ed-tools::-webkit-scrollbar { display: none; }
.ed-tools.more { -webkit-mask-image: linear-gradient(90deg, #000 82%, transparent); mask-image: linear-gradient(90deg, #000 82%, transparent); }
.ed-tool {
  flex: none; min-width: 64px; padding: 0 6px; border: none; background: none; cursor: pointer; border-radius: var(--r-sm);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px;
  font: inherit; font-size: 10.5px; font-weight: 600; color: var(--ink-2); white-space: nowrap;
}
.ed-tool svg { width: 22px; height: 22px; }
.ed-tool:active { background: var(--surface); color: var(--ink); }
.ed-tool.back { min-width: 44px; color: var(--ink); box-shadow: inset -1px 0 0 var(--line); border-radius: 0; }
.ed-tool.accent { color: var(--lime); }
.ed-tool.danger { color: var(--danger); }
.ed-tool .ed-count { color: var(--lime); }

/* карточки правок — шторкой поверх таймлайна, превью остаётся видно */
.ed-sheet {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 20; max-height: 62%; overflow-y: auto;
  background: var(--surface); border-radius: 18px 18px 0 0; padding-bottom: var(--safe-b);
  box-shadow: 0 -12px 40px rgba(0,0,0,.7), inset 0 1px 0 var(--line-2);
}
.ed-sheet.low { max-height: 34%; }
.ed-change-row.ed-ov-row { display: flex; align-items: center; gap: 8px; }   /* .ed-change-row ниже ставит block */
.ed-ov-row > span { flex: 1; }
.ed-ov-row small { display: block; font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.ed-ov-row.active { box-shadow: inset 0 0 0 1.5px var(--lime); }
.ed-ov-new { width: 100%; margin-top: 10px; }
.ed-crop { position: relative; touch-action: none; user-select: none; border-radius: var(--r-md); overflow: hidden; background: #000; }
.ed-crop img, .ed-crop video { display: block; width: 100%; height: auto; pointer-events: none; }
.ed-crop-box { position: absolute; box-shadow: 0 0 0 9999px rgba(0,0,0,.55); border: 1.5px dashed var(--lime); cursor: move; }
.ed-crop-handle {
  position: absolute; right: -9px; bottom: -9px; width: 18px; height: 18px; border-radius: 6px;
  background: var(--lime); box-shadow: 0 0 0 1px rgba(0,0,0,.4); cursor: nwse-resize;
}
.ed-group-title { font-size: 12.5px; font-weight: 600; color: var(--ink-3); margin: 2px 0 -2px; }
.ed-sample { display: block; width: min(46%, 180px); margin: 0 auto; aspect-ratio: 9 / 16; object-fit: cover; border-radius: var(--r-md); background: #18161E; }
.ed-cover { display: flex; gap: 12px; align-items: center; }
.ed-cover img { width: 72px; aspect-ratio: 9 / 16; object-fit: cover; border-radius: var(--r-sm); background: #000; flex-shrink: 0; }

.ed-card { display: flex; flex-direction: column; gap: 12px; padding: 14px; }
.ed-sec { display: flex; flex-direction: column; gap: 8px; }
.ed-sec + .ed-sec { padding-top: 12px; box-shadow: inset 0 1px 0 var(--line); }
.ed-sec-head { display: flex; align-items: baseline; gap: 10px; }
.ed-sec-title { font-size: 13px; font-weight: 600; color: var(--ink-2); flex: 1; }
.ed-mark { font-size: 12px; font-weight: 600; color: var(--danger); }
.ed-revert {
  border: none; background: none; padding: 0; cursor: pointer; font: inherit;
  font-size: 12.5px; color: var(--ink-3); text-decoration: underline; text-underline-offset: 3px;
}
.ed-field {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; cursor: pointer;
  border: none; font: inherit; color: var(--ink); background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line);
  border-radius: var(--r-md); padding: 12px 13px;
}
.ed-field-text { flex: 1; font-size: 16px; font-weight: 700; letter-spacing: -0.01em; line-height: 1.3; }
.ed-field-text small { display: block; font-size: 12.5px; font-weight: 500; color: var(--ink-3); margin-bottom: 2px; }
.ed-field-text.is-muted { color: var(--ink-3); font-weight: 600; }
.ed-field svg { color: var(--ink-3); flex-shrink: 0; }
.ed-row {
  display: flex; align-items: center; gap: 10px; width: 100%; border: none; background: none; cursor: pointer;
  font: inherit; font-size: 14.5px; font-weight: 600; color: var(--ink); padding: 10px 2px; text-align: left;
}
.ed-row-val { margin-left: auto; font-size: 13px; font-weight: 500; color: var(--ink-3); }
.ed-row svg { color: var(--ink-3); flex-shrink: 0; }

.ed-sub-head { display: flex; align-items: center; gap: 10px; }
.ed-sub-head .btn-icon { margin-left: -6px; }
.ed-sub-title { font-family: var(--display); font-size: 14px; font-weight: 800; text-transform: uppercase; letter-spacing: -0.01em; }
.ed-hint { font-size: 12.5px; line-height: 1.4; color: var(--ink-3); margin: 0; }
.ed-radio {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; cursor: pointer;
  border: none; font: inherit; color: var(--ink); background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line);
  border-radius: var(--r-md); padding: 12px 13px;
}
.ed-radio.active { box-shadow: inset 0 0 0 2px var(--lime); }
.ed-radio-text { flex: 1; font-size: 14.5px; font-weight: 600; }
.ed-radio-text small { display: block; font-size: 12.5px; font-weight: 500; color: var(--ink-3); margin-top: 2px; }
.ed-dot { width: 18px; height: 18px; border-radius: 50%; box-shadow: inset 0 0 0 1.5px var(--line-2); flex-shrink: 0; }
.ed-radio.active .ed-dot { box-shadow: inset 0 0 0 5px var(--lime); }
.ed-actions { display: flex; gap: 8px; }
.ed-actions .btn-primary { flex: 1; padding: 13px; }
.ed-actions .btn-outline { flex: 0 0 auto; padding: 12px 18px; }
.ed-words { display: flex; flex-wrap: wrap; gap: 7px; }
.ed-words-cut .chip-opt.active { color: var(--danger); text-decoration: line-through; box-shadow: inset 0 0 0 2px var(--danger); }
.ed-cut-info { color: var(--ink-2); font-weight: 600; }
.ed-cut-reset { width: 100%; margin-top: 10px; }

.ed-change-row {
  display: block; width: 100%; text-align: left; border: none; background: var(--surface-2); cursor: pointer;
  font: inherit; font-size: 13.5px; line-height: 1.35; color: var(--ink); box-shadow: inset 0 0 0 1px var(--line);
  border-radius: var(--r-md); padding: 11px 13px;
}
/* в редакторе тост сверху, на превью: внизу он закрывал дорожки ленты и строки шторки */
body.is-editor .toast { top: 62px; bottom: auto; z-index: 30; }

/* ---------- админка (только BOT_ADMINS) ---------- */
body.is-admin .tabbar, body.is-admin .topbar { display: none; }
.adm-head { display: flex; align-items: center; justify-content: space-between; padding-top: 4px; }
.adm-tabs { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 0 16px 2px; }
.adm-tabs::-webkit-scrollbar { display: none; }
.adm-tabs button {
  flex-shrink: 0; border: none; border-radius: 10px; padding: 8px 11px; cursor: pointer;
  font: inherit; font-size: 12.5px; font-weight: 600; background: var(--surface-2); color: var(--ink-2);
}
.adm-tabs button.active { background: var(--lime); color: var(--on-lime); }
#admBody { display: flex; flex-direction: column; gap: 12px; }
.adm-sec-title { font-family: var(--display); font-size: 12px; font-weight: 800; text-transform: uppercase; color: var(--ink-3); margin: 6px 4px -4px; }
.adm-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.adm-tile { background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-card); padding: 14px; min-width: 0; }
.adm-num { font-family: var(--display); font-size: 21px; font-weight: 900; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.adm-label { font-size: 12.5px; color: var(--ink-3); margin-top: 3px; }
.adm-sub { font-size: 12px; color: var(--ink-3); margin-top: 6px; }
.adm-warn { color: var(--danger); }
.adm-list { display: flex; flex-direction: column; padding: 4px 0; }
.adm-row {
  display: flex; align-items: center; gap: 10px; padding: 11px 14px; border: none; background: none;
  font: inherit; text-align: left; color: var(--ink); width: 100%; cursor: default;
}
button.adm-row { cursor: pointer; }
button.adm-row:active { background: var(--surface-2); }
.adm-row + .adm-row { border-top: 1px solid var(--line); }
.adm-row-main { flex: 1; min-width: 0; }
.adm-row-title { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.adm-row-meta { font-size: 12.5px; color: var(--ink-3); margin-top: 2px; line-height: 1.4; overflow-wrap: anywhere; }
.adm-row-side { font-size: 13px; color: var(--ink-2); flex-shrink: 0; font-variant-numeric: tabular-nums; }
.adm-tag {
  display: inline-block; font-size: 11.5px; font-weight: 600; padding: 2px 7px; border-radius: 6px;
  background: var(--surface-2); color: var(--ink-2); margin-left: 6px; vertical-align: 1px;
}
.adm-tag.is-danger { color: var(--danger); }
.adm-err { font-size: 12px; color: var(--danger); margin-top: 3px; overflow-wrap: anywhere; }
.adm-bar { height: 6px; border-radius: 3px; background: var(--surface-2); margin-top: 6px; overflow: hidden; }
.adm-bar > span { display: block; height: 100%; background: var(--lime); border-radius: 3px; }
.adm-search { width: 100%; }
.adm-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.adm-actions > * { flex: 1; min-width: 0; }
.adm-form { display: flex; flex-direction: column; gap: 10px; }
.adm-form textarea.field-input { min-height: 120px; resize: vertical; line-height: 1.45; }
.adm-count { font-size: 12px; color: var(--ink-3); text-align: right; margin-top: -4px; }
.adm-empty { padding: 14px; font-size: 13px; color: var(--ink-3); }
