/* ═══════════════════════════════════════════════════════════════════════════
   Candy Studio — оформление Mini App.

   Тёмная база, «карамельный» градиент как единственный акцент, стекло вместо
   границ. Приложение открывается внутри Telegram на телефоне, поэтому всё
   рассчитано на палец: минимальная цель нажатия 44px, safe-area учтена,
   тяжёлые эффекты выключаются при prefers-reduced-motion.
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
  --bg:            #0a0610;
  --bg-soft:       #120a1c;
  --ink:           #f6f1fb;
  --ink-dim:       #a99fbb;
  --ink-faint:     #6e6480;

  --glass:         rgba(255, 255, 255, .045);
  --glass-strong:  rgba(255, 255, 255, .075);
  --stroke:        rgba(255, 255, 255, .10);
  --stroke-soft:   rgba(255, 255, 255, .06);

  --pink:          #ff5fa2;
  --violet:        #a855f7;
  --cyan:          #22d3ee;
  --mint:          #34e0b0;
  --amber:         #fbbf24;
  --danger:        #ff5f6d;

  --candy: linear-gradient(135deg, #ff5fa2 0%, #a855f7 52%, #22d3ee 100%);
  --candy-soft: linear-gradient(135deg, rgba(255,95,162,.16), rgba(168,85,247,.16) 52%, rgba(34,211,238,.16));

  --r-sm: 12px;
  --r-md: 18px;
  --r-lg: 26px;
  --r-xl: 34px;

  --tab-h: 66px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);

  --ease: cubic-bezier(.22, 1, .36, 1);
  --spring: cubic-bezier(.34, 1.56, .64, 1);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI",
               Roboto, "Helvetica Neue", sans-serif;
  font-size: 16px;
  line-height: 1.45;
  overscroll-behavior-y: none;
  -webkit-font-smoothing: antialiased;
}

body { overflow-x: hidden; }

h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -0.02em; }
p { margin: 0; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
input, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }

/* ── Фон ──────────────────────────────────────────────────────────────────── */

.aurora {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  background:
    radial-gradient(120% 80% at 50% -10%, #1c0f2c 0%, var(--bg) 62%),
    var(--bg);
}

/* Пятна намеренно слабые. На телефоне область маленькая, и всё, что ярче ~.15,
   превращает фон в сплошную заливку, на которой стеклянные карточки перестают
   читаться как отдельные объекты. */
.blob {
  position: absolute;
  width: 58vmax;
  height: 58vmax;
  border-radius: 50%;
  filter: blur(90px);
  opacity: .15;
  will-change: transform;
}

.blob-1 { background: var(--pink);   top: -26vmax; left: -20vmax; animation: drift-1 26s ease-in-out infinite; }
.blob-2 { background: var(--violet); top: 16vmax;  right: -28vmax; opacity: .13; animation: drift-2 32s ease-in-out infinite; }
.blob-3 { background: var(--cyan);   bottom: -32vmax; left: 4vmax; opacity: .09; animation: drift-3 38s ease-in-out infinite; }

/* Затемняющий слой поверх пятен: возвращает глубину базовому фону, но
   оставляет цветовой подтон по краям. */
.aurora::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(100% 60% at 50% 0%, transparent, rgba(10, 6, 16, .55) 70%),
    linear-gradient(180deg, rgba(10, 6, 16, .35), rgba(10, 6, 16, .78));
}

@keyframes drift-1 {
  0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
  50%      { transform: translate3d(14vmax, 8vmax, 0) scale(1.14); }
}
@keyframes drift-2 {
  0%, 100% { transform: translate3d(0, 0, 0) scale(1.06); }
  50%      { transform: translate3d(-12vmax, 14vmax, 0) scale(.92); }
}
@keyframes drift-3 {
  0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
  50%      { transform: translate3d(10vmax, -12vmax, 0) scale(1.2); }
}

