:root {
  color-scheme: dark;
  --bg: #08111f;
  --bg-soft: #0d1a2d;
  --panel: rgba(17, 34, 56, 0.82);
  --panel-solid: #112238;
  --line: rgba(165, 207, 239, 0.18);
  --text: #f2f7ff;
  --muted: #aabbd0;
  --blue: #70c7ff;
  --violet: #9187ff;
  --gold: #ffce73;
  --green: #72e0ae;
  --danger: #ff929b;
  --shadow: 0 16px 48px rgba(0, 0, 0, 0.24);
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #eef5fb;
  --bg-soft: #dcebf8;
  --panel: rgba(255, 255, 255, 0.88);
  --panel-solid: #ffffff;
  --line: rgba(30, 75, 111, 0.16);
  --text: #102238;
  --muted: #536b84;
  --blue: #087ac5;
  --violet: #5a4ee2;
  --gold: #bd7410;
  --green: #137e51;
  --danger: #bf3551;
  --shadow: 0 14px 42px rgba(40, 74, 102, 0.12);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at 82% 0%, rgba(88, 102, 233, 0.14), transparent 29rem),
    radial-gradient(circle at 6% 18%, rgba(20, 159, 223, 0.1), transparent 25rem),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.55;
}

button, input, select { font: inherit; }

button {
  cursor: pointer;
  min-height: 44px;
  border: 0;
}

button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
}

.topbar {
  position: sticky;
  z-index: 10;
  top: 0;
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 70px;
  padding: 10px max(18px, calc((100vw - 1240px) / 2));
  background: color-mix(in srgb, var(--bg) 87%, transparent);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
  color: var(--text);
  text-decoration: none;
  font-weight: 800;
  letter-spacing: -0.04em;
}

.brand-mark {
  display: grid;
  width: 31px;
  height: 31px;
  place-items: center;
  border-radius: 50%;
  color: #07101d;
  background: linear-gradient(135deg, var(--gold), var(--blue));
  box-shadow: 0 0 23px rgba(112, 199, 255, 0.36);
}

