/* --- ЦВЕТА И КОНТРАСТ (WCAG AA) --- */
:root {
  --bg: #F8FAFC;
  --fg: #0F172A;
  --fg-muted: #475569;
  --accent: #2563EB;
  --accent-hover: #1D4ED8;
  --ok: #15803D;
  --err: #B91C1C;
  --warn: #854D0E;
  --card: #FFFFFF;
  --border: #E2E8F0;
  --radius: 16px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
}

/* Зоны по возрасту */
body.zone-A { --bg: #F0F9FF; --accent: #0EA5E9; --accent-hover: #0284C7; }
body.zone-B { --bg: #F5F3FF; --accent: #8B5CF6; --accent-hover: #7C3AED; }
body.zone-C { --accent: #3B82F6; --accent-hover: #60A5FA; }
body.zone-D { --bg: #F8FAFC; --accent: #0F172A; --accent-hover: #1E293B; }

body.theme-dark {
  --bg: #0F172A; --fg: #F1F5F9; --fg-muted: #CBD5E1; --card: #1E293B; --border: #334155;
  --accent: #3B82F6; --accent-hover: #60A5FA; --ok: #4ADE80; --err: #F87171; --warn: #FBBF24;
}

@media (prefers-color-scheme: dark) {
  body.theme-auto {
    --bg: #0F172A; --fg: #F1F5F9; --fg-muted: #CBD5E1; --card: #1E293B; --border: #334155;
    --accent: #3B82F6; --accent-hover: #60A5FA; --ok: #4ADE80; --err: #F87171; --warn: #FBBF24;
  }
}

@media (prefers-contrast: more) {
  :root {
    --fg-muted: #1E293B;
    --border: #64748B;
  }
  body.theme-dark,
  body.theme-auto {
    --fg-muted: #F8FAFC;
    --border: #94A3B8;
  }
  a, .btn, .topic-action { text-decoration: underline; }
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--fg); line-height: 1.5; min-height: 100vh;
  display: flex; flex-direction: column; -webkit-font-smoothing: antialiased;
  transition: background-color 0.3s, color 0.3s;
}
h1, h2, h3, .logo, .stat-val, .subject-title { font-family: 'Unbounded', 'Inter', sans-serif; }
a { color: var(--accent); text-decoration: none; transition: color 0.2s; }
a:hover { color: var(--accent-hover); }

.skip-link {  position: absolute; top: -100px; left: 16px; background: var(--accent); color: #fff;
  padding: 12px 24px; border-radius: 8px; z-index: 10000; font-weight: 600; transition: top 0.2s;
}
.skip-link:focus { top: 16px; }

.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 32px; background: var(--card); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.logo { display: inline-flex; align-items: center; gap: 8px; flex-shrink: 0; }
.logo-img {
  display: block;
  width: 44px;
  height: 26px;
  object-fit: contain;
}
.logo-text {
  font-family: 'Unbounded', 'Inter', sans-serif;
  font-weight: 800;
  font-size: 24px;
  letter-spacing: -0.6px;
  color: var(--fg);
  line-height: 1;
}
.desktop-nav { display: flex; gap: 24px; align-items: center; font-weight: 500; font-size: 15px; }
.username { color: var(--fg-muted); font-size: 14px; text-decoration: underline dotted; }
.username:hover { color: var(--accent); }
.footer { padding: 32px; text-align: center; color: var(--fg-muted); font-size: 14px; border-top: 1px solid var(--border); margin-top: auto; padding-bottom: 80px; }

main { flex: 1; max-width: 1100px; margin: 0 auto; padding: 40px 24px; width: 100%; outline: none; }

.hero {
  text-align: center; padding: 80px 24px;
  background: linear-gradient(135deg, rgba(37,99,235,0.08) 0%, rgba(255,255,255,0) 100%);
  border-radius: 32px; margin-bottom: 60px;
}
body.theme-dark .hero { background: linear-gradient(135deg, rgba(59,130,246,0.15) 0%, rgba(15,23,42,0) 100%); }
.hero h1 { font-size: 48px; font-weight: 800; letter-spacing: -1.5px; margin-bottom: 24px; line-height: 1.15; }
.hero p { font-size: 20px; color: var(--fg-muted); max-width: 600px; margin: 0 auto 40px; }
.hero-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  width: 100%;
  max-width: 760px;
  margin: 20px auto 0;
}

.hero-actions > .btn {
  width: 100%;
}

.hero-trust {
  justify-content: center;
}

@media (max-width: 600px) {
  .hero-actions {
    grid-template-columns: 1fr;
  }
}

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 12px 24px; border-radius: 12px; font-weight: 600; font-size: 16px;
  border: 1px solid transparent; cursor: pointer; transition: all 0.2s;
  text-decoration: none; font-family: inherit;
}
.btn:active { transform: scale(0.96); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); color: #fff; transform: translateY(-2px); box-shadow: var(--shadow-md); }
.btn-outline { background: var(--card); border-color: var(--border); color: var(--fg); }
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }
.btn-lg { padding: 16px 36px; font-size: 18px; border-radius: 16px; }
.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: 8px; }
.btn-ghost { background: transparent; border: 1px dashed var(--border); color: var(--fg-muted); padding: 8px 16px; font-size: 14px; }
.btn-ghost:hover { color: var(--accent); border-color: var(--accent); }
.btn-block { width: 100%; text-align: center; }

.section-head { margin-bottom: 40px; text-align: center; }
.section-head h2 { font-size: 36px; font-weight: 800; letter-spacing: -1px; margin-bottom: 24px; }
.filter-bar { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.filter-btn { padding: 10px 20px; border-radius: 24px; border: 1px solid var(--border); background: var(--card); color: var(--fg-muted); font-weight: 600; font-size: 15px; cursor: pointer; transition: all 0.2s; font-family: inherit; }
.filter-btn:hover { border-color: var(--accent); color: var(--accent); }
.filter-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); box-shadow: var(--shadow-md); }

