@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&display=swap');

:root {
  /* Тёмная тема (по умолчанию) */
  --bg-root: #0a0a0a;
  --bg-surface: #141414;
  --bg-surface-elevated: #1f1f1f;
  
  --text-primary: #ffffff;
  --text-secondary: rgba(255, 255, 255, 0.6);
  --text-muted: rgba(255, 255, 255, 0.3);
  
  --accent-color: #6366f1; /* Мягкий индиго */
  --accent-hover: #4f46e5;
  --accent-rgb: 99, 102, 241;
  --color-error: #ef4444; /* Мягкий красный */
  --text-sm: 13px;

  --spacing-1: 4px;
  --spacing-2: 8px;
  --spacing-3: 12px;
  --spacing-4: 16px;
  --spacing-5: 20px;
  --spacing-6: 24px;
  --spacing-8: 32px;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.1);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.1);

  --tabbar-height: 64px;
  --app-height: 100vh;

  /* tg-content-safe-area-inset-top = зона под хромом Telegram (не включает safe area iOS) */
  /* tg-safe-area-inset-top = iOS safe area (без хрома Telegram) */
  --tg-chrome-top: var(--tg-content-safe-area-inset-top, 0px);
  --tg-device-top: var(--tg-safe-area-inset-top, env(safe-area-inset-top, 0px));
  --safe-top: calc(var(--tg-chrome-top) + var(--tg-device-top) + 12px);
  --raw-safe-bottom: var(--tg-content-safe-area-inset-bottom, var(--tg-safe-area-inset-bottom, env(safe-area-inset-bottom, 0px)));
  --safe-bottom: var(--raw-safe-bottom);
  /* tabbar-height + отступ капсулы (12px) + зазор под контент */
  --content-bottom: calc(var(--tabbar-height) + var(--safe-bottom) + 28px);

  /* Тосты — выше push-экранов, таб-бара и bottom-sheet */
  --z-toast: 10050;
}

[data-theme="light"] {
  /* Светлая тема (заготовка) */
  --bg-root: #f8fafc;
  --bg-surface: #ffffff;
  --bg-surface-elevated: #f1f5f9;
  
  --text-primary: #0f172a;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  
  --accent-color: #4f46e5;
  --accent-hover: #4338ca;
  --color-error: #dc2626;
}

/* Base Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent; /* Убирает синюю область при нажатии на мобильных устройствах */
}

html, body {
  height: 100%;
  overscroll-behavior: none;
  -webkit-overflow-scrolling: touch;
}

body {
  font-family: 'Inter', sans-serif;
  background-color: #000; /* Внешний фон для десктопов, где app по центру */
  color: var(--text-primary);
  display: flex;
  justify-content: center;
  min-height: var(--app-height);
  margin: 0;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Контейнер Mini App */
#app {
  width: 100%;
  max-width: 430px;
  height: -webkit-fill-available;
  height: var(--app-height);
  max-height: var(--app-height);
  background-color: var(--bg-root);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  overscroll-behavior: none;
}

/* Экраны */
.screen {
  display: none;
  padding: calc(var(--safe-top) + var(--spacing-5)) var(--spacing-4) var(--content-bottom) var(--spacing-4);
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
  z-index: 10;
  overflow-y: auto;
  overflow-x: hidden;
  box-sizing: border-box;
  -webkit-overflow-scrolling: touch;
  -ms-overflow-style: none;  /* Скрываем scrollbar в IE/Edge */
  scrollbar-width: none;  /* Скрываем scrollbar в Firefox */
}

.screen::-webkit-scrollbar {
  display: none; /* Скрываем scrollbar в Chrome/Safari/Webkit */
}

.screen.active {
  display: block;
}

/* Типографика базовая */
h2 {
  font-size: 24px;
  font-weight: 600;
  margin-bottom: var(--spacing-4);
  color: var(--text-primary);
}

p {
  color: var(--text-secondary);
  line-height: 1.5;
}

/* Оставшаяся дебаг-панель */
#debug-panel {
  background: var(--bg-surface-elevated);
  border-radius: var(--radius-md);
  padding: var(--spacing-4);
  display: flex;
  flex-direction: column;
  gap: var(--spacing-2);
  margin-top: var(--spacing-6);
  border: 1px solid rgba(255,255,255,0.05);
}

#debug-panel h3 {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
  color: var(--text-primary);
}

#debug-panel div {
  font-size: 13px;
  color: var(--text-secondary);
  word-break: break-all;
}

#api-result {
  color: var(--accent-color) !important;
  font-family: monospace;
  font-size: 12px;
  min-height: 20px;
}

button {
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  color: inherit;
  border: none;
  border-radius: 0;
  padding: 0;
  margin: 0;
  font: inherit;
  font-weight: inherit;
  cursor: pointer;
  align-self: auto;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
}

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

button:focus,
button:focus-visible {
  outline: none;
}

#debug-panel button {
  background: var(--accent-color);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 500;
  align-self: flex-start;
}


/* =========================================
   FEED SCREEN
   ========================================= */

.feed-top {
  position: sticky;
  top: 0;
  z-index: 100;
  flex-shrink: 0;
}

.feed-header {
  margin: 0;
  padding: calc(var(--safe-top) + 8px) var(--spacing-4) 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(14, 14, 16, 0.72);
  backdrop-filter: blur(12px) saturate(1.2);
  -webkit-backdrop-filter: blur(12px) saturate(1.2);
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.feed-header .balance-pill {
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.feed-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-placeholder {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--text-primary);
}

.balance-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  background: rgba(255, 255, 255, 0.08);
  border: none;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  padding: 0 12px;
  border-radius: var(--radius-full);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transform: translateZ(0);
}

.balance-icon {
  color: #fbbf24;
  font-size: 14px;
}

.feed-gallery {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  contain: layout style;
}

.feed-skeleton {
  opacity: 0.3;
}

.feed-empty {
  text-align: center;
  color: var(--text-muted);
  padding: var(--spacing-8) var(--spacing-4);
  font-size: 14px;
}

.feed-card {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;
  border-radius: 20px;
  border: none;
  overflow: hidden;
  box-shadow: 0 4px 14px -4px rgba(0, 0, 0, 0.45);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  content-visibility: auto;
  contain-intrinsic-size: auto 260px;
  contain: layout style paint;
}

.card-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 30px 10px 10px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.95) 0%, rgba(0, 0, 0, 0.7) 40%, rgba(0, 0, 0, 0) 100%);
  display: flex;
  flex-direction: column;
  gap: 4px;
  pointer-events: none;
}

.card-title {
  font-size: 11px;
  font-weight: 600;
  color: #ffffff;
  margin: 0;
  padding: 0 2px;
  line-height: 1.25;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  gap: 8px;
}

.popularity {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: rgba(0, 0, 0, 0.48);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-full);
  padding: 0 8px 0 7px;
  height: 26px;
  pointer-events: none;
  box-sizing: border-box;
  flex-shrink: 1;
  min-width: 0;
}

.pop-icon {
  width: 10px;
  height: 10px;
  flex-shrink: 0;
  color: rgba(255, 255, 255, 0.65);
}

.pop-val {
  font-size: 11px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.92);
  letter-spacing: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-generate {
  pointer-events: auto;
  min-width: 48px;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.9);
  color: #000;
  border: none;
  padding: 0 10px;
  height: 26px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 4px;
  box-sizing: border-box;
}

.price-icon {
  font-size: 10px;
  color: #000;
  opacity: 0.8;
}

.btn-generate:active {
  background: #ffffff;
  transform: scale(0.96);
}

.card-author {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 10;
  background: rgba(0, 0, 0, 0.45);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-full);
  color: rgba(255, 255, 255, 0.9);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.01em;
  padding: 0 8px;
  height: 22px;
  display: flex;
  align-items: center;
  pointer-events: none;
  max-width: calc(100% - 44px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  box-sizing: border-box;
}

