/* ============================================
   AVALAVA — общие стили
   ============================================ */

/* ============ ПАЛИТРА ============ */
:root {
  /* Бренд (одинаков в обеих темах) */
  --brand-amber-400: #FBBF24;
  --brand-orange-500: #FB923C;
  --brand-orange-600: #F97316;
  --brand-coral-500: #FF7A59;
  --brand-pink-500:  #EC4899;
  --brand-purple-400: #C084FC;
  --brand-purple-500: #A855F7;
  --brand-purple-700: #7E22CE;
  --brand-violet-500: #7C3AED;

  --brand-gradient-cta: linear-gradient(135deg, #FCD34D 0%, #F59E0B 50%, #F97316 100%);
  --brand-gradient-hot: linear-gradient(135deg, #FB923C 0%, #FF7A59 100%);
  --brand-gradient-purple: linear-gradient(135deg, #A855F7 0%, #7E22CE 100%);
  --energy-gradient: linear-gradient(135deg, #FBBF24 0%, #F97316 100%);
  --badge-popular: linear-gradient(135deg, #FBBF24 0%, #FB923C 100%);
  --badge-new: linear-gradient(135deg, #FB923C 0%, #EC4899 100%);

  /* Светлая тема (по умолчанию) */
  --bg-primary: #FAFAFA;
  --bg-card: #FFFFFF;
  --bg-card-hover: #F9F5FF;
  --bg-elevated: #FFFFFF;
  --bg-input: #FFFFFF;
  --bg-chip: #F4F4F5;
  --bg-chip-active: #FFFFFF;
  --bg-hero: linear-gradient(135deg, #FAF5FF 0%, #F3E8FF 100%);

  --text-primary: #0F0F14;
  --text-secondary: #52525B;
  --text-tertiary: #71717A;
  --text-disabled: #A1A1AA;

  --border-default: #E4E4E7;
  --border-subtle: #F4F4F5;

  --shadow-card: 0 4px 12px rgba(0, 0, 0, 0.05), 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-cta: 0 8px 20px rgba(249, 115, 22, 0.35);
  --shadow-accent: 0 4px 12px rgba(168, 85, 247, 0.2);
  --shadow-nav: 0 -4px 20px rgba(0, 0, 0, 0.06);

  --icon-default: #71717A;
  --icon-muted: #A1A1AA;
}

/* Тёмная тема */
:root.dark {
  --bg-primary: #0A0A0F;
  --bg-card: #18181F;
  --bg-card-hover: #232330;
  --bg-elevated: #1F1F28;
  --bg-input: rgba(255, 255, 255, 0.06);
  --bg-chip: rgba(255, 255, 255, 0.06);
  --bg-chip-active: rgba(255, 255, 255, 0.12);
  --bg-hero: radial-gradient(circle at 30% 20%, rgba(168, 85, 247, 0.3) 0%, transparent 60%), #0A0A0F;

  --text-primary: #FFFFFF;
  --text-secondary: rgba(255, 255, 255, 0.7);
  --text-tertiary: rgba(255, 255, 255, 0.5);
  --text-disabled: rgba(255, 255, 255, 0.3);

  --border-default: rgba(255, 255, 255, 0.08);
  --border-subtle: rgba(255, 255, 255, 0.04);

  --shadow-card: 0 0 0 1px rgba(255, 255, 255, 0.04);
  --shadow-cta: 0 0 30px rgba(249, 115, 22, 0.4);
  --shadow-accent: 0 0 24px rgba(168, 85, 247, 0.3);
  --shadow-nav: 0 -4px 20px rgba(0, 0, 0, 0.4);

  --icon-default: rgba(255, 255, 255, 0.7);
  --icon-muted: rgba(255, 255, 255, 0.4);
}

/* ============ БАЗА ============ */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  transition: background 0.3s, color 0.3s;
  min-height: 100vh;
  padding-bottom: calc(80px + env(safe-area-inset-bottom));
}
@media (min-width: 769px) {
  body { padding-bottom: 60px; }
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
}
@media (min-width: 769px) {
  .container { padding: 0 24px; }
}

/* Утилиты видимости — больше не нужны для шапок (рендерится одна через JS),
   но могут пригодиться для других элементов */
.hide-mobile { display: none; }
.hide-desktop { display: block; }
@media (min-width: 769px) {
  .hide-mobile { display: revert; }
  .hide-desktop { display: none; }
}

/* ============ ДЕСКТОПНАЯ ШАПКА ============ */
.header-desktop {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-default);
  padding: 14px 0;
}
.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
@media (min-width: 1100px) {
  .header-inner { gap: 24px; padding: 0 24px; }
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 22px;
  letter-spacing: -0.02em;
}
.brand-mark { width: 32px; height: 32px; flex-shrink: 0; }

.header-nav {
  display: flex;
  align-items: center;
  gap: 4px;
}
.nav-link {
  padding: 8px 10px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: 10px;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
@media (min-width: 1100px) {
  .nav-link { padding: 8px 16px; font-size: 15px; gap: 8px; }
}
.nav-link:hover { background: var(--bg-chip); color: var(--text-primary); }
.nav-link.active { background: var(--bg-chip-active); color: var(--text-primary); font-weight: 600; }
.nav-link svg { width: 18px; height: 18px; }

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
@media (min-width: 1100px) {
  .header-right { gap: 10px; }
}

@media (min-width: 769px) and (max-width: 1099px) {
  .header-inner .btn { padding: 9px 14px; font-size: 13px; }
  .btn-buy { font-size: 11px; padding: 6px 10px; }
}

/* Шапка не должна вызывать горизонтальный скролл */
.header-desktop { overflow: hidden; }

/* ============ MASONRY СЕТКА ============ */
.masonry-grid {
  columns: 2;
  column-gap: 10px;
  margin-top: 4px;
}
@media (min-width: 769px) {
  .masonry-grid {
    columns: 4;
    column-gap: 14px;
  }
}
.masonry-item {
  break-inside: avoid;
  margin-bottom: 10px;
  border-radius: 16px;
  overflow: hidden;
  position: relative;
  background: var(--bg-card);
  cursor: pointer;
  display: block;
  transition: transform 0.2s;
}
.masonry-item:hover { transform: translateY(-3px); }
.masonry-thumb {
  width: 100%;
  display: block;
  background-size: cover;
  background-position: center;
  position: relative;
}
.masonry-thumb::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.82) 0%, rgba(0,0,0,0) 48%);
}
.masonry-badges {
  position: absolute;
  top: 8px;
  left: 8px;
  right: 8px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  z-index: 2;
}
.masonry-name {
  position: absolute;
  bottom: 10px;
  left: 10px;
  right: 10px;
  z-index: 2;
  color: white;
  font-weight: 800;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  line-height: 1.25;
  text-shadow: 0 1px 6px rgba(0,0,0,0.6);
}
@media (min-width: 769px) {
  .masonry-item { margin-bottom: 14px; }
  .masonry-name { font-size: 13px; bottom: 12px; left: 12px; right: 12px; }
}

/* peek-wrapper — обрезает сетку и добавляет fade */
.masonry-peek {
  position: relative;
  max-height: 500px;
  overflow: hidden;
  transition: max-height 0.45s ease;
}
.masonry-peek.masonry-expanded {
  max-height: 3000px;
}
@media (min-width: 769px) {
  .masonry-peek { max-height: 580px; }
}
.masonry-peek-fade {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 250px;
  background: linear-gradient(to bottom,
    transparent 0%,
    rgba(10, 10, 15, 0.35) 30%,
    rgba(10, 10, 15, 0.75) 60%,
    var(--bg-primary) 100%
  );
  pointer-events: none;
}

/* Кнопка «Посмотреть все» для masonry использует стандартный .see-all */

/* ============ VK LOGIN BUTTON ============ */
.btn-vk-login {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  padding: 0 16px;
  background: #7C3AED;
  color: #fff;
  border: none;
  border-radius: 9999px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.18s, opacity 0.18s;
  white-space: nowrap;
  flex-shrink: 0;
}
.btn-vk-login:hover { filter: brightness(1.12); }
.btn-vk-login svg { flex-shrink: 0; }

/* Аватар пользователя в хедере */
.user-avatar-hdr {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 2px solid var(--border-default);
  cursor: pointer;
  transition: border-color 0.18s;
}
.user-avatar-hdr:hover { border-color: var(--accent-primary); }
.user-avatar-hdr img { width: 100%; height: 100%; object-fit: cover; }
.user-avatar-hdr--init {
  background: var(--accent-primary);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
}

/* ============ DESKTOP FAB — кнопка «Создать» снизу по центру ============ */
.desktop-fab {
  display: none;
  border: none;
  cursor: pointer;
  text-decoration: none;
}
@media (min-width: 769px) {
  .desktop-fab {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    position: fixed;
    bottom: 28px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 200;
    background: var(--brand-gradient-cta);
    color: #5B2C00;
    font-family: inherit;
    font-size: 16px;
    font-weight: 700;
    padding: 14px 36px;
    border-radius: 9999px;
    box-shadow: var(--shadow-cta), 0 8px 32px rgba(251, 146, 60, 0.35);
    transition: transform 0.2s, box-shadow 0.2s, filter 0.2s;
    white-space: nowrap;
  }
  .desktop-fab svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
  }
  .desktop-fab:hover {
    filter: brightness(1.07);
    box-shadow: var(--shadow-cta), 0 12px 40px rgba(251, 146, 60, 0.5);
    transform: translateX(-50%) translateY(-2px);
  }
  .desktop-fab:active {
    transform: translateX(-50%) scale(0.97);
  }
}

/* ============ МОБИЛЬНАЯ ШАПКА ============ */
.header-mobile {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-primary);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-default);
  overflow: hidden;
  gap: 8px;
}
.brand-mobile {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 20px;
  letter-spacing: -0.02em;
  min-width: 0;
  flex-shrink: 1;
  white-space: nowrap;
  overflow: hidden;
}
.brand-mobile .brand-mark { width: 28px; height: 28px; flex-shrink: 0; }
.header-actions-mobile {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* ============ ENERGY PILL ============ */
.energy-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--bg-chip);
  border-radius: 9999px;
  font-weight: 700;
  font-size: 13px;
  border: 1px solid var(--border-default);
  cursor: pointer;
  transition: all 0.2s;
}
.energy-pill:hover { background: var(--bg-chip-active); }
.energy-icon {
  width: 18px; height: 18px;
  background: var(--energy-gradient);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 8px rgba(251, 146, 60, 0.4);
  flex-shrink: 0;
}
.energy-icon svg { width: 11px; height: 11px; color: white; }