.subjects-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 24px; }
.subject-card { background: var(--card); border-radius: var(--radius); padding: 32px; border: 1px solid var(--border); display: flex; flex-direction: column; gap: 20px; transition: all 0.3s ease; color: var(--fg); position: relative; box-shadow: var(--shadow-sm); }
.subject-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); border-color: var(--accent); }
.subject-icon { width: 48px; height: 48px; display: flex; align-items: center; justify-content: center; color: var(--accent); margin-bottom: 8px; }
.subject-icon svg { width: 100%; height: 100%; stroke: currentColor; fill: none; }
body.theme-dark .subject-icon { color: #60A5FA; }
.subject-info h3 { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.subject-info p { color: var(--fg-muted); font-size: 15px; font-weight: 500; }
.subject-count { margin-top: auto; font-size: 14px; font-weight: 600; color: var(--accent); background: rgba(37,99,235,0.1); padding: 8px 14px; border-radius: 20px; align-self: flex-start; }

.breadcrumbs { display: flex; gap: 8px; font-size: 14px; color: var(--fg-muted); margin-bottom: 24px; }
.breadcrumbs a { color: var(--fg-muted); text-decoration: underline; }
.breadcrumbs span { color: var(--fg); }
.page-title { font-size: 42px; font-weight: 800; letter-spacing: -1px; margin-bottom: 48px; }
.grades-list { display: flex; flex-direction: column; gap: 40px; }
.grade-group { background: var(--card); border-radius: var(--radius); padding: 40px; border: 1px solid var(--border); box-shadow: var(--shadow-sm); }
.grade-title { font-size: 24px; font-weight: 700; margin-bottom: 24px; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.topics-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }

.topic-card { background: var(--bg); padding: 20px 24px; border-radius: 12px; border: 1px solid transparent; display: flex; flex-direction: column; gap: 10px; transition: all 0.2s; }
.topic-card:hover { border-color: var(--accent); background: var(--card); box-shadow: var(--shadow-sm); }
.topic-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.topic-title-link { color: var(--fg); }
.topic-title { font-size: 17px; font-weight: 600; margin: 0; }
.topic-title-link:hover { color: var(--accent); }
.topic-meta { font-size: 13px; color: var(--fg-muted); }
.topic-action { font-size: 14px; color: var(--accent); font-weight: 600; }
.fav-btn { background: transparent; border: none; cursor: pointer; font-size: 20px; padding: 0; line-height: 1; transition: transform 0.15s; }
.fav-btn:hover { transform: scale(1.2); }

.search-form { display: flex; gap: 8px; max-width: 560px; margin: 0 auto 24px; }
.search-input { flex: 1; padding: 10px 16px; border-radius: 12px; border: 1px solid var(--border); background: var(--card); color: var(--fg); font-family: inherit; font-size: 15px; }
.search-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,0.15); }
.search-meta { color: var(--fg-muted); margin-bottom: 16px; }

.form-wrap { max-width: 480px; margin: 40px auto; background: var(--card); padding: 40px; border-radius: var(--radius); box-shadow: var(--shadow-lg); border: 1px solid var(--border); }
.form-wrap h1 { margin-bottom: 24px; font-size: 32px; font-weight: 800; letter-spacing: -0.5px; }
.form-wrap label { display: block; margin-bottom: 20px; font-weight: 600; font-size: 14px; }
.form-wrap input, .form-wrap textarea { width: 100%; padding: 12px 16px; border-radius: 8px; border: 1px solid var(--border); font-size: 16px; margin-top: 8px; background: var(--bg); color: var(--fg); transition: border-color 0.2s; font-family: inherit; }
.form-wrap input:focus, .form-wrap textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,0.2); }
.err { color: var(--err); font-size: 14px; display: block; margin-top: 4px; }
.warn { color: var(--warn); font-weight: 600; margin-bottom: 20px; }
.actions { display: flex; gap: 12px; margin-top: 24px; flex-wrap: wrap; }

.trainer { max-width: 680px; margin: 0 auto; }
.trainer-head { display: flex; gap: 16px; align-items: center; margin-bottom: 16px; color: var(--fg-muted); font-size: 15px; font-weight: 500; }
.link-quiet { margin-left: auto; color: var(--fg-muted); }
.link-quiet:hover { color: var(--err); }
.task-card { background: var(--card); border-radius: var(--radius); padding: 40px; position: relative; box-shadow: var(--shadow-md); border: 1px solid var(--border); overflow: hidden; }
.task-prompt { font-size: 32px; font-weight: 700; margin: 20px 0; user-select: none; text-align: center; position: relative; z-index: 1; }
.answer-input { font-size: 24px; padding: 16px; width: 100%; border-radius: 12px; border: 2px solid var(--border); background: var(--bg); color: var(--fg); text-align: center; font-weight: 600; transition: border-color 0.2s; }
.answer-input:focus { outline: none; border-color: var(--accent); }
.choices { display: flex; gap: 12px; margin: 20px 0; justify-content: center; flex-wrap: wrap; }
.choice { padding: 16px 24px; border: 2px solid var(--border); border-radius: 12px; cursor: pointer; min-width: 80px; text-align: center; font-size: 22px; font-weight: 600; background: var(--bg); transition: all 0.2s; }
.choice:hover { border-color: var(--accent); }
.choice input { display: none; }
.choice:has(input:checked) { border-color: var(--accent); background: rgba(37,99,235,0.1); }
.choice-key { display: inline-block; background: var(--border); color: var(--fg-muted); width: 22px; height: 22px; border-radius: 4px; font-size: 13px; line-height: 22px; text-align: center; margin-right: 6px; font-weight: 700; }
.result.correct { color: var(--ok); font-weight: 700; font-size: 18px; margin: 24px 0; text-align: center; background: rgba(22,163,74,0.1); padding: 16px; border-radius: 12px; }
.result.wrong { color: var(--err); font-weight: 700; font-size: 18px; margin: 24px 0; text-align: center; background: rgba(220,38,38,0.1); padding: 16px; border-radius: 12px; }
.solution { background: var(--bg); padding: 24px; border-radius: 12px; margin: 24px 0; border: 1px solid var(--border); }
.solution h3 { margin-top: 0; margin-bottom: 20px; font-size: 20px; }
.step { display: flex; gap: 16px; margin-bottom: 16px; }
.step-n { width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 14px; font-weight: 700; }
.step div { font-size: 16px; }
.step code { display: inline-block; background: var(--card); border: 1px solid var(--border); padding: 4px 10px; border-radius: 6px; margin-top: 6px; font-family: monospace; font-size: 15px; }
/* Новый класс для формул, чтобы KaTeX не игнорировал их */
.step-formula { display: inline-block; background: var(--card); border: 1px solid var(--border); padding: 4px 10px; border-radius: 6px; margin-top: 6px; font-size: 15px; }
.hint { color: var(--fg-muted); font-size: 15px; margin-top: 20px; font-style: italic; }
.big-code { font-size: 36px; letter-spacing: 6px; font-weight: 800; text-align: center; padding: 24px; background: var(--bg); border-radius: 12px; margin: 24px 0; border: 1px dashed var(--border); }

