/* ============================================================
   ege easy — design system
   dark · minimal · premium · game-progress atmosphere
   ============================================================ */

/* Light is the default. Components consume these shared tokens, so
   every current and subsequent screen follows the selected theme. */
:root {
  --bg: #e9edf4;
  --bg-2: #dfe5ef;
  --surface: #ffffff;
  --surface-2: #f0f3f8;
  --surface-3: #e3e8f1;
  --border: rgba(30, 41, 59, 0.13);
  --border-strong: rgba(30, 41, 59, 0.24);
  --text: #1b2233;
  --text-2: #4a5872;
  --muted: #57647e;
  --accent: #6d7cff;
  --accent-soft: rgba(109, 124, 255, 0.16);
  --accent-glow: rgba(109, 124, 255, 0.35);
  --accent-ring: rgba(74, 91, 224, 0.32);
  --violet: #9a7bff;
  /* Текст акцентным цветом: чистый --accent (3.51) и --violet (3.16) на
     белом не дотягивают до AA 4.5 — для текста используем ink-варианты. */
  --accent-ink: #4a5be0;
  --violet-ink: #7c3aed;
  --btn-primary-bg: #4a5be0;
  --btn-primary-hover: #3f51e0;
  --success: #3ddc97;
  --success-soft: rgba(61, 220, 151, 0.12);
  --success-ink: #147a4c;
  --danger: #ff6b6b;
  --danger-soft: rgba(255, 107, 107, 0.12);
  --danger-ink: #cf3333;
  --warn: #ffc46b;
  --warn-soft: rgba(255, 196, 107, 0.12);
  --warn-ink: #9a5b00;
  --streak-viol: #6d28d9;
  --streak-viol-soft: rgba(109, 40, 217, 0.12);
  --streak-hot-neon: #ff2244;
  --streak-hot-glow: rgba(255, 34, 68, 0.55);
  --streak-viol-neon: #7c3aed;
  --streak-viol-glow: rgba(124, 58, 237, 0.45);
  --radius: 14px;
  --radius-sm: 10px;
  --sidebar-w: 232px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "SF Mono", "JetBrains Mono", "Fira Code", ui-monospace, Menlo, Consolas, monospace;
  --chrome-bg: rgba(255, 255, 255, 0.88);
  --scrim: rgba(15, 23, 42, 0.58);
  --focus-scrim: rgba(15, 23, 42, 0.10);
  --shadow: rgba(30, 41, 59, 0.16);
  --soft-hover: #e1e6f1;
  /* Светлая тема держится на слоях: белая карточка над углублённым фоном
     + мягкая тень. В тёмной теме эти токены пустые — там глубину дают
     границы и свечения, тени на чёрном не работают. */
  --sidebar-bg: #f4f6fa;
  --card-shadow: 0 1px 2px rgba(30, 41, 59, 0.07), 0 12px 28px -18px rgba(30, 41, 59, 0.30);
  --btn-primary-shadow: 0 8px 18px -8px rgba(74, 91, 224, 0.55);
}

:root[data-theme="dark"] {
  --bg: #0a0c11;
  --bg-2: #0d1017;
  --surface: #12161f;
  --surface-2: #161b27;
  --surface-3: #1b2130;
  --border: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.12);
  --text: #e9ebf3;
  --text-2: #aab1c4;
  --muted: #6d7488;
  /* Светлые ink-варианты для тёмного фона (8.8+ на --surface). */
  --accent-ink: #a5b0ff;
  --accent-ring: rgba(165, 176, 255, 0.30);
  --violet-ink: #c4b5fd;
  --btn-primary-bg: #6d7cff;
  --btn-primary-hover: #7d8aff;
  --success-ink: #86efac;
  --danger-ink: #fca5a5;
  --warn-ink: #fcd34d;
  --streak-viol: #c4b5fd;
  --streak-viol-soft: rgba(196, 181, 253, 0.14);
  --streak-hot-neon: #ff5c7a;
  --streak-hot-glow: rgba(255, 92, 122, 0.6);
  --streak-viol-neon: #c084fc;
  --streak-viol-glow: rgba(192, 132, 252, 0.55);
  --chrome-bg: rgba(10, 12, 17, 0.80);
  --scrim: rgba(5, 6, 10, 0.70);
  --focus-scrim: rgba(8, 11, 22, 0.20);
  --shadow: rgba(0, 0, 0, 0.35);
  --soft-hover: #222a3d;
  --sidebar-bg: #0d1017;
  --card-shadow: none;
  --btn-primary-shadow: none;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { color-scheme: light; }
html[data-theme="dark"] { color-scheme: dark; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: var(--accent-soft); }

/* Единое видимое кольцо фокуса для клавиатурной навигации. Объявлено до
   компонентных стилей, чтобы локальные override (например, answer-input со
   своей тенью фокуса) побеждали при равной специфичности. */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}
.answer-input:focus-visible { outline: none; }
.mathvisual-board *:focus-visible,
.mathvisual-svg *:focus-visible { outline: none; }

/* ---------- layout shell ---------- */

.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  border-right: 1px solid var(--border);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 14px 16px;
}

.sidebar__logo {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: baseline;
  gap: 6px;
  padding: 0 10px 20px;
}
.sidebar__logo--easy { grid-template-columns: auto 1fr; }
.easy-badge {
  width: 34px; height: 34px; border-radius: 50%; flex: 0 0 34px;
  background: linear-gradient(135deg, #22c07a 0%, #6d7cff 130%);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 16px -6px rgba(34, 192, 122, 0.55);
}
.easy-badge svg { width: 18px; height: 18px; }
.easy-name { font-weight: 700; font-size: 17px; letter-spacing: -0.01em; color: var(--text); text-transform: lowercase; white-space: nowrap; }
.easy-name em { font-style: normal; color: var(--success-ink); }
.logo-sub { grid-column: 1 / -1; font-size: 11px; color: var(--muted); letter-spacing: 0.02em; }

.sidebar__nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
  position: relative;
}
.nav-item svg { width: 17px; height: 17px; flex: 0 0 17px; opacity: 0.85; }
.nav-item:hover { background: var(--surface); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--text); }
.nav-item.active::before {
  content: "";
  position: absolute;
  left: -14px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 3px;
  background: var(--accent);
  box-shadow: 0 0 12px var(--accent-glow);
}
.nav-item .nav-badge {
  margin-left: auto;
  font-size: 11px;
  font-weight: 600;
  background: var(--danger-soft);
  color: var(--danger-ink);
  border-radius: 20px;
  padding: 1px 8px;
}

.sidebar__footer {
  border-top: 1px solid var(--border);
  padding: 14px 10px 0;
  font-size: 12px;
  color: var(--muted);
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 14px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--chrome-bg);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 20;
  flex-wrap: wrap;
  row-gap: 8px;
}
.topbar__spacer { flex: 1; }

.screen {
  flex: 1;
  padding: 30px 28px 60px;
  max-width: 1160px;
  width: 100%;
  margin: 0 auto;
  animation: screenIn 0.28s ease;
}

@keyframes screenIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.bottomnav { display: none; }

