/* =============================================================
   Тема «black-box cinema»: чёрный холст, белый текст,
   единственный тёплый градиент — только на продающих элементах.
   Правки цветов и размеров — здесь, в токенах ниже.
   ============================================================= */
:root {
  color-scheme: dark;

  /* --- Поверхности --- */
  --canvas: #000000;          /* фон страницы */
  --surface: #111111;         /* карточки */
  --elevated: #252525;        /* приподнятые блоки, иконки, нажатия */
  --border: #343434;          /* волосяные линии и рамки карточек */
  --border-strong: #4d4d4d;   /* рамки кнопок */

  /* --- Текст --- */
  --text: #ffffff;            /* заголовки и активный текст */
  --text-helper: #a0a0a0;     /* подписи, которым белый слишком громкий */
  --text-muted: #888888;      /* метаданные, второстепенное */

  /* --- Тёплый градиент: только баннер и кнопки оплаты --- */
  --warm-from: #ff8a00;
  --warm-to: #fa3a19;
  --warm-text-from: #ffc840;
  --gradient-warm: linear-gradient(90deg, var(--warm-from) 0%, var(--warm-to) 100%);
  --gradient-warm-text: linear-gradient(90deg, var(--warm-text-from) 0%, var(--warm-to) 100%);
  --gradient-wash: linear-gradient(90deg, rgba(255, 138, 0, .12) 0%, rgba(250, 58, 25, .10) 100%);

  /* --- Типографика --- */
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --text-meta: 13px;
  --text-caption: 15px;
  --text-body: 16px;
  --text-body-lg: 18px;
  --text-subheading: 20px;
  --text-heading: 24px;       /* потолок шкалы, выше не поднимаем */

  /* --- Отступы (шаг 8) --- */
  --s-8: 8px;
  --s-16: 16px;
  --s-24: 24px;
  --s-32: 32px;
  --s-40: 40px;
  --s-48: 48px;
  --section-gap: var(--s-32);  /* на широком экране — 48, см. медиазапрос внизу */

  /* --- Скругления: плоская система, максимум 6px --- */
  --r-card: 6px;
  --r-btn: 6px;
  --r-badge: 4px;

  --tabbar-h: 60px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--canvas); color: var(--text); }
body {
  font: 400 var(--text-body) / 1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(var(--tabbar-h) + var(--safe-b) + var(--s-16));
  overscroll-behavior-y: none;
}
a { color: var(--text); text-decoration: underline; text-underline-offset: 2px; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; }
input, textarea { font: inherit; color: var(--text); }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

#app { max-width: 640px; margin: 0 auto; padding: var(--s-16) var(--s-16) 0; }

/* ===== Общие блоки ===== */
.splash { min-height: 70vh; display: grid; place-items: center; }
.spinner {
  width: 28px; height: 28px; border-radius: 50%;
  border: 2px solid var(--elevated); border-top-color: var(--text);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: var(--s-8); padding-bottom: var(--s-24); }
.topbar h1 { font-size: var(--text-heading); line-height: 1.33; font-weight: 700; margin: 0; }

/* Бейдж тарифа в шапке */
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: var(--r-badge);
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  font-size: var(--text-meta); font-weight: 600; white-space: nowrap;
}
.chip svg { width: 15px; height: 15px; }
.chip.muted { color: var(--text-muted); }

.section-title {
  font-size: var(--text-heading); line-height: 1.33; font-weight: 700; color: var(--text);
  margin: var(--section-gap) 0 var(--s-16);
}
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); padding: var(--s-16); }
.card + .card { margin-top: var(--s-8); }
.hint { color: var(--text-muted); font-size: var(--text-caption); }
.empty { text-align: center; color: var(--text-muted); padding: var(--s-32) var(--s-16); }

