/* Vollkorn — серіф для великих заголовків (editorial-вигляд). Варіативний файл
   покриває всі насиченості одним завантаженням. */
@font-face {
  font-family: "Vollkorn";
  src: url("/static/assets/fonts/Vollkorn-VariableFont_wght.ttf") format("truetype");
  font-weight: 400 900; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Vollkorn";
  src: url("/static/assets/fonts/Vollkorn-Italic-VariableFont_wght.ttf") format("truetype");
  font-weight: 400 900; font-style: italic; font-display: swap;
}

:root {
  --bg: #0e0c0b;         /* теплий майже-чорний (з ледь цегляним підтоном) */
  --bg-2: #171311;       /* панелі, сайдбар */
  --bg-3: #211b18;       /* поля вводу, картки */
  --line: #322824;       /* рамки, розділювачі (теплі) */
  --text: #f6f3f1;       /* основний текст */
  --muted: #a79b94;      /* вторинний текст, підказки */
  /* Головний колір бренду — цегляний (теракота). Ним фарбуємо дії/акценти. */
  --brick: #c25a37;
  --brick-lite: #de7a52;
  --brick-deep: #9c4225;
  /* Зелений лишаємо ВУЗЬКО — тільки для підсвітки окремих слів. */
  --accent: #a3e635;     /* лайм-зелень — highlight слів */
  --accent-lite: #c4f25b;
  --accent-2: #38bdf8;   /* блакитний = інфо/збережене */
  --danger: #ff5a52;
  --warn: #ffa500;
  --radius: 12px;
  --sidenav-w: 264px;
  --shadow-card: 0 4px 14px rgba(0, 0, 0, .38);
  --glow-accent: 0 4px 18px rgba(163, 230, 53, .28);
  --glow-brick: 0 6px 22px rgba(194, 90, 55, .34);
  --font: "Manrope", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-head: "Manrope", "Segoe UI", system-ui, sans-serif;
  --font-display: "Vollkorn", Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; height: 100%;
  background: transparent; color: var(--text);   /* базу малює #bgfx (за зорями) */
  font-family: var(--font); font-size: 14px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

/* ── Глобальний фон: зоряне поле + комети ─────────────────────────────────── */
#bgfx {
  position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none;
  background:
    radial-gradient(1200px 700px at 78% -10%, rgba(194,90,55,.10), transparent 60%),
    radial-gradient(900px 600px at 8% 108%, rgba(56,120,160,.06), transparent 60%),
    var(--bg);
}
/* Зорі — три шари крапок різної яскравості, ледь помітні. */
#bgfx::before, #bgfx::after {
  content: ""; position: absolute; inset: -50%;
  background-repeat: repeat;
}
#bgfx::before {
  background-image:
    radial-gradient(1px 1px at 20% 30%, rgba(255,255,255,.55), transparent),
    radial-gradient(1px 1px at 65% 12%, rgba(255,255,255,.40), transparent),
    radial-gradient(1px 1px at 40% 70%, rgba(255,255,255,.35), transparent),
    radial-gradient(1px 1px at 85% 55%, rgba(255,255,255,.45), transparent),
    radial-gradient(1px 1px at 12% 85%, rgba(255,255,255,.30), transparent),
    radial-gradient(2px 2px at 55% 45%, rgba(255,255,255,.22), transparent);
  background-size: 320px 320px;
  animation: bgfxDrift 140s linear infinite;
}
#bgfx::after {
  background-image:
    radial-gradient(1px 1px at 30% 20%, rgba(222,122,82,.40), transparent),
    radial-gradient(1px 1px at 75% 65%, rgba(255,255,255,.30), transparent),
    radial-gradient(1px 1px at 50% 90%, rgba(255,255,255,.22), transparent);
  background-size: 480px 480px;
  animation: bgfxDrift 220s linear infinite reverse;
  opacity: .7;
}
@keyframes bgfxDrift {
  from { transform: translate3d(0,0,0); }
  to   { transform: translate3d(-160px,-120px,0); }
}
/* Комета: яскрава голівка + хвіст, летить по діагоналі, періодично. */
#bgfx .comet {
  position: absolute; width: 2px; height: 2px; border-radius: 50%;
  background: #fff; box-shadow: 0 0 6px 2px rgba(255,255,255,.8);
  opacity: 0;
}
#bgfx .comet::after {
  content: ""; position: absolute; right: 1px; top: 50%; transform: translateY(-50%);
  width: 140px; height: 1.5px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.75));
  border-radius: 2px;
}
#bgfx .comet.c1 { top: 12%; left: -12%; animation: cometA 15s ease-in 3s infinite; }
#bgfx .comet.c2 { top: 68%; left: -12%; animation: cometB 19s ease-in 9s infinite; }
#bgfx .comet.c3 { top: 34%; right: -12%; animation: cometC 23s ease-in 15s infinite; }
/* зліва-згори → вправо-вниз */
@keyframes cometA {
  0% { opacity: 0; transform: translate(0,0) rotate(18deg); }
  4% { opacity: .9; }
  16% { opacity: .9; }
  22% { opacity: 0; transform: translate(70vw, 42vh) rotate(18deg); }
  100% { opacity: 0; }
}
@keyframes cometB {
  0% { opacity: 0; transform: translate(0,0) rotate(-10deg); }
  4% { opacity: .85; }
  15% { opacity: .85; }
  20% { opacity: 0; transform: translate(80vw,-30vh) rotate(-10deg); }
  100% { opacity: 0; }
}
/* справа-згори → вліво-вниз (дзеркальна, хвіст в інший бік) */
@keyframes cometC {
  0% { opacity: 0; transform: translate(0,0) rotate(160deg); }
  4% { opacity: .8; }
  15% { opacity: .8; }
  21% { opacity: 0; transform: translate(-75vw, 40vh) rotate(160deg); }
  100% { opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  #bgfx::before, #bgfx::after, #bgfx .comet { animation: none; }
  #bgfx .comet { opacity: 0; }
}

/* Заголовки — окремий гарнітур (Manrope), щільніший трекінг. */
h1, h2, h3, h4, .brand-name {
  font-family: var(--font-head); font-weight: 700; letter-spacing: -.01em;
}

button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
/* Темна тема для ВСІХ полів вводу — щоб не «виїдали очі» білим.
   Ловимо всі текстові типи одним селектором (раніше email/tel/date лишались
   білими, бо їх не було в переліку). Виняток — checkbox/radio/range/file/color,
   у них свій вигляд. */
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):not([type="color"]):not([type="submit"]):not([type="button"]),
textarea, select {
  background: var(--bg-3); border: 1px solid var(--line); color: var(--text);
  border-radius: 10px; padding: 9px 12px; }
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):not([type="color"]):not([type="submit"]):not([type="button"]):focus,
textarea:focus, select:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
input::placeholder, textarea::placeholder { color: var(--muted); }

/* ── Шапка ────────────────────────────────────────────────────────────── */
.topbar {
  height: 56px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px; background: var(--bg-2); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 11px; }
.logo {
  width: 34px; height: 34px; display: grid; place-items: center; flex: none;
  background: linear-gradient(135deg, var(--brick), var(--brick-lite));
  border-radius: 9px; box-shadow: var(--glow-brick);
}
.logo svg { width: 19px; height: 19px; display: block; }
.brand-name { font-family: var(--font-display); font-weight: 700; font-size: 18px; letter-spacing: .2px; }
/* Діагностичний рядок оточення — приховуємо з шапки (лишається в DOM для app.js;
   реальні проблеми йдуть тостом). */
.brand-sub { display: none; }
.top-actions { display: flex; gap: 8px; align-items: center; }
.lang-switch {
  background: var(--bg-3); color: var(--text); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 6px 8px; font-size: 13px; cursor: pointer;
}
.lang-switch:hover { border-color: var(--accent); }

