/* === ОСНОВНЫЕ ПЕРЕМЕННЫЕ === */
:root {
  --bg: #f6f8fb;
  --bg-card: #ffffff;
  --bg-sidebar: #ffffff;
  --bg-hover: #f0f4f9;
  --text: #1a2332;
  --text-muted: #5a6a7e;
  --text-light: #8a98ab;
  --primary: #2563eb;
  --primary-dark: #1e40af;
  --primary-light: #dbeafe;
  --accent: #0ea5e9;
  --success: #16a34a;
  --success-light: #dcfce7;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --border: #e5e9f0;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
  --shadow: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 10px 30px rgba(0,0,0,0.12);
  --radius: 12px;
  --radius-sm: 8px;
  --sidebar-w: 260px;
  --topbar-h: 64px;
  --transition: 0.2s ease;
}

[data-theme="dark"] {
  --bg: #0f172a;
  --bg-card: #1e293b;
  --bg-sidebar: #1a2333;
  --bg-hover: #273449;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --text-light: #64748b;
  --primary: #3b82f6;
  --primary-light: #1e3a8a;
  --border: #334155;
  --shadow: 0 4px 12px rgba(0,0,0,0.3);
  --shadow-lg: 0 10px 30px rgba(0,0,0,0.5);
}

/* === БАЗОВЫЕ === */
* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", "PT Sans", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }

a { color: var(--primary); text-decoration: none; }

/* === TOPBAR === */
.topbar {
  height: var(--topbar-h);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: fixed;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.topbar-left, .topbar-right { display: flex; align-items: center; gap: 16px; }

.brand { display: flex; align-items: center; gap: 12px; }
.brand-icon { font-size: 28px; }
.brand-title { font-size: 16px; font-weight: 700; }
.brand-sub { font-size: 12px; color: var(--text-muted); }

.hamburger { display: none; font-size: 24px; padding: 8px 12px; border-radius: 8px; }
.hamburger:hover { background: var(--bg-hover); }

.progress-block {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 16px;
  background: var(--bg-hover);
  border-radius: 100px;
}
.progress-label { font-size: 12px; color: var(--text-muted); font-weight: 500; }
.progress-bar {
  width: 140px; height: 6px;
  background: var(--border);
  border-radius: 100px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: 100px;
  width: 0%;
  transition: width 0.5s ease;
}
.progress-percent { font-size: 12px; font-weight: 600; color: var(--primary); min-width: 36px; }

.theme-toggle {
  font-size: 20px;
  width: 40px; height: 40px;
  border-radius: 10px;
  transition: var(--transition);
}
.theme-toggle:hover { background: var(--bg-hover); }

/* === SIDEBAR === */
.sidebar {
  position: fixed;
  top: var(--topbar-h);
  left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 90;
  transition: transform 0.3s ease;
}

.sidebar nav { padding: 16px 12px; flex: 1; }

.nav-section {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-light);
  padding: 16px 12px 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  transition: var(--transition);
  margin-bottom: 2px;
}
.nav-item:hover { background: var(--bg-hover); }
.nav-item.active {
  background: var(--primary-light);
  color: var(--primary);
}
[data-theme="dark"] .nav-item.active { color: #fff; background: var(--primary); }
.nav-ico { font-size: 18px; width: 24px; text-align: center; }
.nav-badge {
  margin-left: auto;
  background: var(--primary);
  color: #fff;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 100px;
  font-weight: 600;
}

.sidebar-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  color: var(--text-light);
  font-size: 12px;
}

/* === CONTENT === */
.content {
  margin-left: var(--sidebar-w);
  margin-top: var(--topbar-h);
  padding: 32px 48px;
  min-height: calc(100vh - var(--topbar-h));
  max-width: 1200px;
}