.progress-bar { flex: 1; height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; min-width: 120px; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 4px; transition: width 0.3s; }
.progress-label { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--fg-muted); }

.history-dots { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--border); }
.dot-c { background: var(--ok); }
.dot-w { background: var(--err); }
.dot-s { background: var(--warn); }

.level-badge { font-size: 13px; font-weight: 600; color: var(--fg-muted); letter-spacing: 1px; white-space: nowrap; }

.hint-controls { text-align: center; margin-bottom: 12px; }
.hint-box { background: rgba(202, 138, 4, 0.1); border: 1px solid rgba(202, 138, 4, 0.3); color: var(--fg); padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 15px; }

.symbols-panel { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; padding: 12px; background: var(--bg); border: 1px solid var(--border); border-radius: 12px; justify-content: center; }
.symbols-group { display: flex; align-items: center; gap: 6px; background: var(--card); padding: 6px 10px; border-radius: 8px; border: 1px solid var(--border); }
.symbols-label { font-size: 12px; color: var(--fg-muted); font-weight: 600; margin-right: 4px; }
.sym-btn { background: transparent; border: 1px solid transparent; color: var(--fg); font-size: 16px; padding: 4px 8px; border-radius: 6px; cursor: pointer; transition: all 0.15s; font-family: inherit; }
.sym-btn:hover { background: rgba(37,99,235,0.1); color: var(--accent); border-color: var(--accent); }
.sym-btn:active { transform: scale(0.95); }