.btn-favorite {
  position: absolute;
  top: 3px;
  right: 0;
  background: transparent;
  border: none;
  width: 32px;
  height: 32px;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  z-index: 10;
  padding: 0;
  transition: transform 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.btn-favorite:active {
  transform: scale(0.85);
}

.heart-icon {
  width: 18px;
  height: 18px;
  fill: rgba(0,0,0,0.2);
  stroke: #ffffff;
  stroke-width: 2;
  transition: fill 0.2s ease, stroke 0.2s ease;
}

.btn-favorite.active .heart-icon {
  fill: #f43f5e;
  stroke: #f43f5e;
}


/* =========================================
   CHARACTERS SCREEN
   ========================================= */

.char-header {
  position: sticky;
  top: calc(-1 * (var(--safe-top) + var(--spacing-5)));
  margin: calc(-1 * (var(--safe-top) + var(--spacing-5))) calc(-1 * var(--spacing-4)) var(--spacing-6);
  padding: calc(var(--safe-top) + 24px) var(--spacing-4) 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(15, 15, 17, 0.65);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 100;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.char-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
  letter-spacing: -0.02em;
}

.btn-add-char {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  color: var(--text-primary);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  padding: 0;
}

.btn-add-char:active {
  transform: scale(0.9);
  background: rgba(255, 255, 255, 0.15);
}

.icon-plus {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

.char-list {
  display: flex;
  flex-direction: column;
}

.char-item {
  display: flex;
  align-items: center;
  padding: 16px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  cursor: pointer;
  transition: opacity 0.2s;
}

.char-item:active {
  opacity: 0.7;
}

.char-item:last-of-type {
  border-bottom: none;
}

.char-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* CSS-классы для градиентов аватаров, чтобы избежать инлайн-стилей */
.avatar-1 { background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%); }
.avatar-2 { background: linear-gradient(135deg, #ff758c 0%, #ff7eb3 100%); }
.avatar-3 { background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%); }
.avatar-4 { background: linear-gradient(135deg, #fa709a 0%, #fee140 100%); }
.avatar-5 { background: linear-gradient(135deg, #a18cd1 0%, #fbc2eb 100%); }

/* Инициал имени в аватаре */
.char-avatar-initial {
  font-size: 20px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.9);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  pointer-events: none;
  user-select: none;
  line-height: 1;
}
.char-avatar-initial.sm {
  font-size: 14px;
}

/* Пустой стейт списка персонажей */
.char-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 48px 24px 24px;
  gap: 12px;
}
.char-empty-icon {
  width: 56px;
  height: 56px;
  color: var(--text-muted);
  opacity: 0.5;
}
.char-empty-icon svg {
  width: 100%;
  height: 100%;
}
.char-empty-text {
  font-size: 15px;
  color: var(--text-muted);
  text-align: center;
}

/* Пустой стейт карусели */
.carousel-empty {
  padding: 16px 20px;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.35);
  white-space: nowrap;
}

.char-info {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  margin: 0 16px;
  gap: 2px;
}

.char-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.char-name {
  font-size: 17px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.char-badge {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.char-desc {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.char-desc.empty {
  color: var(--text-muted);
  font-style: italic;
}

.char-stats {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  margin-top: 2px;
}

.char-chevron-icon {
  width: 20px;
  height: 20px;
  stroke: var(--text-muted);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
  flex-shrink: 0;
  opacity: 0.5;
}

.char-ghost {
  display: flex;
  align-items: center;
  padding: 16px;
  border: 1px dashed rgba(255, 255, 255, 0.15);
  border-radius: 20px;
  margin-top: 8px;
  cursor: pointer;
  transition: all 0.2s;
  background: rgba(255, 255, 255, 0.02);
  width: 100%;
  text-align: left;
  font-family: inherit;
  outline: none;
  -webkit-tap-highlight-color: transparent;
  color: inherit;
}

.char-ghost * {
  pointer-events: none;
}

.char-ghost:active {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.3);
}

.ghost-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.05);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.ghost-avatar .icon-plus {
  stroke: var(--text-secondary);
}

.char-ghost .char-info {
  justify-content: center;
}

.char-ghost .char-name {
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 16px;
}

.char-ghost--locked {
  border-style: solid;
  border-color: rgba(255, 106, 0, 0.35);
  background: rgba(255, 106, 0, 0.05);
}
.char-ghost--locked:active {
  background: rgba(255, 106, 0, 0.1);
  border-color: rgba(255, 106, 0, 0.55);
}
.ghost-avatar--lock {
  background: rgba(255, 106, 0, 0.12);
}
.ghost-avatar--lock svg {
  stroke: #ff8c42;
}
.char-ghost--locked .char-name {
  color: #ff8c42;
}
.char-ghost--locked .char-desc {
  display: block;
  font-size: 12px;
  color: rgba(255, 140, 66, 0.7);
  margin-top: 2px;
}

/* =========================================
   CHARACTER LIMIT UPSELL SHEET
   ========================================= */

.char-limit-content {
  align-items: center;
  text-align: center;
  gap: 20px;
}

.char-limit-icon {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: rgba(255, 106, 0, 0.1);
  border: 1px solid rgba(255, 106, 0, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ff8c42;
  flex-shrink: 0;
  margin-top: 4px;
}

.char-limit-text {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.char-limit-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
  letter-spacing: -0.3px;
  line-height: 1.2;
}

.char-limit-sub {
  font-size: 14px;
  line-height: 1.55;
  color: var(--text-secondary);
  margin: 0;
}

.char-limit-cta {
  background: linear-gradient(135deg, #ff6a00 0%, #ee0979 100%);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  width: 100%;
  padding: 16px;
  border-radius: var(--radius-lg);
  border: none;
  cursor: pointer;
  transition: transform 0.15s, opacity 0.15s;
  font-family: inherit;
  letter-spacing: -0.2px;
}

.char-limit-cta:active {
  transform: scale(0.97);
  opacity: 0.9;
}

/* =========================================
   ADD/EDIT CHAR SCREEN (Push over)
   ========================================= */

.push-screen {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg-root);
  z-index: 200;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateX(100%);
  transition: transform 0.4s cubic-bezier(0.32, 0.72, 0, 1);
  will-change: transform;
}

.push-screen.active {
  transform: translateX(0);
}

.push-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  align-items: center;
  padding: calc(var(--safe-top) + 14px) 20px 14px;
  background: rgba(15, 15, 17, 0.65);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  z-index: 100;
  min-height: calc(var(--safe-top) + 60px);
}

.push-header > .icon-btn {
  justify-self: start;
  margin-left: -4px;
}

.push-header > .push-title {
  justify-self: center;
}

.push-header > .text-btn {
  justify-self: end;
}

.icon-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-primary);
  padding: 0;
  cursor: pointer;
  flex-shrink: 0;
}

.push-title {
  font-size: 17px;
  font-weight: 600;
  margin: 0;
  color: var(--text-primary);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.text-btn {
  background: rgba(var(--accent-rgb), 0.12);
  border: 1px solid rgba(var(--accent-rgb), 0.3);
  color: var(--accent-color);
  font-size: var(--text-sm);
  font-weight: 500;
  padding: 6px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 150ms;
  white-space: nowrap;
}

.text-btn:active:not(:disabled) {
  opacity: 0.85;
}

.text-btn:disabled {
  opacity: 0.35;
  pointer-events: none;
  cursor: default;
}

/* "Готово" в активном состоянии */
#btn-save-char:not(:disabled),
#btn-edit-char.mode-done {
  background: var(--accent-color);
  color: #fff;
  border-color: transparent;
}

.push-content {
  flex: 1;
  padding: calc(var(--safe-top) + 76px) 20px calc(var(--safe-bottom, 0px) + 24px);
  display: flex;
  flex-direction: column;
  gap: 32px;
  overflow-y: auto;
  overflow-x: hidden;
  touch-action: pan-y;
  min-height: 0;
}

/* Photo upload */
.photo-upload-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
}

.photo-circle {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  overflow: hidden;
  position: relative;
  background: linear-gradient(135deg, #a18cd1 0%, #fbc2eb 100%);
  transition: all 0.2s;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1);
}

.photo-circle:active {
  transform: scale(0.96);
}

.photo-circle.has-photo {
  background: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
  background-size: cover;
  background-position: center;
}

.photo-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: rgba(255, 255, 255, 0.9);
}

.photo-circle.has-photo .photo-empty {
  display: none;
}

.photo-circle.uploading::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
}

.photo-circle.uploading::before {
  content: '';
  position: absolute;
  width: 28px;
  height: 28px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: photo-spin 0.7s linear infinite;
  z-index: 1;
}

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

.photo-empty svg {
  width: 28px;
  height: 28px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.5;
}

.photo-empty span {
  font-size: 12px;
  font-weight: 500;
}

.photo-hint {
  font-size: 12px;
  color: var(--text-muted);
}

/* Edit mode photo overlay */
.photo-edit-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}

.photo-edit-overlay svg {
  width: 32px;
  height: 32px;
  color: #fff;
}

.is-editing .photo-edit-overlay {
  opacity: 1;
  pointer-events: auto;
}

/* Form fields / View mode */
.form-fields {
  display: flex;
  flex-direction: column;
  gap: 24px;
  flex: 1;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
}

/* View text vs Input */
.view-text, .input-line {
  width: 100%;
  font-family: inherit;
  font-size: 16px;
  color: var(--text-primary);
  line-height: 1.4;
}

.input-line {
  background: transparent;
  border: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
  padding: 8px 0;
  transition: border-color 0.3s, opacity 0.2s;
  display: none;
}

.view-text {
  padding: 9px 0;
  white-space: pre-wrap;
  transition: opacity 0.2s;
}

.view-text.empty {
  color: var(--text-muted);
  font-style: italic;
}

.input-line:focus {
  outline: none;
  border-bottom-color: var(--accent-color);
}

.input-line::placeholder {
  color: rgba(255, 255, 255, 0.3);
}

.large-field {
  font-size: 24px;
  font-weight: 600;
}

.input-line.large-field {
  padding: 4px 0 12px;
}

.input-line.auto-resize {
  resize: none;
  overflow: hidden;
  min-height: 38px;
  max-height: 112px;
}

/* Описание персонажа — placeholder на 2 строки, читаемо на узких экранах */
#add-char-desc,
#vc-input-desc {
  min-height: 52px;
}

#add-char-desc::placeholder,
#vc-input-desc::placeholder {
  line-height: 1.35;
  white-space: normal;
}

@media (max-width: 380px) {
  #add-char-desc::placeholder,
  #vc-input-desc::placeholder {
    font-size: 14px;
  }
}

.input-line.auto-resize:focus {
  overflow-y: auto;
}

.field-hint {
  font-size: 12px;
  color: var(--text-muted);
  display: none;
}

/* Edit Mode Toggles */
.is-editing .input-line,
.is-editing .field-hint {
  display: block;
  animation: fadeIn 0.2s ease;
}

.is-editing .view-text {
  display: none;
}

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

/* Delete section */
.delete-section {
  margin-top: auto;
  padding-top: var(--spacing-6);
  padding-bottom: var(--spacing-4);
  display: flex;
  align-items: center;
  gap: var(--spacing-3);
  color: var(--color-error);
  cursor: pointer;
  opacity: 0.75;
  transition: opacity 0.15s;
  user-select: none;
  -webkit-user-select: none;
}

.delete-section:active {
  opacity: 1;
}

.delete-section svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.delete-text {
  font-size: 15px;
  font-weight: 500;
}

/* Confirm Delete Sheet */
.confirm-sheet {
  max-height: 44vh;
}

.confirm-content {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 8px 0 4px;
}

.confirm-text-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: center;
  padding: 0 8px;
}

.confirm-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
  line-height: 1.4;
}

.confirm-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0;
}

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

.btn-danger {
  background: var(--color-error);
  color: #fff;
  font-size: 16px;
  font-weight: 500;
  width: 100%;
  padding: 16px;
  border-radius: var(--radius-lg);
  border: none;
  cursor: pointer;
  transition: transform 0.15s;
  font-family: inherit;
}

.btn-danger:active {
  transform: scale(0.97);
}

.btn-ghost {
  background: transparent;
  color: var(--text-primary);
  font-size: 16px;
  font-weight: 500;
  width: 100%;
  padding: 16px;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(255, 255, 255, 0.15);
  cursor: pointer;
  transition: border-color 0.15s;
  font-family: inherit;
}

.btn-ghost:active {
  border-color: rgba(255, 255, 255, 0.3);
}

.app-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  z-index: 300;
}

.app-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.bottom-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-height: 92vh;
  background: #0f0f11;
  border-radius: 24px 24px 0 0;
  z-index: 310;
  transform: translateY(100%);
  transition: transform 0.4s cubic-bezier(0.32, 0.72, 0, 1);
  display: flex;
  flex-direction: column;
  box-shadow: none;
}

.bottom-sheet.active {
  transform: translateY(0);
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.5);
}

.sheet-handle-wrap {
  width: 100%;
  padding: 16px 0 10px;
  min-height: 44px;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.sheet-handle {
  width: 36px;
  height: 4px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 2px;
}

.sheet-content {
  padding: 0 20px calc(env(safe-area-inset-bottom, 0) + 24px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 24px;
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.sheet-content::-webkit-scrollbar {
  display: none;
}

/* =========================================
   GENERATE SHEET SPECIFICS
   ========================================= */

/* Gen screen header */
.gen-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  min-height: calc(var(--safe-top) + 56px);
  padding: var(--safe-top) 16px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 15, 17, 0.5);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  z-index: 22;
}

.gen-header .icon-btn {
  position: absolute;
  left: 16px;
  background: transparent;
  color: #ffffff;
  width: auto;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 0;
  transform: translateY(2px);
}

.gen-header .push-title {
  color: #ffffff;
  font-weight: 600;
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
  margin: 0;
  padding: 0;
  width: auto;
}

.gen-header-author {
  font-size: 13px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.85);
  letter-spacing: 0.01em;
}

