:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-2: #edf3f8;
  --text: #17202a;
  --muted: #5c6b78;
  --line: #d5e0e9;
  --primary: #156f82;
  --primary-strong: #0e5868;
  --accent: #e98b2a;
  --accent-soft: #fff0d9;
  --success: #19734b;
  --success-soft: #e1f5eb;
  --danger: #a33b35;
  --danger-soft: #fde9e7;
  --shadow: 0 18px 45px rgba(30, 56, 73, .11);
  --radius: 20px;
}

[data-theme="dark"] {
  --bg: #111a21;
  --surface: #19252e;
  --surface-2: #22323d;
  --text: #edf6fa;
  --muted: #adc0ca;
  --line: #334754;
  --primary: #4db2c5;
  --primary-strong: #76c9d8;
  --accent: #f2a64f;
  --accent-soft: #4a3420;
  --success: #69d5a4;
  --success-soft: #173d2d;
  --danger: #ff9a91;
  --danger-soft: #4c2828;
  --shadow: 0 18px 45px rgba(0, 0, 0, .28);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 10% 0%, color-mix(in srgb, var(--primary) 13%, transparent), transparent 31rem),
    var(--bg);
  font-family: "Segoe UI", Arial, sans-serif;
  line-height: 1.58;
}

button, input, select { font: inherit; }
button { cursor: pointer; }

h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { line-height: 1.18; }
strong { color: var(--text); }

