:root {
  --bg: var(--tg-theme-bg-color, #14161c);
  --card-bg: var(--tg-theme-secondary-bg-color, #1f222b);
  --text: var(--tg-theme-text-color, #eef0f5);
  --muted: var(--tg-theme-hint-color, #969cb0);
  --accent: var(--tg-theme-button-color, #6c7cff);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --star-a: #8b6bff;
  --star-b: #ff6bd6;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); -webkit-tap-highlight-color: transparent; }
.app { max-width: 600px; margin: 0 auto; padding: 16px 16px 48px; display: flex; flex-direction: column; gap: 14px; }
.head { text-align: center; padding: 8px 0 0; }
.head h1 { margin: 0; font-size: 26px; }
.status { margin: 6px 0 0; color: var(--muted); font-size: 14px; }
.streak { margin: 4px 0 0; font-size: 14px; font-weight: 600; color: #ff8a3d; }
.streak.hidden { display: none; }
.card { background: var(--card-bg); border-radius: 16px; padding: 16px; }

.signs { display: flex; align-items: flex-end; gap: 10px; margin-bottom: 12px; }
.sign-pick { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.sign-label { font-size: 13px; color: var(--muted); }
.amp { color: var(--muted); font-size: 20px; font-weight: 700; flex: none; padding-bottom: 12px; }
.select { width: 100%; padding: 12px; border-radius: 12px; border: 1px solid rgba(255,255,255,0.12); background: var(--bg); color: var(--text); font-size: 16px; font-family: inherit; appearance: none; -webkit-appearance: none; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path d='M1 1l5 5 5-5' stroke='%23969cb0' stroke-width='2' fill='none' stroke-linecap='round'/></svg>"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }

.primary { width: 100%; padding: 14px; border: none; border-radius: 14px; background: linear-gradient(135deg, var(--star-a), var(--star-b)); color: var(--accent-text); font-size: 16px; font-weight: 600; cursor: pointer; }
.primary:disabled { opacity: 0.6; }
.muted { color: var(--muted); font-size: 14px; margin: 6px 0 0; }

.percent-wrap { text-align: center; padding: 6px 0 14px; }
.percent-signs { font-size: 20px; font-weight: 600; margin-bottom: 4px; }
.percent { font-size: 64px; font-weight: 800; line-height: 1.05; background: linear-gradient(135deg, var(--star-a), var(--star-b)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.percent-cap { margin-top: 2px; color: var(--muted); font-size: 14px; }
.bar { height: 8px; border-radius: 999px; background: rgba(255,255,255,0.08); margin: 12px auto 0; max-width: 260px; overflow: hidden; }
.bar-fill { height: 100%; width: 0; border-radius: 999px; background: linear-gradient(90deg, var(--star-a), var(--star-b)); transition: width 0.6s ease; }

.reading { white-space: pre-wrap; line-height: 1.55; margin: 0; }

/* Тизер Pro: заголовки платных секций видны, контент заблюрен под замком. */
.teaser { margin-top: 14px; padding: 12px; border-radius: 14px; border: 1px solid rgba(139, 107, 255, 0.35); background: rgba(139, 107, 255, 0.08); cursor: pointer; position: relative; }
.teaser-sec { margin-bottom: 10px; }
.teaser-sec:last-of-type { margin-bottom: 0; }
.teaser-title { font-weight: 600; font-size: 15px; }
.teaser-title .lock { font-size: 13px; }
.teaser-body { margin-top: 3px; color: var(--muted); line-height: 1.5; filter: blur(4px); user-select: none; pointer-events: none; letter-spacing: 1px; }
.teaser-cta { margin-top: 12px; text-align: center; font-weight: 600; font-size: 14px; color: var(--star-a); }

.share-btn { margin-top: 14px; }

/* Шарируемая карточка-картинка результата (canvas) */
.card-wrap { margin-top: 16px; border-radius: 14px; overflow: hidden; border: 1px solid rgba(255,255,255,0.08); }
.card-wrap canvas { display: block; width: 100%; height: auto; }

.pro h2 { margin: 0 0 8px; font-size: 18px; }
.referral { margin-top: 14px; border: 1px solid rgba(255,255,255,0.08); }
.referral h2 { margin: 0 0 8px; font-size: 18px; }
.referral .primary { margin-top: 4px; }
#referralStats { margin-top: 8px; }
.plan { position: relative; width: 100%; text-align: left; display: flex; flex-direction: column; gap: 3px; padding: 12px; margin-top: 8px; border-radius: 12px; border: 1px solid rgba(255,255,255,0.1); background: var(--bg); color: var(--text); cursor: pointer; }
.plan-title { font-weight: 600; }
.plan-desc { font-size: 13px; color: var(--muted); }
.plan-price { font-weight: 600; color: var(--accent); }
/* Иерархия пейволла: подзаголовки групп (подписка / разовые) */
.plans-group { margin-top: 14px; font-size: 12px; font-weight: 700; letter-spacing: 0.4px; text-transform: uppercase; color: var(--muted); }
.plans-group:first-child { margin-top: 4px; }
/* Рекомендуемый план — выделяем рамкой и лёгким свечением */
.plan.featured { border-color: var(--star-b); background: rgba(255, 107, 214, 0.07); }
/* Бейджи на плане: «★ популярный» и «−N% выгодно» */
.plan-badges { position: absolute; top: -9px; right: 12px; display: flex; gap: 6px; }
.plan-badge { font-size: 11px; font-weight: 700; line-height: 1; padding: 4px 9px; border-radius: 999px; white-space: nowrap; }
.plan-badge.popular { background: linear-gradient(135deg, var(--star-a), var(--star-b)); color: #fff; }
.plan-badge.save { background: rgba(255, 107, 214, 0.18); color: var(--star-b); border: 1px solid rgba(255, 107, 214, 0.4); }
/* «Подарить Pro другу» — вторичная кнопка под списком планов. */
.gift-pro-btn { margin-top: 16px; }
.gift-pro-hint { margin: 8px 0 0; font-size: 13px; line-height: 1.4; }

/* Pro-фичи списком (вместо одного длинного предложения) */
.pro-feats { list-style: none; margin: 0 0 6px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.pro-feats li { font-size: 14px; color: var(--text); line-height: 1.4; }

/* Пример результата (демо) на первом экране */
.demo { position: relative; text-align: center; border: 1px dashed rgba(139, 107, 255, 0.4); background: rgba(139, 107, 255, 0.05); }
.demo-badge { position: absolute; top: 12px; right: 12px; font-size: 11px; font-weight: 700; color: var(--star-a); background: rgba(139, 107, 255, 0.14); border-radius: 999px; padding: 3px 10px; }
.demo-head { font-size: 18px; font-weight: 600; margin-top: 4px; }
.demo-percent { font-size: 48px; font-weight: 800; line-height: 1.1; background: linear-gradient(135deg, var(--star-a), var(--star-b)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.demo .bar { margin-top: 8px; }
.demo-text { text-align: left; line-height: 1.5; margin-top: 12px; color: var(--text); }

/* Баланс пакета синастрий (pay-per-use) */
.syn-credits { margin-top: 10px; font-size: 14px; font-weight: 600; color: var(--star-b); background: rgba(255, 107, 214, 0.1); border-radius: 10px; padding: 8px 12px; }

.disclaimer { color: var(--muted); font-size: 12px; line-height: 1.5; text-align: center; margin: 4px 8px 0; }
.hidden { display: none; }

/* Вкладки */
.tabs { display: flex; gap: 6px; background: var(--card-bg); border-radius: 14px; padding: 5px; }
.tab { flex: 1; padding: 10px 6px; border: none; border-radius: 10px; background: transparent; color: var(--muted); font-size: 14px; font-weight: 600; font-family: inherit; cursor: pointer; }
.tab.active { background: linear-gradient(135deg, var(--star-a), var(--star-b)); color: #fff; }
.tab-body { display: flex; flex-direction: column; gap: 14px; }
.tab-body.hidden { display: none; }

/* Переключатель режима совместимости (романтика/дружба/бизнес) */
.mode-switch { display: flex; gap: 6px; background: var(--bg); border-radius: 12px; padding: 4px; margin-bottom: 14px; }
.mode-btn { flex: 1; padding: 9px 4px; border: none; border-radius: 9px; background: transparent; color: var(--muted); font-size: 13px; font-weight: 600; font-family: inherit; cursor: pointer; white-space: nowrap; }
.mode-btn.active { background: linear-gradient(135deg, var(--star-a), var(--star-b)); color: #fff; }

/* Кнопки-ссылки и второстепенные */
.link-btn { width: 100%; background: none; border: none; color: var(--star-a); font-size: 14px; font-weight: 600; font-family: inherit; cursor: pointer; padding: 8px 0; text-align: left; }
.ghost { width: 100%; padding: 12px; border: 1px solid rgba(139, 107, 255, 0.45); border-radius: 14px; background: rgba(139, 107, 255, 0.1); color: var(--star-a); font-size: 15px; font-weight: 600; font-family: inherit; cursor: pointer; margin-top: 14px; }
.ghost:disabled { opacity: 0.6; }

/* Блок дат рождения */
.birth-box { margin-bottom: 12px; }
.birth-box .signs { margin-bottom: 6px; }

.lunar-badge { margin-top: 10px; display: inline-block; font-size: 12px; color: var(--star-b); background: rgba(255, 107, 214, 0.12); border-radius: 999px; padding: 4px 12px; }
.lunar-badge.hidden { display: none; }

/* Сферы: шкалы */
.spheres { margin-top: 16px; padding: 14px; border-radius: 14px; border: 1px solid rgba(139, 107, 255, 0.3); background: rgba(139, 107, 255, 0.06); }
.spheres-title { font-weight: 700; font-size: 16px; margin-bottom: 12px; }
.spheres-verdict { font-size: 14px; line-height: 1.5; color: var(--text); background: rgba(139, 107, 255, 0.1); border-radius: 10px; padding: 10px 12px; margin-bottom: 14px; }
.sphere-row { margin-bottom: 14px; }
.sphere-row:last-child { margin-bottom: 0; }
.sphere-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.sphere-name { font-weight: 600; font-size: 15px; }
.sphere-score { font-weight: 700; font-size: 15px; color: var(--star-b); }
.sphere-bar { height: 8px; border-radius: 999px; background: rgba(255, 255, 255, 0.08); margin: 6px 0; overflow: hidden; }
.sphere-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--star-a), var(--star-b)); transition: width 0.5s ease; }
.sphere-comment { font-size: 13px; color: var(--muted); line-height: 1.45; }

/* Справочник знаков */
.sign-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.sign-cell { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 4px; border-radius: 12px; border: 1px solid rgba(255, 255, 255, 0.08); background: var(--bg); color: var(--text); cursor: pointer; font-family: inherit; }
.sign-cell .se { font-size: 24px; }
.sign-cell .sn { font-size: 13px; }
.sign-cell.active { border-color: var(--star-b); background: rgba(255, 107, 214, 0.08); }
.sign-detail h3 { margin: 0 0 4px; font-size: 20px; }
.sign-detail .sd-meta { color: var(--muted); font-size: 14px; margin-bottom: 12px; }
.sign-detail .sd-row { margin-bottom: 8px; line-height: 1.5; }
.sign-detail .sd-label { font-weight: 600; }
.sign-detail .sd-motto { margin-top: 10px; font-style: italic; color: var(--star-a); }

/* Гороскоп (день/неделя/месяц по знаку) */
.horo-pick { margin-top: 12px; margin-bottom: 12px; }
.horo-result { padding: 16px; }
.horo-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 12px; }
.horo-title { font-size: 20px; font-weight: 700; }
.horo-period { font-size: 13px; color: var(--star-b); font-weight: 600; flex: none; }
.horo-row { display: flex; flex-direction: column; gap: 2px; padding: 10px 0; border-top: 1px solid rgba(255, 255, 255, 0.06); }
.horo-row:first-of-type { border-top: none; padding-top: 0; }
.horo-key { font-weight: 600; font-size: 14px; color: var(--star-a); }
.horo-val { line-height: 1.5; }
.horo-lucky { margin-top: 12px; padding-top: 12px; border-top: 1px solid rgba(255, 255, 255, 0.06); font-size: 13px; color: var(--muted); line-height: 1.6; }

/* История */
.hist-search { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.hist-search .select { background-image: none; padding-right: 12px; }
.hist-search .link-btn { width: auto; flex: none; white-space: nowrap; padding: 8px 4px; }
.history-list { margin-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.h-item { padding: 12px; border-radius: 12px; border: 1px solid rgba(255, 255, 255, 0.08); background: var(--bg); cursor: pointer; }
.h-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.h-input { font-weight: 600; font-size: 15px; }
.h-pct { font-weight: 700; color: var(--star-b); font-size: 15px; flex: none; }
.h-date { color: var(--muted); font-size: 12px; margin-top: 2px; }
.h-spheres { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.h-chip { font-size: 11px; color: var(--muted); background: rgba(139, 107, 255, 0.1); border-radius: 999px; padding: 2px 8px; }

/* Лента проверенных пар (ctx.history kind="match"): «доска коллекции» на главном экране */
.match-feed { border: 1px solid rgba(139, 107, 255, 0.22); }
.match-feed.hidden { display: none; }
.mf-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.mf-title { font-size: 17px; font-weight: 700; }
.mf-count { font-size: 12px; font-weight: 700; color: var(--star-b); background: rgba(255, 107, 214, 0.12); border-radius: 999px; padding: 3px 10px; white-space: nowrap; }
/* Бейджи-вехи коллекции: взятые — яркие, не взятые — приглушённые. Последний взятый — с обводкой. */
.mf-badges { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 6px; }
.mf-badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 600; padding: 4px 9px; border-radius: 999px; border: 1px solid transparent; background: rgba(255, 255, 255, 0.05); color: var(--muted); }
.mf-badge.earned { background: rgba(139, 107, 255, 0.16); color: var(--text); }
.mf-badge.highlight { border-color: var(--star-b); background: rgba(255, 107, 214, 0.14); color: var(--text); }
.mf-badge .mf-badge-emoji { font-size: 13px; }
.mf-badge:not(.earned) .mf-badge-emoji { filter: grayscale(1); opacity: 0.5; }
/* Горизонтальная лента карточек собранных пар (скролл вбок, чтобы не растягивать экран) */
.mf-list { margin-top: 12px; display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.mf-list::-webkit-scrollbar { display: none; }
.mf-card { flex: 0 0 auto; width: 124px; padding: 12px 10px; border-radius: 14px; background: var(--bg); border: 1px solid rgba(255, 255, 255, 0.08); text-align: center; }
.mf-card-signs { font-size: 20px; line-height: 1.1; }
.mf-card-names { margin-top: 3px; font-size: 11px; color: var(--muted); line-height: 1.3; min-height: 28px; }
.mf-card-pct { margin-top: 6px; font-size: 26px; font-weight: 800; background: linear-gradient(135deg, var(--star-a), var(--star-b)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.mf-bar { height: 5px; border-radius: 999px; background: rgba(255, 255, 255, 0.08); margin: 6px 0 0; overflow: hidden; }
.mf-bar-fill { height: 100%; width: 0; border-radius: 999px; background: linear-gradient(90deg, var(--star-a), var(--star-b)); }
.mf-card-tags { margin-top: 7px; display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; }
.mf-tag { font-size: 10px; color: var(--muted); background: rgba(139, 107, 255, 0.12); border-radius: 999px; padding: 2px 7px; }
.mf-card-date { margin-top: 6px; font-size: 10px; color: var(--muted); }
.mf-empty { margin-top: 12px; }
.mf-empty.hidden { display: none; }

/* Вкладка «История пар» (вторая волна): лента AI-разборов пары + фильтр по режиму + «Пересчитать» */
.pairs-title { font-size: 18px; font-weight: 700; margin: 0 0 4px; }
.pairs-filter { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 14px; }
.pf-btn { padding: 7px 12px; border: 1px solid rgba(139, 107, 255, 0.3); border-radius: 999px; background: var(--bg); color: var(--muted); font-size: 13px; font-weight: 600; font-family: inherit; cursor: pointer; }
.pf-btn.active { background: linear-gradient(135deg, var(--star-a), var(--star-b)); color: #fff; border-color: transparent; }
.pf-count { font-size: 11px; opacity: 0.85; }
.pairs-list { display: flex; flex-direction: column; gap: 12px; }
.p-item { padding: 14px; border-radius: 14px; border: 1px solid rgba(139, 107, 255, 0.18); background: var(--bg); }
.p-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.p-signs { font-size: 16px; font-weight: 600; }
.p-amp { color: var(--muted); font-weight: 400; }
.p-pct { font-size: 22px; font-weight: 800; flex: none; background: linear-gradient(135deg, var(--star-a), var(--star-b)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.p-bar { height: 6px; border-radius: 999px; background: rgba(255, 255, 255, 0.08); margin: 9px 0 0; overflow: hidden; }
.p-bar-fill { height: 100%; width: 0; border-radius: 999px; background: linear-gradient(90deg, var(--star-a), var(--star-b)); }
.p-meta { margin-top: 10px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.p-mode, .p-type { font-size: 11px; font-weight: 600; color: var(--text); background: rgba(139, 107, 255, 0.16); border-radius: 999px; padding: 3px 9px; }
.p-type { background: rgba(255, 107, 214, 0.14); }
.p-date { font-size: 11px; color: var(--muted); margin-left: auto; }
.p-recalc { margin-top: 12px; padding: 10px; font-size: 14px; }
.pairs-empty { margin-top: 14px; }
.pairs-empty.hidden { display: none; }

/* Диалог-уточнение (Pro): вопрос по своей разобранной паре */
.clarify { margin-top: 16px; padding-top: 14px; border-top: 1px solid rgba(255, 255, 255, 0.08); }
.clarify-title { font-weight: 600; font-size: 16px; margin-bottom: 2px; }
.clarify textarea { width: 100%; margin: 8px 0; padding: 12px; border-radius: 12px; border: 1px solid rgba(255, 255, 255, 0.12); background: var(--bg); color: var(--text); font-size: 15px; font-family: inherit; resize: vertical; }
.clarify .ghost { margin-top: 0; }
.clarify-answer { margin-top: 12px; padding: 12px; border-radius: 12px; background: var(--bg); border: 1px solid rgba(255, 255, 255, 0.08); }
.clarify-teaser { margin-top: 16px; }

/* --- Синастрия (реальная натальная совместимость) --- */
.syn-intro { margin-bottom: 14px; }
.syn-title { font-size: 18px; font-weight: 700; margin-bottom: 4px; }
.syn-person { margin-bottom: 14px; padding: 12px; border-radius: 14px; background: var(--bg); border: 1px solid rgba(255, 255, 255, 0.08); }
.syn-person-title { font-weight: 600; font-size: 15px; margin-bottom: 8px; color: var(--star-a); }
.syn-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.syn-field:last-child { margin-bottom: 0; }
.syn-field-row { display: flex; gap: 10px; }
.syn-field-row .syn-field { flex: 1; min-width: 0; margin-bottom: 0; }
.syn-aspects { margin: 6px 0 12px; }
.syn-aspects-title { font-weight: 600; font-size: 15px; margin-bottom: 8px; }
.syn-asp-row { display: flex; align-items: center; gap: 8px; padding: 7px 0; border-bottom: 1px solid rgba(255, 255, 255, 0.06); font-size: 14px; }
.syn-asp-row:last-child { border-bottom: none; }
.syn-asp-emo { flex: none; width: 22px; text-align: center; }
.syn-asp-text { flex: 1; min-width: 0; }
.syn-asp-orb { flex: none; color: var(--muted); font-size: 12px; }

/* --- Запрос согласия на обработку ПДн (блок D / П-2) --- */
.consent-gate {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(8, 8, 24, 0.82);
  backdrop-filter: blur(4px);
}
.consent-gate.hidden { display: none; }
.consent-box {
  max-width: 420px;
  width: 100%;
  padding: 22px 20px 20px;
  border-radius: 18px;
  background: var(--card, #1b1b2e);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}
.consent-box h2 { margin: 0 0 10px; font-size: 19px; }
.consent-text { margin: 0 0 14px; font-size: 14px; line-height: 1.5; color: var(--muted, #9aa0c4); }
.consent-check { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; line-height: 1.45; cursor: pointer; }
.consent-check input { margin-top: 3px; flex: none; width: 18px; height: 18px; }
.consent-check a { color: var(--star-a, #7aa2ff); }
.consent-box .primary { margin-top: 16px; width: 100%; }
.consent-box .primary:disabled { opacity: 0.5; cursor: not-allowed; }

/* Авторитетная утилита скрытия: объявлена ПОСЛЕДНЕЙ, чтобы при равной специфичности побеждать
   любые одноклассовые display-правила компонентов (корень бага .hidden-специфичности). 2-классовые
   show-правила и инлайн-стили НЕ перебивает (без !important). */
.hidden { display: none; }
