/* =============== Telegram-ish base =============== */
:root{
  /* Дефолты для тёмной темы, JS обновит из Telegram SDK */
  --tg-theme-bg-color: #0f0f12;
  --tg-theme-secondary-bg-color: #1c1c1e;
  --tg-theme-text-color: #ffffff;
  --tg-theme-hint-color: #8e8e93;
  --tg-theme-link-color: #3a95ff;
  --tg-theme-button-color: #3a95ff;
  --tg-theme-button-text-color: #ffffff;
  --tg-theme-section-separator-color: rgba(255,255,255,.1);
  
  /* Bot API 7.0+ */
  --tg-theme-header-bg-color: #0f0f12;
  --tg-theme-bottom-bar-bg-color: #0f0f12;
  --tg-theme-accent-text-color: #3a95ff;
  --tg-theme-section-bg-color: #1c1c1e;
  --tg-theme-section-header-text-color: #8e8e93;
  --tg-theme-subtitle-text-color: #8e8e93;
  --tg-theme-destructive-text-color: #ff3b30;
  
  /* Aliases for easier use */
  --bg: var(--tg-theme-bg-color);
  --card: var(--tg-theme-secondary-bg-color);
  --text: var(--tg-theme-text-color);
  --hint: var(--tg-theme-hint-color);
  --link: var(--tg-theme-link-color);
  --btn: var(--tg-theme-button-color);
  --btnText: var(--tg-theme-button-text-color);
  --sep: var(--tg-theme-section-separator-color);
  --accent: var(--tg-theme-accent-text-color);
  --subtitle: var(--tg-theme-subtitle-text-color);
  --destructive: var(--tg-theme-destructive-text-color);
  
  /* Design tokens */
  --r: 14px;
  --r2: 18px;
  --safeTop: env(safe-area-inset-top, 0px);
  --safeRight: env(safe-area-inset-right, 0px);
  --safeBot: env(safe-area-inset-bottom, 0px);
  --safeLeft: env(safe-area-inset-left, 0px);
  --t: 200ms;
  --t2: 360ms;
}

* { box-sizing: border-box; }

.hidden {
  display: none !important;
}

html { 
  min-height: 100%;
  min-height: 100dvh;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  overflow-x: hidden;
  background: #0f0f12;
  background: var(--bg, #0f0f12);
}
body { 
  min-height: 100%;
  min-height: calc(100dvh + 1px);
  margin: 0;
  padding: 0;
  background: #0f0f12;
  background: var(--bg, #0f0f12);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overscroll-behavior-x: none;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
  position: relative;
}

a { color: var(--link); text-decoration: none; }
button, input, textarea { font: inherit; outline: none; }
.tap { -webkit-tap-highlight-color: transparent; }

/* Фиксированный фон на весь экран (для iOS Safari safe area) */
body::before {
  content: "";
  position: fixed;
  top: -100px;
  left: -100px;
  right: -100px;
  bottom: -100px;
  background: #0f0f12;
  background: var(--bg, #0f0f12);
  z-index: -9999;
  pointer-events: none;
}

/* =============== App shell =============== */
.app{
  height: 100%;
  height: 100dvh;
  display:flex;
  flex-direction:column;
  padding-top: calc(var(--safeTop) + 6px);
  padding-right: var(--safeRight);
  padding-bottom: 0;
  padding-left: var(--safeLeft);
  background: var(--bg, #0f0f12);
  overflow: hidden;
}

/* Web mode - контент заходит за safe area */
.web-mode .app {
  padding-top: 6px;
  padding-right: 0;
  padding-bottom: 0;
  padding-left: 0;
}

/* Хедер в web/PWA режиме - покрывает safe area сверху */
.web-mode .miniapp-header {
  position: sticky;
  top: 0;
  padding-top: env(safe-area-inset-top, 0px);
  background: var(--bg);
}

/* Заголовки других страниц в web/PWA - sticky с safe area */
.web-mode .page > .largeTitle:first-child {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--bg);
  padding-top: calc(env(safe-area-inset-top, 0px) + 20px);
}

.web-mode .page > .mygens-header:first-child {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--bg);
  padding-top: calc(env(safe-area-inset-top, 0px) + 14px);
}

.web-mode .page > .user-profile-content:first-child,
.web-mode .page > .create-container:first-child {
  padding-top: env(safe-area-inset-top, 0px);
}

.web-mode #auth-screen {
  padding-top: env(safe-area-inset-top, 0px);
}

/* Модальное окно в web/PWA - safe area */
.web-mode .modal {
  /* Safe area уже учтён в modal-back-header */
}

.web-mode .modal-header {
  padding-top: env(safe-area-inset-top, 0px);
}

.web-mode .modal-back-header {
  padding-top: calc(env(safe-area-inset-top, 0px) + 12px) !important;
}

/* Telegram Mini App Header */
.miniapp-header{
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--bg);
  border-bottom: 0.5px solid var(--sep);
  flex-shrink: 0;
}

.header-top{
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px 8px;
  gap: 12px;
}

.header-title{
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 0.3px;
  margin: 0;
  color: var(--text);
  flex: 1;
  min-width: 0;
}

.balance-pill{
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 12px;
  background: var(--secondary_bg_color);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}

.balance-pill:active{
  opacity: 0.7;
}

.header-tabs{
  display: flex;
  gap: 0;
  padding: 0 12px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  position: relative;
}

.header-tabs::-webkit-scrollbar{
  display: none;
}

.tab-btn{
  flex: 0 0 auto;
  padding: 12px 16px;
  background: transparent;
  border: none;
  color: var(--hint);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  position: relative;
  transition: color 0.2s;
  white-space: nowrap;
}

.tab-btn.active{
  color: var(--link);
  font-weight: 600;
}

/* Индикатор теперь отдельный элемент */
.tab-indicator{
  position: absolute;
  bottom: 0;
  left: 0;
  height: 2px;
  background: var(--link);
  border-radius: 1px;
  transition: transform 0.3s ease-out, width 0.3s ease-out;
  will-change: transform, width;
}