/* ── Горизонтальна навігація в шапці ──────────────────────────────────── */
.mainnav {
  display: flex; align-items: center; gap: 2px; flex: 1;
  justify-content: center; flex-wrap: wrap; min-width: 0;
}
.navlink {
  background: transparent; border: none; color: var(--muted);
  padding: 8px 13px; border-radius: 9px; cursor: pointer;
  font-size: 14px; font-weight: 500; white-space: nowrap;
  transition: background .13s, color .13s;
}
.navlink:hover { background: var(--bg-3); color: var(--text); }
/* Гість бачить усю шапку; клік по закритому пункту веде на вхід (гейт у showScreen). */
.navlink.active {
  color: var(--text);
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  box-shadow: inset 0 -2px 0 var(--accent);
}
.auth-user {
  color: var(--text); font-weight: 600;
  background: var(--bg-3); border: 1px solid var(--line);
}
.auth-user:hover { border-color: var(--accent); }

/* ── Прості екрани-заготовки (Озвучка / Субтитри / Історія) ────────────── */
.simple-screen { overflow-y: auto; }
.simple-wrap { max-width: 820px; margin: 0 auto; padding: 40px 28px; }
.simple-wrap h1 { margin: 0 0 12px; }
.simple-wrap .note { color: var(--muted); font-size: 15px; line-height: 1.6; }
.account-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* ── Сторінки-інструменти (Озвучка / Субтитри) ────────────────────────── */
.tool-screen { overflow-y: auto; }
.tool-wrap { max-width: 1040px; margin: 0 auto; padding: 28px; }
.tool-head { margin-bottom: 20px; }
.tool-head h1 { margin: 0 0 6px; }
.tool-head .note { color: var(--muted); }
.tool-grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: 20px; align-items: start; }
@media (max-width: 860px) { .tool-grid { grid-template-columns: 1fr; } }
.tool-card {
  background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow-card);
}
.tool-card .field { margin-bottom: 16px; }
.tool-card .field:last-of-type { margin-bottom: 18px; }
.field > label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 7px; }
.field textarea, .field select { width: 100%; }
.field textarea { resize: vertical; min-height: 120px; line-height: 1.5; }
.slider-label { display: flex; align-items: center; justify-content: space-between; }
.slider-value { color: var(--accent); font-weight: 700; }
.cost-note { text-align: center; color: var(--muted); font-size: 12.5px; margin: 10px 0 0; }

/* повзунки в стилі акценту */
input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 6px;
  background: var(--bg-3); border-radius: 6px; outline: none; }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; appearance: none;
  width: 18px; height: 18px; border-radius: 50%; background: var(--accent);
  cursor: pointer; border: 2px solid var(--bg); box-shadow: var(--glow-accent); }
input[type="range"]::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%;
  background: var(--accent); cursor: pointer; border: 2px solid var(--bg); }

/* прев'ю аудіо / медіа-плейсхолдер */
.preview-card label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 10px; }
.media-ph { display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; text-align: center; min-height: 220px; padding: 24px;
  background: var(--bg-3); border: 1px dashed var(--line); border-radius: var(--radius); margin-bottom: 16px; }
.media-ph-icon { font-size: 44px; opacity: .7; }
.media-ph-text { color: var(--muted); font-size: 13.5px; max-width: 240px; }

/* зона завантаження */
.upload-zone { display: flex; flex-direction: column; align-items: center; gap: 6px;
  text-align: center; padding: 26px; cursor: pointer;
  background: var(--bg-3); border: 1.5px dashed var(--line); border-radius: var(--radius);
  transition: border-color .14s, background .14s; }
.upload-zone:hover { border-color: var(--accent); }
.uz-icon { font-size: 34px; }
.uz-link { color: var(--accent); text-decoration: underline; }

/* прев'ю субтитрів */
.sub-preview { margin-bottom: 16px; }
.sub-preview-frame { position: relative; aspect-ratio: 16 / 9; border-radius: var(--radius);
  background: linear-gradient(135deg, #1a1a1a, #262626);
  border: 1px solid var(--line); display: flex; align-items: flex-end; justify-content: center; padding-bottom: 22px; }
.sub-caption { background: rgba(0,0,0,.55); color: #fff; font-weight: 600;
  padding: 5px 12px; border-radius: 6px; font-size: 15px; }

/* ── Кнопки ───────────────────────────────────────────────────────────── */
.btn {
  background: var(--bg-3); border: 1px solid var(--line); color: var(--text);
  padding: 9px 16px; border-radius: 10px; cursor: pointer; font-weight: 500;
  transition: background .14s, border-color .14s, opacity .14s, transform .14s, box-shadow .14s;
}
.btn:hover:not(:disabled) { background: #262626; border-color: #3a3a3a; transform: translateY(-1px); }
.btn:active:not(:disabled) { transform: translateY(0); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.primary {
  background: linear-gradient(135deg, var(--brick), var(--brick-lite));
  border-color: transparent; color: #fff; font-weight: 700;
}
.btn.primary:hover:not(:disabled) { box-shadow: var(--glow-brick); transform: translateY(-1px); }
.btn.ghost { background: transparent; }
.btn.ghost:hover:not(:disabled) { background: rgba(255, 255, 255, .05); }
.btn.tiny { padding: 5px 11px; font-size: 12px; border-radius: 8px; }
/* Незбережені правки сценарію → кнопка «Зберегти у проєкт» проситься натиснути. */
.btn.needs-save {
  border-color: var(--brick); color: #fff;
  background: linear-gradient(135deg, var(--brick), var(--brick-lite));
  animation: needsSavePulse 1.6s ease-in-out infinite;
}
@keyframes needsSavePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(194, 90, 55, .55); }
  50%      { box-shadow: 0 0 0 6px rgba(194, 90, 55, 0); }
}
@media (prefers-reduced-motion: reduce) { .btn.needs-save { animation: none; } }
.btn.wide { width: 100%; margin-top: 6px; }
.btn.link { background: none; border: none; color: var(--accent); padding: 0; text-decoration: underline; font-weight: 500; }

/* ── Екрани ───────────────────────────────────────────────────────────── */

/* Обов'язково !important: браузер ховає [hidden] через display:none у власних
   стилях, а будь-яке наше display (grid/flex нижче) це перебиває. Без цього
   рядка прихований екран лишається на сторінці — саме так редактор «не
   відкривався», хоча насправді малювався під екраном вибору файлу. */
[hidden] { display: none !important; }

.screen { height: calc(100vh - 56px); }

.drop-screen {
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  gap: 28px; padding: 24px; overflow-y: auto;
}
.dropzone {
  width: min(620px, 100%); padding: 48px 32px; text-align: center;
  border: 2px dashed var(--line); border-radius: 16px; background: var(--bg-2);
  transition: border-color .15s, background .15s, box-shadow .15s;
  box-shadow: var(--shadow-card);
  flex-shrink: 0;         /* вікно вставки не стискається, коли проєктів багато */
  margin-top: auto;       /* центрує блок, поки він вміщається у висоту екрана… */
}
.recent { margin-bottom: auto; }  /* …а коли проєктів багато — притискаємось до верху */
.dropzone.hot { border-color: var(--accent); background: #1e1e1e; box-shadow: var(--glow-accent); }
.drop-icon { font-size: 44px; }
.dropzone h1 { margin: 12px 0 4px; font-size: 22px; font-weight: 600; }
.dropzone p { margin: 4px 0; color: var(--muted); }
.hint { font-size: 12px; margin-top: 12px !important; }

.recent { width: min(960px, 100%); }
.recent-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; align-items: start; }
@media (max-width: 720px) { .recent-cols { grid-template-columns: 1fr; } }
.recent h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin-bottom: 10px; }
.recent-list {
  display: flex; flex-direction: column; gap: 6px;
  max-height: 46vh; overflow-y: auto; padding-right: 4px;  /* готові проєкти гортаються тут, не зміщуючи вікно вставки */
}
.recent-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); cursor: pointer;
}
.recent-item:hover { border-color: var(--accent); }
.recent-item .ri-name { flex: 1; font-weight: 500; }
.recent-item .ri-meta { font-size: 12px; color: var(--muted); }
.recent-item .ri-del { opacity: .35; padding: 2px 6px; }
.recent-item .ri-del:hover { opacity: 1; color: var(--danger); }

/* ── Редактор ─────────────────────────────────────────────────────────── */
.editor { display: grid; grid-template-columns: 1fr 340px; overflow: hidden; }

/* Рядок плеєра — minmax(0,1fr): він віддає місце решті й стискається сам.
   Через flex це раз за разом ламалось — нижні блоки виштовхували відео за
   межі вікна, і низ кадру просто не було видно. */