.tabs {
  display: flex;
  flex: 1;
  gap: 3px;
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar { display: none; }

.tab {
  min-height: 40px;
  padding: 0 11px;
  border-radius: 9px;
  color: var(--muted);
  background: transparent;
  font-size: 0.89rem;
  font-weight: 700;
  white-space: nowrap;
}

.tab:hover, .tab.active {
  color: var(--text);
  background: color-mix(in srgb, var(--panel-solid) 80%, transparent);
}

.icon-button {
  width: 44px;
  min-width: 44px;
  border-radius: 50%;
  background: var(--panel-solid);
  color: var(--text);
  border: 1px solid var(--line);
  font-size: 1.25rem;
}

main {
  width: min(1240px, 100%);
  margin: 0 auto;
  padding: 0 18px 58px;
}

.view { display: none; }
.view.active { display: block; animation: appear 0.28s ease-out; }

@keyframes appear {
  from { opacity: 0; transform: translateY(7px); }
  to { opacity: 1; transform: translateY(0); }
}

.hero {
  max-width: 830px;
  padding: clamp(56px, 10vw, 126px) 0 48px;
}

.eyebrow, .mini-tag {
  color: var(--blue);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1, h2, h3, p { margin-top: 0; }

h1 {
  margin: 10px 0 18px;
  max-width: 850px;
  font-size: clamp(2.55rem, 7vw, 5.25rem);
  letter-spacing: -0.066em;
  line-height: 0.98;
}

h1 span {
  color: transparent;
  background: linear-gradient(100deg, var(--blue), #c5b7ff 72%, var(--gold));
  background-clip: text;
}

h2 {
  font-size: clamp(1.55rem, 3.4vw, 2.4rem);
  line-height: 1.1;
  letter-spacing: -0.045em;
}

h3 {
  font-size: 1.25rem;
  line-height: 1.15;
  letter-spacing: -0.025em;
}

.hero-copy, .page-intro p {
  max-width: 690px;
  color: var(--muted);
  font-size: clamp(1.05rem, 2.4vw, 1.22rem);
}

.hero-actions, .preset-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 26px;
}

.primary, .secondary {
  min-height: 47px;
  padding: 0 18px;
  border-radius: 11px;
  font-weight: 800;
}

.primary {
  color: #07101c;
  background: linear-gradient(135deg, var(--gold), #ffaf72);
  box-shadow: 0 9px 25px rgba(255, 188, 98, 0.18);
}

.primary:hover { filter: brightness(1.07); transform: translateY(-1px); }

.secondary {
  color: var(--text);
  border: 1px solid var(--line);
  background: var(--panel);
}

.idea-strip {
  display: grid;
  gap: 1px;
  overflow: hidden;
  margin-bottom: 66px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--line);
}

.idea-strip article {
  display: flex;
  gap: 15px;
  padding: 20px;
  background: var(--panel-solid);
}

.idea-strip p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.step-number {
  color: var(--gold);
  font-weight: 900;
  font-size: 1.22rem;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.lab-section { margin: 54px 0 26px; }

.section-heading, .tool-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.section-heading h2, .tool-head h2 { margin: 6px 0 0; }

.badge {
  flex: 0 0 auto;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.71rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.badge.accent {
  border-color: color-mix(in srgb, var(--gold) 50%, transparent);
  color: var(--gold);
}

.gravity-lab {
  display: grid;
  overflow: hidden;
}

.canvas-wrap {
  position: relative;
  min-height: 330px;
  background:
    radial-gradient(circle at 50% 51%, rgba(64, 168, 238, 0.18), transparent 33%),
    #091829;
}

#gravityCanvas {
  display: block;
  width: 100%;
  height: clamp(330px, 60vw, 500px);
}

.canvas-label {
  position: absolute;
  left: 15px;
  right: 15px;
  color: rgba(229, 242, 255, 0.65);
  font-size: 0.75rem;
  pointer-events: none;
}

.canvas-label.top { top: 14px; }
.canvas-label.bottom { bottom: 12px; text-align: center; }

.controls {
  padding: 22px;
  background: color-mix(in srgb, var(--panel-solid) 92%, transparent);
}

label {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 7px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

output { color: var(--text); }

select, input[type="number"] {
  width: 100%;
  min-height: 45px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--text);
  background: var(--bg-soft);
}

input[type="range"] {
  width: 100%;
  height: 32px;
  margin: 0 0 17px;
  accent-color: var(--blue);
}

.data-readout {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
  margin: 8px 0 16px;
}

.data-readout div {
  padding: 10px 8px;
  border-radius: 9px;
  background: color-mix(in srgb, var(--bg-soft) 70%, transparent);
}

.data-readout span, .data-readout strong {
  display: block;
  font-size: 0.68rem;
}

.data-readout span { color: var(--muted); }
.data-readout strong { margin-top: 3px; color: var(--blue); font-size: 0.8rem; }

.small-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.two-col {
  display: grid;
  gap: 18px;
  margin: 18px 0;
}

.explainer { padding: 25px; }
.explainer p { color: var(--muted); }

.fall-diagram, .elevator-diagram {
  position: relative;
  height: 150px;
  margin-top: 16px;
  overflow: hidden;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(89, 151, 209, 0.12), rgba(104, 70, 174, 0.1));
}

.earth-dot {
  position: absolute;
  bottom: -29px;
  left: 24px;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 28%, #71d2ff, #1478b8 57%, #0b416c);
}

.arc {
  position: absolute;
  width: 210px;
  height: 160px;
  border-top: 2px dashed var(--gold);
  border-radius: 50%;
  transform: rotate(-19deg);
}

.arc-one { left: 68px; top: 63px; }
.arc-two { left: 112px; top: 34px; opacity: .7; }
.arc-three { left: 158px; top: 8px; opacity: .35; }

.diagram-caption {
  position: absolute;
  right: 14px;
  bottom: 13px;
  max-width: 180px;
  color: var(--muted);
  font-size: .76rem;
  text-align: right;
}

.elevator-box {
  position: absolute;
  top: 17px;
  left: 24px;
  width: 95px;
  height: 108px;
  border: 3px solid var(--violet);
  border-bottom: 0;
}

.floor {
  position: absolute;
  bottom: 0;
  width: 100%;
  height: 8px;
  background: var(--gold);
}

.person-shape {
  position: absolute;
  left: 39px;
  bottom: 8px;
  width: 14px;
  height: 40px;
  border-radius: 9px 9px 3px 3px;
  background: var(--blue);
}

.person-shape::before {
  content: "";
  position: absolute;
  top: -17px;
  left: 1px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--blue);
}

.arrow-up {
  position: absolute;
  top: 48px;
  left: 144px;
  padding-left: 32px;
  color: var(--gold);
  font-size: .84rem;
  font-weight: 700;
}

.arrow-up::before {
  content: "↑";
  position: absolute;
  top: -18px;
  left: 0;
  font-size: 2.6rem;
  line-height: 1;
}

.clock-lab {
  display: grid;
  gap: 24px;
  margin-top: 18px;
  padding: 27px;
}

.clock-copy p { color: var(--muted); }

.clock-result {
  display: grid;
  gap: 4px;
  margin-top: 12px;
  padding: 18px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(113, 215, 174, .16), rgba(82, 120, 255, .12));
}

