/* Раздеватор — Mini App. Все стили здесь, инлайновый style только для динамических значений (прогресс-бар, высота видео и т.п.) */

:root {
  /* Переопределяются из app.js значениями Telegram.WebApp.themeParams */
  --tg-bg: #0f1115;
  --tg-text: #f2f3f5;
  --tg-hint: #8a8f98;
  --tg-link: #5b9dff;
  --tg-button: #5b6cff;
  --tg-button-text: #ffffff;
  --tg-secondary-bg: #1a1d24;

  --surface: var(--tg-secondary-bg);
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.16);
  --accent: var(--tg-button);
  --accent-text: var(--tg-button-text);
  --danger: #ff6b6b;
  --success: #45c97a;

  --radius-card: 16px;
  --radius-btn: 14px;
  --radius-chip: 999px;
  --radius-input: 14px;
  --side: 16px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);

  color-scheme: dark;
}

:root[data-theme="light"] {
  --tg-bg: #ffffff;
  --tg-text: #15171c;
  --tg-hint: #767b86;
  --tg-link: #2f6fe0;
  --tg-button: #4a63f0;
  --tg-button-text: #ffffff;
  --tg-secondary-bg: #f2f3f6;
  --border: rgba(10, 12, 20, 0.1);
  --border-strong: rgba(10, 12, 20, 0.18);
  color-scheme: light;
}

* { box-sizing: border-box; }

/* [hidden] должен побеждать display:flex/grid, заданный классами ниже —
   без этого правила флекс/грид-блоки остаются видимыми при hidden. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--tg-bg);
  color: var(--tg-text);
  font-family: -apple-system, system-ui, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

body {
  min-height: 100vh;
}

h1, h2, h3, p, ul { margin: 0; }
ul { padding: 0; list-style: none; }

button {
  font-family: inherit;
  cursor: pointer;
}

input, textarea {
  font-family: inherit;
}

a { color: var(--tg-link); }

/* ---------- Каркас приложения ---------- */

.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  padding-top: var(--safe-top);
}

.screen {
  display: none;
  flex: 1;
  flex-direction: column;
  padding: 16px var(--side) calc(96px + var(--safe-bottom));
  animation: screen-in 200ms ease both;
}

.screen.is-active { display: flex; }

@media (prefers-reduced-motion: reduce) {
  .screen { animation: none; }
}

@keyframes screen-in {
  from { opacity: 0; transform: translateX(12px); }
  to { opacity: 1; transform: translateX(0); }
}

/* Нижняя главная кнопка Telegram перекрывает контент — оставляем отступ,
   а для браузера без SDK показываем собственную кнопку-дублёр. */
.local-main-button {
  display: none;
  position: fixed;
  left: 0; right: 0; bottom: 0;
  max-width: 480px;
  margin: 0 auto;
  padding: 12px var(--side) calc(12px + var(--safe-bottom));
  background: var(--tg-bg);
  border-top: 1px solid var(--border);
  z-index: 20;
}

.local-main-button.is-visible { display: block; }

/* ---------- Типографика ---------- */

.h1 { font-size: 24px; font-weight: 700; line-height: 1.25; }
.h2 { font-size: 18px; font-weight: 700; line-height: 1.3; }
.text { font-size: 15px; line-height: 1.5; }
.text-sm { font-size: 13px; line-height: 1.4; }
.text-xs { font-size: 12px; line-height: 1.35; }
.hint { color: var(--tg-hint); }

.truncate {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* ---------- Верхняя панель ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  margin-bottom: 14px;
}

.topbar__title {
  flex: 1;
  font-size: 18px;
  font-weight: 700;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  min-width: 44px;
  border-radius: var(--radius-btn);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--tg-text);
}

.icon-btn svg { width: 20px; height: 20px; }

.lang-switch {
  min-width: 44px;
  min-height: 44px;
  padding: 0 12px;
  border-radius: var(--radius-chip);
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--tg-text);
  font-size: 13px;
  font-weight: 600;
}