.gen-header-author-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.05);
  padding: 6px 14px;
  border-radius: 9999px;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  outline: none;
  margin: 0 auto;
}

.gen-header-author-btn:active {
  background: rgba(255, 255, 255, 0.15);
  transform: scale(0.96);
}

.gen-banner {
  width: 100%;
  aspect-ratio: 1 / 1;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
  border-radius: 0 0 var(--radius-xl) var(--radius-xl);
  touch-action: pan-y;
  user-select: none;
  min-height: unset;
}

.gen-banner-slider {
  display: flex;
  width: 100%;
  height: 100%;
  transition: transform 0.3s ease;
}

.gen-banner-slide {
  flex: 0 0 100%;
  width: 100%;
  height: 100%;
  background-size: cover;
  background-position: center top;
  background-repeat: no-repeat;
}

.gen-banner-dots {
  position: absolute;
  bottom: 20px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  gap: 6px;
  z-index: 2;
}

.gen-banner-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.4);
  transition: all 0.3s ease;
}

.gen-banner-dot.active {
  background: #ffffff;
  transform: scale(1.33);
}

.gen-banner-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.78) 0%, rgba(0,0,0,0.15) 55%, transparent 100%);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 20px;
  gap: 4px;
}

.gen-banner-title {
  font-size: 22px;
  font-weight: 700;
  color: #fff;
  margin: 0;
  line-height: 1.25;
}

.gen-banner-meta {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.6);
  margin: 0;
}

/* Gen scroll area */
.gen-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: calc(var(--safe-top, 0px) + 56px) 0 calc(var(--safe-bottom, 0px) + 90px);
  touch-action: pan-y;
  -ms-overflow-style: none;
  scrollbar-width: none;
  min-height: 0;
}

.gen-scroll::-webkit-scrollbar {
  display: none;
}

#history-scroll {
  padding-top: calc(var(--safe-top, 0px) + 60px);
  padding-bottom: calc(var(--safe-bottom, 0px) + 16px);
}

.gen-section {
  padding: 0 20px;
}

.section-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 12px;
}

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

.slot-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px dashed rgba(255, 255, 255, 0.15);
  transition: background 0.08s ease, border-color 0.2s;
  cursor: pointer;
  position: relative;
  z-index: 10;
  pointer-events: auto;
}

.slot-item:active {
  background: rgba(255, 255, 255, 0.06);
}

.slot-item.filled {
  border-style: solid;
  border-color: rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.05);
}

.slot-item.drag-over {
  border-color: var(--accent-color);
  background: rgba(79, 70, 229, 0.1);
}

.slot-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.slot-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 12px;
  color: var(--text-muted);
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1);
}

.slot-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* .slot-role removed */

.slot-name {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-primary);
}

.slot-icon {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: rgba(255, 255, 255, 0.3);
}

.slot-icon svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.char-carousel-wrap {
  margin: 0 -20px;
  padding: 0 20px;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.char-carousel-wrap::-webkit-scrollbar {
  display: none;
}

.char-carousel {
  display: flex;
  gap: 16px;
  padding-bottom: 8px;
  width: max-content;
}

.carousel-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 64px;
  cursor: grab;
}

.carousel-item:active {
  cursor: grabbing;
}

.carousel-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1);
}

.carousel-item--add {
  cursor: pointer;
  background: transparent;
  border: none;
  padding: 0;
  margin: 0;
  font-family: inherit;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

.carousel-item--add * {
  pointer-events: none;
}

.carousel-item--add:active {
  cursor: pointer;
}

.carousel-avatar--add {
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(99, 102, 241, 0.1); /* rgba(var(--accent-rgb), 0.1) */
  border: 1px dashed rgba(99, 102, 241, 0.4);
  color: var(--accent-color, #6366f1);
  box-shadow: none;
  transition: background 0.2s, border-color 0.2s;
}

.carousel-item--add:active .carousel-avatar--add {
  opacity: 0.9;
}

.carousel-name {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  text-align: center;
  width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gen-footer {
  position: absolute;
  bottom: calc(var(--safe-bottom, 0px) + 16px);
  left: 0;
  right: 0;
  margin: 0 16px;
  background: transparent;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 25;
}

.gen-footer .btn-primary {
  border-radius: 999px;
  height: 54px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  background: #ffffff;
  color: #000000;
  width: 100%;
  border: none;
  cursor: pointer;
  transition: transform 0.2s;
}

.gen-footer .btn-primary:active {
  transform: scale(0.97);
}

.btn-primary {
  background: #ffffff;
  color: #000000;
  font-size: 16px;
  font-weight: 700;
  width: 100%;
  padding: 16px;
  border-radius: 16px;
  border: none;
  cursor: pointer;
  transition: transform 0.2s;
}

.btn-primary:active {
  transform: scale(0.97);
}

.gen-hint {
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
  margin: 0;
}

/* =========================================
   CHAR PICKER SHEET
   ========================================= */

.picker-sheet {
  max-height: 70vh;
}

.picker-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 20px 16px;
}

.picker-title {
  font-size: 18px;
  font-weight: 600;
  margin: 0;
  color: var(--text-primary);
}

.picker-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 0;
  flex-shrink: 0;
}

.mp-list {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 0 20px calc(env(safe-area-inset-bottom, 0) + 24px);
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.mp-list::-webkit-scrollbar {
  display: none;
}

.mp-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  cursor: pointer;
}

.mp-item:last-child {
  border-bottom: none;
}

.mp-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1);
}

.mp-avatar--create {
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(99, 102, 241, 0.1);
  border: 1px dashed rgba(99, 102, 241, 0.4);
  color: var(--accent-color, #6366f1);
  box-shadow: none;
}

.mp-item--create {
  background: transparent;
  border: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

.mp-item--create * {
  pointer-events: none;
}

/* =========================================
   QUEUE INDICATOR
   ========================================= */

.queue-indicator {
  position: fixed;
  bottom: calc(
    max(
      env(safe-area-inset-bottom, 0px),
      var(--tg-safe-area-inset-bottom, 0px)
    ) + 100px
  );
  left: 50%;
  transform: translateX(-50%) translateY(24px);
  background: rgba(20, 20, 22, 0.65);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 18px;
  height: 36px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 80;
  opacity: 0;
  transition: transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1),
              opacity 0.35s ease;
  cursor: pointer;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.55);
  user-select: none;
  max-width: calc(100vw - 48px);
}

.queue-indicator.active {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.qi-spinner {
  width: 16px;
  height: 16px;
  min-width: 16px;
  min-height: 16px;
  flex-shrink: 0;
  border: 2px solid rgba(255, 255, 255, 0.18);
  border-top-color: rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  animation: qi-spin 0.85s linear infinite;
}

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

.qi-text {
  font-size: 13px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.92);
  letter-spacing: -0.01em;
  white-space: nowrap;
}

/* =========================================
   IOS 26 TOAST (Gen Ready)
   ========================================= */

.gen-ready-toast {
  position: fixed;
  top: calc(var(--safe-top) + 12px);
  left: 16px;
  right: 16px;
  z-index: var(--z-toast);
  touch-action: none;
  background: rgba(28, 28, 30, 0.82);
  backdrop-filter: blur(24px) saturate(160%);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 18px;
  padding: 12px 16px;
  display: none;
  align-items: center;
  gap: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  transform: translateY(-110%) scale(0.9);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
}

.gen-ready-toast.visible {
  transform: translateY(0) scale(1);
  opacity: 1;
  pointer-events: auto;
}

.grt-icon-wrap {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
}

.grt-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.grt-title {
  font-size: 14px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.95);
  line-height: 1.2;
}

.grt-sub {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.5);
  line-height: 1.2;
  margin-top: 2px;
}

/* =========================================
   RETRY TOAST (censorship / liquid glass)
   ========================================= */
.gen-retry-toast {
  position: fixed;
  top: calc(var(--safe-top) + 12px);
  left: 16px;
  right: 16px;
  z-index: var(--z-toast);
  touch-action: none;
  background: linear-gradient(145deg,
    rgba(255, 200, 70, 0.13) 0%,
    rgba(255, 140, 20, 0.07) 100%);
  backdrop-filter: blur(44px) saturate(190%) brightness(1.08);
  -webkit-backdrop-filter: blur(44px) saturate(190%) brightness(1.08);
  border: 1px solid rgba(255, 210, 90, 0.22);
  border-top-color: rgba(255, 230, 120, 0.35);
  border-radius: 20px;
  padding: 12px 18px 13px;
  display: none;
  flex-direction: column;
  gap: 3px;
  box-shadow:
    0 1px 0 rgba(255, 240, 160, 0.12) inset,
    0 8px 32px rgba(0, 0, 0, 0.38),
    0 2px 8px rgba(255, 180, 40, 0.08);
  transform: translateY(-110%) scale(0.96);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.38s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.26s ease;
}

.gen-retry-toast.visible {
  transform: translateY(0) scale(1);
  opacity: 1;
  pointer-events: auto;
}

.grt-warn-title {
  font-size: 13.5px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.95);
  line-height: 1.25;
  letter-spacing: -0.01em;
}

.grt-warn-sub {
  font-size: 12px;
  font-weight: 400;
  color: rgba(255, 210, 100, 0.72);
  line-height: 1.25;
  letter-spacing: -0.005em;
}

/* =========================================
   EMAIL PROMPT MODAL
   ========================================= */
.email-prompt-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding-top: 15vh;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.email-prompt-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.email-prompt-modal {
  background: var(--bg-surface);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  width: 90%;
  max-width: 360px;
  padding: 24px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
  transform: translateY(20px) scale(0.95);
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.email-prompt-overlay.active .email-prompt-modal {
  transform: translateY(0) scale(1);
}

.email-prompt-header {
  text-align: center;
  margin-bottom: 20px;
}

.email-prompt-header h3 {
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 8px;
  color: var(--text-primary);
}

.email-prompt-header p {
  font-size: 14px;
  color: var(--text-secondary);
  margin: 0;
  line-height: 1.4;
}

.email-prompt-body {
  margin-bottom: 24px;
}

.email-prompt-body .email-input {
  display: block;
  width: 100%;
  box-sizing: border-box;
  text-align: center;
  font-size: 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 12px 16px;
  color: var(--text-primary);
  transition: border-color 0.2s, background 0.2s;
}

.email-prompt-body .email-input:focus {
  outline: none;
  border-color: var(--accent-color);
  background: rgba(255, 255, 255, 0.08);
}

.email-prompt-error {
  color: #ff4d4f;
  font-size: 13px;
  text-align: center;
  margin-top: 8px;
}

.email-prompt-actions {
  display: flex;
  gap: 12px;
}

.email-prompt-actions button {
  flex: 1;
}

/* =========================================
   HISTORY SCREEN
   ========================================= */

.history-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
  padding: 0;
}