.answer-actions { margin-top: 16px; display: flex; justify-content: center; }
.confidence-field { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin-top: 14px; display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; }
.confidence-field legend { padding: 0 4px; color: var(--fg-muted); font-size: 13px; }
.confidence-field label { font-size: 13px; display: inline-flex; gap: 5px; align-items: center; cursor: pointer; }
.error-reason { margin: 12px 0 16px; padding: 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--card); }
.error-reason p { margin: 0 0 8px; font-size: 14px; color: var(--fg-muted); }
.error-reason-buttons { display: flex; flex-wrap: wrap; gap: 6px; }
.error-reason-buttons button { border: 1px solid var(--border); background: transparent; color: var(--fg); border-radius: 999px; padding: 5px 10px; font-size: 12px; cursor: pointer; }
.error-reason-buttons button:hover { border-color: var(--accent); }
.error-reason-buttons button.is-selected { background: var(--accent); color: #fff; border-color: var(--accent); }
.parent-prompt { margin: 14px 0 20px; padding: 14px 16px; border-left: 4px solid var(--accent); background: rgba(37, 99, 235, 0.06); border-radius: 8px; }
.parent-prompt p { margin: 6px 0 0; }
.heatmap-table { font-size: 13px; }
.heatmap-table th, .heatmap-table td { padding: 7px 9px; text-align: center; }
.heatmap-table th:first-child, .heatmap-table td:first-child { text-align: left; }
.heatmap-cell.heatmap-mid { background: rgba(245, 158, 11, 0.16); font-weight: 600; }
.heatmap-cell.heatmap-high { background: rgba(239, 68, 68, 0.18); font-weight: 700; }
.faded-intro { color: var(--fg-muted); font-size: 14px; margin: 0 0 10px; }
.faded-step.is-hidden { display: none; }
.faded-controls { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.skip-form { text-align: right; margin-top: 12px; }
.skip-form .link-btn { color: var(--fg-muted); font-size: 14px; }
.skip-form .link-btn:hover { color: var(--warn); }

table { width: 100%; border-collapse: collapse; background: var(--card); border-radius: 12px; overflow: hidden; box-shadow: var(--shadow-sm); border: 1px solid var(--border); }
th, td { padding: 16px; border-bottom: 1px solid var(--border); text-align: left; }
th { background: var(--bg); font-weight: 600; }
.child-card { background: var(--card); border-radius: var(--radius); padding: 24px; margin: 16px 0; border: 1px solid var(--border); }

.admin-wrap { max-width: 700px; margin: 0 auto; background: var(--card); padding: 40px; border-radius: var(--radius); border: 1px solid var(--border); box-shadow: var(--shadow-md); }
.admin-wrap h1 { margin-bottom: 8px; font-size: 32px; font-weight: 800; }
.admin-wrap .subtitle { color: var(--fg-muted); margin-bottom: 32px; }
.admin-section { background: var(--bg); padding: 24px; border-radius: 12px; margin-bottom: 24px; border: 1px solid var(--border); }
.admin-section h2 { font-size: 20px; margin-bottom: 16px; border-bottom: 1px solid var(--border); padding-bottom: 12px; }
.checkbox-label { display: flex; align-items: center; gap: 12px; padding: 12px 0; font-weight: 500; cursor: pointer; border-bottom: 1px solid var(--border); }
.checkbox-label:last-child { border-bottom: none; }
.checkbox-label input { width: 20px; height: 20px; accent-color: var(--accent); cursor: pointer; }
.admin-section textarea { width: 100%; padding: 12px; border-radius: 8px; border: 1px solid var(--border); font-family: monospace; font-size: 14px; margin-top: 10px; background: var(--card); color: var(--fg); resize: vertical; }

.stats-grid { display: flex; gap: 16px; flex-wrap: wrap; }
.stat-card { flex: 1; min-width: 120px; background: var(--card); border: 1px solid var(--border); padding: 16px; border-radius: 8px; text-align: center; }
.stat-val { font-size: 28px; font-weight: 800; color: var(--accent); }
.stat-label { font-size: 13px; color: var(--fg-muted); margin-top: 4px; }
.reports-list { list-style: none; padding: 0; }
.reports-list li { padding: 12px 0; border-bottom: 1px solid var(--border); font-size: 14px; }

.ad-container { margin: 40px auto; max-width: 900px; padding: 20px; background: var(--card); border: 1px dashed var(--border); border-radius: var(--radius); text-align: center; position: relative; }
.ad-label { position: absolute; top: -10px; left: 20px; background: var(--bg); padding: 0 8px; font-size: 12px; color: var(--fg-muted); font-weight: 600; }
.ad-content { display: flex; justify-content: center; align-items: center; min-height: 100px; overflow: hidden; }

.dash-header { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 16px; margin-bottom: 24px; }
.level-box { display: flex; align-items: center; gap: 12px; }
.level-circle { background: var(--accent); color: #fff; width: 48px; height: 48px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 14px; }
.level-bar-wrap { min-width: 150px; }
.level-label { font-size: 12px; color: var(--fg-muted); margin-bottom: 4px; }
.level-bar { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.level-fill { height: 100%; background: var(--accent); border-radius: 3px; }
.dashboard-grid { display: grid; grid-template-columns: 1fr 300px; gap: 24px; }
@media (max-width: 768px) { .dashboard-grid { grid-template-columns: 1fr; } }

.accuracy-widget { text-align: center; padding: 24px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); }
.donut-chart { width: 120px; height: 120px; border-radius: 50%; margin: 16px auto; background: conic-gradient(var(--accent) calc(var(--percent) * 1%), var(--border) 0); display: flex; align-items: center; justify-content: center; }
.donut-inner { width: 90px; height: 90px; background: var(--card); border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.donut-val { font-size: 24px; font-weight: 800; color: var(--fg); }
.acc-meta { font-size: 13px; color: var(--fg-muted); }

.achievements-widget { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; margin-top: 24px; }
.achievements-grid { display: flex; flex-wrap: wrap; gap: 12px; }
.achievement-badge { width: 60px; height: 60px; background: rgba(202,138,4,0.1); border: 1px solid rgba(202,138,4,0.3); border-radius: 12px; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 24px; cursor: help; }
.ach-name { font-size: 9px; color: var(--fg-muted); text-align: center; line-height: 1; margin-top: 4px; }

.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 9999; display: flex; flex-direction: column; gap: 12px; }
.toast { background: var(--card); border: 1px solid var(--border); border-left: 4px solid var(--warn); padding: 16px; border-radius: 8px; box-shadow: var(--shadow-lg); display: flex; gap: 12px; align-items: center; transform: translateX(120%); transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
.toast-show { transform: translateX(0); }
.toast-icon { font-size: 28px; }
.toast-title { font-weight: 700; font-size: 15px; }
.toast-desc { font-size: 13px; color: var(--fg-muted); }

.streak-box { background: var(--card); border: 1px solid var(--border); padding: 16px 20px; border-radius: 12px; margin-bottom: 24px; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; }
.streak-info { display: flex; align-items: center; gap: 12px; }
.streak-fire { font-size: 28px; }
.streak-title { font-weight: 700; font-size: 16px; }
.streak-meta { font-size: 13px; color: var(--fg-muted); }
.streak-motivate { font-size: 14px; font-weight: 600; color: var(--accent); background: rgba(37,99,235,0.1); padding: 8px 12px; border-radius: 8px; }

.modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 20px; }
[hidden] { display: none !important; }
.modal-content { background: var(--card); padding: 32px; border-radius: var(--radius); width: 100%; max-width: 500px; box-shadow: var(--shadow-lg); }
.modal-content h2 { margin-bottom: 16px; font-size: 24px; }
.modal-content label { display: block; margin: 16px 0; font-weight: 600; font-size: 14px; }
.modal-content textarea { width: 100%; padding: 12px; border: 1px solid var(--border); border-radius: 8px; font-family: inherit; margin-top: 8px; background: var(--bg); color: var(--fg); }
.modal-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 24px; }
.report-link-wrap { text-align: center; margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--border); }

.next-step { background: linear-gradient(135deg, rgba(37,99,235,0.08) 0%, rgba(37,99,235,0.02) 100%); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 24px; margin-bottom: 24px; }
.next-step h2 { font-size: 18px; margin-bottom: 12px; }
.next-step-link { display: flex; align-items: center; gap: 12px; padding: 16px 20px; background: var(--card); border-radius: 12px; border: 1px solid var(--border); color: var(--fg); transition: border-color 0.2s, transform 0.2s; }
.next-step-link:hover { border-color: var(--accent); transform: translateX(4px); }
.next-step-title { font-weight: 700; font-size: 17px; }
.next-step-meta { font-size: 14px; color: var(--fg-muted); }
.next-step-arrow { margin-left: auto; color: var(--accent); font-size: 22px; font-weight: 700; }

.chart { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 24px; margin-bottom: 24px; }
.chart h2 { font-size: 18px; margin-bottom: 16px; }
.chart-bars { display: flex; gap: 6px; height: 100px; align-items: flex-end; }
.chart-bar { flex: 1; display: flex; align-items: flex-end; min-height: 4px; border-radius: 4px 4px 0 0; background: transparent; overflow: hidden; }
.chart-bar-fill { width: 100%; border-radius: 4px 4px 0 0; transition: height 0.3s; }
.chart-ok .chart-bar-fill { background: var(--ok); }
.chart-warn .chart-bar-fill { background: var(--warn); }
.chart-err .chart-bar-fill { background: var(--err); }
.chart-empty .chart-bar-fill { background: var(--border); }
.chart-labels { display: flex; gap: 6px; margin-top: 8px; font-size: 11px; color: var(--fg-muted); }
.chart-labels span { flex: 1; text-align: center; }

.progress-list { list-style: none; padding: 0; }
.progress-item { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 16px; margin-bottom: 10px; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; }
.progress-info { display: flex; flex-direction: column; gap: 4px; }
.progress-meta { font-size: 14px; color: var(--fg-muted); }
.progress-actions { display: flex; gap: 8px; }

.task-card.with-watermark { position: relative; }
.notification-bell {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(37, 99, 235, 0.08);
  font-size: 16px;
  text-decoration: none;
}
.notification-bell span {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
}
.search-suggest-wrap { position: relative; flex: 1; min-width: 220px; }
.search-suggest-wrap .search-input { width: 100%; }
.search-suggest-box {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 50;
  padding: 6px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-sm);
}
.search-suggest-item {
  display: block;
  padding: 8px 10px;
  border-radius: 7px;
  color: var(--fg);
}
.search-suggest-item:hover { background: rgba(37, 99, 235, 0.08); }
.search-suggest-item.is-active { background: rgba(37, 99, 235, 0.14); }
.search-suggest-item strong { display: block; font-size: 14px; }
.search-suggest-item span { display: block; margin-top: 2px; font-size: 12px; color: var(--fg-muted); }
.task-card.with-watermark::after { content: attr(data-wm); position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%) rotate(-25deg); font-size: 64px; font-weight: 800; color: rgba(0, 0, 0, 0.06); pointer-events: none; user-select: none; white-space: nowrap; z-index: 0; }
body.theme-dark .task-card.with-watermark::after { color: rgba(255, 255, 255, 0.06); }