/* ============ BUY BUTTON ============ */
.btn-buy {
  background: var(--bg-chip);
  color: var(--text-primary);
  border: 1px solid var(--border-default);
  padding: 7px 14px;
  border-radius: 9999px;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.04em;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.btn-buy:hover { background: var(--bg-chip-active); }
/* Скрыть кнопку «КУПИТЬ» на мобайле — хватает пилюли с балансом */
@media (max-width: 768px) {
  .btn-buy { display: none; }
}

/* ============ КНОПКИ ============ */
.btn {
  font-family: inherit;
  font-weight: 600;
  font-size: 15px;
  padding: 12px 24px;
  border-radius: 12px;
  border: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s;
}
.btn:active { transform: scale(0.98); }
.btn svg { width: 18px; height: 18px; }

.btn-primary {
  background: var(--brand-gradient-cta);
  color: #5B2C00;
  box-shadow: var(--shadow-cta);
  font-weight: 700;
}
.btn-primary:hover { filter: brightness(1.05); }

.btn-secondary {
  background: var(--brand-gradient-purple);
  color: white;
  box-shadow: var(--shadow-accent);
}
.btn-secondary:hover { filter: brightness(1.1); }

.btn-outline {
  background: transparent;
  border: 1px solid var(--border-default);
  color: var(--text-primary);
}
.btn-outline:hover { background: var(--bg-chip); }

.btn-ghost {
  background: transparent;
  color: var(--brand-purple-500);
}
.btn-ghost:hover { background: rgba(168, 85, 247, 0.08); }

/* ============ МОБИЛЬНОЕ НИЖНЕЕ МЕНЮ ============ */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  width: 100%;
  background: var(--bg-primary);
  border-top: 1px solid var(--border-default);
  box-shadow: var(--shadow-nav);
  padding: 8px 4px calc(8px + env(safe-area-inset-bottom));
  display: flex;
  justify-content: space-around;
  align-items: flex-start;
  z-index: 1000;
  /* Принудительный GPU-слой — fix для мобильного Chrome/Safari */
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
}
@media (min-width: 769px) {
  .bottom-nav { display: none; }
}
.nav-item {
  flex: 1;
  min-width: 0;
  max-width: 20%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--icon-default);
  font-size: 11px;
  font-weight: 500;
  padding: 4px 2px;
  transition: color 0.2s;
}
.nav-item svg { width: 22px; height: 22px; stroke-width: 2; flex-shrink: 0; }
.nav-item.active { color: var(--text-primary); }
.nav-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  text-align: center;
  display: block;
}
.nav-item.create {
  margin-top: -16px;
  background: none;
  border: none;
  font-family: inherit;
  cursor: pointer;
  flex-shrink: 0;
}
.nav-item.create .create-button {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--brand-gradient-cta);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-cta);
  margin-bottom: 2px;
  color: #5B2C00;
  position: relative;
  flex-shrink: 0;
}
.nav-item.create .create-button svg { width: 24px; height: 24px; }
.nav-item.create .nav-label { font-weight: 600; color: var(--text-primary); }
/* Очень маленький экран: шрифт меньше */
@media (max-width: 360px) {
  .nav-item { font-size: 10px; padding: 4px 0; }
  .nav-item svg { width: 20px; height: 20px; }
  .nav-item.create .create-button { width: 46px; height: 46px; }
  .nav-item.create .create-button svg { width: 20px; height: 20px; }
}