.history-card {
  position: relative;
  aspect-ratio: 1 / 1;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  cursor: pointer;
  width: 100%;
  content-visibility: auto;
  contain-intrinsic-size: auto 160px;
  overflow: hidden;
}

.history-skeleton {
  display: contents;
}

.history-skel-card {
  aspect-ratio: 1 / 1;
  background: rgba(255, 255, 255, 0.05);
  animation: pulse-bg 1.5s infinite;
}

.history-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

@keyframes pulse-bg {
  0% { background: rgba(255, 255, 255, 0.03); }
  50% { background: rgba(255, 255, 255, 0.08); }
  100% { background: rgba(255, 255, 255, 0.03); }
}

.history-card-pending {
  animation: pulse-bg 1.5s infinite;
  cursor: default;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 8px;
}

.history-card-pending .pending-label {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.35);
  letter-spacing: 0.3px;
  text-align: center;
}

.history-card-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
}

.history-card-error .gen-error-emoji {
  font-size: 48px;
  line-height: 1;
}

.history-card-error .gen-error-label {
  font-size: 11px;
  color: #666;
  letter-spacing: 0.2px;
  text-align: center;
  padding: 0 8px;
  line-height: 1.3;
}

.history-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 40px 20px;
  color: var(--text-secondary);
  color: rgba(255,255,255,0.35);
  font-size: 14px;
  line-height: 1.5;
}


/* =========================================
   GLASS CAPSULE PREMIUM UI (Navbar)
   ========================================= */

.capsule-wrapper {
  position: fixed;
  left: 50%;
  bottom: calc(var(--safe-bottom) + 12px);
  transform: translateX(-50%);
  width: min(430px, calc(100vw - 32px));
  height: var(--tabbar-height);
  z-index: 150;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

/* Скрываем таб-бар на push-экранах и viewer (fixed поверх #app) */
body:has(.push-screen.active) .capsule-wrapper {
  opacity: 0;
  pointer-events: none;
}

.capsule-container {
  pointer-events: auto;
  width: 100%;
  height: 100%;
  border-radius: 9999px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.35); /* Сделали более прозрачным (было 0.6) */
  backdrop-filter: blur(24px) saturate(1.2);
  -webkit-backdrop-filter: blur(24px) saturate(1.2);
  box-shadow: 
    inset 0 0 10px rgba(255, 255, 255, 0.3),
    inset 0 0 30px rgba(255, 255, 255, 0.2),
    inset 0 0 50px rgba(255, 255, 255, 0.1);
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 0 10px;
  box-sizing: border-box;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: none;
  user-select: none;
  color: rgba(255, 255, 255, 0.3);
  flex: 1;
  height: 100%;
  position: relative;
  padding-top: 4px;
  gap: 2px;
}

.nav-item.active {
  color: rgba(255, 255, 255, 1);
}

.icon-wrapper {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: none;
}

.nav-item.active .icon-wrapper {
  transform: scale(1.1);
  filter: drop-shadow(0 0 15px rgba(255, 255, 255, 0.4));
}

.nav-icon {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-text {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  opacity: 0.4;
  transition: none;
}

.nav-item.active .nav-text {
  opacity: 1;
  font-weight: 600;
}

@media (max-width: 480px) {
  :root {
    --tabbar-height: 60px;
  }
}


/* =========================================
   PROFILE SCREEN
   ========================================= */

#screen-profile {
  padding: var(--spacing-4) var(--spacing-4) calc(var(--content-bottom) + 8px) var(--spacing-4);
  gap: var(--spacing-4);
}

#screen-profile.active {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
}

#screen-profile::-webkit-scrollbar {
  display: none;
}

/* --- Group label --- */
.profile-group-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 0 var(--spacing-1);
  margin-bottom: calc(-1 * var(--spacing-2));
}

/* --- Base card --- */
.profile-card {
  background: var(--bg-surface);
  border-radius: var(--radius-xl);
  border: 1px solid rgba(255, 255, 255, 0.07);
  padding: var(--spacing-5);
  display: flex;
  flex-direction: column;
  gap: var(--spacing-4);
}

/* --- Hero block --- */
.profile-hero {
  background: radial-gradient(circle at top left, rgba(var(--accent-rgb), 0.12), var(--bg-surface) 70%);
  border-radius: var(--radius-xl);
  border: 1px solid rgba(255, 255, 255, 0.07);
  padding: calc(var(--safe-top) + var(--spacing-5)) var(--spacing-5) var(--spacing-5);
  display: flex;
  flex-direction: column;
  gap: var(--spacing-5);
}

.profile-user-row {
  display: flex;
  align-items: center;
  gap: var(--spacing-4);
}

.profile-settings-btn {
  margin-left: auto;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.12);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.6);
  cursor: pointer;
  transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.profile-settings-btn svg {
  width: 20px !important;
  height: 20px !important;
  min-width: 20px !important;
  min-height: 20px !important;
  display: block;
}

.profile-settings-btn:active {
  background: rgba(255, 255, 255, 0.22);
}

.profile-avatar-wrap {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  padding: 1px;
  background: linear-gradient(135deg, rgba(79, 172, 254, 0.5) 0%, rgba(0, 242, 254, 0.5) 100%);
  flex-shrink: 0;
}

.profile-avatar {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.9);
}

.profile-user-meta {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.profile-username {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.profile-userid {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.02em;
  background: rgba(255, 255, 255, 0.06);
  padding: 2px 8px;
  border-radius: 999px;
  display: inline-block;
  align-self: flex-start;
}

/* ---- Credit / authorship username ---- */
.profile-credit-wrap {
  position: relative;
}

.profile-credit-row {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 40px;
}

.profile-credit-field {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  padding: 0 4px 0 14px;
  height: 40px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: border-color 0.2s;
}

.profile-credit-field:focus-within {
  border-color: rgba(255, 255, 255, 0.22);
}

.credit-at {
  font-size: 15px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.35);
  flex-shrink: 0;
  user-select: none;
  pointer-events: none;
  line-height: 1;
}

.credit-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 15px;
  font-weight: 500;
  font-family: inherit;
  letter-spacing: -0.01em;
  padding: 0 6px;
  min-width: 0;
  -webkit-appearance: none;
  appearance: none;
}

.credit-input::placeholder {
  color: rgba(255, 255, 255, 0.18);
  font-weight: 400;
}

.credit-save-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  align-self: center;
  transition: background 0.15s, opacity 0.2s;
  color: rgba(255, 255, 255, 0.85);
  -webkit-tap-highlight-color: transparent;
}

.credit-save-btn svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.credit-save-btn:active {
  background: rgba(255, 255, 255, 0.22);
}

.credit-save-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.credit-help-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.12);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  align-self: center;
  color: rgba(255, 255, 255, 0.6);
  transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.credit-help-btn svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  display: block;
}

.credit-help-btn:active {
  background: rgba(255, 255, 255, 0.15);
}

.credit-tooltip {
  display: none;
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 8px);
  background: rgba(22, 22, 26, 0.97);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  padding: 14px 16px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
  z-index: 50;
  animation: credit-tooltip-in 0.18s ease;
}

@keyframes credit-tooltip-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.credit-tooltip.visible {
  display: block;
}

.credit-tooltip p {
  margin: 0;
  font-size: 13px;
  line-height: 1.55;
  color: rgba(255, 255, 255, 0.7);
}

.credit-tooltip-earn {
  margin-top: 10px !important;
  color: rgba(255, 255, 255, 0.45) !important;
  font-size: 12px !important;
}

/* Card author attribution */
.card-author {
  font-size: 11px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.42);
  letter-spacing: 0.02em;
}

/* --- Balance card --- */
.profile-balance-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacing-3);
}

.profile-balance-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.profile-balance-amount {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.profile-balance-star {
  color: #fbbf24;
  font-size: 22px;
}

.profile-balance-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
}

.profile-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.07);
  margin: 0 calc(-1 * var(--spacing-5));
}

.profile-sub-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacing-3);
}

.profile-sub-status {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
}

/* Accent button */
.btn-profile-accent {
  background: var(--accent-color);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 10px 20px;
  font-size: var(--text-sm);
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.15s, background 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
  min-width: 120px;
  text-align: center;
}

.btn-profile-accent:active {
  transform: scale(0.95);
}

/* Ghost pill button */
.btn-profile-ghost {
  background: transparent;
  color: var(--accent-color);
  border: 1px solid var(--accent-color);
  border-radius: 999px;
  padding: 10px 20px;
  font-size: var(--text-sm);
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
  min-width: 120px;
  text-align: center;
}

.btn-profile-ghost:active {
  opacity: 0.85;
}

/* --- Generations card --- */
.profile-gens-card {
  flex-direction: row;
  align-items: center;
  gap: var(--spacing-4);
  cursor: pointer;
  transition: opacity 0.15s;
  padding: var(--spacing-4) var(--spacing-5);
}

.profile-gens-card:active {
  opacity: 0.7;
}

.gens-preview-stack {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.gen-preview-sq {
  width: 28px;
  height: 36px;
  border-radius: 6px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1);
}

.gens-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.gens-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.gens-meta {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

.profile-chevron-icon {
  width: 18px;
  height: 18px;
  stroke: var(--text-muted);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
  flex-shrink: 0;
  opacity: 0.5;
}

/* --- Action cards grid --- */
.profile-actions-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--spacing-3);
  align-items: stretch;
}

.profile-action-card {
  border-radius: var(--radius-xl);
  border: 1px solid rgba(255, 255, 255, 0.07);
  padding: var(--spacing-4);
  display: flex;
  flex-direction: column;
  cursor: pointer;
  transition: opacity 0.15s;
  min-height: 160px;
}

.profile-action-card:active {
  opacity: 0.65;
}

.action-scene {
  background: linear-gradient(to top, rgba(30, 27, 75, 0.4), var(--bg-surface));
}

.action-referral {
  background: linear-gradient(to top, rgba(69, 26, 3, 0.4), var(--bg-surface));
}

.action-card-top {
  display: flex;
  margin-bottom: var(--spacing-3);
}

.action-scene .action-icon-wrap {
  background: rgba(var(--accent-rgb), 0.2);
  color: var(--accent-color);
}

.action-referral .action-icon-wrap {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
}

.action-icon-wrap {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.action-card-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex-grow: 1;
}

.action-card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.action-card-meta {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  line-height: 1.3;
}