.messages-wrap { max-width: 1100px; margin: 16px auto 0; padding: 0 24px; }
.message { padding: 12px 20px; border-radius: 8px; margin-bottom: 8px; font-weight: 500; border: 1px solid transparent; }
.message-success { background: rgba(22,163,74,0.12); color: #15803d; border-color: rgba(22,163,74,0.3); }
.message-error   { background: rgba(220,38,38,0.12); color: #b91c1c; border-color: rgba(220,38,38,0.3); }
.message-warning { background: rgba(202,138,4,0.12); color: #a16207; border-color: rgba(202,138,4,0.3); }
.message-info    { background: rgba(37,99,235,0.12); color: #1d4ed8; border-color: rgba(37,99,235,0.3); }
body.theme-dark .message-success { background: rgba(22,163,74,0.2); color: #86efac; }
body.theme-dark .message-error   { background: rgba(220,38,38,0.2); color: #fca5a5; }
body.theme-dark .message-warning { background: rgba(202,138,4,0.2); color: #fde68a; }
body.theme-dark .message-info    { background: rgba(59,130,246,0.2); color: #93c5fd; }

.logout-form { display: inline; margin: 0; padding: 0; }
.link-btn { background: none; border: none; padding: 0; cursor: pointer; color: var(--accent); font: inherit; font-weight: 500; }
.link-btn:hover { color: var(--accent-hover); }

.assignments-list { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; margin-bottom: 24px; }
.assignments-list h2 { font-size: 20px; margin-bottom: 16px; border-bottom: 1px solid var(--border); padding-bottom: 12px; }
.assignment-item { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--border); }
.assignment-item:last-child { border-bottom: none; }
.assignment-item.overdue { color: var(--err); }
.assignment-meta { color: var(--fg-muted); font-size: 14px; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
  20%, 40%, 60%, 80% { transform: translateX(5px); }
}
.animate-shake { animation: shake 0.5s cubic-bezier(.36,.07,.19,.97) both; }

*:focus-visible {
  outline: 3px solid var(--accent) !important;
  outline-offset: 3px;
  border-radius: 4px;
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.theme-toggle-form { display: inline; margin: 0; padding: 0; }
.theme-toggle-btn {
  background: transparent; border: 1px solid var(--border); border-radius: 8px;
  cursor: pointer; font-size: 18px; padding: 6px 10px;
  transition: all 0.2s;
}
.theme-toggle-btn:hover { border-color: var(--accent); }

.sortable-list { list-style: none; padding: 0; margin: 20px 0; }
.sortable-item {
  background: var(--card); border: 1px solid var(--border); border-radius: 8px;
  padding: 12px 16px; margin-bottom: 8px; cursor: grab;
  display: flex; align-items: center; gap: 12px;
  font-weight: 500; user-select: none;
}
.sortable-item:active { cursor: grabbing; }
.sortable-item.drag-over { border-color: var(--accent); background: rgba(37,99,235,0.05); }
.drag-handle { color: var(--fg-muted); font-size: 20px; cursor: grab; }

.empty-state {
  text-align: center;
  padding: 40px 20px;
  background: var(--card);
  border-radius: var(--radius);
  border: 1px dashed var(--border);
  color: var(--fg-muted);
}
.empty-state svg { width: 120px; height: 120px; margin-bottom: 16px; opacity: 0.5; }
.empty-state p { margin-bottom: 16px; }

/* --- Mobile Bottom Navigation --- */
.mobile-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--card);
  border-top: 1px solid var(--border);
  z-index: 1000;
  padding: 8px 0;
  padding-bottom: calc(8px + env(safe-area-inset-bottom));
}
.mobile-nav-item {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--fg-muted);
  font-size: 10px;
  text-decoration: none;
  gap: 4px;
}
.mobile-nav-item .icon { font-size: 20px; }
.mobile-nav-item.active { color: var(--accent); }
.mobile-nav-item.active .icon { transform: translateY(-2px); transition: transform 0.2s; }

/* Умный микс дня */
.daily-mix-card {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--card); border: 1px solid var(--border); border-left: 4px solid var(--accent);
  padding: 16px; border-radius: 12px; margin-bottom: 12px;
  transition: transform 0.2s, box-shadow 0.2s;
}
.daily-mix-card:hover {
  transform: translateY(-2px); box-shadow: var(--shadow-md);
}
.daily-mix-info { display: flex; flex-direction: column; gap: 4px; }
.daily-mix-title { font-weight: 700; font-size: 16px; color: var(--fg); }
.daily-mix-reason { font-size: 13px; color: var(--fg-muted); font-weight: 500; }

@media (max-width: 768px) {
  body { padding-bottom: 70px; }

  .mobile-nav { display: flex; }
  .desktop-nav { display: none; }
  .topbar { padding: 12px 16px; }
  .logo { font-size: 20px; }
  .logo-text { font-size: 20px; }
  .logo-img { width: 38px; height: 22px; }
  .hero h1 { font-size: 32px; letter-spacing: -0.5px; }
  .hero p { font-size: 16px; }
  .section-head h2 { font-size: 28px; }
  .page-title { font-size: 32px; margin-bottom: 24px; }
  .grade-group { padding: 20px; }
  .subjects-grid { grid-template-columns: 1fr; }
  .form-wrap { padding: 24px 16px; margin: 20px auto; }
  .trainer-head { flex-wrap: wrap; justify-content: space-between; gap: 8px; }
  .progress-bar { width: 100%; flex: 1 1 100%; margin-bottom: 8px; }
  .progress-label { order: 1; }
  .level-badge { order: 2; }
  .link-quiet { order: 3; margin-left: 0; }
  .btn { padding: 14px 20px; min-height: 44px; }
  .btn-sm { min-height: 36px; padding: 8px 12px; }
  .sym-btn { min-width: 44px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }
  .task-card { padding: 20px 16px; }
  .task-prompt { font-size: 24px; margin: 12px 0; }
  .answer-input { font-size: 20px; padding: 12px; }
  .symbols-panel { flex-wrap: nowrap; overflow-x: auto; justify-content: flex-start; padding: 8px; -webkit-overflow-scrolling: touch; }
  .symbols-group { flex-shrink: 0; }
  .choices { flex-direction: column; gap: 8px; }
  .choice { width: 100%; display: flex; align-items: center; justify-content: flex-start; text-align: left; padding: 14px 20px; font-size: 18px; }
  .choice-key { flex-shrink: 0; margin-right: 12px; }
  .answer-actions {
    margin-top: 24px;
    margin-bottom: 16px;
    display: flex;
    justify-content: center;
  }
  .answer-actions .btn { width: 100%; font-size: 18px; }
  .skip-form { margin-bottom: 24px; }
  .chart-labels span { font-size: 10px; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .stats-grid { flex-direction: column; }
  .choice input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
  .choice:focus-within { outline: 3px solid var(--accent); outline-offset: 3px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* Cookie consent: fixed above the mobile nav, never below the fold. */
.cookie-banner {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  z-index: 10000;
  display: none;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  max-width: 760px;
  margin: 0 auto;
  padding: 14px 18px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  font-size: 14px;
}

.cookie-banner .cookie-text {
  flex: 1 1 360px;
  margin: 0;
  line-height: 1.5;
}

@media (max-width: 700px) {
  .cookie-banner {
    left: 8px;
    right: 8px;
    bottom: calc(78px + env(safe-area-inset-bottom, 0px));
  }
}

/* --- Hero trust / dashboard hierarchy --- */
.hero-trust {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.hero-trust span {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--card);
  color: var(--fg-muted);
  font-size: 13px;
  font-weight: 600;
}

.dashboard-next {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.dashboard-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.dashboard-action-card {
  padding: 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
}

.dashboard-action-card h2 {
  margin: 0 0 8px;
  font-size: 16px;
}

.dashboard-action-card a {
  display: block;
  padding: 8px 0;
  color: var(--fg);
  text-decoration: none;
  font-size: 14px;
  border-bottom: 1px solid transparent;
}

.dashboard-action-card a:hover {
  color: var(--accent);
}

.onboarding-card {
  padding: 18px;
  margin-bottom: 20px;
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.08), transparent);
  border: 1px solid var(--border);
  border-radius: 16px;
}

.onboarding-card h2 {
  margin: 0 0 12px;
  font-size: 18px;
}

.onboarding-steps {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.onboarding-step {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px;
  border-radius: 12px;
  background: var(--card);
  border: 1px solid var(--border);
}

.onboarding-step.done {
  opacity: 0.7;
}

.onboarding-check {
  flex: 0 0 26px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--border);
  color: var(--fg-muted);
  font-weight: 700;
  font-size: 13px;
}

.onboarding-step.done .onboarding-check {
  background: var(--ok);
  color: #fff;
}

.onboarding-step .btn {
  margin-top: 8px;
}

.reference-table-wrap {
  width: 100%;
  margin-top: 12px;
  overflow-x: auto;
}

.reference-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.reference-table td {
  padding: 9px 8px;
  border-top: 1px solid var(--border);
  vertical-align: top;
  line-height: 1.45;
}

.reference-table .reference-name {
  width: 34%;
  color: var(--fg-muted);
  font-weight: 600;
}

.reference-table .reference-formula {
  color: var(--accent);
  font-weight: 600;
  word-break: break-word;
  font-style: normal;
}

@media (max-width: 600px) {
  .reference-table .reference-name {
    width: 40%;
  }

  .reference-table td {
    padding: 8px 6px;
    font-size: 14px;
  }
}

/* --- Аналитика слабых тем класса --- */
.weak-topics {
  margin: 24px 0 28px;
}

.weak-topics-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}

.weak-topics-head h2 {
  margin: 0 0 4px;
}

.weak-topics-head p {
  margin: 0;
  color: var(--fg-muted);
  font-size: 14px;
}

.weak-count {
  flex-shrink: 0;
  padding: 5px 9px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--fg-muted);
  font-size: 12px;
}

.weak-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 10px;
}

.weak-topic {
  padding: 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.weak-topic-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: baseline;
}

.weak-topic-top strong {
  line-height: 1.35;
}

.weak-accuracy {
  flex-shrink: 0;
  font-weight: 800;
  color: var(--ok);
}

.weak-accuracy.is-mid {
  color: var(--warn);
}

.weak-accuracy.is-low {
  color: var(--err);
}

.weak-topic-meta {
  margin-top: 4px;
  color: var(--fg-muted);
  font-size: 12px;
}

.weak-topic-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.weak-empty {
  padding: 16px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  color: var(--fg-muted);
  font-size: 14px;
  background: var(--card);
}

.table-scroll {
  width: 100%;
  overflow-x: auto;
}

.weak-chip {
  display: inline-block;
  margin: 2px 4px 2px 0;
  padding: 3px 7px;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.08);
  color: var(--accent);
  font-size: 12px;
  white-space: nowrap;
}

.ai-modes {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.ai-modes .btn.is-active {
  background: #8B5CF6;
  border-color: #8B5CF6;
  color: #fff;
}

.ai-locked {
  color: var(--fg-muted);
  font-size: 13px;
  align-self: center;
}

.challenge-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 8px 0 10px;
  padding: 10px 12px;
  background: rgba(37, 99, 235, 0.08);
  border: 1px solid rgba(37, 99, 235, 0.25);
  border-radius: 10px;
  font-size: 13px;
}

.challenge-banner strong {
  color: var(--accent);
}

.challenge-banner span {
  flex: 1;
  color: var(--fg-muted);
}

.teacher-tools {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 0 0 20px;
}

.teacher-tool {
  padding: 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.teacher-tool strong {
  font-size: 14px;
}

.teacher-tool .search-input {
  font-size: 13px;
}

@media (max-width: 800px) {
  .teacher-tools {
    grid-template-columns: 1fr;
  }
}

.seasonal-cta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 22px 0;
}

.seasonal-note {
  margin-top: 22px;
  padding: 16px;
  background: var(--card);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
}

.seasonal-days {
  display: grid;
  gap: 8px;
  margin: 18px 0;
}

.seasonal-days div {
  display: flex;
  gap: 14px;
  padding: 12px 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.seasonal-days strong {
  flex: 0 0 70px;
}

.seasonal-days span {
  color: var(--fg-muted);
}

/* --- Экзамен: отметки, таймер, разбор --- */
.exam-dot.is-flagged {
  box-shadow: 0 0 0 2px #F59E0B inset;
}

#exam-timer.is-warning {
  color: var(--err);
}

.exam-warning {
  margin-top: 2px;
  color: var(--err);
  font-size: 11px;
  font-weight: 600;
}

.result-topics {
  display: grid;
  gap: 12px;
}

.result-topic-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
  font-size: 14px;
}

.result-topic-top span {
  color: var(--fg-muted);
  white-space: nowrap;
}

.exam-review {
  margin: 24px 0;
}

.exam-review-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}