/* ===== Кнопки =====
   .btn.cta              — тёплый градиент, только оплата и переход к тарифам
   .btn                  — основное действие: плотная серая заливка
   .btn.secondary/.ghost — контурные и приглушённые
*/
.btn {
  display: flex; align-items: center; justify-content: center; gap: var(--s-8); width: 100%;
  min-height: 48px; padding: 12px var(--s-16); border-radius: var(--r-btn);
  font-size: var(--text-body); font-weight: 700; line-height: 1.25;
  background: var(--elevated); border: 1px solid var(--border-strong); color: var(--text);
  transition: background .12s ease, opacity .12s ease;
}
.btn:active { background: var(--border); }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn.cta { background: var(--gradient-warm); border-color: transparent; color: #fff; }
.btn.cta:active { opacity: .88; }
.btn.secondary { background: transparent; border-color: var(--border-strong); font-weight: 600; }
.btn.ghost { background: transparent; border-color: var(--border); color: var(--text-helper); font-weight: 600; }
.btn.success { background: transparent; border-color: var(--border-strong); }
.btn + .btn { margin-top: var(--s-8); }
.row-btns { display: flex; gap: var(--s-8); }
.row-btns .btn + .btn { margin-top: 0; }

/* Маленькая кнопка-ссылка внутри карточек */
.chip-btn {
  padding: var(--s-8) 14px; border-radius: var(--r-btn); background: var(--elevated); border: 1px solid var(--border-strong);
  color: var(--text); font-size: var(--text-caption); font-weight: 600; white-space: nowrap;
}

/* ===== Продающий баннер — единственное цветное пятно ===== */
.banner {
  position: relative; border-radius: var(--r-badge); padding: var(--s-16);
  background: var(--gradient-wash), var(--canvas);
  border: 1px solid rgba(255, 138, 0, .32);
}
.banner .save {
  display: inline-block; margin-bottom: 2px; font-size: var(--text-subheading); font-weight: 700; line-height: 1.4;
  background: var(--gradient-warm-text); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.banner h2 { margin: 0 0 4px; font-size: var(--text-body-lg); line-height: 1.4; font-weight: 700; color: var(--text); }
.banner p { margin: 0 0 var(--s-16); color: var(--text-helper); font-size: var(--text-caption); }
.banner .btn { margin-top: 0; }

/* ===== Главная ===== */
.hero { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); padding: var(--s-16); }
.hero h2 { margin: 0 0 4px; font-size: var(--text-subheading); line-height: 1.4; font-weight: 700; }
.hero p { margin: 0; color: var(--text-helper); font-size: var(--text-caption); }
.progress { height: 6px; border-radius: var(--r-badge); background: var(--elevated); margin: var(--s-16) 0 var(--s-8); overflow: hidden; }
.progress > div { height: 100%; background: var(--text); transition: width .4s ease; }
.hero .progress-label { font-size: var(--text-caption); color: var(--text-muted); }
.hero .btn { margin-top: var(--s-16); }

/* Карточка-приглашение (пробный урок, апгрейд в профиле) */
.promo { display: flex; gap: var(--s-16); align-items: center; margin-top: var(--s-8); }
.promo .icon {
  width: 40px; height: 40px; border-radius: var(--r-badge); display: grid; place-items: center;
  background: var(--elevated); color: var(--text); flex: none;
}
.promo b { display: block; font-size: var(--text-body); font-weight: 700; }
.promo .hint { display: block; }

/* Модули и уроки */
.module { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); overflow: hidden; }
.module + .module { margin-top: var(--s-8); }
.module-head { display: flex; align-items: center; gap: var(--s-16); width: 100%; padding: var(--s-16); text-align: left; }
.module-num {
  width: 28px; height: 28px; flex: none; border-radius: var(--r-badge); display: grid; place-items: center;
  background: var(--elevated); color: var(--text-helper); font-size: var(--text-caption); font-weight: 700;
}
.module-head .title { flex: 1; min-width: 0; }
.module-head .title b { display: block; font-size: var(--text-body); font-weight: 700; line-height: 1.4; }
.module-head .title span { font-size: var(--text-caption); color: var(--text-muted); }
.module-head .chev { color: var(--text-muted); transition: transform .2s ease; }
.module.open .chev { transform: rotate(90deg); }
.lessons { display: none; border-top: 1px solid var(--border); }
.module.open .lessons { display: block; }
.lesson-row { display: flex; align-items: center; gap: var(--s-16); width: 100%; padding: 12px var(--s-16); text-align: left; }
.lesson-row + .lesson-row { border-top: 1px solid var(--border); }
.lesson-row:active { background: var(--elevated); }
.lesson-row .st {
  width: 26px; height: 26px; flex: none; border-radius: var(--r-badge); display: grid; place-items: center;
  background: var(--elevated); color: var(--text); border: 1px solid transparent;
}
.lesson-row .st svg { width: 15px; height: 15px; }
.lesson-row.done .st { background: var(--text); color: var(--canvas); }
.lesson-row.locked .st { background: transparent; border-color: var(--border); color: var(--text-muted); }
.lesson-row .lt { flex: 1; min-width: 0; font-size: var(--text-body); font-weight: 600; line-height: 1.4; }
.lesson-row.locked .lt { color: var(--text-muted); font-weight: 400; }
.tag {
  font-size: var(--text-meta); font-weight: 600; padding: 3px var(--s-8); border-radius: var(--r-badge);
  background: var(--elevated); color: var(--text-helper); white-space: nowrap;
}