.action-card-bottom {
  margin-top: var(--spacing-3);
}

.action-pill {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 999px;
  display: inline-block;
}

/* --- List cards (settings, help) --- */
.profile-list-card {
  gap: 0;
  padding: 0;
  overflow: hidden;
}

.profile-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--spacing-4) var(--spacing-5);
  gap: var(--spacing-3);
  cursor: pointer;
  transition: background 0.12s;
}

.profile-list-item:active {
  background: rgba(255, 255, 255, 0.04);
}

.pli-left {
  display: flex;
  align-items: center;
  gap: var(--spacing-3);
  flex: 1;
  min-width: 0;
}

.pli-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: var(--text-muted);
}

.pli-label {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-primary);
}

.pli-chevron {
  opacity: 0.35;
}

.pli-separator {
  height: 1px;
  background: rgba(255, 255, 255, 0.06);
  margin: 0 var(--spacing-5);
}

/* --- Theme toggle --- */
.profile-toggle {
  width: 44px;
  height: 26px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.1);
  position: relative;
  cursor: pointer;
  transition: background 0.25s;
  flex-shrink: 0;
  padding: 0;
}

.profile-toggle.active {
  background: var(--accent-color);
  border-color: transparent;
}

.toggle-knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.profile-toggle.active .toggle-knob {
  transform: translateX(18px);
}

#theme-toggle {
  pointer-events: none;
  cursor: default;
}

/* --- Support card --- */
.profile-support-card {
  background: var(--bg-surface);
  border-radius: var(--radius-xl);
  border: 1px solid rgba(255, 255, 255, 0.07);
  padding: 0 var(--spacing-5);
  height: 76px;
  display: flex;
  align-items: center;
  gap: var(--spacing-4);
  cursor: pointer;
  transition: opacity 0.15s;
}

.profile-support-card:active {
  opacity: 0.7;
}

.support-icon-wrap {
  width: 24px;
  height: 24px;
  color: rgba(255, 255, 255, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

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

.support-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.support-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.support-meta {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

/* --- Legal card --- */
.legal-card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.legal-card .pli-label {
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 400;
}

.legal-card .profile-list-item {
  padding: var(--spacing-3) var(--spacing-5);
}

.profile-diag-link {
  display: block;
  width: 100%;
  margin-top: var(--spacing-1);
  margin-bottom: var(--spacing-2);
  padding: var(--spacing-4) 0 var(--spacing-3);
  flex-shrink: 0;
  border: none;
  background: none;
  font-size: 11px;
  font-weight: 400;
  color: var(--text-muted);
  opacity: 0.45;
  text-align: center;
  cursor: pointer;
  letter-spacing: 0.02em;
  -webkit-tap-highlight-color: transparent;
}

.profile-diag-link:active {
  opacity: 0.65;
}

.legal-card .pli-chevron {
  opacity: 0.2;
}

/* --- Toast --- */
.profile-toast {
  position: fixed;
  bottom: calc(var(--tabbar-height) + var(--safe-bottom) + 20px);
  left: 50%;
  max-width: min(92vw, 360px);
  transform: translateX(-50%) translateY(8px);
  background: rgba(30, 30, 35, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  padding: 10px 20px;
  border-radius: var(--radius-full);
  white-space: normal;
  text-align: center;
  line-height: 1.35;
  z-index: var(--z-toast);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.profile-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* =========================================
   MANUAL GEN SCREEN
   ========================================= */

.btn-manual-gen {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.13);
  padding: 0 13px 0 10px;
  color: rgba(255, 255, 255, 0.85);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  letter-spacing: -0.01em;
  white-space: nowrap;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.18s, background 0.18s;
  -webkit-tap-highlight-color: transparent;
}
.btn-manual-gen svg {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
  opacity: 0.75;
}
.btn-manual-gen:active {
  transform: scale(0.94);
  background: rgba(255, 255, 255, 0.13);
}

.manual-gen-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-4);
  padding: calc(var(--safe-top, 0px) + 60px) 20px calc(var(--safe-bottom, 0px) + 90px);
  touch-action: pan-y;
  -ms-overflow-style: none;
  scrollbar-width: none;
  min-height: 0;
}
.manual-gen-scroll::-webkit-scrollbar {
  display: none;
}

.manual-section {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-3);
  position: relative;
}

.manual-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.4);
}

.manual-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.manual-counter {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}

/* Model Select */
.model-select {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
}
.model-select-value {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-primary);
}
.model-select-chevron {
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  transition: transform 0.2s;
}
.model-select-chevron.rotated {
  transform: rotate(180deg);
}

.model-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--bg-surface-elevated);
  border-radius: var(--radius-lg);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  max-height: 250px;
  overflow-y: auto;
  display: none;
  flex-direction: column;
  padding: 4px 0;
}
.model-dropdown.open {
  display: flex;
}
.model-group-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: rgba(255, 255, 255, 0.4);
  padding: 14px 16px 6px;
  text-transform: uppercase;
}
.model-group-label:first-child {
  padding-top: 10px;
}
.model-option {
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: background 0.15s;
}
.model-option:active {
  background: rgba(255, 255, 255, 0.04);
}
.radio-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
}
.model-option.active .radio-dot {
  border-color: var(--accent-color);
}
.model-option.active .radio-dot::after {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-color);
}
.model-option span {
  font-size: 15px;
  color: var(--text-primary);
}
.model-group-sub-badge {
  display: inline-block;
  background: linear-gradient(90deg, #ff6a00, #ee0979);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 1px 5px;
  border-radius: 4px;
  vertical-align: middle;
  margin-left: 4px;
  text-transform: uppercase;
}
.model-option--sub span {
  background: linear-gradient(90deg, #ff9a3c, #ff4e7e);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* References */
.ref-row {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding: 8px 8px 4px 0;
  margin-top: -8px;
  -ms-overflow-style: none;
  scrollbar-width: none;
}
.ref-row::-webkit-scrollbar {
  display: none;
}
.ref-btn {
  width: 72px;
  height: 72px;
  border-radius: var(--radius-lg);
  border: 1px dashed rgba(255, 255, 255, 0.2);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  flex-shrink: 0;
  color: var(--text-secondary);
  transition: background 0.15s;
}
.ref-btn:active {
  background: rgba(255, 255, 255, 0.05);
}
.ref-btn--soon {
  opacity: 0.35;
  cursor: default;
}
.ref-btn--soon:active {
  background: none;
}
.ref-btn svg {
  width: 20px;
  height: 20px;
}
.ref-btn span {
  font-size: 10px;
  font-weight: 500;
}
.ref-preview {
  width: 72px;
  height: 72px;
  border-radius: var(--radius-lg);
  background-size: cover;
  background-position: center;
  flex-shrink: 0;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1);
  position: relative;
}
.ref-preview.char-slot {
  display: flex;
  align-items: center;
  justify-content: center;
}
.ref-preview.char-slot .slot-avatar {
  width: 100%;
  height: 100%;
  border-radius: var(--radius-lg);
}
.ref-remove-btn {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 20px;
  height: 20px;
  background: var(--color-error, #ef4444);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0,0,0,0.5);
  z-index: 5;
  transition: transform 0.15s;
}
.ref-remove-btn:active {
  transform: scale(0.9);
}
.ref-remove-btn svg {
  width: 12px;
  height: 12px;
  stroke-width: 2.5;
}

/* Prompt Textarea */
.manual-textarea {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-family: inherit;
  font-size: 15px;
  color: var(--text-primary);
  line-height: 1.4;
  resize: none;
  width: 100%;
  transition: border-color 0.2s;
}
.manual-textarea:focus {
  outline: none;
  border-color: rgba(255, 255, 255, 0.2);
}
.manual-textarea::placeholder {
  color: rgba(255, 255, 255, 0.3);
}

/* Params Row */
.manual-params-row {
  display: flex;
  gap: 16px;
  justify-content: flex-start;
  flex-wrap: wrap;
}
.manual-param-block {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-3);
  position: relative;
}

.qty-control {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  padding: 6px 12px;
  border: none;
  width: 90px;
  height: 36px;
  box-sizing: border-box;
}
.qty-btn {
  width: 24px;
  height: 24px;
  border: none;
  background: transparent;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 500;
  cursor: pointer;
  padding: 0;
  transition: opacity 0.15s;
}
.qty-btn:active {
  opacity: 0.5;
}
.qty-val {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  text-align: center;
  min-width: 20px;
}

.aspect-select-compact {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  padding: 6px 12px;
  border: none;
  cursor: pointer;
  height: 36px;
  width: 90px;
  box-sizing: border-box;
}
.aspect-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}
.aspect-select-compact span {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  text-align: center;
  min-width: 36px;
}
.aspect-dropdown-compact {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  background: var(--bg-surface-elevated);
  border-radius: var(--radius-lg);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  display: none;
  flex-direction: column;
  z-index: 100;
  min-width: 120px;
  overflow: hidden;
}
.aspect-dropdown-compact.open {
  display: flex;
}
.aspect-option {
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  text-align: center;
}
.aspect-option:last-child {
  border-bottom: none;
}
.aspect-option:active {
  background: rgba(255, 255, 255, 0.04);
}

/* Footer */
.manual-footer {
  position: absolute;
  bottom: calc(var(--safe-bottom, 0px) + 16px);
  left: 16px;
  right: 16px;
  z-index: 25;
}
.manual-cost {
  margin-left: 6px;
  opacity: 0.8;
}

/* Type Switch (Image/Video) */
.type-switch-container {
  flex-shrink: 0;
  padding-top: 4px;
  padding-bottom: 4px;
  display: flex;
  justify-content: center;
}

#manual-img-content {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-4);
}

/* Воздух над заголовками секций (не первой) */
#manual-img-content > .manual-section:not(:first-child),
#manual-img-content > .manual-params-row {
  padding-top: var(--spacing-4);
}

.type-switch {
  display: flex;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 99px;
  padding: 4px;
  position: relative;
  width: 100%;
  max-width: 240px;
  -webkit-tap-highlight-color: transparent;
}
.type-switch button {
  flex: 1;
  padding: 8px 16px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.3s ease;
  z-index: 2;
  -webkit-tap-highlight-color: transparent;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}
.type-switch button:focus,
.type-switch button:focus-visible {
  outline: none;
}
.type-switch button:active {
  background: transparent;
}
.type-switch button.active {
  color: var(--bg-root);
}
.type-switch .glider {
  position: absolute;
  top: 4px;
  left: 4px;
  height: calc(100% - 8px);
  width: calc(50% - 4px);
  background: var(--text-primary);
  border-radius: 99px;
  transition: transform 0.4s cubic-bezier(0.68, -0.55, 0.27, 1.55);
  z-index: 1;
}