.balance-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 12px;
  border-radius: var(--radius-chip);
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
  color: var(--tg-text);
  text-decoration: none;
}

.balance-chip svg { width: 15px; height: 15px; color: var(--accent); }

/* ---------- Экран 0: гейт 18+ ---------- */

.gate {
  padding-top: calc(24px + var(--safe-top));
}

.gate__top { display: flex; justify-content: flex-end; }

.gate__body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 16px;
  padding: 24px 0;
}

.gate__mark {
  width: 72px;
  height: 72px;
  border-radius: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 700;
  color: var(--accent);
}

.gate__actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.gate__legal {
  display: flex;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 18px;
  font-size: 12.5px;
}

.gate__legal a { color: var(--tg-hint); text-decoration: none; min-height: 44px; display: flex; align-items: center; }

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

.btn {
  min-height: 48px;
  border-radius: var(--radius-btn);
  border: 0;
  font-size: 15px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 16px;
  width: 100%;
}

.btn--primary { background: var(--accent); color: var(--accent-text); }
.btn--primary:disabled { opacity: 0.45; }
.btn--secondary { background: var(--surface); color: var(--tg-text); border: 1px solid var(--border-strong); font-weight: 600; }
.btn--danger { background: transparent; color: var(--danger); font-weight: 600; }
.btn--ghost { background: transparent; color: var(--tg-text); border: 1px solid var(--border-strong); font-weight: 600; }

.btn.is-loading { position: relative; color: transparent; }
.btn.is-loading::after {
  content: "";
  position: absolute;
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.35);
  border-top-color: #fff;
  animation: spin 700ms linear infinite;
}
@media (prefers-reduced-motion: reduce) {
  .btn.is-loading::after { animation: none; }
}
@keyframes spin { to { transform: rotate(360deg); } }

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

/* ---------- Главная ---------- */

.home-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 16px;
}

.home-header__user { display: flex; flex-direction: column; }
.home-header__greet { font-size: 13px; color: var(--tg-hint); }
.home-header__name { font-size: 18px; font-weight: 700; }
.home-header__controls { display: flex; gap: 8px; align-items: center; }

.active-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  margin-bottom: 14px;
  border-radius: var(--radius-card);
  background: var(--surface);
  border: 1px solid var(--border);
  text-decoration: none;
  color: var(--tg-text);
}

.active-banner svg { width: 18px; height: 18px; color: var(--accent); flex-shrink: 0; }
.active-banner__text { flex: 1; font-size: 13px; line-height: 1.3; }
.active-banner__arrow { color: var(--tg-hint); width: 16px; height: 16px; }

.hero {
  position: relative;
  border-radius: var(--radius-card);
  overflow: hidden;
  border: 1px solid var(--border);
  margin-bottom: 18px;
  height: 150px;
  display: flex;
  align-items: flex-end;
}

.hero__img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.hero__caption { position: relative; padding: 16px; font-size: 18px; font-weight: 700; color: #fff; text-shadow: 0 2px 10px rgba(0,0,0,0.5); max-width: 220px; }

.section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--tg-hint);
  margin: 4px 0 10px;
}

.tiles {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.tile {
  min-height: 92px;
  border-radius: var(--radius-card);
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 6px;
  text-decoration: none;
  color: var(--tg-text);
}

.tile svg { width: 20px; height: 20px; color: var(--accent); }
.tile__title { font-size: 14.5px; font-weight: 700; }
.tile__hint { font-size: 11.5px; color: var(--tg-hint); }

.tile.is-disabled {
  opacity: 0.55;
  border-style: dashed;
}
.tile.is-disabled svg { color: var(--tg-hint); }

.tile__badge {
  align-self: flex-start;
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-chip);
  background: rgba(255, 255, 255, 0.1);
  color: var(--tg-text);
}

.recent-list {
  display: flex;
  gap: 10px;
}

