/* EditsCut Mini App — тема telegram-native (реестр CORE/DESIGN-SYSTEM.md).
   Цвета — из темы Telegram пользователя (--tg-theme-*), запасные значения — светлые, как в референсе.
   Все компоненты ссылаются только на токены контракта. */

:root, [data-theme="telegram-native"] {
  --bg: var(--tg-theme-secondary-bg-color, #f2f4f8);
  --surface: var(--tg-theme-bg-color, #ffffff);
  --surface-2: var(--tg-theme-section-bg-color, #f6f7fb);
  --text: var(--tg-theme-text-color, #0d1017);
  --text-muted: var(--tg-theme-hint-color, #8a90a0);
  --line: color-mix(in srgb, var(--text) 8%, transparent);
  --accent-solid: var(--tg-theme-button-color, #2f7bf6);
  --accent: var(--accent-solid);
  --accent-2: color-mix(in srgb, var(--accent-solid) 12%, var(--surface));
  --on-accent: var(--tg-theme-button-text-color, #ffffff);
  --success: #22b35e;
  --warning: #f5b544;
  --danger: var(--tg-theme-destructive-text-color, #e5484d);

  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, sans-serif;
  --fs-1: 12px; --fs-2: 14px; --fs-3: 16px; --fs-4: 18px; --fs-5: 22px; --fs-6: 28px; --fs-7: 36px;
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 24px; --sp-6: 32px; --sp-7: 48px;
  --r-sm: 10px; --r-md: 16px; --r-lg: 22px; --r-full: 999px;
  --shadow-1: 0 1px 2px rgba(15, 20, 35, .05);
  --shadow-2: 0 8px 24px rgba(15, 20, 35, .08);
  --shadow-3: 0 12px 32px color-mix(in srgb, var(--accent-solid) 30%, transparent);
  --ease: cubic-bezier(.2, .6, .2, 1); --dur: .2s;
  --nav-h: 64px;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { background: var(--bg); color: var(--text); font-family: var(--font-sans); font-size: var(--fs-3);
  line-height: 1.45; -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
input, textarea { font: inherit; color: inherit; }
svg { display: block; }
.hidden { display: none !important; }

.app { max-width: 560px; margin: 0 auto; min-height: 100vh;
  padding: var(--sp-4) var(--sp-4) calc(var(--nav-h) + max(env(safe-area-inset-bottom), 12px) + var(--sp-6)); }
.app.no-nav { padding-bottom: calc(max(env(safe-area-inset-bottom), 12px) + var(--sp-5)); }

/* ---------- типографика ---------- */
.h1 { font-size: var(--fs-6); font-weight: 800; letter-spacing: -.02em; line-height: 1.12; }
.h2 { font-size: var(--fs-4); font-weight: 700; letter-spacing: -.01em; }
.muted { color: var(--text-muted); }
.small { font-size: var(--fs-2); }
.xs { font-size: var(--fs-1); }
.section-title { display: flex; justify-content: space-between; align-items: baseline;
  margin: var(--sp-5) 2px var(--sp-3); }

/* ---------- шапка ---------- */
.top { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--sp-4); }
.logo { display: flex; align-items: center; gap: var(--sp-2); font-weight: 800; font-size: var(--fs-4); letter-spacing: -.02em; }
.logo__mark { width: 32px; height: 32px; border-radius: 10px; background: var(--accent); color: var(--on-accent);
  display: grid; place-items: center; }
.step-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--sp-4); }
.step-dots { display: flex; gap: 6px; }
.step-dots i { width: 18px; height: 4px; border-radius: 4px; background: var(--line); }
.step-dots i.on { background: var(--accent-solid); }

/* ---------- карточки ---------- */
.card { background: var(--surface); border-radius: var(--r-lg); padding: var(--sp-4); box-shadow: var(--shadow-1); }
.card + .card { margin-top: var(--sp-3); }

.hero { border-radius: var(--r-lg); padding: var(--sp-5) var(--sp-4) var(--sp-4); color: var(--on-accent);
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent-solid) 88%, #fff) 0%, var(--accent-solid) 60%,
  color-mix(in srgb, var(--accent-solid) 80%, #000) 100%); box-shadow: var(--shadow-3); position: relative; overflow: hidden; }
.hero::after { content: ""; position: absolute; right: -40px; top: -40px; width: 160px; height: 160px; border-radius: 50%;
  background: rgba(255, 255, 255, .12); }
.hero__label { font-size: var(--fs-2); opacity: .85; }
.hero__value { font-size: 44px; font-weight: 800; letter-spacing: -.03em; line-height: 1.05; margin: 2px 0 var(--sp-4); }
.hero__value small { font-size: var(--fs-2); font-weight: 500; opacity: .8; margin-left: 6px; letter-spacing: 0; }

/* ---------- кнопки ---------- */
.btn { display: flex; align-items: center; justify-content: center; gap: var(--sp-2); width: 100%;
  min-height: 52px; padding: 0 var(--sp-5); border-radius: var(--r-md); font-weight: 700; font-size: var(--fs-3);
  transition: transform var(--dur) var(--ease), opacity var(--dur) var(--ease); }
.btn:active { transform: scale(.98); }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn--primary { background: var(--accent); color: var(--on-accent); box-shadow: var(--shadow-3); }
.btn--white { background: var(--on-accent); color: var(--accent-solid); }
.btn--ghost { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-2); margin-top: var(--sp-2); }
.btn-row .btn { min-height: 46px; font-size: var(--fs-2); }
.hint { text-align: center; margin-top: var(--sp-2); }

/* ---------- быстрые действия ---------- */
.quick { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-2); margin-top: var(--sp-3); }
.quick button { background: var(--surface); border-radius: var(--r-md); padding: var(--sp-3) var(--sp-2);
  display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: var(--fs-1); color: var(--text); box-shadow: var(--shadow-1); }
.quick .ico { width: 38px; height: 38px; border-radius: 12px; background: var(--accent-2); color: var(--accent-solid); display: grid; place-items: center; }

/* ---------- список роликов ---------- */
.rows { background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-1); overflow: hidden; }
.row { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4); width: 100%; text-align: left; }
.row + .row { border-top: 1px solid var(--line); }
.row__thumb { width: 44px; height: 56px; border-radius: 10px; background: var(--accent-2); color: var(--accent-solid);
  display: grid; place-items: center; flex: none; }
.row__body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.row__title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row__chev { color: var(--text-muted); }
.chip { display: inline-flex; align-items: center; gap: 5px; font-size: var(--fs-1); color: var(--text-muted); }
.chip i { width: 7px; height: 7px; border-radius: 50%; background: var(--text-muted); }
.chip.ok i { background: var(--success); } .chip.work i { background: var(--accent-solid); } .chip.bad i { background: var(--danger); }
.empty { text-align: center; padding: var(--sp-6) var(--sp-4); }
.empty .ico { width: 56px; height: 56px; margin: 0 auto var(--sp-3); border-radius: 18px; background: var(--accent-2);
  color: var(--accent-solid); display: grid; place-items: center; }

/* ---------- загрузка ---------- */
.drop { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--sp-2);
  width: 100%; min-height: 220px; border: 2px dashed color-mix(in srgb, var(--accent-solid) 35%, transparent);
  border-radius: var(--r-lg); background: var(--surface); text-align: center; padding: var(--sp-5); }
.drop .ico { width: 64px; height: 64px; border-radius: 20px; background: var(--accent-2); color: var(--accent-solid); display: grid; place-items: center; }
.bar { height: 8px; border-radius: 8px; background: var(--line); overflow: hidden; margin-top: var(--sp-3); }
.bar > i { display: block; height: 100%; width: 0; background: var(--accent-solid); border-radius: 8px; transition: width .3s var(--ease); }
.uploaded { display: flex; align-items: center; gap: var(--sp-3); }
.uploaded .ico { width: 48px; height: 48px; border-radius: 14px; background: color-mix(in srgb, var(--success) 14%, var(--surface));
  color: var(--success); display: grid; place-items: center; }

.pics { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--sp-2); margin-top: var(--sp-3); }
.pics > * { aspect-ratio: 1; border-radius: 12px; overflow: hidden; background: var(--surface-2); }
.pics img { width: 100%; height: 100%; object-fit: cover; }
.pics .add { display: grid; place-items: center; color: var(--accent-solid); border: 1.5px dashed color-mix(in srgb, var(--accent-solid) 40%, transparent); background: var(--surface); }

/* ---------- выбор стиля ---------- */
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-2); }
.opt { position: relative; background: var(--surface); border-radius: var(--r-md); padding: var(--sp-3) var(--sp-2);
  display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; border: 2px solid transparent;
  box-shadow: var(--shadow-1); transition: border-color var(--dur) var(--ease); }