/* ---------- generic components ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--card-shadow);
  transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s;
}
.card--hover:hover {
  border-color: var(--border-strong);
  transform: translateY(-2px);
  box-shadow: 0 8px 30px var(--shadow);
}
.card--glow { box-shadow: 0 0 40px rgba(109, 124, 255, 0.08), inset 0 0 0 1px rgba(109, 124, 255, 0.12); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s, box-shadow 0.2s;
  text-decoration: none;
  color: var(--text);
  white-space: nowrap;
}
.btn:active { transform: scale(0.98); }
.btn--primary {
  background: var(--btn-primary-bg);
  color: #fff;
  box-shadow: var(--btn-primary-shadow);
}
.btn--primary:hover { background: var(--btn-primary-hover); box-shadow: 0 0 20px var(--accent-glow); }
.btn--ghost {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--text-2);
}
.btn--ghost:hover { border-color: var(--accent); color: var(--text); }
.btn--soft { background: var(--surface-3); color: var(--text); }
.btn--soft:hover { background: var(--soft-hover); }
.btn--danger-soft { background: var(--danger-soft); color: var(--danger-ink); }
.btn--sm { padding: 6px 12px; font-size: 13px; }
.btn--lg { padding: 13px 26px; font-size: 15px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn svg { width: 15px; height: 15px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  background: var(--surface-3);
  color: var(--text-2);
  letter-spacing: 0.02em;
  white-space: nowrap;
  flex-shrink: 0;
}
.chip--accent { background: var(--accent-soft); color: var(--accent-ink); border: 1px solid var(--accent-ring); }
.chip--success { background: var(--success-soft); color: var(--success-ink); }
.chip--danger { background: var(--danger-soft); color: var(--danger-ink); }
.chip--warn { background: var(--warn-soft); color: var(--warn-ink); }

.progress {
  height: 6px;
  background: var(--surface-3);
  border-radius: 6px;
  overflow: hidden;
  position: relative;
}
.progress__fill {
  height: 100%;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--accent), var(--violet));
  transition: width 0.6s cubic-bezier(0.22, 1, 0.36, 1);
  position: relative;
}
.progress__fill::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.25), transparent);
  animation: shimmer 2.4s infinite;
}
@keyframes shimmer {
  0% { transform: translateX(-100%); }
  60%, 100% { transform: translateX(100%); }
}
.progress--success .progress__fill { background: linear-gradient(90deg, #2bb886, var(--success)); }
.progress--warn .progress__fill { background: linear-gradient(90deg, #e0a545, var(--warn)); }
.progress--thin { height: 4px; }
.progress--gauge { position: relative; }
.progress--gauge .progress__fill {
  background: linear-gradient(90deg, var(--danger), var(--warn) 55%, var(--success));
  background-size: 260% 100%;
}
.progress--gauge .progress__fill::after { display: none; }
.progress--gauge::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image: repeating-linear-gradient(90deg, var(--bg) 0 1px, transparent 1px 20%);
}

.stars { color: var(--warn-ink); letter-spacing: 2px; font-size: 12px; }
.stars .off { color: var(--border-strong); }

.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

.section-title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 34px 0 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.section-title::after { content: ""; flex: 1; height: 1px; background: var(--border); }

.page-head { margin-bottom: 8px; }
.page-title { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.page-sub { color: var(--muted); font-size: 14px; margin-top: 4px; }

.grid { display: grid; gap: 16px; }
.grid--2 { grid-template-columns: repeat(2, 1fr); }
.grid--3 { grid-template-columns: repeat(3, 1fr); }
.grid--4 { grid-template-columns: repeat(4, 1fr); }

.stat-num { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat-label { font-size: 12px; color: var(--muted); margin-top: 2px; }

.delta-up { color: var(--success-ink); font-size: 12px; font-weight: 600; }
.delta-down { color: var(--danger-ink); font-size: 12px; font-weight: 600; }

.empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

/* ---------- topbar widgets ---------- */

.level-chip {
  display: flex;
  align-items: center;
  gap: 10px;
}
.level-chip__badge {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  background: var(--accent-soft);
  color: var(--accent-ink);
  border: 1px solid rgba(109, 124, 255, 0.3);
  padding: 4px 10px;
  border-radius: 8px;
}
.level-chip__bar { width: 130px; }
.level-chip__xp { font-size: 11px; color: var(--muted); margin-top: 3px; font-variant-numeric: tabular-nums; }

.streak-chip {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 600;
  color: var(--warn-ink);
  background: var(--warn-soft);
  padding: 6px 12px;
  border-radius: 10px;
  position: relative;
  overflow: visible;
  animation: streak-breathe 2.4s ease-in-out infinite;
}
/* Искры: две частицы над пламенем, каждая с двойником через box-shadow */
.streak-chip::before,
.streak-chip::after {
  content: "";
  position: absolute;
  left: 16px;
  bottom: 16px;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--warn-ink);
  box-shadow: 5px 3px 0 -0.5px var(--warn-ink);
  opacity: 0;
  pointer-events: none;
  animation: spark-rise 1.7s ease-out infinite;
}
.streak-chip::after {
  left: 20px;
  width: 2px;
  height: 2px;
  animation-delay: 0.85s;
}
.streak-chip svg {
  width: 14px;
  height: 14px;
  transform-origin: 50% 90%;
  animation:
    flame-sway 1.3s ease-in-out infinite,
    flame-glow 0.9s ease-in-out infinite alternate;
}
@keyframes flame-sway {
  0%, 100% { transform: translateX(0) skewX(0deg) scaleY(1); }
  25% { transform: translateX(-1px) skewX(-7deg) scaleY(1.04); }
  50% { transform: translateX(0.8px) skewX(5deg) scaleY(0.98); }
  75% { transform: translateX(-0.5px) skewX(-3deg) scaleY(1.06); }
}
@keyframes flame-glow {
  from { filter: drop-shadow(0 0 3px var(--warn-ink)) drop-shadow(0 0 7px var(--warn-soft)); opacity: 1; }
  to { filter: drop-shadow(0 0 5px var(--warn-ink)) drop-shadow(0 0 12px var(--warn-soft)); opacity: 0.93; }
}
@keyframes spark-rise {
  0% { transform: translate(0, 0) scale(1); opacity: 0; }
  15% { opacity: 1; }
  100% { transform: translate(3px, -20px) scale(0.25); opacity: 0; }
}
@keyframes streak-breathe {
  0%, 100% { box-shadow: 0 0 0 0 var(--warn-soft); }
  50% { box-shadow: 0 0 14px 0 var(--warn-soft); }
}
/* Уровни огня серии: 7–30 дней — красный, 31+ — фиолетовый.
   Каждый уровень усиливает всё сразу: цвет, размах качания, искры, свечение. */