.recent-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-decoration: none;
  color: var(--tg-text);
}

.recent-card__thumb {
  aspect-ratio: 3 / 4;
  border-radius: var(--radius-card);
  background: var(--surface);
  border: 1px solid var(--border);
  overflow: hidden;
  position: relative;
}
.recent-card__thumb img { width: 100%; height: 100%; object-fit: cover; }
.recent-card__status {
  font-size: 10.5px;
  text-align: center;
  color: var(--tg-hint);
}

/* ---------- Карусель категорий ---------- */

.categories {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 12px;
  -ms-overflow-style: none;
  scrollbar-width: none;
}
.categories::-webkit-scrollbar { display: none; }

.category-chip {
  min-height: 36px;
  padding: 0 14px;
  border-radius: var(--radius-chip);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--tg-text);
  font-size: 13px;
  white-space: nowrap;
  flex-shrink: 0;
}

.category-chip.is-active {
  background: var(--accent);
  color: var(--accent-text);
  border-color: transparent;
}

/* ---------- Поиск ---------- */

.search-field {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 14px;
  border-radius: var(--radius-input);
  background: var(--surface);
  border: 1px solid var(--border);
  margin-bottom: 14px;
}
.search-field svg { width: 16px; height: 16px; color: var(--tg-hint); flex-shrink: 0; }
.search-field input {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--tg-text);
  font-size: 14.5px;
  outline: none;
  min-width: 0;
}
.search-field input::placeholder { color: var(--tg-hint); }

/* ---------- Переключатель длительности ---------- */

.segmented {
  display: flex;
  gap: 1px;
  background: var(--border);
  border-radius: var(--radius-chip);
  border: 1px solid var(--border);
  margin-bottom: 14px;
  overflow: hidden;
}
.segmented__option {
  flex: 1;
  min-height: 40px;
  border: 0;
  background: var(--tg-bg);
  color: var(--tg-text);
  font-size: 13.5px;
  font-weight: 600;
}
.segmented__option.is-active { background: var(--accent); color: var(--accent-text); }

/* ---------- Список шаблонов ----------
   По одному сценарию в строке (не сетка) — так просили на мобилках: большое превью
   во всю ширину, название подписью снизу. Пагинация по 10 штук на страницу — см.
   .template-pagination. */

.template-grid {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.template-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-decoration: none;
  color: var(--tg-text);
  border: none;
  background: none;
  padding: 0;
  text-align: left;
}

.template-card__media {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;
  border-radius: var(--radius-card);
  background: var(--surface);
  border: 1px solid var(--border);
  overflow: hidden;
}
.template-card__media img, .template-card__media video {
  width: 100%; height: 100%; object-fit: cover;
}

.template-card__no-preview {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--tg-hint);
  text-align: center;
  padding: 8px;
}
.template-card__no-preview svg { width: 28px; height: 28px; opacity: 0.6; }
.template-card__no-preview span { font-size: 12px; line-height: 1.2; }

.template-card__lock {
  position: absolute;
  top: 10px; right: 10px;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: var(--radius-chip);
  background: rgba(10, 12, 20, 0.7);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
}
.template-card__lock svg { width: 11px; height: 11px; }

/* Подпись под фото — как в соцсетях: название + цена одной строкой под картинкой. */
.template-card__body {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 2px;
}

.template-card__title {
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.template-card__price {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12.5px;
  color: var(--tg-hint);
}
.template-card__price svg { width: 12px; height: 12px; color: var(--accent); }

.template-card.is-locked { opacity: 0.7; }

/* ---------- Пагинация шаблонов ---------- */

.template-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 6px 0 2px;
}
.template-pagination__label {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--tg-hint);
  min-width: 52px;
  text-align: center;
}
.template-pagination__next svg { transform: rotate(180deg); }
.icon-btn:disabled { opacity: 0.35; }

/* ---------- Состояния: скелетон / пусто / ошибка ---------- */