.exam-review-head h2 {
  margin: 0 0 4px;
}

.exam-review-head p {
  margin: 0;
  color: var(--fg-muted);
  font-size: 14px;
}

.review-item {
  margin-bottom: 8px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card);
  overflow: hidden;
}

.review-item summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  cursor: pointer;
  list-style: none;
}

.review-item summary::-webkit-details-marker {
  display: none;
}

.review-item.is-wrong summary {
  border-left: 4px solid var(--err);
}

.review-item.is-correct summary {
  border-left: 4px solid var(--ok);
}

.review-number {
  flex: 0 0 26px;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--bg);
  font-size: 12px;
  font-weight: 700;
}

.review-topic {
  flex: 1;
  font-weight: 600;
  font-size: 14px;
}

.review-status {
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.review-status.ok { color: var(--ok); }
.review-status.err { color: var(--err); }
.review-status.warn { color: var(--warn); }

.review-body {
  padding: 0 14px 16px 50px;
  font-size: 14px;
}

.review-prompt {
  font-weight: 600;
  margin: 4px 0 10px;
}

.review-solution {
  margin: 10px 0;
  padding: 10px 12px;
  background: var(--bg);
  border-radius: 8px;
}

.review-solution ol {
  margin: 6px 0 0;
  padding-left: 20px;
}

.review-hint {
  color: var(--warn);
}

.result-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 20px 0;
}