.streak-chip--hot {
  color: var(--danger-ink);
  background: var(--danger-soft);
  border: 1px solid var(--streak-hot-glow);
  animation: streak-breathe-hot 1.8s ease-in-out infinite;
}
.streak-chip--hot svg {
  color: var(--streak-hot-neon);
  animation:
    flame-sway-hot 1s ease-in-out infinite,
    flame-glow-hot 0.7s ease-in-out infinite alternate;
}
.streak-chip--hot::before,
.streak-chip--hot::after {
  background: var(--streak-hot-neon);
  box-shadow:
    0 0 6px 1px var(--streak-hot-neon),
    0 0 12px 2px var(--streak-hot-glow),
    6px 4px 0 -0.5px var(--streak-hot-neon),
    -4px 6px 0 -1px var(--streak-hot-neon);
  filter: drop-shadow(0 0 4px var(--streak-hot-neon));
  animation: spark-rise-hot 1.2s ease-out infinite;
}
.streak-chip--hot::before { width: 4px; height: 4px; }
.streak-chip--hot::after { animation-delay: 0.6s; }
@keyframes flame-sway-hot {
  0%, 100% { transform: translateX(0) skewX(0deg) scaleY(1); }
  25% { transform: translateX(-1.5px) skewX(-10deg) scaleY(1.07); }
  50% { transform: translateX(1.2px) skewX(8deg) scaleY(0.96); }
  75% { transform: translateX(-0.8px) skewX(-5deg) scaleY(1.09); }
}
@keyframes flame-glow-hot {
  from { filter: drop-shadow(0 0 3px var(--streak-hot-neon)) drop-shadow(0 0 9px var(--streak-hot-neon)) drop-shadow(0 0 18px var(--streak-hot-glow)); opacity: 1; }
  to { filter: drop-shadow(0 0 5px var(--streak-hot-neon)) drop-shadow(0 0 14px var(--streak-hot-neon)) drop-shadow(0 0 26px var(--streak-hot-glow)); opacity: 0.92; }
}
@keyframes spark-rise-hot {
  0% { transform: translate(0, 0) scale(1); opacity: 0; }
  15% { opacity: 1; }
  100% { transform: translate(4px, -26px) scale(0.25); opacity: 0; }
}
@keyframes streak-breathe-hot {
  0%, 100% { box-shadow: 0 0 0 0 var(--streak-hot-glow), 0 0 10px 0 var(--streak-hot-glow); }
  50% { box-shadow: 0 0 18px 0 var(--streak-hot-glow), 0 0 34px 0 var(--streak-hot-glow); }
}
.streak-chip--inferno {
  color: var(--streak-viol);
  background: var(--streak-viol-soft);
  border: 1px solid var(--streak-viol-glow);
  animation: streak-breathe-inferno 1.5s ease-in-out infinite;
}
.streak-chip--inferno svg {
  color: var(--streak-viol-neon);
  animation:
    flame-sway-inferno 0.85s ease-in-out infinite,
    flame-glow-inferno 0.55s ease-in-out infinite alternate;
}
.streak-chip--inferno::before,
.streak-chip--inferno::after {
  background: var(--streak-viol-neon);
  box-shadow:
    0 0 6px 1px var(--streak-viol-neon),
    0 0 14px 2px var(--streak-viol-glow),
    7px 4px 0 -0.5px var(--streak-viol-neon),
    -5px 7px 0 -1px var(--streak-viol-neon);
  filter: drop-shadow(0 0 5px var(--streak-viol-neon));
  animation: spark-rise-inferno 1s ease-out infinite;
}
.streak-chip--inferno::before { width: 4px; height: 4px; }
.streak-chip--inferno::after { width: 3px; height: 3px; animation-delay: 0.5s; }
@keyframes flame-sway-inferno {
  0%, 100% { transform: translateX(0) skewX(0deg) scaleY(1); }
  25% { transform: translateX(-2px) skewX(-12deg) scaleY(1.09); }
  50% { transform: translateX(1.6px) skewX(10deg) scaleY(0.95); }
  75% { transform: translateX(-1px) skewX(-6deg) scaleY(1.11); }
}
@keyframes flame-glow-inferno {
  from { filter: drop-shadow(0 0 4px var(--streak-viol-neon)) drop-shadow(0 0 10px var(--streak-viol-neon)) drop-shadow(0 0 20px var(--streak-viol-glow)); opacity: 1; }
  to { filter: drop-shadow(0 0 6px var(--streak-viol-neon)) drop-shadow(0 0 16px var(--streak-viol-neon)) drop-shadow(0 0 30px var(--streak-viol-glow)); opacity: 0.92; }
}
@keyframes spark-rise-inferno {
  0% { transform: translate(0, 0) scale(1); opacity: 0; }
  15% { opacity: 1; }
  100% { transform: translate(5px, -32px) scale(0.25); opacity: 0; }
}
@keyframes streak-breathe-inferno {
  0%, 100% { box-shadow: 0 0 0 0 var(--streak-viol-glow), 0 0 12px 0 var(--streak-viol-glow); }
  50% { box-shadow: 0 0 22px 0 var(--streak-viol-glow), 0 0 40px 0 var(--streak-viol-glow); }
}
@media (prefers-reduced-motion: reduce) {
  .streak-chip, .streak-chip svg, .streak-chip::before, .streak-chip::after { animation: none; }
  .streak-chip::before, .streak-chip::after { display: none; }
}

.theme-toggle {
  width: 34px;
  height: 34px;
  padding: 0;
  flex: 0 0 34px;
  color: var(--text-2);
}
.theme-toggle:hover { color: var(--text); }
.theme-toggle svg { width: 16px; height: 16px; }

/* ---------- dashboard ---------- */

.hero {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 16px;
  margin-top: 6px;
}

.forecast-card { position: relative; overflow: hidden; }
.forecast-card::before {
  content: "";
  position: absolute;
  top: -60px;
  right: -60px;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(109, 124, 255, 0.18), transparent 70%);
  pointer-events: none;
}
/* Прогноз как герой-виджет: крупная цифра, шкала до 100 с меткой цели,
   тренд-пилюля и кликабельный совет. Только var(--…)-токены — обе темы. */
.forecast-hero {
  background:
    radial-gradient(420px 200px at 85% -30%, var(--accent-soft), transparent 65%),
    linear-gradient(180deg, var(--accent-soft), transparent 42%),
    var(--surface);
  border: 1px solid var(--accent-ring);
}
.forecast-hero__top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.forecast-trend {
  font-size: 12px;
  font-weight: 700;
  padding: 4px 11px;
  border-radius: 20px;
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--border-strong);
  white-space: nowrap;
  flex-shrink: 0;
}
.forecast-trend--up { background: var(--success-soft); color: var(--success-ink); }
.forecast-trend--down { background: var(--danger-soft); color: var(--danger-ink); }
.forecast-mid {
  margin-top: 10px;
  font-size: 56px;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.forecast-mid small { font-size: 17px; font-weight: 600; letter-spacing: 0; color: var(--muted); margin-left: 8px; }
.forecast-range { margin-top: 6px; font-size: 13px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.forecast-range b { color: var(--accent-ink); }
.forecast-scale { position: relative; height: 8px; border-radius: 99px; background: var(--surface-3); margin-top: 16px; }
.forecast-scale__fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--accent), var(--violet));
}
.forecast-scale__goal {
  position: absolute;
  top: -5px;
  bottom: -5px;
  width: 3px;
  border-radius: 2px;
  background: var(--warn-ink);
}
.forecast-scale__labels { display: flex; justify-content: space-between; margin-top: 6px; font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.forecast-scale__labels .goal { color: var(--warn-ink); font-weight: 700; }
.forecast-scale__labels--goal { position: relative; }
.forecast-scale__labels--goal .goal { position: absolute; top: 0; white-space: nowrap; transform: translateX(-50%); }
.forecast-scale__labels--goal .goal--left { transform: none; }
.forecast-scale__labels--goal .goal--right { transform: translateX(-100%); }
.forecast-gain-btn {
  margin-top: 14px;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  border: 1px solid var(--accent-ring);
  color: var(--text);
  font-family: inherit;
  font-size: 13.5px;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, transform 0.1s;
}
.forecast-gain-btn:hover { border-color: var(--accent-ink); }
.forecast-gain-btn:active { transform: scale(0.99); }
.forecast-gain-btn b { color: var(--accent-ink); font-variant-numeric: tabular-nums; }
.forecast-gain-btn .go { margin-left: auto; color: var(--accent-ink); font-weight: 700; flex-shrink: 0; }
.forecast-cover { margin-top: 14px; }
.forecast-cover__row { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; color: var(--muted); margin-bottom: 6px; font-variant-numeric: tabular-nums; }
.forecast-empty { text-align: center; padding: 14px 4px 6px; }
.forecast-empty__icon {
  width: 46px;
  height: 46px;
  margin: 0 auto 12px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  border: 1px solid var(--accent-ring);
  color: var(--accent-ink);
}
.forecast-empty__icon svg { width: 22px; height: 22px; }
.forecast-empty__title { font-size: 16px; font-weight: 700; }
.forecast-empty__text { margin-top: 8px; font-size: 13.5px; color: var(--text-2); line-height: 1.6; }
.forecast-empty .btn { margin-top: 14px; }
@media (max-width: 640px) {
  .forecast-mid { font-size: 46px; }
}
.forecast-value {
  font-size: 44px;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.forecast-note { font-size: 12px; color: var(--muted); margin-top: 8px; }
.forecast-gain { font-size: 13px; color: var(--text-2); margin-top: 8px; }

.action-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.action-card {
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 110px;
}
.action-card__icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent-ink);
}
.action-card__icon svg { width: 17px; height: 17px; }
.action-card--warn .action-card__icon { background: var(--warn-soft); color: var(--warn-ink); }
.action-card--success .action-card__icon { background: var(--success-soft); color: var(--success-ink); }
.action-card--violet .action-card__icon { background: rgba(154, 123, 255, 0.14); color: var(--violet-ink); }
.action-card__title { font-weight: 600; font-size: 14px; }
.action-card__sub { font-size: 12px; color: var(--muted); }