/* ============ THEME TOGGLE ============ */
.theme-toggle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-chip);
  border: 1px solid var(--border-default);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
  transition: all 0.2s;
  flex-shrink: 0;
}
.theme-toggle:hover { background: var(--bg-chip-active); }
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }
:root.dark .theme-toggle .icon-sun { display: block; }
:root.dark .theme-toggle .icon-moon { display: none; }

/* ============ SECTION ============ */
.section { margin: 28px 0; }
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}
.section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0;
}
.section-title svg {
  width: 20px; height: 20px;
  color: var(--brand-amber-400);
}
.section-subtitle {
  color: var(--text-secondary);
  font-size: 14px;
  margin: 4px 0 16px;
}
.see-all {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  margin-top: 8px;
  padding: 4px 0;
}
.see-all svg { width: 14px; height: 14px; }
.see-all:hover { color: var(--text-primary); }

/* ============ HERO КАРУСЕЛЬ ============ */
.hero-carousel {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  margin: 16px -16px 0;
  padding: 0 40px 12px;
}
.hero-carousel::-webkit-scrollbar { display: none; }
@media (min-width: 769px) {
  .hero-carousel {
    margin: 16px 0 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    overflow: visible;
  }
}
.hero-card {
  flex: 0 0 100%;
  max-width: 360px;
  height: 190px;
  border-radius: 20px;
  scroll-snap-align: center;
  scroll-snap-stop: always;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 18px;
}
@media (min-width: 769px) {
  .hero-card {
    flex: unset;
    max-width: unset;
    height: 160px;
    padding: 20px;
  }
}
.hero-card.vk-card {
  background: linear-gradient(135deg, #0077FF 0%, #4D90FE 100%);
  color: white;
}
.hero-card.purple-card {
  background: linear-gradient(135deg, #A855F7 0%, #7E22CE 100%);
  color: white;
}
.hero-card.warm-card {
  background: linear-gradient(135deg, #F97316 0%, #EC4899 100%);
  color: white;
}
.hero-card h3 { font-size: 18px; font-weight: 700; margin: 0; }
.hero-card-icon {
  width: 72px; height: 72px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  align-self: center;
  backdrop-filter: blur(10px);
}
.hero-card-icon svg { width: 36px; height: 36px; color: white; }
@media (min-width: 769px) {
  .hero-card-icon { width: 56px; height: 56px; border-radius: 14px; }
  .hero-card-icon svg { width: 28px; height: 28px; }
}
.hero-card-btn {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.22);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: white;
  padding: 8px 16px;
  border-radius: 9999px;
  font-size: 13px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.hero-card-btn svg { width: 14px; height: 14px; }

/* ============ QUICK ACTIONS ============ */
/* ============ КАРТОЧКИ ТИПА СОЗДАНИЯ ============ */
.create-type-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.create-type-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: 18px;
  padding: 16px;
  text-decoration: none;
  color: var(--text-primary);
  transition: background 0.2s, border-color 0.2s, transform 0.15s;
  cursor: pointer;
}
.create-type-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--brand-orange-500);
  transform: translateY(-1px);
}
.create-type-card--soon {
  opacity: 0.6;
  cursor: default;
  pointer-events: none;
}
.create-type-card--soon:hover { transform: none; }
.ctc-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.ctc-icon svg { width: 26px; height: 26px; }
.ctc-body {
  flex: 1;
  min-width: 0;
}
.ctc-title {
  font-size: 16px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 2px;
}
.ctc-desc {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.3;
}
.ctc-soon-badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .04em;
  background: var(--bg-chip);
  border: 1px solid var(--border-default);
  color: var(--text-secondary);
  padding: 2px 7px;
  border-radius: 9999px;
  vertical-align: middle;
}
.ctc-arrow {
  width: 18px;
  height: 18px;
  color: var(--icon-muted);
  flex-shrink: 0;
}