/* Video Stub */
.manual-stub {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
  color: var(--color-text-muted);
  height: 100%;
  min-height: 300px;
}
.manual-stub svg {
  width: 48px;
  height: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}
.manual-stub h3 {
  color: var(--color-text);
  font-size: 18px;
  margin-bottom: 8px;
  font-weight: 600;
}
.manual-stub p {
  font-size: 14px;
  line-height: 1.5;
}

/* =========================================
   IMMERSIVE VIEWER SCREEN (iOS 26 Style)
   ========================================= */

.viewer-screen {
  background: #000000;
  display: flex;
  flex-direction: column;
  color: #ffffff;
}

.viewer-top-chrome {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: calc(var(--safe-top) + 12px) 16px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 10;
  background: linear-gradient(180deg, rgba(0,0,0,0.5) 0%, rgba(0,0,0,0) 100%);
  pointer-events: none;
}

.viewer-top-chrome > * {
  pointer-events: auto;
}

.viewer-icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(12px) saturate(180%);
  -webkit-backdrop-filter: blur(12px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.9);
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
  padding: 0;
}

.viewer-icon-btn:active {
  background: rgba(255, 255, 255, 0.18);
  transform: scale(0.92);
}

.viewer-meta {
  font-size: 13px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.6);
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
  letter-spacing: 0.02em;
}

.viewer-body {
  flex: 1;
  overflow: hidden;
  position: relative;
  z-index: 1;
  touch-action: none;
}

#viewer-error-overlay {
  display: none;
  position: absolute;
  inset: 0;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 28px;
  text-align: center;
  gap: 8px;
}

#viewer-error-overlay.active {
  display: flex;
}

.viewer-error-emoji {
  font-size: 52px;
  line-height: 1;
}

.viewer-error-label {
  font-size: 13px;
  color: #666;
  margin: 0;
  line-height: 1.4;
  max-width: 280px;
}

.viewer-track {
  display: flex;
  width: 100%;
  height: 100%;
  align-items: center;
  will-change: transform;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.viewer-slide {
  flex: 0 0 100%;
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 0 12px;
  box-sizing: border-box;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}


.viewer-bottom-chrome {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 24px 20px calc(var(--safe-bottom, 0px) + 24px);
  display: flex;
  gap: 12px;
  z-index: 10;
  background: transparent;
  pointer-events: none;
}

.viewer-bottom-chrome > * {
  pointer-events: auto;
}

.viewer-capsule-secondary {
  flex: 1;
  height: 54px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #ffffff;
  font-size: 16px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.2s, background 0.2s;
  box-shadow: 0 4px 24px rgba(0,0,0,0.2);
}

.viewer-capsule-secondary:active {
  background: rgba(255, 255, 255, 0.18);
  transform: scale(0.96);
}

.viewer-capsule-primary {
  flex: 1;
  min-width: 0;
  height: 54px;
  border-radius: 99px;
  background: #ffffff;
  border: none;
  color: #000000;
  font-size: 16px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 4px 24px rgba(255,255,255,0.15), 0 0 0 0 rgba(255,255,255,0);
}

.viewer-capsule-primary:active {
  transform: scale(0.96);
  box-shadow: 0 2px 12px rgba(255,255,255,0.1), 0 0 0 4px rgba(255,255,255,0.1);
}

.viewer-capsule-primary:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  transform: scale(1);
}

.viewer-capsule-accent {
  flex: 1;
  min-width: 0;
  height: 54px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #ffffff;
  font-size: 16px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.2s, background 0.2s;
  box-shadow: 0 4px 24px rgba(0,0,0,0.2);
}

.viewer-capsule-accent:active {
  background: rgba(255, 255, 255, 0.18);
  transform: scale(0.96);
}

/* ===== TOPUP SHEET (v2) ===== */

.topup-sheet {
  max-height: 90dvh;
  border-radius: 32px 32px 0 0;
  background: rgba(22, 22, 26, 0.88);
  backdrop-filter: blur(48px) saturate(2);
  -webkit-backdrop-filter: blur(48px) saturate(2);
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  overflow: hidden;
}

.bottom-sheet.topup-sheet.active {
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.32);
}

.topup-viewport {
  position: relative;
  width: 100%;
  display: flex;
  transition: transform 0.4s cubic-bezier(0.32, 0.72, 0, 1);
}

.topup-viewport.show-payment {
  transform: translateX(-100%);
}

.topup-view {
  width: 100%;
  flex-shrink: 0;
  padding: 0 0 36px;
  overflow-y: auto;
  max-height: calc(90dvh - 32px);
  -ms-overflow-style: none;
  scrollbar-width: none;
}
.topup-view::-webkit-scrollbar { display: none; }

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

.topup-header-left {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.topup-title {
  font-size: 24px;
  font-weight: 700;
  color: rgba(255,255,255,0.98);
  letter-spacing: -0.4px;
  line-height: 1.1;
}

.topup-subtitle {
  font-size: 14px;
  color: rgba(255,255,255,0.45);
  font-weight: 400;
}

.topup-balance-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 20px;
  padding: 8px 16px;
  font-size: 16px;
  font-weight: 600;
  color: rgba(255,255,255,0.9);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.topup-balance-star {
  color: rgba(255,220,80,0.9);
  font-size: 14px;
}

.topup-trust-banner {
  margin: 0 24px 12px;
  padding: 8px 12px;
  border-radius: 12px;
  background: linear-gradient(
    135deg,
    rgba(255, 220, 90, 0.09) 0%,
    rgba(255, 255, 255, 0.03) 100%
  );
  border: 1px solid rgba(255, 220, 100, 0.18);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
  text-align: center;
}

.topup-trust-title {
  font-size: 13px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.94);
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin: 0;
}

.topup-trust-desc {
  font-size: 11px;
  font-weight: 400;
  color: rgba(255, 255, 255, 0.48);
  line-height: 1.3;
  margin: 3px 0 0;
  letter-spacing: -0.01em;
}

/* Horizontal scroll for plans */
.topup-plans-scroll {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding: 0 28px 20px;
  gap: 14px;
  -ms-overflow-style: none;
  scrollbar-width: none;
}
.topup-plans-scroll::-webkit-scrollbar { display: none; }

/* ─── Plan card (narrower ~2/3 of prev width) ─── */
.topup-plan-card {
  position: relative;
  flex: 0 0 min(220px, calc(100vw - 120px));
  scroll-snap-align: center;
  border-radius: 28px;
  padding: 16px 18px 18px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  overflow: hidden;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.topup-plan-card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 28px;
  background: radial-gradient(circle at 50% 0%, rgba(255,255,255,0.07) 0%, transparent 65%);
  pointer-events: none;
}

.topup-plan-card.is-popular {
  background: linear-gradient(175deg, rgba(255,220,80,0.09) 0%, rgba(255,255,255,0.03) 60%);
  border-color: rgba(255,220,80,0.40);
  box-shadow: 0 16px 36px rgba(255,220,80,0.07);
}

.topup-plan-card.is-popular::before {
  background: radial-gradient(circle at 50% 0%, rgba(255,220,80,0.14) 0%, transparent 65%);
}

/* Badge row — always in DOM, always visible */
.topup-card-badges-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  min-height: 24px;
  margin-bottom: 18px;
}

/* Discount — top-left */
.topup-discount-tag {
  display: inline-flex;
  align-items: center;
  background: rgba(255,90,70,0.14);
  border: 1px solid rgba(255,90,70,0.22);
  color: rgba(255,120,100,1);
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 100px;
  letter-spacing: 0.02em;
}

.topup-discount-tag--empty {
  visibility: hidden;
  pointer-events: none;
}

/* Popular/Best — top-right */
.topup-acc-badge {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 100px;
  border: 1px solid transparent;
  white-space: nowrap;
}

.topup-acc-badge--empty {
  visibility: hidden;
  pointer-events: none;
}

.topup-acc-badge--popular {
  background: rgba(255,255,255,0.09);
  color: rgba(255,255,255,0.75);
  border-color: rgba(255,255,255,0.09);
}

.topup-acc-badge--best {
  background: rgba(255,220,80,0.14);
  color: rgba(255,220,80,1);
  border-color: rgba(255,220,80,0.28);
}

/* Amount */
.topup-plan-amount {
  font-size: 44px;
  font-weight: 700;
  color: rgba(255,255,255,0.98);
  line-height: 1;
  letter-spacing: -2px;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 5px;
  text-align: center;
  margin-bottom: 6px;
}

.topup-plan-amount-star {
  font-size: 22px;
  color: rgba(255,220,80,0.9);
  letter-spacing: 0;
}

.topup-plan-label {
  font-size: 15px;
  color: rgba(255,255,255,0.55);
  font-weight: 500;
  text-align: center;
  margin-bottom: 22px;
}

/* Price button — fully capsule */
.topup-plan-price-btn {
  background: rgba(255,255,255,0.10);
  border-radius: 9999px;
  padding: 13px 20px;
  font-size: 17px;
  font-weight: 600;
  color: rgba(255,255,255,0.95);
  width: 100%;
  border: 1px solid rgba(255,255,255,0.06);
  transition: background 0.18s ease, transform 0.12s cubic-bezier(0.34,1.56,0.64,1);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  letter-spacing: -0.2px;
}

.topup-plan-price-btn:active {
  transform: scale(0.95);
  background: rgba(255,255,255,0.16);
}

.topup-plan-card.is-popular .topup-plan-price-btn {
  background: rgba(255,218,68,0.88);
  color: #1a1200;
  border: none;
  font-weight: 700;
}

.topup-plan-card.is-popular .topup-plan-price-btn:active {
  background: rgba(255,218,68,1);
}

/* Skeleton */
.topup-skeleton {
  flex: 0 0 min(220px, calc(100vw - 120px));
  height: 226px;
  border-radius: 28px;
  background: linear-gradient(90deg, rgba(255,255,255,0.04) 0%, rgba(255,255,255,0.08) 50%, rgba(255,255,255,0.04) 100%);
  background-size: 200% 100%;
  animation: topupShimmer 1.6s ease-in-out infinite;
}

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

/* ─── Payment View ─── */
.payment-header {
  justify-content: flex-start;
  padding-bottom: 20px;
}

.topup-back-btn {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(255,255,255,0.10);
  color: rgba(255,255,255,0.95);
  cursor: pointer;
  border: none;
  outline: none;
  flex-shrink: 0;
  transition: background 0.18s ease, transform 0.12s cubic-bezier(0.34,1.56,0.64,1);
  -webkit-tap-highlight-color: transparent;
}

.topup-back-btn:active {
  background: rgba(255,255,255,0.18);
  transform: scale(0.90);
}