.skill-row {
  display: grid;
  grid-template-columns: 150px 1fr 52px;
  align-items: center;
  gap: 14px;
  padding: 11px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s;
  position: relative;
}
.skill-row:hover { background: var(--surface-2); }
.skill-row__name { font-size: 14px; font-weight: 500; }
.skill-row__pct { font-size: 13px; color: var(--text-2); text-align: right; font-variant-numeric: tabular-nums; }
.skill-row__tip {
  display: none;
  position: absolute;
  z-index: 30;
  left: 150px;
  top: calc(100% - 4px);
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 12px;
  color: var(--text-2);
  box-shadow: 0 12px 32px var(--shadow);
  min-width: 230px;
  pointer-events: none;
}
.skill-row:hover .skill-row__tip { display: block; animation: screenIn 0.15s ease; }

.reco-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.reco-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-2);
  font-size: 14px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.reco-item:hover { border-color: var(--accent); color: var(--text); background: var(--accent-soft); }
.reco-item__arrow { color: var(--accent-ink); font-weight: 700; }

/* ---------- «Что делать сейчас» — главный навигатор обучения ---------- */

.nextstep {
  position: relative;
  overflow: hidden;
  margin-top: 18px;
  padding: 24px;
  background:
    radial-gradient(480px 220px at 12% -20%, var(--accent-soft), transparent 65%),
    var(--surface);
  border: 1px solid var(--accent);
  box-shadow: 0 0 44px -6px var(--accent-glow), 0 24px 48px -30px var(--shadow);
}
.nextstep__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.nextstep__label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent-ink);
}
.nextstep__label svg { width: 14px; height: 14px; }
.nextstep__freedom { font-size: 12px; color: var(--muted); }
.nextstep__title {
  margin-top: 12px;
  font-size: clamp(19px, 3.4vw, 25px);
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.25;
}
.nextstep__reason {
  margin-top: 8px;
  max-width: 640px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-2);
}
.nextstep__actions {
  margin-top: 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.nextstep__alts { display: flex; gap: 8px; flex-wrap: wrap; }
.nextstep__alts .btn { max-width: 320px; overflow: hidden; text-overflow: ellipsis; }
.nextstep__alts .btn span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
@media (max-width: 640px) {
  .nextstep { padding: 18px; }
  .nextstep__actions .btn--lg { width: 100%; }
  .nextstep__alts { width: 100%; }
  .nextstep__alts .btn { flex: 1 1 auto; max-width: none; }
}

/* ---------- skill tree / path ---------- */

.tree-root {
  display: flex;
  justify-content: center;
  margin-bottom: 0;
}
.tree-root__node {
  padding: 12px 34px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--accent-soft), rgba(154, 123, 255, 0.1));
  border: 1px solid rgba(109, 124, 255, 0.35);
  font-weight: 800;
  letter-spacing: 0.14em;
  font-size: 14px;
  text-align: center;
  box-shadow: 0 0 30px rgba(109, 124, 255, 0.12);
}
.tree-root__node small { display: block; font-weight: 500; letter-spacing: 0.02em; color: var(--text-2); font-size: 11px; margin-top: 2px; }

.tree-connector-v {
  width: 2px;
  height: 26px;
  margin: 0 auto;
  background: linear-gradient(var(--accent), var(--border-strong));
}

.tree-branches { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; position: relative; }
.tree-branches::before {
  content: "";
  position: absolute;
  top: 0;
  left: 25%;
  right: 25%;
  height: 2px;
  background: var(--border-strong);
}
.tree-branch { position: relative; padding-top: 26px; }
.tree-branch::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  width: 2px;
  height: 26px;
  background: var(--border-strong);
}
.tree-branch__title {
  text-align: center;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.14em;
  color: var(--text-2);
  margin-bottom: 18px;
}
.tree-branch__title span { color: var(--muted); font-weight: 500; letter-spacing: 0; margin-left: 8px; font-size: 12px; }

.tree-nodes { display: flex; flex-direction: column; gap: 12px; position: relative; }
.tree-nodes::before {
  content: "";
  position: absolute;
  left: 19px;
  top: 10px;
  bottom: 10px;
  width: 2px;
  background: var(--border);
}

.tree-node {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 16px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: border-color 0.2s, transform 0.15s, box-shadow 0.2s;
  position: relative;
  margin-left: 40px;
}
.tree-node::before {
  content: "";
  position: absolute;
  left: -21px;
  top: 50%;
  width: 21px;
  height: 2px;
  background: var(--border);
}
.tree-node:hover { border-color: var(--border-strong); transform: translateX(3px); }
.tree-node--locked { opacity: 0.45; cursor: not-allowed; }
.tree-node--locked:hover { transform: none; border-color: var(--border); }

.tree-node__dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex: 0 0 12px;
  background: var(--surface-3);
  border: 2px solid var(--border-strong);
}
.tree-node--not-started .tree-node__dot { background: var(--surface-3); border-color: var(--border-strong); }
.tree-node--in-progress .tree-node__dot { border-color: var(--accent); box-shadow: 0 0 10px var(--accent-glow); animation: pulse 2s infinite; }
.tree-node--completed { border-color: rgba(61, 220, 151, 0.35); }
.tree-node--completed .tree-node__dot { background: var(--success); border-color: var(--success); }
.tree-node--mastered { border-color: rgba(61, 220, 151, 0.35); }
.tree-node--mastered .tree-node__dot { background: var(--success); border-color: var(--success); box-shadow: 0 0 10px rgba(61, 220, 151, 0.4); }
.tree-node--weak .tree-node__dot { background: var(--danger); border-color: var(--danger); }

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(109, 124, 255, 0.4); }
  50% { box-shadow: 0 0 0 6px rgba(109, 124, 255, 0); }
}