.quick-actions {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  scrollbar-width: none;
  margin: 0 -16px;
  padding: 4px 16px 12px;
}
.quick-actions::-webkit-scrollbar { display: none; }
@media (min-width: 769px) {
  .quick-actions {
    margin: 0;
    padding: 4px 0 12px;
    gap: 20px;
    overflow: visible;
    justify-content: flex-start;
    flex-wrap: wrap;
  }
}
.quick-action {
  flex-shrink: 0;
  width: 72px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.qa-icon {
  width: 60px;
  height: 60px;
  border-radius: 18px;
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
  transition: all 0.2s;
}
.qa-icon svg { width: 26px; height: 26px; }
.quick-action:hover .qa-icon {
  background: var(--bg-card-hover);
  transform: translateY(-2px);
}
.qa-label {
  font-size: 11px;
  font-weight: 500;
  text-align: center;
  color: var(--text-secondary);
  line-height: 1.2;
}

/* ============ TEMPLATE ROW ============ */
.template-row {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  scrollbar-width: none;
  margin: 0 -16px;
  padding: 4px 16px 12px;
}
.template-row::-webkit-scrollbar { display: none; }
@media (min-width: 769px) {
  .template-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    margin: 0;
    padding: 4px 0 12px;
    gap: 16px;
    overflow: visible;
  }
}
.template-card {
  flex-shrink: 0;
  width: 160px;
  aspect-ratio: 4/5;
  border-radius: 16px;
  position: relative;
  overflow: hidden;
  background: var(--bg-card);
  transition: transform 0.2s;
  cursor: pointer;
}
@media (min-width: 769px) {
  .template-card { width: auto; }
}
.template-card:hover { transform: translateY(-4px); }
.template-image {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
}
.template-image::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.85) 0%, rgba(0,0,0,0) 50%);
}
.template-badges-top {
  position: absolute;
  top: 8px;
  left: 8px;
  right: 8px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 6px;
  z-index: 2;
}
.template-type-icon {
  width: 28px; height: 28px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
}
.template-type-icon svg { width: 14px; height: 14px; }
.template-name {
  position: absolute;
  bottom: 12px;
  left: 12px;
  right: 12px;
  z-index: 2;
  color: white;
  font-weight: 800;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
  line-height: 1.2;
}

