/* Мини-приложение «Монтажник» основного бота. Тема — светлая или тёмная, как у Telegram
   (boot.js и app.js ставят data-theme на <html> по Telegram.WebApp.colorScheme). */
:root {
  --bg: #f4f4f6;
  --card: #ffffff;
  --ink: #15161a;
  --soft: #6a6b73;
  --line: #e6e6ea;
  --field: #f0f0f3;
  --on-bg: #15161a;
  --on-ink: #ffffff;
  --track-off: #d9d9de;
  --frame: #2a2d33;
  --ok: #1f7a4d;
  --ok-wash: #e2f3ea;
  --warn: #9a3412;
  --warn-wash: #fde4dc;
  --soon: #4338ca;
  --soon-wash: #e5e3ff;
  --hot-a: #ff8a3d;
  --hot-b: #e0338a;
  --hot-c: #8a3df0;
  --tab-h: 64px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0f1012;
  --card: #1b1c20;
  --ink: #f2f2f4;
  --soft: #9b9ca3;
  --line: #2a2b30;
  --field: #24252a;
  --on-bg: #f2f2f4;
  --on-ink: #15161a;
  --track-off: #3a3b40;
  --ok: #6fd3a1;
  --ok-wash: #183326;
  --warn: #ffb59b;
  --warn-wash: #3a2219;
  --soon: #c4c0ff;
  --soon-wash: #2a2850;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
/* Без приближения (владелец 07.10.2026: «случайно двумя пальцами и двойным нажатием на свободном
   месте приближаю»): листать можно, щипок и двойное касание экран не увеличивают */
html, body { touch-action: pan-x pan-y; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
button, label, input, a { touch-action: manipulation; }
body {
  font: 16px/1.4 "Golos Text", system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-tap-highlight-color: transparent;
  padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom, 0px) + 24px);
}
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }
a { color: inherit; }

.app { max-width: 480px; margin: 0 auto; padding: 0 14px; }
.screen { display: flex; flex-direction: column; gap: 14px; padding-top: 12px; }
h1 { margin: 6px 0 0; font-size: 26px; letter-spacing: -0.01em; }
h2 { margin: 6px 0 -4px; font-size: 17px; }
.muted { margin: 0; color: var(--soft); }
/* Подписи разделов «Баланса» — как у Brandly: мелкие заглавные с разрядкой */
.eyebrow { margin: 6px 0 -6px; font-size: 13px; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: var(--soft); }

/* Загрузка и сбой */
.loading { display: flex; justify-content: center; padding: 40vh 0 0; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--line);
  border-top-color: var(--ink); animation: spin .8s linear infinite; }
