/* ==========================================================================
   Интерактивная образовательная платформа: Кинематика дифференциального робота
   Стилизация в современном инженерно-образовательном стиле
   ========================================================================== */

:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --primary-glow: rgba(37, 99, 235, 0.2);

  /* Цветовые маркеры компонентов робота */
  --motor-a: #2563eb;       /* Левый мотор А - ярко-синий */
  --motor-a-bg: #eff6ff;
  --motor-a-border: #93c5fd;

  --motor-b: #dc2626;       /* Правый мотор В - контрастный красный */
  --motor-b-bg: #fef2f2;
  --motor-b-border: #fca5a5;

  --marker: #8b5cf6;        /* Центральный маркер - фиолетовый */
  --marker-bg: #f5f3ff;
  --marker-border: #c4b5fd;

  --icr: #d97706;           /* МЦВ (Мгновенный центр вращения) - янтарный */
  --icr-bg: #fffbeb;
  --icr-border: #fcd34d;

  --success: #16a34a;
  --success-bg: #dcfce7;
  --warning: #d97706;
  --warning-bg: #fef3c7;
  --danger: #dc2626;

  --bg: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-glass: rgba(255, 255, 255, 0.92);
  --bg-dark: #0f172a;
  --bg-sidebar: #ffffff;
  --border: #e2e8f0;
  --border-dark: #334155;

  --text: #0f172a;
  --text-muted: #475569;
  --text-dim: #64748b;
  --text-light: #f8fafc;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', Consolas, Monaco, monospace;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.04);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
}

/* Базовые настройки */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg);
  background-image: 
    radial-gradient(at 0% 0%, rgba(37, 99, 235, 0.04) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(139, 92, 246, 0.04) 0px, transparent 50%);
  background-attachment: fixed;
  color: var(--text);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* Верхняя панель навигации */
.top-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--text);
}

.brand-badge {
  background: linear-gradient(135deg, #2563eb, #8b5cf6);
  color: white;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.2rem;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

.brand-text h1 {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: #0f172a;
  line-height: 1.2;
}

.brand-text span {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 500;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 8px;
  list-style: none;
}

.nav-item a {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
  transition: all 0.2s ease;
}

.nav-item a:hover {
  color: var(--primary);
  background: var(--primary-light);
}

.nav-item a.active {
  color: var(--primary);
  background: var(--primary-light);
  box-shadow: inset 0 0 0 1px var(--primary-glow);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-interactive-hub {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: white;
  font-size: 0.88rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  text-decoration: none;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
  transition: all 0.2s;
}

.btn-interactive-hub:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
}

/* Лейаут с боковым оглавлением */
.main-wrapper {
  max-width: 1440px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 2rem;
  padding: 2rem 1.5rem;
}

@media (max-width: 1080px) {
  .main-wrapper {
    grid-template-columns: 1fr;
  }
}

/* Сайдбар */
.sidebar-nav {
  position: sticky;
  top: 80px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
}

.sidebar-title {
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  margin-bottom: 0.75rem;
}

.sidebar-menu {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  transition: all 0.15s ease;
}

.sidebar-link:hover {
  color: var(--primary);
  background: var(--primary-light);
}

.sidebar-link.active {
  color: var(--primary);
  background: var(--primary-light);
  font-weight: 700;
  border-left: 3px solid var(--primary);
}

.sidebar-badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--border);
  color: var(--text-dim);
}

/* Контентная часть */
.content-area {
  min-width: 0;
}

/* Баннер Hero */
.hero-banner {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  border-radius: var(--radius-xl);
  color: white;
  padding: 3rem 2.5rem;
  margin-bottom: 2.5rem;
  box-shadow: var(--shadow-xl);
  position: relative;
  overflow: hidden;
}

.hero-banner::before {
  content: '';
  position: absolute;
  top: -50px;
  right: -50px;
  width: 300px;
  height: 300px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(37, 99, 235, 0.3) 0%, transparent 70%);
  pointer-events: none;
}

.hero-banner::after {
  content: '';
  position: absolute;
  bottom: -40px;
  left: 20%;
  width: 250px;
  height: 250px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(139, 92, 246, 0.25) 0%, transparent 70%);
  pointer-events: none;
}

.hero-tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 4px 14px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  color: #93c5fd;
  margin-bottom: 1.25rem;
  backdrop-filter: blur(8px);
}

.hero-title {
  font-size: 2.3rem;
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 1rem;
  letter-spacing: -0.02em;
}

