/* ==========================================
   БАЗОВЫЕ СТИЛИ И ПЕРЕМЕННЫЕ
   ========================================== */

:root {
  --bg: #131a26;
  --card: #1c263a;
  --card2: #24324b;
  --primary: #5c8dff;
  --primary2: #3fb950;
  --accent: #b06bff;
  --grad: linear-gradient(135deg, #5c8dff, #b06bff);
  --gold: #f5a623;
  --border: #2e3c56;
  --text: #f0f6fc;
  --muted: #8b949e;
  --danger: #f85149;

  /* Шрифты и радиусы */
  --fh: 'Unbounded', system-ui, sans-serif;
  --fb: 'Onest', system-ui, sans-serif;
  --r: 18px;

  /* Алиасы для JS */
  --font-heading: var(--fh);
  --font-body: var(--fb);
  --font-b: var(--fb);
  --radius: var(--r);
  --card-grad: linear-gradient(135deg, var(--card2), var(--card));

  /* Отступы и текст */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --text-xs: 11px;
  --text-sm: 13px;
  --text-base: 15px;
  --text-lg: 18px;
  --text-xl: 24px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  font-family: var(--fb);
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.5;
  font-size: 16px;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(circle at 15% 10%, rgba(92,141,255,.15) 0%, transparent 45%),
    radial-gradient(circle at 90% 70%, rgba(176,107,255,.10) 0%, transparent 45%);
}

/* Сбросы */
ul, ol { list-style: none; padding: 0; margin: 0; }
button { font-family: inherit; }
a { color: inherit; text-decoration: none; }

/* ==========================================
   ЭКРАНЫ
   ========================================== */
.screen {
  display: none;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  position: relative;
  z-index: 1;
}
.screen.active { display: flex; }

/* ==========================================
   ТОПБАР
   ========================================== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: rgba(19, 26, 38, 0.85);
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  gap: 12px;
}

.avatar { width: 40px; height: 40px; border-radius: 12px; background: var(--card); border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; color: var(--primary); flex-shrink: 0; overflow: hidden; }
.avatar svg { width: 20px; height: 20px; }
.avatar img { width: 100%; height: 100%; object-fit: cover; object-position: center; display: block; }
.username { font-family: var(--fh); font-weight: 800; font-size: 16px; line-height: 1.2; }
.sublabel { font-size: 12px; color: var(--muted); }
.streak { font-family: var(--fh); font-weight: 800; font-size: 14px; color: var(--gold); display: flex; align-items: center; gap: 4px; }
.streak svg { width: 16px; height: 16px; }
.back-link { cursor: pointer; color: var(--primary); font-weight: 600; font-size: 14px; }
.sec-title { font-family: var(--fh); font-weight: 700; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.sec-icon, .btn-ico { display: inline-flex; }
.sec-icon svg, .btn-ico svg { width: 18px; height: 18px; }

/* ==========================================
   СКРОЛЛ
   ========================================== */
.scroll {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  padding-bottom: 100px;
}

/* ==========================================
   НИЖНЯЯ НАВИГАЦИЯ
   ========================================== */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: rgba(19, 26, 38, 0.95);
  backdrop-filter: blur(14px);
  display: flex;
  justify-content: space-around;
  padding: 10px 0;
  border-top: 1px solid var(--border);
  z-index: 50;
}
.nav-item {
  background: none; border: none;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  color: var(--muted); font-size: 10px; cursor: pointer;
  padding: 8px 12px; border-radius: 12px; transition: .2s;
}
.nav-item.active { color: var(--primary); }
.nav-icon svg { width: 24px; height: 24px; }
.sidebar-subscribe { display: none; }

/* ==========================================
   АВТОРИЗАЦИЯ
   ========================================== */
