: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; }
}
