/* ============================================================================
   YouKey V7 — дизайн-система (Фаза A.1). ИЗОЛИРОВАННЫЙ слой: все классы с
   префиксом .v7-, токены в --v7-*. НЕ влияет на существующий style.css и старые
   страницы — подключается только там, где включён V7 (feature-flag homepage_v7).
   Основание: IMPLEMENTATION_TZ_V7 + правки владельца. Шрифт Onest, иконки — SVG
   (Lucide/Simple Icons), без Unicode-эмодзи. Контраст ≥ WCAG AA.
   ========================================================================== */

:root {
  /* Поверхности и фон */
  --v7-bg: #f7f7f5;
  --v7-surface: #ffffff;
  --v7-surface-2: #f1f5ed;
  /* Текст */
  --v7-ink: #10160f;
  --v7-muted: #62705f;
  --v7-muted-2: #667266;
  /* Бренд */
  --v7-lime: #aafc08;
  --v7-lime-ink: #121a0c; /* тёмный текст на лайме (лайм на белом нечитаем) */
  --v7-lime-text: #416924; /* читаемый лаймовый текст на светлом */
  --v7-lime-soft: #e9fcd8;
  /* Границы */
  --v7-border: #dee5d8;
  --v7-border-strong: #cedac9;
  /* Статусы */
  --v7-ok: #42782a;
  --v7-warn: #9b6716;
  --v7-err: #b13b31;
  --v7-err-soft: #fbeceb;
  /* Радиусы */
  --v7-r-control: 12px;
  --v7-r-card: 18px;
  --v7-r-panel: 22px;
  --v7-r-pill: 999px;
  /* Тени */
  --v7-shadow-sm: 0 1px 2px rgba(17, 35, 14, 0.04), 0 8px 24px -16px rgba(17, 35, 14, 0.12);
  --v7-shadow: 0 12px 35px rgba(17, 35, 14, 0.05);
  /* Прочее */
  --v7-ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --v7-container: 1360px;
  --v7-font: 'Onest', 'Golos Text', system-ui, -apple-system, 'Segoe UI', Arial, sans-serif;
}

/* Scope-обёртка: стили V7 действуют внутри .v7 (или <body class="v7">),
   чтобы случайно не задеть старую вёрстку, где V7 не включён. */
.v7,
.v7 * {
  box-sizing: border-box;
}
.v7 {
  font-family: var(--v7-font);
  color: var(--v7-ink);
  background: var(--v7-bg);
  -webkit-font-smoothing: antialiased;
}

/* --- Типографика --- */
.v7 .v7-overline {
  display: block;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: #536d3c;
  margin-bottom: 12px;
}
.v7 .v7-h1 {
  font-size: clamp(40px, 5.9vw, 90px);
  letter-spacing: -0.073em;
  line-height: 1.02;
  font-weight: 800;
  margin: 0 0 24px;
  text-wrap: balance;
}
.v7 .v7-h1 em {
  font-style: normal;
  color: #6b9b18;
}
.v7 .v7-h2 {
  font-size: clamp(26px, 3.1vw, 47px);
  letter-spacing: -0.055em;
  line-height: 1.12;
  font-weight: 760;
  margin: 0 0 16px;
}
.v7 .v7-h3 {
  font-size: 20px;
  font-weight: 750;
  letter-spacing: -0.035em;
  line-height: 1.25;
  margin: 0 0 10px;
}
.v7 .v7-p {
  font-size: 16px;
  line-height: 1.65;
  color: #505c4f;
  margin: 0 0 12px;
}
.v7 .v7-small {
  font-size: 12px;
  color: var(--v7-muted-2);
}
.v7 .v7-num {
  font-variant-numeric: tabular-nums; /* цены — моноширинные цифры */
}