.page { display: none; }
.page.active { display: block; animation: fadeIn 0.3s ease; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.page-header { margin-bottom: 32px; }
.page-header h1 { font-size: 32px; font-weight: 800; margin-bottom: 8px; }
.page-header p { color: var(--text-muted); font-size: 16px; }

/* === ГЛАВНАЯ === */
.hero {
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  color: #fff;
  padding: 48px 40px;
  border-radius: var(--radius);
  margin-bottom: 32px;
  position: relative;
  overflow: hidden;
}
.hero::before {
  content: '';
  position: absolute;
  top: -50%; right: -10%;
  width: 400px; height: 400px;
  background: rgba(255,255,255,0.1);
  border-radius: 50%;
}
.hero h1 { font-size: 36px; font-weight: 800; margin-bottom: 12px; position: relative; }
.hero-sub { font-size: 17px; opacity: 0.95; margin-bottom: 24px; max-width: 700px; position: relative; }
.hero-actions { display: flex; gap: 12px; position: relative; }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}
.card {
  background: var(--bg-card);
  padding: 24px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: var(--transition);
  position: relative;
}
.card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary);
}
.card-icon { font-size: 32px; margin-bottom: 12px; }
.card h3 { font-size: 18px; margin-bottom: 8px; }
.card p { font-size: 14px; color: var(--text-muted); margin-bottom: 12px; }
.card-meta { font-size: 12px; color: var(--primary); font-weight: 600; }

.info-block {
  background: var(--bg-card);
  padding: 32px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.info-block h3 { font-size: 20px; margin-bottom: 16px; }
.info-block p { margin-bottom: 12px; color: var(--text-muted); }
.info-block ul { margin-left: 24px; margin-top: 8px; }
.info-block li { margin-bottom: 6px; color: var(--text-muted); }

/* === КНОПКИ === */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  transition: var(--transition);
  border: 1px solid transparent;
}
.btn-primary {
  background: #fff;
  color: var(--primary);
}
.btn-primary:hover { background: #f0f4f9; }

.btn-secondary {
  background: rgba(255,255,255,0.15);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.3);
  backdrop-filter: blur(8px);
}
.btn-secondary:hover { background: rgba(255,255,255,0.25); }

.btn-blue {
  background: var(--primary);
  color: #fff;
}
.btn-blue:hover { background: var(--primary-dark); }

.btn-success {
  background: var(--success);
  color: #fff;
}
.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-outline {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-outline:hover { background: var(--bg-hover); }

.btn-sm { padding: 6px 12px; font-size: 12px; }

/* === ТЕОРИЯ === */
.theory-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 24px;
}

.theory-toc {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 16px;
  height: fit-content;
  position: sticky;
  top: calc(var(--topbar-h) + 24px);
  max-height: calc(100vh - var(--topbar-h) - 48px);
  overflow-y: auto;
}
.theory-toc-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text-muted);
  transition: var(--transition);
}
.theory-toc-item:hover { background: var(--bg-hover); color: var(--text); }
.theory-toc-item.active { background: var(--primary-light); color: var(--primary); font-weight: 600; }
.theory-toc-num {
  width: 22px; height: 22px;
  background: var(--border);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700;
  flex-shrink: 0;
}
.theory-toc-item.active .theory-toc-num { background: var(--primary); color: #fff; }
.theory-toc-check { margin-left: auto; color: var(--success); font-size: 14px; }

.theory-content {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 32px 40px;
}

.theory-section { display: none; }
.theory-section.active { display: block; animation: fadeIn 0.3s; }

.theory-section h2 {
  font-size: 24px;
  margin-bottom: 16px;
  color: var(--text);
  display: flex; align-items: center; gap: 12px;
}
.theory-section h3 { font-size: 17px; margin: 20px 0 8px; color: var(--primary); }
.theory-section h4 { font-size: 15px; margin: 16px 0 6px; }
.theory-section p { margin-bottom: 12px; color: var(--text-muted); }
.theory-section ul, .theory-section ol { margin: 8px 0 12px 24px; color: var(--text-muted); }
.theory-section li { margin-bottom: 4px; }
.theory-section strong { color: var(--text); }

.theory-box {
  background: var(--primary-light);
  border-left: 4px solid var(--primary);
  padding: 16px 20px;
  border-radius: var(--radius-sm);
  margin: 16px 0;
}
.theory-box.warning { background: var(--warning-light); border-color: var(--warning); }
.theory-box.danger { background: var(--danger-light); border-color: var(--danger); }
.theory-box.success { background: var(--success-light); border-color: var(--success); }
.theory-box-title { font-weight: 700; margin-bottom: 4px; color: var(--text); }
.theory-box p { color: var(--text); margin: 0; }

.theory-table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: 14px;
}
.theory-table th, .theory-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.theory-table th {
  background: var(--bg-hover);
  font-weight: 700;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--text-muted);
}
.theory-table tbody tr:hover { background: var(--bg-hover); }

