:root {
  --c-x: #2563eb; /* height / position    - blue  */
  --c-v: #16a34a; /* velocity (in prose)  - green */
  --c-a: #dc2626; /* acceleration / drag  - red   */
  --c-t: #7c3aed; /* time / playhead      - violet */

  /* Object identity colors (used for tracks, curves, readouts, legend) */
  --obj-a: #2563eb; /* object A - blue   */
  --obj-b: #ea580c; /* object B - orange */

  --ink: #0f172a;
  --muted: #64748b;
  --line: #cbd5e1;
  --grid: #e2e8f0;
  --panel: #ffffff;
  --bg: #f1f5f9;

  --radius: 10px;
}

* { box-sizing: border-box; }

/* The `hidden` attribute must win even over class rules that set `display`
   (e.g. .custom / .picker / .impact use display:flex, which by specificity
   would otherwise override the UA `[hidden] { display:none }`). */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  font-size: 18px;
  line-height: 1.4;
}

body {
  max-width: 1500px;
  margin: 0 auto;
  padding: 16px clamp(12px, 3vw, 28px) 32px;
}

/* ---------- top bar ---------- */
.topbar h1 {
  margin: 4px 0 2px;
  font-size: clamp(26px, 3.4vw, 40px);
  font-weight: 800;
  letter-spacing: -0.02em;
}
.topbar h1::first-letter { color: var(--c-x); }

.subtitle {
  margin: 0 0 14px;
  font-size: 17px;
  color: var(--muted);
  font-weight: 600;
}
.sign-note { display: inline-block; }

/* ---------- control rows ---------- */
.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 16px 28px;
  padding: 16px 20px;
  margin-bottom: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.controls-objects { align-items: center; }
.controls-transport { justify-content: space-between; align-items: center; }