.skeleton-grid {
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.skeleton-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.skeleton-row__media { width: 100%; aspect-ratio: 3 / 4; border-radius: var(--radius-card); }
.skeleton-row__lines { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 2px; }
.skeleton-row__line { height: 15px; border-radius: 6px; width: 55%; }
.skeleton-row__line--short { width: 20%; }
.skeleton-box {
  border-radius: var(--radius-card);
  background: var(--surface);
  position: relative;
  overflow: hidden;
}
.skeleton-box::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.08), transparent);
  animation: shimmer 1.4s infinite;
}
@media (prefers-reduced-motion: reduce) {
  .skeleton-box::after { animation: none; }
}
@keyframes shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }

.state-block {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 10px;
  padding: 40px 20px;
  color: var(--tg-hint);
}
.state-block svg { width: 32px; height: 32px; color: var(--tg-hint); }
.state-block__title { font-size: 15px; font-weight: 600; color: var(--tg-text); }
.state-block .btn { width: auto; margin-top: 6px; }

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

.upload-preview {
  position: relative;
  border-radius: var(--radius-card);
  background: var(--surface);
  border: 1px solid var(--border);
  overflow: hidden;
  margin-bottom: 14px;
  height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.upload-preview video, .upload-preview img { width: 100%; height: 100%; object-fit: cover; }
.upload-preview__sound-btn {
  position: absolute;
  top: 10px; right: 10px;
  min-height: 32px;
  padding: 0 12px;
  border-radius: var(--radius-chip);
  background: rgba(10,12,20,0.65);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.2);
  font-size: 12px;
}

.requirements {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 10px 0 16px;
}
.requirement {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13.5px;
}
.requirement svg { width: 16px; height: 16px; color: var(--accent); flex-shrink: 0; }

.dropzone {
  min-height: 140px;
  border-radius: var(--radius-card);
  border: 1.5px dashed var(--border-strong);
  background: var(--surface);
  color: var(--tg-text);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px;
  text-align: center;
  width: 100%;
  margin-bottom: 10px;
}
.dropzone svg { width: 26px; height: 26px; color: var(--tg-hint); }
.dropzone__hint { font-size: 11.5px; color: var(--tg-hint); }

.dropzone.has-photo {
  flex-direction: row;
  justify-content: flex-start;
  min-height: auto;
  padding: 10px;
  gap: 12px;
  text-align: left;
  border-style: solid;
}
.dropzone__thumb {
  width: 56px; height: 56px;
  border-radius: 10px;
  object-fit: cover;
  flex-shrink: 0;
}

.upload-error {
  color: var(--danger);
  font-size: 12.5px;
  margin-top: -4px;
  margin-bottom: 10px;
}

.consent-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 12.5px;
  color: var(--tg-hint);
  margin-bottom: 14px;
}
.consent-row input {
  width: 22px; height: 22px;
  margin: 0;
  accent-color: var(--accent);
  flex-shrink: 0;
}

.prompt-field {
  margin-bottom: 16px;
}
.prompt-field label {
  display: block;
  font-size: 12.5px;
  color: var(--tg-hint);
  margin-bottom: 6px;
}
.prompt-field textarea {
  width: 100%;
  min-height: 64px;
  border-radius: var(--radius-input);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--tg-text);
  padding: 10px 12px;
  font-size: 14px;
  resize: vertical;
}
.prompt-field__count {
  text-align: right;
  font-size: 11px;
  color: var(--tg-hint);
  margin-top: 4px;
}

.spacer { flex: 1; }

.balance-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 12px 14px;
  border-radius: var(--radius-card);
  background: var(--surface);
  border: 1px solid var(--border);
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--tg-hint);
}
.balance-row strong { color: var(--tg-text); font-size: 13.5px; }

/* ---------- Прогресс ---------- */

.progress-hero {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  text-align: center;
}