.payment-methods {
  padding: 0 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.payment-method-btn {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 20px;
  padding: 16px 20px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.16s ease, transform 0.14s cubic-bezier(0.34,1.56,0.64,1);
}

.payment-method-btn:active {
  background: rgba(255,255,255,0.08);
  transform: scale(0.97);
}

.pm-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: rgba(255,255,255,0.07);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: rgba(255,255,255,0.8);
}

.pm-icon svg {
  width: 22px;
  height: 22px;
}

.pm-icon-stars {
  background: rgba(255,200,40,0.15);
  color: rgba(255,200,40,1);
}

.pm-info {
  flex: 1;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.pm-title {
  font-size: 16px;
  font-weight: 500;
  color: rgba(255,255,255,0.95);
}

.pm-meta {
  font-size: 13px;
  color: rgba(255,255,255,0.4);
}

.pm-chevron {
  width: 18px;
  height: 18px;
  color: rgba(255,255,255,0.25);
  flex-shrink: 0;
}

/* =========================================
   SUGGEST CARD SCREEN
   ========================================= */

.suggest-photos-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.suggest-photo-item {
  width: 80px;
  height: 80px;
  border-radius: var(--radius-lg);
  background-size: cover;
  background-position: center;
  flex-shrink: 0;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.1);
  position: relative;
}

.suggest-photo-remove {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 20px;
  height: 20px;
  background: var(--color-error);
  border: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #fff;
  padding: 0;
  box-shadow: 0 2px 4px rgba(0,0,0,0.5);
  z-index: 5;
}

.suggest-photo-add {
  width: 80px;
  height: 80px;
  border-radius: var(--radius-lg);
  border: 1px dashed rgba(255,255,255,0.2);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  flex-shrink: 0;
  color: var(--text-secondary);
  transition: background 0.15s;
}

.suggest-photo-add:active {
  background: rgba(255,255,255,0.05);
}

.suggest-photo-add svg {
  width: 20px;
  height: 20px;
}

.suggest-photo-add span {
  font-size: 10px;
  font-weight: 500;
}

.suggest-input {
  height: 48px;
  padding-top: 0;
  padding-bottom: 0;
  line-height: 48px;
}

.suggest-cost-row {
  display: flex;
  justify-content: center;
  padding: 4px 0 8px;
}

.suggest-cost-badge {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 99px;
  padding: 8px 20px;
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.suggest-cost-badge span {
  color: var(--text-primary);
  font-weight: 600;
}

/* =========================================
   FEED TOOLBAR (сортировка / поиск — без второй шапки)
   ========================================= */

.feed-toolbar {
  flex-shrink: 0;
  padding: 0 0 10px;
  display: flex;
  flex-direction: column;
  gap: 0;
  background: none;
  border: none;
}

.feed-sort-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  gap: 10px;
  min-height: 36px;
}

.feed-search-btn {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.65);
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  outline: none;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s, transform 0.15s;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.feed-search-btn:active {
  transform: scale(0.94);
  background: rgba(255, 255, 255, 0.12);
}

.feed-search-btn svg {
  display: block;
}

.sort-capsule {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 10px 6px 8px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-full);
  color: rgba(255, 255, 255, 0.55);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.01em;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.sort-capsule:active {
  background: rgba(255, 255, 255, 0.11);
  color: rgba(255, 255, 255, 0.85);
}

.sort-capsule.open {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.14);
  color: rgba(255, 255, 255, 0.8);
}

.sort-capsule-chevron {
  transition: transform 0.2s ease;
  opacity: 0.45;
}

.sort-capsule.open .sort-capsule-chevron {
  transform: rotate(180deg);
  opacity: 0.7;
}

.sort-dropdown {
  position: absolute;
  top: calc(100% + 7px);
  left: 0;
  min-width: 176px;
  background: rgba(22, 22, 22, 0.97);
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  box-shadow:
    0 16px 48px -8px rgba(0, 0, 0, 0.75),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  overflow: hidden;
  z-index: 200;
  opacity: 0;
  transform: translateY(-5px) scale(0.97);
  transform-origin: top left;
  transition: opacity 0.17s ease, transform 0.17s ease;
  pointer-events: none;
}

.sort-dropdown.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.sort-option {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 11px 14px;
  color: rgba(255, 255, 255, 0.55);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}

.sort-option + .sort-option {
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.sort-option:active {
  background: rgba(255, 255, 255, 0.06);
}

.sort-option.active {
  color: #fff;
}

.sort-check {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
  color: var(--accent-color);
  opacity: 0;
  transition: opacity 0.12s;
}

.sort-option.active .sort-check {
  opacity: 1;
}

/* =========================================
   FEED INFINITE SCROLL
   ========================================= */

#screen-feed.active {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0;
}

.feed-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px var(--spacing-4) var(--content-bottom);
  -ms-overflow-style: none;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  touch-action: pan-y;
}

.feed-scroll::-webkit-scrollbar { display: none; }

.feed-card-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.feed-sentinel,
.history-sentinel {
  height: 1px;
  pointer-events: none;
  visibility: hidden;
}

.feed-end,
.history-end {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  padding: 20px 0 8px;
  letter-spacing: 0.02em;
}

@keyframes shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position:  400px 0; }
}

.shimmer {
  background: linear-gradient(
    90deg,
    rgba(255,255,255,0.04) 0%,
    rgba(255,255,255,0.10) 50%,
    rgba(255,255,255,0.04) 100%
  );
  background-size: 400px 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}

.feed-loading-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-top: 12px;
}

.feed-loading-row[hidden] .shimmer {
  animation-play-state: paused;
}

.feed-skel-card {
  aspect-ratio: 3 / 4;
  border-radius: 20px;
}

/* =========================================
   HISTORY INFINITE SCROLL
   ========================================= */

.history-loading-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 4px;
  margin-top: 4px;
}

.history-loading-row .history-skel-card {
  animation: shimmer 1.4s ease-in-out infinite;
  background: linear-gradient(
    90deg,
    rgba(255,255,255,0.04) 0%,
    rgba(255,255,255,0.10) 50%,
    rgba(255,255,255,0.04) 100%
  );
  background-size: 400px 100%;
}

.suggest-locked-field {
  opacity: 0.45;
  pointer-events: none;
  cursor: default;
}

#suggest-prompt:read-only {
  opacity: 0.5;
  border-color: rgba(255, 255, 255, 0.04);
  cursor: default;
  resize: none;
}

/* =============================================
   SUBSCRIPTION SCREEN
   ============================================= */

.sub-screen {
  background: #0a0a0a !important;
  --bg-root: #0a0a0a;
  --bg-surface: #141414;
  --text-primary: #ffffff;
  --text-secondary: rgba(255, 255, 255, 0.6);
  --text-muted: rgba(255, 255, 255, 0.35);
}

.sub-screen-title {
  color: #fff !important;
}

.sub-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
  -ms-overflow-style: none;
  scrollbar-width: none;
  padding-top: calc(var(--safe-top, 0px) + 60px);
  padding-bottom: calc(var(--safe-bottom, 0px) + 90px);
}
.sub-scroll::-webkit-scrollbar { display: none; }

/* Hero */
.sub-hero {
  position: relative;
  padding: 28px 20px 24px;
  text-align: center;
  overflow: hidden;
}
.sub-hero-glow {
  position: absolute;
  top: -60px;
  left: 50%;
  transform: translateX(-50%);
  width: 300px;
  height: 220px;
  background: radial-gradient(ellipse at center, rgba(168, 85, 247, 0.22) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}
.sub-hero-title {
  font-size: 28px;
  font-weight: 700;
  color: #fff;
  line-height: 1.22;
  letter-spacing: -0.03em;
  margin: 0 0 10px;
  position: relative;
  z-index: 1;
}
.sub-hero-sub {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.5);
  line-height: 1.55;
  margin: 0;
  position: relative;
  z-index: 1;
}