/* --- Контейнер/сетка --- */
.v7 .v7-container {
  width: 100%;
  max-width: var(--v7-container);
  margin: 0 auto;
  padding: 0 24px;
}
.v7 .v7-grid {
  display: grid;
  gap: 24px;
}
@media (min-width: 768px) {
  .v7 .v7-grid-2 { grid-template-columns: repeat(2, 1fr); }
  .v7 .v7-grid-3 { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 1200px) {
  .v7 .v7-grid-4 { grid-template-columns: repeat(4, 1fr); }
}

/* --- Breadcrumbs --- */
.v7 .v7-breadcrumb {
  font-size: 13px;
  color: var(--v7-muted);
  margin-bottom: 24px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.v7 .v7-breadcrumb a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.v7 .v7-breadcrumb a:hover { color: var(--v7-lime-text); }
.v7 .v7-breadcrumb [aria-current='page'] { color: var(--v7-ink); font-weight: 600; }

/* --- Кнопки --- */
.v7 .v7-btn {
  min-height: 48px;
  border-radius: var(--v7-r-control);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-decoration: none;
  padding: 12px 21px;
  font-family: inherit;
  font-weight: 760;
  font-size: 14px;
  line-height: 1.2;
  transition: transform 0.2s var(--v7-ease), box-shadow 0.2s var(--v7-ease), background 0.2s var(--v7-ease);
  border: 1px solid transparent;
  cursor: pointer;
  white-space: normal;
  text-align: center;
  background: none;
}
.v7 .v7-btn:hover { transform: translateY(-2px); }
.v7 .v7-btn:active { transform: translateY(0); }
.v7 .v7-btn:focus-visible {
  outline: 3px solid rgba(170, 252, 8, 0.6);
  outline-offset: 2px;
}
.v7 .v7-btn.primary {
  background: var(--v7-lime);
  color: var(--v7-lime-ink);
  box-shadow: 0 10px 26px -10px rgba(170, 252, 8, 0.8);
}
.v7 .v7-btn.secondary {
  background: var(--v7-surface);
  border-color: var(--v7-border-strong);
  color: var(--v7-ink);
}
.v7 .v7-btn.text {
  min-height: auto;
  padding: 6px 4px;
  background: none;
  color: var(--v7-lime-text);
  text-decoration: underline;
  text-underline-offset: 4px;
}
.v7 .v7-btn[disabled],
.v7 .v7-btn.is-disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  pointer-events: none;
}
.v7 .v7-btn.is-loading {
  color: transparent;
  pointer-events: none;
  position: relative;
}
.v7 .v7-btn.is-loading::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  border: 2px solid currentColor;
  border-top-color: var(--v7-lime-ink);
  border-radius: 50%;
  color: var(--v7-ink);
  animation: v7-spin 0.7s linear infinite;
}
.v7 .v7-btn svg { width: 18px; height: 18px; flex: none; }
.v7 .v7-text-link {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  font-weight: 700;
  color: var(--v7-lime-text);
  font-size: 14px;
  text-decoration: underline;
  text-underline-offset: 4px;
}
.v7 .v7-text-link svg { width: 17px; height: 17px; }