.progress-ring {
  position: relative;
  width: 120px; height: 120px;
}
.progress-ring svg { transform: rotate(-90deg); width: 100%; height: 100%; }
.progress-ring__bg { fill: none; stroke: var(--surface); stroke-width: 8; }
.progress-ring__value { fill: none; stroke: var(--accent); stroke-width: 8; stroke-linecap: round; transition: stroke-dashoffset 400ms ease; }
.progress-ring__label {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 700;
}
/* Собственный keyframe с явными from/to: иначе implicit from берёт базовый
   rotate(-90deg) кольца, и на стыке цикла (-90°→360°=450°) происходит рывок назад.
   Явные 0°→360° дают бесшовный плавный оборот. */
.progress-ring.is-indeterminate svg { animation: spin-ring 1s linear infinite; transform-origin: 50% 50%; }
@keyframes spin-ring { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .progress-ring.is-indeterminate svg { animation: none; }
}

.progress-steps {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  border-radius: var(--radius-card);
  background: var(--surface);
  border: 1px solid var(--border);
  margin-bottom: 14px;
}
.progress-step {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13.5px;
  color: var(--tg-hint);
}
.progress-step.is-done { text-decoration: line-through; opacity: 0.7; }
.progress-step.is-active { color: var(--tg-text); font-weight: 600; }
.progress-step .icon { color: var(--accent); flex-shrink: 0; }
.progress-step:not(.is-done):not(.is-active) .icon { color: var(--tg-hint); opacity: 0.5; }

.fail-block, .refund-block {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 12px;
  padding: 20px;
}
.fail-block svg { width: 36px; height: 36px; color: var(--danger); }

/* ---------- Результат ---------- */

.result-media {
  position: relative;
  width: 100%;
  border-radius: var(--radius-card);
  background: var(--surface);
  border: 1px solid var(--border);
  overflow: hidden;
  margin-bottom: 14px;
  aspect-ratio: 3 / 4;
}
.result-media video, .result-media img { width: 100%; height: 100%; object-fit: cover; }

.result-meta { margin-bottom: 16px; }
.result-meta__title { font-size: 16px; font-weight: 700; }
.result-meta__sub { font-size: 12.5px; color: var(--tg-hint); margin-top: 2px; }

/* ---------- Пополнение ---------- */

.balance-hero {
  text-align: center;
  padding: 18px 0 20px;
}
.balance-hero__value {
  font-size: 40px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.balance-hero__label { font-size: 13px; color: var(--tg-hint); margin-top: 4px; }

.maintenance-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-card);
  background: rgba(255, 107, 107, 0.12);
  border: 1px solid rgba(255, 107, 107, 0.3);
  color: var(--danger);
  font-size: 13px;
  margin-bottom: 14px;
}
.maintenance-banner svg { width: 18px; height: 18px; flex-shrink: 0; }

.package-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.package-card {
  position: relative;
  border-radius: var(--radius-card);
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: left;
  color: var(--tg-text);
}
.package-card.is-selected { border-color: var(--accent); }
.package-card__credits { font-size: 17px; font-weight: 700; }
.package-card__price { font-size: 13px; color: var(--tg-hint); }
.package-card__badge {
  position: absolute; top: -8px; right: 10px;
  font-size: 10.5px; font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-chip);
  background: var(--accent);
  color: var(--accent-text);
}

.checkout-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 30px 0;
  text-align: center;
}

/* ---------- Профиль ---------- */

.profile-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}
.profile-avatar {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 700;
  color: var(--accent);
  flex-shrink: 0;
}
.profile-head__name { font-size: 17px; font-weight: 700; }
.profile-head__username { font-size: 12.5px; color: var(--tg-hint); }
.profile-head__id { font-size: 11px; color: var(--tg-hint); margin-top: 2px; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}
.stat-card {
  border-radius: var(--radius-card);
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 12px 10px;
  text-align: center;
}
.stat-card__value { font-size: 17px; font-weight: 700; }
.stat-card__label { font-size: 10.5px; color: var(--tg-hint); margin-top: 2px; }