.slider {
  display: grid;
  grid-template-columns: auto 90px auto;
  grid-template-rows: auto auto;
  align-items: center;
  gap: 6px 10px;
  flex: 1 1 340px;
  min-width: 300px;
}
.slider-label {
  grid-column: 1 / -1;
  font-weight: 700;
  font-size: 16px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.slider-label i { font-style: italic; text-transform: none; }
.slider .mode {
  text-transform: none;
  letter-spacing: 0;
  color: var(--c-v);
  font-weight: 700;
}
.slider input[type="range"] {
  grid-column: 1 / 2;
  width: 100%;
  height: 28px;
  accent-color: var(--c-x);
}
.numbox {
  width: 90px;
  font-size: 18px;
  font-weight: 700;
  padding: 8px 10px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.slider .numbox { grid-column: 2 / 3; }
.slider .unit {
  grid-column: 3 / 4;
  font-size: 15px;
  color: var(--muted);
  font-weight: 600;
}

/* ---------- air resistance switch (prominent) ---------- */
.air-toggle { display: flex; flex-direction: column; gap: 6px; }
.air-label {
  font-size: 14px;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.segmented { display: flex; }
.btn-seg {
  font-size: 17px;
  padding: 10px 18px;
  border-color: var(--line);
  border-radius: 0;
}
.btn-seg:first-child { border-radius: 8px 0 0 8px; }
.btn-seg:last-child { border-radius: 0 8px 8px 0; border-left: none; }
.btn-seg.is-active {
  background: var(--c-t);
  border-color: var(--c-t);
  color: #fff;
}
.btn-seg.is-active:hover { background: #6d28d9; }

/* ---------- object pickers ---------- */
.picker { display: flex; flex-direction: column; gap: 6px; }
.picker-label {
  font-size: 14px;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  gap: 8px;
}
.select {
  font-size: 18px;
  font-weight: 700;
  padding: 9px 12px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  min-width: 210px;
}
.swatch {
  width: 16px; height: 16px;
  border-radius: 4px;
  display: inline-block;
  flex: none;
}
.swatch-a { background: var(--obj-a); }
.swatch-b { background: var(--obj-b); }

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 16px;
}
.check input { width: 22px; height: 22px; accent-color: var(--c-t); }

/* ---------- custom parameter panels ---------- */
.custom-panels { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 12px; }
.custom {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 18px;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 16px 14px;
  margin: 0;
}
.custom legend {
  font-weight: 800;
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 6px;
}
.custom label { font-weight: 700; font-size: 15px; display: inline-flex; align-items: center; gap: 6px; }
.custom .numbox { width: 84px; }

/* ---------- buttons ---------- */
.btn-groups { display: flex; flex-direction: column; gap: 10px; }
.buttons { display: flex; gap: 10px; }
.speeds { display: flex; align-items: center; gap: 6px; }
.speeds-label {
  font-size: 14px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-right: 4px;
}

.btn {
  font-size: 18px;
  font-weight: 800;
  padding: 10px 18px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  transition: transform .05s ease, background .15s ease;
}
.btn:hover { background: #e2e8f0; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn:disabled:hover { background: #fff; }
.btn-primary {
  background: var(--c-x);
  border-color: var(--c-x);
  color: #fff;
  min-width: 104px;
}
.btn-primary:hover { background: #1d4ed8; }

.btn-speed {
  font-size: 15px;
  padding: 8px 12px;
  border-color: var(--line);
  min-width: 56px;
}
.btn-speed.is-active {
  background: var(--c-t);
  border-color: var(--c-t);
  color: #fff;
}
.btn-speed.is-active:hover { background: #6d28d9; }

select:focus, input:focus, button:focus { outline: 3px solid #93c5fd; outline-offset: 1px; }

/* ---------- activity + display options ---------- */
.controls-activity { align-items: center; gap: 12px 24px; }
.opt-group { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 16px; }
.group-label {
  font-size: 14px;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
#presetToss.is-active {
  background: var(--c-t);
  border-color: var(--c-t);
  color: #fff;
}
#presetToss.is-active:hover { background: #6d28d9; }
/* v / a called out in labels: distinguished by underline style, not color */
.vec-v, .vec-a { font-style: italic; font-weight: 800; padding-bottom: 1px; }
.vec-v { border-bottom: 3px solid currentColor; }
.vec-a { border-bottom: 3px dashed currentColor; }
.scale-note {
  flex-basis: 100%;
  margin: 2px 0 0;
  font-size: 14px;
  color: var(--muted);
}
.apex-hint {
  flex-basis: 100%;
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: #92400e;
}

/* ---------- guided-activity prompt panel ---------- */
.activity-panel {
  margin: 0 0 14px;
  padding: 12px 18px;
  background: #eff6ff;
  border: 2px solid var(--c-x);
  border-radius: var(--radius);
}
.activity-q, .activity-o { margin: 0; font-size: 19px; font-weight: 700; color: var(--ink); }
.activity-q::before { content: "❓ "; }
.activity-o { margin-top: 8px; color: #1d4ed8; }
.activity-o::before { content: "🔎 "; }

/* ---------- readouts (one card per active object) ---------- */
.readouts { display: flex; flex-wrap: wrap; gap: 12px; margin: 14px 0 10px; }
.obj-readout {
  flex: 1 1 460px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-left-width: 10px;
  border-radius: var(--radius);
  padding: 10px 18px 12px;
}
.ro-a { border-left-color: var(--obj-a); }
.ro-b { border-left-color: var(--obj-b); }

.obj-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-bottom: 8px; }
.obj-name { font-size: 20px; font-weight: 800; }
.ro-a .obj-name { color: var(--obj-a); }
.ro-b .obj-name { color: var(--obj-b); }
.obj-impact {
  margin-left: auto;
  font-size: 14px;
  font-weight: 800;
  line-height: 1.3;
  font-variant-numeric: tabular-nums;
  color: var(--c-a);
  background: #fef2f2;
  border: 1.5px solid var(--c-a);
  padding: 3px 10px;
  border-radius: 6px;
}
/* A frozen object's readout (impact OR time limit) is flagged subtly so the
   retained numbers aren't read as live motion, and so a stopped object stands
   out from one still falling in a two-object comparison. */
.obj-readout.is-frozen { background: #fff7f7; }
/* A time-limit (capped) note is NOT an impact: use a neutral amber, not the
   red impact styling, and don't imply a landing. */
.obj-impact.capped {
  color: #92400e;
  background: #fffbeb;
  border-color: #d97706;
}
/* After a genuine impact the readout uses descriptive labels ("Velocity at
   impact", etc.). Stack the rows (label left, value right) so the longer
   labels stay legible on a projector. */
.obj-readout.is-impact .reads { flex-direction: column; gap: 6px; }
.obj-readout.is-impact .read {
  width: 100%;
  flex: 1 1 auto;
  background: transparent;
  padding: 3px 0;
}
.obj-readout.is-impact .read-label {
  font-size: 15px;
  font-style: normal;
  font-weight: 700;
  color: var(--muted);
}

.reads { display: flex; flex-wrap: wrap; gap: 10px; }
.read {
  flex: 1 1 96px;
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 6px 12px;
  background: var(--bg);
  border-radius: 8px;
}
.read-label { font-size: 20px; font-weight: 800; font-style: italic; color: var(--muted); }
.read-val {
  font-size: 26px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  margin-left: auto;
}
.read-unit { font-size: 14px; color: var(--muted); font-weight: 600; }

/* ---------- impact / comparison banner ---------- */
.impact {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 0 0 14px;
  padding: 12px 20px;
  background: #fef2f2;
  border: 2px solid var(--c-a);
  border-radius: var(--radius);
}
.impact-badge {
  font-size: 22px;
  font-weight: 900;
  color: #fff;
  background: var(--c-a);
  padding: 4px 14px;
  border-radius: 8px;
  letter-spacing: 0.02em;
}
.impact-text {
  font-size: 22px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

/* ---------- stage: animation + graphs ---------- */
.stage {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 16px;
  align-items: stretch;
}
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.track-canvas { display: block; width: 100%; height: 560px; }
.graphs { display: grid; grid-template-rows: 1fr 1fr; gap: 16px; }
.graph-canvas {
  display: block;
  width: 100%;
  height: 272px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

/* ---------- footer ---------- */
.hint {
  margin-top: 18px;
  font-size: 16px;
  color: var(--muted);
  line-height: 1.6;
}
.c-x { color: var(--c-x); } .c-v { color: var(--c-v); } .c-a { color: var(--c-a); }

/* Stack the animation above the graphs on narrower laptops */
@media (max-width: 1180px) {
  .stage { grid-template-columns: 1fr; }
  .track-canvas { height: 380px; }
}