.spinner.small { width: 22px; height: 22px; border-width: 2px; margin: 12px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.failed { margin-top: 30vh; display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }
.failed p { margin: 0; }

/* Вне Telegram */
.stub { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.stub-card { max-width: 380px; width: 100%; background: var(--card); border-radius: 22px; padding: 26px 22px;
  display: flex; flex-direction: column; gap: 12px; }
.stub-card h1 { margin: 4px 0 0; }
.stub-mark { width: 60px; height: 60px; border-radius: 50%; background: var(--field);
  display: flex; align-items: center; justify-content: center; }

/* Шапка */
.top { display: flex; align-items: center; justify-content: space-between; }
.brand { font-size: 22px; font-weight: 900; letter-spacing: -0.02em; }
.balance-pill { display: flex; align-items: center; gap: 6px; background: var(--card); border: 0;
  border-radius: 16px; padding: 6px 12px; font-size: 14px; font-weight: 600; min-height: 34px; }

/* Пример ролика. Шрифт, цвет и размер субтитров — переменные --cap-*, их ставит app.js. Место —
   как в боте: снизу низ надписи на нижней границе безопасной зоны (16 % высоты), сверху — верх
   на верхней (12 %), `safe_zone` в config/style.yaml. Высокий шрифт снизу растёт вверх сам */
.preview-wrap { display: flex; justify-content: center; }
.frame { position: relative; width: 214px; height: 380px; border-radius: 18px; overflow: hidden;
  background: var(--frame); }
/* Кадр-пример — фото владельца (07.10.2026: «Поставь эту картинку для дизайна как основную, на
   которую будут шрифты накладываться»), 9:16, как ролик */
.photo { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.badge { position: absolute; right: 10px; top: 10px; padding: 4px 8px; border-radius: 10px;
  background: rgba(0, 0, 0, .55); color: #fff; font-size: 11px; }
/* Субтитры сверху — значок «Пример» уходит вниз, чтобы не лезть на строку */
.frame[data-place="top"] .badge { top: auto; bottom: 10px; }
/* Надпись видна, только когда выбор и шрифт уже на месте (app.js, replay) */
.caption:not(.on), .caption.wait { visibility: hidden; }
.caption { position: absolute; left: 10px; right: 10px; display: flex; flex-direction: column;
  align-items: center; text-align: center; text-shadow: 0 2px 8px rgba(0, 0, 0, .75); bottom: 16%; }
.frame[data-place="top"] .caption { bottom: auto; top: 12%; }
.caption .small { color: #fff; line-height: 1.1; font-family: var(--cap-font); font-weight: var(--cap-small-weight, 600);
  font-size: var(--cap-small, 14px); }
.caption .key { line-height: 1; letter-spacing: -0.02em; font-family: var(--cap-font);
  font-weight: var(--cap-weight, 900); font-size: var(--cap-key, 44px); color: var(--cap-color, #FFC53D); }
/* Надпись выходит, как в ролике: app/render/anim.py — каждое слово раскрывает маска снизу вверх за
   captions.word_in_ms = 90 мс по кривой motion.easing [0.22, 1, 0.36, 1] из config/style.yaml.
   Маска шире слова на половину высоты со всех сторон: хвосты букв и тень не видны до своего мига */
.caption .w { display: inline-block; }
.caption.play .w { animation: word-in 90ms cubic-bezier(0.22, 1, 0.36, 1) var(--at, 0ms) backwards; }
@keyframes word-in {
  from { clip-path: inset(150% -50% -50% -50%); }
  to { clip-path: inset(-50% -50% -50% -50%); }
}

/* Полоска сверху, пока большой пример за краем экрана: оформление всё время видно (владелец
   07.10.2026). Карточка со скруглёнными углами, не касается краёв, вся надпись в три строки */
.strip { position: fixed; z-index: 8; top: 14px; left: 0; right: 0; margin: 0 auto;
  width: min(100% - 28px, 452px); height: 120px; border-radius: 16px; overflow: hidden;
  background: var(--frame) url("sample.jpg") center 66% / cover no-repeat;
  box-shadow: 0 8px 22px rgba(0, 0, 0, .28);
  transform: translateY(calc(-100% - 48px)); transition: transform .2s ease; }
.strip.shown { transform: none; }
.strip .caption { top: 50%; bottom: auto; transform: translateY(-50%); }
.strip .caption .small { font-size: calc(var(--cap-small, 14px) * .9 * var(--strip-fit, 1)); }
.strip .caption .key { font-size: calc(var(--cap-key, 44px) * .8 * var(--strip-fit, 1)); }

/* Чипы стиля, шрифта и цвета */
.chips { display: flex; gap: 6px; overflow-x: auto; background: var(--card); border-radius: 22px; padding: 6px;
  scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips.center > :first-child { margin-left: auto; }
.chips.center > :last-child { margin-right: auto; }
.chip { flex-shrink: 0; border: 0; border-radius: 16px; padding: 9px 14px; font-size: 15px; background: transparent;
  display: flex; align-items: center; gap: 7px; min-height: 40px; }
.chip[aria-pressed="true"] { background: var(--on-bg); color: var(--on-ink); font-weight: 600; }
.dot { width: 11px; height: 11px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .15); }
.chip.soon { cursor: default; color: var(--soft); box-shadow: inset 0 0 0 1.5px var(--line); }
.chip.soon .soon-name { opacity: .6; }
.soon-pill { font-size: 10px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  padding: 3px 7px; border-radius: 8px; background: var(--soon-wash); color: var(--soon); }

/* Плитки субтитров и монтажа */
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.grid .tile:last-child:nth-child(odd) { grid-column: 1 / -1; min-height: 0; }
.tile { background: var(--card); border-radius: 16px; padding: 10px 12px; display: flex; flex-direction: column;
  gap: 10px; justify-content: space-between; min-height: 96px; }
.tile-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 6px; font-size: 14px;
  line-height: 1.25; }
.ask { flex-shrink: 0; width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--card); color: var(--soft); font-size: 13px; }
.cycle { border: 0; background: var(--field); border-radius: 10px; padding: 9px 10px; display: flex;
  justify-content: space-between; align-items: center; font-size: 14px; font-weight: 600; min-height: 40px; }
.switch { width: 50px; height: 30px; border: 0; border-radius: 15px; padding: 2px; display: flex;
  background: var(--track-off); justify-content: flex-start; transition: background .15s ease; }
.switch[aria-pressed="true"] { background: var(--on-bg); justify-content: flex-end; }
.switch span { width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); }
.switch[aria-pressed="true"] span { background: var(--on-ink); }

/* Видео: загрузка в приложении, как у Brandly (владелец 08.10.2026) */
.section-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: -4px; }
.section-head h2 { margin: 6px 0 0; }
.link { border: 0; background: none; color: var(--soft); font-size: 14px; text-decoration: underline;
  text-underline-offset: 3px; padding: 6px 0; }
.info-link { display: inline-flex; align-items: center; gap: 5px; }
.info-link svg { flex-shrink: 0; }
/* Зона «Загрузите видео»: пунктир — пусто, сплошная зелёная — файл подходит, сплошная
   тёплая — не подходит. Нажатие в любом месте открывает выбор файла (input внутри label) */
.upload { position: relative; border: 2px dashed var(--line); border-radius: 18px; background: var(--card);
  padding: 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  cursor: pointer; min-height: 84px; }
.upload input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.upload:focus-within { outline: 2px solid var(--ink); outline-offset: 2px; }
.upload.ready { border-style: solid; border-color: var(--ok); }
.upload.bad { border-style: solid; border-color: var(--warn); }
.upload.locked { cursor: default; }
.upload.locked .plus { opacity: .35; }
.upload-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.upload-title { font-size: 18px; font-weight: 800; overflow-wrap: anywhere; }
.upload-hint { font-size: 13px; color: var(--soft); }
.upload.bad .upload-hint { color: var(--warn); }
.plus { flex-shrink: 0; width: 48px; height: 48px; border-radius: 50%; background: var(--on-bg); color: var(--on-ink);
  display: flex; align-items: center; justify-content: center; }
.upload-alert { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.upload-alert p { margin: 0; white-space: pre-line; }
/* Большая кнопка во всю ширину — градиент, как круглая «Монтаж» на панели */
.launch { position: relative; min-height: 60px; border: 0; border-radius: 30px; color: #fff;
  background: linear-gradient(90deg, var(--hot-a), var(--hot-b) 55%, var(--hot-c));
  font-size: 17px; font-weight: 800; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 1px; width: 100%; padding: 8px 18px; box-shadow: 0 8px 20px rgba(224, 51, 138, .25); }
.launch:disabled { opacity: .45; cursor: default; box-shadow: none; }
.launch-note { font-size: 12px; font-weight: 600; opacity: .9; }
/* Ход загрузки — на месте кнопки, той же формы */
.progress { position: relative; height: 60px; border-radius: 30px; overflow: hidden; background: var(--field);
  display: flex; align-items: center; justify-content: center; }
/* Градиент — во всю дорожку (--box-w): заливка его открывает, а не сжимает в полоску */
.progress-bar { position: absolute; inset: 0 auto 0 0; width: 0; overflow: hidden; transition: width .2s ease;
  background: linear-gradient(90deg, var(--hot-a), var(--hot-b) 55%, var(--hot-c)) 0 0 / var(--box-w, 100%) 100% no-repeat; }
.progress-text { position: relative; font-size: 16px; font-weight: 800; color: var(--ink); padding: 0 16px;
  text-align: center; line-height: 1.2; }
/* Белая копия подписи — во всю ширину дорожки (--box-w ставит app.js), видна только по заливке;
   ширина и поля те же, поэтому и переносится она так же */
.progress-text.on-bar { position: absolute; inset: 0 auto 0 0; width: var(--box-w, 100vw); color: #fff;
  display: flex; align-items: center; justify-content: center; }
.under { text-align: center; font-size: 13px; color: var(--soft); margin-top: -4px; }
.under-label { font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }

/* Экран «Монтаж запущен» */
.done { display: flex; flex-direction: column; gap: 12px; padding-top: 18px; }
.done h1 { margin: 0; }
.done-mark { width: 64px; height: 64px; border-radius: 50%; background: var(--ok-wash); color: var(--ok);
  display: flex; align-items: center; justify-content: center; }
.started-text { white-space: pre-line; }
.done .summary div { padding: 9px 0; font-size: 15px; }

/* Баланс — как у Brandly */
.card { background: var(--card); border-radius: 18px; padding: 14px 16px; }
.balance-card { display: flex; flex-direction: column; gap: 6px; padding: 18px; border-radius: 22px; }
.balance-card .eyebrow { margin: 0; }
.balance-big { font-size: 46px; font-weight: 900; letter-spacing: -0.03em; line-height: 1.05; }
.balance-unit { font-size: 20px; font-weight: 600; color: var(--soft); letter-spacing: 0; }
.free-note { margin: 0; color: var(--ok); font-weight: 600; }
.balance-card .wide { margin-top: 10px; }
.pack { position: relative; width: 100%; border: 2px solid transparent; text-align: left;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px; border-radius: 20px; }
.pack[aria-checked="true"] { border-color: var(--ink); }
.popular { position: absolute; left: 14px; top: -10px; padding: 3px 10px; border-radius: 10px;
  font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: #fff;
  background: linear-gradient(90deg, var(--hot-a), var(--hot-b) 60%, var(--hot-c)); }
.pack-left, .pack-right { display: flex; flex-direction: column; gap: 3px; }
.pack-right { text-align: right; align-items: flex-end; }
.pack-videos { font-size: 18px; font-weight: 700; }
.pack-n { font-size: 30px; font-weight: 900; letter-spacing: -0.02em; }
.pack-price { font-size: 22px; font-weight: 900; white-space: nowrap; }
.pack-sub { font-size: 14px; color: var(--soft); white-space: nowrap; }
.method { width: 100%; border: 2px solid transparent; display: flex; justify-content: space-between;
  align-items: center; gap: 12px; padding: 16px; min-height: 58px; border-radius: 18px; text-align: left; }
.method[aria-checked="true"] { border-color: var(--ink); }
.method-name { font-size: 17px; font-weight: 700; }
.method-price { color: var(--soft); white-space: nowrap; }
.summary { margin: 0; background: var(--card); border-radius: 18px; padding: 4px 16px; }
.summary div { display: flex; justify-content: space-between; gap: 12px; padding: 12px 0; }
.summary div + div { border-top: 1px solid var(--line); }
.summary dt { color: var(--soft); }
.summary dd { margin: 0; text-align: right; font-weight: 800; }
.email { display: flex; flex-direction: column; gap: 8px; }
.email-saved { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field input { font: inherit; color: var(--ink); background: var(--field); border: 1.5px solid transparent;
  border-radius: 12px; padding: 12px 14px; min-height: 46px; }
.field input:focus { outline: none; border-color: var(--ink); }
.field-error { font-size: 13px; color: var(--warn); }
.consent { display: flex; align-items: flex-start; gap: 12px; cursor: pointer; font-size: 15px; padding: 4px 0; }
.consent input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.consent .box { flex-shrink: 0; width: 26px; height: 26px; border-radius: 8px; border: 2px solid var(--line);
  background: var(--card); display: flex; align-items: center; justify-content: center; }
.consent input:checked + .box { background: var(--on-bg); border-color: var(--on-bg); }
.consent input:checked + .box::after { content: ""; width: 12px; height: 7px; border-left: 2.5px solid var(--on-ink);
  border-bottom: 2.5px solid var(--on-ink); transform: translateY(-2px) rotate(-45deg); }
.consent input:focus-visible + .box { outline: 2px solid var(--ink); outline-offset: 2px; }
.doc { text-decoration: underline; text-underline-offset: 3px; }
.pay { min-height: 58px; border: 0; border-radius: 29px; background: var(--on-bg); color: var(--on-ink);
  font-size: 18px; font-weight: 800; width: 100%; }
.pay:disabled { background: var(--track-off); color: var(--soft); cursor: default; }

/* История операций */
.history { display: flex; flex-direction: column; max-height: 55vh; overflow-y: auto; }
.history-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; }
.history-row + .history-row { border-top: 1px solid var(--line); }
.history-what { font-weight: 600; }
.history-at { font-size: 13px; color: var(--soft); }
.history-credits { font-weight: 800; white-space: nowrap; }
.history-credits.plus { color: var(--ok); }

/* Списки и карточки других вкладок */
.list { display: flex; flex-direction: column; gap: 8px; }
.row { background: var(--card); border-radius: 16px; padding: 12px 14px; display: flex; align-items: center;
  justify-content: space-between; gap: 12px; }
.row.gone { opacity: .6; }
.row-title { font-weight: 600; }
.row-sub { font-size: 13px; color: var(--soft); }
.row-main.tap { cursor: pointer; flex: 1; }
/* Экран ролика: плеер во всю ширину листа, снизу «Прислать в чат» и «Сохранить в Фото» поровну */
.player-box { display: flex; flex-direction: column; gap: 12px; }
.player { display: block; width: 100%; max-height: 62vh; aspect-ratio: 9 / 16; border-radius: 14px;
  background: #000; object-fit: contain; }
.player-actions { display: flex; gap: 8px; }
.player-actions > button { flex: 1; padding: 0 10px; }
.sheet .player-hint { font-size: 14px; }
.status { font-size: 13px; padding: 4px 10px; border-radius: 10px; background: var(--field); color: var(--soft);
  white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
/* В очереди и «Монтирую» — с мигающей точкой: ролик живой, страница сама обновит список */
.status.live { background: var(--soon-wash); color: var(--soon); font-weight: 600; }
.status.live::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor;
  animation: pulse 1.2s ease-in-out infinite; }
.status.bad { background: var(--warn-wash); color: var(--warn); font-weight: 600; }
@keyframes pulse { 50% { opacity: .25; } }
.empty { padding: 4px 2px; }
.label { font-size: 13px; color: var(--soft); }
.ref-link { margin: 4px 0 12px; font-weight: 600; overflow-wrap: anywhere; user-select: text; }
.buttons { display: flex; gap: 8px; flex-wrap: wrap; }
.buttons > * { flex: 1 1 140px; }
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.stat-card .label { overflow-wrap: break-word; }
.stat { font-size: 22px; font-weight: 800; }
.secondary, .primary { min-height: 44px; border-radius: 12px; padding: 0 18px; font-size: 15px; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.secondary { border: 1px solid var(--line); background: var(--card); }
.primary { border: 0; background: var(--on-bg); color: var(--on-ink); }
.wide { width: 100%; min-height: 52px; border-radius: 26px; font-size: 16px; }
.faq details { background: var(--card); border-radius: 16px; padding: 12px 14px; }
.faq summary { font-weight: 600; cursor: pointer; }
.faq p { margin: 8px 0 0; color: var(--soft); white-space: pre-line; }
.faq details[open] > p:only-child { margin: 0; }

/* Нижняя панель */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; background: var(--card);
  border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
  padding: 4px 6px calc(6px + env(safe-area-inset-bottom, 0px)); min-height: var(--tab-h); }
.tab { position: relative; border: 0; background: none; display: flex; flex-direction: column; align-items: center;
  justify-content: flex-end; gap: 3px; font-size: 11px; color: var(--soft); min-height: 52px; }
.tab[aria-current="page"] { color: var(--ink); font-weight: 700; }
.tab svg { width: 22px; height: 22px; }
.tab.center .orb { width: 56px; height: 56px; margin-top: -26px; border-radius: 50%; color: #fff;
  background: linear-gradient(135deg, var(--hot-a), var(--hot-b) 55%, var(--hot-c));
  display: flex; align-items: center; justify-content: center; box-shadow: 0 6px 18px rgba(224, 51, 138, .35); }
.tab.center .orb svg { width: 26px; height: 26px; }
.tab-badge { position: absolute; top: 2px; left: 50%; margin-left: 4px; min-width: 18px; padding: 1px 6px;
  border-radius: 9px; background: var(--hot-b); color: #fff; font-size: 10px; font-weight: 700; line-height: 16px; }
.tab-badge:empty { display: none; }

/* Шторка «?» и истории */
.sheet-backdrop { position: fixed; inset: 0; z-index: 20; background: rgba(15, 16, 18, .45);
  display: flex; flex-direction: column; justify-content: flex-end; }
.sheet { background: var(--card); border-radius: 22px 22px 0 0; padding: 20px 20px calc(24px + env(safe-area-inset-bottom, 0px));
  display: flex; flex-direction: column; gap: 10px; max-width: 480px; width: 100%; margin: 0 auto; }
.sheet h3 { margin: 0; font-size: 19px; }
.sheet p { margin: 0; color: var(--soft); white-space: pre-line; line-height: 1.45; }
.sheet .primary { align-self: flex-start; margin-top: 6px; }

/* Сообщение внизу — над панелью */
.toast { position: fixed; z-index: 30; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tab-h) + env(safe-area-inset-bottom, 0px) + 14px); width: min(100% - 28px, 452px);
  background: var(--on-bg); color: var(--on-ink); border-radius: 14px; padding: 12px 14px; font-size: 14px;
  box-shadow: 0 8px 22px rgba(0, 0, 0, .25); }