.history-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: var(--tg-text);
}
.history-row:last-child { border-bottom: none; }
.history-row__thumb {
  width: 44px; height: 44px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  object-fit: cover;
  flex-shrink: 0;
}
.history-row__title { font-size: 13.5px; font-weight: 600; }
.history-row__date { font-size: 11.5px; color: var(--tg-hint); }
.history-row__status { font-size: 11.5px; color: var(--tg-hint); margin-left: auto; white-space: nowrap; }
.history-row__status.is-done { color: var(--success); }
.history-row__status.is-refunded { color: var(--danger); }

/* ---------- Реферальная программа ---------- */

.referral-card {
  border-radius: var(--radius-card);
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 14px;
  margin-bottom: 14px;
}
.referral-link-row {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}
.referral-link-row input {
  flex: 1;
  min-height: 44px;
  border-radius: var(--radius-input);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--tg-text);
  padding: 0 12px;
  font-size: 13px;
  min-width: 0;
}
.referral-link-row .btn { width: auto; padding: 0 14px; }

/* ---------- Правила ---------- */

.legal-list { display: flex; flex-direction: column; margin-bottom: 18px; }
.legal-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
  padding: 4px 0;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: var(--tg-text);
  font-size: 14.5px;
}
.legal-link:last-child { border-bottom: none; }
.legal-link svg { width: 16px; height: 16px; color: var(--tg-hint); }

/* ---------- Toast ---------- */

#toast-root {
  position: fixed;
  left: 0; right: 0;
  bottom: calc(16px + var(--safe-bottom));
  display: flex;
  justify-content: center;
  z-index: 60;
  pointer-events: none;
}
.toast {
  max-width: calc(100% - 32px);
  padding: 12px 16px;
  border-radius: var(--radius-btn);
  background: #1c1e26;
  color: #fff;
  font-size: 13.5px;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.3);
  animation: toast-in 180ms ease both;
}
:root[data-theme="light"] .toast { background: #1f2026; }
@media (prefers-reduced-motion: reduce) { .toast { animation: none; } }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.toast--error svg { color: var(--danger); }
.toast--success svg { color: var(--success); }
.toast svg { width: 16px; height: 16px; flex-shrink: 0; }

/* ---------- Модальное окно ---------- */

#modal-root {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: none;
  align-items: flex-end;
  justify-content: center;
}
#modal-root.is-open { display: flex; }

.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.5);
}

.modal-card {
  position: relative;
  width: 100%;
  max-width: 480px;
  background: var(--tg-bg);
  border-top: 1px solid var(--border);
  border-radius: 20px 20px 0 0;
  padding: 20px var(--side) calc(20px + var(--safe-bottom));
  animation: modal-in 180ms ease both;
}
@media (prefers-reduced-motion: reduce) { .modal-card { animation: none; } }
@keyframes modal-in { from { transform: translateY(16px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.modal-card__title { font-size: 17px; font-weight: 700; margin-bottom: 8px; }
.modal-card__text { font-size: 14px; color: var(--tg-hint); margin-bottom: 18px; line-height: 1.5; }

/* ---------- Утилиты ---------- */

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- Иконки (вставляются inline из app.js, см. ICONS) ---------- */

.icon {
  display: inline-flex;
  width: 20px;
  height: 20px;
  color: var(--accent);
  flex-shrink: 0;
}
.icon svg { width: 100%; height: 100%; display: block; }
.icon-sm { width: 15px; height: 15px; }
.icon-lg { width: 32px; height: 32px; }

.icon-btn .icon,
.topbar .icon,
.legal-link .icon,
.active-banner__arrow,
.history-row .icon,
.btn .icon {
  color: inherit;
}

.state-block .icon { color: var(--tg-hint); }
.fail-block .icon, .refund-block .icon { color: var(--danger); }
.tile.is-disabled .icon { color: var(--tg-hint); }