.theory-mark-read {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  display: flex; gap: 12px; align-items: center;
}
.theory-mark-read input { width: 18px; height: 18px; cursor: pointer; }
.theory-mark-read label { cursor: pointer; user-select: none; font-size: 14px; color: var(--text-muted); }

.theory-nav {
  display: flex; justify-content: space-between; margin-top: 24px;
}

/* === ПРИМЕРЫ === */
.examples-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.examples-tab {
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  transition: var(--transition);
}
.examples-tab:hover { background: var(--bg-hover); }
.examples-tab.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.examples-content { display: none; }
.examples-content.active { display: block; animation: fadeIn 0.3s; }

.example-block {
  background: var(--bg-card);
  padding: 24px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-bottom: 16px;
}
.example-block h3 { font-size: 18px; margin-bottom: 12px; color: var(--text); }
.example-block p { color: var(--text-muted); margin-bottom: 12px; }

.example-params {
  background: var(--bg-hover);
  padding: 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
}
.example-param-row {
  display: grid;
  grid-template-columns: 1fr 100px;
  gap: 12px;
  align-items: center;
  margin-bottom: 8px;
}
.example-param-row:last-child { margin-bottom: 0; }
.example-param-row label { font-size: 13px; color: var(--text-muted); }
.example-param-row input {
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  font-size: 13px;
  text-align: right;
  font-weight: 600;
  font-family: inherit;
}

.example-data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin: 12px 0;
}
.example-data-table th, .example-data-table td {
  padding: 8px 10px;
  border: 1px solid var(--border);
  text-align: left;
}
.example-data-table th { background: var(--bg-hover); font-weight: 700; font-size: 12px; }
.example-data-table td.numeric { text-align: right; font-variant-numeric: tabular-nums; }