.opt .ico { color: var(--accent-solid); margin-bottom: 2px; }
.opt b { font-size: var(--fs-2); }
.opt span { font-size: 11px; color: var(--text-muted); line-height: 1.25; }
.opt.on { border-color: var(--accent-solid); }
.opt.on::after { content: ""; position: absolute; top: 6px; right: 6px; width: 16px; height: 16px; border-radius: 50%;
  background: var(--accent-solid) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E") center/11px no-repeat; }

.styles { display: flex; gap: var(--sp-2); overflow-x: auto; margin: 0 calc(-1 * var(--sp-4)); padding: 2px var(--sp-4) var(--sp-2);
  scroll-snap-type: x mandatory; scrollbar-width: none; }
.styles::-webkit-scrollbar { display: none; }
.style { flex: none; width: 92px; scroll-snap-align: start; display: flex; flex-direction: column; gap: 6px; align-items: center; }
.style__img { width: 92px; height: 122px; border-radius: 14px; overflow: hidden; border: 2px solid transparent; background: #111; }
.style__img img { width: 100%; height: 100%; object-fit: cover; }
.style b { font-size: var(--fs-1); font-weight: 600; color: var(--text-muted); }
.style.on .style__img { border-color: var(--accent-solid); }
.style.on b { color: var(--accent-solid); }

.toggles { background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-1); }
.toggle { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4); width: 100%; text-align: left; }
.toggle + .toggle { border-top: 1px solid var(--line); }
.toggle .ico { width: 34px; height: 34px; border-radius: 10px; background: var(--accent-2); color: var(--accent-solid); display: grid; place-items: center; flex: none; }
.toggle__body { flex: 1; display: flex; flex-direction: column; }
.toggle__body b { font-weight: 600; font-size: var(--fs-2); }
.switch { width: 46px; height: 28px; border-radius: 28px; background: var(--line); position: relative; flex: none; transition: background var(--dur) var(--ease); }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: var(--on-accent);
  box-shadow: var(--shadow-1); transition: transform var(--dur) var(--ease); }