.hero-title span {
  background: linear-gradient(90deg, #60a5fa, #c084fc);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-desc {
  font-size: 1.05rem;
  color: #cbd5e1;
  max-width: 780px;
  line-height: 1.7;
  margin-bottom: 1.75rem;
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-top: 2rem;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  padding-top: 1.75rem;
}

.stat-card {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 1rem 1.25rem;
  border-radius: var(--radius-md);
  backdrop-filter: blur(4px);
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 800;
  color: #38bdf8;
  font-family: var(--font-mono);
}

.stat-label {
  font-size: 0.82rem;
  color: #94a3b8;
  font-weight: 500;
  margin-top: 2px;
}

/* Секции контента */
.theory-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2.25rem;
  margin-bottom: 2.5rem;
  box-shadow: var(--shadow-sm);
  scroll-margin-top: 90px;
  transition: box-shadow 0.2s;
}

.theory-section:hover {
  box-shadow: var(--shadow-md);
}

.section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  border-bottom: 2px solid var(--border);
  padding-bottom: 1rem;
  flex-wrap: wrap;
  gap: 12px;
}

.section-badge-group {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.section-badge {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: 6px;
  letter-spacing: 0.05em;
}

.badge-blue { background: #dbeafe; color: #1d4ed8; }
.badge-red { background: #fee2e2; color: #b91c1c; }
.badge-purple { background: #f3e8ff; color: #7e22ce; }
.badge-amber { background: #fef3c7; color: #b45309; }
.badge-green { background: #dcfce7; color: #15803d; }

.section-title {
  font-size: 1.6rem;
  font-weight: 800;
  color: #0f172a;
  letter-spacing: -0.01em;
}

.section-subtitle {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Карточки параметров и обозначений */
.params-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin: 1.5rem 0;
}

.param-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  transition: all 0.2s ease;
}

.param-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.param-symbol {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-weight: 800;
  font-size: 1.15rem;
  flex-shrink: 0;
}

.symbol-blue { background: #eff6ff; color: var(--motor-a); border: 1px solid #bfdbfe; }
.symbol-red { background: #fef2f2; color: var(--motor-b); border: 1px solid #fecaca; }
.symbol-purple { background: #faf5ff; color: var(--marker); border: 1px solid #e9d5ff; }
.symbol-amber { background: #fffbeb; color: var(--icr); border: 1px solid #fde68a; }
.symbol-gray { background: #f1f5f9; color: var(--text-muted); border: 1px solid #cbd5e1; }

.param-info h4 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 2px;
}

.param-info p {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.4;
}

/* Блоки ключевых формул */
.formula-callout {
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  border: 1px solid #cbd5e1;
  border-left: 4px solid var(--primary);
  border-radius: var(--radius-md);
  padding: 1.25rem 1.5rem;
  margin: 1.5rem 0;
}

.formula-callout.accent-a {
  border-left-color: var(--motor-a);
  background: linear-gradient(135deg, #eff6ff 0%, #f8fafc 100%);
}

.formula-callout.accent-b {
  border-left-color: var(--motor-b);
  background: linear-gradient(135deg, #fef2f2 0%, #f8fafc 100%);
}

.formula-callout.accent-purple {
  border-left-color: var(--marker);
  background: linear-gradient(135deg, #faf5ff 0%, #f8fafc 100%);
}

.formula-callout.accent-amber {
  border-left-color: var(--icr);
  background: linear-gradient(135deg, #fffbeb 0%, #f8fafc 100%);
}

.formula-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.formula-title {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.formula-math {
  font-size: 1.15rem;
  overflow-x: auto;
  padding: 8px 0;
}

.formula-explanation {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-top: 6px;
  border-top: 1px dashed var(--border);
  padding-top: 6px;
}

/* Интерактивные SVG-схемы */
.svg-diagram-container {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin: 1.5rem 0;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.02);
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}

.diagram-caption {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  text-align: center;
  margin-top: 10px;
}

/* Контейнеры симуляторов и полигона */
.simulator-box {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin: 1.75rem 0;
  box-shadow: var(--shadow-md);
}

.simulator-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  gap: 10px;
}

.simulator-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.1rem;
  font-weight: 700;
  color: #0f172a;
}

.simulator-controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 1.25rem;
  background: var(--bg);
  padding: 1rem 1.25rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.control-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
}

.control-label span.val {
  font-family: var(--font-mono);
  color: var(--primary);
  font-weight: 700;
}

.range-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 4px;
  background: #cbd5e1;
  outline: none;
}

.range-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
  transition: transform 0.1s;
}

.range-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

.range-slider.slider-a::-webkit-slider-thumb { background: var(--motor-a); }
.range-slider.slider-b::-webkit-slider-thumb { background: var(--motor-b); }

.button-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-primary {
  background: var(--primary);
  color: white;
}
.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-outline {
  background: white;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-outline:hover {
  background: var(--bg);
  color: var(--text);
  border-color: #cbd5e1;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 0.78rem;
}

/* Canvas область отрисовки */
.canvas-wrapper {
  position: relative;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.03);
}

canvas.sim-canvas {
  display: block;
  width: 100%;
  background: #ffffff;
}

.canvas-overlay-telemetry {
  position: absolute;
  top: 12px;
  right: 12px;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(8px);
  color: white;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  line-height: 1.6;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: var(--shadow-md);
  pointer-events: none;
}

.canvas-overlay-telemetry .line-a { color: #60a5fa; }
.canvas-overlay-telemetry .line-b { color: #f87171; }
.canvas-overlay-telemetry .line-c { color: #c084fc; }
.canvas-overlay-telemetry .line-icr { color: #fbbf24; }

/* Карточки разобранных примеров (Worked Examples) */
.example-box {
  background: #ffffff;
  border: 1px solid var(--border);
  border-left: 4px solid #10b981;
  border-radius: var(--radius-md);
  padding: 1.5rem;
  margin: 1.5rem 0;
  box-shadow: var(--shadow-sm);
}

.example-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.example-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: #065f46;
  display: flex;
  align-items: center;
  gap: 8px;
}

.example-condition {
  font-size: 0.92rem;
  color: var(--text);
  line-height: 1.6;
  background: #f0fdf4;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  border: 1px solid #bbf7d0;
}

.example-steps {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}

.step-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 0.88rem;
}

.step-title {
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.example-answer {
  background: #ecfdf5;
  border: 1px solid #34d399;
  color: #064e3b;
  font-weight: 700;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Сравнительные таблицы */
.comparison-table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.88rem;
}

.comparison-table th, .comparison-table td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.comparison-table th {
  background: #f8fafc;
  font-weight: 700;
  color: var(--text);
  border-top: 1px solid var(--border);
}

.comparison-table tr:hover {
  background: #f8fafc;
}

/* Калькулятор кинематики */
.calculator-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-top: 1.25rem;
}

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

.calc-panel {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.5rem;
}

.calc-panel h3 {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 1rem;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.calc-input-group {
  margin-bottom: 12px;
}

.calc-input-group label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.calc-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.9rem;
  background: white;
}

.calc-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.calc-results {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem;
  margin-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.calc-result-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  padding-bottom: 6px;
  border-bottom: 1px dashed var(--border);
}

.calc-result-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.calc-result-row .res-val {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--primary);
}

/* Футер */
.platform-footer {
  border-top: 1px solid var(--border);
  background: #ffffff;
  padding: 2.5rem 1.5rem;
  margin-top: 4rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.88rem;
}

.platform-footer p {
  margin-bottom: 6px;
}

/* Понятный вход в тему и единое правило дуги */
section[id], div[id^="ch1-"], div[id^="sec2"] { scroll-margin-top: 92px; }
.learning-section { border-color: #bfdbfe; background: linear-gradient(145deg, #fff 0%, #f8fbff 100%); }
.concept-grid, .radius-cards { display:grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap:14px; margin:20px 0; }
.concept-card { padding:20px; border:1px solid #dbeafe; border-radius:16px; background:#fff; }
.concept-card h4 { font-size:1.05rem; color:#0f172a; margin:7px 0; }
.concept-card p { font-size:.93rem; color:#475569; }
.concept-icon { display:inline-grid; place-items:center; width:40px; height:40px; border-radius:12px; background:#dbeafe; color:#1e40af; font-size:1.4rem; font-weight:800; }
.concept-card:nth-child(2) .concept-icon { background:#ccfbf1; color:#0f766e; }
.route-demo { display:grid; grid-template-columns:minmax(0,1.15fr) minmax(250px,.85fr); gap:20px; align-items:center; margin:24px 0; }
.route-board { padding:10px; background:white; border:1px solid #dbeafe; border-radius:20px; box-shadow:var(--shadow-sm); }
.route-board svg { display:block; width:100%; height:auto; }
.route-controls p { margin-bottom:14px; }
.route-controls .button-bar { justify-content:flex-start; }
.route-choice.is-selected { background:#0f766e; color:#fff; border-color:#0f766e; }
.route-result, .note-strip { padding:14px 16px; border-radius:12px; background:#ecfdf5; color:#115e59; font-size:.93rem; margin-top:14px; }
.note-strip { margin-top:18px; }
.subsection-bridge { margin-top:2rem; padding:20px; border-radius:16px; background:#f8fafc; border:1px solid #e2e8f0; }
.subsection-bridge h4 { font-size:1.2rem; margin-bottom:8px; }
.subsection-bridge p { margin-bottom:16px; }
.master-rule { display:grid; grid-template-columns:1.1fr .9fr; gap:28px; padding:26px; margin:24px 0; border-radius:20px; background:#102a43; color:#fff; }
.master-rule h4 { font-size:1.5rem; margin:6px 0; color:#fff; }
.master-rule p { color:#dce9f4; font-size:.94rem; }
.master-rule .rule-math { font-size:1.65rem; font-weight:800; color:#fff; margin:12px 0; }
.master-rule .katex { color:inherit; }
.rule-kicker { color:#7dd3fc; font-size:.75rem; letter-spacing:.12em; text-transform:uppercase; font-weight:800; }
.rule-steps { display:grid; gap:10px; align-content:center; }
.rule-steps>div { display:flex; gap:12px; align-items:center; background:rgba(255,255,255,.09); border-radius:12px; padding:10px 12px; font-size:.9rem; }
.rule-steps b { display:grid; place-items:center; min-width:28px; height:28px; border-radius:50%; color:#102a43; background:#7dd3fc; }
.radius-cards { grid-template-columns:repeat(3,minmax(0,1fr)); }
.radius-cards>div { display:flex; flex-direction:column; gap:8px; padding:18px; border:1px solid #cbd5e1; border-top:4px solid #0f766e; border-radius:12px; background:#fff; }
.radius-cards>div:nth-child(2) { border-top-color:#f97316; }
.radius-cards>div:nth-child(3) { border-top-color:#8b5cf6; }
.radius-cards strong { color:#0f172a; }
.radius-cards span { color:#475569; font-size:.88rem; }
.compact-example { margin-top:18px; }
.advanced-details { margin-top:22px; padding:16px; border:1px solid #cbd5e1; border-radius:12px; background:#f8fafc; }
.advanced-details summary { cursor:pointer; font-weight:700; color:#1d4ed8; }
.advanced-details[open] summary { margin-bottom:16px; }
.graph-result { margin-top:12px; }
@media(max-width:800px) {
  .route-demo, .master-rule { grid-template-columns:1fr; }
  .radius-cards { grid-template-columns:1fr; }
  .concept-grid { grid-template-columns:1fr; }
  .master-rule { padding:20px; }
  .route-board svg { min-width:0; }
}

.mobile-toc { display:none; }
@media(max-width:1350px) {
  .top-header nav { display:none; }
  .top-header { min-height:62px; }
}
@media(max-width:1080px) {
  .sidebar-nav { display:none; }
  .mobile-toc { display:block; margin-bottom:16px; border:1px solid #bfdbfe; border-radius:12px; background:#fff; }
  .mobile-toc summary { cursor:pointer; padding:12px 16px; font-weight:700; color:#1d4ed8; }
  .mobile-toc nav { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:4px; padding:0 12px 12px; }
  .mobile-toc a { padding:8px; border-radius:6px; color:#334155; text-decoration:none; font-size:.85rem; }
  .mobile-toc a:hover { background:#eff6ff; }
}
@media(max-width:600px) {
  .top-header { padding:8px 14px; }
  .brand-text h1 { font-size:.92rem; }
  .brand-text span { font-size:.7rem; }
  .header-actions { display:none; }
  .main-wrapper { padding:14px 12px; gap:0; }
  .hero-banner { padding:24px 20px; margin-bottom:16px; }
  .hero-title { font-size:1.75rem; overflow-wrap:anywhere; }
  .hero-desc { font-size:.95rem; }
  .hero-stats { grid-template-columns:repeat(2,minmax(0,1fr)); gap:8px; }
  .stat-card { padding:12px; min-width:0; }
  .stat-value { font-size:1rem; }
  .stat-label { font-size:.72rem; }
  .theory-section { padding:20px 16px; margin-bottom:16px; }
  .section-title { overflow-wrap:anywhere; }
  .formula-math, .comparison-table { max-width:100%; overflow-x:auto; }
  .comparison-table { display:block; }
  .simulator-controls { grid-template-columns:1fr !important; }
  .simulator-box { padding:14px; }
  .route-controls .button-bar { gap:6px; }
  .route-board svg text { font-size:13px; }
}
@media(max-width:600px) {
  #sec23-cases { grid-template-columns:1fr !important; }
  .formula-callout, .example-box, .step-card { min-width:0; }
}
@media(max-width:600px) {
  html, body { overflow-x:clip; }
  .step-card, .formula-math, .formula-explanation { overflow-x:auto; }
}

/* После удаления двух меню учебник использует всю ширину страницы. */
.main-wrapper { max-width:1180px; grid-template-columns:minmax(0,1fr); }

/* Объяснение поворота на одном числовом примере */
.plain-rule { margin:20px 0; padding:18px 20px; background:#ecfdf5; border-left:4px solid #0f766e; border-radius:12px; color:#115e59; }
.turn-lesson { margin:24px 0; padding:22px; border:1px solid #bfdbfe; border-radius:20px; background:linear-gradient(145deg,#fff,#f8fbff); }
.turn-lesson-head { display:flex; align-items:flex-end; justify-content:space-between; gap:20px; margin-bottom:18px; }
.turn-lesson-head h4 { font-size:1.4rem; margin:8px 0; line-height:1.25; }
.turn-lesson-head p { color:#475569; font-size:.93rem; max-width:620px; }
.turn-case.is-selected { background:#1d4ed8; border-color:#1d4ed8; color:#fff; }
.turn-lesson-body { display:grid; grid-template-columns:minmax(0,1fr) minmax(265px,.82fr); gap:20px; align-items:center; }
.turn-picture { width:100%; display:block; border:1px solid #dbeafe; border-radius:16px; background:#fff; }
.turn-picture g[hidden] { display:none; }
.turn-explanation { min-width:0; }
.turn-step-buttons { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:8px; margin-bottom:18px; }
.turn-step { font:inherit; font-size:.84rem; font-weight:700; border:1px solid #cbd5e1; border-radius:10px; background:#fff; padding:10px; color:#334155; cursor:pointer; }
.turn-step.is-selected { color:#fff; background:#0f766e; border-color:#0f766e; }
.turn-explanation p { min-height:78px; color:#334155; }
.turn-step-result { font-weight:700; background:#dbeafe; color:#1e40af; padding:14px; border-radius:12px; }
.turn-lesson[data-step="1"] .radius-line, .turn-lesson[data-step="1"] .lesson-arc { opacity:.25; }
.turn-lesson[data-step="2"] .lesson-arc { opacity:.25; }
.turn-lesson[data-step="3"] .center-dot { opacity:.5; }
.turn-lesson[data-step="4"] .radius-line { opacity:.45; }
.rule-intro { font-size:1.05rem !important; line-height:1.6; }
.rule-details { margin-top:14px; }
.rule-details summary { cursor:pointer; color:#7dd3fc; font-weight:700; }
.rule-details[open] summary { margin-bottom:12px; }
.olympiad-chapter { margin-bottom:2.5rem; }
.olympiad-chapter>summary { font-size:1.05rem; }
.olympiad-chapter>.theory-section { margin:18px 0 0; }
@media(max-width:760px) {
  .turn-lesson-head, .turn-lesson-body { display:block; }
  .turn-lesson-head .button-bar { margin-top:12px; }
  .turn-picture { margin:14px 0; }
  .turn-explanation p { min-height:0; }
}

/* Переключатель тем, доступный и на узких экранах. */
.top-header { gap: 14px; }
.topic-nav { display:flex; align-items:center; gap:5px; flex-wrap:wrap; }
.topic-nav a { color:#334155; text-decoration:none; font-weight:700; font-size:.85rem; white-space:nowrap; padding:9px 12px; border-radius:9px; }
.topic-nav a:hover, .topic-nav a:focus-visible { background:#eff6ff; color:#1d4ed8; }
.topic-nav a[aria-current="page"] { background:#dbeafe; color:#1e40af; }
@media(max-width:1350px) { .top-header .topic-nav { display:flex; } }
@media(max-width:760px) {
  .top-header { flex-wrap:wrap; }
  .topic-nav { order:3; width:100%; }
  .topic-nav a { flex:1; text-align:center; font-size:.78rem; padding:8px 5px; }
}