.tree-node__body { flex: 1; min-width: 0; }
.tree-node__name { font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.tree-node__meta { font-size: 12px; color: var(--muted); margin-top: 5px; display: flex; align-items: center; gap: 10px; }
.tree-node__bar { width: 90px; }
.tree-node__lock { color: var(--muted); }
.tree-node__lock svg { width: 15px; height: 15px; }

/* ---------- session (task solving) ---------- */

.session-wrap { max-width: 760px; margin: 0 auto; }
.session-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.session-head__title { font-size: 15px; font-weight: 600; }
.session-head__progress { margin-left: auto; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }

.task-card { padding: 28px; }
.task-card__tags { display: flex; gap: 8px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.task-card__text { font-size: 17px; line-height: 1.7; white-space: pre-line; }
/* Every KaTeX fragment is emphasized consistently, including new lesson
   surfaces added later. The rule targets only KaTeX output, never prose. */
.katex { font-size: 1.3em; font-weight: 700; }
/* Специфичность выше вендорной (.katex{font:normal} из katex.min.css):
   жирность цифр не зависит от порядка подключения стилей. */
.task-card__text .katex, .lesson-text .katex, .feedback__solution .katex,
.hint-box .katex, .lesson-token .katex { font-weight: 700; }
.task-card__text .katex-display,
.lesson-text .katex-display { margin: .65em 0; overflow-x: auto; overflow-y: hidden; padding: .15em 0; }
.math-fallback { font-family: var(--mono); white-space: pre-wrap; font-size: 1.3em; font-weight: 700; }
.task-card__text sup, .feedback__solution sup, .hint-box sup, .lesson-token sup { font-size: .72em; line-height: 0; }

.task-visual {
  width: 100%;
  max-width: 680px;
  margin: 22px auto 4px;
  min-width: 0;
  aspect-ratio: var(--visual-ratio, auto);
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-2);
}
.task-visual img {
  display: block;
  width: 100%;
  height: auto;
  max-height: min(58vh, 520px);
  object-fit: contain;
  margin: 0 auto;
}
.task-visual--svg img,
.task-visual--graph img,
.task-visual--geometry img { image-rendering: auto; }
.task-visual__fallback {
  display: none;
  padding: 14px 16px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}
.task-visual--missing,
.task-visual--broken { min-height: 48px; }
.task-visual--missing .task-visual__fallback,
.task-visual--broken .task-visual__fallback { display: block; }
.task-visual figcaption {
  padding: 8px 12px 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  border-top: 1px solid var(--border);
}

/* MathVisual: declarative diagrams rendered live by JSXGraph (or, for
   probability trees, plain inline SVG). Shares .task-visual's frame
   (border/background/margin) so it sits identically to a static image;
   only the board itself needs its own sizing and a theme-aware background
   (jsxgraph.css hardcodes white, which would look wrong in dark mode). */
.mathvisual-host.mathvisual-jsx { aspect-ratio: var(--visual-ratio, 1.5); }
/* Пока движок не смонтировал диаграмму (первый заход ждёт ~1.2 МБ vendor),
   хост — пустая рамка. Скелетон показывает, что содержимое грузится,
   вместо «сломанного» серого прямоугольника. */
.mathvisual-host { position: relative; }
.mathvisual-host[data-mathvisual]:not([data-mathvisual-mounted])::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 20%, var(--soft-hover) 50%, transparent 80%);
  background-size: 200% 100%;
  animation: visualShimmer 1.4s ease-in-out infinite;
  pointer-events: none;
}
@keyframes visualShimmer {
  from { background-position: 120% 0; }
  to { background-position: -120% 0; }
}
.mathvisual-board {
  width: 100%;
  height: 100%;
  min-height: 220px;
  /* Удержание пальца/кнопки на фигуре не должно давать браузерную подсветку
     (жирный квадрат/заливку контура элемента), выделение текста и callout. */
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
  -webkit-user-select: none;
}
.mathvisual-svg {
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
  -webkit-user-select: none;
}
/* JSXGraph фокусирует render-ноду элемента под пальцем (для клавиатурного
   управления), а Chromium рисует вокруг неё :focus outline по bounding box —
   на окружности это жирный чёрный квадрат, на других элементах их силуэт.
   Фигуры статичны (всё fixed), клавиатурного взаимодействия с элементами
   нет — outline подавляем глобально для всего, что рисует движок. */
.mathvisual-board *:focus,
.mathvisual-svg *:focus { outline: none; }
.mathvisual-board.jxgbox,
.mathvisual-jsx .jxgbox { background-color: transparent !important; }
.mathvisual-jsx .jxgbox svg text,
.mathvisual-label { font-family: var(--font) !important; }
.mathvisual-svg { padding: 10px 6px; }
.mathvisual-svg svg text { font-family: var(--font); }