/* Tabs */
.sub-tabs-wrap {
  padding: 4px 20px 20px;
}
.sub-tabs {
  position: relative;
  display: flex;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 99px;
  padding: 3px;
}
.sub-tab-glider {
  position: absolute;
  top: 3px;
  left: 3px;
  height: calc(100% - 6px);
  width: calc(33.333% - 2px);
  background: rgba(255, 255, 255, 0.14);
  border-radius: 99px;
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 0;
  pointer-events: none;
}
.sub-tab {
  flex: 1;
  background: transparent;
  border: none;
  border-radius: 99px;
  padding: 11px 4px;
  font-size: 13px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.4);
  cursor: pointer;
  z-index: 1;
  position: relative;
  transition: color 0.2s;
  -webkit-tap-highlight-color: transparent;
  outline: none;
  letter-spacing: -0.01em;
}
.sub-tab:focus,
.sub-tab:focus-visible { outline: none; box-shadow: none; }
.sub-tab.active { color: #fff; }
.sub-tab--pro {
  background: linear-gradient(90deg, #c084fc 0%, #f472b6 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.sub-tab--pro.active {
  background: none;
  -webkit-background-clip: unset;
  background-clip: unset;
  -webkit-text-fill-color: #fff;
  color: #fff;
}

/* Plan Card */
.sub-card-viewport { padding: 0 16px 24px; }
.sub-card-wrap { min-height: 220px; }

.sub-plan-card {
  border-radius: 22px;
  padding: 22px 20px;
  position: relative;
  z-index: 10;
  overflow: hidden;
  pointer-events: auto;
  transition: opacity 0.2s ease, transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.sub-card-entering {
  opacity: 0;
  transform: translateY(10px) scale(0.975);
}
.sub-plan-card--free {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.sub-plan-card--plus {
  background: linear-gradient(180deg, rgba(232, 160, 32, 0.12) 0%, rgba(232, 160, 32, 0.03) 100%), #141416;
  border-color: rgba(232, 160, 32, 0.4);
  cursor: pointer;
}

.sub-plan-card--pro {
  background: linear-gradient(180deg, rgba(167, 139, 250, 0.15) 0%, rgba(167, 139, 250, 0.04) 100%), #141416;
  border-color: rgba(167, 139, 250, 0.5);
  box-shadow: 0 8px 32px rgba(167, 139, 250, 0.15);
  cursor: pointer;
}

.sub-popular-badge {
  position: absolute;
  top: 16px;
  right: 16px;
  background: rgba(139, 92, 246, 0.18);
  border: 1px solid rgba(139, 92, 246, 0.38);
  color: #c4b5fd;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  padding: 3px 10px;
  border-radius: 99px;
}

.sub-plan-name {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: rgba(255, 255, 255, 0.4);
  margin-bottom: 8px;
}
.sub-plan-card--plus .sub-plan-name { color: rgba(232, 160, 32, 0.8); }
.sub-plan-card--pro  .sub-plan-name { color: rgba(167, 139, 250, 0.8); }

.sub-plan-price {
  font-size: 36px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.03em;
  line-height: 1;
  margin-bottom: 18px;
}
.sub-price-unit {
  font-size: 17px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.45);
  letter-spacing: 0;
}

.sub-features-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.sub-feature {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.82);
  line-height: 1.4;
}
.sub-feature-locked { color: rgba(255, 255, 255, 0.28); }
.sub-feature-check {
  font-size: 12px;
  font-weight: 700;
  width: 16px;
  flex-shrink: 0;
  margin-top: 1px;
  color: rgba(255, 255, 255, 0.35);
}
.sub-plan-card--plus .sub-feature:not(.sub-feature-locked) .sub-feature-check { color: #E8A020; }
.sub-plan-card--pro  .sub-feature:not(.sub-feature-locked) .sub-feature-check { color: #a78bfa; }

/* Unlocks */
.sub-unlocks { padding: 4px 20px 24px; }
.sub-section-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(255, 255, 255, 0.3);
  margin-bottom: 12px;
}
.sub-unlock-tiles { display: flex; flex-wrap: wrap; gap: 8px; }
.sub-unlock-capsule {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 99px;
  padding: 10px 18px 10px 13px;
  font-size: 14px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.65);
  letter-spacing: -0.01em;
}
.sub-unlock-icon { font-size: 18px; line-height: 1; }

.sub-grant-label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 19px;
  font-weight: 800;
  color: #fff;
  margin-bottom: 16px;
  letter-spacing: -0.03em;
  line-height: 1;
}
.sub-grant-star {
  font-size: 13px;
  opacity: 0.55;
}
.sub-plan-card--plus .sub-grant-label { color: #fbbf24; }
.sub-plan-card--pro  .sub-grant-label { color: #c4b5fd; }

.sub-scroll-spacer { height: 90px; }

/* Sticky CTA footer */
.sub-footer {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 20px 20px calc(var(--safe-bottom, 0px) + 20px);
  z-index: 25;
  pointer-events: none;
}

.sub-footer > * {
  pointer-events: auto;
}

.sub-cta-btn {
  width: 100%;
  height: 56px;
  border-radius: 99px;
  border: none;
  background: linear-gradient(135deg, #7c3aed, #a855f7);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  pointer-events: auto;
  letter-spacing: -0.015em;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 8px 30px rgba(124, 58, 237, 0.38);
  -webkit-tap-highlight-color: transparent;
}
.sub-cta-btn:active {
  transform: scale(0.97);
  box-shadow: 0 4px 16px rgba(124, 58, 237, 0.22);
}

/* =============================================
   SUBSCRIPTION MANAGE SCREEN
   ============================================= */

.sub-manage-screen {
  background: #0a0a0a !important;
}

.sub-manage-scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px 16px 0;
}

/* Hero card */
.sub-manage-hero {
  position: relative;
  border-radius: 20px;
  padding: 24px 22px 22px;
  margin-bottom: 24px;
  overflow: hidden;
  border: 1.5px solid rgba(255,255,255,0.08);
  background: #141414;
}

.sub-manage-hero--plus {
  border-color: rgba(250, 200, 80, 0.35);
  background: linear-gradient(135deg, #1a1508 0%, #141414 60%);
}

.sub-manage-hero--pro {
  border-color: rgba(160, 220, 255, 0.30);
  background: linear-gradient(135deg, #08121a 0%, #141414 60%);
}

.sub-manage-hero-glow {
  position: absolute;
  top: -40px;
  right: -40px;
  width: 160px;
  height: 160px;
  border-radius: 50%;
  opacity: 0.18;
  pointer-events: none;
  filter: blur(50px);
}

.sub-manage-hero--plus .sub-manage-hero-glow { background: #fac850; }
.sub-manage-hero--pro  .sub-manage-hero-glow { background: #a0dcff; }

.sub-manage-plan-name {
  font-size: 26px;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.02em;
  margin-bottom: 10px;
}

.sub-manage-status-row {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 14px;
}

.sub-manage-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 6px rgba(74, 222, 128, 0.7);
  flex-shrink: 0;
}

.sub-manage-status-text {
  font-size: 14px;
  font-weight: 600;
  color: #4ade80;
  letter-spacing: 0.01em;
}

.sub-manage-next-charge {
  font-size: 13px;
  color: rgba(255,255,255,0.5);
  margin-bottom: 8px;
}

.sub-manage-grant-row {
  font-size: 13px;
  color: rgba(255,255,255,0.35);
}

/* Section label */
.sub-manage-section-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.3);
  margin-bottom: 10px;
}

/* Perks list */
.sub-manage-perks {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 32px;
}

.sub-manage-perk {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  background: #141414;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.06);
}

.sub-manage-perk-icon {
  font-size: 18px;
  line-height: 1;
  flex-shrink: 0;
}

.sub-manage-perk-text {
  font-size: 14px;
  font-weight: 500;
  color: rgba(255,255,255,0.85);
}

/* Controls */
.sub-manage-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding-bottom: 8px;
}

.sub-manage-autorenew {
  font-size: 12px;
  color: rgba(255,255,255,0.28);
}

.sub-manage-cancel-link {
  background: none;
  border: none;
  padding: 4px 0;
  font-size: 12px;
  color: rgba(255,255,255,0.22);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.15s;
}

.sub-manage-cancel-link:active { color: rgba(255,80,80,0.7); }

.sub-manage-scroll-spacer { height: 48px; }

/* =============================================
   CANCEL SUBSCRIPTION SHEET
   ============================================= */

.cancel-sub-sheet {
  max-height: 52vh;
}

.cancel-sub-content {
  padding: 8px 20px 24px;
}

.cancel-sub-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary, #111);
  margin-bottom: 10px;
}

.cancel-sub-body {
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-secondary, #666);
  margin-bottom: 24px;
}

.cancel-sub-actions {
  display: flex;
  gap: 10px;
}

.cancel-sub-btn-secondary {
  flex: 1;
  height: 48px;
  border-radius: 12px;
  border: 1.5px solid rgba(0,0,0,0.10);
  background: rgba(0,0,0,0.06);
  font-size: 15px;
  font-weight: 600;
  color: var(--text-secondary, #555);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: opacity 0.15s;
}

.cancel-sub-btn-secondary:active { opacity: 0.7; }

.cancel-sub-btn-primary {
  flex: 1.4;
  height: 48px;
  border-radius: 12px;
  border: none;
  background: #7c3aed;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  box-shadow: 0 4px 16px rgba(124,58,237,0.35);
  transition: transform 0.13s, box-shadow 0.13s;
}

.cancel-sub-btn-primary:active {
  transform: scale(0.97);
  box-shadow: 0 2px 8px rgba(124,58,237,0.2);
}

/* ============================================================
   Экран входа (браузерный режим — Telegram Login Widget)
   ============================================================ */
#screen-login {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: var(--bg-root, #0a0a0a);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  width: 100%;
  max-width: 320px;
  text-align: center;
}

.login-logo {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text-primary, #ffffff);
  margin-bottom: 8px;
}

.login-tagline {
  font-size: 15px;
  color: var(--text-secondary, rgba(255,255,255,0.6));
  margin: 0 0 28px;
  font-weight: 400;
}

#tg-login-btn-wrap {
  width: 100%;
  margin-bottom: 16px;
}

.btn-tg-login {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 14px 24px;
  background: #2AABEE;
  color: #ffffff;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  border: none;
  border-radius: var(--radius-md, 12px);
  cursor: pointer;
  transition: background 0.15s ease, opacity 0.15s ease;
  letter-spacing: 0.01em;
}

.btn-tg-login::before {
  content: '';
  display: inline-block;
  width: 20px;
  height: 20px;
  margin-right: 10px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M12 2C6.477 2 2 6.477 2 12s4.477 10 10 10 10-4.477 10-10S17.523 2 12 2zm4.93 6.77l-1.68 7.93c-.12.56-.46.7-.93.43l-2.56-1.89-1.24 1.19c-.14.14-.25.25-.51.25l.18-2.6 4.7-4.25c.2-.18-.05-.28-.32-.1L7.07 14.6l-2.5-.78c-.54-.17-.55-.54.12-.8l9.74-3.75c.45-.16.85.11.5.5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-size: contain;
  flex-shrink: 0;
}

.btn-tg-login:hover:not(:disabled) {
  background: #1a9cd8;
}

.btn-tg-login:active:not(:disabled) {
  opacity: 0.85;
}

.btn-tg-login:disabled {
  opacity: 0.55;
  cursor: default;
}

.login-status {
  font-size: 13px;
  color: transparent;
  margin: 0 0 8px;
  min-height: 18px;
  transition: color 0.2s;
}

.login-status--error {
  color: var(--color-error, #ef4444);
}

.login-status--info {
  color: var(--text-secondary, rgba(255,255,255,0.6));
  animation: login-status-pulse 2s ease-in-out infinite;
}

@keyframes login-status-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.55; }
}

/* =============================================
   SETTINGS SHEET
   ============================================= */

.settings-sheet {
  background: var(--bg-surface, #141414);
  max-height: 85vh;
}

.settings-content {
  padding: 0 24px 24px;
  display: flex;
  flex-direction: column;
}

.settings-header {
  margin-bottom: 32px;
}

.settings-subtitle {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: rgba(255, 255, 255, 0.4);
  margin-bottom: 4px;
}

.settings-title {
  font-size: 40px;
  font-weight: 900;
  color: rgba(255, 255, 255, 0.9);
  line-height: 1;
  margin: 0;
  letter-spacing: -0.02em;
}

.settings-list {
  display: flex;
  flex-direction: column;
  gap: 32px;
  margin-bottom: 40px;
}

.settings-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.settings-label {
  flex: 1;
}

.settings-name {
  font-size: 20px;
  font-weight: 800;
  color: #ffffff;
  line-height: 1.1;
}

.settings-toggle {
  width: 80px;
  height: 48px;
  background: #000000;
  border-radius: 24px;
  position: relative;
  cursor: pointer;
  flex-shrink: 0;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  -webkit-tap-highlight-color: transparent;
}

.settings-toggle-thumb {
  width: 44px;
  height: 44px;
  background: #e2dcf2;
  border-radius: 50%;
  position: absolute;
  top: 2px;
  left: 2px;
  transition: transform 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* For active state if needed later */
.settings-toggle.active .settings-toggle-thumb {
  transform: translateX(32px);
}

.settings-close-btn {
  background: #e2dcf2;
  color: #000000;
  font-size: 16px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  border: none;
  border-radius: 999px;
  padding: 18px;
  width: 100%;
  cursor: pointer;
  font-family: inherit;
  transition: opacity 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.settings-close-btn:active {
  opacity: 0.8;
}

.login-hint {
  font-size: 15px;
  color: var(--text-secondary, rgba(255,255,255,0.6));
  line-height: 1.4;
  margin: 8px 0 0;
}
