/* ============================================================
   PyQuest v2 — дизайн-система
   Шрифты: Unbounded (заголовки) · Manrope (текст) · JetBrains Mono (код)
   ============================================================ */

:root {
  --font-ui: 'Manrope', -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Unbounded', 'Manrope', sans-serif;
  --font-mono: 'JetBrains Mono', 'Cascadia Code', Consolas, monospace;

  /* Светлая тема */
  --bg: #eef1fb;
  --bg-card: #ffffff;
  --bg-card-2: #f5f7ff;
  --bg-hover: #e9edfb;
  --bg-code: #eef1fa;
  --bg-editor: #171b2e;
  --text: #171b30;
  --text-2: #545b78;
  --text-3: #8d94b3;
  --border: #dfe4f5;
  --accent: #5b5bf0;
  --accent-2: #9a4df5;
  --accent-soft: rgba(91, 91, 240, 0.1);
  --grad: linear-gradient(120deg, #5b5bf0, #9a4df5);
  --py-yellow: #f5b301;
  --py-yellow-soft: rgba(245, 179, 1, 0.14);
  --green: #0eb98a;
  --green-soft: rgba(14, 185, 138, 0.11);
  --red: #ee4966;
  --red-soft: rgba(238, 73, 102, 0.1);
  --blue: #2f80ed;
  --shadow: 0 2px 4px rgba(23, 27, 48, 0.05), 0 10px 30px rgba(23, 27, 48, 0.07);
  --shadow-lg: 0 14px 50px rgba(23, 27, 48, 0.16);
  --glow: 0 6px 24px rgba(91, 91, 240, 0.35);
  --editor-text: #dfe4f6;
  --decor-opacity: 0.5;
}

html[data-theme="dark"] {
  --bg: #0b0e1c;
  --bg-card: #131829;
  --bg-card-2: #1a2036;
  --bg-hover: #202844;
  --bg-code: #0e1322;
  --bg-editor: #0e1120;
  --text: #e9ecf8;
  --text-2: #9aa3c4;
  --text-3: #5d6688;
  --border: #232b49;
  --accent: #8a8afc;
  --accent-2: #b57bff;
  --accent-soft: rgba(138, 138, 252, 0.13);
  --grad: linear-gradient(120deg, #7a6cff, #b45cff);
  --py-yellow: #ffd343;
  --py-yellow-soft: rgba(255, 211, 67, 0.12);
  --green: #34e2a5;
  --green-soft: rgba(52, 226, 165, 0.11);
  --red: #ff6b84;
  --red-soft: rgba(255, 107, 132, 0.11);
  --blue: #62a6ff;
  --shadow: 0 2px 4px rgba(0, 0, 0, 0.35), 0 12px 32px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 18px 60px rgba(0, 0, 0, 0.55);
  --glow: 0 6px 28px rgba(122, 108, 255, 0.45);
  --editor-text: #dfe4f6;
  --decor-opacity: 1;
}

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

body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  transition: background 0.3s, color 0.3s;
  min-height: 100vh;
}

/* Декоративные «свечения» фона */
.bg-decor {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: var(--decor-opacity);
  background:
    radial-gradient(600px 420px at 12% -5%, rgba(122, 108, 255, 0.16), transparent 65%),
    radial-gradient(520px 380px at 100% 12%, rgba(180, 92, 255, 0.1), transparent 60%),
    radial-gradient(700px 480px at 55% 110%, rgba(52, 226, 165, 0.07), transparent 60%);
}

/* ============ Каркас ============ */
.app { display: flex; min-height: 100vh; position: relative; z-index: 1; }

.sidebar {
  width: 256px;
  flex-shrink: 0;
  background: color-mix(in srgb, var(--bg-card) 82%, transparent);
  backdrop-filter: blur(14px);
  border-right: 1px solid var(--border);
  padding: 22px 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 20;
}

.logo {
  display: flex;
  align-items: center;
  gap: 11px;
  cursor: pointer;
  padding: 4px 8px;
  user-select: none;
}
.logo-img { width: 38px; height: 38px; border-radius: 11px; box-shadow: var(--glow); }
.logo-text {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.5px;
}
.logo-accent {
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.nav { display: flex; flex-direction: column; gap: 3px; flex: 1; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 13px;
  color: var(--text-2);
  text-decoration: none;
  font-weight: 700;
  font-size: 14.5px;
  transition: background 0.15s, color 0.15s, transform 0.15s;
  position: relative;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); }
.nav-item.active::before {
  content: '';
  position: absolute;
  left: -14px;
  top: 20%;
  height: 60%;
  width: 4px;
  border-radius: 4px;
  background: var(--grad);
}
.nav-icon { font-size: 17px; width: 24px; text-align: center; }

.sidebar-footer { display: flex; flex-direction: column; gap: 9px; }

.streak-widget {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  background: var(--py-yellow-soft);
  border: 1px solid color-mix(in srgb, var(--py-yellow) 30%, transparent);
  border-radius: 14px;
}
.streak-fire { font-size: 24px; }
.streak-count { font-size: 19px; font-weight: 800; line-height: 1.1; }
.streak-label { font-size: 11.5px; color: var(--text-2); }

.profile-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 13px;
  background: var(--bg-card-2);
  border: 1px solid var(--border);
  border-radius: 13px;
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
  text-align: left;
}
.profile-chip:hover { background: var(--bg-hover); }
.profile-emoji { font-size: 19px; }
.profile-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sync-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--text-3);
  flex-shrink: 0;
  transition: background 0.3s;
}
.sync-dot.synced { background: var(--green); box-shadow: 0 0 8px var(--green); }
.sync-dot.syncing { background: var(--py-yellow); animation: pulse 1s infinite; }
.sync-dot.error { background: var(--red); }
@keyframes pulse { 50% { opacity: 0.4; } }