@media (max-width: 600px) {
  .review-body {
    padding-left: 14px;
  }

  .review-item summary {
    align-items: flex-start;
    flex-wrap: wrap;
  }
}

/* --- Онбординг --- */
.onboarding-shell {
  max-width: 680px;
  margin: 0 auto;
}

.onboarding-progress {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.onboarding-progress span {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--fg-muted);
  font-weight: 700;
  font-size: 13px;
}

.onboarding-progress span.is-done {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.onboarding-progress span + span {
  position: relative;
}

.onboarding-progress span + span::before {
  content: "";
  position: absolute;
  right: 100%;
  width: 8px;
  height: 1px;
  background: var(--border);
}

.onboarding-step-label {
  margin: 0 0 16px;
  color: var(--fg-muted);
  font-size: 13px;
}

.onboarding-lead {
  font-size: 18px;
  color: var(--fg-muted);
  line-height: 1.6;
  margin-bottom: 20px;
}

.onboarding-card {
  padding: 24px;
}

.onboarding-label {
  display: block;
  margin: 0 0 6px;
  font-weight: 600;
}

.onboarding-input {
  width: 100%;
  margin-bottom: 18px;
}

.onboarding-submit {
  width: 100%;
  margin-top: 4px;
}

.onboarding-summary {
  display: grid;
  gap: 10px;
  margin-bottom: 20px;
}

.onboarding-summary div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.onboarding-summary span {
  color: var(--fg-muted);
}

.onboarding-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 16px;
}

.today-card {
  margin-bottom: 20px;
  padding: 18px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
}

.today-card h2 {
  margin: 0 0 4px;
  font-size: 18px;
}

.today-card > p {
  margin: 0 0 12px;
  color: var(--fg-muted);
  font-size: 13px;
}

.today-items {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.today-item {
  display: block;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  text-decoration: none;
  color: var(--fg);
}

.today-item:hover {
  border-color: var(--accent);
}

.today-item .today-icon {
  font-size: 18px;
}

.today-item strong {
  display: block;
  font-size: 14px;
  margin: 4px 0 2px;
}

.today-item span {
  display: block;
  color: var(--fg-muted);
  font-size: 12px;
}

.today-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}

@media (max-width: 700px) {
  .today-items {
    grid-template-columns: 1fr;
  }
}

/* --- PWA install prompt --- */
.pwa-install {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  z-index: 9000;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 560px;
  margin: 0 auto;
  padding: 12px 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
}

.pwa-install > div {
  flex: 1;
  min-width: 0;
}

.pwa-install strong {
  display: block;
  font-size: 14px;
}

.pwa-install span {
  display: block;
  margin-top: 2px;
  color: var(--fg-muted);
  font-size: 12px;
}

