:root {
  --bg: #f4f8fb;
  --panel: #ffffff;
  --ink: #17324d;
  --muted: #617386;
  --line: #d8e3ec;
  --blue: #1f73b7;
  --blue-dark: #145783;
  --green: #2f8f5b;
  --soft-blue: #eaf4fb;
  --soft-green: #eaf7ef;
  --soft-gold: #fff7df;
  --gold: #b77a0b;
  --shadow: 0 12px 35px rgba(27, 60, 88, 0.10);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
}

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

.site-header {
  min-height: 72px;
  padding: 12px clamp(18px, 4vw, 48px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  gap: 11px;
  align-items: center;
  color: var(--ink);
  text-decoration: none;
}
.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--blue);
  color: white;
  font-weight: 800;
  font-size: 1.3rem;
}
.brand strong, .brand small { display: block; }
.brand small { color: var(--muted); margin-top: 2px; }
.home-link { color: var(--blue-dark); text-decoration: none; font-weight: 700; }

.app-shell {
  width: min(1380px, calc(100% - 28px));
  margin: 24px auto 36px;
}

.hero-panel, .controls-card, .sim-card, .results-card, .analysis-card, .teacher-note {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  border-radius: 18px;
}

.hero-panel {
  padding: clamp(22px, 4vw, 36px);
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: center;
  margin-bottom: 20px;
}

.eyebrow {
  display: inline-block;
  font-size: .78rem;
  letter-spacing: .08em;
  font-weight: 800;
  color: var(--blue-dark);
  background: var(--soft-blue);
  border-radius: 999px;
  padding: 7px 10px;
}

h1 { margin: 10px 0 7px; font-size: clamp(2rem, 4vw, 3.2rem); line-height: 1; }
h2 { margin: 0; font-size: 1.15rem; }
p { color: var(--muted); }
.hero-panel p { max-width: 760px; margin-bottom: 0; font-size: 1.02rem; }

.equation-card {
  flex: 0 0 auto;
  min-width: 210px;
  padding: 18px 22px;
  border-radius: 16px;
  background: var(--soft-blue);
  text-align: center;
}
.equation-card span { display: block; color: var(--muted); font-size: .86rem; }
.equation-card strong { display: block; font-size: 1.75rem; margin-top: 4px; }

.workspace {
  display: grid;
  grid-template-columns: minmax(280px, 360px) 1fr;
  gap: 20px;
}

.controls-card, .sim-card, .results-card, .analysis-card { padding: 22px; }
.simulation-column { display: grid; gap: 20px; }

.section-heading { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 18px; }
.section-heading > span {
  flex: 0 0 30px;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--blue);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 800;
}
.section-heading p { margin: 4px 0 0; font-size: .9rem; }
.section-heading.compact { margin-top: 22px; margin-bottom: 10px; }

.field-label { display: block; font-weight: 750; margin: 14px 0 7px; }
select, input[type="number"] {
  width: 100%;
  border: 1px solid #c8d6e2;
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  padding: 10px 11px;
}

.object-preview {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-top: 10px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfdff;
}
.object-preview strong, .object-preview small { display: block; }
.object-preview small { color: var(--muted); margin-top: 2px; }

.object-icon, .moving-object { position: relative; }
.object-icon { width: 62px; height: 40px; flex: 0 0 62px; }