.theme-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 13px;
  background: var(--bg-card-2);
  border: 1px solid var(--border);
  border-radius: 13px;
  color: var(--text-2);
  font-family: var(--font-ui);
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
}
.theme-toggle:hover { background: var(--bg-hover); }
html[data-theme="dark"] .theme-icon-dark { display: none; }
html[data-theme="light"] .theme-icon-light { display: none; }

.main {
  flex: 1;
  padding: 30px 44px 90px;
  max-width: 1080px;
  margin: 0 auto;
  min-width: 0;
  animation: view-in 0.35s cubic-bezier(0.25, 0.9, 0.35, 1);
}
@keyframes view-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

/* ============ Общие элементы ============ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 24px;
  box-shadow: var(--shadow);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 22px;
  border-radius: 13px;
  border: none;
  font-family: var(--font-ui);
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.12s, opacity 0.15s, background 0.15s, box-shadow 0.15s;
  text-decoration: none;
  user-select: none;
}
.btn:active { transform: scale(0.96); }
.btn-primary { background: var(--grad); color: #fff; box-shadow: var(--glow); }
.btn-primary:hover { opacity: 0.92; transform: translateY(-1px); }
.btn-secondary { background: var(--bg-card); color: var(--text); border: 1.5px solid var(--border); }
.btn-secondary:hover { background: var(--bg-hover); border-color: var(--accent); }
.btn-green { background: var(--green); color: #06281c; }
.btn-green:hover { opacity: 0.9; transform: translateY(-1px); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text); }
.btn-sm { padding: 8px 14px; font-size: 13px; border-radius: 11px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.page-title {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
  margin-bottom: 8px;
  letter-spacing: -0.5px;
}
.page-sub { color: var(--text-2); margin-bottom: 26px; font-size: 15px; max-width: 640px; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 11px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.2px;
}
.badge-accent { background: var(--accent-soft); color: var(--accent); }
.badge-green { background: var(--green-soft); color: var(--green); }
.badge-yellow { background: var(--py-yellow-soft); color: var(--py-yellow); }
.badge-muted { background: var(--bg-hover); color: var(--text-2); }

.progress-bar { height: 8px; background: var(--bg-hover); border-radius: 99px; overflow: hidden; }
.progress-fill {
  height: 100%;
  background: var(--grad);
  border-radius: 99px;
  transition: width 0.6s cubic-bezier(0.3, 0.9, 0.4, 1);
}
.progress-fill.green { background: var(--green); }

.section-title {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 600;
  margin: 30px 0 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  letter-spacing: -0.2px;
}

/* ============ Дашборд ============ */
.hero {
  position: relative;
  background: var(--grad);
  border-radius: 24px;
  padding: 30px 34px;
  color: #fff;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  margin-bottom: 22px;
  overflow: hidden;
  box-shadow: 0 16px 50px rgba(110, 90, 250, 0.35);
}
.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(320px 200px at 85% 20%, rgba(255, 255, 255, 0.16), transparent 60%),
    radial-gradient(260px 200px at 10% 110%, rgba(0, 0, 0, 0.18), transparent 60%);
}
.hero > * { position: relative; }
.hero h1 {
  font-family: var(--font-display);
  font-size: 21px;
  font-weight: 700;
  margin-bottom: 8px;
  letter-spacing: -0.3px;
}
.hero p { opacity: 0.93; font-size: 14.5px; max-width: 470px; margin-bottom: 16px; }
.hero .btn { background: rgba(255, 255, 255, 0.96); color: #4c3bd8; box-shadow: 0 6px 18px rgba(0,0,0,0.2); }
.hero .btn:hover { background: #fff; }
.hero-mascot { flex-shrink: 0; width: 150px; filter: drop-shadow(0 10px 20px rgba(0,0,0,0.25)); }

.mascot-wrap { display: flex; flex-direction: column; align-items: center; flex-shrink: 0; }
.mascot-bubble {
  position: relative;
  background: rgba(255, 255, 255, 0.97);
  color: #33296b;
  padding: 11px 15px;
  border-radius: 15px;
  border-bottom-left-radius: 15px;
  font-size: 12.5px;
  font-weight: 700;
  line-height: 1.45;
  max-width: 240px;
  margin-bottom: 12px;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.2);
  animation: bubble-in 0.5s cubic-bezier(0.3, 1.3, 0.5, 1);
  text-align: center;
}
.mascot-bubble::after {
  content: '';
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%) rotate(45deg);
  width: 13px;
  height: 13px;
  background: rgba(255, 255, 255, 0.97);
  border-radius: 3px;
}
@keyframes bubble-in {
  from { transform: translateY(8px) scale(0.9); opacity: 0; }
  to { transform: none; opacity: 1; }
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 13px;
  box-shadow: var(--shadow);
  transition: transform 0.15s;
}
.stat-card:hover { transform: translateY(-2px); }
.stat-icon {
  font-size: 23px;
  width: 46px; height: 46px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 14px;
  background: var(--accent-soft);
  flex-shrink: 0;
}
.stat-value { font-size: 20px; font-weight: 800; line-height: 1.2; }
.stat-label { font-size: 12px; color: var(--text-2); font-weight: 600; }