.clock-result strong { color: var(--green); font-size: clamp(1.6rem, 5vw, 2.4rem); letter-spacing: -.06em; }
.clock-result span { color: var(--muted); font-size: .83rem; }

.gps-callout {
  margin-top: 12px;
  padding: 12px;
  border-left: 3px solid var(--gold);
  color: var(--muted);
  font-size: .83rem;
  background: color-mix(in srgb, var(--gold) 7%, transparent);
}

.page-intro {
  padding: clamp(55px, 8vw, 100px) 0 34px;
}

.page-intro h1 { margin-bottom: 15px; }
.page-intro h1:not(.challenge-intro h1) { font-size: clamp(2.55rem, 6vw, 4.4rem); }

.equation-card {
  display: grid;
  gap: 24px;
  padding: 30px;
  border: 1px solid color-mix(in srgb, var(--violet) 42%, var(--line));
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(97, 89, 212, 0.2), rgba(42, 139, 210, 0.12));
}

.equation {
  color: var(--text);
  font-family: ui-serif, Georgia, serif;
  font-size: clamp(3.8rem, 13vw, 7.3rem);
  font-weight: 700;
  letter-spacing: -.1em;
  line-height: .9;
}

.equation span { color: var(--gold); }

.equation-notes {
  display: grid;
  gap: 12px;
}

.equation-notes div {
  display: grid;
  grid-template-columns: 35px 1fr;
  align-items: center;
  gap: 9px;
}

.equation-notes strong {
  color: var(--gold);
  font-family: ui-serif, Georgia, serif;
  font-size: 1.6rem;
}

.equation-notes span { color: var(--muted); font-size: .9rem; }

.energy-tool { margin-top: 20px; padding: 26px; }

.calculator-grid {
  display: grid;
  gap: 25px;
  align-items: stretch;
}

.input-line {
  display: grid;
  grid-template-columns: 1fr 1.1fr;
  gap: 8px;
  margin-bottom: 18px;
}

.preset {
  min-height: 37px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: var(--bg-soft);
  font-size: .74rem;
  font-weight: 700;
}

.preset:hover { color: var(--text); border-color: var(--blue); }

.energy-output {
  padding: 22px;
  border-radius: 13px;
  background: linear-gradient(145deg, rgba(255, 203, 112, .15), rgba(108, 105, 255, .1));
}

.energy-output > span {
  color: var(--muted);
  font-size: .82rem;
  font-weight: 700;
}

.energy-output > strong {
  display: block;
  margin: 5px 0 21px;
  color: var(--gold);
  font-size: clamp(1.8rem, 5vw, 3rem);
  letter-spacing: -.06em;
  line-height: 1;
}

.result-grid {
  display: grid;
  gap: 8px;
}

.result-grid div {
  padding: 10px;
  border-radius: 8px;
  background: rgba(5, 12, 26, .17);
}

.result-grid small, .result-grid b { display: block; }
.result-grid small { color: var(--muted); font-size: .71rem; }
.result-grid b { margin-top: 2px; font-size: .95rem; }

.energy-output p {
  margin: 15px 0 0;
  color: var(--muted);
  font-size: .74rem;
}

.mass-story {
  display: grid;
  gap: 18px;
  margin: 18px 0;
}