.corrections-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin: 12px 0;
}
.corrections-table th, .corrections-table td {
  padding: 8px;
  border: 1px solid var(--border);
  text-align: center;
}
.corrections-table th { background: var(--bg-hover); font-weight: 700; }
.corrections-table td.numeric { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.corrections-table td.label { text-align: left; color: var(--text-muted); }
.corrections-table .positive { color: var(--success); }
.corrections-table .negative { color: var(--danger); }

.example-result {
  background: var(--success-light);
  border: 1px solid var(--success);
  padding: 16px 20px;
  border-radius: var(--radius-sm);
  margin-top: 16px;
}
.example-result-title { font-size: 13px; color: var(--text-muted); margin-bottom: 4px; }
.example-result-value { font-size: 24px; font-weight: 800; color: var(--success); }

/* === ЗАДАНИЯ === */
.tasks-list { display: flex; flex-direction: column; gap: 16px; }

.task {
  background: var(--bg-card);
  padding: 24px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  transition: var(--transition);
}
.task.completed { border-left-color: var(--success); }
.task.failed { border-left-color: var(--danger); }
.task h3 {
  font-size: 18px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.task-badge {
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 100px;
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.task-badge.basic { background: #dbeafe; color: #1d4ed8; }
.task-badge.medium { background: #fef3c7; color: #b45309; }
.task-badge.advanced { background: #fee2e2; color: #b91c1c; }

.task-desc { color: var(--text-muted); margin-bottom: 16px; }

.task-data {
  background: var(--bg-hover);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 13px;
  overflow-x: auto;
}
.task-data table { width: 100%; border-collapse: collapse; }
.task-data th, .task-data td {
  padding: 6px 10px;
  border: 1px solid var(--border);
  text-align: left;
}
.task-data th { background: var(--bg-card); font-size: 12px; }
.task-data td.numeric { text-align: right; font-variant-numeric: tabular-nums; }

.task-input-block {
  display: flex;
  gap: 12px;
  align-items: end;
  margin: 12px 0;
  flex-wrap: wrap;
}
.task-input-field { display: flex; flex-direction: column; gap: 4px; }
.task-input-field label { font-size: 12px; color: var(--text-muted); font-weight: 600; }
.task-input-field input {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  width: 200px;
  font-weight: 600;
  font-family: inherit;
}
.task-input-field input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.task-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

.task-feedback {
  margin-top: 16px;
  padding: 16px;
  border-radius: var(--radius-sm);
  display: none;
}
.task-feedback.show { display: block; animation: fadeIn 0.3s; }
.task-feedback.success { background: var(--success-light); border-left: 3px solid var(--success); }
.task-feedback.error { background: var(--danger-light); border-left: 3px solid var(--danger); }
.task-feedback-title { font-weight: 700; margin-bottom: 8px; display: flex; gap: 8px; align-items: center; }
.task-feedback p { color: var(--text); margin: 6px 0; font-size: 14px; }
.task-feedback ul { margin: 8px 0 8px 24px; font-size: 13px; }
.task-feedback li { margin-bottom: 4px; }

.task-solution {
  margin-top: 16px;
  padding: 16px;
  background: var(--bg-hover);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--primary);
  display: none;
}
.task-solution.show { display: block; animation: fadeIn 0.3s; }
.task-solution h4 { font-size: 14px; margin-bottom: 8px; color: var(--primary); }
.task-solution p { font-size: 13px; margin-bottom: 8px; color: var(--text); }
.task-solution .step { margin-bottom: 8px; }
.task-solution .step-num {
  display: inline-block;
  width: 22px; height: 22px;
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
  text-align: center;
  font-size: 12px;
  line-height: 22px;
  font-weight: 700;
  margin-right: 6px;
}

.task-checkboxes { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; }
.task-checkboxes label {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
}
.task-checkboxes label:hover { background: var(--bg-hover); }
.task-checkboxes input { width: 18px; height: 18px; }
.task-checkboxes label.checked-correct { background: var(--success-light); border-color: var(--success); }
.task-checkboxes label.checked-wrong { background: var(--danger-light); border-color: var(--danger); }

/* === КАЛЬКУЛЯТОР === */
.calc-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}
.calc-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}
.calc-card h3 { font-size: 18px; margin-bottom: 16px; }

.calc-field {
  display: flex; flex-direction: column; gap: 6px;
  margin-bottom: 12px;
}
.calc-field label { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.3px; }
.calc-field input, .calc-field select {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  font-variant-numeric: tabular-nums;
}
.calc-field input:focus, .calc-field select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.calc-analog {
  background: var(--bg);
  padding: 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  border: 1px solid var(--border);
  position: relative;
}
.calc-analog-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 12px;
}
.calc-analog-title { font-weight: 700; font-size: 14px; }
.calc-analog-remove {
  background: var(--danger-light);
  color: var(--danger);
  width: 28px; height: 28px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 700;
}
.calc-row {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 8px;
  align-items: center;
  margin-bottom: 6px;
  font-size: 12px;
}
.calc-row.header { font-weight: 700; color: var(--text-muted); font-size: 11px; text-transform: uppercase; }
.calc-row input {
  padding: 5px 8px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  font-size: 12px;
  text-align: right;
  font-family: inherit;
  font-variant-numeric: tabular-nums;
}
.calc-row .label-cell { color: var(--text-muted); }

.calc-result-block {
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  color: #fff;
  padding: 24px;
  border-radius: var(--radius);
  margin-top: 16px;
  text-align: center;
}
.calc-result-block .label { font-size: 13px; opacity: 0.9; margin-bottom: 4px; }
.calc-result-block .value { font-size: 36px; font-weight: 800; }

@media (max-width: 900px) {
  .calc-grid { grid-template-columns: 1fr; }
}

/* === ПРОГРЕСС === */
.progress-dashboard {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
}
.stat-card-icon { font-size: 36px; margin-bottom: 8px; }
.stat-card-value { font-size: 32px; font-weight: 800; color: var(--primary); }
.stat-card-label { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.progress-actions { text-align: center; margin-top: 32px; }

/* === МОДАЛКА === */
.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  display: none;
  align-items: center; justify-content: center;
  z-index: 1000;
  padding: 24px;
}
.modal.show { display: flex; }
.modal-box {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 32px;
  max-width: 500px; width: 100%;
  box-shadow: var(--shadow-lg);
}
.modal-title { font-size: 20px; font-weight: 700; margin-bottom: 12px; }
.modal-body { color: var(--text-muted); margin-bottom: 24px; }
.modal-actions { text-align: right; }

/* === TOAST === */
.toast {
  position: fixed;
  bottom: 24px; right: 24px;
  background: var(--text);
  color: var(--bg-card);
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  transform: translateX(150%);
  transition: transform 0.3s ease;
  z-index: 1100;
}
.toast.show { transform: translateX(0); }
.toast.success { background: var(--success); color: #fff; }
.toast.error { background: var(--danger); color: #fff; }

/* === MOBILE === */
@media (max-width: 768px) {
  .hamburger { display: block; }
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .content { margin-left: 0; padding: 24px 16px; }
  .theory-layout { grid-template-columns: 1fr; }
  .theory-toc { position: static; }
  .hero h1 { font-size: 26px; }
  .hero { padding: 32px 24px; }
  .page-header h1 { font-size: 24px; }
  .brand-sub { display: none; }
  .progress-label { display: none; }
  .progress-bar { width: 80px; }
}

/* === АДАПТИВНОСТЬ ТАБЛИЦ === */
@media (max-width: 600px) {
  .example-data-table, .corrections-table, .theory-table, .task-data table {
    font-size: 11px;
  }
  .example-data-table th, .example-data-table td,
  .corrections-table th, .corrections-table td,
  .theory-table th, .theory-table td,
  .task-data th, .task-data td {
    padding: 5px 6px;
  }
}

/* Scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-light); }

/* === ПОДВАЛ === */
.app-footer {
  text-align: center;
  padding: 20px 24px;
  margin: 40px 0 0 0;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
  box-sizing: border-box;
}

.app-footer::before {
  content: '';
  display: block;
  width: 60px;
  height: 2px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  margin: 0 auto 12px;
  border-radius: 2px;
}

[data-theme="dark"] .app-footer {
  background: var(--bg-sidebar);
}

/* === ФУТЕР С КНОПКОЙ === */
.app-footer-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 1200px;
  margin: 0 auto;
  flex-wrap: wrap;
}
.app-footer-text {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}
.app-footer-btn {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  padding: 8px 18px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  transition: var(--transition);
  border: none;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25);
}
.app-footer-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
}

/* === ДЕМО МОДАЛКА === */
.demo-modal {
  align-items: center;
  justify-content: center;
}
.demo-box {
  background: var(--bg-card);
  border-radius: 16px;
  padding: 0;
  max-width: 760px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
  animation: slideUp 0.3s ease;
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
.demo-close {
  position: absolute;
  top: 12px; right: 16px;
  background: transparent;
  color: var(--text-muted);
  font-size: 28px;
  line-height: 1;
  padding: 4px 10px;
  border-radius: 6px;
  z-index: 10;
  transition: var(--transition);
}
.demo-close:hover {
  background: var(--bg-hover);
  color: var(--text);
}
.demo-header {
  padding: 24px 32px 16px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.05), rgba(14, 165, 233, 0.05));
}
.demo-step-indicator {
  display: inline-block;
  background: var(--primary);
  color: #fff;
  padding: 4px 12px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 8px;
}
.demo-header h2 {
  font-size: 22px;
  margin: 0;
  color: var(--text);
}
.demo-body {
  padding: 28px 32px;
  overflow-y: auto;
  flex: 1;
  font-size: 15px;
  line-height: 1.7;
  color: var(--text);
}
.demo-body h3 {
  font-size: 17px;
  margin: 0 0 12px;
  color: var(--primary);
}
.demo-body p {
  margin-bottom: 12px;
  color: var(--text);
}
.demo-body strong {
  color: var(--text);
  font-weight: 700;
}
.demo-body ul, .demo-body ol {
  margin: 12px 0 12px 24px;
}
.demo-body li {
  margin-bottom: 8px;
  color: var(--text);
}
.demo-body .demo-note {
  background: var(--primary-light);
  border-left: 3px solid var(--primary);
  padding: 12px 16px;
  border-radius: 8px;
  margin: 16px 0;
  font-size: 14px;
}
.demo-body .demo-result {
  background: linear-gradient(135deg, #dcfce7, #bbf7d0);
  border: 1px solid #16a34a;
  color: #14532d;
  padding: 16px 20px;
  border-radius: 10px;
  margin-top: 16px;
  font-size: 16px;
  text-align: center;
}
[data-theme="dark"] .demo-body .demo-result {
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.15), rgba(34, 197, 94, 0.25));
  color: #bbf7d0;
}
.demo-body .demo-result strong {
  color: #15803d;
  font-size: 20px;
}
[data-theme="dark"] .demo-body .demo-result strong {
  color: #4ade80;
}
.demo-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 14px;
}
.demo-body table th, .demo-body table td {
  padding: 8px 12px;
  border: 1px solid var(--border);
  text-align: left;
}
.demo-body table th {
  background: var(--bg-hover);
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.demo-body table td.numeric {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
.demo-body table tr.highlight {
  background: rgba(37, 99, 235, 0.1);
}
.demo-body .step-badge {
  display: inline-block;
  background: var(--primary);
  color: #fff;
  width: 24px; height: 24px;
  border-radius: 50%;
  text-align: center;
  line-height: 24px;
  font-size: 13px;
  font-weight: 700;
  margin-right: 8px;
  vertical-align: middle;
}
.demo-nav {
  padding: 16px 32px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--bg);
}
.demo-dots {
  display: flex;
  gap: 6px;
  flex: 1;
  justify-content: center;
}
.demo-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--border);
  cursor: pointer;
  transition: var(--transition);
}
.demo-dot.active {
  background: var(--primary);
  width: 24px;
  border-radius: 4px;
}
.demo-dot.done {
  background: var(--accent);
}
.demo-actions-final {
  display: none;
  text-align: center;
  margin-top: 20px;
}
.demo-actions-final.show {
  display: block;
}
.demo-step-content {
  display: none;
}
.demo-step-content.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