/* ============ БЕЙДЖИ ============ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.badge svg { width: 11px; height: 11px; }
.badge-popular {
  background: var(--badge-popular);
  color: #5B2C00;
  box-shadow: 0 2px 8px rgba(251, 191, 36, 0.35);
}
.badge-new {
  background: var(--badge-new);
  color: white;
  box-shadow: 0 2px 8px rgba(251, 146, 60, 0.35);
}
.badge-premium {
  background: var(--brand-gradient-purple);
  color: white;
}
.badge-category {
  background: var(--bg-chip);
  color: var(--text-secondary);
  border: 1px solid var(--border-default);
  font-weight: 500;
}

/* ============ CHIPS / ФИЛЬТРЫ ============ */
.chip-row {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  overflow-x: auto;
  scrollbar-width: none;
  margin-left: -16px;
  margin-right: -16px;
  padding: 0 16px;
}
.chip-row::-webkit-scrollbar { display: none; }
@media (min-width: 769px) {
  .chip-row { margin: 0 0 16px; padding: 0; flex-wrap: wrap; }
}
.chip {
  flex-shrink: 0;
  padding: 8px 16px;
  border-radius: 9999px;
  background: var(--bg-chip);
  border: 1px solid var(--border-default);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}
.chip:hover { background: var(--bg-chip-active); }
.chip.active {
  background: var(--text-primary);
  color: var(--bg-primary);
  border-color: var(--text-primary);
}
.chip svg { width: 14px; height: 14px; }
.chip .chip-icon-amber { color: var(--brand-amber-400); }