.stage {
  display: grid;
  grid-template-rows: minmax(140px, 1fr) auto auto auto;
  padding: 14px; gap: 10px; min-width: 0; min-height: 0; overflow: hidden;
}
.stage > * { min-height: 0; }

.player-wrap {
  background: #000; border-radius: var(--radius);
  overflow: hidden; position: relative;
}

/* inset:0 замість height:100%. У grid-контейнері відсоткова висота не
   резолвилась, і відео брало власну пропорцію 16:9 — вилазило далеко за
   контейнер. Кадр обрізався знизу, а субтитри малювались за межами екрана.
   Абсолютне позиціювання дає елементу рівно розмір контейнера. */
#player {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: contain;
}
#player::cue { font-size: 22px; background: rgba(0,0,0,.62); }
.player-empty {
  position: absolute; inset: 0; color: var(--muted);
  display: flex; align-items: center; justify-content: center; text-align: center;
}
.pe-drop {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 28px 34px; border: 2px dashed var(--line); border-radius: 16px;
  background: rgba(255, 255, 255, .02);
}
.pe-icon { font-size: 40px; }
.pe-title { font-size: 18px; font-weight: 700; color: var(--text); }
.pe-sub { font-size: 13px; }
.pe-hint { font-size: 11.5px; opacity: .7; max-width: 320px; }
.pe-progress { width: min(70%, 340px); }
.player-wrap.hot { outline: 2px solid var(--accent); outline-offset: -6px; }
.player-wrap.hot .pe-drop { border-color: var(--accent); background: rgba(90,140,255,.08); }

/* Поки відео не залито (режим «Субтитри») — панель приглушена й не клікається. */
body.no-project .panel .tabpane,
body.no-project .subs-actions,
body.no-project .project-name { opacity: .4; pointer-events: none; }