.answer-row { display: flex; gap: 10px; margin-top: 24px; }
.answer-input {
  flex: 1;
  font-family: var(--mono);
  font-size: 16px;
  background: var(--bg-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 12px 16px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.answer-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.answer-input--correct { border-color: var(--success) !important; box-shadow: 0 0 0 3px var(--success-soft) !important; }
.answer-input--wrong { border-color: var(--danger) !important; box-shadow: 0 0 0 3px var(--danger-soft) !important; animation: shake 0.3s; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

.session-tools { display: flex; gap: 10px; margin-top: 14px; align-items: center; }

.feedback {
  margin-top: 22px;
  border-radius: var(--radius);
  padding: 18px 20px;
  animation: screenIn 0.25s ease;
}
.feedback--ok { background: var(--success-soft); border: 1px solid rgba(61, 220, 151, 0.3); }
.feedback--bad { background: var(--danger-soft); border: 1px solid rgba(255, 107, 107, 0.3); }
.feedback--retry { background: var(--surface-2); border-color: var(--border-strong); }
.feedback--retry .feedback__head { color: var(--warn-ink); }
.feedback__head { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 15px; }
.feedback--ok .feedback__head { color: var(--success-ink); }
.feedback--bad .feedback__head { color: var(--danger-ink); }
.feedback__xp { margin-left: auto; font-size: 13px; font-weight: 700; color: var(--accent-ink); font-variant-numeric: tabular-nums; }
.feedback__solution { margin-top: 12px; font-size: 14px; color: var(--text-2); line-height: 1.65; white-space: pre-line; }
.feedback__solution b { color: var(--text); }

.hint-box {
  margin-top: 16px;
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  background: var(--warn-soft);
  border: 1px solid rgba(255, 196, 107, 0.25);
  color: var(--warn-ink);
  font-size: 14px;
  animation: screenIn 0.25s ease;
}

.hint-box--deep {
  background: var(--accent-soft);
  border-color: rgba(109, 124, 255, 0.3);
  color: var(--text-2);
  white-space: pre-line;
  line-height: 1.65;
}
.hint-box--deep b { color: var(--text); }

.timer-chip { font-variant-numeric: tabular-nums; }

/* ---------- lessons ---------- */

.lesson-board {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  margin-top: 18px;
  padding: 18px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.lesson-token {
  font-family: var(--mono);
  font-size: 18px;
  padding: 5px 9px;
  border-radius: 8px;
  color: var(--text);
  transition: opacity 0.25s, background 0.25s, box-shadow 0.25s;
}
.lesson-token--on {
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-weight: 700;
  box-shadow: 0 0 16px var(--accent-glow);
}
/* Приглушённые токены остаются читаемыми (это требование механизма Focus,
   а не отдельных уроков): нижний порог непрозрачности, без фильтров. */

/* ---------- result screens ---------- */

.result-wrap {
  max-width: 560px;
  margin: 30px auto 0;
  text-align: center;
}
.result-title {
  font-size: 34px;
  font-weight: 800;
  letter-spacing: 0.1em;
  background: linear-gradient(90deg, var(--accent), var(--violet));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: resultIn 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}
.result-title--danger { background: linear-gradient(90deg, var(--danger), var(--warn)); -webkit-background-clip: text; background-clip: text; }
@keyframes resultIn {
  from { opacity: 0; transform: scale(0.92); letter-spacing: 0.3em; }
  to { opacity: 1; transform: none; }
}
.result-sub { color: var(--muted); margin-top: 8px; font-size: 14px; }
.result-xp {
  font-size: 44px;
  font-weight: 800;
  color: var(--accent-ink);
  margin: 22px 0 4px;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 30px var(--accent-glow);
}
.result-breakdown {
  margin: 10px auto 4px;
  max-width: 380px;
  text-align: left;
  font-size: 13px;
  color: var(--text-2);
}
.result-breakdown__row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 4px 0;
  border-bottom: 1px dashed var(--border);
}
.result-breakdown__row:last-child { border-bottom: none; }
.result-breakdown__row b { color: var(--accent-ink); }
.result-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 26px 0; }

/* ---------- missions ---------- */

.mission-card { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.mission-card__top { display: flex; align-items: flex-start; gap: 10px; }
.mission-card__top > :first-child { min-width: 0; }
.mission-card__title { font-weight: 650; font-size: 15px; }
.mission-card__path { font-size: 12px; color: var(--muted); }
.mission-card__reward { margin-left: auto; flex-shrink: 0; }
.mission-card__foot { display: flex; align-items: center; gap: 12px; font-size: 12px; color: var(--muted); }
.mission-card__bar { flex: 1; }
.mission-card--done { border-color: rgba(61, 220, 151, 0.3); }

/* ---------- errors ---------- */

.error-group { margin-bottom: 14px; }
.error-group__head { display: flex; align-items: center; gap: 12px; }
.error-group__count { margin-left: auto; }
.error-subtopics { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

/* ---------- bosses / trials ---------- */

.boss-card {
  position: relative;
  overflow: hidden;
  border-color: rgba(255, 107, 107, 0.25);
}
.boss-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(600px 120px at 50% -40px, rgba(255, 107, 107, 0.12), transparent);
  pointer-events: none;
}
.boss-card--defeated { border-color: rgba(61, 220, 151, 0.3); }
.boss-card--defeated::before { background: radial-gradient(600px 120px at 50% -40px, rgba(61, 220, 151, 0.1), transparent); }
.boss-label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.22em;
  color: var(--danger-ink);
}
.boss-card--defeated .boss-label { color: var(--success-ink); }
.boss-title { font-size: 20px; font-weight: 700; margin-top: 6px; }

/* ---------- stats ---------- */

.chart-box { padding: 22px; }
.chart-box svg { display: block; width: 100%; height: auto; }
.chart-legend { display: flex; gap: 18px; font-size: 12px; color: var(--muted); margin-top: 10px; }
.chart-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; }

/* ---------- achievements ---------- */

.badge-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.badge-card { text-align: center; padding: 24px 16px; position: relative; }
.badge-card--locked { opacity: 0.42; }
.badge-icon {
  width: 58px;
  height: 58px;
  margin: 0 auto 12px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  color: var(--text-2);
}
.badge-card:not(.badge-card--locked) .badge-icon {
  background: linear-gradient(135deg, var(--accent-soft), rgba(154, 123, 255, 0.16));
  border-color: rgba(109, 124, 255, 0.4);
  color: var(--accent-ink);
  box-shadow: 0 0 24px rgba(109, 124, 255, 0.15);
}
.badge-icon svg { width: 26px; height: 26px; }
.badge-name { font-weight: 650; font-size: 14px; }
.badge-desc { font-size: 12px; color: var(--muted); margin-top: 5px; line-height: 1.5; }

/* ---------- profile identity card ---------- */

.profile-card { margin-top: 18px; padding: 26px 28px; }
.profile-card__identity { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }

.avatar {
  width: 56px;
  height: 56px;
  flex: 0 0 56px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--accent-soft), rgba(154, 123, 255, 0.16));
  border: 1px solid rgba(109, 124, 255, 0.3);
  color: var(--accent-ink);
  font-size: 21px;
  font-weight: 700;
}
.avatar svg { width: 24px; height: 24px; }

.profile-card__who { min-width: 0; }
.profile-card__name { font-size: 19px; font-weight: 700; letter-spacing: -0.01em; }
.profile-card__streak { margin-left: auto; }

.account-id-wrap { position: relative; display: flex; align-items: center; gap: 10px; margin-top: 7px; flex-wrap: wrap; }
.account-id {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px 6px 12px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.account-id:hover, .account-id:focus-visible { border-color: var(--accent); background: var(--accent-soft); }
.account-id:active { transform: scale(0.98); }
.account-id:disabled { cursor: default; opacity: 0.55; }
.account-id__text { display: flex; flex-direction: column; gap: 1px; text-align: left; }
.account-id__label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.account-id__value { font-size: 13px; font-weight: 650; color: var(--text); letter-spacing: 0.02em; }
.account-id__icon { display: grid; place-items: center; color: var(--muted); transition: color 0.15s; }
.account-id__icon svg { width: 14px; height: 14px; }
.account-id:hover .account-id__icon { color: var(--accent-ink); }
.account-id--copied .account-id__icon { color: var(--success-ink); }
.account-id__feedback {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  color: var(--success-ink);
  opacity: 0;
  transform: translateY(2px);
  transition: opacity 0.18s ease, transform 0.18s ease;
  pointer-events: none;
}
.account-id__feedback svg { width: 13px; height: 13px; }
.account-id__feedback.is-visible { opacity: 1; transform: none; }

.profile-card__progress { margin-top: 22px; }
.profile-card__level { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; font-size: 12px; color: var(--muted); }
.profile-card__xp { color: var(--text-2); }
.profile-card__next { margin-left: auto; }

.stat-grid { margin-top: 16px; }
.stat-card { display: flex; align-items: center; gap: 14px; }
.stat-card .action-card__icon { flex: 0 0 34px; }

/* ---------- profile stats teaser ---------- */
.stats-teaser { margin-top: 16px; padding: 22px 24px; }
.stats-teaser__head { display: flex; align-items: center; gap: 14px; }
.stats-teaser__icon { width: 40px; height: 40px; flex: 0 0 40px; border-radius: 12px; display: grid; place-items: center; background: rgba(154, 123, 255, 0.14); color: var(--violet-ink); }
.stats-teaser__icon svg { width: 20px; height: 20px; }
.stats-teaser__title { font-size: 16px; font-weight: 700; }
.stats-teaser__sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.stats-teaser__metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: 18px; }
.stats-teaser__metric { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; }
.stats-teaser__metric b { font-size: 19px; font-weight: 750; font-variant-numeric: tabular-nums; }
.stats-teaser__metric span { font-size: 11.5px; color: var(--muted); }
.stats-teaser__bars { display: flex; align-items: flex-end; gap: 5px; height: 56px; margin-top: 16px; padding: 10px 12px 8px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; }
.stats-teaser__bar { flex: 1; border-radius: 4px 4px 2px 2px; background: rgba(109, 124, 255, 0.35); min-height: 4px; }
.stats-teaser__bar--today { background: var(--accent); }
.stats-teaser__bars-label { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; font-size: 11.5px; color: var(--muted); margin-top: 8px; }
.stats-teaser__foot { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.stats-teaser__foot .btn { display: inline-flex; align-items: center; gap: 8px; }
.stats-teaser__foot .btn svg { width: 15px; height: 15px; }

/* ---------- profile timeline ---------- */

.timeline { position: relative; padding-left: 26px; }
.timeline::before { content: ""; position: absolute; left: 7px; top: 6px; bottom: 6px; width: 2px; background: var(--border); }
.timeline__item { position: relative; padding: 0 0 20px; }
.timeline__item::before {
  content: "";
  position: absolute;
  left: -24px;
  top: 6px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent-glow);
}
.timeline__date { font-size: 12px; color: var(--muted); }
.timeline__text { font-size: 14px; margin-top: 2px; }