.story-card { padding: 23px; }
.story-card p { margin-bottom: 0; color: var(--muted); }
.story-number {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  margin-bottom: 15px;
  border-radius: 50%;
  color: var(--bg);
  background: var(--blue);
  font-weight: 900;
}

.gamma-panel {
  display: grid;
  gap: 18px;
  padding: 26px;
}

.gamma-panel p { color: var(--muted); }
.gamma-panel label { margin-top: 21px; }
.gamma-readout strong { color: var(--gold); }
#gammaChart { width: 100%; height: 255px; }

.evidence-grid {
  display: grid;
  gap: 18px;
}

.evidence-card {
  display: flex;
  min-height: 315px;
  flex-direction: column;
  overflow: hidden;
  padding: 23px;
}

.evidence-card .year {
  color: var(--gold);
  font-weight: 900;
  font-size: .8rem;
  letter-spacing: .12em;
}

.evidence-card h2 { margin: 10px 0; font-size: 1.5rem; }
.evidence-card p { color: var(--muted); font-size: .91rem; }

.visual {
  position: relative;
  min-height: 100px;
  margin-top: auto;
  overflow: hidden;
  border-radius: 11px;
  background: #081628;
}

.lens-visual .sun {
  position: absolute;
  top: 26px;
  left: 45%;
  width: 51px;
  height: 51px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff8d7, #ffce63 45%, #db782d);
  box-shadow: 0 0 28px #ffac45;
}

.lens-visual .star {
  position: absolute;
  top: 18px;
  right: 16px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 0 12px white;
}

.ray {
  position: absolute;
  height: 2px;
  background: var(--blue);
  transform-origin: left;
}

.ray.one { top: 31px; left: 5px; width: 44%; transform: rotate(10deg); }
.ray.two { top: 74px; left: 5px; width: 74%; transform: rotate(-12deg); }

.clock-visual .clock-face {
  position: absolute;
  top: 24px;
  left: 28px;
  display: grid;
  width: 55px;
  height: 55px;
  place-items: center;
  border: 4px solid var(--blue);
  border-radius: 50%;
  color: var(--blue);
  font-size: .66rem;
}

.clock-visual .small {
  top: 36px;
  left: auto;
  right: 27px;
  width: 37px;
  height: 37px;
  border-color: var(--gold);
  color: var(--gold);
}

.path-line {
  position: absolute;
  top: 51px;
  left: 85px;
  right: 64px;
  border-top: 2px dashed var(--muted);
}

.wave-visual {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.wave-visual i {
  width: 17px;
  height: 17px;
  border: 2px solid var(--violet);
  border-radius: 50%;
  animation: pulse 1.8s infinite ease-out;
}

.wave-visual i:nth-child(2) { animation-delay: .2s; }
.wave-visual i:nth-child(3) { animation-delay: .4s; }
.wave-visual i:nth-child(4) { animation-delay: .6s; }

@keyframes pulse {
  50% { transform: scale(2.8); opacity: .18; }
  100% { transform: scale(1); opacity: .8; }
}

.hole-visual {
  display: grid;
  place-items: center;
}

.hole-visual span {
  width: 100px;
  height: 72px;
  border: 16px solid #e98842;
  border-right-color: #ffdb85;
  border-left-color: #a04485;
  border-radius: 50%;
  box-shadow: 0 0 26px rgba(255, 156, 74, .35);
  background: #02050a;
  transform: rotate(-12deg);
}

.facts-panel {
  display: grid;
  gap: 26px;
  margin-top: 18px;
  padding: 27px;
}

.fact-list {
  display: grid;
  gap: 15px;
  margin: 0;
}

.fact-list div {
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.fact-list div:last-child { padding-bottom: 0; border-bottom: 0; }
.fact-list dt { margin-bottom: 5px; color: var(--blue); font-weight: 800; }
.fact-list dd { margin: 0; color: var(--muted); font-size: .91rem; }

.sources {
  margin-top: 18px;
  padding: 26px;
}

.sources h2 { margin-bottom: 6px; }
.sources p { color: var(--muted); }

.source-links {
  display: grid;
  gap: 9px;
  margin-top: 16px;
}

.source-links a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 49px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--text);
  background: var(--bg-soft);
  text-decoration: none;
  font-size: .88rem;
  font-weight: 700;
}