/* ===== Урок ===== */
.back-link {
  display: inline-flex; align-items: center; gap: 4px; color: var(--text-helper);
  font-size: var(--text-caption); font-weight: 600; margin-bottom: var(--s-16); text-decoration: none;
}
.player {
  position: relative; width: 100%; aspect-ratio: 16 / 9; border-radius: var(--r-card);
  overflow: hidden; background: #000; border: 1px solid var(--border);
}
.player iframe, .player video { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.lesson-meta { color: var(--text-muted); font-size: var(--text-caption); margin: var(--s-16) 0 4px; }
.lesson-title { font-size: var(--text-heading); line-height: 1.33; font-weight: 700; margin: 0 0 var(--s-16); }
.rich { font-size: var(--text-body); line-height: 1.6; word-wrap: break-word; }
.rich blockquote {
  margin: 12px 0; padding: var(--s-8) 12px; border-left: 2px solid var(--border-strong);
  background: var(--elevated); border-radius: 0 var(--r-badge) var(--r-badge) 0; color: var(--text-helper);
}
.rich pre, .rich code {
  font-family: ui-monospace, Menlo, Consolas, monospace; font-size: var(--text-caption);
  background: var(--canvas); border: 1px solid var(--border); border-radius: var(--r-badge);
}
.rich code { padding: 1px 5px; }
.rich pre { padding: 10px 12px; overflow-x: auto; }
.rich tg-spoiler { background: var(--border-strong); color: transparent; border-radius: var(--r-badge); cursor: pointer; }
.rich tg-spoiler.shown { background: none; color: inherit; }
.materials a, .materials div {
  display: flex; gap: 10px; align-items: center; padding: 12px 0;
  word-break: break-word; font-size: var(--text-body); text-decoration: none;
}
.materials a svg { color: var(--text-muted); }
.materials > :first-child { padding-top: 0; }
.materials > * + * { border-top: 1px solid var(--border); }
.lesson-actions { margin-top: var(--s-24); }

/* ===== Тарифы ===== */
.tariff {
  position: relative; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-card); padding: var(--s-16);
}
.tariff + .tariff { margin-top: var(--s-8); }
.tariff.current { border-color: var(--border-strong); }
.tariff.best { border-color: rgba(255, 138, 0, .32); }
.tariff.best::before {
  content: "Популярный"; position: absolute; top: -1px; right: -1px;
  padding: 4px 10px; border-radius: 0 var(--r-card) 0 var(--r-badge);
  background: var(--gradient-warm); color: #fff; font-size: var(--text-meta); font-weight: 700;
}
.tariff-level { font-size: var(--text-meta); font-weight: 600; color: var(--text-muted); }
.tariff h3 { margin: 2px 0; font-size: var(--text-subheading); line-height: 1.4; font-weight: 700; }
.tariff .sub { color: var(--text-helper); font-size: var(--text-caption); }
.features { list-style: none; padding: 0; margin: var(--s-16) 0; }
.features li { display: flex; gap: 10px; align-items: flex-start; padding: 5px 0; font-size: var(--text-body); font-weight: 400; }
.features li svg { width: 18px; height: 18px; color: var(--text-muted); margin-top: 3px; }
.price-row { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: var(--s-16); }
.price { font-size: var(--text-heading); line-height: 1.33; font-weight: 700; }
.price-old { color: var(--text-muted); text-decoration: line-through; font-size: var(--text-caption); }
.price-note {
  width: 100%; font-size: var(--text-caption); font-weight: 600;
  background: var(--gradient-warm-text); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.owned-badge { display: flex; align-items: center; gap: var(--s-8); color: var(--text); font-weight: 600; font-size: var(--text-caption); }
.owned-badge svg { width: 18px; height: 18px; }

/* ===== Эфиры ===== */
.event { display: flex; gap: var(--s-16); align-items: center; }
.event-date {
  width: 52px; flex: none; text-align: center; border-radius: var(--r-badge); padding: var(--s-8) 0;
  background: var(--elevated); color: var(--text);
}
.event-date b { display: block; font-size: var(--text-subheading); line-height: 1.1; font-weight: 700; }
.event-date span { font-size: var(--text-meta); font-weight: 600; text-transform: uppercase; color: var(--text-muted); }
.event-date.past { color: var(--text-muted); }
.event-body { flex: 1; min-width: 0; }
.event-body b { display: block; font-size: var(--text-body); font-weight: 700; line-height: 1.4; }
.event-body .hint { font-size: var(--text-caption); }
.event .mini-btn {
  padding: var(--s-8) 12px; border-radius: var(--r-btn); background: var(--elevated);
  border: 1px solid var(--border-strong); color: var(--text);
  font-weight: 600; font-size: var(--text-caption); white-space: nowrap;
}
.event .mini-btn.ghost { background: transparent; border-color: var(--border); color: var(--text-helper); }
.event > .hint svg { color: var(--text-muted); }
.locked-card { text-align: center; }
.locked-card .icon {
  width: 44px; height: 44px; margin: 0 auto var(--s-16); border-radius: var(--r-badge);
  display: grid; place-items: center; background: var(--elevated); color: var(--text);
}
.locked-card b { font-size: var(--text-body-lg); font-weight: 700; }
.locked-card p { margin: var(--s-8) 0 var(--s-16); color: var(--text-helper); font-size: var(--text-caption); }

/* ===== Профиль ===== */
.profile-head { display: flex; align-items: center; gap: var(--s-16); }
.avatar {
  width: 52px; height: 52px; border-radius: var(--r-card); display: grid; place-items: center; flex: none;
  background: var(--elevated); color: var(--text); font-size: var(--text-subheading); font-weight: 700;
}
.profile-head b { font-size: var(--text-body-lg); font-weight: 700; display: block; }
.list-item { display: flex; align-items: center; gap: var(--s-16); width: 100%; padding: 14px var(--s-16); text-align: left; }
.list-item + .list-item { border-top: 1px solid var(--border); }
.list-item:active { background: var(--elevated); }
.list-item .li-icon {
  width: 32px; height: 32px; border-radius: var(--r-badge); display: grid; place-items: center;
  background: var(--elevated); color: var(--text); flex: none;
}
.list-item .li-icon svg { width: 18px; height: 18px; }
.list-item span { flex: 1; font-size: var(--text-body); font-weight: 600; }
.list-item .chev { color: var(--text-muted); width: 18px; height: 18px; }
.card.flush { padding: 0; overflow: hidden; }

.field { display: block; margin-bottom: var(--s-16); }
.field span { display: block; font-size: var(--text-caption); color: var(--text-muted); margin-bottom: 6px; }
.field input, .field textarea {
  width: 100%; padding: 12px 14px; border-radius: var(--r-btn); border: 1px solid var(--border);
  background: var(--canvas); outline: none; font-size: var(--text-body);
}
.field input::placeholder, .field textarea::placeholder { color: var(--text-muted); }
.field input:focus, .field textarea:focus { border-color: var(--text); }
.field textarea { min-height: 84px; resize: vertical; }

/* ===== Нижнее меню ===== */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; justify-content: space-around;
  height: calc(var(--tabbar-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: var(--canvas); border-top: 1px solid var(--border);
}
.tabbar a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--text-muted); font-size: var(--text-meta); font-weight: 600; text-decoration: none;
}
.tabbar a.active { color: var(--text); }