/* --- Поля ввода / поиск --- */
.v7 .v7-input,
.v7 .v7-textarea {
  width: 100%;
  min-height: 48px;
  font-family: inherit;
  font-size: 16px; /* ≥16px — чтобы iOS не зумил при фокусе */
  color: var(--v7-ink);
  background: var(--v7-surface);
  border: 1px solid var(--v7-border);
  border-radius: var(--v7-r-control);
  padding: 12px 14px;
  transition: border-color 0.15s var(--v7-ease), box-shadow 0.15s var(--v7-ease);
}
.v7 .v7-textarea { min-height: 110px; resize: vertical; }
.v7 .v7-input::placeholder,
.v7 .v7-textarea::placeholder { color: #9aa79a; }
.v7 .v7-input:focus-visible,
.v7 .v7-textarea:focus-visible {
  outline: none;
  border-color: var(--v7-lime);
  box-shadow: 0 0 0 3px rgba(170, 252, 8, 0.25);
}
.v7 .v7-input[aria-invalid='true'] {
  border-color: var(--v7-err);
  box-shadow: 0 0 0 3px rgba(177, 59, 49, 0.18);
}
.v7 .v7-field-error { color: var(--v7-err); font-size: 13px; margin-top: 6px; }
.v7 .v7-label { display: block; font-size: 13px; font-weight: 600; color: var(--v7-muted); margin-bottom: 6px; }
.v7 .v7-search {
  position: relative;
  display: flex;
  align-items: center;
}
.v7 .v7-search svg {
  position: absolute;
  left: 14px;
  width: 20px;
  height: 20px;
  color: var(--v7-muted);
  pointer-events: none;
}
.v7 .v7-search .v7-input { padding-left: 44px; }

/* --- Карточки --- */
.v7 .v7-card {
  background: var(--v7-surface);
  border: 1px solid var(--v7-border);
  border-radius: var(--v7-r-card);
  padding: 20px;
  box-shadow: var(--v7-shadow-sm);
  transition: transform 0.2s var(--v7-ease), box-shadow 0.2s var(--v7-ease), border-color 0.2s var(--v7-ease);
}
.v7 a.v7-card,
.v7 .v7-card.is-hoverable:hover {
  transform: translateY(-3px);
  box-shadow: var(--v7-shadow);
  border-color: var(--v7-border-strong);
}
.v7 .v7-card__media {
  border-radius: 14px;
  overflow: hidden;
  background: var(--v7-surface-2);
  aspect-ratio: 16 / 10;
  margin-bottom: 14px;
}
.v7 .v7-card__media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.v7 .v7-panel {
  background: var(--v7-surface);
  border: 1px solid var(--v7-border);
  border-radius: var(--v7-r-panel);
  padding: 28px;
  box-shadow: var(--v7-shadow);
}

/* --- Бейджи / чипы / статус-пилюли --- */
.v7 .v7-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: var(--v7-r-pill);
  background: var(--v7-surface-2);
  color: var(--v7-ink);
}
.v7 .v7-badge.lime { background: var(--v7-lime-soft); color: #3c5a1e; }
.v7 .v7-badge.ok { background: #e6f3e2; color: var(--v7-ok); }
.v7 .v7-badge.warn { background: #fbf0dd; color: var(--v7-warn); }
.v7 .v7-badge.err { background: var(--v7-err-soft); color: var(--v7-err); }
.v7 .v7-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--v7-r-pill);
  border: 1px solid var(--v7-border);
  background: var(--v7-surface);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.v7 .v7-chip[aria-pressed='true'],
.v7 .v7-chip.is-active {
  background: var(--v7-lime-soft);
  border-color: #c7e6a0;
  color: #3c5a1e;
}

/* --- TierBadge (статус лояльности) --- */
.v7 .v7-tier {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: var(--v7-r-pill);
  background: var(--v7-surface-2);
  border: 1px solid var(--v7-border);
  font-weight: 700;
  font-size: 13px;
}
.v7 .v7-tier__dot { width: 10px; height: 10px; border-radius: 50%; background: var(--v7-lime); }
.v7 .v7-tier.gold .v7-tier__dot { background: #d9a400; }
.v7 .v7-tier.silver .v7-tier__dot { background: #9aa6ac; }
.v7 .v7-tier.bronze .v7-tier__dot { background: #c08a4a; }

/* --- PriceBlock --- */
.v7 .v7-price { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.v7 .v7-price__now { font-size: 30px; font-weight: 800; letter-spacing: -0.04em; }
.v7 .v7-price__old { font-size: 16px; color: var(--v7-muted); text-decoration: line-through; }
.v7 .v7-price__per { font-size: 13px; color: var(--v7-muted); }

/* --- LoyaltyProgress (прогресс скидок) — между тарифом и CTA --- */
.v7 .v7-loyalty {
  background: var(--v7-surface-2);
  border: 1px solid var(--v7-border);
  border-radius: 14px;
  padding: 14px 16px;
}
.v7 .v7-loyalty__row { display: flex; justify-content: space-between; font-size: 13px; color: var(--v7-muted); margin-bottom: 8px; }
.v7 .v7-progress {
  height: 8px;
  border-radius: var(--v7-r-pill);
  background: #e3e9dd;
  overflow: hidden;
}
.v7 .v7-progress__bar { height: 100%; background: var(--v7-lime); border-radius: inherit; transition: width 0.4s var(--v7-ease); }

/* --- RewardBalance (денежный/баллы) --- */
.v7 .v7-reward {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-radius: var(--v7-r-pill);
  background: var(--v7-lime-soft);
  color: #3c5a1e;
  font-weight: 800;
}

/* --- ReviewCard --- */
.v7 .v7-review { display: flex; flex-direction: column; gap: 10px; }
.v7 .v7-review__head { display: flex; align-items: center; gap: 10px; }
.v7 .v7-review__avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--v7-surface-2); object-fit: cover; }
.v7 .v7-review__stars { color: #e3a008; display: inline-flex; gap: 2px; }
.v7 .v7-review__stars svg { width: 16px; height: 16px; }

/* --- FAQ аккордеон --- */
.v7 .v7-faq { border: 1px solid var(--v7-border); border-radius: 14px; overflow: hidden; background: var(--v7-surface); }
.v7 .v7-faq__item + .v7-faq__item { border-top: 1px solid var(--v7-border); }
.v7 .v7-faq__q {
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  font-family: inherit;
  font-weight: 700;
  font-size: 16px;
  color: var(--v7-ink);
  padding: 18px 20px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}
.v7 .v7-faq__q:focus-visible { outline: 3px solid rgba(170, 252, 8, 0.5); outline-offset: -3px; }
.v7 .v7-faq__q svg { width: 20px; height: 20px; transition: transform 0.2s var(--v7-ease); flex: none; }
.v7 .v7-faq__item[open] .v7-faq__q svg { transform: rotate(180deg); }
.v7 .v7-faq__a { padding: 0 20px 18px; color: #505c4f; line-height: 1.6; }

/* --- Modal --- */
.v7 .v7-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(16, 22, 15, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 1000;
}
.v7 .v7-modal {
  background: var(--v7-surface);
  border-radius: var(--v7-r-panel);
  padding: 28px;
  max-width: 460px;
  width: 100%;
  box-shadow: 0 30px 80px -20px rgba(16, 22, 15, 0.4);
}
.v7 .v7-modal__title { font-size: 22px; font-weight: 800; letter-spacing: -0.03em; margin: 0 0 14px; }

/* --- Toast --- */
.v7 .v7-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--v7-ink);
  color: #fff;
  padding: 12px 18px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.25);
  z-index: 1100;
}
.v7 .v7-toast.ok { background: var(--v7-ok); }
.v7 .v7-toast.err { background: var(--v7-err); }

/* --- MobileTabBar (нижнее меню: Каталог→Профиль→Промпты→Игра→Чат) --- */
.v7 .v7-tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  background: var(--v7-surface);
  border-top: 1px solid var(--v7-border);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 900;
}
.v7 .v7-tabbar__item {
  flex: 1;
  min-height: 56px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 11px;
  font-weight: 600;
  color: var(--v7-muted);
  text-decoration: none;
}
.v7 .v7-tabbar__item svg { width: 22px; height: 22px; }
.v7 .v7-tabbar__item[aria-current='page'] { color: var(--v7-lime-ink); }
.v7 .v7-tabbar__item[aria-current='page'] svg { color: #6b9b18; }

/* --- ChatDrawer (вход в чат) --- */
.v7 .v7-chat-fab {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--v7-lime);
  color: var(--v7-lime-ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 12px 30px -8px rgba(170, 252, 8, 0.7);
  border: none;
  cursor: pointer;
  z-index: 850;
}
.v7 .v7-chat-fab svg { width: 26px; height: 26px; }

/* --- EmptyState / ErrorState --- */
.v7 .v7-empty,
.v7 .v7-error {
  text-align: center;
  padding: 40px 20px;
  color: var(--v7-muted);
}
.v7 .v7-empty svg,
.v7 .v7-error svg { width: 40px; height: 40px; margin-bottom: 12px; color: #a7b2a2; }
.v7 .v7-error { color: var(--v7-err); }
.v7 .v7-error svg { color: var(--v7-err); }

/* --- Skeleton (загрузка) --- */
.v7 .v7-skeleton {
  border-radius: 10px;
  background: linear-gradient(100deg, #eef1ea 30%, #f6f8f3 50%, #eef1ea 70%);
  background-size: 200% 100%;
  animation: v7-shimmer 1.3s infinite;
}
.v7 .v7-skeleton.line { height: 14px; margin-bottom: 10px; }
.v7 .v7-skeleton.title { height: 26px; width: 60%; margin-bottom: 16px; }
.v7 .v7-skeleton.block { height: 160px; }

/* --- Анимации --- */
@keyframes v7-spin { to { transform: rotate(360deg); } }
@keyframes v7-shimmer { to { background-position: -200% 0; } }

/* Доступность: уважать reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .v7 * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
  .v7 .v7-btn:hover,
  .v7 a.v7-card:hover { transform: none; }
}

/* ============================================================================
   V7-РЕСКИН существующей главной БЕЗ правки style.css. style.css построен на
   CSS-переменных (--bg/--brand/--font…); переопределяем их ТОЛЬКО под scope .v7
   (на странице <body class="v7">). Остальные 25 страниц (без класса v7)
   остаются на прежних токенах. Так и статическая вёрстка, и контент, который
   вставляет main.js (карточки/отзывы/баннеры) — всё получает палитру и шрифт V7.
   ========================================================================== */
.v7 {
  /* Фон/текст */
  --bg: #f7f7f5;
  --bg-soft: #f1f5ed;
  --bg-tint: rgba(170, 252, 8, 0.08);
  --ink: #10160f;
  --ink-2: #1c241a;
  --muted: #62705f;
  --muted-2: #667266;
  --line: rgba(16, 22, 15, 0.08);
  --line-2: rgba(16, 22, 15, 0.12);
  /* Бренд (лайм V7 #AAFC08 вместо прежнего #aaff00) */
  --brand: #aafc08;
  --brand-2: #93e000;
  --brand-ink: #416924;
  --brand-deep: #4e7d1f;
  /* Геометрия/типографика V7 */
  --radius: 18px;
  --radius-sm: 12px;
  --radius-lg: 22px;
  --font: 'Onest', 'Golos Text', system-ui, -apple-system, 'Segoe UI', Arial, sans-serif;
  --font-display: 'Onest', 'Golos Text', system-ui, sans-serif;
  /* Фон главной V7 — чистый, без прежней точечной сетки */
  background-image: none;
}
/* Заголовки Onest: чуть плотнее трекинг крупным кеглем (как в дизайн-системе V7) */
.v7 h1 { letter-spacing: -0.06em; }
.v7 h2 { letter-spacing: -0.045em; }
.v7 h3 { letter-spacing: -0.03em; }

/* --- Модуль «Попробуйте бесплатно» на /prompts (DES-03) --- */
.v7 .v7-free-prompt { margin-bottom: 28px; }
.v7 .v7-prompt-text {
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--v7-surface-2);
  border: 1px solid var(--v7-border);
  border-radius: 12px;
  padding: 16px;
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.6;
  max-height: 320px;
  overflow: auto;
  color: var(--v7-ink);
  margin: 0;
}
.v7 .v7-steps-wrap { margin-top: 18px; border-top: 1px solid var(--v7-border); padding-top: 16px; }
.v7 .v7-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.v7 .v7-steps li { display: flex; gap: 12px; align-items: flex-start; font-size: 14px; color: #505c4f; }
.v7 .v7-step-n {
  flex: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--v7-lime-soft);
  color: #3c5a1e;
  font-weight: 800;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.v7 .v7-whybuy { margin-top: 14px; display: grid; gap: 10px; }
.v7 .v7-whybuy__item { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; color: #505c4f; }
.v7 .v7-whybuy__item svg { width: 18px; height: 18px; color: #6b9b18; flex: none; margin-top: 2px; }

/* --- История баллов на /bonus (DES-05) --- */
.v7 .v7-hist-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--v7-border); }
.v7 .v7-hist-row:last-child { border-bottom: none; }
.v7 .v7-hist-label { font-weight: 600; font-size: 14px; color: var(--v7-ink); }
.v7 .v7-hist-date { font-size: 12px; color: var(--v7-muted); margin-top: 2px; }
.v7 .v7-hist-delta { font-weight: 800; font-variant-numeric: tabular-nums; font-size: 15px; white-space: nowrap; }
.v7 .v7-hist-plus { color: var(--v7-ok); }
.v7 .v7-hist-minus { color: var(--v7-muted); }

/* --- Реферальная программа в профиле (REF-14) --- */
.v7 .v7-ref-gens { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.v7 .v7-ref-gen {
  background: var(--v7-surface-2);
  border: 1px solid var(--v7-border);
  border-radius: 12px;
  padding: 12px;
  text-align: center;
}
.v7 .v7-ref-gen b { display: block; font-size: 22px; font-weight: 800; color: var(--v7-ink); }
.v7 .v7-ref-gen span { font-size: 12px; color: var(--v7-muted); }

/* Нижнее мобильное меню на главной — поднимаем контент, чтобы таббар не
   перекрывал футер/кнопки на телефоне. */
@media (max-width: 760px) {
  .v7.has-tabbar { padding-bottom: 64px; }
  .v7 .to-top { bottom: 76px; }
}
@media (min-width: 761px) {
  .v7 .v7-tabbar { display: none; } /* таббар — только на телефоне */
}