/* Транспорт плеєра */
.transport {
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 8px 12px 10px;
}
.seek {
  width: 100%; accent-color: var(--accent); height: 4px; margin: 0 0 8px; display: block;
}
.transport-row { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.tbtn {
  background: var(--bg-3); border: 1px solid var(--line); border-radius: 7px;
  padding: 6px 10px; cursor: pointer; font-size: 12px; line-height: 1;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.tbtn:hover:not(:disabled) { background: #27303e; }
.tbtn:disabled { opacity: .35; cursor: not-allowed; }
.tbtn.play { min-width: 40px; font-size: 14px; background: var(--accent); border-color: transparent; }
.tbtn.play:hover { background: var(--accent-lite); }
.tbtn.mark { border-color: #35507d; color: #b9d0ff; }
.tbtn.danger { border-color: #6b2f2f; color: #ffb4b0; }
.tbtn.danger:not(:disabled):hover { background: #3a2022; }
.tbtn.preview { border-color: #6b5326; color: #ffd08a; }
.tbtn.preview.on { background: var(--warn); border-color: transparent; color: #1a1200; font-weight: 600; }
.tbtn.ghost { background: none; }
.tcode { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; margin-left: 6px; }
.tcode b { color: var(--text); }
.tspacer { flex: 1; }
.markinfo { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.tsel {
  background: var(--bg-3); border: 1px solid var(--line); border-radius: 7px;
  padding: 5px 6px; font-size: 12px;
}

/* Таймлайн */
.timeline-block { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.timeline-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.tl-title { font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
.tl-stat { text-transform: none; letter-spacing: 0; color: var(--text); margin-left: 8px; font-size: 12px; }
.tl-actions { display: flex; gap: 6px; }
#timeline { width: 100%; display: block; cursor: crosshair; border-radius: 6px; background: var(--bg-3); }
.tl-scroll { position: relative; height: 12px; margin-top: 6px; background: var(--bg-3);
  border-radius: 6px; cursor: pointer; }
.tl-thumb { position: absolute; top: 0; height: 100%; min-width: 18px;
  background: color-mix(in srgb, var(--accent) 40%, transparent);
  border: 1px solid var(--accent); border-radius: 6px; cursor: grab; }
.tl-thumb:active { cursor: grabbing; background: color-mix(in srgb, var(--accent) 60%, transparent); }
.tl-legend { display: flex; gap: 14px; align-items: center; margin-top: 7px; font-size: 11px; color: var(--muted); }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; vertical-align: -1px; margin-right: 4px; }
.sw.keep { background: color-mix(in srgb, var(--accent-2) 40%, transparent); border: 1px solid var(--accent-2); }
.sw.cut { background: #ff5f5744; border: 1px solid var(--danger); }
.sw.sel { background: color-mix(in srgb, var(--accent) 30%, transparent); border: 1px solid var(--accent); }
.sw.ai { background: #ffb45444; border: 1px solid var(--warn); }
.tl-hint { margin-left: auto; }

/* Транскрипт */
.transcript-block {
  background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 12px; height: clamp(120px, 22vh, 210px); display: flex; flex-direction: column;
}
.transcript { flex: 1; overflow-y: auto; margin-top: 8px; padding-right: 4px; }
.transcript .empty { color: var(--muted); padding: 20px 0; text-align: center; }
.tr-seg {
  display: flex; gap: 10px; padding: 6px 8px; border-radius: 6px; cursor: pointer;
  border-left: 2px solid transparent;
}
.tr-seg:hover { background: var(--bg-3); }
.tr-seg.active { background: #1d2a3f; border-left-color: var(--accent); }
.tr-seg.dropped { opacity: .35; text-decoration: line-through; }
.tr-seg .t { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 12px; flex-shrink: 0; }
.tr-seg .x { opacity: 0; color: var(--danger); flex-shrink: 0; padding: 0 4px; }
.tr-seg:hover .x { opacity: .7; }
.tr-seg .grow[contenteditable="true"] {
  background: var(--bg); outline: 1px solid var(--accent); border-radius: 4px;
  padding: 2px 5px; margin: -2px 0;
}
.tr-seg .grow { cursor: text; }

/* Прев'ю субтитрів у плеєрі — колір і розмір підставляються з обраного стилю */
#player::cue {
  background: rgba(0, 0, 0, .6);
  font-family: "Segoe UI", sans-serif;
  font-weight: 700;
}

/* ── Панель ───────────────────────────────────────────────────────────── */
.panel {
  background: var(--bg-2); border-left: 1px solid var(--line);
  padding: 14px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px;
}
.project-name {
  background: var(--bg-3); border: 1px solid var(--line); border-radius: 8px;
  padding: 9px 11px; font-weight: 600; width: 100%;
}
.tabs { display: flex; gap: 3px; background: var(--bg-3); padding: 3px; border-radius: 9px; }
.tab {
  flex: 1; background: none; border: none; padding: 7px 4px; border-radius: 7px;
  color: var(--muted); cursor: pointer; font-size: 12px;
}
.tab.active { background: var(--bg); color: var(--text); font-weight: 600; }
.tabpane { display: none; flex-direction: column; gap: 12px; }
.tabpane.active { display: flex; }

/* ── Режим «Субтитри» (subs-mode): панель ліворуч, одна секція ─────────────
   Той самий редактор, але вхід через «Субтитри» лишає тільки суть:
   розпізнати → накласти → стиль/позиція/розмір → показати → рендер/скачати. */
.subs-only { display: none; }
.subs-mode .subs-only { display: block; }

.subs-mode.editor,
.subs-mode .editor { grid-template-columns: 360px 1fr; }
body.subs-mode .editor { grid-template-columns: 360px 1fr; }
body.subs-mode .panel {
  order: -1; border-left: 0; border-right: 1px solid var(--line);
}
/* Ховаємо навігацію вкладок і все «просунуте» — лишається обʼєднана секція */
body.subs-mode .tabs,
body.subs-mode #tabCut,
body.subs-mode #tabOverlays,
body.subs-mode #tabClips,
body.subs-mode #tabText,
body.subs-mode #tabExport,
body.subs-mode .adv-only { display: none !important; }
/* «Мова» і «Субтитри» показуємо завжди — це і є секція «Налаштування» */
body.subs-mode #tabAudio,
body.subs-mode #tabSubs { display: flex !important; }
/* Ті самі «рамочки», що в Озвучці/Студії: піднята картка всередині панелі. */
body.subs-mode #tabAudio,
body.subs-mode #tabSubs {
  background: var(--bg-3); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 15px 15px; box-shadow: var(--shadow-card);
}

.panel-title {
  font-size: 13px; font-weight: 700; letter-spacing: .3px;
  color: var(--text); margin: 2px 0 -2px;
}
body.subs-mode .subs-actions { display: flex; flex-direction: column; gap: 10px; }

/* На сторінці субтитрів головне — великий плеєр, де видно субтитри. Таймлайн
   різки не потрібен, тож ховаємо його й віддаємо всю висоту плеєру. */
body.subs-mode .timeline-block { display: none; }
body.subs-mode .stage { grid-template-rows: minmax(0, 1fr) auto auto; }
body.subs-mode .transcript-block { height: clamp(110px, 16vh, 170px); }

.field { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted); }
.field > span b { color: var(--text); float: right; font-variant-numeric: tabular-nums; }
.field > span small { display: block; opacity: .75; }
.field select, .field textarea, .field input[type="text"] {
  background: var(--bg-3); border: 1px solid var(--line); border-radius: 8px;
  padding: 9px 10px; color: var(--text); width: 100%; resize: vertical;
}
.field input[type="range"] { width: 100%; accent-color: var(--accent); }

.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.check input { margin-top: 3px; accent-color: var(--accent); width: 16px; height: 16px; }
.check span b { display: block; font-weight: 500; }
.check span small { color: var(--muted); font-size: 12px; }

.note { font-size: 11.5px; color: var(--muted); line-height: 1.5; margin: 0; }

.job { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); }
.bar { height: 5px; background: var(--bg-3); border-radius: 3px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .25s; }
.job.error .bar i { background: var(--danger); }
/* Поки job активний — смуга «дихає» рухомими діагональними штрихами, тож навіть
   коли відсоток стоїть на місці (довгий синтез), видно, що робота триває. */
.job.busy .bar i {
  background-image: linear-gradient(45deg,
    rgba(255,255,255,.28) 25%, transparent 25%, transparent 50%,
    rgba(255,255,255,.28) 50%, rgba(255,255,255,.28) 75%, transparent 75%);
  background-size: 22px 22px;
  animation: jobStripes .7s linear infinite;
}
@keyframes jobStripes { from { background-position: 0 0; } to { background-position: 22px 0; } }
.job-row { display: flex; align-items: center; gap: 10px; }
.job-row .bar { flex: 1; }
.job .job-stop {
  flex-shrink: 0; font-size: 12px; padding: 3px 10px; border-radius: 6px;
  border: 1px solid var(--danger); color: var(--danger); background: transparent; cursor: pointer;
}
.job .job-stop:hover { background: var(--danger); color: #fff; }
/* Живий рядок статусу у вкладці «Озвучка / Ролик», поки крок виконується. */
.final-status .st.run {
  color: #d29922; font-weight: 600;
  animation: stPulse 1s ease-in-out infinite;
}
@keyframes stPulse { 0%,100% { opacity: 1; } 50% { opacity: .45; } }

.cut-summary { display: none; }
.cut-summary.on {
  display: block; background: #142218; border: 1px solid #2b5c3f;
  border-left: 3px solid var(--accent-2); border-radius: 9px; padding: 10px 12px; font-size: 12.5px;
}
.cut-summary b { color: var(--accent-2); }

.cutlist { display: flex; flex-direction: column; gap: 5px; }
.cut-item {
  display: flex; align-items: center; gap: 8px; font-size: 12px;
  background: var(--bg-3); padding: 6px 9px; border-radius: 7px;
  font-variant-numeric: tabular-nums;
}
.cut-item .grow { flex: 1; }
.cut-item button { background: none; border: none; color: var(--danger); cursor: pointer; opacity: .6; }
.cut-item button:hover { opacity: 1; }

.meta-out { display: flex; flex-direction: column; gap: 10px; }
.meta-card { background: var(--bg-3); border-radius: 9px; padding: 10px; }
.meta-card h4 {
  margin: 0 0 6px; font-size: 11px; text-transform: uppercase;
  letter-spacing: .5px; color: var(--muted); display: flex; justify-content: space-between;
}
.meta-card h4 button { background: none; border: none; color: var(--accent); cursor: pointer; font-size: 11px; }
.meta-card p { margin: 0 0 6px; line-height: 1.5; white-space: pre-wrap; }
.meta-card p:last-child { margin-bottom: 0; }
.meta-card .alt { color: var(--muted); font-size: 12.5px; }
.tagwrap { display: flex; flex-wrap: wrap; gap: 4px; }
.tag { background: #22314a; color: #a8c5ff; padding: 2px 7px; border-radius: 5px; font-size: 11.5px; }

.downloads { display: flex; gap: 6px; }
.downloads .btn { flex: 1; text-align: center; text-decoration: none; }

.renders { display: flex; flex-direction: column; gap: 6px; }
.render-item {
  background: var(--bg-3); border-radius: 8px; padding: 9px 10px;
  display: flex; align-items: center; gap: 8px; font-size: 12px;
}
.render-item .grow { flex: 1; }
.render-item a { color: var(--accent); text-decoration: none; }

.upload-progress { margin-top: 18px; }
.upload-progress .bar { margin-bottom: 5px; }
.upload-progress span { font-size: 12px; color: var(--muted); }

.drop-error {
  margin-top: 16px; padding: 12px 14px; text-align: left;
  background: #2a1618; border: 1px solid #5d2b2b; border-left: 3px solid var(--danger);
  border-radius: 9px; font-size: 13px;
}
.drop-error b { display: block; margin-bottom: 4px; }
.drop-error span { color: var(--muted); font-size: 12px; word-break: break-word; }

.toast {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%);
  background: var(--bg-3); border: 1px solid var(--line); border-left: 3px solid var(--accent);
  padding: 11px 16px; border-radius: 9px; max-width: 520px; z-index: 50;
  box-shadow: 0 8px 26px #0009;
}
.toast.error { border-left-color: var(--danger); }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: #2b3543; border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: #3a4658; }
::-webkit-scrollbar-track { background: transparent; }

/* ── Обгортка ─────────────────────────────────────────────────────────────── */
hr.sep { border: 0; border-top: 1px solid var(--line); margin: 18px 0 14px; }

.cover-box { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.cover-img {
  /* aspect-ratio задається з JS під формат (16/9 youtube, 9/16 tiktok);
     contain — щоб у превю було видно всю обгортку без повторного обрізання. */
  width: 100%; aspect-ratio: 16 / 9; object-fit: contain;
  max-height: 70vh;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-3);
}

.cover-frames { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; }
.cover-thumb {
  position: relative; flex: 0 0 88px; padding: 0; cursor: pointer;
  background: none; border: 2px solid transparent; border-radius: 7px; overflow: hidden;
  line-height: 0;
}
.cover-thumb img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; display: block; opacity: .6; }
.cover-thumb:hover img { opacity: .9; }
.cover-thumb.on { border-color: var(--accent-2); }
.cover-thumb.on img { opacity: 1; }
.cover-thumb span {
  position: absolute; left: 3px; bottom: 3px; padding: 1px 4px;
  font-size: 9.5px; line-height: 1.4; color: var(--text);
  background: rgba(0, 0, 0, .65); border-radius: 3px;
}

.cover-fields { display: flex; flex-direction: column; gap: 10px; }
.cover-row { display: flex; gap: 8px; }
.cover-row .field { flex: 1; min-width: 0; }
.cover-row .field.narrow { flex: 0 0 84px; }
.field > span .hint { font-style: normal; opacity: .7; float: right; }

.cover-actions { display: flex; align-items: center; gap: 8px; }
.cover-actions .btn:first-child { flex: 1; }

/* ── Свій шар субтитрів і оверлеїв поверх кадру ─────────────────────────── */
/* overlay-layer JS підганяє точно під видимий прямокутник відео (contain),
   тому все всередині позиціонується у частках кадру — однаково для 16:9 і 9:16. */
.overlay-layer {
  position: absolute; pointer-events: none;
  left: 0; top: 0; width: 100%; height: 100%;
}

.sub-preview {
  position: absolute; left: 50%; transform: translateX(-50%);
  max-width: 92%; text-align: center; line-height: 1.15;
  font-weight: 800; white-space: pre-wrap;
  padding: .08em .34em; border-radius: .18em;
  color: #fff; background: rgba(0, 0, 0, .34);
  text-shadow: 0 0 .12em #000, 0 .04em .1em #000,
    -.03em -.03em 0 #000, .03em -.03em 0 #000, -.03em .03em 0 #000, .03em .03em 0 #000;
}
.sub-preview .w { transition: color .06s linear; }   /* колір = primary/secondary */

/* Картинка-оверлей у плеєрі: тягається мишкою, кутик міняє розмір */
.ov-box {
  position: absolute; pointer-events: auto; cursor: grab;
  border: 1px solid transparent; box-sizing: border-box; overflow: hidden;
}
.ov-box.sel { border-color: var(--accent); overflow: visible; }
.ov-box.dragging { cursor: grabbing; }
.ov-box img { width: 100%; height: 100%; display: block; object-fit: contain;
  -webkit-user-drag: none; user-select: none; pointer-events: none;
  transform-origin: center center; }
.ov-box .handle {
  position: absolute; right: 2px; bottom: 2px; width: 14px; height: 14px;
  background: var(--accent); border: 2px solid #fff; border-radius: 50%;
  cursor: nwse-resize; pointer-events: auto; z-index: 2;
}
.ov-box.hidden-now { display: none; }     /* поза вікном показу */

/* ── Колір субтитрів ────────────────────────────────────────────────────── */
.color-row { display: flex; align-items: center; gap: 8px; }
.color-row input[type="color"] {
  width: 42px; height: 30px; padding: 0; border: 1px solid var(--line);
  border-radius: 7px; background: var(--bg-3); cursor: pointer;
}
.color-note { font-size: 11px; color: var(--muted); }

/* ── Панель оверлеїв ────────────────────────────────────────────────────── */
.overlay-list { display: flex; flex-direction: column; gap: 10px; }
.ov-card {
  background: var(--bg-3); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px; display: flex; flex-direction: column; gap: 8px;
}
.ov-card.sel { border-color: var(--accent); }
.ov-card-head { display: flex; align-items: center; gap: 8px; }
.ov-card-head img {
  width: 40px; height: 40px; object-fit: cover; border-radius: 6px;
  background: var(--bg); border: 1px solid var(--line);
}
.ov-card-head .grow { flex: 1; font-size: 12px; color: var(--muted); overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
.ov-times { display: flex; gap: 8px; }
.ov-times .field { flex: 1; }
.ov-card .field { display: flex; flex-direction: column; gap: 4px; }
.ov-card .field > span { font-size: 11px; color: var(--muted); }
.ov-card input[type="number"], .ov-card select {
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 7px;
  padding: 6px 8px;
}
.ov-card input[type="range"] { width: 100%; accent-color: var(--accent); }
.ov-move-hint { font-size: 11px; color: var(--muted); }

.tl-zoom { display: inline-flex; align-items: center; gap: 4px; margin-right: 8px; }
.tl-zoom b { font-size: 11px; color: var(--muted); min-width: 30px; text-align: center; }

/* Дії в картці оверлея/кліпа + збережені фрагменти */
.ov-card-actions { display: flex; gap: 6px; }
.ov-card-actions .btn { flex: 1; }
.clip-list { display: flex; flex-direction: column; gap: 10px; }
.fragments { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }

/* ── Екран «Анімація з картинки» ─────────────────────────────────────────── */
.animate-screen { display: grid; grid-template-columns: 1fr 360px; overflow: hidden; }
.anim-stage { padding: 18px; min-width: 0; min-height: 0; display: flex; }
.anim-preview {
  flex: 1; position: relative; background: #000; border-radius: var(--radius);
  overflow: hidden; display: grid; place-items: center;
}
.anim-drop {
  text-align: center; padding: 40px; color: var(--muted);
  border: 2px dashed var(--line); border-radius: 16px; margin: 24px;
}
.anim-drop.hot { border-color: var(--accent); background: var(--bg-3); }
.anim-drop h2 { color: var(--text); margin: 10px 0 4px; }

/* Рамка прев'ю = точний обраний формат (9:16 / 1:1 / 16:9), по центру.
   Розмір задає JS (setAnimFrameAspect), щоб влазило і по висоті, і по ширині. */
.anim-frame {
  position: relative; background: #000; border-radius: var(--radius);
  overflow: hidden; box-shadow: 0 0 0 1px var(--line);
}
.anim-canvas { position: absolute; inset: 0; overflow: hidden; }
.anim-canvas img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
}
.anim-overlays { position: absolute; inset: 0; pointer-events: none; }
.anim-overlays video {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
  mix-blend-mode: screen; filter: grayscale(1) brightness(1.1);
}
.anim-vignette {
  position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 42%, rgba(0,0,0,.6) 100%);
}
#animResult { position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: contain; background: #000; }

/* CSS-наближення руху для прев'ю (рендер робить точний zoompan) */
@keyframes animZoomIn { from { transform: scale(1); } to { transform: scale(1.25); } }
@keyframes animZoomOut { from { transform: scale(1.25); } to { transform: scale(1); } }
@keyframes animPan { from { transform: scale(1.35) translateX(12%); } to { transform: scale(1.35) translateX(-12%); } }
@keyframes animKen { from { transform: scale(1) translate(0,0); } to { transform: scale(1.22) translate(3%,-3%); } }
.mo-zoom_in  { animation: animZoomIn 5s ease-in-out infinite alternate; }
.mo-zoom_out { animation: animZoomOut 5s ease-in-out infinite alternate; }
.mo-pan      { animation: animPan 6s ease-in-out infinite alternate; }
.mo-ken_burns, .mo-random { animation: animKen 6s ease-in-out infinite alternate; }

.anim-panel { gap: 14px; }
.anim-head { display: flex; align-items: center; justify-content: space-between; }
.preset-row, .chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  padding: 6px 10px; border: 1px solid var(--line); border-radius: 20px;
  background: var(--bg-3); cursor: pointer; font-size: 12px; user-select: none;
}
.chip:hover { border-color: #34405280; }
.chip.on { background: var(--accent); border-color: transparent; color: #fff; }
.preset-row .chip.on { background: var(--accent-2); }
.anim-downloads { display: flex; flex-direction: column; gap: 6px; }

.anim-head-btns { display: flex; gap: 6px; }

/* ── Видалення лого ───────────────────────────────────────────────────────
   Тут фото показуємо цілим (object-fit: contain), а не кадруємо під формат:
   зону значка треба обводити по справжніх пропорціях, інакше рамка поїде. */
/* Розтягуємось по контейнеру через inset, а не height:100%: у грід-контейнері
   з place-items:center висота 100% рахується від контенту й фото розпирає екран. */
.clean-frame {
  position: absolute; inset: 0; display: flex; flex-direction: column; gap: 8px;
  padding: 18px; box-sizing: border-box;
}
.clean-canvas {
  position: relative; flex: 1; min-height: 0; overflow: hidden;
  cursor: crosshair; user-select: none;
}
/* Фото — абсолютне з margin:auto: тільки так відсотковий max-height рахується
   від висоти канви, а рамка елемента збігається з самим зображенням (це важливо,
   бо по цій рамці рахуються координати зони). */
.clean-canvas img {
  position: absolute; inset: 0; margin: auto; display: block;
  max-width: 100%; max-height: 100%; width: auto; height: auto;
}
.clean-box {
  position: absolute; border: 2px solid var(--accent);
  background: rgba(88, 140, 255, .18); pointer-events: none; border-radius: 3px;
}
.clean-hint { text-align: center; margin: 0; }

.clean-list { display: flex; flex-direction: column; gap: 4px; max-height: 180px; overflow: auto; }
.clean-item {
  display: flex; align-items: center; gap: 8px; font-size: 12px;
  background: var(--bg-3); border-radius: 8px; padding: 6px 8px; cursor: pointer;
}
.clean-item.on { outline: 1px solid var(--accent); }
.clean-item .grow { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clean-item .st { color: var(--muted); }
.clean-item .st.ok { color: var(--accent-2); }
.clean-item .st.bad { color: var(--danger); }

.clean-preset-row { display: flex; gap: 6px; margin-top: 6px; }
.field .sub { display: block; margin-top: 8px; font-size: 12px; color: var(--muted); }
.field .sub b { color: var(--text); }
#cleanCornerSave { margin-top: 10px; }
.clean-preset-row input { flex: 1; min-width: 0; }
.chip .x { margin-left: 6px; opacity: .6; }

/* ── Автозбірка ──────────────────────────────────────────────────────────── */
.auto-screen { padding: 20px 26px; overflow: hidden; }
.auto-wrap { display: grid; grid-template-columns: minmax(360px, 460px) 1fr;
  grid-template-rows: minmax(0, 1fr); gap: 24px; height: 100%; }
/* Кожна колонка гортається окремо (налаштування зліва, матеріали справа) — і
   не «тягне» за собою всю сторінку. Нижній відступ, щоб лог-консоль / нижні
   кнопки не ховали останні елементи. */
.auto-left, .auto-right { overflow-y: auto; min-height: 0; padding-bottom: 140px; padding-right: 6px; }
.auto-left h1, .auto-right h1 { font-size: 20px; margin-bottom: 10px; }
.auto-flow { font-size: 13px; color: var(--muted); margin-bottom: 16px; padding: 8px 12px;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); }
.auto-flow.error { color: var(--danger); }
.auto-flow.on { color: var(--accent-2); }
.auto-flow.off { color: var(--danger); }

/* ── Студія ──────────────────────────────────────────────────────────────── */
#studioModeRow { flex-wrap: wrap; }
#studioModeRow .btn.mode { flex: 0 0 auto; padding: 6px 10px; font-size: 12px; }
.studio-drop { border: 1.5px dashed var(--line); border-radius: var(--radius);
  padding: 18px 14px; text-align: center; color: var(--muted); transition: border-color .15s, background .15s; }
.studio-drop.over { border-color: var(--accent); background: var(--bg-3); }
.studio-drop p { margin: 0 0 6px; font-size: 13px; }
.studio-drop .hint { margin-top: 4px !important; }
.studio-toolbar { display: flex; align-items: center; justify-content: space-between;
  gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.studio-count { font-size: 12px; color: var(--muted); }
.studio-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.fld.inline { flex-direction: row; align-items: center; gap: 6px; margin: 0; }
.fld.inline > span { display: inline; }
.fld.inline select { width: auto; }
.studio-empty { color: var(--muted); font-size: 13px; padding: 20px; text-align: center; }
.studio-card { position: relative; cursor: default; }
.studio-card.selectable .thumb { cursor: pointer; }
.studio-card.selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent) inset; }
.sel-badge { position: absolute; top: 5px; left: 5px; z-index: 3; min-width: 22px; height: 22px;
  padding: 0 6px; border-radius: 11px; background: rgba(0,0,0,.6); border: 1px solid rgba(255,255,255,.3);
  color: #fff; font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.sel-badge.on { background: var(--accent); border-color: var(--accent); }
/* ── Auth + Кабінет ──────────────────────────────────────────────────────── */
.auth-screen { display: flex; align-items: center; justify-content: center; }
.auth-card { width: 360px; max-width: 92vw; background: var(--bg-2); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 28px 26px; box-shadow: var(--shadow-card); }
.auth-card h1 { font-size: 22px; margin-bottom: 18px; text-align: center; }
.auth-tabs { display: flex; gap: 8px; margin-bottom: 18px; }
.auth-tabs .btn.mode { flex: 1; }
.auth-error { color: var(--danger); font-size: 13px; margin-top: 10px; text-align: center; }
.auth-ok { color: var(--accent); font-size: 13px; margin-top: 10px; text-align: center; }
.auth-hint { color: var(--muted); font-size: 13px; margin: 0 0 14px; line-height: 1.5; text-align: center; }
.auth-links { display: flex; justify-content: space-between; gap: 10px; margin-top: 12px; }
.auth-links a { color: var(--muted); font-size: 12.5px; text-decoration: none; }
.auth-links a:hover { color: var(--accent); text-decoration: underline; }

/* Юридичні сторінки (Terms / Privacy / Cookies) — спільний макет */
.legal-page { max-width: 820px; margin: 0 auto; padding: 40px 28px 64px; overflow-y: auto; height: 100%; }
.legal-page h1 { font-family: var(--font-head); font-size: 30px; margin: 0 0 6px; }
.legal-page .updated { color: var(--muted); font-size: 13px; margin: 0 0 28px; }
.legal-page h2 { font-family: var(--font-head); font-size: 19px; margin: 30px 0 10px; }
.legal-page p, .legal-page li { color: var(--text); font-size: 15px; line-height: 1.65; }
.legal-page p { margin: 0 0 12px; }
.legal-page ul { margin: 0 0 12px; padding-left: 22px; }
.legal-page li { margin: 4px 0; }
.legal-page a { color: var(--accent); }
.legal-page .muted { color: var(--muted); }
.legal-page .callout { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; margin: 0 0 12px; font-size: 14px; color: var(--muted); }

/* Cookie-банер */
#cookieBanner { position: fixed; left: 16px; right: 16px; bottom: 16px; z-index: 9999;
  max-width: 560px; margin: 0 auto; background: var(--bg-2); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-card); padding: 16px 18px;
  display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
#cookieBanner p { margin: 0; flex: 1; min-width: 220px; font-size: 13.5px; color: var(--muted); line-height: 1.5; }
#cookieBanner p a { color: var(--accent); }
#cookieBanner .cb-actions { display: flex; gap: 8px; }
#cookieBanner[hidden] { display: none; }
.account-wrap { max-width: 900px; margin: 0 auto; padding: 24px; overflow-y: auto; height: 100%; }
.account-wrap h1 { font-size: 22px; margin-bottom: 16px; }
.account-wrap h3 { font-size: 15px; margin-bottom: 8px; }
.account-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.account-card { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.account-balance { font-size: 26px; font-weight: 700; color: var(--accent); }
.account-projects { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.ac-proj { display: flex; gap: 10px; align-items: center; background: var(--bg-2); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 8px; cursor: pointer; font-size: 13px; }
.ac-proj:hover { border-color: var(--accent); }
.ac-proj-cover { width: 48px; height: 48px; flex: 0 0 auto; border-radius: 6px; overflow: hidden; background: #000;
  display: flex; align-items: center; justify-content: center; font-size: 20px; }
.ac-proj-cover img { width: 100%; height: 100%; object-fit: cover; }
.ledger-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.ledger-table th, .ledger-table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.ledger-table th { color: var(--muted); font-weight: 600; }
.led-plus { color: var(--accent); } .led-minus { color: var(--muted); }
.ledger-tools { display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin: 4px 0 10px; }
.ledger-filters { display: flex; gap: 6px; }
.ledger-filters .chip { cursor: pointer; }
.ledger-filters .chip.active { background: var(--accent); border-color: transparent; color: #fff; }
.ledger-sum { font-variant-numeric: tabular-nums; }
#acLedgerMore { margin-top: 10px; }
.cost-hint { font-size: 12px; color: var(--muted); text-align: center; margin: -4px 0 2px; }
.auth-actions { display: inline-flex; gap: 6px; }
.studio-balance { font-size: 13px; margin: -8px 0 14px; color: var(--text); }
.studio-balance a { color: var(--accent); }
.studio-balance .muted { color: var(--muted); font-size: 12px; }
.studio-queue { display: flex; align-items: center; gap: 10px; margin-bottom: 12px;
  padding: 9px 12px; background: var(--bg-2); border: 1px solid var(--accent);
  border-radius: var(--radius); font-size: 12.5px; }
.studio-queue .spin { width: 16px; height: 16px; flex: 0 0 auto; border: 2px solid rgba(255,255,255,.25);
  border-top-color: var(--accent); border-radius: 50%; animation: genspin .8s linear infinite; }
.studio-queue #studioQueueText { flex: 1; }
.studio-selbar { display: flex; align-items: center; justify-content: space-between;
  gap: 10px; flex-wrap: wrap; margin: -4px 0 12px; padding: 8px 10px;
  background: var(--bg-2); border: 1px solid var(--accent); border-radius: var(--radius); font-size: 12px; }
.studio-selbar #studioSelText { color: var(--muted); }
.studio-lightbox { position: fixed; inset: 0; z-index: 100; display: none;
  align-items: center; justify-content: center; background: rgba(0,0,0,.9); cursor: zoom-out; }
.studio-lightbox.open { display: flex; }
.studio-lightbox img, .studio-lightbox video { max-width: 94vw; max-height: 94vh; object-fit: contain;
  box-shadow: 0 8px 40px rgba(0,0,0,.6); border-radius: 6px; }
.auto-projects { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; }
.auto-projects .ap-label { font-size: 12px; color: var(--muted); white-space: nowrap; }
.auto-projects .ap-select { flex: 1; min-width: 0; font-size: 13px; padding: 6px 10px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-2); color: var(--fg); }
.auto-projects .ap-select:hover { border-color: var(--accent); }
.auto-projects .ap-del { opacity: .5; padding: 4px 8px; }
.auto-projects .ap-del:hover:not([disabled]) { opacity: 1; color: var(--danger); }
.auto-projects .ap-del[disabled] { opacity: .2; cursor: default; }
.auto-scene .regen .rl { display: block; font-size: 11px; color: var(--muted); margin: 6px 0 2px; }
.scenes-view { display: flex; gap: 8px; margin: 12px 0; }
.scenes-view .btn.mode { flex: 1; }
.flat-view { flex-wrap: wrap; align-items: center; margin: 8px 0 6px; }
.flat-view > .btn.mode { flex: 0 0 auto; }
.flat-modes { display: inline-flex; gap: 6px; margin-left: auto; }
.flat-modes .btn.mode { flex: 0 0 auto; padding: 4px 10px; font-size: 12px; }
#autoFlat { font-family: inherit; line-height: 1.5; }
#autoFlatHint { font-size: 12px; margin: 4px 0 0; }
#autoFlatHint code { background: rgba(127,127,127,.15); padding: 0 4px; border-radius: 3px; }
.status-line { font-size: 12px; margin: 6px 0; }
.status-line .st { font-weight: 600; }
.status-line .st.ok { color: #3fb950; }
.status-line .st.wait { color: #d29922; }
.status-line .st.err { color: var(--danger); }
.status-line .st.idle { color: var(--muted); font-weight: 400; }
.status-line .st i { font-style: normal; text-decoration: underline dotted; cursor: help; opacity: .8; }
.final-status { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; margin-bottom: 14px;
  padding: 10px 12px; background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); }
.final-block { margin-bottom: 18px; }
.final-block h3 { font-size: 14px; margin-bottom: 8px; }
.final-block .auto-final { width: 100%; max-width: 420px; border-radius: var(--radius); }
.final-block audio { width: 100%; }
.log-console { position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  background: #0b0e14; border-top: 1px solid var(--line); height: 34vh; max-height: 90vh; min-height: 34px;
  display: flex; flex-direction: column; box-shadow: 0 -4px 16px rgba(0,0,0,.4); }
.log-console.collapsed { height: auto !important; }
.log-console.collapsed .log-body, .log-console.collapsed .log-resize { display: none; }
/* Ручка resize — тягни вгору/вниз, щоб міняти висоту консолі логів. */
.log-resize { height: 7px; cursor: ns-resize; background: var(--bg-3);
  border-bottom: 1px solid var(--line); flex: 0 0 auto; }
.log-resize:hover { background: var(--accent); }
.log-resize::before { content: ""; display: block; width: 40px; height: 3px; margin: 2px auto 0;
  background: #47526480; border-radius: 2px; }
.log-head { display: flex; justify-content: space-between; align-items: center;
  padding: 6px 12px; font-size: 12px; border-bottom: 1px solid var(--line); background: var(--bg-2); }
.log-title b { color: var(--muted); }
.log-title b.on { color: #3fb950; }
.log-title b.off { color: var(--danger); }
.log-body { margin: 0; padding: 8px 12px; overflow-y: auto; font-family: ui-monospace, Consolas, monospace;
  font-size: 11.5px; line-height: 1.5; color: #c9d1d9; white-space: pre-wrap; word-break: break-word;
  user-select: text; -webkit-user-select: text; cursor: text; }
.log-body .lg-err { color: #ff7b72; }
.log-body .lg-warn { color: #d29922; }
.log-body .lg-ok { color: #3fb950; }
.fld { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted); margin-bottom: 14px; }
.fld > span { display: flex; justify-content: space-between; }
.fld > span a { color: var(--accent); }
.fld textarea, .fld select {
  background: var(--bg-3); border: 1px solid var(--line); color: var(--text);
  border-radius: 8px; padding: 8px 10px; resize: vertical; }
.fld textarea { font-family: ui-monospace, monospace; font-size: 12px; line-height: 1.4; }
.row { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.row > .fld { min-width: 110px; }
.row > .btn { align-self: flex-end; }
.chk { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text); margin: 8px 0; }
.chk input { accent-color: var(--accent); }
/* Уніфіковані «рамочки» — той самий вигляд, що й картки Озвучки (.tool-card):
   м'який фон, рамка, скруглення й тінь. Спільно для Студії та Автозбірки. */
.auto-settings { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 16px; margin-top: 14px; box-shadow: var(--shadow-card); }
.auto-settings legend { font-size: 12px; color: var(--muted); padding: 0 6px; font-weight: 600; }
.auto-warns { font-size: 12px; color: #e0b451; background: #2a220f; border: 1px solid #4a3c17;
  border-radius: 8px; padding: 8px 12px; margin-bottom: 14px; }
.auto-warns ul { margin: 4px 0 0 16px; }
.auto-summary { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 14px; }
.auto-summary h3 { font-size: 16px; margin-bottom: 8px; }
.auto-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.auto-chips span { font-size: 12px; background: var(--bg-3); border: 1px solid var(--line);
  border-radius: 20px; padding: 3px 10px; color: var(--muted); }
.auto-actions { display: flex; gap: 10px; margin-bottom: 16px; }
.auto-scenes { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.auto-scene { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; }
/* Формат рамки береться з проєкту (--scene-ar задає JS: 16/9 чи 9/16). */
.auto-scene .thumb { aspect-ratio: var(--scene-ar, 9/16); background: #000; display: flex; align-items: center; justify-content: center; }
/* contain — щоб фото будь-якої пропорції показувалось повністю, без обрізки. */
.auto-scene .thumb img, .auto-scene .thumb video { width: 100%; height: 100%; object-fit: contain; }
.auto-scene .thumb .ph { font-size: 28px; color: var(--muted); }
/* Лінивий показ відео: постер + кнопка плей замість одразу вантаженого <video>. */
.auto-scene .lazy-video { position: relative; width: 100%; height: 100%; }
.auto-scene .lazy-video .poster { width: 100%; height: 100%; object-fit: contain; display: block; }
.auto-scene .lazy-video .play-btn { position: absolute; inset: 0; margin: auto; width: 54px; height: 54px;
  border-radius: 50%; border: none; background: rgba(0,0,0,.55); color: #fff; font-size: 22px;
  cursor: pointer; display: flex; align-items: center; justify-content: center; }
.auto-scene .lazy-video .play-btn:hover { background: rgba(0,0,0,.75); }
.auto-scene .lazy-video video { width: 100%; height: 100%; object-fit: contain; }
/* Кружечок на кадрі, що зараз генерується (фото/відео). */
.auto-scene .thumb { position: relative; }
.gen-spin { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.45); z-index: 2; }
.gen-spin .spin { width: 34px; height: 34px; border: 3px solid rgba(255,255,255,.25);
  border-top-color: var(--accent); border-radius: 50%; animation: genspin 0.8s linear infinite; }
@keyframes genspin { to { transform: rotate(360deg); } }

/* Індикатор локальної анімації сцени — переживає перемикання вкладок (стан у
   animatingScenes, клас навішує markAnimatingScenes). */
.auto-scene.is-animating { position: relative; }
.auto-scene.is-animating::after { content: "⏳";
  position: absolute; top: 6px; left: 6px; z-index: 4; padding: 3px 8px;
  border-radius: 999px; font-size: 12px; font-weight: 600;
  background: rgba(0,0,0,.6); color: #fff; }

/* Кутові дії на кадрі (замінити/скачати/видалити) — з'являються на hover картки. */
.auto-scene .card-actions { position: absolute; top: 5px; right: 5px; z-index: 3;
  display: flex; gap: 4px; opacity: 0; transition: opacity .12s; }
.auto-scene:hover .card-actions { opacity: 1; }
.card-actions .ca-btn { width: 26px; height: 26px; padding: 0; border-radius: 6px;
  border: 1px solid rgba(255,255,255,.15); background: rgba(0,0,0,.6); color: #fff;
  font-size: 13px; cursor: pointer; line-height: 1; display: flex; align-items: center; justify-content: center; }
.card-actions .ca-btn:hover { background: rgba(0,0,0,.85); border-color: var(--accent); }
.card-actions .ca-del:hover { border-color: var(--danger); color: var(--danger); }
/* Рядок ZIP-скачування над сіткою кадрів. */
.dl-row { display: flex; gap: 8px; margin: 0 0 10px; }
.auto-scene .cap { padding: 6px 8px 0; font-size: 12px; }
.auto-scene .cap.small { color: var(--muted); padding-top: 2px;
  overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.auto-scene .stat { padding: 4px 8px 8px; font-size: 12px; color: var(--muted); }
.auto-result { margin-bottom: 16px; }
.auto-result h3 { font-size: 14px; margin-bottom: 8px; }
.auto-final { width: 100%; max-width: 320px; border-radius: var(--radius); background: #000; display: block; }
.auto-vo { font-size: 12px; color: var(--muted); margin-top: 10px; }
.auto-vo audio { display: block; width: 100%; max-width: 320px; margin-top: 4px; }
.mode-row { display: flex; gap: 8px; margin-bottom: 10px; }
.btn.mode { opacity: .6; }
.btn.mode.active { opacity: 1; border-color: var(--accent); background: var(--bg-3); }
.steps { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.steps .btn:disabled { opacity: .4; }
.auto-scene .regen-toggle { width: 100%; border: none; background: var(--bg-3); color: var(--muted);
  font-size: 11px; padding: 5px; cursor: pointer; border-top: 1px solid var(--line); }
.auto-scene .regen { padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.auto-scene .regen-prompt { width: 100%; background: var(--bg-3); border: 1px solid var(--line);
  color: var(--text); border-radius: 6px; padding: 6px; font-size: 11px; font-family: ui-monospace, monospace; resize: vertical; }
.auto-scene .regen .btn { font-size: 12px; padding: 6px; }
/* Ручна анімація кадру локально (без Veo) */
.auto-scene .anim-mini { padding: 8px; display: flex; flex-direction: column; gap: 8px;
  border-top: 1px solid var(--line); background: #12161d55; }
.auto-scene .anim-mini .fld { display: flex; flex-direction: column; gap: 3px; font-size: 11px; color: var(--muted); }
.auto-scene .anim-mini select { background: var(--bg-3); border: 1px solid var(--line);
  color: var(--text); border-radius: 6px; padding: 5px; font-size: 12px; }
.auto-scene .anim-mini .chip { font-size: 11px; padding: 3px 7px; }
.auto-scene .anim-mini .anim-go { font-size: 12px; padding: 7px; }
.src-badge { color: var(--accent-2); font-weight: 600; }
.vo-warn { color: #d29922; font-size: 12px; margin: 4px 0 8px;
  background: #d2992218; border: 1px solid #d2992255; border-radius: 6px; padding: 6px 8px; }
.pub-block .pub-field { margin: 8px 0; }
.pub-block .pub-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.pub-block .pub-label { font-size: 12px; font-weight: 600; color: var(--accent-2); }
.pub-block .pub-val { margin-top: 3px; padding: 6px 8px; border-radius: 6px; background: var(--bg-3);
  font-size: 12.5px; line-height: 1.4; white-space: pre-wrap; word-break: break-word;
  user-select: text; -webkit-user-select: text; }

/* ── Розумне скорочення (ШІ) ─────────────────────────────────────────────── */
.ai-cut { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px; margin-bottom: 14px; }
.ai-cut-controls { margin-top: 10px; display: flex; flex-direction: column; gap: 9px; }
.ai-hint { color: var(--muted); font-size: 11px; text-align: center; margin-top: -3px; }
.ai-summary { font-size: 12px; color: var(--muted); }
.ai-summary b { color: var(--accent-2); font-size: 13px; }
.ai-summary small { display: block; margin-top: 3px; }
.ai-cutlist { display: flex; flex-direction: column; gap: 6px; max-height: 320px; overflow-y: auto; }
.ai-item { display: flex; align-items: flex-start; gap: 8px; font-size: 12px;
  background: var(--bg-3); border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; }
.ai-item.kept { opacity: .5; }
.ai-item .grow { flex: 1; }
.ai-item .grow small { display: block; color: var(--muted); margin-top: 2px; }
.ai-item .ai-dur { color: var(--danger); font-variant-numeric: tabular-nums; white-space: nowrap; }
.ai-item button { background: none; border: 1px solid var(--line); border-radius: 6px;
  color: var(--muted); cursor: pointer; width: 24px; height: 24px; flex-shrink: 0; }
.ai-item button:hover { border-color: var(--accent); color: var(--text); }
.ai-tag { font-size: 10px; padding: 2px 6px; border-radius: 5px; white-space: nowrap;
  background: var(--bg); border: 1px solid var(--line); color: var(--muted); }
.ai-tag.ai-retake { color: var(--warn); border-color: var(--warn); }
.ai-tag.ai-repeat { color: var(--accent); border-color: var(--accent); }
.ai-tag.ai-filler { color: var(--muted); }
.ai-tag.ai-tangent { color: var(--accent-2); border-color: var(--accent-2); }
.ai-tag.ai-weak { color: var(--danger); border-color: var(--danger); }

/* ── Кабінет: безпека (пароль/показати/видалити) ─────────────────────────── */
.account-pw { display: flex; flex-direction: column; gap: 8px; }
.pw-field { position: relative; display: flex; align-items: center; }
.pw-field > input { width: 100%; padding-right: 34px; }
.pw-toggle {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer; padding: 4px;
  font-size: 15px; line-height: 1; opacity: .45;
}
.pw-toggle:hover, .pw-toggle.on { opacity: .9; }
.account-pw .form-error { color: var(--danger); font-size: 13px; margin: 0; }
.danger-zone { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line, #2a2a2a); }
.btn.danger { border-color: #6b2f2f; color: #ffb4b0; }
.btn.danger:not(:disabled):hover { background: #3a2022; color: #fff; }

/* ── Попередження про автовидалення (ретеншен) на картці проєкту ─────────── */
.ri-retention {
  display: inline-block; font-size: 11px; color: var(--warn, #e0a020);
  background: color-mix(in srgb, var(--warn, #e0a020) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--warn, #e0a020) 35%, transparent);
  border-radius: 6px; padding: 1px 6px; margin-top: 3px; white-space: nowrap;
}
.ri-retention.urgent {
  color: var(--danger); background: color-mix(in srgb, var(--danger) 14%, transparent);
  border-color: color-mix(in srgb, var(--danger) 45%, transparent);
}

/* ── Модалка підтвердження пошти (напівпрозоре скло, по центру) ──────────── */
.verify-modal {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  background: rgba(8, 10, 16, 0.55); backdrop-filter: blur(6px);
  animation: verifyFade .2s ease;
}
.verify-card {
  width: min(400px, 92vw); text-align: center; padding: 32px 26px;
  border-radius: 18px; border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(30, 34, 46, 0.72); backdrop-filter: blur(18px) saturate(1.2);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.45);
  animation: verifyPop .28s cubic-bezier(.2, .9, .3, 1.2);
}
.verify-card h2 { margin: 14px 0 8px; font-size: 22px; }
.verify-card p { margin: 0 0 22px; color: var(--muted); line-height: 1.5; }
.verify-icon { font-size: 52px; line-height: 1; }
.verify-card .wide { width: 100%; }
.verify-modal.err .verify-card { border-color: color-mix(in srgb, var(--danger) 45%, transparent); }
@keyframes verifyFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes verifyPop { from { opacity: 0; transform: translateY(12px) scale(.96); } to { opacity: 1; transform: none; } }