/* ===== Шторка оплаты ===== */
.sheet-backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, .7); animation: fade .2s ease; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; max-width: 640px; margin: 0 auto;
  background: var(--surface); border-top: 1px solid var(--border);
  border-radius: var(--r-card) var(--r-card) 0 0;
  padding: var(--s-8) var(--s-16) calc(var(--s-16) + var(--safe-b));
  max-height: 90vh; overflow-y: auto; animation: up .25s ease;
}
.sheet .grab { width: 36px; height: 4px; border-radius: var(--r-badge); background: var(--border-strong); margin: 0 auto var(--s-16); }
.sheet h3 { margin: 0 0 4px; font-size: var(--text-subheading); line-height: 1.4; font-weight: 700; }
.sum-row {
  display: flex; justify-content: space-between; gap: var(--s-16); padding: 12px 0;
  border-bottom: 1px solid var(--border); font-size: var(--text-body); color: var(--text-helper);
}
.sum-row.total { border: 0; font-weight: 700; font-size: var(--text-body-lg); color: var(--text); }
.legal { font-size: var(--text-meta); line-height: 1.5; color: var(--text-muted); margin: 12px 0 var(--s-16); }
.legal a { color: var(--text-helper); }
.wait { text-align: center; }
.wait .spinner { margin: var(--s-8) auto var(--s-16); }
.wait h3 { margin-bottom: var(--s-8); }
.wait p { margin: 0 0 var(--s-16); }
@keyframes up { from { transform: translateY(100%); } }
@keyframes fade { from { opacity: 0; } }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + var(--safe-b) + var(--s-16)); z-index: 60;
  transform: translateX(-50%); max-width: calc(100vw - var(--s-32));
  padding: 12px var(--s-16); border-radius: var(--r-btn);
  background: var(--elevated); border: 1px solid var(--border); color: var(--text);
  font-size: var(--text-caption); animation: fade .2s ease;
}

/* На широком экране разрежаем сетку до референсных 48px между секциями */
@media (min-width: 700px) {
  :root { --section-gap: var(--s-48); }
  #app { padding: var(--s-24) var(--s-24) 0; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