#auth-screen {
  display: none; position: fixed; inset: 0; z-index: 100;
  background: var(--bg); align-items: center; justify-content: center; padding: 20px;
}
#auth-screen.show { display: flex; }
.auth-card { background: var(--card); border: 1px solid var(--border); border-radius: 24px; padding: 32px 24px; width: 100%; max-width: 400px; text-align: center; box-shadow: 0 20px 40px rgba(0,0,0,.4); }
.auth-title { font-family: var(--fh); font-size: 22px; font-weight: 800; margin-bottom: 8px; }
.auth-subtitle { font-size: var(--text-sm); color: var(--muted); margin-bottom: 24px; }
.auth-btn { width: 100%; padding: 16px; border-radius: 14px; border: none; font-family: var(--fh); font-weight: 700; font-size: 15px; color: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 12px; background: var(--grad); transition: transform .15s; }
.auth-btn:active { transform: scale(.98); }
.auth-btn--vk { background: #0077FF; }
.auth-btn-logo svg { width: 20px; height: 20px; }
.auth-status { font-size: 13px; color: var(--danger); margin-top: 8px; min-height: 20px; }
.auth-note { font-size: 12px; color: var(--muted); margin-top: 16px; line-height: 1.4; }

/* ==========================================
   ГЛАВНАЯ (карусель)
   ========================================== */
.carousel { display: flex; gap: 12px; overflow-x: auto; scroll-snap-type: x mandatory; padding: 8px 16px 20px; margin: 0 -16px; scrollbar-width: none; }
.carousel::-webkit-scrollbar { display: none; }
.carousel-card { flex: 0 0 85%; max-width: 320px; scroll-snap-align: center; background: var(--card); border: 1px solid var(--border); border-radius: 20px; padding: 16px; display: flex; flex-direction: column; box-shadow: 0 10px 20px rgba(0,0,0,.2); transform: scale(.95); opacity: .7; transition: transform .3s, opacity .3s; }
.carousel-card.active { transform: scale(1); opacity: 1; }
.cc-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.cc-head-icon { color: var(--primary); display: flex; }
.cc-head-icon--gold { color: var(--gold); }
.cc-head-title { font-family: var(--fh); font-weight: 700; font-size: 14px; }
.cc-head-title--gold { color: var(--gold); }
.cc-metric { font-family: var(--fh); font-size: 32px; font-weight: 800; margin-bottom: 4px; }
.cc-metric--gold { color: var(--gold); }
.cc-subtitle { font-size: 13px; color: var(--muted); margin-bottom: 16px; }
.cc-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.cc-chip { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 12px; font-size: 11px; font-weight: 600; }
.cc-chip--primary { background: rgba(76,141,255,.15); color: var(--primary); }
.cc-chip--success { background: rgba(63,185,80,.15); color: var(--primary2); }
.cc-tasks { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.cc-task { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.cc-task--done { color: var(--primary2); }
.cc-task-check { display: none; }
.cc-task--done .cc-task-check { display: block; }
.cc-bar { height: 6px; background: rgba(255,255,255,.1); border-radius: 3px; overflow: hidden; margin-top: auto; }
.cc-bar-fill { height: 100%; background: var(--primary); border-radius: 3px; }
.cc-action { margin-top: auto; background: rgba(255,255,255,.05); border: 1px solid var(--border); border-radius: 12px; padding: 10px; color: var(--text); font-family: var(--fb); font-size: 13px; font-weight: 600; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 6px; }
.cc-action--gold { background: rgba(245,166,35,.15); color: var(--gold); border-color: transparent; }
.cc-empty { font-size: 12px; color: var(--muted); text-align: center; padding: 12px 0; line-height: 1.4; }
.carousel-dots { display: flex; justify-content: center; gap: 6px; margin-top: -8px; margin-bottom: 16px; }
.carousel-dot { width: 6px; height: 6px; border-radius: 50%; background: rgba(255,255,255,.2); }
.carousel-dot.active { background: var(--primary); width: 16px; border-radius: 3px; }

/* Карточка "Продолжить" */
.continue-card { background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 16px 20px; display: flex; align-items: center; gap: 16px; margin-bottom: 16px; cursor: pointer; transition: transform .12s ease, background .15s; -webkit-tap-highlight-color: transparent; }
.continue-card:active { transform: scale(.98); background: var(--card2); }
.continue-card--primary { border-color: rgba(92,141,255,.5); background: linear-gradient(135deg, rgba(92,141,255,.14), var(--card) 70%); }
.continue-icon { width: 44px; height: 44px; border-radius: 12px; background: rgba(76,141,255,.15); color: var(--primary); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.continue-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 700; }
.continue-title { font-family: var(--fh); font-size: 14px !important; line-height: 1.35; font-weight: 700; }
.continue-card > div:nth-child(2) { flex: 1; min-width: 0; }
.continue-arrow { margin-left: auto; color: var(--muted); display: flex; }

/* Прогресс-бар на главной (До ранга / До награды) */
.path-progress-bar {
  display: block !important; width: 100%; height: 8px !important;
  background: rgba(255,255,255,.12) !important; border-radius: 4px; overflow: hidden;
}
.path-progress-fill {
  display: block !important; height: 100% !important; min-width: 8px; border-radius: 4px;
  background: linear-gradient(90deg, #4c8dff, #a06bff) !important;
  box-shadow: 0 0 10px rgba(160,107,255,.5);
  transition: width .6s ease;
}

/* ==========================================
   СПИСОК РАЗДЕЛОВ / УРОКИ
   ========================================== */
.section-title-with-icon { font-family: var(--fh); font-size: 16px; font-weight: 700; display: flex; align-items: center; gap: 8px; margin: 20px 0 12px; }
.section-title-with-icon svg { width: 20px; height: 20px; color: var(--primary); }
.list-row { background: var(--card); border: 1px solid var(--border); border-radius: 16px; display: flex; align-items: center; padding: 16px; margin-bottom: 12px; cursor: pointer; transition: .15s; }
.list-row:hover { background: var(--card2); }
.list-row--locked { opacity: .5; cursor: not-allowed; }
.status-badge { width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center; margin-right: 12px; flex-shrink: 0; }
.status-badge--current { background: rgba(76,141,255,.15); color: var(--primary); }
.status-badge--done { background: rgba(63,185,80,.15); color: var(--primary2); }
.status-badge--locked { background: rgba(255,255,255,.05); color: var(--muted); }
.mini-progress { height: 6px; background: rgba(255,255,255,.1); border-radius: 3px; overflow: hidden; margin-top: 8px; }
.mini-progress-fill { height: 100%; background: var(--primary); border-radius: 3px; }
.mini-progress--weak .mini-progress-fill { background: var(--danger); }
.section-status { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 600; margin-top: 4px; }
.section-status-dot { width: 6px; height: 6px; border-radius: 50%; }
.section-status--weak { color: var(--danger); }
.section-status-dot--weak { background: var(--danger); }
.section-status--strong { color: var(--primary2); }
.section-status-dot--strong { background: var(--primary2); }

.section-layout { display: flex; flex-direction: column; gap: 16px; }
.lesson-card-rich { display: flex; align-items: center; gap: 16px; padding: 16px; background: var(--card); border: 1px solid var(--border); border-radius: 16px; margin-bottom: 12px; }
.lesson-card-rich--next { border-color: rgba(76,141,255,.5); }
.lesson-card-rich--done { opacity: .7; }
.lesson-card-rich--locked { opacity: .5; }
.lc-num { font-family: var(--fh); font-weight: 800; color: var(--muted); width: 20px; text-align: center; flex-shrink: 0; }
.lc-body { flex: 1; min-width: 0; }
.lc-title { font-weight: 600; font-size: 15px; margin-bottom: 4px; }
.lc-meta { font-size: 12px; color: var(--muted); }
.lc-lock { color: var(--muted); flex-shrink: 0; }
.lc-action-btn { background: var(--grad); color: #fff; border: none; padding: 8px 16px; border-radius: 10px; font-weight: 600; font-size: 13px; cursor: pointer; flex-shrink: 0; }

.section-side-col { display: none; }
.side-info-card { background: var(--card); border: 1px solid var(--border); border-radius: 20px; padding: 20px; }
.side-info-title { font-family: var(--fh); font-size: 14px; font-weight: 700; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.side-info-title svg { width: 18px; height: 18px; color: var(--primary); flex-shrink: 0; }
.side-info-list li { font-size: 13px; color: var(--muted); margin-bottom: 8px; padding-left: 16px; position: relative; }
.side-info-list li::before { content: '•'; color: var(--primary); position: absolute; left: 0; font-size: 16px; }
.side-kim-badge { display: inline-block; background: rgba(76,141,255,.15); color: var(--primary); font-weight: 700; padding: 6px 12px; border-radius: 8px; font-size: 13px; }
.side-info-desc { font-size: 12px; color: var(--muted); line-height: 1.5; }
.side-progress-bar { height: 6px; background: rgba(255,255,255,.1); border-radius: 3px; overflow: hidden; margin-bottom: 8px; }
.side-progress-fill { height: 100%; background: linear-gradient(90deg, #4c8dff, #a06bff); }
.side-info-card--tip { background: linear-gradient(135deg, rgba(245,166,35,.1), rgba(210,153,34,.05)); border-color: rgba(245,166,35,.2); }
.side-info-card--tip .side-info-title { color: var(--gold); }
.fast-track-banner { display: flex; align-items: center; gap: 12px; padding: 16px; background: linear-gradient(135deg, rgba(63,185,80,.12), rgba(76,141,255,.08)); border-radius: 16px; flex-wrap: wrap; }

/* ==========================================
   КВИЗ
   ========================================== */
.quiz-wrap {
  flex: 1; min-height: 0; overflow-y: auto;
  padding: 20px 20px 40px;
  display: flex; flex-direction: column; gap: 16px;
}
.q-progress { height: 8px; background: rgba(255,255,255,.1); border-radius: 4px; overflow: hidden; }
.q-progress-fill { height: 100%; background: var(--grad); transition: width .3s; }
.q-card { background: var(--card); border: 1px solid var(--border); border-radius: 20px; padding: 20px; }
.q-tag { font-size: 11px; color: var(--primary); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; margin-bottom: 12px; }
.q-text { font-family: var(--fh); font-size: 17px; font-weight: 600; line-height: 1.4; }
.answers { display: flex; flex-direction: column; gap: 10px; }
.ans-btn { background: var(--card2); border: 1px solid var(--border); border-radius: 14px; padding: 14px 18px; text-align: left; color: var(--text); font-family: var(--fb); font-size: 15px; font-weight: 500; cursor: pointer; transition: .2s; }
.ans-btn:hover { background: rgba(255,255,255,.05); }
.ans-btn.correct { background: rgba(63,185,80,.15); border-color: var(--primary2); color: #fff; }
.ans-btn.wrong { background: rgba(248,81,73,.15); border-color: var(--danger); color: #fff; }
.btn-next { background: var(--grad); color: #fff; border: none; border-radius: 14px; padding: 14px; font-family: var(--fh); font-size: 15px; font-weight: 700; cursor: pointer; box-shadow: 0 4px 15px rgba(76,141,255,.3); }
.btn-next:disabled { opacity: .5; cursor: not-allowed; box-shadow: none; }
.ai-panel { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 14px; font-size: 13px; }

/* ==========================================
   РЕЗУЛЬТАТ
   ========================================== */
.result-wrap {
  flex: 1; min-height: 0; overflow-y: auto;
  padding: 40px 20px;
  display: flex; flex-direction: column; align-items: center; text-align: center;
}
.result-emoji { font-size: 56px; margin-bottom: 16px; }
.result-title { font-family: var(--fh); font-size: 24px; font-weight: 800; margin-bottom: 8px; }
.result-sub { font-size: 14px; color: var(--muted); margin-bottom: 24px; }
.ring-wrap { position: relative; width: 130px; height: 130px; margin-bottom: 24px; }
.ring-bg { fill: none; stroke: var(--card2); stroke-width: 10; }
.ring-fill { fill: none; stroke: url(#rg); stroke-width: 10; stroke-linecap: round; transition: stroke-dashoffset 1s ease; }
.ring-text { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ring-num { font-family: var(--fh); font-size: 32px; font-weight: 800; line-height: 1; }
.ring-denom { font-size: 12px; color: var(--muted); }
.res-stats { display: flex; justify-content: center; gap: 12px; width: 100%; max-width: 400px; margin-bottom: 24px; }
.res-stat { background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 14px; flex: 1; text-align: center; }
.res-num { font-family: var(--fh); font-size: 22px; font-weight: 800; }
.res-num.g { color: var(--primary2); }
.res-num.r { color: var(--danger); }
.res-num.y { color: var(--gold); }
.res-label { font-size: 11px; color: var(--muted); margin-top: 4px; }
.res-btns { display: flex; flex-direction: column; gap: 12px; width: 100%; max-width: 300px; }

/* ==========================================
   ПРОФИЛЬ
   ========================================== */
.profile-header-card { background: var(--card); border: 1px solid var(--border); border-radius: 20px; padding: 20px; display: flex; gap: 16px; align-items: center; margin-bottom: 20px; flex-wrap: wrap; }
.profile-avatar-big { width: 72px; height: 72px; border-radius: 20px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; position: relative; overflow: hidden; background-size: cover; background-position: center; }
.profile-avatar-big img { width: 100%; height: 100%; object-fit: cover; object-position: center; display: block; }
.profile-name-big { font-family: var(--fh); font-size: 18px; font-weight: 800; margin-bottom: 4px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.profile-level-big { font-size: 13px; color: var(--primary); font-weight: 600; display: flex; align-items: center; gap: 4px; }
.rank-next-link { background: rgba(245,166,35,.15); color: var(--gold); padding: 2px 8px; border-radius: 6px; font-size: 11px; cursor: pointer; }

.profile-stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 20px; }
.profile-stat { background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 12px 8px; text-align: center; display: flex; flex-direction: column; justify-content: center; min-height: 80px; }
.profile-stat-num { font-family: var(--fh); font-size: 18px; font-weight: 800; margin-bottom: 4px; line-height: 1.1; word-break: break-word; }
.profile-stat-label { font-size: 10px; color: var(--muted); line-height: 1.2; }
.profile-stat-sub { font-size: 10px; color: var(--muted); margin-top: 4px; line-height: 1.2; }

.profile-tabs { display: flex; padding: 0 20px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.profile-tab { background: none; border: none; padding: 14px 16px; font-family: var(--fb); font-size: 14px; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; }
.profile-tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* Pro-блок (активная подписка) */
.pro-block-card { background: var(--card); border: 1px solid var(--border); border-radius: 16px; overflow: hidden; margin-bottom: 16px; }
.pro-block-card--active { border-color: rgba(245,166,35,.4); }
.pro-block-head { padding: 16px; display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--border); background: linear-gradient(90deg, rgba(245,166,35,.1), transparent); }
.pro-block-icon { color: var(--gold); }
.pro-block-title { font-family: var(--fh); font-weight: 800; font-size: 16px; color: var(--gold); }
.pro-block-row { display: flex; align-items: center; padding: 14px 16px; border: none; background: transparent; width: 100%; text-align: left; border-bottom: 1px solid var(--border); cursor: pointer; color: var(--text); }
.pro-block-row:last-child { border-bottom: none; }
.pro-block-row-icon { width: 24px; color: var(--primary); margin-right: 12px; display: flex; }
.pro-block-row-body { flex: 1; }
.pro-block-row-title { font-weight: 600; font-size: 14px; }
.pro-block-row-desc { font-size: 12px; color: var(--muted); margin-top: 2px; }
.pro-block-row-arrow { color: var(--muted); }

.sub-status-card { background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.sub-status-card.active { border-color: rgba(63,185,80,.4); }

/* ==========================================
   КИМ-БЛОК В ПРОФИЛЕ
   ========================================== */
.kim-block { background: var(--card); border: 1px solid var(--border); border-radius: 20px; padding: 16px; display: flex; flex-direction: column; gap: 16px; }
.kim-top { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; }
.kim-ring { position: relative; width: 80px; height: 80px; flex-shrink: 0; }
.kim-ring svg { display: block; min-width: 80px; }
.kim-ring-bg { stroke: rgba(255,255,255,.06); stroke-width: 8; }
.kim-ring-fill { stroke: url(#kimRingGradient); stroke-width: 8; stroke-linecap: round; transition: stroke-dashoffset .8s ease; }
.kim-ring-text { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.kim-ring-num { font-family: var(--fh); font-size: 18px; font-weight: 800; line-height: 1; color: var(--text); }
.kim-ring-denom { font-size: 10px; color: var(--muted); margin-top: 2px; }
.kim-info { flex: 1; min-width: 180px; }
.kim-info-title { font-family: var(--fh); font-size: 14px; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.kim-info-forecast { font-size: 12px; color: var(--text); line-height: 1.3; margin-bottom: 6px; }
.kim-info-forecast-chip { display: inline-block; background: rgba(76,141,255,.12); color: var(--primary); padding: 2px 6px; border-radius: 6px; font-size: 10px; font-weight: 600; margin-left: 4px; }
.kim-info-forecast-dyn { font-size: 11px; color: var(--muted); }
.kim-info-next { font-size: 12px; color: var(--muted); }
.kim-map-head { font-family: var(--fh); font-size: 14px; font-weight: 700; margin: 4px 0 8px; }
.kim-legend { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 12px; }
.kim-legend-item { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); }
.kim-legend-dot { width: 8px; height: 8px; border-radius: 50%; }
.kim-legend-dot--done { background: var(--primary2); }
.kim-legend-dot--progress { background: var(--primary); }
.kim-legend-dot--empty { background: var(--muted); }
.kim-map { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; margin-bottom: 16px; }
.kim-cell { aspect-ratio: 1; display: flex; align-items: center; justify-content: center; border-radius: 8px; border: none; font-family: var(--fh); font-size: 11px; font-weight: 700; background: rgba(255,255,255,.05); color: var(--muted); cursor: pointer; }
.kim-cell--done { background: var(--primary2); color: #fff; }
.kim-cell--progress { background: var(--primary); color: #fff; }
.kim-cell--selected { box-shadow: 0 0 0 2px #fff; }
.kim-task-card { background: var(--card2); border-radius: 14px; padding: 14px; }
.kim-task-title { font-family: var(--fh); font-size: 13px; font-weight: 700; color: var(--text); margin-bottom: 4px; }
.kim-task-sub { font-size: 11px; color: var(--muted); margin-bottom: 10px; }
.kim-lesson-row { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; margin-bottom: 6px; background: var(--card); border-radius: 10px; cursor: pointer; text-align: left; border: none; color: var(--text); }
.kim-lesson-check { width: 16px; height: 16px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; background: var(--primary2); color: #fff; font-size: 10px; }
.kim-lesson-check--empty { background: transparent; border: 1.5px dashed var(--muted); }
.kim-lesson-title { flex: 1; font-size: 12px; color: var(--text); }
.kim-lesson-points { font-family: var(--fh); font-size: 11px; font-weight: 700; color: var(--primary); }

/* ==========================================
   ★ КОЛЛЕКЦИЯ (ФИНАЛЬНЫЙ ФИКС ОТ КЛОДА)
   ========================================== */
.info-card {
  background: var(--card); border: 1px solid var(--border); border-radius: 18px; padding: 16px;
}
@keyframes chestGlow {
  0%, 100% { box-shadow: 0 0 0 1px rgba(245,166,35,.3), 0 0 14px rgba(245,166,35,.12); }
  50% { box-shadow: 0 0 0 1px rgba(245,166,35,.6), 0 0 26px rgba(245,166,35,.3); }
}
@keyframes chestPulse { 50% { transform: scale(1.05); } }

.collection-list { display: flex; flex-direction: column; gap: 10px; }
.collection-item {
  display: flex; align-items: center; gap: 14px; padding: 12px 14px;
  background: var(--card); border: 1px solid var(--border); border-radius: 16px;
}
.collection-item.unlocked {
  border-color: rgba(245,166,35,.4);
  background: linear-gradient(135deg, rgba(245,166,35,.09), var(--card) 60%);
}
.collection-item.locked { opacity: .55; }
.ci-icon {
  width: 48px; height: 48px; border-radius: 14px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 26px; line-height: 1;
  background: rgba(255,255,255,.06);
}
.collection-item.unlocked .ci-icon { background: rgba(245,166,35,.16); box-shadow: 0 0 14px rgba(245,166,35,.18); }
.collection-item.locked .ci-icon { filter: grayscale(1); font-size: 22px; }
.ci-body { flex: 1; min-width: 0; }
.ci-title { font-size: 15px; font-weight: 700; line-height: 1.3; }
.ci-sub { font-size: 12px; color: var(--primary2); margin-top: 3px; }

/* Заголовки секций в коллекции */
.collection-section-title {
  font-family: var(--fh);
  font-size: 16px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 20px 0 8px;
  color: var(--text);
}
.collection-section-title svg {
  width: 20px;
  height: 20px;
  color: var(--primary);
}

/* ==========================================
   МОДАЛКИ / ROADMAP / ЕЩЁ
   ========================================== */
.roadmap-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.roadmap-item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 12px; background: var(--card2); }
.roadmap-item--current { background: rgba(76,141,255,.15); border: 1px solid rgba(76,141,255,.3); }
.roadmap-item--past { opacity: .6; }
.roadmap-item--future { opacity: .8; }
.roadmap-item-badge { width: 28px; height: 28px; border-radius: 50%; background: rgba(255,255,255,.1); display: flex; align-items: center; justify-content: center; font-family: var(--fh); font-size: 12px; font-weight: 800; flex-shrink: 0; }
.roadmap-item--current .roadmap-item-badge { background: var(--primary); color: #fff; }
.roadmap-item-body { flex: 1; }
.roadmap-item-name { font-weight: 700; font-size: 14px; }
.roadmap-item-threshold { font-size: 11px; color: var(--muted); }
.roadmap-item-check { color: var(--primary2); }

.more-group-title { font-family: var(--fh); font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin: 20px 0 10px 4px; font-weight: 700; }
.more-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.more-row { width: 100%; display: flex; align-items: center; gap: 14px; background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 14px; color: var(--text); text-align: left; cursor: pointer; transition: .15s; }
.more-row:hover { background: var(--card2); }
.more-row-icon { color: var(--primary); display: flex; flex-shrink: 0; }
.more-row-icon svg { width: 20px; height: 20px; }
.more-row-body { flex: 1; }
.more-row-title { font-weight: 600; font-size: 14px; }
.more-row-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.more-row-arrow { color: var(--muted); flex-shrink: 0; }

.prof-modal-overlay, .chest-modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.7); backdrop-filter: blur(4px); z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 20px; }
.prof-modal-card, .chest-modal-card { background: var(--card); border: 1px solid var(--border); border-radius: 24px; width: 100%; max-width: 400px; padding: 24px; box-shadow: 0 20px 40px rgba(0,0,0,.5); animation: modalPop .3s cubic-bezier(.34,1.56,.64,1); max-height: 90vh; overflow-y: auto; }
@keyframes modalPop { 0% { transform: scale(.9); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }

.skeleton { background: linear-gradient(90deg, rgba(255,255,255,.05) 25%, rgba(255,255,255,.1) 50%, rgba(255,255,255,.05) 75%); background-size: 200% 100%; animation: skeletonLoad 1.5s infinite; border-radius: 8px; }
@keyframes skeletonLoad { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.skeleton-card { height: 120px; border-radius: 20px; margin-bottom: 16px; }
.skeleton-list-item { height: 70px; border-radius: 16px; margin-bottom: 12px; }
.skeleton-text { height: 14px; margin-bottom: 8px; }

.btn-primary { background: var(--grad); color: #fff; border: none; border-radius: 12px; padding: 14px 20px; font-family: var(--fh); font-weight: 700; font-size: 14px; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px; transition: transform .15s; }
.btn-primary:active { transform: scale(.98); }
.btn-secondary { background: var(--card2); color: var(--text); border: none; border-radius: 12px; padding: 14px 20px; font-family: var(--fb); font-weight: 600; font-size: 14px; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px; }
.btn-ghost { background: transparent; border: none; color: var(--primary); font-family: var(--fb); font-size: 13px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }

/* ==========================================
   ★ ПЕЙВОЛЛ (ОКНО ВЫБОРА ТАРИФА)
   ========================================== */
.paywall-card { 
  max-width: 440px; 
  max-height: 90vh; 
  overflow-y: auto; 
  padding: 22px 18px 18px; 
}
.paywall-head { text-align: center; margin-bottom: 20px; }
.paywall-title { font-family: var(--fh); font-size: 22px; font-weight: 800; margin-bottom: 4px; }
.paywall-sub { font-size: 13px; color: var(--muted); }

.paywall-compare { display: flex; flex-direction: column; gap: 16px; margin-bottom: 12px; }
.paywall-col {
  position: relative; padding: 18px 16px 14px; border-radius: 20px;
  background: var(--card2); border: 1px solid var(--border);
}
.paywall-col--pro {
  margin-top: 6px; border-color: rgba(245,166,35,.55);
  background: linear-gradient(180deg, rgba(245,166,35,.1), var(--card2) 60%);
  box-shadow: 0 0 30px rgba(245,166,35,.1);
}
.paywall-col-ribbon {
  position: absolute; top: -12px; left: 16px;
  background: var(--gold); color: #000; font-size: 11px; font-weight: 800;
  padding: 4px 12px; border-radius: 999px; white-space: nowrap;
}
.paywall-col-name { font-family: var(--fh); font-size: 18px; font-weight: 800; text-align: left; margin-bottom: 12px; }
.paywall-col-feats { list-style: none; margin: 0 0 14px; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px; font-size: 13px; }
.paywall-col-feats li { position: relative; padding-left: 18px; line-height: 1.3; }
.paywall-col-feats li.ok::before { content: '✓'; position: absolute; left: 0; color: var(--primary2); font-weight: 800; }
.paywall-col-feats li.no { color: var(--muted); text-decoration: line-through; }
.paywall-col-feats li.no::before { content: '✕'; position: absolute; left: 0; color: var(--muted); text-decoration: none; }

.paywall-price-btn {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 2px 10px;
  width: 100%; min-height: 52px; padding: 10px 14px; margin-bottom: 8px; cursor: pointer; text-align: left;
  font-family: var(--fb); color: var(--text);
  background: rgba(255,255,255,.05); border: 1px solid var(--border); border-radius: 14px;
  transition: transform .15s;
}
.paywall-price-btn:active { transform: scale(.98); }
.paywall-price-btn--best { border-color: var(--primary); background: rgba(92,141,255,.12); }
.paywall-price-btn--pro { border-color: rgba(245,166,35,.45); }
.paywall-price-btn--pro-hot { background: var(--gold); border-color: transparent; color: #000; box-shadow: 0 6px 22px rgba(245,166,35,.35); }
.paywall-price-btn-label { flex: 1; font-size: 13px; font-weight: 600; text-align: left; }
.paywall-price-btn-price { font-family: var(--fh); font-size: 16px; font-weight: 800; }
.paywall-price-btn--pro-hot > div:nth-child(2) { margin-top: 0; justify-content: flex-end; }
.paywall-price-btn--pro-hot > div:last-child { flex-basis: 100%; text-align: left; margin-top: 0; opacity: .75; }
.paywall-price-old { text-decoration: line-through; font-size: 12px; opacity: .6; }
.paywall-disc { color: var(--primary2); font-weight: 800; }
.paywall-price-btn--pro-hot .paywall-disc { color: #1a4d22; }

.paywall-option { font-family: var(--fb); }
.paywall-refresh, .paywall-cancel { width: 100%; padding: 10px; font-size: 13px; background: transparent; border: none; cursor: pointer; }
.paywall-refresh { color: var(--primary); }
.paywall-cancel { color: var(--muted); }

/* ==========================================
   ★ ЭКРАН UPGRADE (ТАРИФЫ)
   ========================================== */
.upgrade-hero { text-align: center; margin-bottom: 32px; }
.upgrade-hero-icon { width: 56px; height: 56px; margin: 0 auto 12px; display: flex; align-items: center; justify-content: center; background: rgba(245,166,35,.15); border-radius: 16px; }
.upgrade-hero-icon svg { width: 28px; height: 28px; }
.upgrade-hero-title { font-family: var(--fh); font-size: 28px; font-weight: 800; margin-bottom: 8px; }
.upgrade-hero-sub { font-size: 14px; color: var(--muted); max-width: 400px; margin: 0 auto; line-height: 1.5; }

.upgrade-section-title { font-family: var(--fh); font-size: 16px; font-weight: 700; display: flex; align-items: center; gap: 8px; margin: 24px 0 16px; }
.upgrade-section-title svg { width: 20px; height: 20px; color: var(--primary); }

.upgrade-features { display: grid; grid-template-columns: 1fr; gap: 12px; margin-bottom: 32px; }
.upgrade-feature { display: flex; gap: 12px; align-items: flex-start; background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 16px; }
.upgrade-feature.soon { opacity: 0.7; }
.upgrade-feature-icon { color: var(--primary); flex-shrink: 0; width: 24px; height: 24px; }
.upgrade-feature-icon svg { width: 24px; height: 24px; }
.upgrade-feature-body { flex: 1; min-width: 0; }
.upgrade-feature-title { font-weight: 700; font-size: 15px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.upgrade-feature-tag { background: rgba(139,148,158,.2); color: var(--muted); font-size: 9px; font-weight: 700; padding: 2px 6px; border-radius: 6px; text-transform: uppercase; letter-spacing: .04em; }
.upgrade-feature-desc { font-size: 13px; color: var(--muted); margin-top: 4px; line-height: 1.4; }

.upgrade-plans { display: flex; flex-direction: column; gap: 12px; margin-bottom: 24px; }
.upgrade-plan {
  position: relative; display: flex; flex-direction: column; gap: 8px;
  background: var(--card); border: 1px solid var(--border); border-radius: 16px;
  padding: 16px; text-align: left; color: var(--text); cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.upgrade-plan:active { transform: scale(0.98); }
.upgrade-plan--pro { border-color: rgba(245,166,35,.4); background: linear-gradient(180deg, rgba(245,166,35,.05), var(--card)); }
.upgrade-plan-ribbon {
  position: absolute; top: -10px; right: 16px;
  background: var(--gold); color: #000; font-size: 10px; font-weight: 800;
  padding: 3px 10px; border-radius: 20px; display: inline-flex; align-items: center; gap: 4px;
  box-shadow: 0 4px 12px rgba(245,166,35,0.3);
}
.upgrade-plan-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.upgrade-plan-name { font-family: var(--fh); font-weight: 700; font-size: 15px; }
.upgrade-plan-period { font-size: 11px; color: var(--muted); background: rgba(255,255,255,0.05); padding: 2px 8px; border-radius: 8px; }
.upgrade-plan-price-row { display: flex; align-items: baseline; gap: 8px; margin-bottom: 4px; }
.upgrade-plan-price { font-family: var(--fh); font-weight: 800; font-size: 22px; }
.upgrade-plan-discount { color: var(--primary2); font-size: 12px; font-weight: 700; }
.upgrade-plan-note { font-size: 12px; color: var(--muted); line-height: 1.4; }
.upgrade-honest { font-size: 12px; color: var(--muted); text-align: center; margin-bottom: 16px; line-height: 1.5; }
.upgrade-honest b { color: var(--text); }

.upgrade-active-card { background: linear-gradient(135deg, rgba(245,166,35,.15), rgba(160,107,255,.1)); border: 1px solid rgba(245,166,35,.4); border-radius: 20px; padding: 24px 20px; text-align: center; margin-bottom: 24px; }
.upgrade-active-icon { width: 56px; height: 56px; margin: 0 auto 12px; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,.2); border-radius: 16px; }
.upgrade-active-icon svg { width: 28px; height: 28px; }
.upgrade-active-title { font-family: var(--fh); font-size: 22px; font-weight: 800; margin-bottom: 8px; }
.upgrade-active-sub { font-size: 14px; color: var(--text); line-height: 1.5; }

/* ==========================================
   ★ ФИКС ПРОФЕССОРА И AI-ЧАТА (ФИНАЛЬНЫЙ)
   ========================================== */
@media (max-width: 1023px) {
  #professor-container, .professor-widget {
    transform: scale(.85) !important;
    transform-origin: bottom right !important;
    bottom: 80px !important;
    right: 10px !important;
    z-index: 50 !important;
  }
}

.back-link { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; flex-shrink: 0; }
.sec-title { flex: 1; min-width: 0; line-height: 1.25; }
#topic-title { font-size: 14px; }

#s-ai {
  height: 100dvh;
  overflow: hidden;
}

#s-ai .topbar {
  flex-shrink: 0;
}

#s-ai .scroll {
  display: flex;
  flex-direction: column;
  overflow: hidden; 
  padding: 0 !important; 
  padding-bottom: calc(70px + env(safe-area-inset-bottom, 0px)) !important; 
}

#ai-content {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 16px 16px 0 16px !important; 
}

.ai-chat-header { 
  display: flex; justify-content: space-between; align-items: center; 
  padding-bottom: 16px; border-bottom: 1px solid var(--border); 
  margin-bottom: 16px; flex-shrink: 0; 
}

.ai-chat-header-left { display: flex; gap: 12px; align-items: center; }

.ai-chat-avatar { 
  width: 40px; height: 40px; border-radius: 50%; 
  background: url('/images/professor_avatar.png') center/cover no-repeat, var(--grad); 
  flex-shrink: 0;
}
.ai-chat-msg-avatar { 
  width: 28px; height: 28px; border-radius: 50%; 
  background: url('/images/professor_avatar.png') center/cover no-repeat, var(--grad); 
  flex-shrink: 0; 
}

.ai-chat-name { font-family: var(--fh); font-weight: 700; font-size: 15px; }
.ai-chat-status { font-size: 12px; color: var(--primary2); }
.ai-chat-close { background: none; border: none; color: var(--muted); font-size: 24px; cursor: pointer; }

.ai-chat-messages { 
  flex: 1; 
  min-height: 0;
  overflow-y: auto; 
  display: flex; flex-direction: column; gap: 12px; 
  padding-bottom: 16px; 
}

.ai-chat-msg-row { display: flex; gap: 8px; width: 100%; }
.ai-chat-msg-row--user { justify-content: flex-end; }
.ai-chat-msg-row--assistant { justify-content: flex-start; }

.ai-chat-msg { max-width: 85%; padding: 12px 16px; border-radius: 16px; font-size: 14px; line-height: 1.5; }
.ai-chat-msg--assistant { background: var(--card); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.ai-chat-msg--user { background: var(--primary); color: #fff; border-bottom-right-radius: 4px; }

.ai-chat-quick { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.ai-chat-quick-btn { background: var(--card2); border: 1px solid var(--border); border-radius: 20px; padding: 8px 12px; font-size: 12px; color: var(--text); cursor: pointer; }

.ai-chat-input-row { 
  display: flex; gap: 8px; 
  padding-top: 12px; 
  padding-bottom: 12px;
  margin: 0 !important; 
  border-top: 1px solid var(--border); 
  flex-shrink: 0;
  background: var(--bg); 
  z-index: 10;
}

.ai-chat-input { 
  flex: 1; background: var(--card); border: 1px solid var(--border); 
  border-radius: 14px; padding: 12px 16px; color: var(--text); 
  font-family: var(--fb); font-size: 14px; resize: none; outline: none; 
}

.ai-chat-send { 
  width: 44px; height: 44px; border-radius: 14px; background: var(--grad); 
  border: none; color: #fff; display: flex; align-items: center; 
  justify-content: center; cursor: pointer; flex-shrink: 0; 
}

.ai-chat-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.ai-chat-action-btn { background: rgba(76,141,255,.1); color: var(--primary); border: 1px solid rgba(76,141,255,.3); border-radius: 12px; padding: 8px 14px; font-size: 12px; font-weight: 600; cursor: pointer; }
.ai-chat-typing { display: flex; gap: 4px; align-items: center; padding: 16px; }
.ai-chat-typing span { width: 6px; height: 6px; background: var(--muted); border-radius: 50%; animation: bounce 1.4s infinite ease-in-out both; }
.ai-chat-typing span:nth-child(1) { animation-delay: -0.32s; }
.ai-chat-typing span:nth-child(2) { animation-delay: -0.16s; }
@keyframes bounce { 0%, 80%, 100% { transform: scale(0); } 40% { transform: scale(1); } }

.theory-card, .theory-wrap, .lesson-content { padding: 24px 20px; border-radius: 20px; }
.theory-counter { top: 20px; right: 20px; }
.theory-content h3, .theory-wrap h3 { font-size: 18px; }
/* Страховка от сжатия поля */
.ai-chat-input {
  min-height: 48px !important;
  box-sizing: border-box !important;
}

/* ==========================================
   FIX: ПОЛНОЭКРАННЫЙ ЧАТ ПРОФЕССОРА НА МОБИЛЬНЫХ
   #ai-content одновременно является .scroll.
   Более точный селектор сохраняет внутренние отступы,
   а flex-обёртка удерживает сообщения и поле ввода
   в пределах доступной высоты экрана.
   ========================================== */
#s-ai .scroll#ai-content {
  padding: 16px 16px calc(70px + env(safe-area-inset-bottom, 0px)) !important;
  justify-content: flex-start;
  align-items: stretch;
  box-sizing: border-box;
}

#ai-content > .ai-fullscreen-wrap {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  width: 100%;
}

#ai-content > .ai-fullscreen-wrap > .ai-chat-messages {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

#ai-content > .ai-fullscreen-wrap > .ai-chat-input-row {
  flex: 0 0 auto;
  min-width: 0;
}