@media (max-width: 600px) {
  .demo-box { max-height: 95vh; }
  .demo-header { padding: 20px 20px 12px; }
  .demo-body { padding: 20px; font-size: 14px; }
  .demo-nav { padding: 12px 20px; flex-wrap: wrap; }
  .app-footer-content { justify-content: center; text-align: center; }
}

/* === КНОПКА ДЕМО В САЙДБАРЕ === */
.nav-item-demo {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.1), rgba(14, 165, 233, 0.1));
  border: 1px solid rgba(37, 99, 235, 0.2);
  color: var(--primary);
  font-weight: 600;
  margin: 4px 0 8px;
  cursor: pointer;
  width: 100%;
  text-align: left;
  font-family: inherit;
  font-size: 14px;
  position: relative;
  overflow: hidden;
}
.nav-item-demo:hover {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.18), rgba(14, 165, 233, 0.18));
  border-color: var(--primary);
  transform: translateX(2px);
}
.nav-item-demo .nav-ico {
  font-size: 16px;
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}
.nav-item-demo::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: linear-gradient(180deg, var(--primary), var(--accent));
  border-radius: 0 2px 2px 0;
}
[data-theme="dark"] .nav-item-demo {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.2), rgba(14, 165, 233, 0.2));
  color: #93c5fd;
}
[data-theme="dark"] .nav-item-demo:hover {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.3), rgba(14, 165, 233, 0.3));
}