/* ============ ГАЛЕРЕЯ ИДЕЙ ============ */
.gallery {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
@media (min-width: 769px) {
  .gallery {
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
  }
}
.gallery-item {
  aspect-ratio: 3/4;
  border-radius: 14px;
  overflow: hidden;
  position: relative;
  cursor: pointer;
  background-size: cover;
  background-position: center;
}
.gallery-item:hover { transform: translateY(-2px); }

/* --- Prompt-card (4 фото + заголовок) --- */
.gallery-item-prompt {
  aspect-ratio: auto !important;
  grid-column: span 2;
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: 16px;
  overflow: hidden;
  cursor: pointer;
  transition: transform .2s, box-shadow .2s;
}
.gallery-item-prompt:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 40px rgba(0,0,0,.18);
}
.gallery-prompt-header {
  padding: 14px 14px 10px;
}
.gallery-prompt-title {
  font-size: 14px;
  font-weight: 800;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 4px;
  line-height: 1.2;
}
.gallery-prompt-desc {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.gallery-prompt-photos {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
}
.gallery-prompt-photos img {
  width: 100%;
  height: 110px;
  object-fit: cover;
  display: block;
}
@media (min-width: 769px) {
  .gallery-prompt-photos img { height: 140px; }
}

/* ============ PROMPT OVERLAY ============ */
.idea-detail-prompt {
  background: var(--bg-card);
  border-radius: 24px;
  overflow: hidden;
  border: 1px solid var(--border-default);
  width: 100%;
  max-width: 440px;
}
@media (min-width: 769px) {
  .idea-detail-prompt { max-width: 820px; }
}
.idea-prompt-header {
  padding: 20px 54px 14px 20px;
  position: relative;
}
.idea-prompt-close {
  position: absolute;
  top: 14px;
  right: 14px;
  background: var(--bg-chip);
  border: 1px solid var(--border-default);
  border-radius: 50%;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-primary);
  flex-shrink: 0;
}
.idea-prompt-close:hover { background: var(--bg-chip-active); }
.idea-prompt-title {
  font-size: 20px;
  font-weight: 800;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: .4px;
  margin-bottom: 6px;
  line-height: 1.2;
}
.idea-prompt-desc {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
}
.idea-prompt-grid-wrap {
  position: relative;
}
.idea-prompt-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 0 4px 4px;
}
.idea-prompt-grid-actions {
  position: absolute;
  bottom: 14px;
  right: 14px;
  display: flex;
  gap: 8px;
}
.idea-prompt-grid-actions .action-btn {
  background: rgba(0,0,0,.45);
  backdrop-filter: blur(8px);
  border-color: rgba(255,255,255,.2);
  color: #fff;
}
.idea-prompt-grid-actions .action-btn:hover {
  background: rgba(0,0,0,.65);
}
.idea-prompt-grid img {
  width: 100%;
  aspect-ratio: 3/4;
  object-fit: cover;
  border-radius: 10px;
  display: block;
  cursor: pointer;
  transition: opacity .15s;
}
.idea-prompt-grid img:hover { opacity: .88; }