/* Зерно поверх градиентов: без него на больших плоскостях виден бандинг. */
.grain {
  position: absolute;
  inset: -50%;
  opacity: .035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ── Загрузка ─────────────────────────────────────────────────────────────── */

.boot {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  animation: fade-in .3s var(--ease);
}

.boot-mark { font-size: 62px; animation: bob 2.2s ease-in-out infinite; }
@keyframes bob {
  0%, 100% { transform: translateY(0) rotate(-6deg); }
  50%      { transform: translateY(-14px) rotate(6deg); }
}

.boot-bar {
  width: 148px; height: 4px; border-radius: 99px;
  background: rgba(255, 255, 255, .1); overflow: hidden;
}
.boot-bar i {
  display: block; width: 40%; height: 100%; border-radius: 99px;
  background: var(--candy); animation: slide 1.3s var(--ease) infinite;
}
@keyframes slide {
  0%   { transform: translateX(-110%); }
  100% { transform: translateX(360%); }
}

.boot-text { color: var(--ink-dim); font-size: 14px; }

/* ── Экран-заглушка ───────────────────────────────────────────────────────── */

.gate {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 32px;
  text-align: center;
}
.gate-icon { font-size: 56px; }
.gate h2 { font-size: 21px; }
.gate p { color: var(--ink-dim); font-size: 15px; max-width: 320px; }
.gate-actions { display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 300px; margin-top: 10px; }

/* ── Каркас ───────────────────────────────────────────────────────────────── */

.view {
  position: relative;
  z-index: 1;
  padding: calc(var(--safe-t) + 14px) 16px calc(var(--tab-h) + var(--safe-b) + 24px);
  max-width: 560px;
  margin: 0 auto;
  animation: view-in .34s var(--ease);
}

@keyframes view-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

/* Пока висит плашка генерации, содержимому нужен запас снизу — иначе она
   накрывает последний элемент экрана, чаще всего как раз кнопку запуска. */
body.gen-running .view {
  padding-bottom: calc(var(--tab-h) + var(--safe-b) + 92px);
}

.stack { display: flex; flex-direction: column; gap: 14px; }

/* ── Шапка ────────────────────────────────────────────────────────────────── */

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.topbar .who { flex: 1; min-width: 0; }
.topbar .hello { font-size: 12px; color: var(--ink-faint); text-transform: uppercase; letter-spacing: .09em; }
.topbar .name { font-size: 19px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.avatar {
  position: relative;
  width: 42px; height: 42px; border-radius: 50%;
  background: var(--candy-soft);
  display: grid; place-items: center;
  font-size: 19px; font-weight: 700;
  overflow: hidden; flex-shrink: 0;
  border: 1px solid var(--stroke);
}
/* Буква лежит под фотографией и видна, только если та не загрузилась: у части
   аккаунтов фото скрыто настройками приватности и в initData его просто нет. */
.avatar img {
  position: absolute; inset: 0;
  width: 100%; height: 100%; object-fit: cover;
}

/* ── Карточки ─────────────────────────────────────────────────────────────── */

.card {
  position: relative;
  background: var(--glass);
  border: 1px solid var(--stroke-soft);
  border-radius: var(--r-lg);
  padding: 18px;
  backdrop-filter: blur(22px) saturate(1.3);
  -webkit-backdrop-filter: blur(22px) saturate(1.3);
}

.card-title {
  font-size: 12px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 12px;
}

/* Карточка баланса — главный объект на экране. */
.balance {
  position: relative;
  overflow: hidden;
  border-radius: var(--r-xl);
  padding: 22px;
  background:
    linear-gradient(150deg, rgba(255,95,162,.20), rgba(168,85,247,.14) 48%, rgba(34,211,238,.12)),
    var(--glass-strong);
  border: 1px solid var(--stroke);
  backdrop-filter: blur(26px) saturate(1.4);
  -webkit-backdrop-filter: blur(26px) saturate(1.4);
}
.balance::after {
  /* Блик, медленно проезжающий по карточке. */
  content: "";
  position: absolute; top: -60%; left: -30%;
  width: 60%; height: 220%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.10), transparent);
  transform: rotate(18deg);
  animation: sheen 7s ease-in-out infinite;
  pointer-events: none;
}
@keyframes sheen {
  0%, 70%, 100% { transform: translateX(-40%) rotate(18deg); opacity: 0; }
  82%           { opacity: 1; }
  95%           { transform: translateX(320%) rotate(18deg); opacity: 0; }
}