/* === КНОПКА АУДИО В САЙДБАРЕ === */
.nav-item-audio {
  background: linear-gradient(135deg, rgba(168, 85, 247, 0.1), rgba(236, 72, 153, 0.1));
  border: 1px solid rgba(168, 85, 247, 0.25);
  color: #a855f7;
  font-weight: 600;
  margin: 4px 0 4px;
  cursor: pointer;
  width: 100%;
  text-align: left;
  font-family: inherit;
  font-size: 14px;
  position: relative;
  overflow: hidden;
  transition: var(--transition);
}
.nav-item-audio:hover {
  background: linear-gradient(135deg, rgba(168, 85, 247, 0.18), rgba(236, 72, 153, 0.18));
  border-color: #a855f7;
  transform: translateX(2px);
}
.nav-item-audio::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: linear-gradient(180deg, #a855f7, #ec4899);
  border-radius: 0 2px 2px 0;
}
.nav-item-audio.playing {
  background: linear-gradient(135deg, rgba(168, 85, 247, 0.3), rgba(236, 72, 153, 0.3));
  color: #fff;
  border-color: #a855f7;
}
[data-theme="dark"] .nav-item-audio {
  background: linear-gradient(135deg, rgba(168, 85, 247, 0.2), rgba(236, 72, 153, 0.2));
  color: #c084fc;
}
[data-theme="dark"] .nav-item-audio:hover {
  background: linear-gradient(135deg, rgba(168, 85, 247, 0.3), rgba(236, 72, 153, 0.3));
}

