:root {
  color-scheme: light;
  --ink: #16211e;
  --muted: #66706d;
  --paper: #f6f7f4;
  --surface: #ffffff;
  --line: #d9dfda;
  --teal: #087c75;
  --rust: #c35a2b;
  --gold: #d4a72c;
  --violet: #7458b6;
  --shadow: 0 24px 70px rgba(22, 33, 30, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(8, 124, 117, 0.08), transparent 34%),
    linear-gradient(315deg, rgba(195, 90, 43, 0.08), transparent 40%),
    var(--paper);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

a {
  color: inherit;
  text-decoration: none;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 64px;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(246, 247, 244, 0.88);
  backdrop-filter: blur(18px);
}

.brand {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0;
}

.topbar nav {
  display: flex;
  gap: 18px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 650;
}

.topbar nav a:hover {
  color: var(--teal);
}

.lab-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 24px;
  width: min(1480px, calc(100vw - 40px));
  min-height: calc(100svh - 64px);
  margin: 0 auto;
  padding: 24px 0;
}

.stage {
  position: relative;
  height: clamp(680px, calc(100svh - 112px), 780px);
  min-height: 680px;
  overflow: hidden;
  border: 1px solid rgba(22, 33, 30, 0.12);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.stage-copy {
  position: absolute;
  z-index: 2;
  top: 28px;
  left: 32px;
  width: min(500px, calc(100% - 64px));
  pointer-events: none;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--teal);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(34px, 4.2vw, 58px);
  line-height: 0.95;
  letter-spacing: 0;
}

.stage-copy p:last-child {
  max-width: 360px;
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.65;
}

#pendulumCanvas {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
}

.inspector {
  display: flex;
  flex-direction: column;
  gap: 22px;
  align-self: stretch;
  min-height: 680px;
  padding: 22px;
  border: 1px solid rgba(22, 33, 30, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 18px 50px rgba(22, 33, 30, 0.1);
}

.transport {
  display: grid;
  grid-template-columns: 48px 48px 1fr;
  align-items: center;
  gap: 10px;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface);
  font-size: 20px;
  font-weight: 800;
  cursor: pointer;
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    background 160ms ease;
}

.icon-button:hover {
  transform: translateY(-1px);
  border-color: rgba(8, 124, 117, 0.45);
  background: rgba(8, 124, 117, 0.08);
}

.panel-label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.transport strong {
  display: block;
  margin-top: 4px;
  font-size: 22px;
}

.control-group {
  display: grid;
  gap: 10px;
}

.control-group label {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  font-size: 14px;
  font-weight: 750;
}

.control-group output {
  color: var(--teal);
  font-variant-numeric: tabular-nums;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--teal);
}

.readouts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 0;
}

.readouts div {
  min-height: 78px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.readouts dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.readouts dd {
  margin: 8px 0 0;
  font-size: 18px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.equations {
  margin-top: auto;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
  line-height: 1.65;
}

.equations p {
  margin: 0 0 8px;
}

.equations p:last-child {
  margin-bottom: 0;
}

@media (max-width: 980px) {
  .lab-shell {
    grid-template-columns: 1fr;
    width: min(100vw - 28px, 760px);
  }

  .stage,
  .inspector {
    min-height: auto;
  }

  .stage {
    height: 560px;
  }

  #pendulumCanvas {
    min-height: 0;
  }
}

@media (max-width: 640px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
    padding: 14px 18px;
  }

  .lab-shell {
    width: calc(100vw - 20px);
    padding: 12px 0 20px;
  }

  .stage-copy {
    top: 20px;
    left: 20px;
    width: calc(100% - 40px);
  }

  .stage-copy p:last-child {
    max-width: 300px;
    font-size: 14px;
  }

  #pendulumCanvas {
    min-height: 0;
  }

  .stage {
    height: 520px;
  }

  .inspector {
    padding: 18px;
  }
}