.tab-indicator.dragging{
  transition: none;
}

.tab-btn:active{
  opacity: 0.7;
}

/* =============== Banner Carousel =============== */
.banner-carousel {
  padding: 12px 16px 0;
  position: relative;
}

.banner-track {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}

.banner-track::-webkit-scrollbar {
  display: none;
}

.banner-slide {
  flex: 0 0 100%;
  scroll-snap-align: start;
  background: var(--card);
  border-radius: 14px;
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s;
  border: 0.5px solid var(--sep);
}

.banner-slide:active {
  transform: scale(0.98);
  opacity: 0.9;
}

.banner-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.banner-text {
  flex: 1;
  min-width: 0;
}

.banner-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}

.banner-subtitle {
  font-size: 14px;
  color: var(--hint);
  margin-top: 2px;
}

.banner-arrow {
  width: 20px;
  height: 20px;
  color: var(--hint);
  flex-shrink: 0;
}

/* Banner dots */
.banner-dots {
  display: flex;
  justify-content: center;
  gap: 6px;
  padding: 10px 0 0;
}

.banner-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--hint);
  opacity: 0.3;
  transition: all 0.3s ease;
}

.banner-dot.active {
  opacity: 1;
  width: 18px;
  border-radius: 3px;
  background: var(--link);
}

/* Content spacing after header */
.feedContainer{
  padding-top: 8px;
}

/* Subscribe buttons */
.subscribe-btn,
.subscribe-btn-profile {
  transition: transform 0.15s, opacity 0.15s !important;
}

.subscribe-btn:active,
.subscribe-btn-profile:active {
  transform: scale(0.96);
  opacity: 0.8;
}

.subscribe-btn:disabled,
.subscribe-btn-profile:disabled {
  opacity: 0.6;
  pointer-events: none;
}

.primaryBtn{
  border:0;
  background: var(--btn);
  color: var(--btnText);
  padding: 10px 14px;
  border-radius: 999px;
  font-weight: 700;
  letter-spacing: .2px;
  transition: transform var(--t), opacity var(--t);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.primaryBtn:active{ transform: translateY(1px) scale(.99); opacity: .9; }

.primaryBtn i[data-lucide],
.secondaryBtn i[data-lucide] {
  vertical-align: middle;
  flex-shrink: 0;
}

.secondaryBtn{
  border: 1.5px solid var(--sep);
  background: var(--card);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 999px;
  font-weight: 700;
  letter-spacing: .2px;
  transition: transform var(--t), opacity var(--t);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.secondaryBtn:active{ transform: translateY(1px) scale(.99); opacity: .9; }

.seg{
  display:flex;
  gap:8px;
  margin-top: 10px;
  overflow:auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}
.seg::-webkit-scrollbar{ display:none; }

.seg button{
  flex:0 0 auto;
  border: 1px solid var(--sep);
  background: var(--card);
  color: var(--text);
  padding: 9px 14px;
  border-radius: 999px;
  font-weight: 600;
  transition: transform var(--t), background var(--t);
  cursor: pointer;
}
.seg button.active{
  background: color-mix(in srgb, var(--btn) 18%, var(--card));
  border-color: color-mix(in srgb, var(--btn) 35%, var(--sep));
}
.seg button:active{ transform: scale(.98); }

/* =============== Telegram Section / List Pattern =============== */
.largeTitle{
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text);
  padding: 20px 16px 8px;
  line-height: 1.1;
}

/* My Generations Header */
.mygens-header{
  display: flex;
  align-items: center;
  padding: 14px 16px 10px;
  gap: 4px;
}
.mygens-back-btn,
.user-profile-back-btn{
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  background: none;
  color: var(--accent);
  padding: 0;
  cursor: pointer;
  border-radius: 50%;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}
.mygens-back-btn:active,
.user-profile-back-btn:active{
  background: var(--secondary_bg_color);
}
.mygens-back-btn svg,
.user-profile-back-btn svg{
  width: 28px;
  height: 28px;
  stroke-width: 2;
}
.mygens-header-title{
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text);
  line-height: 1.1;
}

.section{
  margin-bottom: 20px;
}

.sectionHeader{
  padding: 12px 16px 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--hint);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.list{
  background: var(--card);
  border-radius: var(--r);
  margin: 0 8px;
  overflow: hidden;
}

.cell{
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 0.5px solid var(--sep);
  transition: background var(--t);
  cursor: pointer;
  min-height: 60px;
}

.cell:last-child{
  border-bottom: none;
}

.cell:active{
  background: color-mix(in srgb, var(--text) 8%, transparent);
}

/* Oferta notice */
.oferta-notice {
  font-size: 12px;
  color: var(--hint);
  text-align: center;
  padding: 12px 16px;
}

.oferta-notice a {
  color: var(--link);
  text-decoration: none;
}

.cellIcon{
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--btn) 15%, transparent);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.cellIcon svg{
  width: 18px;
  height: 18px;
  stroke: var(--btn);
}

