:root {
  --bg: #0f0f1a;
  --surface: #16162a;
  --border: #2a2a4a;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --violet: #8b5cf6;
  --cyan: #06b6d4;
  --emerald: #10b981;
  --amber: #f59e0b;
  --red: #ef4444;
  --radius: 16px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  margin: 0;
  padding: 0;
  padding-top: 56px;
}

html {
  margin: 0;
  padding: 0;
}

.bg-glow {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(ellipse 40% 30% at 25% 10%, rgba(139,92,246,.12), transparent),
    radial-gradient(ellipse 40% 30% at 75% 90%, rgba(6,182,212,.1), transparent);
}

.container { width: 100%; max-width: none; margin: 0 auto; padding: 0 1.5rem; }
.main-content { padding: 2rem 1.5rem 4rem; width: 100%; }

.glass {
  background: #16162a;
  border-bottom: 1px solid rgba(255,255,255,.06);
}

.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: 56px;
  max-height: 56px;
  margin: 0;
  padding: 0;
  background: #16162a;
  border-bottom: 1px solid rgba(255,255,255,.06);
  box-sizing: border-box;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  height: 56px;
  max-height: 56px;
  margin: 0;
  padding-top: 0;
  padding-bottom: 0;
  box-sizing: border-box;
}

.logo {
  display: flex;
  align-items: center;
  gap: .5rem;
  text-decoration: none;
  color: inherit;
  line-height: 1;
  min-width: 0;
}

.logo-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--violet), var(--cyan));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  color: #fff;
  flex-shrink: 0;
  line-height: 1;
}