.source-links a:hover { border-color: var(--blue); }
.source-links span { color: var(--blue); font-size: 1.2rem; }

.quiz {
  max-width: 780px;
  padding: clamp(22px, 5vw, 38px);
  margin: 0 auto;
}

.quiz-progress {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: .76rem;
  font-weight: 700;
}

.progress-track {
  overflow: hidden;
  height: 7px;
  border-radius: 20px;
  background: var(--bg-soft);
}

.progress-track i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--blue);
  transition: width .25s ease;
}

.quiz h2 { margin: 34px 0 22px; }

.answers {
  display: grid;
  gap: 10px;
}

.answer {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 58px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--text);
  background: var(--bg-soft);
  text-align: left;
  font-size: .93rem;
  font-weight: 650;
}

.answer:hover:not(:disabled) { border-color: var(--blue); transform: translateX(2px); }
.answer span {
  display: grid;
  flex: 0 0 auto;
  width: 29px;
  height: 29px;
  place-items: center;
  border-radius: 8px;
  color: var(--blue);
  background: color-mix(in srgb, var(--blue) 12%, transparent);
  font-size: .75rem;
  font-weight: 900;
}

.answer.correct { border-color: var(--green); background: color-mix(in srgb, var(--green) 13%, var(--panel-solid)); }
.answer.incorrect { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 11%, var(--panel-solid)); }
.answer:disabled { cursor: default; }

.quiz-feedback {
  min-height: 28px;
  margin: 19px 0 13px;
  color: var(--muted);
  font-size: .9rem;
}

.quiz-feedback strong { color: var(--text); }
.hidden { display: none; }

.takeaways {
  max-width: 780px;
  margin: 18px auto 0;
  padding: 27px;
}

.takeaways ol {
  display: grid;
  gap: 11px;
  padding-left: 21px;
  color: var(--muted);
}

.takeaways li::marker { color: var(--gold); font-weight: 900; }

footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 22px max(18px, calc((100vw - 1240px) / 2));
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: .78rem;
}

.footer-button {
  flex: 0 0 auto;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: transparent;
  font-size: .78rem;
  font-weight: 800;
}

.toast {
  position: fixed;
  z-index: 50;
  right: 18px;
  bottom: 18px;
  max-width: min(330px, calc(100vw - 36px));
  padding: 12px 15px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  background: var(--panel-solid);
  box-shadow: var(--shadow);
  font-size: .88rem;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}

.toast.show { opacity: 1; transform: translateY(0); }

@media (min-width: 650px) {
  .idea-strip { grid-template-columns: repeat(3, 1fr); }
  .idea-strip article { min-height: 143px; }
  .two-col { grid-template-columns: 1fr 1fr; }
  .clock-lab { grid-template-columns: 1.05fr .95fr; align-items: center; }
  .equation-card { grid-template-columns: 1.1fr .9fr; align-items: center; }
  .calculator-grid { grid-template-columns: .8fr 1.2fr; }
  .mass-story { grid-template-columns: repeat(3, 1fr); }
  .evidence-grid { grid-template-columns: repeat(2, 1fr); }
  .facts-panel { grid-template-columns: .72fr 1.28fr; }
}

@media (min-width: 900px) {
  .gravity-lab { grid-template-columns: minmax(0, 1.55fr) minmax(300px, .75fr); }
  .controls { border-left: 1px solid var(--line); }
  .data-readout { grid-template-columns: 1fr; }
  .gamma-panel { grid-template-columns: 1.1fr .9fr; align-items: center; }
}

@media (max-width: 540px) {
  .topbar { gap: 9px; padding-inline: 12px; }
  .brand { font-size: .9rem; }
  .brand-mark { width: 27px; height: 27px; }
  .tab { padding: 0 8px; font-size: .8rem; }
  main { padding-inline: 13px; }
  .section-heading, .tool-head { align-items: flex-start; flex-direction: column; }
  .data-readout { gap: 5px; }
  .data-readout div { padding-inline: 5px; }
  .data-readout strong { font-size: .72rem; }
  footer { align-items: flex-start; flex-direction: column; }
}