.pwa-close {
  border: 0;
  background: transparent;
  color: var(--fg-muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

@media (max-width: 700px) {
  .pwa-install {
    bottom: calc(78px + env(safe-area-inset-bottom, 0px));
  }
}

/* --- VK mini app --- */
body.vk-mode main {
  max-width: 520px;
  padding-top: 24px;
}

body.vk-mode .topbar,
body.vk-mode .footer,
body.vk-mode .mobile-nav,
body.vk-mode .cookie-banner,
body.vk-mode .pwa-install {
  display: none !important;
}

.vk-app {
  max-width: 440px;
  margin: 0 auto;
}

.vk-brand {
  color: var(--accent);
  font-weight: 800;
  letter-spacing: 0.02em;
  margin-bottom: 8px;
}

.vk-progress {
  color: var(--fg-muted);
  font-size: 13px;
  margin: 0 0 12px;
}

.vk-card {
  padding: 22px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow-md);
}

.vk-question {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.35;
  margin: 0 0 18px;
}

.vk-options {
  display: grid;
  gap: 8px;
}

.vk-option {
  width: 100%;
  padding: 14px 16px;
  text-align: left;
  font: inherit;
  font-size: 17px;
  font-weight: 600;
  color: var(--fg);
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
}

.vk-option:hover:not(:disabled) {
  border-color: var(--accent);
}

.vk-option.is-correct {
  border-color: var(--ok);
  background: rgba(22, 163, 74, 0.1);
  color: var(--ok);
}

.vk-option.is-wrong {
  border-color: var(--err);
  background: rgba(220, 38, 38, 0.1);
  color: var(--err);
}

.vk-feedback {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 700;
}

.vk-feedback.is-correct {
  background: rgba(22, 163, 74, 0.1);
  color: var(--ok);
}

.vk-feedback.is-wrong {
  background: rgba(220, 38, 38, 0.1);
  color: var(--err);
}

.vk-next {
  width: 100%;
  margin-top: 14px;
}

.vk-result {
  padding: 26px;
  text-align: center;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
}

.vk-result h1 {
  margin-top: 0;
}

.vk-score {
  font-size: 22px;
  font-weight: 800;
  margin: 12px 0 18px;
}

.vk-result .btn {
  display: block;
  margin: 8px auto;
}

.search-form-filters {
  flex-wrap: wrap;
}

.search-form-filters select.search-input {
  min-width: 160px;
  flex: 0 1 auto;
}

@media (max-width: 768px) {
  .onboarding-steps {
    grid-template-columns: 1fr;
  }

  .search-form-filters select.search-input {
    min-width: 0;
    width: 100%;
  }
}

@media (max-width: 768px) {
  .dashboard-actions {
    grid-template-columns: 1fr;
  }

  .dashboard-next .btn {
    width: 100%;
  }
}

/* --- Task focus mode --- */
body.task-mode .mobile-nav {
  display: none !important;
}

body.task-mode .task-card {
  overflow: visible;
}

.exam-head {
  position: sticky;
  top: 0;
  z-index: 55;
  padding: 10px 0;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.exam-palette {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 0 14px;
}

.exam-palette-label {
  font-size: 13px;
  color: var(--fg-muted);
  margin-right: 2px;
}

.exam-dot {
  width: 28px;
  height: 28px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--card);
  color: var(--fg-muted);
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
}

.exam-dot:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.exam-dot-answered {
  background: rgba(22, 163, 74, 0.15);
  border-color: var(--ok);
  color: var(--ok);
}

.exam-dot-skipped {
  background: rgba(202, 138, 4, 0.15);
  border-color: var(--warn);
  color: var(--warn);
}

.exam-dot-current {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.exam-palette-count {
  margin-left: auto;
  font-size: 12px;
  color: var(--fg-muted);
}

.choice {
  position: relative;
}

.choice:has(input:checked) {
  border-color: var(--accent);
  background: rgba(37, 99, 235, 0.08);
  box-shadow: 0 0 0 1px var(--accent) inset;
}

.choice:has(input:checked) .choice-key {
  background: var(--accent);
  color: #fff;
}

.choice:focus-within {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
}

@media (max-width: 768px) {
  body.task-mode main {
    padding-bottom: 104px;
  }

  body.task-mode .cookie-banner {
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  }

  .task-mode .answer-actions {
    position: sticky;
    bottom: 0;
    z-index: 60;
    margin: 4px -16px 0;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
    background: var(--card);
    border-top: 1px solid var(--border);
  }

  .task-mode .skip-form {
    margin-bottom: 8px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .dashboard-action-card,
  .choice,
  .btn {
    transition: none !important;
  }
}

/* --- Двухколоночный герой с демо-задачей --- */
.hero {
  text-align: left;
  padding: 56px 24px 64px;
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(300px, 0.9fr);
  gap: 40px;
  align-items: center;
  max-width: 1050px;
  margin: 0 auto;
}

.hero-content h1 {
  font-size: clamp(34px, 4vw, 52px);
  line-height: 1.08;
  margin-bottom: 20px;
}

.hero-content p {
  margin: 0 0 24px;
  max-width: 620px;
}

.hero-content .hero-trust {
  justify-content: flex-start;
}

.hero-content .hero-actions {
  margin: 18px 0 0;
  max-width: 620px;
}

.hero-demo {
  padding: 26px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: var(--shadow-lg);
}

.hero-demo-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.hero-demo-badge {
  display: inline-block;
  padding: 5px 9px;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.1);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}

.hero-demo-free {
  font-size: 12px;
  color: var(--fg-muted);
}

.hero-demo h2 {
  margin: 0 0 18px;
  font-size: 24px;
  line-height: 1.25;
}

.hero-demo-options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.hero-demo-option {
  padding: 14px 8px;
  border: 2px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
  color: var(--fg);
  font: inherit;
  font-size: 20px;
  font-weight: 700;
  cursor: pointer;
}

.hero-demo-option:hover:not(:disabled) {
  border-color: var(--accent);
}

.hero-demo-option.is-correct {
  border-color: var(--ok);
  background: rgba(22, 163, 74, 0.1);
  color: var(--ok);
}

.hero-demo-option.is-wrong {
  border-color: var(--err);
  background: rgba(220, 38, 38, 0.1);
  color: var(--err);
}

.hero-demo-option:disabled {
  cursor: default;
}

.hero-demo-feedback {
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
}

.hero-demo-feedback.is-correct {
  background: rgba(22, 163, 74, 0.1);
  color: var(--ok);
}

.hero-demo-feedback.is-wrong {
  background: rgba(220, 38, 38, 0.1);
  color: var(--err);
}

.hero-demo-link {
  display: inline-block;
  margin-top: 16px;
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
  font-size: 14px;
}

.hero-demo-link:hover {
  text-decoration: underline;
}

@media (max-width: 900px) {
  .hero {
    text-align: center;
    padding: 40px 18px 48px;
  }

  .hero-grid {
    grid-template-columns: 1fr;
    gap: 28px;
  }

  .hero-content h1 {
    margin-left: auto;
    margin-right: auto;
  }

  .hero-content p {
    margin-left: auto;
    margin-right: auto;
  }

  .hero-content .hero-trust {
    justify-content: center;
  }

  .hero-content .hero-actions {
    margin-left: auto;
    margin-right: auto;
  }

  .hero-demo {
    max-width: 520px;
    margin: 0 auto;
    text-align: left;
  }
}