/* Кольцо дневной цели + уровня */
.rings-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 22px;
}
.ring-card { display: flex; align-items: center; gap: 18px; }
.ring-wrap { position: relative; width: 84px; height: 84px; flex-shrink: 0; }
.ring-wrap svg { transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: var(--bg-hover); stroke-width: 9; }
.ring-val { fill: none; stroke: url(#ringGrad); stroke-width: 9; stroke-linecap: round; transition: stroke-dashoffset 0.8s cubic-bezier(0.3, 0.9, 0.4, 1); }
.ring-center {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
}
.ring-info { min-width: 0; }
.ring-title { font-weight: 800; font-size: 15px; margin-bottom: 2px; }
.ring-sub { font-size: 12.5px; color: var(--text-2); }

/* Тепловая карта активности */
.heatmap { display: flex; gap: 4px; margin-top: 6px; }
.heat-col { display: flex; flex-direction: column; gap: 4px; }
.heat-cell {
  width: 13px; height: 13px;
  border-radius: 4px;
  background: var(--bg-hover);
}
.heat-cell.h1 { background: color-mix(in srgb, var(--accent) 30%, var(--bg-hover)); }
.heat-cell.h2 { background: color-mix(in srgb, var(--accent) 60%, var(--bg-hover)); }
.heat-cell.h3 { background: var(--accent); box-shadow: 0 0 6px var(--accent-soft); }
.heat-cell.today { outline: 2px solid var(--py-yellow); outline-offset: 1px; }

/* ============ Модули курса ============ */
.modules-grid { display: flex; flex-direction: column; gap: 13px; }

.module-card {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 18px 22px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  cursor: pointer;
  transition: transform 0.16s, box-shadow 0.16s, border-color 0.16s;
  box-shadow: var(--shadow);
}
.module-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  border-color: var(--accent);
}
.module-icon {
  font-size: 26px;
  width: 56px; height: 56px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 17px;
  background: var(--accent-soft);
  flex-shrink: 0;
}
.module-card.done-mod .module-icon { background: var(--green-soft); }
.module-info { flex: 1; min-width: 0; }
.module-title { font-size: 16px; font-weight: 800; margin-bottom: 3px; display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.module-desc { font-size: 13px; color: var(--text-2); margin-bottom: 10px; }
.module-progress-row { display: flex; align-items: center; gap: 12px; }
.module-progress-row .progress-bar { flex: 1; }
.module-progress-text { font-size: 12px; color: var(--text-3); font-weight: 700; white-space: nowrap; }
.module-check { font-size: 22px; }

/* Список уроков */
.lessons-list { display: flex; flex-direction: column; gap: 9px; }
.lesson-row {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 15px 19px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.12s;
}
.lesson-row:hover { border-color: var(--accent); transform: translateX(4px); }
.lesson-num {
  width: 37px; height: 37px;
  border-radius: 12px;
  background: var(--bg-hover);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800;
  font-size: 13.5px;
  color: var(--text-2);
  flex-shrink: 0;
}
.lesson-row.done .lesson-num { background: var(--green-soft); color: var(--green); }
.lesson-row-title { flex: 1; font-weight: 700; font-size: 14.5px; }
.lesson-row-marks { display: flex; gap: 7px; font-size: 14px; }
.mark { opacity: 0.22; }
.mark.on { opacity: 1; }

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-2);
  text-decoration: none;
  font-weight: 700;
  font-size: 13.5px;
  margin-bottom: 16px;
}
.back-link:hover { color: var(--accent); }