.site-header {
  color: white;
  background: linear-gradient(120deg, #103f4b, #16798b 58%, #1b91a2);
  border-bottom: 4px solid var(--accent);
}

.header-inner {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  min-height: 126px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand { display: flex; align-items: center; gap: 18px; }
.brand-icon { width: 62px; height: 62px; flex: 0 0 auto; }
.brand h1 { margin: 0 0 4px; font-size: clamp(1.8rem, 4vw, 2.75rem); letter-spacing: -.035em; }
.brand p { margin: 0; color: #d9f3f7; }
.arrow-line, .ground-line { fill: none; stroke: #fff; stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; }
.ball { fill: #f2a64f; stroke: #fff; stroke-width: 3; }

.theme-toggle {
  width: 44px;
  height: 44px;
  border: 1px solid rgba(255,255,255,.5);
  border-radius: 50%;
  color: white;
  background: rgba(255,255,255,.12);
  font-size: 1.35rem;
}
.theme-toggle:hover { background: rgba(255,255,255,.22); }

.section-nav {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.nav-btn {
  border: 0;
  border-radius: 999px;
  padding: 10px 18px;
  color: var(--muted);
  background: transparent;
  font-weight: 700;
}
.nav-btn:hover { color: var(--primary); background: var(--surface-2); }
.nav-btn.active { color: white; background: var(--primary); }

.main-content {
  width: min(1180px, calc(100% - 32px));
  margin: 34px auto 60px;
}

.content-section { display: none; animation: appear .22s ease-out; }
.content-section.active { display: block; }
@keyframes appear { from { opacity: 0; transform: translateY(7px); } }

.eyebrow {
  display: inline-block;
  margin-bottom: 8px;
  color: var(--primary);
  font-weight: 800;
  font-size: .79rem;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.hero-card {
  display: grid;
  grid-template-columns: 1.25fr .75fr;
  gap: 28px;
  align-items: center;
  padding: clamp(24px, 5vw, 48px);
  border: 1px solid var(--line);
  border-radius: 28px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.hero-card h2 { margin-bottom: 12px; font-size: clamp(1.7rem, 4vw, 2.7rem); }
.hero-card p { margin-bottom: 0; color: var(--muted); font-size: 1.06rem; }

.formula-stack { display: grid; gap: 10px; }
.formula-stack code {
  display: block;
  padding: 13px 18px;
  border-left: 5px solid var(--accent);
  border-radius: 12px;
  color: var(--text);
  background: var(--accent-soft);
  font: 700 1.25rem/1.3 Consolas, monospace;
}

.theory-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin: 22px 0;
}
.theory-card {
  position: relative;
  padding: 25px 25px 22px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.theory-card h3 { margin: 0 0 10px; font-size: 1.2rem; }
.theory-card p { margin: 0; color: var(--muted); }
.card-number {
  position: absolute;
  right: 18px;
  top: 8px;
  color: color-mix(in srgb, var(--primary) 17%, transparent);
  font-size: 3rem;
  font-weight: 900;
}

.notice {
  padding: 18px 22px;
  border: 1px solid color-mix(in srgb, var(--accent) 48%, var(--line));
  border-radius: 16px;
  background: var(--accent-soft);
}

.section-heading-row {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}
.section-heading-row h2 { margin: 0; font-size: clamp(1.7rem, 4vw, 2.4rem); }
.model-badge, .score-pill {
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface);
  font-size: .9rem;
}

.lab-grid {
  display: grid;
  grid-template-columns: minmax(260px, 340px) 1fr;
  gap: 22px;
  align-items: start;
}

.control-panel, .experiment-card, .calculator-card {
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.control-panel { display: grid; gap: 10px; }
.control-panel label, .calculator-card label { margin-top: 4px; font-weight: 700; }
input, select {
  width: 100%;
  min-height: 44px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  background: var(--surface-2);
}
input:focus, select:focus { outline: 3px solid color-mix(in srgb, var(--primary) 25%, transparent); border-color: var(--primary); }
input[type="range"] { min-height: auto; padding: 0; accent-color: var(--primary); }

.prediction-box {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 10px;
  margin: 9px 0;
  padding: 14px;
  border-radius: 14px;
  background: var(--surface-2);
}
.prediction-box h3 { grid-column: 1 / -1; margin: 0 0 2px; font-size: 1rem; }
.prediction-box label { font-size: .88rem; }

.button-row { display: flex; flex-wrap: wrap; gap: 10px; }
.btn {
  min-height: 43px;
  padding: 9px 17px;
  border: 1px solid transparent;
  border-radius: 11px;
  font-weight: 800;
}
.btn.primary { color: white; background: var(--primary); }
.btn.primary:hover { background: var(--primary-strong); }
.btn.secondary { color: var(--text); border-color: var(--line); background: var(--surface-2); }
.btn.secondary:hover, .btn.ghost:hover { border-color: var(--primary); color: var(--primary); }
.btn.ghost { color: var(--muted); border-color: var(--line); background: transparent; }
.btn.full { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.experiment-card { padding: 18px; }
#fallScene { display: block; width: 100%; max-height: 470px; }
.ground { stroke: #395d44; stroke-width: 8; stroke-linecap: round; }
.terrain { fill: none; stroke: #6d9e57; stroke-width: 10; stroke-linecap: round; opacity: .9; }
.fall-path { stroke: #238da0; stroke-width: 3; stroke-dasharray: 8 8; opacity: .45; }
.fall-ball { fill: #e98b2a; stroke: white; stroke-width: 4; }
.svg-label, .g-label, .scale text { fill: #17313a; font: 700 15px "Segoe UI", sans-serif; }
.g-label { fill: #156f82; font-size: 18px; }
.scale line { stroke: #5f7f89; stroke-width: 1.5; opacity: .55; }

.meters {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 12px;
}
.meters div { padding: 12px; border-radius: 12px; text-align: center; background: var(--surface-2); }
.meters span { display: block; color: var(--muted); font-size: .82rem; }
.meters strong { display: block; margin-top: 3px; }

.feedback, .solution-box, .task-feedback {
  margin-top: 12px;
  padding: 13px 15px;
  border-radius: 12px;
  color: var(--muted);
  background: var(--surface-2);
}
.feedback.success, .task-feedback.success { color: var(--success); background: var(--success-soft); }
.feedback.error, .task-feedback.error { color: var(--danger); background: var(--danger-soft); }

.algorithm-grid { display: grid; grid-template-columns: 1.2fr .8fr; gap: 22px; align-items: start; }
.steps-list { display: grid; gap: 13px; margin: 0; padding: 0; list-style: none; }
.steps-list li {
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 15px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: var(--surface);
}
.steps-list li > span {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  color: white;
  background: var(--primary);
  font-weight: 900;
}
.steps-list h3 { margin: 0 0 5px; }
.steps-list p { margin: 0; color: var(--muted); }

.calculator-card { display: grid; gap: 9px; }
.calculator-card h3 { margin-bottom: 6px; }
.solution-box { min-height: 86px; }
.solution-box ol { margin: 8px 0 0; padding-left: 22px; }
.solution-box li + li { margin-top: 6px; }

.tasks-intro { color: var(--muted); }
.task-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.task-card {
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.task-card.completed { border-color: color-mix(in srgb, var(--success) 68%, var(--line)); }
.task-topline { display: flex; justify-content: space-between; gap: 15px; align-items: center; }
.task-number { color: var(--primary); font-weight: 900; }
.task-type { color: var(--muted); font-size: .8rem; }
.task-card h3 { margin: 10px 0 8px; font-size: 1.08rem; }
.task-card p { color: var(--muted); }
.answer-row { display: grid; grid-template-columns: 1fr auto; gap: 9px; }
.answer-row .btn { white-space: nowrap; }
.hint-toggle { margin-top: 10px; padding: 0; border: 0; color: var(--primary); background: transparent; font-weight: 700; }
.task-hint { margin: 8px 0 0; padding: 10px 12px; border-left: 4px solid var(--accent); background: var(--accent-soft); }
.task-hint[hidden] { display: none; }
.final-actions { margin-top: 20px; }

.site-footer {
  padding: 26px 16px;
  color: var(--muted);
  text-align: center;
  border-top: 1px solid var(--line);
  background: var(--surface);
}
.site-footer p { margin: 0; }

@media (max-width: 820px) {
  .hero-card, .lab-grid, .algorithm-grid { grid-template-columns: 1fr; }
  .theory-grid, .task-grid { grid-template-columns: 1fr; }
  .section-nav { justify-content: flex-start; overflow-x: auto; }
  .nav-btn { white-space: nowrap; }
}

@media (max-width: 560px) {
  .header-inner { min-height: 108px; }
  .brand-icon { display: none; }
  .main-content { width: min(100% - 20px, 1180px); margin-top: 22px; }
  .section-heading-row { align-items: flex-start; flex-direction: column; }
  .meters { grid-template-columns: 1fr; }
  .prediction-box { grid-template-columns: 1fr; }
  .answer-row { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; }
}

/* ===== Дополнения для тренажёров по кинематике ===== */
.scene { display: block; width: 100%; max-height: 470px; }
.scene-bg { fill: url(#sceneSky); }
.trail { fill: none; stroke: #238da0; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; opacity: .8; }
.vec-v { stroke: #1c7ed6; stroke-width: 4; stroke-linecap: round; }
.vec-f { stroke: #d6336c; stroke-width: 4; stroke-linecap: round; }
.tangent-line { stroke: #1c7ed6; stroke-width: 2; stroke-dasharray: 7 7; opacity: .55; }
.guide-circle { fill: none; stroke: #5f7f89; stroke-width: 2; stroke-dasharray: 5 7; opacity: .6; }
.radius-line { stroke: #5f7f89; stroke-width: 2; opacity: .7; }
.center-dot { fill: #17313a; }
.body-dot { fill: #e98b2a; stroke: #fff; stroke-width: 4; }
.vec-label { font: 800 15px "Segoe UI", sans-serif; }
.vec-label.v { fill: #1c7ed6; }
.vec-label.f { fill: #d6336c; }
.vec-label.plain { fill: #17313a; }
.legend { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 10px; color: var(--muted); font-size: .9rem; }
.legend i { display: inline-block; width: 22px; height: 4px; margin-right: 7px; vertical-align: middle; border-radius: 2px; }
.legend .lv { background: #1c7ed6; }
.legend .lf { background: #d6336c; }
.legend .lt { background: #238da0; }

.button-row.compact { margin-top: 4px; }
.select-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px; }
.select-pair label { font-size: .88rem; }
.meters.wide { grid-template-columns: repeat(auto-fit, minmax(105px, 1fr)); }
.verdict { margin-top: 12px; padding: 13px 15px; border-radius: 12px; font-weight: 700; color: var(--primary-strong); background: color-mix(in srgb, var(--primary) 12%, var(--surface)); }

/* ===== Разборы задач ===== */
.examples-intro { color: var(--muted); }
.example-list { display: grid; gap: 18px; }
.example-card {
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.example-top { display: flex; justify-content: space-between; align-items: center; gap: 14px; }
.example-number { color: var(--primary); font-weight: 900; }
.example-level { color: var(--muted); font-size: .8rem; }
.example-card h3 { margin: 8px 0 10px; font-size: 1.2rem; }
.example-condition {
  margin-bottom: 14px;
  padding: 13px 16px;
  border-left: 5px solid var(--primary);
  border-radius: 0 12px 12px 0;
  background: var(--surface-2);
}
.example-steps { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.example-steps li {
  padding: 12px 15px;
  border: 1px solid var(--line);
  border-radius: 12px;
  animation: appear .2s ease-out;
}
.example-steps li b { display: block; margin-bottom: 3px; color: var(--primary); }
.example-answer {
  margin-top: 12px;
  padding: 13px 16px;
  border-radius: 12px;
  color: var(--success);
  background: var(--success-soft);
  font-weight: 800;
}
.example-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 14px; }
.example-progress { color: var(--muted); font-size: .9rem; }

/* ===== Разбор внутри задания ===== */
.solution-toggle { margin: 10px 0 0 16px; padding: 0; border: 0; color: var(--primary); background: transparent; font-weight: 700; }
.solution-toggle:disabled { color: var(--muted); cursor: not-allowed; opacity: .7; }
.task-solution { margin: 10px 0 0; padding: 12px 14px; border-radius: 12px; border: 1px dashed var(--primary); background: var(--surface-2); }
.task-solution[hidden] { display: none; }
.task-solution b { color: var(--primary); }
.task-solution p { margin: 0 0 6px; color: var(--text); }
.task-solution p:last-child { margin-bottom: 0; }
.toolbar-note { margin: 0 0 14px; color: var(--muted); }

@media (max-width: 560px) {
  .select-pair { grid-template-columns: 1fr; }
}
.check-row { display: flex; align-items: center; gap: 10px; margin-top: 6px; font-weight: 600; }
.check-row input[type="checkbox"] { width: 20px; min-height: 20px; accent-color: var(--primary); }
.hidden-row[hidden] { display: none; }
.arc-preview { display: block; width: 100%; max-height: 240px; margin-top: 8px; border-radius: 12px; background: linear-gradient(#e5f6ff, #fff8e3); }
.arc-line { fill: none; stroke: #e98b2a; stroke-width: 5; stroke-linecap: round; }
.chord-line { stroke: #d6336c; stroke-width: 3; stroke-dasharray: 8 6; }
.arc-dot { fill: #17313a; }

/* ===== Дополнения для тренажёра «Сила упругости» ===== */
.spring-coil { fill: none; stroke: #5f7f89; stroke-width: 4; stroke-linejoin: round; stroke-linecap: round; }
.spring-coil.plastic { stroke: #c2410c; }
.support-bar { fill: #5f7f89; }
.weight-body { fill: #e98b2a; stroke: #fff; stroke-width: 3; }
.ruler-line { stroke: #17313a; stroke-width: 2; }
.ruler-tick { stroke: #17313a; stroke-width: 1.5; }
.ruler-text { fill: #17313a; font: 600 12px "Segoe UI", sans-serif; }
.natural-mark { stroke: #238da0; stroke-width: 2; stroke-dasharray: 6 6; }
.graph-card { margin-top: 14px; padding: 14px; border-radius: 14px; background: var(--surface-2); }
.graph-card h3 { margin: 0 0 6px; font-size: 1rem; }
.graph { display: block; width: 100%; max-height: 300px; }
.graph-axis { stroke: #5f7f89; stroke-width: 2; }
.graph-grid { stroke: #5f7f89; stroke-width: 1; opacity: .25; }
.graph-text { fill: #5f7f89; font: 600 12px "Segoe UI", sans-serif; }
.graph-point { fill: #1c7ed6; stroke: #fff; stroke-width: 2; }
.graph-point.over { fill: #d6336c; }
.graph-line { stroke: #1c7ed6; stroke-width: 2; stroke-dasharray: 6 5; opacity: .6; }
.lg { background: #e98b2a; }
.lw { background: #d6336c; }
.graph-text { fill: var(--muted); }
.graph-axis { stroke: var(--muted); }
.graph-grid { stroke: var(--muted); }
.graph-point { stroke: var(--surface-2); }

/* ===== Дополнения для тренажёра «Количество путей в графе» ===== */
.graph-svg { display: block; width: 100%; max-height: 320px; }
.g-edge { stroke: #5f7f89; stroke-width: 2.5; fill: none; }
.g-edge.active { stroke: #d6336c; stroke-width: 4; }
.g-node { fill: #d0ebff; stroke: #1971c2; stroke-width: 3; }
.g-node.start { fill: #d3f9d8; stroke: #2b8a3e; }
.g-node.finish { fill: #ffe8cc; stroke: #e8590c; }
.g-node.active { stroke: #d6336c; stroke-width: 5; }
.g-name { fill: #17313a; font: 800 17px "Segoe UI", sans-serif; text-anchor: middle; }
.g-badge { fill: #fff; stroke: #2b8a3e; stroke-width: 2; }
.g-count { fill: #2b8a3e; font: 800 13px "Segoe UI", sans-serif; text-anchor: middle; }
.graph-box { margin: 12px 0; padding: 10px; border-radius: 14px; background: linear-gradient(#e5f6ff, #fff8e3); }
.label-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; margin-top: 12px; }
.label-grid label { display: grid; gap: 4px; font-weight: 700; font-size: .9rem; }
.label-grid input { width: 100%; }
.label-grid input.ok { border-color: var(--success); background: var(--success-soft); }
.label-grid input.bad { border-color: #d6336c; }
.paths-list { margin: 8px 0 0; padding-left: 22px; }
.paths-list li { margin: 2px 0; font-family: "Cascadia Mono", Consolas, monospace; }

/* ===== Дополнения для тренажёра «Кратчайший путь по таблице» ===== */
.g-weight-bg { fill: #fff; stroke: #5f7f89; stroke-width: 1.5; }
.g-weight { fill: #17313a; font: 800 13px "Segoe UI", sans-serif; text-anchor: middle; }
.g-node.banned { fill: #e9ecef; stroke: #868e96; stroke-dasharray: 5 4; }
.g-name.banned { fill: #868e96; text-decoration: line-through; }
.g-edge.banned { stroke: #ced4da; stroke-dasharray: 4 5; }
.dist-table { border-collapse: collapse; margin: 10px 0; width: 100%; max-width: 420px; background: var(--surface); }
.dist-table th, .dist-table td { border: 1px solid var(--line); padding: 6px 8px; text-align: center; }
.dist-table th { background: var(--surface-2); }
.dist-table td.diag { background: color-mix(in srgb, var(--muted) 25%, var(--surface)); }
.pic-toggle { margin: 6px 0; }

textarea {
  width: 100%;
  min-height: 110px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  background: var(--surface-2);
  font: inherit;
  font-family: "Cascadia Mono", Consolas, monospace;
  resize: vertical;
}
textarea:focus { outline: 3px solid color-mix(in srgb, var(--primary) 25%, transparent); border-color: var(--primary); }
.my-solution { margin-top: 12px; padding: 12px; border: 2px dashed var(--primary); border-radius: 14px; }
.my-solution h4 { margin: 0 0 6px; }