/* ---------- onboarding ---------- */

.onboard-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow-y: auto;
}
.onboard-card {
  width: 100%;
  max-width: 620px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 40px;
  animation: screenIn 0.35s ease;
  margin: auto;
}
.onboard-steps { display: flex; gap: 6px; margin-bottom: 28px; }
.onboard-steps i { flex: 1; height: 3px; border-radius: 3px; background: var(--surface-3); transition: background 0.3s; }
.onboard-steps i.on { background: var(--accent); }
.onboard-title { font-size: 26px; font-weight: 750; letter-spacing: -0.02em; }
.onboard-sub { color: var(--muted); margin-top: 8px; font-size: 14px; line-height: 1.6; }
.choice-list { display: flex; flex-direction: column; gap: 10px; margin-top: 24px; }
.choice-item {
  text-align: left;
  padding: 15px 18px;
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.choice-item:hover { border-color: var(--accent); background: var(--accent-soft); }
.choice-item b { display: block; font-size: 15px; margin-bottom: 2px; }
.choice-item span { color: var(--muted); font-size: 13px; }

/* ---------- modal / toast ---------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: var(--scrim);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity: 0; } }
.modal {
  width: 100%;
  max-width: 520px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  padding: 28px;
  animation: modalIn 0.25s cubic-bezier(0.22, 1, 0.36, 1);
  max-height: 86vh;
  max-height: 86dvh;
  overflow-y: auto;
  position: relative;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(14px) scale(0.98); }
  to { opacity: 1; transform: none; }
}
.modal__close {
  position: absolute;
  top: 14px;
  right: 14px;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
}
.modal__close:hover { color: var(--text); background: var(--surface-3); }
.modal-wrap { position: relative; width: 100%; display: flex; justify-content: center; }
/* Ручка свайпа: видна только на телефоне, где модалка — bottom-sheet. */
.modal__grab { display: none; }
.modal--drag { transition: none !important; will-change: transform; user-select: none; -webkit-user-select: none; cursor: grabbing; }
.modal--drag .modal__grab { cursor: grabbing; }
.modal--snap { transition: transform 0.28s cubic-bezier(0.2, 0.9, 0.25, 1); }
.modal--dismiss { transition: transform 0.18s ease-in, opacity 0.18s ease-in; opacity: 0; pointer-events: none; }

/* ---------- skill modal (окно темы в Пути) ---------- */
.skill-modal__title { font-size: 22px; font-weight: 700; margin-top: 4px; padding-right: 36px; overflow-wrap: anywhere; }
.skill-modal__stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 16px; }
.skill-modal__stat-num { font-family: var(--mono, monospace); font-size: 20px; font-weight: 700; }
.skill-modal__actions { margin-top: 22px; display: flex; gap: 10px; flex-wrap: wrap; }
/* Чипы внутри модалки обязаны переноситься: white-space:nowrap + flex-shrink:0
   из .chip растягивали окно по горизонтали на телефоне (длинный текст — во всю строку). */
.modal { overflow-x: hidden; }
.modal .chip { white-space: normal; flex-shrink: 1; min-width: 0; max-width: 100%; overflow-wrap: anywhere; word-break: break-word; }
.modal .error-subtopics { min-width: 0; }
.modal .error-subtopics > * { min-width: 0; }

/* ---------- контекстные подсказки ---------- */

.help-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: none;
  color: var(--muted);
  cursor: pointer;
  padding: 0;
  margin-left: 6px;
  vertical-align: middle;
  flex-shrink: 0;
}
.help-dot svg { width: 12px; height: 12px; }
.help-dot:hover { color: var(--text); border-color: var(--accent); background: var(--accent-soft); }
.help-body { color: var(--text-2); font-size: 14px; line-height: 1.65; margin-top: 12px; }
.help-body p { margin: 0 0 10px; }
.help-body p:last-child { margin-bottom: 0; }
.help-body b { color: var(--text); }
.streak-chip--clickable { cursor: pointer; }
.streak-chip--clickable:hover { border-color: var(--accent); }

.toast-root {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}
.toast {
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 13px 18px;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 16px 40px var(--shadow);
  animation: toastIn 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  max-width: 340px;
}
.toast svg { width: 17px; height: 17px; flex: 0 0 17px; }
.toast--xp { border-color: rgba(109, 124, 255, 0.4); }
.toast--ach { border-color: rgba(255, 196, 107, 0.4); }
.toast.out { animation: toastOut 0.3s ease forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateX(30px); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(10px); } }

.levelup-overlay {
  position: fixed;
  inset: 0;
  z-index: 110;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--scrim);
  backdrop-filter: blur(8px);
  animation: fadeIn 0.25s ease;
  cursor: pointer;
}
.levelup-box { text-align: center; animation: resultIn 0.5s cubic-bezier(0.22, 1, 0.36, 1); }
.levelup-box__label { font-size: 13px; letter-spacing: 0.3em; color: var(--muted); font-weight: 700; }
.levelup-box__level {
  font-size: 84px;
  font-weight: 800;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, var(--accent), var(--violet));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: none;
  filter: drop-shadow(0 0 30px var(--accent-glow));
  line-height: 1.1;
}

/* ---------- responsive ---------- */