/* === МИНИ-ПЛЕЕР === */
.mini-player {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.15);
  padding: 12px 14px;
  display: none;
  align-items: center;
  gap: 12px;
  z-index: 200;
  min-width: 320px;
  max-width: 400px;
  animation: slideUpFade 0.3s ease;
}
@keyframes slideUpFade {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
.mini-player.show {
  display: flex;
}
.mini-player-play {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, #a855f7, #ec4899);
  color: #fff;
  font-size: 18px;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: var(--transition);
  border: none;
  cursor: pointer;
}
.mini-player-play:hover {
  transform: scale(1.05);
}
.mini-player-info {
  flex: 1;
  min-width: 0;
}
.mini-player-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mini-player-progress {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 4px;
  cursor: pointer;
}
.mini-player-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #a855f7, #ec4899);
  width: 0%;
  transition: width 0.2s linear;
  border-radius: 2px;
}
.mini-player-time {
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.mini-player-close {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--bg-hover);
  color: var(--text-muted);
  font-size: 18px;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  line-height: 1;
  border: none;
  cursor: pointer;
  transition: var(--transition);
}
.mini-player-close:hover {
  background: var(--danger-light);
  color: var(--danger);
}

@media (max-width: 600px) {
  .mini-player {
    left: 16px; right: 16px;
    bottom: 16px;
    min-width: auto;
  }
}

/* === КНОПКА ДЕБАТЫ В САЙДБАРЕ === */
.nav-item-debates {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.1), rgba(249, 115, 22, 0.1));
  border: 1px solid rgba(239, 68, 68, 0.25);
  color: #ef4444;
  font-weight: 600;
  margin: 4px 0 4px;
  cursor: pointer;
  width: 100%;
  text-align: left;
  font-family: inherit;
  font-size: 14px;
  position: relative;
  overflow: hidden;
  transition: var(--transition);
}
.nav-item-debates:hover {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.18), rgba(249, 115, 22, 0.18));
  border-color: #ef4444;
  transform: translateX(2px);
}
.nav-item-debates::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: linear-gradient(180deg, #ef4444, #f97316);
  border-radius: 0 2px 2px 0;
}
.nav-item-debates.playing {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.3), rgba(249, 115, 22, 0.3));
  color: #fff;
  border-color: #ef4444;
}
.nav-item-video {
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.1), rgba(20, 184, 166, 0.1));
  border: 1px solid rgba(34, 197, 94, 0.25);
  color: #16a34a;
  font-weight: 600;
  margin: 4px 0 4px;
  cursor: pointer;
  width: 100%;
  text-align: left;
  font-family: inherit;
  font-size: 14px;
  position: relative;
  overflow: hidden;
  transition: var(--transition);
}
.nav-item-video:hover {
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.18), rgba(20, 184, 166, 0.18));
  border-color: #16a34a;
  transform: translateX(2px);
}
.nav-item-video::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: linear-gradient(180deg, #22c55e, #14b8a6);
  border-radius: 0 2px 2px 0;
}
.nav-item-video.playing {
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.3), rgba(20, 184, 166, 0.3));
  color: #fff;
  border-color: #16a34a;
}
[data-theme="dark"] .nav-item-video {
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.2), rgba(20, 184, 166, 0.2));
  color: #4ade80;
}
[data-theme="dark"] .nav-item-video:hover {
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.3), rgba(20, 184, 166, 0.3));
}
[data-theme="dark"] .nav-item-debates {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.2), rgba(249, 115, 22, 0.2));
  color: #fca5a5;
}
[data-theme="dark"] .nav-item-debates:hover {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.3), rgba(249, 115, 22, 0.3));
}