.cellContent{
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cellTitle{
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cellSubtitle{
  font-size: 13px;
  color: var(--hint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cellValue{
  font-size: 15px;
  color: var(--hint);
  flex-shrink: 0;
  margin-left: auto;
}

.cellChevron{
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  opacity: 0.3;
}

.cellChevron svg{
  width: 100%;
  height: 100%;
  stroke: var(--text);
}

/* =============== Pages + transitions =============== */
.pages{
  position: relative;
  flex:1;
  display: flex;
  flex-direction: column;
  min-height: 0; /* Важно для flex shrinking */
}
.page{
  display:none;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  animation: pageIn var(--t2) cubic-bezier(.2,.9,.2,1);
}
/* Галерея - без padding, swipe панели имеют свой */
#page-gallery.active{ display:flex; }
/* Другие страницы - с padding и своим скроллом */
.page.active:not(#page-gallery){ 
  display:flex;
  padding: 12px calc(12px + var(--safeRight)) calc(var(--safeBot) + 78px) calc(12px + var(--safeLeft));
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

@keyframes pageIn{
  from{ opacity:0; transform: translateY(6px); }
  to{ opacity:1; transform: translateY(0); }
}

/* =============== Skeleton loaders =============== */
@keyframes shimmer{
  0%{ background-position: -468px 0; }
  100%{ background-position: 468px 0; }
}
.skeleton{
  background: linear-gradient(to right, var(--card) 0%, color-mix(in srgb, var(--card) 95%, var(--text)) 50%, var(--card) 100%);
  background-size: 800px 104px;
  animation: shimmer 1.8s ease-in-out infinite;
  border-radius: var(--r);
}
.skeleton-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 0;
}
.skeleton-card{
  border-radius: var(--r2);
  overflow:hidden;
  background: var(--card);
  border: 1px solid var(--sep);
  aspect-ratio: 3/4;
}
.skeleton-img{
  width: 100%;
  height: 100%;
  background: linear-gradient(to right, var(--card) 0%, color-mix(in srgb, var(--card) 95%, var(--text)) 50%, var(--card) 100%);
  background-size: 800px 104px;
  animation: shimmer 1.8s ease-in-out infinite;
}
.skeleton-overlay{
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 40px;
  background: linear-gradient(to top, rgba(0,0,0,0.4), transparent);
}
.skeleton-text{
  height: 14px;
  margin: 6px 0;
  border-radius: 4px;
  background: linear-gradient(to right, var(--card) 0%, color-mix(in srgb, var(--card) 95%, var(--text)) 50%, var(--card) 100%);
  background-size: 800px 104px;
  animation: shimmer 1.8s ease-in-out infinite;
}
.skeleton-text.short{ width: 60%; }

/* Скелетон для карточек пакетов */
.skeleton-cell{
  display: flex;
  align-items: center;
  padding: 12px 16px;
}
.skeleton-icon{
  width: 40px;
  height: 40px;
  border-radius: 10px;
  flex-shrink: 0;
  background: linear-gradient(to right, var(--card) 0%, color-mix(in srgb, var(--card) 95%, var(--text)) 50%, var(--card) 100%);
  background-size: 800px 104px;
  animation: shimmer 1.8s ease-in-out infinite;
}

/* =============== Swipe Tabs =============== */
.swipe-container{
  position: relative;
  overflow: hidden;
  flex: 1;
  min-height: 0; /* Важно для flex shrinking */
}

.swipe-track{
  display: flex;
  height: 100%;
  transition: transform 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  will-change: transform;
}
.swipe-track.dragging{
  transition: none;
}
.swipe-panel{
  width: 100vw;
  min-width: 100vw;
  max-width: 100vw;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  box-sizing: border-box;
  padding: 0 12px calc(var(--safeBot) + 78px);
}

/* =============== Pull to refresh =============== */
.feedContainer {
  position: relative;
  min-height: 100%;
}

.pullRefresh{
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: translateY(-60px);
  transition: none;
  pointer-events: none;
  z-index: 100;
}

.pull-spinner{
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--secondary_bg_color);
  color: var(--hint);
}

.pullRefresh.loading .pull-spinner{
  animation: spin 0.8s linear infinite;
}

@keyframes spin{
  to{ transform: rotate(360deg); }
}

/* =============== Feed / Gallery =============== */
.grid{
  /* Masonry layout */
}
.card{
  border-radius: 12px;
  overflow:hidden;
  background: var(--card);
  border: none;
  transform: translateZ(0);
  margin-bottom: 10px;
  width: calc(50% - 5px); /* 2 columns with 10px gap */
  cursor: pointer;
  box-shadow: 0 0.5px 0 0 rgba(0,0,0,0.04);
  transition: transform 0.15s, box-shadow 0.15s;
  position: relative;
}

.card:active{
  transform: scale(0.97);
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}

/* Loading spinner on card */
.card-loading-spinner{
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  border-radius: 12px;
}

.card-loading-spinner .spinner-circle{
  width: 32px;
  height: 32px;
  border: 3px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin{
  to{ transform: rotate(360deg); }
}

.imgWrap{
  position:relative;
  background: var(--secondary_bg_color);
  overflow:hidden;
}
.imgWrap img{
  width:100%; height:auto;
  object-fit:cover;
  display:block;
}
.imgWrap img.blurred{
  filter: blur(10px);
  transform: scale(1.1);
}
/* Градиент сверху */
.imgWrap::before{
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 60px;
  background: linear-gradient(to bottom, rgba(0,0,0,0.5) 0%, transparent 100%);
  pointer-events: none;
  z-index: 1;
}
.cardOverlay{
  position:absolute;
  left:0; right:0; bottom:0;
  padding: 50px 10px 10px;
  background: linear-gradient(to top, rgba(0,0,0,0.7) 0%, rgba(0,0,0,0.4) 50%, transparent 100%);
  pointer-events:none;
  z-index: 1;
}
.cardMeta{
  display:flex;
  flex-direction:column;
  gap:4px;
}
.cardMeta .uname{
  font-weight: 700;
  font-size: 13px;
  color: #ffffff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
  white-space: nowrap;
  overflow:hidden;
  text-overflow: ellipsis;
}
.cardMeta .hint{
  color: rgba(255,255,255,0.85);
  font-size: 11px;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

.badgeRow{
  position:absolute;
  left:10px; right:10px; top:10px;
  display:flex; align-items:center; justify-content:space-between;
  pointer-events:none;
  z-index: 2;
}
.tag{
  pointer-events:none;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #ffffff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}
.likes{
  pointer-events:none;
  display:flex; align-items:center; gap:4px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #ffffff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.likes i[data-lucide] {
  vertical-align: middle;
  flex-shrink: 0;
}

/* =============== Post detail modal =============== */
.modal{
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  background: var(--bg);
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.modal.active{
  display: block;
  animation: slideUp 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes slideUp{
  from{ transform: translateY(100%); }
  to{ transform: translateY(0); }
}

.modal-header{
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  background: color-mix(in srgb, var(--bg) 75%, transparent);
  border-bottom: 1px solid var(--sep);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-back-btn{
  background: none;
  border: none;
  color: var(--link);
  font-size: 17px;
  font-weight: 500;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  gap: 4px;
}

.modal-back-btn:active{
  opacity: 0.6;
}

.modal-title{
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.4px;
}

.modal-content{
  padding: 12px;
}

.panel{
  background: var(--card);
  border: 1px solid var(--sep);
  border-radius: var(--r2);
  overflow:hidden;
}

.postHead{
  padding: 12px;
  display:flex; align-items:center; justify-content:space-between;
  gap:10px;
  border-bottom: 1px solid var(--sep);
  background: var(--card);
}
.postUser{
  display:flex; align-items:center; gap:10px;
  min-width:0;
}
.postUser .avatar{ width: 36px; height: 36px; }
.postUser .uname{ font-size: 14px; }
.actions{
  display:flex; gap:8px; align-items:center;
}
.iconBtn{
  border: 1px solid var(--sep);
  background: var(--card);
  color: var(--text);
  border-radius: 999px;
  padding: 9px 12px;
  font-weight: 600;
  display:inline-flex; align-items:center; gap:8px;
  transition: transform var(--t), background var(--t), border-color var(--t), color var(--t);
  cursor: pointer;
}
.iconBtn:active{ transform: scale(.98); }
.iconBtn.active{
  background: color-mix(in srgb, var(--btn) 18%, var(--card));
  border-color: color-mix(in srgb, var(--btn) 35%, var(--sep));
}
.iconBtn.liked, .iconBtn.like-btn.liked {
  background: #fe2c55 !important;
  border-color: #fe2c55 !important;
  color: #fff !important;
}
.iconBtn.liked i, .iconBtn.like-btn.liked i {
  stroke: #fff !important;
  fill: #fff !important;
  color: #fff !important;
}
.iconBtn.liked svg, .iconBtn.like-btn.liked svg {
  stroke: #fff !important;
  fill: #fff !important;
  color: #fff !important;
}
.iconBtn.liked span, .iconBtn.like-btn.liked span {
  color: #fff !important;
}
.like-count {
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.like-count-display {
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Floating like button on image */
.floating-like-btn {
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.floating-like-btn:hover {
  transform: scale(1.05);
}
.floating-like-btn:active {
  transform: scale(0.92);
}
.floating-like-btn.liked {
  background: #fe2c55 !important;
  border-color: rgba(254, 44, 85, 0.3) !important;
  box-shadow: 0 0 20px rgba(254, 44, 85, 0.4) !important;
}
.floating-like-btn.liked i {
  fill: #fff !important;
  stroke: none !important;
}

/* Like animation (flying heart) */
.like-animation-heart {
  position: absolute;
  pointer-events: none;
  z-index: 999;
  will-change: transform, opacity;
}

@keyframes heartBeat {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0);
  }
  50% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1.2);
  }
}

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

.result{
  border-radius: var(--r2);
  overflow:hidden;
  border: 1px solid var(--sep);
  background:#111;
  min-height: 200px;
  /* aspect-ratio: 1/1; */
}
.result img{ width:100%; height:100%; object-fit:contain; display:block; }

.promptBox{
  padding: 12px;
  border-radius: var(--r2);
  border: 1px solid var(--sep);
  background: var(--card);
}
.promptTop{
  display:flex; align-items:center; justify-content:space-between;
  gap:10px;
  margin-bottom: 8px;
}
.promptTop .label{
  font-weight: 700;
  letter-spacing: .2px;
}
.copyBtn{
  border: 1px solid var(--sep);
  background: transparent;
  color: var(--text);
  padding: 7px 10px;
  border-radius: 999px;
  font-weight: 600;
  cursor: pointer;
}
.copyBtn:active{ transform: scale(.99); }
.promptText{
  color: color-mix(in oklab, var(--text) 92%, var(--hint));
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 13px;
  line-height: 1.35;
}

/* =============== Buy / packages =============== */
.packs{
  display:grid;
  grid-template-columns: repeat(2, 1fr);
  gap:10px;
  padding: 14px;
}
.pack{
  border-radius: var(--r2);
  border: 1.5px solid color-mix(in srgb, var(--text) 12%, transparent);
  background: var(--card);
  padding: 16px;
  display:flex;
  flex-direction: column;
  gap:12px;
  transition: transform var(--t), border-color var(--t), background var(--t);
  position: relative;
  cursor: pointer;
}
.pack:active{ transform: scale(.98); }
.pack.popular{
  border-color: color-mix(in srgb, var(--btn) 40%, transparent);
  background: var(--card);
}
.pack.popular::before{
  content: '⭐ Популярно';
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--btn);
  color: var(--btnText);
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.packHeader{
  display:flex;
  flex-direction: column;
  gap:6px;
  flex: 1;
}
.packGens{
  font-size: 28px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.5px;
}
.packLabel{
  font-size: 12px;
  color: var(--hint);
  font-weight: 600;
}
.packDesc{
  color: var(--hint);
  font-size: 11px;
  line-height: 1.3;
  margin-top: 4px;
}
.packFooter{
  display:flex;
  flex-direction: column;
  gap:6px;
  padding-top: 12px;
  border-top: 1px solid var(--sep);
}
.packPrice{
  display:flex;
  align-items: baseline;
  gap:8px;
}
.packNewPrice{ 
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.5px;
}
.packOldPrice{
  color: var(--hint);
  text-decoration: line-through;
  font-weight: 600;
  font-size: 14px;
}
.packSavings{
  font-size: 11px;
  color: var(--btn);
  font-weight: 600;
}

/* =============== Helpers =============== */
.spacer{ height: 4px; }
.sectionTitle{
  margin: 0 0 10px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: .2px;
  color: var(--text);
}

.toast{
  position: fixed;
  left: 50%;
  bottom: calc(var(--safeBot) + 40px);
  transform: translateX(-50%);
  background: var(--card);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--sep);
  opacity:0;
  pointer-events:none;
  transition: opacity var(--t2), transform var(--t2);
  z-index: 999;
  font-weight: 600;
}
.toast.show{
  opacity:1;
  transform: translateX(-50%) translateY(-2px);
}

/* =============== Custom Popup (Alert/Confirm) =============== */
.custom-popup-overlay{
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  padding: 20px;
}

.custom-popup-overlay.show{
  opacity: 1;
  pointer-events: auto;
}

.custom-popup{
  background: var(--card);
  border-radius: 16px;
  max-width: 300px;
  width: 100%;
  overflow: hidden;
  transform: scale(0.9);
  transition: transform 0.2s ease;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}

.custom-popup-overlay.show .custom-popup{
  transform: scale(1);
}

.custom-popup-title{
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  text-align: center;
  padding: 20px 20px 8px;
}

.custom-popup-title:empty{
  display: none;
}

.custom-popup-message{
  font-size: 14px;
  color: var(--hint);
  text-align: center;
  padding: 0 20px 20px;
  line-height: 1.4;
}

.custom-popup-buttons{
  display: flex;
  border-top: 0.5px solid var(--sep);
}

.custom-popup-buttons button{
  flex: 1;
  padding: 14px 16px;
  background: none;
  border: none;
  font-size: 17px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
  color: var(--link);
}

.custom-popup-buttons button:active{
  background: rgba(0,0,0,0.05);
}

.custom-popup-buttons button.primary{
  font-weight: 600;
}

.custom-popup-buttons button.destructive{
  color: var(--destructive);
}

.custom-popup-buttons button:not(:last-child){
  border-right: 0.5px solid var(--sep);
}

/* =============== Empty state =============== */
.empty-state{
  text-align: center;
  padding: 60px 24px;
  color: var(--hint);
  font-size: 14px;
}
.empty-icon{
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.5;
  display: flex;
  align-items: center;
  justify-content: center;
}

.empty-icon i[data-lucide] {
  opacity: 0.6;
}

/* =============== Payment modal =============== */
.payment-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2000;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.payment-modal.active {
  display: flex;
  align-items: flex-end;
  animation: fadeIn 0.2s;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.payment-content {
  width: 100%;
  background: var(--card);
  border: 1px solid var(--sep);
  border-radius: 20px 20px 0 0;
  padding: 8px 16px calc(16px + env(safe-area-inset-bottom));
  animation: slideUpModal 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.payment-content::before {
  content: '';
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: var(--sep);
  align-self: center;
  flex-shrink: 0;
}

@keyframes slideUpModal {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.payment-header {
  text-align: center;
}

.payment-package-name {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 4px;
  letter-spacing: -0.5px;
}

.payment-package-desc {
  font-size: 14px;
  color: var(--hint);
}

.payment-benefits {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.payment-benefit {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: color-mix(in srgb, var(--btn) 8%, transparent);
  border-radius: 12px;
}

.payment-benefit .benefit-icon {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  stroke: var(--btn);
}

.payment-benefit .benefit-text {
  flex: 1;
}

.payment-benefit .benefit-title {
  font-weight: 600;
  color: var(--text);
  font-size: 14px;
}

.payment-benefit .benefit-desc {
  font-size: 13px;
  color: var(--hint);
  margin-top: 2px;
}

.payment-price {
  text-align: center;
}

.payment-total-label {
  font-size: 13px;
  color: var(--hint);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

.payment-total-amount {
  font-size: 40px;
  font-weight: 800;
  color: var(--btn);
  letter-spacing: -1.5px;
  line-height: 1.1;
}

.payment-old-price {
  font-size: 16px;
  color: var(--hint);
  text-decoration: line-through;
  margin-top: 2px;
}

.payment-content .oferta-notice {
  padding: 0;
  margin: 0;
}

.payment-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.payment-pay-btn {
  width: 100%;
  background: var(--btn);
  color: var(--btnText);
  border: none;
  border-radius: 999px;
  padding: 14px 20px;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: -0.3px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.payment-pay-btn:active {
  opacity: 0.9;
  transform: translateY(1px) scale(.99);
}

.payment-cancel-btn {
  width: 100%;
  background: transparent;
  color: var(--link);
  border: none;
  padding: 10px 20px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
}

.payment-cancel-btn:active {
  opacity: 0.6;
}

/* =============== Profile =============== */
.profileTop{
  padding: 14px;
  display:flex;
  gap:12px;
  align-items:center;
  border-bottom: 1px solid var(--sep);
  background: var(--card);
}
.profileTop .avatar{ width: 56px; height: 56px; border-radius: 16px; }
.profileMeta{
  flex:1;
  min-width:0;
  display:flex;
  flex-direction:column;
  gap:4px;
}
.profileMeta .title{ font-size: 16px; }
.profileMeta .hint{ font-size: 12px; }
.stats{
  display:grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 12px;
}
.stat{
  border-radius: 14px;
  border: 1px solid var(--sep);
  background: var(--card);
  padding: 10px 12px;
  text-align:center;
}
.stat .n{ font-weight: 700; font-size: 16px; }
.stat .k{ color: var(--hint); font-size: 12px; margin-top: 2px; }

/* =============== Create Page =============== */
.inputsRow{
  display:flex;
  gap:10px;
  overflow:auto;
  padding-bottom: 2px;
  scrollbar-width:none;
}
.inputsRow::-webkit-scrollbar{ display:none; }
.thumb{
  flex: 0 0 auto;
  width: 86px; height: 86px;
  border-radius: 12px;
  overflow:hidden;
  border: 1px solid var(--sep);
  background: #111;
  position: relative;
}
.thumb img{ width:100%; height:100%; object-fit:cover; display:block; }
.thumb .removeBtn{
  position: absolute;
  top: 4px;
  right: 4px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(0,0,0,0.8);
  border: none;
  color: #fff;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.thumb .removeBtn:active{ transform: scale(0.9); }

.addPhotoBtn:active{ transform: scale(0.98); opacity: 0.8; }

/* Cell Radio for model selection */
.cell-radio {
  display:flex;
  align-items:center;
  justify-content:center;
  width:24px;
  height:24px;
  border-radius:50%;
  border:2px solid var(--sep);
  transition: all 0.2s;
}
.cell-radio i,
.cell-radio svg {
  opacity: 0;
  color: #fff;
  stroke: #fff;
  transition: opacity 0.2s;
}
.cell input[type="radio"]:checked ~ .cell-radio {
  background: var(--btn);
  border-color: var(--btn);
}
.cell input[type="radio"]:checked ~ .cell-radio i,
.cell input[type="radio"]:checked ~ .cell-radio svg {
  opacity: 1;
}


/* =============== Footer Tabs (iOS Liquid Glass) =============== */
.bottom{
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  
  /* Полноширочный blur-слой — покрывает всё до края экрана включая safe area */
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  background: color-mix(in srgb, var(--tg-theme-bg-color, #000) 40%, transparent);
  
  padding: 8px 5% calc(8px + var(--safeBot));
}

.tabs{
  display: flex;
  justify-content: space-around;
  align-items: center;
  height: 49px;
  position: relative;
  touch-action: pan-x;
  -webkit-user-select: none;
  user-select: none;
  
  /* Pill visual — скруглённая форма на .tabs */
  border-radius: 100px;
  background: color-mix(in srgb, var(--tg-theme-bg-color, #000) 35%, transparent);
  border: 0.33px solid color-mix(in srgb, var(--tg-theme-section-separator-color, #fff) 12%, transparent);
  box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.08);
}

/* Плавающий индикатор под активной вкладкой */
.tabs::before{
  content: '';
  position: absolute;
  width: calc((100% / 4) - 8px);
  height: calc(100% - 4px); /* Адаптивно под высоту tabs */
  border-radius: 50px;
  background: color-mix(in srgb, var(--tg-theme-text-color, #fff) 8%, transparent);
  left: 5px;
  top: 50%;
  transform: translateY(-50%);
  transition: left 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
  pointer-events: none;
  z-index: 0;
}

/* Web mode - больше высота tabs для отступов */
.web-mode .tabs {
  height: 56px;
  padding: 4px 0;
  border-radius: 100px;
}

/* Позиции индикатора для каждой вкладки */
.tab:nth-child(1).active ~ .tabs::before,
.tabs:has(.tab:nth-child(1).active)::before{
  left: 4px;
}

.tab:nth-child(2).active ~ .tabs::before,
.tabs:has(.tab:nth-child(2).active)::before{
  left: calc((100% / 4) + 4px);
}

.tab:nth-child(3).active ~ .tabs::before,
.tabs:has(.tab:nth-child(3).active)::before{
  left: calc((100% / 4 * 2) + 4px);
}

.tab:nth-child(4).active ~ .tabs::before,
.tabs:has(.tab:nth-child(4).active)::before{
  left: calc((100% / 4 * 3) + 4px);
}

.tab{
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  padding: 0;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--tg-theme-hint-color, #8e8e93);
  font-size: 10px;
  font-weight: 500;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  position: relative;
  z-index: 1;
}

.tab.active{
  color: var(--tg-theme-accent-text-color, #007AFF);
}

.tab .ico{
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1px;
}

.tab .ico svg{
  width: 25px;
  height: 25px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  transition: opacity 0.15s ease;
}

.tab:not(.active) .ico svg{
  opacity: 0.85;
}

.tab:active{
  opacity: 0.4;
  transition: opacity 0s;
}


/* =============== Result modal image =============== */
.postImage {
  max-width: 100%;
  width: 100%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r);
}

.postImage img {
  max-width: 100%;
  max-height: 70vh;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
  border-radius: var(--r);
}

.modalContent {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--bg);
}

.resultImageContainer {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  overflow: hidden;
}

.resultImageContainer img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
}

.resultActions {
  background: var(--bg);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-top: 1px solid var(--sep);
}

.resultActions button {
  width: 100%;
  padding: 16px;
  border-radius: 10px;
  font-size: 17px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s ease;
}

.resultActions button:active {
  transform: scale(0.98);
  opacity: 0.8;
}

.resultActions .primaryBtn {
  background: var(--btn);
  color: #fff;
  border: none;
}

.resultActions .secondaryBtn {
  background: var(--sep);
  color: var(--btn);
  border: none;
}

.resultActions button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.postInfo {
  padding: 12px 16px;
  background: var(--bg);
}

.postCaption {
  font-size: 15px;
  line-height: 1.4;
  color: var(--label);
  margin-bottom: 8px;
}

.postPrompt {
  font-size: 13px;
  line-height: 1.3;
  color: var(--label2);
  padding: 8px 12px;
  background: var(--bg2);
  border-radius: 8px;
}

/* =============== Preloader =============== */
.preloader {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 1;
  transition: opacity 0.3s ease;
}

.preloader.hidden {
  opacity: 0;
  pointer-events: none;
}

.preloader-spinner {
  width: 48px;
  height: 48px;
  border: 3px solid var(--sep);
  border-top-color: var(--btn);
  border-radius: 50%;
  animation: spinner 0.8s linear infinite;
}

@keyframes spinner {
  to {
    transform: rotate(360deg);
  }
}

.btn-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spinner 0.6s linear infinite;
  display: inline-block;
  vertical-align: middle;
  margin-right: 8px;
}

.skeleton-img {
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, var(--card) 0%, var(--sep) 50%, var(--card) 100%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s ease-in-out infinite;
}

@keyframes skeleton-loading {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* =============== Credits Notification (Confetti Popup) =============== */
#credits-notification {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  opacity: 0;
  transition: opacity 0.3s ease;
  padding: 20px;
}

#credits-notification.active {
  opacity: 1;
}

.credits-content {
  background: var(--card);
  border-radius: var(--r2);
  padding: 48px 32px;
  text-align: center;
  max-width: 400px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  transform: scale(0.9);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#credits-notification.active .credits-content {
  transform: scale(1);
}

.credits-icon {
  width: 80px;
  height: 80px;
  margin: 0 auto 24px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: pulse 2s ease-in-out infinite;
}

.credits-icon i {
  width: 48px;
  height: 48px;
  stroke: #fff;
  stroke-width: 2;
}

@keyframes pulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
}

.credits-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 24px;
}

.credits-amount {
  font-size: 72px;
  font-weight: 900;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1;
  margin-bottom: 8px;
}

.credits-label {
  font-size: 18px;
  color: var(--hint);
  font-weight: 500;
  margin-bottom: 32px;
}

.credits-close {
  width: 100%;
  padding: 16px;
  background: var(--btn);
  color: var(--btnText);
  border: none;
  border-radius: var(--r);
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.credits-close:active {
  opacity: 0.7;
}

/* =============== Auth Screen =============== */
#auth-screen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--bg);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 20px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.auth-back-btn {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 12px);
  left: 12px;
  z-index: 10;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--card);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.auth-container {
  width: 100%;
  max-width: 360px;
  text-align: center;
  padding: 40px 0;
}

.auth-logo {
  width: 80px;
  height: 80px;
  margin: 0 auto 16px;
  background: linear-gradient(135deg, var(--link) 0%, #764ba2 100%);
  border-radius: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
}

.auth-title {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 8px;
}

.auth-subtitle {
  font-size: 15px;
  color: var(--hint);
  margin: 0 0 32px;
}

.auth-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
  background: var(--card);
  border-radius: var(--r);
  padding: 4px;
}

.auth-tab {
  flex: 1;
  padding: 10px 16px;
  background: transparent;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 500;
  color: var(--hint);
  cursor: pointer;
  transition: all 0.2s;
}

.auth-tab.active {
  background: var(--bg);
  color: var(--text);
}

.auth-form {
  margin-bottom: 24px;
  position: relative;
  z-index: 10;
}

.auth-field {
  margin-bottom: 12px;
  text-align: left;
}

.auth-field input {
  width: 100%;
  padding: 14px 16px;
  background: var(--card);
  border: 1px solid var(--sep);
  border-radius: var(--r);
  font-size: 16px;
  color: var(--text);
  transition: border-color 0.2s;
}

.auth-field input:focus {
  border-color: var(--link);
}

.auth-field input::placeholder {
  color: var(--hint);
}

.auth-hint {
  display: block;
  font-size: 12px;
  color: var(--hint);
  margin-top: 4px;
  padding-left: 4px;
}

.auth-error {
  color: var(--destructive);
  font-size: 14px;
  margin-bottom: 12px;
  min-height: 20px;
}

.auth-btn {
  width: 100%;
  padding: 14px 24px;
  border: none;
  border-radius: var(--r);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-decoration: none;
}

.auth-btn.primary {
  background: var(--btn);
  color: var(--btnText);
}

.auth-btn.primary:hover {
  opacity: 0.9;
}

.auth-btn.primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.auth-btn.vk {
  background: #0077FF;
  color: #fff;
  margin-bottom: 12px;
}

.auth-btn.vk:hover {
  background: #0066dd;
}

.auth-divider {
  display: flex;
  align-items: center;
  margin: 24px 0;
  color: var(--hint);
  font-size: 14px;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--sep);
}

.auth-divider span {
  padding: 0 16px;
}

.auth-social {
  margin-bottom: 24px;
}

.auth-telegram-link {
  padding: 16px;
  background: var(--card);
  border-radius: var(--r);
  font-size: 14px;
  color: var(--hint);
}

.auth-telegram-link p {
  margin: 0;
  line-height: 1.6;
}

.auth-telegram-link a {
  color: var(--link);
  font-weight: 500;
}

/* VK ID Widget Container */
.vk-auth-container {
  margin-bottom: 8px;
  min-height: 44px;
  display: flex;
  justify-content: center;
  position: relative;
  z-index: 1;
}

/* Desktop Screen - Only Mobile */
#desktop-screen {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 9999;
}

.desktop-container {
  width: 100%;
  max-width: 400px;
  text-align: center;
}

.desktop-logo {
  width: 80px;
  height: 80px;
  margin: 0 auto 20px;
  background: linear-gradient(135deg, var(--link) 0%, #764ba2 100%);
  border-radius: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
}

.desktop-title {
  font-size: 32px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 12px;
}

.desktop-subtitle {
  font-size: 18px;
  color: var(--text);
  margin: 0 0 8px;
  font-weight: 500;
}

.desktop-hint {
  font-size: 15px;
  color: var(--hint);
  margin: 0 0 32px;
}

.desktop-qr {
  background: #fff;
  border-radius: 16px;
  padding: 16px;
  display: inline-block;
  margin-bottom: 16px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.1);
}

.desktop-qr img {
  display: block;
  border-radius: 8px;
}

.desktop-url {
  font-size: 14px;
  color: var(--hint);
  margin: 0 0 40px;
  font-family: monospace;
}

.desktop-telegram {
  padding-top: 24px;
  border-top: 1px solid var(--sep);
}

.desktop-telegram p {
  font-size: 14px;
  color: var(--hint);
  margin: 0 0 12px;
}

.desktop-tg-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  background: #0088cc;
  color: #fff;
  border-radius: 12px;
  text-decoration: none;
  font-size: 15px;
  font-weight: 600;
  transition: background 0.2s;
}

.desktop-tg-btn:hover {
  background: #0077b5;
}

/* =============== Auth Prompts (inline) =============== */
/* Для страницы создания */
.auth-prompt-create {
  /* Без отступов - кнопка на всю ширину родителя */
}

.auth-prompt-create .auth-prompt-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px 16px;
  font-size: 16px;
  font-weight: 600;
  border-radius: 12px;
}

.auth-prompt-hint {
  font-size: 13px;
  color: var(--hint);
  margin: 8px 0 0;
  text-align: center;
}

/* Для страницы профиля и вкладки подписок */
.profile-auth-prompt,
.subscriptions-auth-prompt,
.subscriptions-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 24px;
  text-align: center;
}

.profile-auth-content {
  max-width: 280px;
}

.profile-auth-icon {
  color: var(--hint);
  margin-bottom: 20px;
}

.profile-auth-title {
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 12px;
  color: var(--text);
}

.profile-auth-text {
  font-size: 15px;
  color: var(--hint);
  margin: 0 0 24px;
  line-height: 1.4;
}

.profile-auth-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px 24px;
  font-size: 16px;
  font-weight: 600;
  border-radius: 12px;
}

.profile-auth-hint {
  font-size: 13px;
  color: var(--hint);
  margin: 12px 0 0;
}

/* Для страницы пакетов */
.auth-prompt-packages {
  text-align: center;
  padding: 60px 20px;
}

.auth-prompt-packages .auth-prompt-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  max-width: 320px;
  padding: 14px 24px;
  font-size: 16px;
  font-weight: 600;
}

.auth-prompt-icon {
  width: 80px;
  height: 80px;
  margin: 0 auto 20px;
  background: color-mix(in srgb, var(--link) 12%, transparent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-prompt-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 8px;
}

.auth-prompt-text {
  font-size: 15px;
  color: var(--hint);
  margin: 0 0 24px;
  line-height: 1.5;
}

/* =============== PWA Install Prompt =============== */
.pwa-prompt {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.pwa-prompt.show {
  opacity: 1;
  pointer-events: auto;
}

.pwa-prompt-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
}

.pwa-prompt-content {
  position: relative;
  background: var(--card);
  border-radius: 20px 20px 0 0;
  padding: 24px;
  padding-top: 32px;
  padding-bottom: calc(24px + env(safe-area-inset-bottom));
  max-width: 420px;
  width: 100%;
  transform: translateY(100%);
  transition: transform 0.3s ease;
  user-select: none;
  -webkit-user-select: none;
}

.pwa-prompt.show .pwa-prompt-content {
  transform: translateY(0);
}

/* Полоска вверху (как на iOS) */
.pwa-prompt-handle {
  width: 36px;
  height: 5px;
  background: var(--hint);
  opacity: 0.3;
  border-radius: 3px;
  margin: 0 auto 20px;
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
}

.pwa-prompt-title {
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 8px;
  text-align: center;
  color: var(--text);
}

.pwa-prompt-text {
  font-size: 15px;
  color: var(--hint);
  margin: 0 0 20px;
  text-align: center;
  line-height: 1.4;
}

.pwa-prompt-steps {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 24px;
}

.pwa-prompt-step {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  color: var(--text);
  flex-wrap: wrap;
}

.pwa-prompt-step-num {
  width: 24px;
  height: 24px;
  background: var(--btn);
  color: var(--btnText);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
}

.pwa-prompt-step strong {
  font-weight: 600;
}

.pwa-share-icon {
  color: var(--btn);
  flex-shrink: 0;
}

.pwa-menu-icon {
  color: var(--hint);
  flex-shrink: 0;
}

.pwa-prompt-btn {
  width: 100%;
  padding: 14px 24px;
  background: var(--btn);
  color: var(--btnText);
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}

/* =============== Rules Chip =============== */
.rules-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: color-mix(in srgb, var(--btn) 12%, transparent);
  color: var(--btn);
  border: none;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}
.rules-chip:active {
  background: color-mix(in srgb, var(--btn) 22%, transparent);
}

/* =============== Bottom Sheet (rules, etc.) =============== */
.bottom-sheet {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}
.bottom-sheet.show {
  opacity: 1;
  pointer-events: auto;
}
.bottom-sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.5);
}
.bottom-sheet-content {
  position: relative;
  background: var(--card);
  border-radius: 20px 20px 0 0;
  padding: 24px;
  padding-top: 32px;
  padding-bottom: calc(24px + env(safe-area-inset-bottom));
  max-width: 420px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform 0.3s ease;
  user-select: none;
  -webkit-user-select: none;
  -webkit-overflow-scrolling: touch;
}
.bottom-sheet.show .bottom-sheet-content {
  transform: translateY(0);
}
.bottom-sheet-handle {
  width: 36px;
  height: 5px;
  background: var(--hint);
  opacity: 0.3;
  border-radius: 3px;
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
}
.bottom-sheet-title {
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 16px;
  text-align: center;
  color: var(--text);
}
.bottom-sheet-section {
  margin-bottom: 16px;
}
.bottom-sheet-section-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--btn);
  margin: 0 0 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.bottom-sheet-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.bottom-sheet-list li {
  position: relative;
  padding: 4px 0 4px 20px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
}
.bottom-sheet-list li::before {
  content: '';
  position: absolute;
  left: 4px;
  top: 11px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--hint);
  opacity: 0.5;
}
.bottom-sheet-note {
  font-size: 13px;
  color: var(--hint);
  text-align: center;
  line-height: 1.5;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 0.5px solid var(--sep);
}

/* =============== Toggle Switch =============== */
.toggle {
  position: relative;
  display: inline-block;
  width: 51px;
  height: 31px;
  flex-shrink: 0;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle .slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--sep);
  border-radius: 31px;
  transition: 0.3s;
}

.toggle .slider::before {
  position: absolute;
  content: "";
  height: 27px;
  width: 27px;
  left: 2px;
  bottom: 2px;
  background-color: white;
  border-radius: 50%;
  transition: 0.3s;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.toggle input:checked + .slider {
  background-color: var(--accent);
}

.toggle input:checked + .slider::before {
  transform: translateX(20px);
}

.toggle input:disabled + .slider {
  opacity: 0.5;
  cursor: not-allowed;
}