/* Лайтбокс для промт-фото */
.prompt-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.92);
  z-index: 10100;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 12px 16px 16px;
  animation: fadeIn .15s;
  cursor: zoom-out;
}
.prompt-lightbox-bar {
  display: flex;
  justify-content: flex-end;
  flex-shrink: 0;
  margin-bottom: 10px;
  cursor: default;
}
.prompt-lightbox img {
  flex: 1;
  min-height: 0;
  width: 100%;
  object-fit: contain;
  border-radius: 12px;
  box-shadow: 0 24px 80px rgba(0,0,0,.7);
  animation: slideUp .2s;
  cursor: default;
}
.prompt-lightbox-close {
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #fff;
  transition: background .15s;
  flex-shrink: 0;
}
.prompt-lightbox-close:hover { background: rgba(255,255,255,.22); }
@media (min-width: 769px) {
  .idea-prompt-grid { grid-template-columns: repeat(4, 1fr); }
}
.idea-prompt-footer {
  padding: 12px 14px 16px;
}
.idea-prompt-generate {
  width: 100%;
  background: var(--brand-gradient-cta);
  color: #5B2C00;
  border: none;
  padding: 14px;
  border-radius: 14px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: var(--shadow-cta);
  transition: opacity .15s;
}
.idea-prompt-generate:hover { opacity: .92; }
.idea-prompt-generate svg { flex-shrink: 0; }

/* ============ ДЕТАЛЬ ИДЕИ ============ */
.idea-detail {
  background: var(--bg-card);
  border-radius: 24px;
  overflow: hidden;
  border: 1px solid var(--border-default);
  max-width: 420px;
  margin: 0 auto;
}
.idea-image {
  width: 100%;
  aspect-ratio: 3/4;
  background-size: cover;
  background-position: center;
  position: relative;
  overflow: hidden;
}
.idea-image--video {
  aspect-ratio: 16/9;
}
.idea-image-overlay {
  position: absolute;
  bottom: 12px;
  left: 12px;
  right: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.author-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px 5px 5px;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(10px);
  border-radius: 9999px;
  color: white;
  font-size: 13px;
  font-weight: 600;
}
.author-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--brand-gradient-purple);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
}
.action-chip {
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(10px);
  color: white;
  padding: 7px 14px;
  border-radius: 9999px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  border: none;
}
.action-chip svg { width: 14px; height: 14px; }
.idea-meta {
  padding: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.idea-meta-avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, #FB923C, #EC4899);
  flex-shrink: 0;
}
.idea-model-pill {
  padding: 6px 12px;
  background: var(--bg-chip);
  border: 1px solid var(--border-default);
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.idea-model-pill svg { width: 14px; height: 14px; color: var(--brand-amber-400); }
.idea-side-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}
.action-btn {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--bg-chip);
  border: 1px solid var(--border-default);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
  transition: all 0.2s;
}
.action-btn:hover { background: var(--bg-chip-active); }
.action-btn svg { width: 18px; height: 18px; }
.action-btn.liked { color: var(--brand-pink-500); border-color: var(--brand-pink-500); }
.idea-prompt {
  padding: 0 14px 14px;
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}
.idea-prompt svg { width: 14px; height: 14px; }
.prompt-blur {
  flex: 1;
  height: 22px;
  background: repeating-linear-gradient(
    45deg,
    transparent 0 4px,
    var(--bg-chip) 4px 8px
  );
  border-radius: 8px;
  filter: blur(1.5px);
}
.btn-repeat {
  width: calc(100% - 28px);
  margin: 0 14px 14px;
  background: var(--brand-gradient-cta);
  color: #5B2C00;
  border: none;
  padding: 14px;
  border-radius: 14px;
  font-weight: 800;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: var(--shadow-cta);
}
.btn-repeat svg { width: 18px; height: 18px; }