/* === Личный кабинет === */
.cabinet-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: linear-gradient(135deg, #3b6ee0 0%, #2563eb 100%);
  color: #fff !important;
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(59, 110, 224, 0.3);
  transition: all 0.2s ease;
  white-space: nowrap;
  margin-left: 8px;
}
.cabinet-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(59, 110, 224, 0.45);
  background: linear-gradient(135deg, #4a7eef 0%, #3573eb 100%);
  color: #fff !important;
}
.cabinet-btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 4px rgba(59, 110, 224, 0.3);
}
.cabinet-ico {
  font-size: 16px;
  line-height: 1;
}
/* На узких экранах — только иконка */
@media (max-width: 720px) {
  .cabinet-btn { padding: 8px 10px; }
  .cabinet-label { display: none; }
}
/* Тёмная тема — адаптация */
body.dark .cabinet-btn,
[data-theme="dark"] .cabinet-btn {
  background: linear-gradient(135deg, #2c4cb0 0%, #1e3a8a 100%);
  box-shadow: 0 2px 6px rgba(59, 110, 224, 0.4);
}
body.dark .cabinet-btn:hover,
[data-theme="dark"] .cabinet-btn:hover {
  background: linear-gradient(135deg, #3a5cc8 0%, #294aa3 100%);
}


/* === Личный кабинет — модалка === */
.course-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.18s ease-out;
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
.course-modal {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(15, 23, 42, 0.35);
  max-height: 92vh;
  overflow-y: auto;
  width: calc(100% - 32px);
  position: relative;
}
.btn-secondary {
  background: #f3f4f6;
  color: #1f2937;
  border: 1px solid #d1d5db;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.15s ease;
}
.btn-secondary:hover {
  background: #e5e7eb;
  border-color: #9ca3af;
}
.btn-primary {
  background: #2563eb;
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}
.btn-primary:hover {
  background: #1d4ed8;
}
.btn-primary:active {
  transform: translateY(1px);
}
.btn-primary:disabled,
.btn-secondary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Тёмная тема */
body.dark .modal,
[data-theme="dark"] .modal {
  background: #1e293b;
  color: #f1f5f9;
}
body.dark .modal-header,
[data-theme="dark"] .modal-header {
  background: #1e293b !important;
  border-bottom-color: #334155 !important;
}
body.dark .modal-header h2,
[data-theme="dark"] .modal-header h2 {
  color: #f1f5f9 !important;
}
body.dark .course-account-tab,
[data-theme="dark"] .course-account-tab {
  color: #94a3b8 !important;
}
body.dark .course-account-tab[style*="2563eb"] {
  color: #60a5fa !important;
  border-bottom-color: #60a5fa !important;
}
body.dark .course-account-tab:hover {
  color: #e2e8f0 !important;
}
body.dark input[type="email"],
body.dark input[type="password"],
body.dark input[type="text"],
[data-theme="dark"] input[type="email"],
[data-theme="dark"] input[type="password"],
[data-theme="dark"] input[type="text"] {
  background: #0f172a;
  color: #f1f5f9;
  border-color: #334155;
}
body.dark .btn-secondary,
[data-theme="dark"] .btn-secondary {
  background: #334155;
  color: #f1f5f9;
  border-color: #475569;
}
body.dark .btn-secondary:hover,
[data-theme="dark"] .btn-secondary:hover {
  background: #475569;
}
body.dark #course-account-info div,
[data-theme="dark"] #course-account-info div {
  background: #1e3a8a !important;
  border-color: #2563eb !important;
}
body.dark #course-account-info div span,
body.dark #course-account-info div b,
[data-theme="dark"] #course-account-info div span,
[data-theme="dark"] #course-account-info div b {
  color: #f1f5f9 !important;
}

/* === Модалка: Инструкция === */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 9999;
  align-items: flex-start;
  justify-content: center;
  padding: 30px 20px;
  overflow-y: auto;
}
.modal-overlay[hidden] {
  display: none !important;
}
.modal-overlay > .modal-panel {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  width: 100%;
  max-width: 820px;
  margin: 0 auto;
  animation: modal-pop 0.2s ease-out;
}
@keyframes modal-pop {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}
.modal-close {
  background: transparent;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #6b7280;
  padding: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.modal-close:hover {
  background: rgba(0, 0, 0, 0.05);
}

/* Тёмная тема */
body.theme-dark .modal-overlay > .modal-panel {
  background: #1e293b;
  color: #e2e8f0;
}
body.theme-dark .modal-overlay > .modal-panel h3 {
  color: #34d399;
}