.logo-text {
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1;
  background: linear-gradient(135deg, var(--violet), var(--cyan), #ec4899);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.header-right { display: flex; align-items: center; gap: .75rem; }

.nav-toggle {
  display: none; flex-direction: column; justify-content: center; gap: 5px;
  width: 40px; height: 40px; padding: 0; border: none; border-radius: 10px;
  background: rgba(255,255,255,.06); cursor: pointer; flex-shrink: 0;
  margin-left: auto;
}
.nav-toggle span {
  display: block; width: 20px; height: 2px; margin: 0 auto;
  background: var(--text); border-radius: 2px; transition: transform .25s, opacity .25s;
}
.nav-toggle.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle.open span:nth-child(2) { opacity: 0; }
.nav-toggle.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.name-input {
  background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.1);
  border-radius: 8px; padding: .4rem .75rem; color: var(--text);
  font-size: .875rem; width: 120px;
}
.name-input:focus { outline: none; border-color: var(--violet); }

.btn-rating {
  padding: .4rem .75rem; border-radius: 8px;
  background: rgba(245,158,11,.1); color: var(--amber);
  text-decoration: none; font-size: .875rem; font-weight: 500;
}
.btn-rating:hover { background: rgba(245,158,11,.2); }

.btn-nav {
  padding: .4rem .75rem; border-radius: 8px;
  background: rgba(139,92,246,.1); color: #c4b5fd;
  text-decoration: none; font-size: .875rem; font-weight: 500;
}
.btn-nav:hover { background: rgba(139,92,246,.2); }

.btn-ghost {
  padding: .4rem .75rem; border-radius: 8px;
  background: transparent; color: var(--muted);
  text-decoration: none; font-size: .875rem; font-weight: 500;
  border: 1px solid rgba(255,255,255,.1);
}
.btn-ghost:hover { color: var(--text); border-color: rgba(255,255,255,.2); }

.header-user {
  font-size: .875rem; color: #c4b5fd; font-weight: 500;
  max-width: 100px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ── Auth ── */
.auth-wrap {
  display: flex; justify-content: center; align-items: center;
  min-height: 60vh; padding: 2rem 0;
}
.auth-card { width: 100%; max-width: 400px; padding: 2rem; }
.auth-card h1 { font-size: 1.5rem; margin-bottom: .25rem; }
.auth-sub { color: var(--muted); font-size: .9rem; margin-bottom: 1.5rem; }
.auth-form { display: flex; flex-direction: column; gap: 1rem; }
.auth-form label { display: flex; flex-direction: column; gap: .35rem; font-size: .85rem; color: var(--muted); }
.auth-submit { width: 100%; margin-top: .5rem; }
.auth-error {
  background: rgba(239,68,68,.1); border: 1px solid rgba(239,68,68,.3);
  color: #fca5a5; padding: .75rem; border-radius: 8px; margin-bottom: 1rem; font-size: .875rem;
}
.auth-footer { text-align: center; margin-top: 1.25rem; font-size: .875rem; color: var(--muted); }
.auth-footer a { color: var(--violet); text-decoration: none; }
.auth-footer a:hover { color: #c4b5fd; }

/* ── Cabinet ── */
.cabinet-hero {
  display: flex; align-items: center; gap: 1rem; margin-bottom: 1.5rem; flex-wrap: wrap;
}
.cabinet-avatar {
  width: 56px; height: 56px; border-radius: 16px;
  background: linear-gradient(135deg, var(--violet), var(--cyan));
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem; font-weight: 700; color: #fff; flex-shrink: 0;
}
.cabinet-email { color: var(--muted); font-size: .9rem; }
.cabinet-new-btn { margin-left: auto; }
.cabinet-stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: .75rem; margin-bottom: 1.5rem;
}
.stat-card {
  padding: 1rem; border-radius: 12px; text-align: center;
  background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.08);
}
.stat-num { display: block; font-size: 1.5rem; font-weight: 700; color: #c4b5fd; }
.stat-label { font-size: .75rem; color: var(--muted); }
.cabinet-section-title { font-size: 1.1rem; margin: 1.5rem 0 1rem; }
.cabinet-settings { margin-bottom: 1.25rem; }
.cabinet-settings-label {
  display: block; font-size: .9rem; color: var(--muted); margin-bottom: .5rem;
}
.cabinet-settings-row { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.cabinet-locale-select {
  min-width: 200px; padding: .55rem .75rem; border-radius: 10px;
  background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.12);
  color: inherit; font: inherit; cursor: pointer;
}
.cabinet-settings-status { font-size: .85rem; color: var(--muted); }

.hero { text-align: center; margin-bottom: 2.5rem; }
.hero h1 { font-size: clamp(2rem, 5vw, 3rem); font-weight: 700; margin-bottom: .75rem; }
.gradient-text {
  background: linear-gradient(135deg, var(--violet), var(--cyan));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.hero-sub { color: var(--muted); font-size: 1.1rem; max-width: 720px; margin: 0 auto; }

.step { margin-bottom: 2rem; }
.step h2 { font-size: 1.1rem; margin-bottom: 1rem; }

.spheres-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .75rem;
}

.sphere-card {
  display: flex; flex-direction: column; padding: 1rem;
  border-radius: var(--radius); border: 1px solid rgba(255,255,255,.1);
  background: rgba(255,255,255,.04); cursor: pointer;
  transition: all .25s;
}
.sphere-card:hover { border-color: rgba(255,255,255,.2); transform: translateY(-2px); }
.sphere-card:has(input:checked) {
  border-color: rgba(139,92,246,.5); background: rgba(139,92,246,.1);
  box-shadow: 0 0 30px rgba(139,92,246,.15);
}

.sphere-icon {
  width: 44px; height: 44px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem; margin-bottom: .5rem;
}
.sphere-violet { background: linear-gradient(135deg, #8b5cf6, #7c3aed); }
.sphere-cyan { background: linear-gradient(135deg, #06b6d4, #3b82f6); }
.sphere-orange { background: linear-gradient(135deg, #f97316, #ef4444); }
.sphere-pink { background: linear-gradient(135deg, #ec4899, #f43f5e); }
.sphere-emerald { background: linear-gradient(135deg, #10b981, #14b8a6); }
.sphere-amber { background: linear-gradient(135deg, #f59e0b, #eab308); }
.sphere-lime { background: linear-gradient(135deg, #84cc16, #22c55e); }
.sphere-indigo { background: linear-gradient(135deg, #6366f1, #8b5cf6); }

.sphere-name { font-weight: 600; font-size: .9rem; }
.sphere-count { font-size: .75rem; color: var(--muted); margin-top: .25rem; }

.input {
  width: 100%; padding: .75rem 1rem; border-radius: 12px;
  background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.1);
  color: var(--text); font-size: 1rem; margin-bottom: .75rem;
}
.input:focus { outline: none; border-color: var(--violet); }

.skills-tags { display: flex; flex-wrap: wrap; gap: .5rem; }

.skill-tag {
  padding: .5rem 1rem; border-radius: 999px; font-size: .875rem;
  border: 1px solid rgba(255,255,255,.1); background: rgba(255,255,255,.05);
  color: var(--text); cursor: pointer; transition: all .2s;
}
.skill-tag:hover { border-color: rgba(255,255,255,.2); }
.skill-tag.active {
  background: rgba(139,92,246,.2); border-color: rgba(139,92,246,.5); color: #c4b5fd;
}

.levels-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: .75rem;
}

.level-card {
  padding: 1rem; border-radius: 12px; border: 1px solid rgba(255,255,255,.1);
  background: rgba(255,255,255,.04); cursor: pointer; transition: all .25s;
  display: flex; flex-direction: column; gap: .25rem;
}
.level-card:has(input:checked) {
  border-color: rgba(139,92,246,.5); background: rgba(139,92,246,.1);
}
.level-icon { font-size: 1.5rem; }
.level-name { font-weight: 600; }
.level-desc { font-size: .75rem; color: var(--muted); }

.form-actions { display: flex; justify-content: center; margin-top: 1rem; }

.btn-primary {
  padding: 1rem 2rem; border: none; border-radius: 16px; font-size: 1.1rem;
  font-weight: 600; cursor: pointer; color: #fff;
  background: linear-gradient(135deg, var(--violet), var(--cyan));
  transition: all .25s;
}
.btn-primary:hover:not(:disabled) { transform: scale(1.03); box-shadow: 0 8px 30px rgba(139,92,246,.3); }
.btn-primary:disabled { opacity: .4; cursor: not-allowed; }

.btn-secondary {
  padding: .75rem 1.5rem; border: none; border-radius: 12px;
  background: rgba(255,255,255,.1); color: var(--text);
  font-weight: 600; cursor: pointer;
}
.btn-secondary:hover { background: rgba(255,255,255,.15); }

.btn-success {
  padding: .75rem 1.5rem; border: none; border-radius: 12px;
  background: rgba(16,185,129,.2); color: var(--emerald);
  font-weight: 600; cursor: pointer; width: 100%;
}

.hidden { display: none !important; }

.loading-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(15,15,26,.9); display: flex; align-items: center; justify-content: center;
}
.modal-overlay {
  position: fixed; inset: 0; z-index: 1100;
  background: rgba(15,15,26,.85); display: flex; align-items: center; justify-content: center;
  padding: 1rem;
  padding: max(1rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) max(1rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.modal-card {
  width: min(100%, 420px);
  background: var(--card, #1a1a2e);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: 0 20px 60px rgba(0,0,0,.45);
  max-height: min(90dvh, 900px);
  overflow-y: auto;
}
.modal-card h3 { margin: 0 0 .75rem; }
.modal-card p { margin: 0 0 1.25rem; color: var(--muted); }
.modal-actions { display: flex; gap: .75rem; justify-content: flex-end; }
body.modal-open { overflow: hidden; }

.footer-link-btn {
  background: none; border: none; padding: 0; margin: 0;
  color: inherit; font: inherit; cursor: pointer; text-align: left;
}
.footer-link-btn:hover { color: var(--text); }

.feedback-card-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: .75rem;
}
.feedback-card-head h3 { margin: 0; }
.feedback-close {
  flex-shrink: 0; width: 36px; height: 36px; border: none; border-radius: 10px;
  background: rgba(255,255,255,.06); color: var(--text); font-size: 1.4rem; line-height: 1;
  cursor: pointer;
}
.feedback-close:hover { background: rgba(255,255,255,.12); }
.feedback-sub { margin: .5rem 0 1rem !important; font-size: .9rem; }
.feedback-form .input,
.feedback-form .textarea { margin-bottom: 0; font-size: 16px; }
.feedback-textarea { min-height: 120px; resize: vertical; }
.feedback-actions { margin-top: .25rem; flex-wrap: wrap; }
.feedback-actions .btn-primary,
.feedback-actions .btn-ghost { min-height: 44px; }
.feedback-success {
  background: rgba(16,185,129,.12); border: 1px solid rgba(16,185,129,.3);
  color: #6ee7b7; padding: .75rem; border-radius: 8px; font-size: .875rem;
}
.loader-box { text-align: center; }
.loader-spinner {
  width: 48px; height: 48px; border: 3px solid rgba(139,92,246,.2);
  border-top-color: var(--violet); border-radius: 50%;
  animation: spin 1s linear infinite; margin: 0 auto 1rem;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-center { text-align: center; padding: 4rem; color: var(--muted); }
.part-loading {
  padding: 2rem;
  font-size: .95rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}
.part-typing-loader {
  display: flex; align-items: center; justify-content: center; gap: .75rem;
  padding: 1rem 0; color: var(--muted); font-size: .9rem;
}
.part-typing-loader .loader-spinner {
  width: 22px; height: 22px; border-width: 2px; margin: 0;
}
.tab.tab-loading::after { content: '…'; opacity: .6; margin-left: .15rem; }

.back-link {
  display: inline-block; color: var(--muted); text-decoration: none;
  margin-bottom: 1.5rem; font-size: .875rem;
}
.back-link:hover { color: var(--text); }

.card {
  width: 100%;
  background: rgba(22,22,42,.7); border: 1px solid rgba(255,255,255,.08);
  border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1rem;
}

.progress-bar-wrap {
  display: flex; align-items: center; gap: 1rem; margin: 1rem 0;
}
.progress-bar {
  flex: 1; height: 8px; background: rgba(255,255,255,.05);
  border-radius: 999px; overflow: hidden;
}
.progress-fill {
  height: 100%; background: linear-gradient(90deg, var(--violet), var(--cyan));
  border-radius: 999px; transition: width .4s;
}

.topic-block { margin-bottom: 1.5rem; }
.topic-header { display: flex; gap: .75rem; margin-bottom: .75rem; align-items: flex-start; }
.topic-icon {
  width: 40px; height: 40px; border-radius: 10px;
  background: rgba(139,92,246,.2); display: flex; align-items: center; justify-content: center;
}
.topic-title { font-weight: 600; }
.topic-desc { font-size: .85rem; color: var(--muted); }

.lesson-item {
  display: flex; align-items: center; gap: .75rem; width: 100%;
  padding: .75rem; border-radius: 12px; border: 1px solid rgba(255,255,255,.08);
  background: rgba(255,255,255,.03); margin-bottom: .5rem;
  text-align: left; cursor: pointer; color: inherit; font: inherit;
  transition: all .2s;
}
.lesson-item:hover:not(:disabled) { border-color: rgba(139,92,246,.3); background: rgba(139,92,246,.05); }
.lesson-item.completed { border-color: rgba(16,185,129,.3); background: rgba(16,185,129,.05); }
.lesson-item.locked { opacity: .45; cursor: not-allowed; }
.lesson-item.paywall-locked { opacity: .55; cursor: pointer; }

.topic-block--locked { border-color: rgba(245,158,11,.25); }
.topic-lock-badge {
  font-size: .7rem; padding: .15rem .5rem; border-radius: 999px;
  background: rgba(245,158,11,.15); color: var(--amber); font-weight: 600;
}

.paywall-banner {
  margin-bottom: 1rem; padding: .85rem 1rem;
  border-color: rgba(245,158,11,.3); background: rgba(245,158,11,.08);
  font-size: .9rem;
}
.paywall-banner a { color: var(--amber); font-weight: 600; }

.paywall-card, .pricing-page { max-width: 520px; margin: 0 auto; text-align: center; }
.paywall-card h2 { margin-bottom: .75rem; }
.paywall-card p { color: var(--muted); margin-bottom: 1.25rem; }

.pricing-page h1 { margin-bottom: .5rem; }
.pricing-lead { color: var(--muted); margin-bottom: 1.5rem; }
.pricing-card { padding: 2rem; text-align: left; }
.pricing-badge {
  display: inline-block; font-size: .75rem; font-weight: 600; padding: .2rem .6rem;
  border-radius: 999px; background: rgba(139,92,246,.2); color: #c4b5fd; margin-bottom: .75rem;
}
.pricing-features { list-style: none; margin: 1rem 0 1.5rem; }
.pricing-features li { padding: .35rem 0; color: var(--muted); }
.pricing-note, .pricing-active { color: var(--muted); margin-bottom: 1rem; font-size: .9rem; }
.pricing-active { color: var(--emerald); }
.pricing-price { font-size: 2rem; font-weight: 700; margin: .25rem 0 1rem; }
.pricing-price-note { font-size: .9rem; font-weight: 500; color: var(--muted); }
.pricing-pay-btn { width: 100%; margin-bottom: .75rem; }
.pricing-secondary-link { display: inline-block; margin-top: .75rem; text-decoration: none; }
.pricing-error { color: #f87171; font-size: .9rem; margin-bottom: .75rem; }
.pricing-error.hidden { display: none; }
.payment-return-card { text-align: center; padding: 2rem; }
.payment-return-success h1 { color: var(--emerald); }

.balance-page { max-width: 520px; margin: 0 auto; text-align: center; }
.balance-page h1 { margin-bottom: .5rem; }
.balance-lead { color: var(--muted); margin-bottom: 1.5rem; }
.balance-card {
  padding: 1.75rem; text-align: left; position: relative; overflow: hidden;
}
.balance-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
}
.balance-card--ok::before { background: linear-gradient(90deg, var(--emerald), var(--cyan)); }
.balance-card--pending::before { background: linear-gradient(90deg, var(--amber), #f97316); }
.balance-status {
  display: flex; align-items: flex-start; gap: 1rem;
  padding: 1rem 1.15rem; border-radius: 14px; margin-bottom: 1rem;
}
.balance-status--ok {
  background: rgba(16,185,129,.1); border: 1px solid rgba(16,185,129,.25);
}
.balance-status--pending {
  background: rgba(245,158,11,.1); border: 1px solid rgba(245,158,11,.25);
}
.balance-status-icon {
  width: 44px; height: 44px; border-radius: 12px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem; font-weight: 700;
}
.balance-status--ok .balance-status-icon {
  background: rgba(16,185,129,.2); color: var(--emerald);
}
.balance-status--pending .balance-status-icon {
  background: rgba(245,158,11,.2);
}
.balance-status-title { font-weight: 600; font-size: 1.05rem; }
.balance-status-sub { font-size: .85rem; color: var(--muted); margin-top: .15rem; }
.balance-status-badge {
  display: inline-block; font-size: .7rem; font-weight: 600;
  padding: .15rem .5rem; border-radius: 999px; vertical-align: middle;
  background: rgba(139,92,246,.2); color: #c4b5fd; margin-left: .35rem;
}
.balance-perks {
  list-style: none; margin: 0 0 1.25rem; padding: 0;
}
.balance-perks li {
  padding: .4rem 0 .4rem 1.5rem; color: var(--muted); font-size: .9rem;
  position: relative;
}
.balance-perks li::before {
  content: '✓'; position: absolute; left: 0; color: var(--emerald); font-weight: 700;
}
.balance-meta { color: var(--muted); font-size: .9rem; margin-bottom: 1.25rem; line-height: 1.5; }
.balance-actions { display: flex; flex-wrap: wrap; gap: .75rem; }
.balance-actions .btn-amber,
.balance-actions .btn-secondary {
  margin-top: 0; flex: 1 1 140px; text-align: center; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center;
  transition: transform .2s, box-shadow .2s, background .2s;
}
.balance-actions .btn-amber:hover {
  transform: translateY(-1px); box-shadow: 0 6px 20px rgba(245,158,11,.25);
}
.balance-check-msg {
  margin-top: 1rem; min-height: 0; font-size: .875rem; color: var(--muted);
}
.balance-check-msg:not(:empty) {
  padding: .65rem .85rem; border-radius: 10px;
  background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.08);
  color: var(--text);
}

.lesson-status {
  width: 32px; height: 32px; border-radius: 8px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: .9rem;
}
.lesson-item .lesson-status { background: rgba(139,92,246,.2); }
.lesson-item.completed .lesson-status { background: rgba(16,185,129,.2); }
.lesson-item.locked .lesson-status { background: rgba(255,255,255,.05); }

.lesson-title { flex: 1; min-width: 0; font-size: .9rem; word-break: break-word; }
.score-badge {
  font-size: .75rem; padding: .2rem .5rem; border-radius: 999px; font-weight: 600;
}
.score-pass { background: rgba(16,185,129,.2); color: var(--emerald); }
.score-fail { background: rgba(239,68,68,.2); color: var(--red); }

.tabs {
  display: flex; gap: .25rem; padding: .25rem; width: 100%;
  background: rgba(255,255,255,.05); border-radius: 12px; margin-bottom: 1.5rem;
  border: 1px solid rgba(255,255,255,.08);
}
.tab {
  flex: 1; padding: .6rem; border: none; border-radius: 8px;
  background: transparent; color: var(--muted); cursor: pointer;
  font-size: .85rem; font-weight: 500; transition: all .2s;
}
.tab.active { background: rgba(139,92,246,.2); color: #c4b5fd; }
.tab.tab-locked { opacity: .45; cursor: not-allowed; }
.tab.tab-done::after { content: ' ✓'; color: var(--emerald); font-size: .75rem; }

.lesson-header { margin-bottom: 1.25rem; }
.lesson-topic-badge {
  display: inline-block; font-size: .8rem; padding: .25rem .6rem; border-radius: 999px;
  background: rgba(139,92,246,.15); color: #c4b5fd; margin-bottom: .5rem;
}
.lesson-title-main { font-size: 1.5rem; font-weight: 700; margin-bottom: .35rem; }
.lesson-topic-desc { color: var(--muted); font-size: .9rem; margin-bottom: .25rem; }
.lesson-scope { font-size: .8rem; color: var(--cyan); }

.step-progress-wrap { margin-bottom: 1rem; }
.step-progress-bar {
  height: 6px; background: rgba(255,255,255,.06); border-radius: 999px; overflow: hidden; margin-bottom: .4rem;
}
.step-progress-fill {
  height: 100%; width: 0; background: linear-gradient(90deg, var(--violet), var(--cyan));
  border-radius: 999px; transition: width .4s;
}
.step-labels {
  display: flex; gap: .35rem; flex-wrap: wrap; font-size: .7rem; color: var(--muted);
}

.quiz-scope-note {
  font-size: .85rem; color: var(--amber); margin-bottom: 1rem;
  padding: .5rem .75rem; background: rgba(245,158,11,.08); border-radius: 8px;
  border: 1px solid rgba(245,158,11,.2);
}

.prose h2 { font-size: 1.2rem; color: #c4b5fd; margin: 1.25rem 0 .5rem; }
.prose h3 { font-size: 1rem; color: #a5b4fc; margin: 1rem 0 .4rem; }
.prose p { margin: .5rem 0; color: #cbd5e1; }
.prose ul, .prose ol { margin: .5rem 0 .75rem 1.25rem; color: #cbd5e1; }
.prose li { margin: .25rem 0; }
.prose strong { color: var(--text); }

.code-block {
  background: rgba(0,0,0,.4); border-radius: 12px; padding: 1rem;
  font-family: 'Consolas', monospace; font-size: .85rem; color: #6ee7b7;
  overflow-x: auto; margin: .75rem 0;
}

.quiz-q { margin-bottom: 1rem; }
.quiz-q .quiz-question { font-weight: 500; margin-bottom: .5rem; }
.quiz-q .quiz-question p { font-weight: 500; margin-bottom: .5rem; }
.quiz-q .quiz-q-num { margin-right: .35rem; }
.quiz-q .code-block {
  font-weight: 400; white-space: pre; margin: .6rem 0 .75rem;
  line-height: 1.45;
}
.quiz-opt {
  display: block; width: 100%; text-align: left; padding: .6rem 1rem;
  border-radius: 10px; border: 1px solid rgba(255,255,255,.1);
  background: rgba(255,255,255,.04); color: var(--text); margin-bottom: .4rem;
  cursor: pointer; font-size: .9rem; transition: all .2s;
}
.quiz-opt:hover:not(:disabled) { border-color: rgba(255,255,255,.2); }
.quiz-opt.selected { border-color: #3b82f6; background: rgba(59,130,246,.45); color: #dbeafe; }
.quiz-opt.correct { border-color: #22c55e; background: rgba(34,197,94,.45); color: #dcfce7; }
.quiz-opt.wrong { border-color: #ef4444; background: rgba(239,68,68,.45); color: #fecaca; }
.quiz-opt:disabled { cursor: default; }

.textarea {
  width: 100%; min-height: 180px; padding: 1rem; border-radius: 12px;
  background: rgba(0,0,0,.3); border: 1px solid rgba(255,255,255,.1);
  color: var(--text); font-family: inherit; font-size: .95rem; resize: vertical;
}
.textarea:focus { outline: none; border-color: var(--violet); }

.hints-box {
  padding: .75rem; border-radius: 10px; margin-bottom: 1rem;
  background: rgba(245,158,11,.1); border: 1px solid rgba(245,158,11,.2);
  font-size: .85rem; color: #fcd34d;
}

.result-box {
  padding: 1rem; border-radius: 12px; margin: 1rem 0; text-align: center;
}
.result-pass { border: 1px solid rgba(16,185,129,.3); background: rgba(16,185,129,.05); }
.result-fail { border: 1px solid rgba(239,68,68,.3); background: rgba(239,68,68,.05); }

.test-header, .rating-header { text-align: center; margin-bottom: 2rem; }
.test-icon { font-size: 2.5rem; display: block; margin-bottom: .5rem; }

.rating-list { display: flex; flex-direction: column; gap: .5rem; width: 100%; }
.rating-item {
  display: flex; align-items: center; gap: 1rem; padding: 1rem;
  border-radius: 12px; border: 1px solid rgba(255,255,255,.08);
  background: rgba(255,255,255,.04);
}
.rating-item.me { border-color: rgba(139,92,246,.4); background: rgba(139,92,246,.1); }
.rating-pos { width: 36px; text-align: center; font-weight: 700; }
.rating-name { flex: 1; min-width: 0; font-weight: 500; overflow: hidden; text-overflow: ellipsis; }
.rating-score { color: var(--amber); font-weight: 700; }

.final-test-cta {
  text-align: center; padding: 1.5rem; margin-top: 1.5rem;
  border-radius: var(--radius); border: 1px solid rgba(245,158,11,.3);
  background: rgba(245,158,11,.05);
}
.btn-amber {
  padding: .75rem 1.5rem; border: none; border-radius: 12px;
  background: linear-gradient(135deg, #f59e0b, #f97316);
  color: #fff; font-weight: 600; cursor: pointer; margin-top: .75rem;
}

.breadcrumb { font-size: .85rem; color: var(--muted); margin-bottom: .5rem; }
.breadcrumb span { color: #c4b5fd; }

/* ── Topic progress ── */
.progress-panel { margin: 1.25rem 0; width: 100%; }
.progress-panel-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 1rem; flex-wrap: wrap; gap: .5rem;
}
.progress-panel-head h2 { font-size: 1rem; font-weight: 600; }
.overall-score {
  font-size: .85rem; color: var(--cyan); font-weight: 600;
  background: rgba(6,182,212,.1); padding: .25rem .6rem; border-radius: 999px;
}

.topic-chips { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: .75rem; width: 100%; }
.topic-chip {
  padding: .5rem .75rem; border-radius: 10px; border: 1px solid;
  font-size: .8rem; flex: 1 1 200px;
}
.topic-chip-name { display: block; font-weight: 600; margin-bottom: .15rem; }
.topic-chip-meta { color: var(--muted); font-size: .75rem; }

.status-strong { border-color: rgba(16,185,129,.4); background: rgba(16,185,129,.1); color: #6ee7b7; }
.status-good { border-color: rgba(6,182,212,.4); background: rgba(6,182,212,.1); color: #67e8f9; }
.status-weak { border-color: rgba(239,68,68,.4); background: rgba(239,68,68,.1); color: #fca5a5; }
.status-progress { border-color: rgba(245,158,11,.4); background: rgba(245,158,11,.1); color: #fcd34d; }
.status-none { border-color: rgba(255,255,255,.1); background: rgba(255,255,255,.04); color: var(--muted); }

.insight {
  font-size: .85rem; padding: .6rem .75rem; border-radius: 8px; margin-top: .5rem;
}
.insight-weak { background: rgba(239,68,68,.08); color: #fca5a5; border: 1px solid rgba(239,68,68,.2); }
.insight-strong { background: rgba(16,185,129,.08); color: #6ee7b7; border: 1px solid rgba(16,185,129,.2); }
.progress-link { display: inline-block; margin-top: .75rem; font-size: .85rem; color: var(--violet); text-decoration: none; }
.progress-link:hover { color: #c4b5fd; }

.topic-header-body { flex: 1; min-width: 0; }
.topic-title-row { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.topic-status-badge {
  font-size: .7rem; padding: .2rem .5rem; border-radius: 999px;
  border: 1px solid; font-weight: 600; white-space: nowrap;
}
.topic-mini-bar {
  height: 4px; background: rgba(255,255,255,.06); border-radius: 999px;
  margin-top: .5rem; overflow: hidden;
}
.topic-mini-fill { height: 100%; border-radius: 999px; transition: width .3s; }
.topic-mini-fill.status-strong { background: var(--emerald); }
.topic-mini-fill.status-good { background: var(--cyan); }
.topic-mini-fill.status-weak { background: var(--red); }
.topic-mini-fill.status-progress { background: var(--amber); }

.topic-block--weak { border-color: rgba(239,68,68,.2); }
.topic-block--strong { border-color: rgba(16,185,129,.2); }

/* ── Progress page ── */
.progress-page-header { text-align: center; margin-bottom: 2rem; }
.progress-page-header h1 { font-size: 2rem; margin-bottom: .5rem; }

.course-progress-card { margin-bottom: 1.25rem; }
.course-progress-card h2 { font-size: 1.2rem; margin: .25rem 0; }
.course-progress-card h2 a { color: inherit; text-decoration: none; }
.course-progress-card h2 a:hover { color: #c4b5fd; }
.course-progress-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 1rem; flex-wrap: wrap;
}
.course-progress-stats { display: flex; gap: .5rem; flex-wrap: wrap; }
.stat-pill {
  font-size: .75rem; padding: .3rem .6rem; border-radius: 999px;
  background: rgba(255,255,255,.06); color: var(--muted);
}

.summary-legend { display: flex; flex-wrap: wrap; gap: .5rem; margin: .5rem 0; }
.legend-item {
  font-size: .75rem; padding: .25rem .5rem; border-radius: 6px; border: 1px solid;
}

.topic-progress-list { margin-top: 1rem; display: flex; flex-direction: column; gap: .5rem; }
.topic-progress-row {
  display: grid; grid-template-columns: 1fr 120px 60px; gap: .75rem; align-items: center;
  padding: .6rem .75rem; border-radius: 10px; border: 1px solid rgba(255,255,255,.06);
  background: rgba(255,255,255,.02);
}
.topic-progress-title { font-size: .9rem; font-weight: 500; display: block; }
.topic-progress-label { font-size: .7rem; color: var(--muted); }
.topic-progress-bar {
  height: 6px; background: rgba(255,255,255,.06); border-radius: 999px; overflow: hidden;
}
.topic-progress-fill {
  height: 100%; background: linear-gradient(90deg, var(--violet), var(--cyan));
  border-radius: 999px;
}
.topic-progress-score { text-align: right; font-weight: 700; font-size: .9rem; }
.topic-progress-score small { display: block; font-weight: 400; font-size: .7rem; color: var(--muted); }

.topic-progress-row.status-strong .topic-progress-fill { background: var(--emerald); }
.topic-progress-row.status-good .topic-progress-fill { background: var(--cyan); }
.topic-progress-row.status-weak .topic-progress-fill { background: var(--red); }
.topic-progress-row.status-weak { border-color: rgba(239,68,68,.25); }

@media (max-width: 768px) {
  .container { padding: 0 1rem; }
  .main-content { padding: 1.25rem 1rem 3rem; }

  .nav-toggle { display: flex; }
  .header-right {
    display: none;
    position: fixed;
    top: 56px;
    left: 0;
    right: 0;
    z-index: 50;
    flex-direction: column;
    align-items: stretch;
    gap: .25rem;
    padding: .75rem 1rem 1rem;
    background: rgba(22,22,42,.97);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(255,255,255,.08);
  }
  .header-right.open {
    display: flex;
  }
  .header-right .btn-nav,
  .header-right .btn-rating,
  .header-right .btn-ghost {
    display: block; text-align: center; padding: .75rem 1rem; font-size: .95rem;
  }
  .header-user {
    max-width: none; text-align: center; padding: .5rem;
    border-bottom: 1px solid rgba(255,255,255,.06); margin-bottom: .25rem;
  }
  body.nav-open { overflow: hidden; }

  .hero { margin-bottom: 1.5rem; }
  .hero-sub { font-size: .95rem; }
  .card { padding: 1rem; }
  .lesson-title-main { font-size: 1.2rem; }
  .progress-page-header h1 { font-size: clamp(1.5rem, 5vw, 2rem); }
  .test-icon { font-size: 2rem; }

  .cabinet-new-btn { margin-left: 0; width: 100%; text-align: center; }
  .cabinet-hero { flex-direction: column; align-items: flex-start; }
  .cabinet-avatar { width: 48px; height: 48px; font-size: 1.25rem; }

  .progress-bar-wrap { flex-wrap: wrap; gap: .5rem; }
  .form-actions .btn-primary { width: 100%; }
  .auth-card { padding: 1.5rem; }

  .modal-overlay {
    align-items: flex-start;
    padding-top: max(.75rem, env(safe-area-inset-top));
  }
  .feedback-card {
    width: 100%;
    margin: 0 auto;
    max-height: none;
  }
  .feedback-actions {
    flex-direction: column-reverse;
  }
  .feedback-actions .btn-primary,
  .feedback-actions .btn-ghost {
    width: 100%;
  }

  .topic-chip { flex: 1 1 100%; }
  .course-progress-head { flex-direction: column; }
}

@media (max-width: 600px) {
  .topic-progress-row { grid-template-columns: 1fr; gap: .5rem; }
  .topic-progress-score { text-align: left; }
  .tabs .tab-label { display: none; }
  .tabs .tab { padding: .75rem .5rem; font-size: 1.1rem; }
  .spheres-grid { grid-template-columns: repeat(2, 1fr); }
  .levels-grid { grid-template-columns: 1fr; }
  .sphere-card { padding: .75rem; }
  .sphere-icon { width: 36px; height: 36px; font-size: 1.1rem; }
  .rating-item { gap: .5rem; padding: .75rem; }
  .rating-pos { width: 28px; font-size: .9rem; }
}

body.is-app-client .site-footer,
body.is-app-client .cookie-banner {
  display: none !important;
}

/* TWA / app: never add top inset — system chrome already accounts for it */
body.is-twa .header,
body.is-app-client .header {
  padding: 0 !important;
  margin: 0 !important;
  height: 56px !important;
  max-height: 56px !important;
}

/* ── Cookie banner ── */
.cookie-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  padding: 1rem 1.5rem;
  padding-bottom: max(1rem, env(safe-area-inset-bottom));
  background: rgba(15, 15, 26, .96);
  backdrop-filter: blur(16px);
  border-top: 1px solid rgba(255,255,255,.08);
  box-shadow: 0 -8px 32px rgba(0,0,0,.4);
}
.cookie-banner-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
  flex-wrap: wrap;
  max-width: 1200px;
  margin: 0 auto;
}
.cookie-banner p {
  flex: 1;
  min-width: min(100%, 280px);
  font-size: .875rem;
  color: var(--muted);
  line-height: 1.5;
}
.cookie-banner a {
  color: #93c5fd;
  text-decoration: none;
}
.cookie-banner a:hover { text-decoration: underline; }
.cookie-banner-actions {
  display: flex;
  gap: .5rem;
  flex-shrink: 0;
}
.cookie-banner-actions button {
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
}
body.cookie-banner-visible {
  padding-bottom: 5.5rem;
}
@media (max-width: 600px) {
  .cookie-banner-inner {
    flex-direction: column;
    align-items: stretch;
    text-align: center;
  }
  .cookie-banner-actions { justify-content: center; }
  body.cookie-banner-visible { padding-bottom: 8rem; }
}

/* ── SEO / Footer ── */
.projects-page { max-width: 880px; margin: 0 auto; }
.projects-page h1 { margin-bottom: .5rem; }
.projects-lead { color: var(--muted); margin-bottom: 1.75rem; max-width: 42rem; }
.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}
.project-card {
  display: flex; gap: 1rem; align-items: flex-start;
  padding: 1.15rem 1.25rem;
  border-radius: var(--radius);
  border: 1px solid rgba(255,255,255,.08);
  background: rgba(255,255,255,.03);
  text-decoration: none; color: inherit;
  transition: border-color .15s, background .15s, transform .15s;
}
.project-card:hover {
  border-color: rgba(139,92,246,.45);
  background: rgba(139,92,246,.08);
  transform: translateY(-1px);
}
.project-icon {
  width: 56px; height: 56px; border-radius: 14px; flex-shrink: 0;
}
.project-body h2 { font-size: 1.05rem; margin-bottom: .35rem; }
.project-body p { color: var(--muted); font-size: .9rem; line-height: 1.45; }
.project-url {
  display: inline-block; margin-top: .55rem;
  color: var(--cyan); font-size: .8rem;
}

.site-footer {
  border-top: 1px solid rgba(255,255,255,.06);
  padding: 2rem 0 2.5rem;
  margin-top: 2rem;
}
.footer-inner {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 2rem; flex-wrap: wrap;
}
.footer-brand p { color: var(--muted); font-size: .875rem; margin-top: .35rem; }
.footer-nav { display: flex; flex-wrap: wrap; gap: 1rem; }
.footer-nav a,
.footer-nav .footer-link-btn {
  color: var(--muted); text-decoration: none; font-size: .875rem;
}
.footer-nav a:hover,
.footer-nav .footer-link-btn:hover { color: var(--text); }

.seo-faq {
  margin-top: 3rem; padding-top: 2rem;
  border-top: 1px solid rgba(255,255,255,.06);
}
.seo-faq h2 { font-size: 1.5rem; margin-bottom: 1.25rem; text-align: center; }
.faq-list { display: flex; flex-direction: column; gap: .75rem; max-width: 800px; margin: 0 auto; }
.faq-item {
  border: 1px solid rgba(255,255,255,.08); border-radius: var(--radius);
  background: rgba(255,255,255,.02); padding: 1rem 1.25rem;
}
.faq-item summary {
  cursor: pointer; font-weight: 600; list-style: none;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item p { margin-top: .75rem; color: var(--muted); font-size: .95rem; }