/* ============ ПРОФИЛЬ-БЛОК ============ */
.profile-block {
  background: var(--bg-hero);
  border-radius: 20px;
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  border: 1px solid var(--border-default);
  flex-wrap: wrap;
}
.profile-block > .btn {
  width: 100%;
  text-align: center;
}
@media (min-width: 480px) {
  .profile-block { flex-wrap: nowrap; }
  .profile-block > .btn { width: auto; }
}
.avatar-lg {
  width: 64px; height: 64px;
  border-radius: 50%;
  background: var(--brand-gradient-purple);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 22px;
  font-weight: 800;
  box-shadow: var(--shadow-accent);
  flex-shrink: 0;
}
.profile-info { flex: 1; min-width: 0; }
.profile-name {
  font-size: 17px;
  font-weight: 800;
  margin: 0 0 4px;
}
.profile-tariff {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  background: var(--brand-gradient-cta);
  color: #5B2C00;
  font-size: 11px;
  font-weight: 700;
  border-radius: 9999px;
  margin-bottom: 6px;
}
.profile-balance {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
}
.balance-num {
  font-weight: 800;
  font-size: 15px;
  background: var(--brand-gradient-cta);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* ============ ТАРИФЫ ============ */
.plans-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  max-width: 900px;
  margin: 0 auto;
}
@media (min-width: 769px) {
  .plans-grid { grid-template-columns: repeat(4, 1fr); }
}
.plan {
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: 20px;
  padding: 24px 20px;
  text-align: center;
  position: relative;
  transition: all 0.2s;
}
.plan:hover { box-shadow: var(--shadow-accent); }
.plan.featured {
  border: 2px solid var(--brand-orange-500);
  box-shadow: var(--shadow-cta);
}
.plan-badge {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--brand-gradient-cta);
  color: #5B2C00;
  font-size: 11px;
  font-weight: 800;
  padding: 4px 12px;
  border-radius: 9999px;
  letter-spacing: 0.04em;
}
.plan-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.plan-price { font-size: 30px; font-weight: 800; margin: 0; }
.plan-period { font-size: 13px; color: var(--text-tertiary); margin: 0 0 16px; }
.plan-features {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0 0 20px;
  line-height: 1.7;
}

/* ============ STATES ============ */
.alert {
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 14px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 8px;
}
.alert svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }
.alert-success { background: #ECFDF5; color: #059669; }
.alert-error { background: #FEF2F2; color: #DC2626; }
.alert-warning { background: #FFF7ED; color: #EA580C; }
:root.dark .alert-success { background: rgba(16, 185, 129, 0.1); color: #10B981; }
:root.dark .alert-error { background: rgba(239, 68, 68, 0.1); color: #EF4444; }
:root.dark .alert-warning { background: rgba(251, 146, 60, 0.1); color: #FB923C; }

/* ============ INPUT ============ */
.input {
  width: 100%;
  font-family: inherit;
  font-size: 15px;
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid var(--border-default);
  background: var(--bg-input);
  color: var(--text-primary);
  outline: none;
  transition: all 0.2s;
}
.input::placeholder { color: var(--text-tertiary); }
.input:focus {
  border-color: var(--brand-purple-500);
  box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.2);
}
.label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  display: block;
}

/* ============ PROGRESS ============ */
.progress {
  height: 8px;
  background: var(--bg-chip);
  border-radius: 9999px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: var(--brand-gradient-cta);
  border-radius: 9999px;
  transition: width 0.3s;
}

/* ============ UPLOAD ZONE ============ */
.upload-zone {
  border: 2px dashed var(--border-default);
  border-radius: 20px;
  padding: 48px 24px;
  text-align: center;
  background: var(--bg-card);
  transition: all 0.2s;
  cursor: pointer;
}
.upload-zone:hover {
  border-color: var(--brand-purple-500);
  background: var(--bg-card-hover);
}
.upload-icon {
  width: 64px; height: 64px;
  margin: 0 auto 16px;
  border-radius: 16px;
  background: var(--bg-chip);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--brand-purple-500);
}
.upload-icon svg { width: 32px; height: 32px; }
.upload-title { font-size: 16px; font-weight: 700; margin: 0 0 4px; }
.upload-hint { font-size: 13px; color: var(--text-tertiary); margin: 0; }

/* ============ ДЕЦЕЛИ + АНИМАЦИИ ============ */
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
.skeleton {
  background: linear-gradient(
    90deg,
    var(--bg-chip) 0%,
    var(--bg-card-hover) 50%,
    var(--bg-chip) 100%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 8px;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}
.pulse { animation: pulse 1.5s infinite; }

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.fade-in { animation: fadeInUp 0.3s ease-out; }

/* ============ ЛОГОТИП — общий SVG ============ */
.brand-mark-svg {
  width: 100%;
  height: 100%;
}

/* ============ FOOTER ============ */
footer {
  border-top: 1px solid var(--border-default);
  padding: 32px 0;
  margin-top: 48px;
  color: var(--text-tertiary);
  font-size: 13px;
  text-align: center;
}
@media (min-width: 769px) {
  /* Отступ снизу чтобы FAB-кнопка «Создать» не перекрывала текст */
  footer { padding-bottom: 120px; }
}
@media (max-width: 768px) {
  footer { display: none; }
}