.toggle.on .switch { background: var(--accent-solid); }
.toggle.on .switch::after { transform: translateX(18px); }

/* ---------- монтаж идёт ---------- */
.progress { display: flex; flex-direction: column; align-items: center; text-align: center; padding-top: var(--sp-6); }
.ring { width: 168px; height: 168px; position: relative; margin-bottom: var(--sp-5); }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 10; }
.ring .track { stroke: var(--line); }
.ring .val { stroke: var(--accent-solid); stroke-linecap: round; transition: stroke-dashoffset .8s var(--ease); }
.ring b { position: absolute; inset: 0; display: grid; place-items: center; font-size: 38px; font-weight: 800; letter-spacing: -.03em; }
.checklist { width: 100%; margin-top: var(--sp-5); text-align: left; }
.check { display: flex; align-items: center; gap: var(--sp-3); padding: 10px var(--sp-4); }
.check i { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; flex: none; }
.check.done i { background: var(--accent-solid); border-color: var(--accent-solid); color: var(--on-accent); }
.check.now i { border-color: var(--accent-solid); }
.check.now i::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent-solid); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .3; } }
.tip { display: flex; gap: var(--sp-3); align-items: center; margin-top: var(--sp-5); background: var(--accent-2); border-radius: var(--r-md); padding: var(--sp-3) var(--sp-4); text-align: left; }
.tip .ico { color: var(--accent-solid); flex: none; }

/* ---------- готово ---------- */
.player { position: relative; border-radius: var(--r-lg); overflow: hidden; background: #000; aspect-ratio: 9 / 16;
  max-height: 62vh; margin: 0 auto; box-shadow: var(--shadow-2); }
.player video { width: 100%; height: 100%; object-fit: contain; display: block; }
.edit-box { display: flex; gap: var(--sp-2); align-items: flex-end; background: var(--surface); border-radius: var(--r-md); padding: 6px 6px 6px var(--sp-4); box-shadow: var(--shadow-1); margin-top: var(--sp-3); }
.edit-box textarea { flex: 1; border: 0; outline: 0; background: none; resize: none; font-size: var(--fs-2); padding: 9px 0; max-height: 96px; }
.edit-box button { width: 40px; height: 40px; border-radius: 12px; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; flex: none; }
.chips { display: flex; gap: 6px; overflow-x: auto; margin: var(--sp-2) calc(-1 * var(--sp-4)) 0; padding: 0 var(--sp-4); scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips button { flex: none; background: var(--surface); border-radius: var(--r-full); padding: 7px 12px; font-size: var(--fs-1); font-weight: 600; box-shadow: var(--shadow-1); }

/* ---------- тост ---------- */
.toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + max(env(safe-area-inset-bottom), 12px) + 20px); transform: translate(-50%, 20px);
  background: color-mix(in srgb, var(--text) 92%, transparent); color: var(--surface); padding: 10px 16px; border-radius: 14px; font-size: var(--fs-2);
  opacity: 0; pointer-events: none; transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease); max-width: 88vw; text-align: center; z-index: 60; }
.toast.on { opacity: 1; transform: translate(-50%, 0); }

/* ---------- нижняя навигация: плавающая таблетка (стандарт экосистемы 2026-08-23) ---------- */
.nav-fade { position: fixed; left: 0; right: 0; bottom: 0; height: 110px; pointer-events: none; z-index: 40;
  background: linear-gradient(to top, var(--bg) 35%, transparent); }
.nav { position: fixed; left: 50%; transform: translateX(-50%); bottom: max(env(safe-area-inset-bottom), 12px); z-index: 50;
  display: flex; gap: 4px; padding: 6px; border-radius: var(--r-full); background: color-mix(in srgb, var(--surface) 95%, transparent);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); box-shadow: var(--shadow-2); }
.nav button { min-height: 48px; min-width: 52px; padding: 0 14px; border-radius: var(--r-full); display: flex; align-items: center; gap: 8px;
  color: var(--text-muted); font-weight: 700; font-size: var(--fs-2); transition: background var(--dur) var(--ease), color var(--dur) var(--ease); }
.nav button span { display: none; }
.nav button.on { background: var(--accent); color: var(--on-accent); padding: 0 18px; }
.nav button.on span { display: inline; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