.balance-label { font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: rgba(255,255,255,.55); }
.balance-row { display: flex; align-items: baseline; gap: 10px; margin: 6px 0 2px; }
.balance-num {
  font-size: 46px; font-weight: 800; letter-spacing: -.04em; line-height: 1;
  font-variant-numeric: tabular-nums;
  background: linear-gradient(135deg, #fff 20%, #ffd6ea 60%, #c4b5fd);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.balance-unit { font-size: 24px; }
.balance-hint { font-size: 13px; color: var(--ink-dim); }
.balance-actions { display: flex; gap: 8px; margin-top: 16px; }

/* ── Кнопки ───────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 0 18px;
  border-radius: var(--r-md);
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -.01em;
  transition: transform .16s var(--spring), opacity .16s, filter .16s;
  user-select: none;
}
.btn:active { transform: scale(.96); }
.btn[disabled] { opacity: .42; pointer-events: none; }
.btn-block { width: 100%; }

.btn-primary {
  background: var(--candy);
  color: #14061a;
  font-weight: 750;
  box-shadow: 0 8px 26px -8px rgba(255, 95, 162, .65);
}
.btn-glass {
  background: var(--glass-strong);
  border: 1px solid var(--stroke);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.btn-ghost { color: var(--ink-dim); }
.btn-danger { background: rgba(255, 95, 109, .16); color: #ffa8b0; border: 1px solid rgba(255,95,109,.28); }
.btn-lg { min-height: 54px; font-size: 16.5px; border-radius: var(--r-lg); }

/* ── Сегментированный переключатель ───────────────────────────────────────── */

.segment {
  position: relative;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 4px;
  padding: 4px;
  background: var(--glass);
  border: 1px solid var(--stroke-soft);
  border-radius: var(--r-md);
}
.segment button {
  position: relative;
  z-index: 1;
  min-height: 40px;
  border-radius: 13px;
  font-size: 13.5px;
  font-weight: 620;
  color: var(--ink-dim);
  transition: color .2s, background .2s;
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.segment button.on {
  color: #16081c;
  background: var(--candy);
  box-shadow: 0 6px 18px -8px rgba(168, 85, 247, .8);
}

/* ── Загрузка фото ────────────────────────────────────────────────────────── */

.dropzone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 190px;
  border-radius: var(--r-lg);
  border: 1.5px dashed rgba(255, 255, 255, .16);
  background: var(--glass);
  text-align: center;
  padding: 20px;
  transition: border-color .2s, background .2s, transform .2s var(--spring);
  overflow: hidden;
}
.dropzone:active { transform: scale(.985); }
.dropzone.filled { border-style: solid; border-color: var(--stroke); padding: 0; min-height: 0; }
.dropzone-icon { font-size: 34px; }
.dropzone-title { font-weight: 650; font-size: 15px; }
.dropzone-sub { font-size: 13px; color: var(--ink-faint); }
.dropzone img { width: 100%; display: block; max-height: 340px; object-fit: cover; }

.dz-clear {
  position: absolute; top: 10px; right: 10px;
  width: 34px; height: 34px; border-radius: 50%;
  background: rgba(10, 6, 16, .66);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: grid; place-items: center;
  font-size: 15px;
  border: 1px solid var(--stroke);
}

/* ── Бесплатная генерация и замок ─────────────────────────────────────────── */

.free-tag {
  background: linear-gradient(120deg, #34d399, #22d3ee);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  font-weight: 800;
}

.pack-left {
  font-size: 11.5px;
  color: var(--mint);
  font-weight: 650;
  margin-top: 2px;
}

/* Замок поверх размытого превью — чтобы было ясно, что картинка не сломалась,
   а намеренно скрыта до оплаты. */
.lock-badge {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-size: 44px;
  filter: drop-shadow(0 4px 16px rgba(0, 0, 0, .7));
  pointer-events: none;
  animation: lock-pop .4s var(--spring);
}
@keyframes lock-pop {
  from { opacity: 0; transform: translate(-50%, -50%) scale(.6); }
  to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

/* ── Поле промпта ─────────────────────────────────────────────────────────── */

.field {
  position: relative;
  background: var(--glass);
  border: 1px solid var(--stroke-soft);
  border-radius: var(--r-md);
  transition: border-color .2s;
}
.field:focus-within { border-color: rgba(168, 85, 247, .5); }
.field textarea, .field input {
  width: 100%;
  background: none;
  border: 0;
  outline: 0;
  padding: 14px 14px 14px;
  resize: none;
  font-size: 15.5px;
  line-height: 1.5;
  min-height: 96px;
  display: block;
}
.field input { min-height: 0; height: 50px; padding: 0 14px; }
.field textarea::placeholder, .field input::placeholder { color: var(--ink-faint); }
.field-count {
  position: absolute; right: 12px; bottom: 8px;
  font-size: 11px; color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

/* ── Строка цены ──────────────────────────────────────────────────────────── */

.pricerow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--r-md);
  background: var(--glass);
  border: 1px solid var(--stroke-soft);
  font-size: 14px;
}
.pricerow .lbl { color: var(--ink-dim); }
.pricerow .val { font-weight: 700; font-variant-numeric: tabular-nums; }
.pricerow.short .val { color: #ffa8b0; }

/* ── Магазин ──────────────────────────────────────────────────────────────── */

.packs { display: flex; flex-direction: column; gap: 12px; }

.pack {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  border-radius: var(--r-lg);
  background: var(--glass);
  border: 1px solid var(--stroke-soft);
  overflow: hidden;
  transition: transform .18s var(--spring), border-color .2s;
  text-align: left;
  width: 100%;
}
.pack:active { transform: scale(.975); }

.pack.featured {
  border-color: rgba(255, 95, 162, .45);
  background: linear-gradient(140deg, rgba(255,95,162,.14), rgba(168,85,247,.10) 60%, transparent), var(--glass);
  box-shadow: 0 14px 40px -18px rgba(255, 95, 162, .7);
}
.pack.featured::before {
  content: "";
  position: absolute; inset: 0;
  background: radial-gradient(80% 100% at 100% 0%, rgba(255,95,162,.22), transparent 70%);
  pointer-events: none;
}

.pack-emoji {
  width: 54px; height: 54px; flex-shrink: 0;
  display: grid; place-items: center;
  font-size: 27px;
  border-radius: 17px;
  background: var(--glass-strong);
  border: 1px solid var(--stroke-soft);
}
.pack-main { flex: 1; min-width: 0; }
.pack-name { font-size: 16px; font-weight: 700; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pack-credit { font-size: 13px; color: var(--ink-dim); margin-top: 2px; }
.pack-tag {
  font-size: 11.5px;
  font-weight: 620;
  margin-top: 4px;
  background: var(--candy);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.pack-price {
  flex-shrink: 0;
  text-align: right;
  font-weight: 750;
  font-size: 16px;
  font-variant-numeric: tabular-nums;
}
.pack-price small { display: block; font-size: 11px; font-weight: 500; color: var(--ink-faint); }

.badge {
  display: inline-flex;
  align-items: center;
  height: 21px;
  padding: 0 9px;
  border-radius: 99px;
  font-size: 10.5px;
  font-weight: 750;
  letter-spacing: .04em;
  text-transform: uppercase;
  background: var(--candy);
  color: #16081c;
}
.badge-soft { background: rgba(52, 224, 176, .16); color: var(--mint); }
.badge-amber { background: rgba(251, 191, 36, .16); color: var(--amber); }

/* ── Способы оплаты ───────────────────────────────────────────────────────── */

.paylist { display: flex; flex-direction: column; gap: 10px; }
.payopt {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 14px 16px;
  border-radius: var(--r-md);
  background: var(--glass);
  border: 1px solid var(--stroke-soft);
  text-align: left;
  width: 100%;
  transition: transform .16s var(--spring);
}
.payopt:active { transform: scale(.975); }
.payopt-ico { font-size: 22px; width: 30px; text-align: center; flex-shrink: 0; }
/* Все трое — span'ы внутри flex-строки: без display:block название и подпись
   слипаются в один абзац. */
.payopt-main { display: block; flex: 1; min-width: 0; }
.payopt-name { display: block; font-weight: 650; font-size: 15px; }
.payopt-sub { display: block; font-size: 12.5px; color: var(--ink-faint); margin-top: 2px; }
.payopt-arrow { color: var(--ink-faint); font-size: 18px; }

/* ── Галерея ──────────────────────────────────────────────────────────────── */

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.tile {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--glass);
  border: 1px solid var(--stroke-soft);
  transition: transform .18s var(--spring);
}
.tile:active { transform: scale(.96); }
.tile img, .tile video { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile-kind {
  position: absolute; top: 8px; left: 8px;
  width: 26px; height: 26px; border-radius: 9px;
  display: grid; place-items: center; font-size: 12px;
  background: rgba(10, 6, 16, .6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.tile-cap {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 20px 9px 8px;
  font-size: 11px;
  line-height: 1.3;
  background: linear-gradient(transparent, rgba(6, 3, 10, .88));
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ── Список / строки ──────────────────────────────────────────────────────── */

.rows { display: flex; flex-direction: column; }
.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 0;
  border-bottom: 1px solid var(--stroke-soft);
  font-size: 14.5px;
}
.row:last-child { border-bottom: 0; }
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub { font-size: 12.5px; color: var(--ink-faint); margin-top: 1px; }
.row-val { font-weight: 700; font-variant-numeric: tabular-nums; flex-shrink: 0; }
.row-val.plus { color: var(--mint); }
.row-val.minus { color: var(--ink-dim); }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat {
  padding: 14px 12px;
  border-radius: var(--r-md);
  background: var(--glass);
  border: 1px solid var(--stroke-soft);
  text-align: center;
}
.stat b { display: block; font-size: 21px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.03em; }
.stat span { font-size: 11px; color: var(--ink-faint); }

.empty {
  text-align: center;
  padding: 44px 20px;
  color: var(--ink-faint);
}
.empty-icon { font-size: 44px; margin-bottom: 10px; opacity: .8; }
.empty p { font-size: 14px; }

/* ── Реферальная ссылка ───────────────────────────────────────────────────── */

.reflink {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 14px;
  border-radius: var(--r-md);
  background: rgba(10, 6, 16, .5);
  border: 1px dashed var(--stroke);
  font-size: 13px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  word-break: break-all;
}
.reflink span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Нижняя навигация ─────────────────────────────────────────────────────── */

.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 40;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  height: calc(var(--tab-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  background: rgba(10, 6, 16, .74);
  backdrop-filter: blur(26px) saturate(1.4);
  -webkit-backdrop-filter: blur(26px) saturate(1.4);
  border-top: 1px solid var(--stroke-soft);
}

.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 10px;
  font-weight: 600;
  color: var(--ink-faint);
  transition: color .2s;
  position: relative;
}
.tab i { font-style: normal; font-size: 21px; line-height: 1; transition: transform .24s var(--spring); }
.tab.on { color: var(--ink); }
.tab.on i { transform: translateY(-2px) scale(1.12); }
.tab.on::after {
  content: "";
  position: absolute; top: 6px;
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--candy); opacity: .22; filter: blur(11px);
}

/* ── Прогресс генерации ───────────────────────────────────────────────────── */

/* Плашка над навигацией. Ничего не перекрывает и не ловит нажатия: генерация
   видео идёт минутами, и запирать на это время весь экран — верный способ
   заставить человека закрыть приложение. */
.genbar {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(var(--tab-h) + var(--safe-b) + 10px);
  z-index: 45;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 15px;
  border-radius: var(--r-md);
  overflow: hidden;
  pointer-events: none;
  background: rgba(20, 12, 30, .9);
  border: 1px solid var(--stroke);
  backdrop-filter: blur(22px) saturate(1.4);
  -webkit-backdrop-filter: blur(22px) saturate(1.4);
  box-shadow: 0 12px 34px -14px rgba(0, 0, 0, .9);
  animation: genbar-in .34s var(--spring);
  max-width: 536px;
  margin: 0 auto;
}
@keyframes genbar-in {
  from { opacity: 0; transform: translateY(16px) scale(.96); }
  to   { opacity: 1; transform: none; }
}

.genbar-spin {
  width: 18px; height: 18px; flex-shrink: 0;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .14);
  border-top-color: var(--pink);
  animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.genbar-main { flex: 1; min-width: 0; display: block; }
.genbar-title {
  display: block;
  font-size: 14px; font-weight: 650;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.genbar-sub {
  display: block;
  font-size: 11.5px; color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
  margin-top: 1px;
}
.genbar-pct {
  flex-shrink: 0;
  font-size: 15px; font-weight: 750;
  font-variant-numeric: tabular-nums;
  background: var(--candy);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Полоса заполнения по нижней кромке плашки. */
.genbar-track {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 2.5px;
  background: rgba(255, 255, 255, .07);
}
.genbar-track i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--candy);
  border-radius: 0 99px 99px 0;
  transition: width .6s var(--ease);
}

/* ── Панель снизу ─────────────────────────────────────────────────────────── */

.sheet { position: fixed; inset: 0; z-index: 60; }
.sheet-backdrop {
  position: absolute; inset: 0;
  background: rgba(6, 3, 10, .6);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: fade-in .24s var(--ease);
}
.sheet-body {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  max-height: 88vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 8px 16px calc(20px + var(--safe-b));
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  background: linear-gradient(180deg, #1a1024, #0d0714);
  border-top: 1px solid var(--stroke);
  animation: sheet-up .34s var(--ease);
}
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: none; } }

.sheet-grip {
  width: 38px; height: 4px; border-radius: 99px;
  background: rgba(255, 255, 255, .2);
  margin: 6px auto 14px;
}
.sheet h3 { font-size: 19px; margin-bottom: 4px; }
.sheet .sheet-sub { color: var(--ink-dim); font-size: 14px; margin-bottom: 16px; }

/* ── Просмотр результата ──────────────────────────────────────────────────── */

.viewer { display: flex; flex-direction: column; gap: 14px; }
.viewer-media {
  position: relative;
  border-radius: var(--r-lg);
  overflow: hidden;
  background: rgba(0, 0, 0, .4);
  border: 1px solid var(--stroke-soft);
}
.viewer-media img, .viewer-media video { width: 100%; display: block; max-height: 62vh; object-fit: contain; }

/* Результат проявляется из размытия — маленькая церемония на месте, где
   человек только что потратил деньги. */
.reveal { animation: reveal 1s var(--ease) both; }
@keyframes reveal {
  from { filter: blur(26px) saturate(.5); transform: scale(1.06); opacity: .4; }
  to   { filter: none; transform: none; opacity: 1; }
}

.viewer-prompt {
  font-size: 13.5px;
  color: var(--ink-dim);
  background: var(--glass);
  border: 1px solid var(--stroke-soft);
  border-radius: var(--r-sm);
  padding: 11px 13px;
  max-height: 110px;
  overflow-y: auto;
}
.viewer-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }

/* ── Уведомление ──────────────────────────────────────────────────────────── */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tab-h) + var(--safe-b) + 18px);
  z-index: 95;
  transform: translateX(-50%);
  max-width: calc(100vw - 32px);
  padding: 12px 18px;
  border-radius: 99px;
  background: rgba(26, 16, 36, .95);
  border: 1px solid var(--stroke);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  font-size: 14px;
  font-weight: 550;
  box-shadow: 0 12px 34px -12px rgba(0, 0, 0, .8);
  animation: toast-in .3s var(--spring);
  text-align: center;
}
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 14px) scale(.94); }
  to   { opacity: 1; transform: translate(-50%, 0) scale(1); }
}
.toast.bad { border-color: rgba(255, 95, 109, .4); }