@media (max-width: 1020px) {
  .grid--4, .action-cards { grid-template-columns: repeat(2, 1fr); }
  .grid--3, .badge-grid { grid-template-columns: repeat(2, 1fr); }
  .hero { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .sidebar { display: none; }
  .screen { padding: 20px 16px 110px; }
  .topbar { padding: 12px 16px; gap: 12px; }
  .level-chip__bar { width: 80px; }
  .topbar .hide-mobile { display: none; }

  .bottomnav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 50;
    background: var(--chrome-bg);
    backdrop-filter: blur(14px);
    border-top: 1px solid var(--border);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .bottomnav a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 7px 2px;
    color: var(--muted);
    text-decoration: none;
    font-size: 10px;
    font-weight: 600;
    border-radius: 10px;
  }
  .bottomnav a svg { width: 20px; height: 20px; }
  .bottomnav a.active { color: var(--accent-ink); }

  .tree-branches { grid-template-columns: 1fr; }
  .tree-branches::before { display: none; }
  .grid--2, .grid--3 { grid-template-columns: minmax(0, 1fr); }
  .grid > * { min-width: 0; }
  .result-stats { grid-template-columns: repeat(3, 1fr); }
  .page-title { font-size: 22px; }
  .profile-card { padding: 20px; }
  .profile-card__streak { margin-left: 0; }
  .stats-teaser { padding: 18px; }
  .stats-teaser__metrics { grid-template-columns: repeat(2, 1fr); }
  .stats-teaser__foot .btn { flex: 1; justify-content: center; }
  .account-id-wrap { margin-top: 9px; }
  .onboard-card { padding: 26px 20px; }
  .answer-row { flex-direction: column; }
  .task-visual { max-width: 100%; margin-top: 18px; }
  .task-visual img { max-height: 48vh; }
  .skill-row { grid-template-columns: 110px 1fr 46px; }
  .skill-row__tip { left: 0; }

  /* Модалка темы — bottom-sheet: во всю ширину, кнопки в столбик на всю ширину */
  .modal-backdrop { align-items: flex-end; padding: 0; }
  .modal-wrap { justify-content: stretch; }
  .modal__grab { display: flex; justify-content: center; padding: 12px 0 10px; margin: -8px 0 0; cursor: grab; touch-action: none; }
  .modal__grab span { width: 48px; height: 5px; border-radius: 3px; background: var(--border-strong); }
  .modal {
    max-width: none;
    border-radius: 20px 20px 0 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
    padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
    max-height: 92vh;
    max-height: 92dvh;
  }
  .modal__close { top: 10px; right: 10px; padding: 12px; min-width: 44px; min-height: 44px; }
  .skill-modal__title { font-size: 19px; }
  .skill-modal__stats { gap: 8px; }
  .skill-modal__stat-num { font-size: 18px; }
  .skill-modal__actions { flex-direction: column; align-items: stretch; margin-top: 16px; }
  .skill-modal__actions .btn { width: 100%; min-height: 48px; font-size: 15px; white-space: normal; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ---------- interactive lesson engine ---------- */
.lesson-wrap { max-width: 800px; }
.lesson-progress-meta {
  display: flex;
  justify-content: space-between;
  margin: 0 0 7px;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: .04em;
  text-transform: uppercase;
}
.lesson-card { overflow: hidden; }
.lesson-step-label {
  color: var(--accent-ink);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  margin-bottom: 8px;
}
.lesson-title { font-size: 20px; font-weight: 720; letter-spacing: -.015em; margin-bottom: 10px; }
.lesson-text { font-size: 15px; }
.lesson-independent-task {
  margin-top: 18px;
  padding: 16px 18px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.lesson-independent-task .task-card__text { margin-top: 7px; font-size: 16px; }
/* При фокусе приглушается только окружение внутри формулы. Теория и
   навигация остаются над ним, полностью читаемыми и кликабельными. */
.lesson-card--focus { position: relative; }
.lesson-card--focus .lesson-board { position: relative; border-color: rgba(109,124,255,.38); box-shadow: inset 0 0 0 1px rgba(109,124,255,.08), 0 18px 44px rgba(0,0,0,.18); }
.lesson-board--focus::before {
  content: ""; position: absolute; inset: -1px; border-radius: inherit;
  background: var(--focus-scrim); pointer-events: none; z-index: 0;
}
.lesson-card--focus .lesson-token { position: relative; z-index: 1; }
.lesson-card--focus .lesson-token--on { opacity: 1; animation: lessonFocusIn .48s cubic-bezier(.2,.9,.2,1); }
@keyframes lessonFocusIn {
  from { transform: translateY(4px) scale(.95); box-shadow: 0 0 0 rgba(109,124,255,0); }
  to { transform: none; }
}
.lesson-token { transition: opacity .3s ease, background .3s ease, color .3s ease, box-shadow .3s ease, transform .3s ease; }
.lesson-token--dim { opacity: .65; }
.lesson-answer-grid { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: end; margin-top: 24px; }
.lesson-answer-grid--multiple { grid-template-columns: repeat(3, minmax(0, 1fr)) auto; }
.lesson-answer-field { display: block; min-width: 0; }
.lesson-answer-field > span { display: block; font-family: var(--mono); font-size: 12px; color: var(--muted); margin: 0 0 6px 2px; }
.lesson-answer-field .answer-input { width: 100%; box-sizing: border-box; }
.lesson-check-btn { align-self: end; min-height: 46px; }
.lesson-tools > span { margin-left: auto; color: var(--muted); font-size: 12px; }
.lesson-static-note {
  display: flex; align-items: center; gap: 8px; margin-top: 18px;
  padding: 12px 14px; border-radius: var(--radius-sm); color: var(--muted);
  font-size: 13px; background: var(--surface-2); border: 1px solid var(--border);
}
.lesson-static-note span { color: var(--text-2); }
.lesson-card--focus .lesson-body { position: relative; z-index: 2; }
.lesson-card--focus .lesson-nav { position: relative; z-index: 2; }
.lesson-text { color: var(--text-2); line-height: 1.78; letter-spacing: .002em; }
.lesson-note--success { color: var(--success-ink); border-color: rgba(61,220,151,.24); background: var(--success-soft); }
.lesson-nav { display: flex; justify-content: space-between; gap: 10px; margin-top: 24px; }
.lesson-nav .is-disabled { opacity: .5; cursor: not-allowed; }
.lesson-result-note {
  display: inline-flex; align-items: center; gap: 8px; margin: 0 0 22px; padding: 10px 14px;
  color: var(--warn-ink); background: var(--warn-soft); border: 1px solid rgba(255,196,107,.24); border-radius: 999px; font-size: 13px;
}
.lesson-result-note--ok { color: var(--success-ink); background: var(--success-soft); border-color: rgba(61,220,151,.24); }

/* ============================================================
   Универсальная загрузка (boot + ожидание деталей каталога).
   Только var(--…)-токены — работает в обеих темах.
   ============================================================ */
.ege-loader { max-width: 340px; margin: 64px auto; text-align: center; padding-top: 34px; padding-bottom: 26px; }
.ege-loader__orbit { width: 96px; height: 96px; margin: 0 auto 18px; position: relative; display: grid; place-items: center; }
.ege-loader__orbit::before, .ege-loader__orbit::after { content: ""; position: absolute; border-radius: 50%; border: 3px solid transparent; }
.ege-loader__orbit::before { inset: 0; border-top-color: var(--accent); border-right-color: var(--accent); animation: ege-spin 1s linear infinite; }
.ege-loader__orbit::after { inset: 12px; border-top-color: var(--success); opacity: .75; animation: ege-spin 1.9s linear infinite reverse; }
@keyframes ege-spin { to { transform: rotate(360deg); } }
.ege-loader__core { width: 54px; height: 54px; border-radius: 17px; display: grid; place-items: center; background: var(--surface); border: 1px solid var(--border); box-shadow: 0 8px 28px var(--accent-glow); animation: ege-pulse 1.7s ease-in-out infinite; }
@keyframes ege-pulse { 50% { transform: scale(1.07); } }
.ege-loader__core svg { animation: ege-svgspin 7s linear infinite; filter: drop-shadow(0 0 6px var(--accent-glow)); }
@keyframes ege-svgspin { to { transform: rotate(360deg); } }
.ege-loader__brand { font-size: 15px; font-weight: 700; letter-spacing: -0.01em; text-transform: lowercase; color: var(--text-2); }
.ege-loader__brand span { color: var(--success-ink); }
.ege-loader__title { margin-top: 8px; font-size: 16px; font-weight: 800; }
.ege-loader__sub { margin-top: 5px; font-size: 12.5px; color: var(--muted); font-family: var(--mono); min-height: 19px; }
.ege-loader__bar { margin: 14px auto 0; height: 6px; max-width: 240px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.ege-loader__bar > i { display: block; height: 100%; width: 30%; border-radius: 99px; background: linear-gradient(90deg, var(--success), var(--accent)); animation: ege-slide 1.4s ease-in-out infinite; }
@keyframes ege-slide { 0% { margin-left: -30%; } 100% { margin-left: 100%; } }

@media (max-width: 620px) {
  .lesson-card { padding: 21px 17px; }
  .lesson-answer-grid, .lesson-answer-grid--multiple { grid-template-columns: 1fr; }
  .lesson-check-btn { width: 100%; }
  .lesson-tools > span { display: none; }
  .lesson-title { font-size: 18px; }
}

/* Переключатель предмета (топбар, профиль, пустые состояния). */
.subject-select {
  background: var(--bg-soft, var(--bg));
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 7px 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  max-width: 170px;
}
.subject-select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
