/* =============================================
   Sticker Studio v2 — тёплая «бумажная» тема Claude
   Дизайн-система: токены + примитивы компонентов.
   Значения — 1:1 из макета «Sticker Studio v2».
   Фиксированный бренд-тема (НЕ следует themeParams Telegram).
   ============================================= */

:root {
  /* Поверхности */
  --paper: #FAF9F5;     /* фон приложения (бумага) */
  --paper-2: #F5F3EC;   /* вторичный фон / вторичные кнопки */
  --paper-3: #F3F0E8;   /* приглушённые кружки/иконки */
  --paper-4: #FBFAF6;   /* очень светлый фон (dashed-зоны) */
  --card: #FFFFFF;      /* карточки */

  /* Границы */
  --border: #E9E5DB;
  --border-2: #E4DFD3;
  --border-3: #ECE7DC;

  /* Текст */
  --ink: #22201D;       /* основной */
  --ink-2: #3E3A33;     /* тёмно-вторичный (на кнопках) */
  --muted: #6B675E;     /* вторичный */
  --muted-2: #948E82;   /* приглушённый (лейблы) */
  --faint: #AAA296;     /* плейсхолдеры */

  /* Коралловый акцент */
  --coral: #D97757;
  --coral-grad: linear-gradient(135deg, #E28A6C 0%, #D97757 55%, #CE6A48 100%);
  --coral-grad-sm: linear-gradient(135deg, #E28A6C, #D97757 60%, #CE6A48);
  --coral-dark: #B4552F;   /* коралловый текст на светлом */
  --coral-tint: #FBEEE8;   /* коралловый фон-подложка */
  --coral-tint-2: #FBEDE9;
  --coral-tint-border: #F0D4C7;

  /* Опасность */
  --danger: #BE4327;
  --danger-tint: #FBEDE9;
  --danger-border: #E9BCAE;

  /* Подарочный градиент (бонусы/рефералы) */
  --gift-grad: linear-gradient(150deg, #FCEFE9, #F6E0D3 60%, #F3D8C8);
  --gift-grad-2: linear-gradient(135deg, #FCEFE9, #F7E1D5);

  /* Скругления */
  --r-sm: 11px;
  --r-md: 14px;
  --r-lg: 16px;
  --r-xl: 18px;
  --r-2xl: 20px;
  --r-3xl: 26px;
  --pill: 999px;

  /* Тени */
  --sh-card: 0 1px 2px rgba(40, 35, 30, .04);
  --sh-pop: 0 1px 2px rgba(40, 35, 30, .04), 0 12px 28px -20px rgba(40, 35, 30, .2);
  --sh-lift: 0 2px 4px rgba(40, 35, 30, .04), 0 16px 34px -22px rgba(40, 35, 30, .24);
  --sh-coral: 0 12px 24px -10px rgba(217, 119, 87, .8);
  --sh-coral-sm: 0 8px 16px -8px rgba(217, 119, 87, .7);
  --sh-gift: 0 14px 30px -20px rgba(217, 119, 87, .5);

  /* Шрифты */
  --font-head: 'Fraunces', Georgia, 'Times New Roman', serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  --tabbar-h: 76px;   /* высота плавающего таб-бара + отступ */
}

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

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior: none;
}

body { overflow: hidden; }

.hidden { display: none !important; }

::-webkit-scrollbar { width: 0; height: 0; }
.scroll-y { overflow-y: auto; -webkit-overflow-scrolling: touch; }
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.scroll-x::-webkit-scrollbar, .scroll-y::-webkit-scrollbar { width: 0; height: 0; }

input, textarea, button { font-family: inherit; }
input::placeholder, textarea::placeholder { color: var(--faint); opacity: 1; }

/* ---------- Шахматка прозрачности (превью стикеров) ---------- */
.checker {
  background-color: #FBFAF7;
  background-image:
    linear-gradient(45deg, #EAE5DA 25%, transparent 25%),
    linear-gradient(-45deg, #EAE5DA 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #EAE5DA 75%),
    linear-gradient(-45deg, transparent 75%, #EAE5DA 75%);
  background-size: 12px 12px;
  background-position: 0 0, 0 6px, 6px -6px, -6px 0;
}

/* ---------- Анимации ---------- */
@keyframes ss-spin { to { transform: rotate(360deg); } }
@keyframes ss-sheet { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes ss-scrim { from { opacity: 0; } to { opacity: 1; } }
@keyframes ss-toast { from { transform: translateY(16px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes ss-drop { from { transform: translateY(-14px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes ss-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes ss-pop { from { opacity: 0; transform: scale(.94); } to { opacity: 1; transform: scale(1); } }

/* =============================================
   Полноэкранные состояния (загрузка / ошибка)
   ============================================= */
.fullscreen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0 44px;
  z-index: 100;
  background: var(--paper);
}

.orb {
  width: 64px;
  height: 64px;
  border-radius: 20px;
  background: var(--coral-grad);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 14px 30px -8px rgba(217, 119, 87, .6);
  color: #fff;
  flex-shrink: 0;
}
.orb.sm { width: 34px; height: 34px; border-radius: 11px; box-shadow: 0 5px 12px -4px rgba(217, 119, 87, .65); }
.orb.xs { width: 30px; height: 30px; border-radius: 9px; box-shadow: 0 4px 10px -3px rgba(217, 119, 87, .6); }

.loader-title { font: 600 22px var(--font-head); margin-top: 22px; }
.loader-row { display: flex; align-items: center; gap: 11px; margin-top: 22px; color: var(--muted); }
.spinner {
  width: 18px; height: 18px;
  border-radius: var(--pill);
  border: 2.5px solid #EBD6CB;
  border-top-color: var(--coral);
  animation: ss-spin .8s linear infinite;
  flex-shrink: 0;
}
.spinner.lg { width: 58px; height: 58px; border-width: 4px; border-color: #F0DACE; border-top-color: var(--coral); }

.err-circle {
  width: 72px; height: 72px;
  border-radius: var(--pill);
  background: var(--paper-3);
  display: flex; align-items: center; justify-content: center;
  color: #8A857A;
}
.err-title { font: 600 21px var(--font-head); margin-top: 22px; }
.err-text { font: 400 14.5px var(--font-body); color: var(--muted); margin-top: 9px; line-height: 1.5; }

/* =============================================
   Каркас приложения
   ============================================= */
#app { display: flex; flex-direction: column; height: 100dvh; height: 100vh; position: relative; }

/* ---------- Топбар ---------- */
#topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 18px 12px;
  padding-top: calc(8px + env(safe-area-inset-top, 0px));
  flex-shrink: 0;
  z-index: 15;
}
.topbar-left { display: flex; align-items: center; gap: 11px; min-width: 0; }
.topbar-title {
  font: 600 17px var(--font-head);
  letter-spacing: .01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.icon-btn {
  width: 34px; height: 34px;
  border-radius: var(--r-sm);
  background: var(--paper-3);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--ink-2);
  flex-shrink: 0;
}
.icon-btn:active { transform: scale(.93); }

.balance-chip {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 12px 7px 10px;
  border-radius: var(--pill);
  background: var(--paper-2);
  border: 1px solid var(--border);
  cursor: pointer; color: var(--muted);
  flex-shrink: 0;
  font: 600 13px var(--font-body);
}
.balance-chip:active { transform: scale(.95); }

/* ---------- Область экрана ---------- */
#screen {
  flex: 1;
  position: relative;
  overflow: hidden;
}
.screen-scroll {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.screen-scroll::-webkit-scrollbar { width: 0; height: 0; }
/* внутренний паддинг экранов + место под таб-бар */
.pad { padding: 2px 18px 122px; }
.pad-tab { padding-bottom: calc(122px + env(safe-area-inset-bottom, 0px)); }

.screen-title { font: 600 27px var(--font-head); margin: 6px 0 4px; }
.screen-sub { font: 400 13.5px var(--font-body); color: var(--muted); margin-bottom: 18px; }
.section-label { font: 600 13px var(--font-body); color: var(--muted); margin: 2px 0 10px; }
.section-label.caps { letter-spacing: .1em; text-transform: uppercase; color: var(--muted-2); font-size: 12px; }

.panel-in { animation: ss-fade .32s cubic-bezier(.2, .9, .3, 1); }

/* ---------- Таб-бар (плавающий) ---------- */
#tabbar {
  position: absolute;
  left: 16px; right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  display: flex;
  gap: 2px;
  background: var(--card);
  border: 1px solid #EBE7DD;
  border-radius: var(--r-3xl);
  padding: 9px 6px;
  box-shadow: 0 12px 34px -12px rgba(40, 35, 30, .28);
  z-index: 20;
}
.tab-btn {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 5px 2px;
  border: none; background: transparent;
  cursor: pointer;
  color: var(--muted-2);
  font: 500 11px var(--font-body);
}
.tab-btn .tab-label { color: var(--muted-2); transition: color .18s ease; }
.tab-btn.active { color: var(--coral); }
.tab-btn.active .tab-label { color: var(--coral); font-weight: 600; }
.tab-btn:active { transform: scale(.94); }

/* =============================================
   Кнопки
   ============================================= */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 9px;
  width: 100%;
  padding: 15px 20px;
  border: none;
  border-radius: var(--r-lg);
  font: 600 15.5px var(--font-body);
  cursor: pointer;
  text-align: center;
  transition: transform .14s ease, box-shadow .2s ease, opacity .2s ease;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .55; cursor: default; transform: none; }

.btn-primary { background: var(--coral-grad); color: #fff; box-shadow: var(--sh-coral); }
.btn-primary.lg { padding: 17px 20px; border-radius: var(--r-xl); font-size: 16.5px; box-shadow: 0 14px 28px -12px rgba(217, 119, 87, .8); }

.btn-secondary {
  background: var(--paper-2);
  color: var(--ink-2);
  border: 1.5px solid var(--border);
}
.btn-secondary:active { background: #EFEBE1; }

.btn-danger {
  background: var(--danger-tint);
  color: var(--danger);
  border: 1.5px solid var(--danger-border);
}

.btn-ghost { background: transparent; color: var(--muted); border: none; }
.btn-outline-coral { background: var(--card); color: var(--coral-dark); border: 1.5px solid var(--coral-tint-border); }

.btn-row { display: flex; gap: 10px; }
.btn-row .btn { flex: 1; }

.btn-sub { text-align: center; font: 400 12px var(--font-body); color: var(--muted-2); margin-top: 9px; }

/* =============================================
   Карточки и строки
   ============================================= */
.card {
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: var(--r-xl);
  padding: 16px;
  box-shadow: var(--sh-card);
}

.icon-box {
  display: flex; align-items: center; justify-content: center;
  border-radius: 12px;
  background: var(--coral-tint);
  color: var(--coral);
  flex-shrink: 0;
}

.chevron { color: #C3BCAF; flex-shrink: 0; }

/* Строка-кнопка действия (Конструктор / списки) */
.action-btn {
  display: flex; align-items: center; gap: 14px;
  width: 100%; text-align: left;
  padding: 14px 15px;
  border-radius: var(--r-lg);
  background: var(--card);
  border: 1.5px solid var(--border);
  box-shadow: 0 1px 2px rgba(40, 35, 30, .03);
  cursor: pointer;
}
.action-btn:active { transform: scale(.99); background: var(--paper-4); }
.action-btn.dashed {
  background: var(--paper-4);
  border: 1.5px dashed #DFD8CB;
  box-shadow: none;
  gap: 13px;
  padding: 13px 15px;
}
.action-btn .ab-title { font: 600 15px var(--font-body); }
.action-btn .ab-desc { font: 400 12.5px var(--font-body); color: var(--muted); margin-top: 2px; }
.action-btn .icon-box { width: 42px; height: 42px; }

/* =============================================
   Поля ввода
   ============================================= */
textarea, input[type="text"], input[type="url"], input.field {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  background: var(--card);
  color: var(--ink);
  font: 400 15px var(--font-body);
  padding: 13px 15px;
  outline: none;
  resize: none;
  box-shadow: var(--sh-card);
  transition: border-color .18s ease;
}
textarea { min-height: 104px; border-radius: var(--r-lg); line-height: 1.45; padding: 15px; }
textarea:focus, input[type="text"]:focus, input[type="url"]:focus, input.field:focus { border-color: var(--coral); }
.field-soft { background: var(--paper-4); }

/* =============================================
   Сегментированный переключатель
   ============================================= */
.segmented {
  display: flex; gap: 4px;
  padding: 4px;
  background: #F0EDE4;
  border-radius: var(--r-md);
}
.seg-btn {
  flex: 1;
  display: flex; align-items: center; justify-content: center; gap: 7px;
  padding: 11px;
  border: none; border-radius: var(--r-sm);
  cursor: pointer;
  font: 600 14px var(--font-body);
  color: var(--muted);
  background: transparent;
  transition: background .18s ease, color .18s ease, box-shadow .18s ease;
}
.seg-btn.active { background: var(--card); color: var(--ink); box-shadow: 0 2px 6px rgba(40, 35, 30, .1); }

/* =============================================
   Чипы стилей
   ============================================= */
.chip {
  flex: 0 0 auto;
  padding: 9px 15px;
  border-radius: var(--pill);
  font: 500 13.5px var(--font-body);
  cursor: pointer;
  background: var(--card);
  color: #4A463E;
  border: 1.5px solid var(--border);
  white-space: nowrap;
}
.chip:active { transform: scale(.95); }
.chip.active { background: var(--coral); color: #fff; border-color: var(--coral); }

/* =============================================
   Выбор модели (радио)
   ============================================= */
.model-opt {
  display: flex; align-items: center; gap: 12px;
  width: 100%; text-align: left;
  padding: 13px 14px;
  border-radius: var(--r-md);
  cursor: pointer;
  background: var(--card);
  border: 1.5px solid var(--border);
}
.model-opt.active { background: var(--coral-tint); border-color: var(--coral); }
.model-radio {
  width: 18px; height: 18px; border-radius: var(--pill);
  flex-shrink: 0;
  background: var(--card);
  border: 2px solid #D8D3C8;
  box-shadow: inset 0 0 0 3px #fff;
}
.model-opt.active .model-radio { background: var(--coral); border-color: var(--coral); }
.model-name { font: 600 14.5px var(--font-body); }
.model-desc { font: 400 12px var(--font-body); color: var(--muted); margin-top: 1px; }
.model-cost { flex-shrink: 0; font: 500 12.5px var(--font-body); color: var(--muted-2); }

/* =============================================
   Сетка стикеров
   ============================================= */
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }

.sticker-cell {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--r-md);
  border: 1.5px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.sticker-cell.drag { cursor: grab; }
.sticker-cell.dragging { opacity: .4; }
.sticker-cell .face { font-size: 32px; line-height: 1; pointer-events: none; }
.sticker-cell img { width: 100%; height: 100%; object-fit: contain; padding: 8px; pointer-events: none; }
.sticker-cell .drag-dots { position: absolute; top: 3px; left: 3px; color: #C3BCAF; pointer-events: none; }
.sticker-cell .cell-tag {
  position: absolute; bottom: 3px; right: 3px;
  font-size: 11px;
  background: #fff; border-radius: 6px; padding: 1px 3px;
  box-shadow: 0 1px 2px rgba(40, 35, 30, .12);
  pointer-events: none;
}
/* Бейдж формата: движущийся стикер (video/animated) — статичное превью его не выдаёт */
.fmt-badge {
  position: absolute; bottom: 3px; left: 3px;
  min-width: 15px; height: 15px; padding: 0 3px;
  display: flex; align-items: center; justify-content: center;
  font: 700 9px/1 var(--font-body);
  color: #fff; background: var(--coral); border-radius: 5px;
  box-shadow: 0 1px 2px rgba(40, 35, 30, .18);
  pointer-events: none;
}

/* Пустая зона добавления */
.dropzone {
  border: 2px dashed #DFD8CB;
  border-radius: var(--r-xl);
  padding: 34px 20px;
  text-align: center;
  background: var(--paper-4);
  font: 500 14px var(--font-body);
  color: var(--muted-2);
}

/* Загрузка фото (AI) */
.photo-drop {
  width: 100%;
  display: flex; flex-direction: column; align-items: center; gap: 11px;
  padding: 26px;
  border: 2px dashed #D9D3C6;
  border-radius: var(--r-xl);
  background: var(--paper-4);
  color: var(--muted);
  font: 500 14px var(--font-body);
  cursor: pointer;
  overflow: hidden;
  position: relative;
}
.photo-drop:active { border-color: var(--coral); }
.photo-drop img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }

/* Результат генерации */
.result-frame {
  width: 212px; height: 212px;
  margin: 0 auto;
  border-radius: var(--r-3xl);
  overflow: hidden;
  border: 1.5px solid var(--border);
  box-shadow: 0 16px 36px -16px rgba(40, 35, 30, .22);
  display: flex; align-items: center; justify-content: center;
}
.result-frame img { width: 100%; height: 100%; object-fit: contain; }
.result-frame .face { font-size: 120px; line-height: 1; filter: drop-shadow(0 10px 16px rgba(40, 35, 30, .2)); }

/* =============================================
   Баннеры и подарочные карточки
   ============================================= */
.free-banner {
  display: flex; align-items: center; gap: 11px;
  padding: 12px 14px;
  border-radius: var(--r-md);
  background: var(--coral-tint);
  border: 1px solid var(--coral-tint-border);
  font: 500 14px var(--font-body);
  color: var(--coral-dark);
}

.gift-card {
  display: flex; align-items: center; gap: 14px;
  padding: 18px;
  border-radius: var(--r-2xl);
  background: var(--gift-grad);
  border: 1px solid var(--coral-tint-border);
  box-shadow: var(--sh-gift);
}
.gift-emoji { font-size: 30px; line-height: 1; flex-shrink: 0; }
.gift-title { font: 600 17px var(--font-head); color: var(--ink); }
.gift-desc { font: 400 13px var(--font-body); color: #7A756B; margin-top: 2px; }

/* Строка «Ежедневный бонус» на «Мои паки» */
.daily-banner {
  display: flex; align-items: center; gap: 12px;
  width: 100%; text-align: left;
  padding: 13px 15px;
  border-radius: var(--r-lg);
  background: var(--gift-grad-2);
  border: 1px solid var(--coral-tint-border);
  cursor: pointer;
}
.daily-banner .db-title { font: 600 14.5px var(--font-body); color: var(--ink); }
.daily-banner .db-desc { font: 400 12.5px var(--font-body); color: var(--coral-dark); margin-top: 2px; }
.daily-banner .db-cta {
  padding: 7px 14px; border-radius: var(--pill);
  background: var(--coral); color: #fff;
  font: 600 12.5px var(--font-body); flex-shrink: 0;
}

/* =============================================
   Пакеты (Баланс)
   ============================================= */
.package-card {
  position: relative;
  display: flex; align-items: center; gap: 14px;
  padding: 16px;
  border-radius: var(--r-xl);
  background: var(--card);
  border: 1.5px solid var(--border);
  box-shadow: var(--sh-card);
}
.package-card.popular { background: var(--coral-tint); border-color: var(--coral); }
.badge-popular {
  position: absolute; top: -10px; left: 16px;
  padding: 3px 11px; border-radius: var(--pill);
  background: var(--coral); color: #fff;
  font: 600 10.5px var(--font-body); letter-spacing: .03em;
  box-shadow: 0 4px 10px -3px rgba(217, 119, 87, .6);
}
.package-gens { font: 600 17px var(--font-head); }
.package-credits { font: 400 12px var(--font-body); color: var(--muted); margin-top: 1px; }
.package-buy {
  display: flex; align-items: center; gap: 6px;
  padding: 11px 16px;
  border: none; border-radius: 13px;
  background: var(--coral-grad-sm); color: #fff;
  font: 600 14px var(--font-body);
  box-shadow: var(--sh-coral-sm);
  cursor: pointer; flex-shrink: 0;
}
.package-buy:active { transform: scale(.95); }

/* =============================================
   Списки паков
   ============================================= */
.pack-card {
  display: flex; align-items: center; gap: 14px;
  width: 100%; text-align: left;
  padding: 14px;
  border-radius: var(--r-xl);
  cursor: pointer;
  background: var(--card);
  border: 1.5px solid var(--border);
  box-shadow: var(--sh-pop);
}
.pack-card:active { transform: scale(.99); }
.pack-cover {
  width: 50px; height: 50px;
  border-radius: var(--r-md);
  background: var(--paper-2);
  border: 1px solid var(--border-3);
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; flex-shrink: 0;
}
.pack-name { font: 600 15.5px var(--font-body); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pack-meta { display: flex; align-items: center; gap: 9px; margin-top: 5px; flex-wrap: wrap; }
.type-badge {
  padding: 2px 9px; border-radius: var(--pill);
  background: #F0EDE4; color: var(--muted);
  font: 600 11px var(--font-body);
}
.pack-count { font: 400 12.5px var(--font-body); color: var(--muted); }
.pack-installs { font: 600 11.5px var(--font-body); color: var(--coral-dark); }

/* Пустое состояние */
.empty-state { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 40px 26px 0; }
.empty-icon {
  width: 72px; height: 72px; border-radius: var(--r-2xl);
  background: var(--paper-3);
  display: flex; align-items: center; justify-content: center;
  color: #B0A99B;
}
.empty-title { font: 600 19px var(--font-head); margin-top: 20px; }
.empty-text { font: 400 14px var(--font-body); color: var(--muted); margin-top: 9px; line-height: 1.5; }

/* =============================================
   Успех (пак готов)
   ============================================= */
.success-check {
  width: 74px; height: 74px; border-radius: var(--pill);
  background: var(--coral-tint);
  display: flex; align-items: center; justify-content: center;
  margin: 8px auto 0; color: var(--coral);
}
.success-title { font: 600 26px var(--font-head); margin-top: 18px; text-align: center; }

/* =============================================
   Рефералы
   ============================================= */
.ref-toggle {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%;
  padding: 13px 15px;
  border-radius: var(--r-md);
  background: var(--card);
  border: 1.5px solid var(--border);
  cursor: pointer;
  font: 600 13.5px var(--font-body); color: var(--ink-2);
}
.ref-level {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  border-radius: 13px;
  background: var(--paper-4);
  border: 1px solid var(--border-3);
}
.ref-level .lv-num {
  width: 26px; height: 26px; border-radius: var(--pill);
  background: var(--coral-tint); color: var(--coral-dark);
  display: flex; align-items: center; justify-content: center;
  font: 600 12px var(--font-body); flex-shrink: 0;
}
.ref-level .lv-reward { font: 500 13.5px var(--font-body); color: var(--ink-2); }

.ref-link {
  flex: 1; min-width: 0;
  display: flex; align-items: center;
  padding: 0 14px;
  border-radius: var(--r-md);
  background: var(--paper-2);
  border: 1.5px solid var(--border);
  font: 500 13.5px var(--font-body); color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.progress-track { height: 10px; border-radius: var(--pill); background: #F0EDE4; overflow: hidden; }
.progress-fill { height: 100%; border-radius: var(--pill); background: linear-gradient(90deg, #E28A6C, #D97757); }

.leader-row {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px;
  border-radius: 13px;
  background: var(--card);
  border: 1.5px solid var(--border);
}
.leader-row.you { background: var(--coral-tint); border-color: var(--coral-tint-border); }
.medal {
  width: 24px; height: 24px; border-radius: var(--pill);
  display: flex; align-items: center; justify-content: center;
  font: 700 12px var(--font-body); flex-shrink: 0;
}

/* =============================================
   Онбординг
   ============================================= */
.ob-logo { display: flex; align-items: center; gap: 9px; margin-bottom: 36px; }
.ob-logo-name { font: 600 15px var(--font-head); }
.ob-title { font: 600 34px/1.12 var(--font-head); margin: 0 0 14px; letter-spacing: -.01em; }
.ob-sub { font: 400 16px/1.55 var(--font-body); color: var(--muted); margin: 0 0 28px; }
.ob-proof { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 16px; }
.ob-proof span { font: 500 13px var(--font-body); color: var(--muted-2); }

.preview-row { display: flex; gap: 12px; overflow-x: auto; margin: 0 -24px; padding: 2px 24px 6px; }
.preview-card {
  flex: 0 0 auto; width: 148px;
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: var(--r-xl);
  padding: 14px;
  box-shadow: 0 1px 2px rgba(40, 35, 30, .04), 0 14px 30px -22px rgba(40, 35, 30, .22);
}
.preview-cover {
  width: 100%; height: 96px;
  border-radius: 13px;
  display: flex; align-items: center; justify-content: center;
  font-size: 52px; margin-bottom: 12px;
}
.preview-name { font: 600 14.5px var(--font-body); }
.preview-meta { display: flex; align-items: center; gap: 6px; margin-top: 5px; }
.preview-count { font: 400 12px var(--font-body); color: var(--muted); }
.preview-dot { width: 3px; height: 3px; border-radius: var(--pill); background: #CDC7BA; }
.preview-installs { font: 600 12px var(--font-body); color: var(--coral-dark); }

/* =============================================
   Нижний лист (sheet)
   ============================================= */
#sheet-scrim {
  position: absolute; inset: 0;
  z-index: 50;
  display: flex; flex-direction: column; justify-content: flex-end;
  background: rgba(34, 32, 29, .4);
  animation: ss-scrim .2s ease-out;
}
.sheet {
  background: var(--card);
  border-radius: 28px 28px 0 0;
  padding: 20px 20px calc(26px + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -12px 42px -12px rgba(40, 35, 30, .3);
  animation: ss-sheet .3s cubic-bezier(.2, .9, .3, 1);
  max-height: 90%;
  overflow-y: auto;
}
.sheet::-webkit-scrollbar { width: 0; }
.sheet-handle { width: 40px; height: 4px; border-radius: var(--pill); background: #E3DED3; margin: 0 auto 18px; }
.sheet-title { font: 600 21px var(--font-head); margin-bottom: 3px; }
.sheet-title.mb { margin-bottom: 16px; }
.sheet-sub { font: 400 13.5px var(--font-body); color: var(--muted); margin-bottom: 16px; }

/* Липкий футер листа: кнопка действия всегда снизу экрана, поверх скролла
   (лист .sheet — скролл-контейнер с нижним padding P = 26px + safe-area).
   Отрицательные bottom/margin «сажают» футер вплотную к низу и накрывают P. */
.sheet-footer {
  position: sticky;
  bottom: calc(-26px - env(safe-area-inset-bottom, 0px));
  z-index: 2;
  margin: 0 -20px calc(-26px - env(safe-area-inset-bottom, 0px));
  padding: 14px 20px calc(26px + env(safe-area-inset-bottom, 0px));
  background: var(--card);
}
.sheet-footer::before {
  content: '';
  position: absolute;
  left: 0; right: 0; top: -22px; height: 22px;
  background: linear-gradient(to top, var(--card), transparent);
  pointer-events: none;
}

/* Пикеры эмодзи */
.emoji-grid { display: flex; gap: 7px; flex-wrap: wrap; }
.emoji-btn {
  width: 44px; height: 44px;
  border-radius: 12px;
  font-size: 23px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  background: var(--paper-2);
  border: 1.5px solid var(--border);
}
.emoji-btn.sm { width: 40px; height: 40px; border-radius: var(--r-sm); font-size: 20px; }
.emoji-btn.active { background: var(--coral-tint); border-color: var(--coral); }

/* Ячейка выбора чужого стикера */
.pick-cell {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--r-md);
  border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; padding: 0;
}
.pick-cell.sel { border-color: var(--coral); }
.pick-cell .face { font-size: 30px; line-height: 1; }
.pick-check {
  position: absolute; top: 4px; right: 4px;
  width: 19px; height: 19px; border-radius: var(--pill);
  background: var(--card); border: 1.5px solid #D8D3C8;
  display: flex; align-items: center; justify-content: center;
}
.pick-cell.sel .pick-check { background: var(--coral); border-color: var(--coral); }

/* Превью стикера в листе редактирования */
.sheet-preview {
  width: 120px; height: 120px; margin: 0 auto;
  border-radius: var(--r-2xl);
  border: 1.5px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 66px;
}
.sheet-preview img { width: 100%; height: 100%; object-fit: contain; padding: 10px; }

/* =============================================
   Уведомление (соц-доказ)
   ============================================= */
#notif {
  position: absolute; top: 12px; left: 14px; right: 14px;
  z-index: 45;
  animation: ss-drop .35s cubic-bezier(.2, .9, .3, 1);
}
.notif-card {
  display: flex; align-items: center; gap: 11px;
  padding: 12px 14px;
  border-radius: var(--r-lg);
  background: var(--card);
  border: 1px solid var(--coral-tint-border);
  box-shadow: 0 14px 34px -12px rgba(40, 35, 30, .34);
}
.notif-text { flex: 1; min-width: 0; font: 600 13.5px var(--font-body); color: var(--ink); }
.notif-close {
  width: 26px; height: 26px; border-radius: var(--pill);
  background: var(--paper-3); border: none;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--muted-2); flex-shrink: 0;
}

/* =============================================
   Тосты
   ============================================= */
#toast-wrap {
  position: absolute; left: 0; right: 0;
  bottom: calc(106px + env(safe-area-inset-bottom, 0px));
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  z-index: 60; pointer-events: none; padding: 0 20px;
}
.toast {
  display: flex; align-items: center; gap: 9px;
  padding: 12px 18px;
  border-radius: var(--pill);
  background: #26231F; color: #fff;
  box-shadow: 0 12px 30px -8px rgba(40, 35, 30, .4);
  animation: ss-toast .3s cubic-bezier(.2, .9, .3, 1);
  max-width: 100%;
  font: 600 13.5px var(--font-body);
}
.toast .toast-msg { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.toast.error { background: #B23A22; }

/* Ненавязчивый баннер фонового добавления стикеров (не блокирует UI) */
#add-banner {
  position: absolute; left: 50%; bottom: calc(106px + env(safe-area-inset-bottom, 0px));
  display: flex; align-items: center; gap: 9px;
  padding: 11px 18px; border-radius: var(--pill);
  background: var(--card); border: 1.5px solid var(--border);
  box-shadow: 0 10px 28px -10px rgba(40, 35, 30, .32);
  font: 600 13.5px var(--font-body); color: var(--ink);
  z-index: 40; pointer-events: none; white-space: nowrap;
  opacity: 0; transform: translateX(-50%) translateY(8px);
  transition: opacity .2s ease-out, transform .2s ease-out;
}
#add-banner.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.spinner.sm { width: 15px; height: 15px; border-width: 2px; }
.cell-pop { animation: ss-pop .28s cubic-bezier(.2, .9, .3, 1); }
@keyframes ss-pop { from { opacity: 0; transform: scale(.6); } to { opacity: 1; transform: none; } }

/* Утилиты */
.row { display: flex; align-items: center; }
.col { display: flex; flex-direction: column; }
.grow { flex: 1; min-width: 0; }
.gap-8 { gap: 8px; } .gap-10 { gap: 10px; } .gap-12 { gap: 12px; }
.mt-10 { margin-top: 10px; } .mt-14 { margin-top: 14px; } .mt-16 { margin-top: 16px; } .mt-22 { margin-top: 22px; }
.mb-14 { margin-bottom: 14px; } .mb-16 { margin-bottom: 16px; } .mb-18 { margin-bottom: 18px; } .mb-20 { margin-bottom: 20px; } .mb-22 { margin-bottom: 22px; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.center { text-align: center; }