/* ── Скелетоны ────────────────────────────────────────────────────────────── */

.skel {
  border-radius: var(--r-md);
  background: linear-gradient(100deg, rgba(255,255,255,.04) 30%, rgba(255,255,255,.10) 50%, rgba(255,255,255,.04) 70%);
  background-size: 220% 100%;
  animation: shimmer 1.4s linear infinite;
}
@keyframes shimmer { to { background-position: -220% 0; } }

/* ── Мелочи ───────────────────────────────────────────────────────────────── */

.muted { color: var(--ink-dim); font-size: 13.5px; }
.tiny { font-size: 12px; color: var(--ink-faint); }
.center { text-align: center; }
.gradient-text {
  background: var(--candy);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.divider { height: 1px; background: var(--stroke-soft); margin: 4px 0; }

.notice {
  display: flex; gap: 10px;
  padding: 12px 14px;
  border-radius: var(--r-md);
  background: rgba(251, 191, 36, .09);
  border: 1px solid rgba(251, 191, 36, .22);
  font-size: 13px;
  color: #f8dfa6;
}

/* Слабые телефоны и «уменьшить движение» — гасим всё лишнее. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}

/* Светлая тема Telegram: приложение остаётся тёмным осознанно — карамельные
   градиенты на белом теряют весь объём. Подстраиваем только края. */
@media (prefers-color-scheme: light) {
  body { background: var(--bg); }
}