/* ============ Урок ============ */
.lesson-header { margin-bottom: 18px; }
.lesson-header h1 {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.4px;
  margin: 6px 0 8px;
}

.tabs {
  display: flex;
  gap: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 6px;
  border-radius: 15px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
  position: sticky;
  top: 10px;
  z-index: 5;
}
.tab {
  flex: 1;
  padding: 11px;
  text-align: center;
  border-radius: 11px;
  font-weight: 800;
  font-size: 14px;
  cursor: pointer;
  color: var(--text-2);
  transition: background 0.15s, color 0.15s;
  user-select: none;
  display: flex; align-items: center; justify-content: center; gap: 7px;
}
.tab:hover { background: var(--bg-hover); }
.tab.active { background: var(--accent-soft); color: var(--accent); }
.tab .tab-done { color: var(--green); }

/* Теория */
.theory-content { font-size: 15.5px; }
.theory-content h2 {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  margin: 28px 0 12px;
  letter-spacing: -0.2px;
}
.theory-content h2:first-child { margin-top: 0; }
.theory-content h3 { font-size: 16px; font-weight: 800; margin: 22px 0 10px; }
.theory-content p { margin-bottom: 14px; }
.theory-content ul, .theory-content ol { margin: 0 0 14px 22px; }
.theory-content li { margin-bottom: 7px; }
.theory-content code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  background: var(--bg-code);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: 6px;
  color: var(--accent);
  font-weight: 500;
}
.theory-content pre {
  background: var(--bg-editor);
  border-radius: 15px;
  padding: 17px 19px;
  overflow-x: auto;
  margin: 14px 0 18px;
  border: 1px solid var(--border);
}
.theory-content pre code {
  background: none; border: none; padding: 0;
  color: var(--editor-text);
  font-size: 13.5px;
  line-height: 1.65;
  font-weight: 400;
}

.term { border-bottom: 2px dotted var(--accent); cursor: help; font-weight: 700; color: var(--accent); }

.callout {
  display: flex;
  gap: 14px;
  padding: 15px 18px;
  border-radius: 15px;
  margin: 16px 0;
  font-size: 14px;
}
.callout-icon { font-size: 20px; flex-shrink: 0; }
.callout.practice { background: var(--green-soft); border: 1px solid color-mix(in srgb, var(--green) 28%, transparent); }
.callout.warn { background: var(--py-yellow-soft); border: 1px solid color-mix(in srgb, var(--py-yellow) 30%, transparent); }
.callout.info { background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 28%, transparent); }
.callout b:first-child { display: block; margin-bottom: 3px; }

.lesson-nav { display: flex; justify-content: space-between; gap: 12px; margin-top: 26px; flex-wrap: wrap; }

/* ============ Редактор кода ============ */
.practice-task { margin-bottom: 16px; }
.practice-task-title { font-weight: 800; font-size: 16px; margin-bottom: 8px; display: flex; align-items: center; gap: 10px; }