.object-icon.ball, .moving-object.ball {
  border-radius: 50%;
  background: linear-gradient(145deg, #f3a43b, #d56f26);
  border: 3px solid #a24a1b;
}
.object-icon.ball { width: 40px; flex-basis: 40px; }

.object-icon.car, .moving-object.car {
  width: 64px;
  height: 28px;
  background: #3979c9;
  border-radius: 8px 12px 5px 5px;
  border: 2px solid #1d4f88;
}
.object-icon.car::before, .moving-object.car::before,
.object-icon.car::after, .moving-object.car::after {
  content: "";
  position: absolute;
  bottom: -9px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #263746;
}
.object-icon.car::before, .moving-object.car::before { left: 8px; }
.object-icon.car::after, .moving-object.car::after { right: 8px; }

.object-icon.wheel, .moving-object.wheel {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 8px solid #384957;
  background: #aab8c3;
}
.object-icon.wheel { flex-basis: 42px; }

.object-icon.cart, .moving-object.cart {
  width: 66px;
  height: 30px;
  border: 3px solid #486475;
  background: #90bfd4;
  border-radius: 5px;
}
.object-icon.cart::before, .object-icon.cart::after,
.moving-object.cart::before, .moving-object.cart::after {
  content: "";
  position: absolute;
  bottom: -9px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #31424e;
}
.object-icon.cart::before, .moving-object.cart::before { left: 8px; }
.object-icon.cart::after, .moving-object.cart::after { right: 8px; }

.slider-block { margin-top: 16px; }
.slider-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.slider-row label { font-weight: 750; }
.slider-row output { font-variant-numeric: tabular-nums; color: var(--blue-dark); font-weight: 800; }
input[type="range"] { width: 100%; accent-color: var(--blue); margin-top: 8px; }

.friction-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.friction-grid label { display: block; font-size: .82rem; color: var(--muted); margin-bottom: 4px; }
.micro-note { font-size: .75rem; margin: 7px 0 0; line-height: 1.35; }

.prediction-options { display: grid; gap: 8px; }
.prediction-options label {
  display: flex;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  background: #fbfdff;
}

.button-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 18px; }
.primary-btn, .secondary-btn, .graph-btn {
  border-radius: 10px;
  padding: 10px 14px;
  font-weight: 800;
  border: 1px solid transparent;
}
.primary-btn { background: var(--blue); color: white; }
.primary-btn:hover { background: var(--blue-dark); }
.secondary-btn { background: #fff; color: var(--ink); border-color: #c8d6e2; }
.secondary-btn:disabled { opacity: .5; cursor: not-allowed; }

.track-wrap {
  background: linear-gradient(#f7fbfe, #eef6fa);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 48px 22px 12px;
  overflow: hidden;
  position: relative;
}
.track { position: relative; height: 116px; }
.track-line { position: absolute; left: 0; right: 0; bottom: 22px; height: 5px; background: #738896; border-radius: 4px; }
.start-line { position: absolute; left: 0; bottom: 16px; width: 3px; height: 62px; background: #22384c; }
.start-line span { position: absolute; top: -25px; left: -13px; font-size: .67rem; font-weight: 900; color: var(--muted); }
.moving-object {
  position: absolute;
  left: 16px;
  bottom: 30px;
  z-index: 2;
  transform-origin: center;
}
.force-arrow { position: absolute; left: 28px; top: 15px; display: flex; align-items: center; gap: 7px; color: var(--blue-dark); font-size: .76rem; font-weight: 800; }
.arrow-line { width: 75px; height: 3px; background: var(--blue); position: relative; }
.arrow-line::after { content: ""; position: absolute; right: -1px; top: -5px; border-left: 10px solid var(--blue); border-top: 6px solid transparent; border-bottom: 6px solid transparent; }
.track-scale { display: flex; justify-content: space-between; font-size: .78rem; color: var(--muted); }

.live-readouts, .force-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}
.live-readouts > div, .force-grid > div {
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 11px;
  background: #fbfdff;
}
.live-readouts span, .force-grid span { display: block; font-size: .77rem; color: var(--muted); }
.live-readouts strong, .force-grid strong { display: block; margin-top: 3px; font-variant-numeric: tabular-nums; }
.force-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.force-grid .emphasis { background: var(--soft-blue); border-color: #bbd9ec; }

.result-message { margin-top: 14px; border-radius: 11px; padding: 12px 14px; font-weight: 700; }
.result-message.neutral { background: #f1f5f8; color: var(--muted); }
.result-message.good { background: var(--soft-green); color: #236845; }
.result-message.warn { background: var(--soft-gold); color: #805300; }
.math-details { margin-top: 13px; border-top: 1px solid var(--line); padding-top: 10px; }
.math-details summary { cursor: pointer; font-weight: 800; color: var(--blue-dark); }
.math-steps { margin-top: 10px; line-height: 1.7; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9rem; color: #314a60; }

.analysis-card { margin-top: 20px; }
.analysis-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 18px; }
.graph-controls { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.graph-btn { background: #fff; color: var(--ink); border-color: #c8d6e2; }
.graph-btn.active { background: var(--blue); color: white; border-color: var(--blue); }
.graph-wrap { border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: #fff; }
#graphCanvas { width: 100%; height: auto; display: block; }
.graph-caption { display: flex; justify-content: space-between; gap: 18px; margin-top: 10px; color: var(--muted); font-size: .9rem; }
.graph-caption strong { color: var(--ink); }

.teacher-note { margin-top: 20px; padding: 15px 18px; color: var(--muted); font-size: .9rem; }
.teacher-note strong { color: var(--ink); }
footer { text-align: center; color: var(--muted); font-size: .83rem; padding: 0 15px 28px; }

@media (max-width: 900px) {
  .workspace { grid-template-columns: 1fr; }
  .hero-panel { align-items: flex-start; }
  .equation-card { min-width: 180px; }
  .live-readouts { grid-template-columns: 1fr 1fr; }
  .force-grid { grid-template-columns: 1fr 1fr; }
  .analysis-header { display: block; }
  .graph-controls { justify-content: flex-start; margin-bottom: 12px; }
}

@media (max-width: 600px) {
  .site-header { align-items: flex-start; }
  .brand small { display: none; }
  .hero-panel { display: block; }
  .equation-card { margin-top: 18px; width: 100%; }
  .live-readouts, .force-grid, .friction-grid { grid-template-columns: 1fr 1fr; }
  .button-row { grid-template-columns: 1fr; }
  .graph-caption { display: block; }
  .graph-caption span { display: block; margin-top: 3px; }
}

/* Force-mode additions */
.mode-explainer {
  margin: 8px 0 0;
  padding: 9px 11px;
  border-radius: 10px;
  background: var(--soft-blue);
  color: var(--blue-dark);
  font-size: .82rem;
  line-height: 1.4;
  font-weight: 650;
}
.conditional-control.hidden { display: none; }

.force-stage-note {
  position: absolute;
  top: 10px;
  left: 18px;
  right: 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 5;
  font-size: .76rem;
  color: var(--muted);
}
.force-stage-note strong {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 5px 9px;
  background: var(--soft-green);
  color: #236845;
}
.force-stage-note strong.off {
  background: #eef2f5;
  color: #617386;
}

.force-vector {
  position: absolute;
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  font-size: .70rem;
  font-weight: 850;
  pointer-events: none;
}
.applied-vector { bottom: 82px; color: var(--blue-dark); }
.friction-vector { bottom: 4px; color: #9a5d0b; }
.vector-line {
  width: 74px;
  height: 3px;
  position: relative;
  border-radius: 3px;
}
.vector-line.right { background: var(--blue); }
.vector-line.left { background: #c17a17; }
.vector-line.right::after {
  content: "";
  position: absolute;
  right: -1px;
  top: -5px;
  border-left: 10px solid var(--blue);
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
}
.vector-line.left::before {
  content: "";
  position: absolute;
  left: -1px;
  top: -5px;
  border-right: 10px solid #c17a17;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
}

@media (max-width: 600px) {
  .force-stage-note { align-items: flex-start; flex-direction: column; gap: 4px; }
  .force-vector { font-size: .62rem; }
  .vector-line { width: 50px; }
}