.editor-wrap {
  background: var(--bg-editor);
  border-radius: 17px;
  overflow: hidden;
  border: 1px solid var(--border);
  margin-bottom: 13px;
  box-shadow: var(--shadow);
}
.editor-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}
.editor-dots { display: flex; gap: 6px; margin-right: 8px; }
.editor-dot { width: 11px; height: 11px; border-radius: 50%; }
.editor-dot:nth-child(1) { background: #ff5f57; }
.editor-dot:nth-child(2) { background: #febc2e; }
.editor-dot:nth-child(3) { background: #28c840; }
.editor-filename { font-family: var(--font-mono); font-size: 12px; color: #8b93b5; flex: 1; }
.editor-hotkey { font-size: 11px; color: #5b6382; font-family: var(--font-mono); }

.editor-body { display: flex; position: relative; }
.editor-gutter {
  padding: 15px 10px 15px 16px;
  font-family: var(--font-mono);
  font-size: 13.5px;
  line-height: 1.65;
  color: #454e70;
  text-align: right;
  user-select: none;
  white-space: pre;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  min-width: 46px;
}
.editor-stack { position: relative; flex: 1; overflow: hidden; }
.editor-highlight {
  position: absolute;
  inset: 0;
  margin: 0;
  padding: 15px 18px;
  font-family: var(--font-mono);
  font-size: 13.5px;
  line-height: 1.65;
  white-space: pre;
  overflow: hidden;
  pointer-events: none;
  color: var(--editor-text);
}
.code-editor {
  position: relative;
  width: 100%;
  min-height: 200px;
  display: block;
  background: transparent;
  border: none;
  outline: none;
  resize: none;
  padding: 15px 18px;
  font-family: var(--font-mono);
  font-size: 13.5px;
  line-height: 1.65;
  color: transparent;
  caret-color: #a8b3ff;
  white-space: pre;
  overflow: auto;
  tab-size: 4;
  z-index: 1;
}
.code-editor::placeholder { color: #565e7e; }
.code-editor::selection { background: rgba(122, 108, 255, 0.35); color: transparent; }

/* Токены подсветки */
.tok-kw   { color: #c792ea; font-weight: 500; }
.tok-str  { color: #a8e08a; }
.tok-num  { color: #f5a97f; }
.tok-com  { color: #5c6785; font-style: italic; }
.tok-fn   { color: #82aaff; }
.tok-dec  { color: #ffd343; }
.tok-self { color: #ff8fa3; }
.tok-op   { color: #89ddff; }

.run-row { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }

.console-wrap {
  background: var(--bg-editor);
  border-radius: 15px;
  border: 1px solid var(--border);
  overflow: hidden;
}
.console-title {
  padding: 9px 16px;
  font-size: 11px;
  font-weight: 800;
  color: #8b93b5;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  text-transform: uppercase;
  letter-spacing: 1px;
}
.console-out {
  padding: 14px 18px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  color: var(--editor-text);
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 56px;
  max-height: 340px;
  overflow-y: auto;
}
.console-out .err { color: #ff8a8a; }
.console-out .muted { color: #667090; }

.check-result {
  margin-top: 15px;
  padding: 15px 20px;
  border-radius: 15px;
  font-weight: 700;
  font-size: 14.5px;
  animation: pop-in 0.3s cubic-bezier(0.3, 1.4, 0.6, 1);
}
.check-result.ok { background: var(--green-soft); color: var(--green); border: 1px solid color-mix(in srgb, var(--green) 32%, transparent); }
.check-result.fail { background: var(--red-soft); color: var(--red); border: 1px solid color-mix(in srgb, var(--red) 32%, transparent); }
.check-result pre { font-family: var(--font-mono); font-size: 12.5px; margin-top: 8px; white-space: pre-wrap; font-weight: 400; }

.hint-box {
  margin-top: 13px;
  padding: 14px 18px;
  background: var(--py-yellow-soft);
  border: 1px solid color-mix(in srgb, var(--py-yellow) 32%, transparent);
  border-radius: 13px;
  font-size: 14px;
  animation: pop-in 0.25s;
}
.solution-box { margin-top: 13px; animation: pop-in 0.25s; }
.solution-box pre {
  background: var(--bg-editor);
  border-radius: 13px;
  padding: 16px 18px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--editor-text);
  line-height: 1.6;
}

/* ============ Квиз ============ */
.quiz-progress { display: flex; align-items: center; gap: 14px; margin-bottom: 22px; }
.quiz-progress .progress-bar { flex: 1; height: 12px; }
.quiz-counter { font-weight: 800; font-size: 13.5px; color: var(--text-2); white-space: nowrap; }

.quiz-question { font-size: 18px; font-weight: 800; margin-bottom: 8px; line-height: 1.45; }
.quiz-question code {
  font-family: var(--font-mono);
  background: var(--bg-code);
  border: 1px solid var(--border);
  padding: 2px 7px;
  border-radius: 7px;
  font-size: 0.88em;
  color: var(--accent);
}
.quiz-code {
  background: var(--bg-editor);
  border-radius: 13px;
  padding: 15px 18px;
  font-family: var(--font-mono);
  font-size: 13.5px;
  color: var(--editor-text);
  margin: 12px 0 18px;
  white-space: pre;
  overflow-x: auto;
  line-height: 1.6;
}

.quiz-options { display: flex; flex-direction: column; gap: 10px; margin: 18px 0; }
.quiz-option {
  padding: 15px 20px;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: 15px;
  cursor: pointer;
  font-weight: 700;
  font-size: 14.5px;
  transition: border-color 0.12s, background 0.12s, transform 0.12s;
  font-family: var(--font-ui);
  text-align: left;
  color: var(--text);
}
.quiz-option:hover { border-color: var(--accent); transform: translateX(4px); }
.quiz-option.correct { border-color: var(--green); background: var(--green-soft); animation: pop-in 0.25s; }
.quiz-option.wrong { border-color: var(--red); background: var(--red-soft); animation: shake 0.35s; }
@keyframes shake {
  20% { transform: translateX(-5px); } 40% { transform: translateX(5px); }
  60% { transform: translateX(-3px); } 80% { transform: translateX(3px); }
}
.quiz-option code { font-family: var(--font-mono); font-size: 0.88em; }

.quiz-input {
  width: 100%;
  padding: 14px 18px;
  border: 2px solid var(--border);
  border-radius: 15px;
  background: var(--bg-card);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 15px;
  outline: none;
  margin: 14px 0;
}
.quiz-input:focus { border-color: var(--accent); }

.quiz-explain {
  padding: 15px 20px;
  border-radius: 15px;
  margin: 16px 0;
  font-size: 14px;
  animation: pop-in 0.3s;
}
.quiz-explain.ok { background: var(--green-soft); border: 1px solid color-mix(in srgb, var(--green) 32%, transparent); }
.quiz-explain.fail { background: var(--red-soft); border: 1px solid color-mix(in srgb, var(--red) 32%, transparent); }
.quiz-explain b { display: block; margin-bottom: 4px; font-size: 15px; }

.quiz-result { text-align: center; padding: 30px 20px; }
.quiz-result-emoji { font-size: 58px; margin-bottom: 14px; }
.quiz-result h2 { font-family: var(--font-display); font-size: 21px; font-weight: 700; margin-bottom: 8px; }
.quiz-result p { color: var(--text-2); margin-bottom: 22px; }

/* ============ Тренажёр ============ */
.trainer-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 13px; margin-bottom: 20px; }

.boxes-row { display: flex; gap: 10px; margin: 14px 0 4px; flex-wrap: wrap; }
.box-item {
  flex: 1;
  min-width: 90px;
  text-align: center;
  padding: 13px 8px;
  background: var(--bg-card-2);
  border: 1px solid var(--border);
  border-radius: 14px;
}
.box-item .box-n { font-size: 20px; font-weight: 800; }
.box-item .box-t { font-size: 11px; color: var(--text-3); font-weight: 700; }
.box-item.hot { border-color: var(--accent); background: var(--accent-soft); }

.flashcard {
  perspective: 1200px;
  margin: 0 auto 18px;
  max-width: 560px;
  min-height: 260px;
}
.flashcard-inner {
  position: relative;
  width: 100%;
  min-height: 260px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 30px 30px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: var(--shadow-lg);
  text-align: center;
  animation: pop-in 0.3s;
}
.flashcard-cat { font-size: 11.5px; font-weight: 800; color: var(--accent); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 12px; }
.flashcard-q { font-size: 17.5px; font-weight: 800; line-height: 1.45; }
.flashcard-code {
  background: var(--bg-editor);
  border-radius: 12px;
  padding: 13px 16px;
  font-family: var(--font-mono);
  font-size: 13.5px;
  color: var(--editor-text);
  margin: 14px auto 0;
  white-space: pre;
  overflow-x: auto;
  text-align: left;
  max-width: 100%;
}
.flashcard-back {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px dashed var(--border);
  font-size: 14.5px;
  color: var(--text-2);
  animation: pop-in 0.25s;
}
.flashcard-back code { font-family: var(--font-mono); background: var(--bg-code); border: 1px solid var(--border); padding: 1px 6px; border-radius: 6px; color: var(--accent); }
.flashcard-ex { margin-top: 10px; font-size: 13px; color: var(--text-3); font-family: var(--font-mono); }

.trainer-controls { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.trainer-input {
  width: 100%;
  max-width: 380px;
  margin: 0 auto;
  display: block;
  padding: 13px 18px;
  border: 2px solid var(--border);
  border-radius: 14px;
  background: var(--bg-card-2);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 15px;
  outline: none;
  text-align: center;
}
.trainer-input:focus { border-color: var(--accent); }
.trainer-input.ok { border-color: var(--green); }
.trainer-input.bad { border-color: var(--red); }

/* ============ Роадмап ============ */
.track-card { margin-bottom: 16px; position: relative; overflow: hidden; }
.track-head { display: flex; align-items: center; gap: 16px; margin-bottom: 12px; }
.track-icon { font-size: 32px; }
.track-title { font-family: var(--font-display); font-size: 16.5px; font-weight: 600; }
.track-sub { font-size: 13px; color: var(--text-2); }
.track-skills { display: flex; flex-wrap: wrap; gap: 8px; margin: 13px 0; }
.track-progress-row { display: flex; align-items: center; gap: 14px; margin-top: 12px; }
.track-progress-row .progress-bar { flex: 1; }
.track-pct { font-weight: 800; font-size: 15px; white-space: nowrap; }

/* ============ Глоссарий ============ */
.glossary-search {
  width: 100%;
  padding: 15px 20px;
  border: 2px solid var(--border);
  border-radius: 16px;
  background: var(--bg-card);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 15px;
  outline: none;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}
.glossary-search:focus { border-color: var(--accent); }
.glossary-list { display: flex; flex-direction: column; gap: 11px; }
.glossary-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 15px;
  padding: 17px 21px;
  box-shadow: var(--shadow);
}
.glossary-term { font-weight: 800; font-size: 15.5px; color: var(--accent); margin-bottom: 5px; }
.glossary-def { font-size: 14px; color: var(--text-2); }
.glossary-def code { font-family: var(--font-mono); font-size: 0.87em; background: var(--bg-code); padding: 1px 5px; border-radius: 5px; border: 1px solid var(--border); }

/* ============ Награды ============ */
.ach-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 15px; }
.ach-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 22px;
  text-align: center;
  box-shadow: var(--shadow);
  transition: transform 0.15s;
}
.ach-card:hover { transform: translateY(-3px); }
.ach-card.locked { opacity: 0.4; filter: grayscale(0.9); }
.ach-emoji { font-size: 40px; margin-bottom: 10px; }
.ach-name { font-weight: 800; font-size: 15px; margin-bottom: 4px; }
.ach-desc { font-size: 12.5px; color: var(--text-2); }

/* ============ Оверлеи ============ */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(8, 10, 22, 0.62);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  animation: fade-in 0.2s;
}
@keyframes fade-in { from { opacity: 0; } }
.overlay-card {
  width: 100%;
  max-width: 460px;
  max-height: 88vh;
  overflow-y: auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 28px;
  box-shadow: var(--shadow-lg);
  animation: pop-in 0.28s cubic-bezier(0.3, 1.3, 0.5, 1);
}
.overlay-title { font-family: var(--font-display); font-size: 19px; font-weight: 700; margin-bottom: 6px; text-align: center; }
.overlay-sub { font-size: 13.5px; color: var(--text-2); text-align: center; margin-bottom: 20px; }

.profiles-grid { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.profile-row {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 13px 16px;
  background: var(--bg-card-2);
  border: 2px solid var(--border);
  border-radius: 15px;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.12s;
  font-weight: 700;
  width: 100%;
  font-family: var(--font-ui);
  font-size: 15px;
  color: var(--text);
  text-align: left;
}
.profile-row:hover { border-color: var(--accent); transform: translateX(3px); }
.profile-row.active { border-color: var(--accent); background: var(--accent-soft); }
.profile-row .pr-emoji { font-size: 24px; }
.profile-row .pr-info { flex: 1; min-width: 0; }
.profile-row .pr-sub { font-size: 11.5px; color: var(--text-3); font-weight: 600; }

.form-field { margin-bottom: 13px; }
.form-label { display: block; font-size: 12.5px; font-weight: 800; color: var(--text-2); margin-bottom: 6px; }
.form-input {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid var(--border);
  border-radius: 13px;
  background: var(--bg-card-2);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 15px;
  outline: none;
}
.form-input:focus { border-color: var(--accent); }
.form-error { color: var(--red); font-size: 13px; font-weight: 700; margin: 8px 0; min-height: 18px; }

.emoji-picker { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.emoji-opt {
  font-size: 22px;
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-card-2);
  border: 2px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: border-color 0.12s, transform 0.12s;
}
.emoji-opt:hover { transform: scale(1.1); }
.emoji-opt.sel { border-color: var(--accent); background: var(--accent-soft); }

.overlay-actions { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.overlay-actions .btn { flex: 1; }
.overlay-link {
  display: block;
  text-align: center;
  margin-top: 14px;
  color: var(--accent);
  font-weight: 700;
  font-size: 13.5px;
  cursor: pointer;
  background: none; border: none;
  font-family: var(--font-ui);
  width: 100%;
}
.overlay-link:hover { text-decoration: underline; }

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 14px;
}
.setting-row:last-child { border-bottom: none; }
.goal-opts { display: flex; gap: 7px; }
.goal-opt {
  padding: 7px 13px;
  border-radius: 10px;
  border: 2px solid var(--border);
  background: var(--bg-card-2);
  color: var(--text);
  font-family: var(--font-ui);
  font-weight: 800;
  font-size: 13px;
  cursor: pointer;
}
.goal-opt.sel { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }

/* ============ Попап термина ============ */
.term-popover {
  position: fixed;
  z-index: 100;
  max-width: 340px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 15px;
  padding: 16px 18px;
  box-shadow: var(--shadow-lg);
  animation: pop-in 0.18s;
}
.term-popover-title { font-weight: 800; color: var(--accent); margin-bottom: 5px; font-size: 15px; }
.term-popover-body { font-size: 13.5px; color: var(--text-2); }
.term-popover-body code { font-family: var(--font-mono); font-size: 0.88em; background: var(--bg-code); padding: 1px 5px; border-radius: 5px; }

/* ============ Тосты и конфетти ============ */
.toasts {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 200;
}
.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 15px;
  padding: 13px 20px;
  box-shadow: var(--shadow-lg);
  font-weight: 800;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: toast-in 0.35s cubic-bezier(0.3, 1.3, 0.6, 1);
}
.toast.out { animation: toast-out 0.3s forwards; }
.toast-xp { color: var(--accent); }

#confettiCanvas {
  position: fixed;
  inset: 0;
  z-index: 300;
  pointer-events: none;
}

@keyframes toast-in { from { transform: translateX(120%); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes toast-out { to { transform: translateX(120%); opacity: 0; } }
@keyframes pop-in { from { transform: scale(0.95); opacity: 0; } to { transform: none; opacity: 1; } }

/* ============ Загрузка Python ============ */
.py-loading { display: flex; align-items: center; gap: 10px; color: var(--text-2); font-size: 13.5px; font-weight: 700; padding: 10px 0; }
.spinner {
  width: 18px; height: 18px;
  border: 3px solid var(--accent-soft);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============ Мобильная версия ============ */
@media (max-width: 900px) {
  .app { flex-direction: column; }

  .sidebar {
    width: 100%;
    height: auto;
    position: sticky;
    top: 0;
    flex-direction: row;
    align-items: center;
    padding: 10px 14px;
    gap: 10px;
  }
  .logo-text { display: none; }

  /* Навигация — нижняя панель, как в мобильных приложениях */
  .nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 50;
    flex-direction: row;
    background: color-mix(in srgb, var(--bg-card) 92%, transparent);
    backdrop-filter: blur(16px);
    border-top: 1px solid var(--border);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    overflow-x: auto;
    justify-content: space-around;
  }
  .nav-item {
    flex-direction: column;
    gap: 2px;
    padding: 6px 8px;
    font-size: 10px;
    border-radius: 10px;
    flex-shrink: 0;
  }
  .nav-item.active::before { display: none; }
  .nav-icon { font-size: 20px; width: auto; }

  .sidebar-footer { flex-direction: row; align-items: center; margin-left: auto; }
  .streak-widget { padding: 7px 11px; gap: 8px; }
  .streak-label { display: none; }
  .streak-count { font-size: 16px; }
  .profile-name, .theme-toggle-text { display: none; }
  .profile-chip, .theme-toggle { padding: 9px 11px; }

  .main { padding: 18px 14px 110px; }
  .hero { padding: 22px; flex-direction: column; text-align: center; }
  .hero p { max-width: none; }
  .hero-mascot { width: 110px; }
  .rings-row { grid-template-columns: 1fr; }
  .tabs { top: 66px; }
  .lesson-nav .btn { flex: 1; }
  .heat-cell { width: 11px; height: 11px; }
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

/* ============ Аватары-змейки ============ */
.avatar-snake { display: block; border-radius: 50%; flex-shrink: 0; }

.emoji-picker { gap: 10px; }
.emoji-opt {
  width: 48px;
  height: 48px;
  padding: 5px;
  border-radius: 14px;
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}
.emoji-opt.sel {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.emoji-opt:hover { transform: scale(1.08); }

.profile-emoji { display: flex; align-items: center; }
.pr-emoji { display: flex; align-items: center; }
