:root {
  --bg: #0c0c0c;
  --fg: #ffffff;
  --muted: rgba(255, 255, 255, 0.74);
  --quiet: rgba(255, 255, 255, 0.56);
  --border: rgba(255, 255, 255, 0.2);
  --line: rgba(255, 255, 255, 0.12);
  --accent: #797af2;
  --cream: #f6f6ef;
  --ink: #0c0c0c;
  --stage: #000000;
  --nav: 76px;
  --measure: 760px;
  --wide: 1040px;
  --serif: "Source Serif 4", Georgia, "Iowan Old Style", Palatino, serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.55;
}

body[data-theme="day"] {
  --bg: var(--cream);
  --fg: var(--ink);
  --muted: rgba(12, 12, 12, 0.78);
  --quiet: rgba(12, 12, 12, 0.58);
  --border: rgba(12, 12, 12, 0.18);
  --line: rgba(12, 12, 12, 0.1);
  --stage: #111111;
}

a { color: inherit; }

::selection { background: var(--accent); color: white; }

.nav {
  position: fixed;
  top: 0;
  left: 50%;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(var(--wide), calc(100% - 40px));
  height: var(--nav);
  transform: translateX(-50%);
  pointer-events: none;
}

.brand, .nav-controls { pointer-events: auto; }

.brand {
  color: inherit;
  font-size: 15px;
  letter-spacing: 0.08em;
  text-decoration: none;
  text-transform: uppercase;
}

.nav-controls { display: flex; gap: 10px; }

.icon-button {
  display: inline-flex;
  width: 38px;
  height: 38px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: color-mix(in srgb, var(--bg) 55%, transparent);
  color: inherit;
  cursor: pointer;
  backdrop-filter: blur(16px);
  transition: border-color 160ms ease, transform 160ms ease, background 160ms ease;
}

.icon-button:hover {
  border-color: color-mix(in srgb, var(--fg) 66%, transparent);
  transform: translateY(-1px);
}

.icon-button[aria-expanded="true"] {
  border-color: var(--accent);
}

.outline {
  position: fixed;
  top: calc(var(--nav) - 8px);
  left: 22px;
  z-index: 35;
  width: min(280px, calc(100vw - 32px));
  max-height: calc(100vh - var(--nav) - 24px);
  overflow: auto;
  padding: 18px 18px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(18px);
}

.outline[hidden] { display: none; }

.outline p {
  margin: 0 0 10px;
  color: var(--quiet);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.outline a {
  display: block;
  padding: 6px 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.3;
  text-decoration: none;
}

.outline a[data-level="2"] { padding-left: 14px; font-size: 14px; }

.outline a.is-active { color: var(--fg); }

.page {
  width: min(var(--wide), calc(100% - 40px));
  margin: 0 auto;
  padding: calc(var(--nav) + 18px) 0 80px;
}

.hero { max-width: 920px; padding-top: 28px; }

.kicker {
  margin: 0 0 18px;
  color: var(--quiet);
  font-size: 13px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(44px, 6.4vw, 78px);
  font-weight: 450;
  letter-spacing: -0.025em;
  line-height: 0.98;
}

.subtitle {
  max-width: 16em;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: clamp(22px, 2.4vw, 30px);
  font-weight: 400;
  line-height: 1.25;
}

.authors {
  max-width: 46rem;
  margin: 28px 0 0;
  font-size: 18px;
  line-height: 1.65;
}

.authors sup { color: var(--accent); font-size: 0.72em; }

.affiliations {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.5;
}

.affiliations a { color: inherit; }

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 28px;
}

.button {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: inherit;
  font: inherit;
  font-size: 15px;
  text-decoration: none;
  cursor: pointer;
  background: transparent;
}

.button.primary {
  border-color: transparent;
  background: var(--fg);
  color: var(--bg);
}

.button:hover { border-color: color-mix(in srgb, var(--fg) 55%, transparent); }

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  max-width: var(--wide);
  margin: 54px 0 0;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.stats strong {
  display: block;
  font-size: clamp(28px, 3vw, 40px);
  font-weight: 450;
  letter-spacing: -0.03em;
  line-height: 1;
}

.stats span {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.4;
}

section, .hero, h2, h3 {
  scroll-margin-top: calc(var(--nav) + 18px);
}

section { margin-top: 88px; }

.measure { max-width: var(--measure); }

h2 {
  margin: 0 0 18px;
  font-size: clamp(32px, 4vw, 46px);
  font-weight: 450;
  letter-spacing: -0.03em;
  line-height: 1.05;
}

h3 {
  margin: 36px 0 10px;
  font-size: 26px;
  font-weight: 450;
  letter-spacing: -0.02em;
}

p { margin: 0 0 16px; }

.lede { font-size: 20px; }

figure { margin: 28px 0; }

figure img, .stage video {
  display: block;
  width: 100%;
  height: auto;
  background: var(--stage);
}

.frame,
.plate {
  overflow: hidden;
  border-radius: 8px;
}

.frame { background: var(--stage); }

.plate {
  padding: 16px 14px 10px;
  background: #f6f6ef;
}

.plate img {
  background: #f6f6ef;
}

figcaption, .caption {
  margin-top: 10px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.gallery {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.gallery figcaption { grid-column: 1 / -1; }

.specs {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 8px 18px;
  margin: 22px 0 0;
  padding: 0;
}

.specs dt { color: var(--quiet); }

.specs dd { margin: 0; }

.pairs { display: grid; gap: 28px; margin-top: 28px; }

.pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.clip-label {
  margin: 0 0 8px;
  color: var(--quiet);
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.stage {
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  background: #000;
}

.stage .icon-button {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(0, 0, 0, 0.45);
  color: white;
  border-color: rgba(255, 255, 255, 0.35);
}

.stage video {
  width: 100%;
  height: min(62vh, 520px);
  object-fit: contain;
  background: #000;
}

.hero-video video { height: auto; max-height: none; aspect-ratio: 16 / 9; }

.table-wrap {
  overflow-x: auto;
  margin-top: 18px;
  border-top: 1px solid var(--border);
}

table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
  font-size: 15px;
  line-height: 1.35;
}

th, td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  white-space: nowrap;
}

th:first-child, td:first-child,
th:nth-child(2), td:nth-child(2) { text-align: left; }

th {
  color: var(--quiet);
  font-weight: 450;
  font-size: 13px;
  letter-spacing: 0.04em;
}

.bib {
  position: relative;
  margin: 0;
  padding: 18px 18px 16px;
  overflow: auto;
  border-radius: 8px;
  background: color-mix(in srgb, var(--fg) 6%, transparent);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.footer {
  margin-top: 88px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
  color: var(--quiet);
  font-size: 14px;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 28px;
  background: rgba(0, 0, 0, 0.78);
}

.modal[hidden] { display: none; }

.modal video {
  width: min(1100px, 100%);
  max-height: calc(100vh - 80px);
  background: #000;
}

.modal .icon-button {
  position: absolute;
  top: 18px;
  right: 18px;
}

.model-panel {
  margin-top: 28px;
  overflow: hidden;
  border: 1px solid rgba(12, 12, 12, 0.14);
  border-radius: 8px;
  background: #f6f6ef;
  color: #10263d;
}

.urdf-viewer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  min-height: 620px;
}

.urdf-canvas {
  position: relative;
  min-height: 620px;
  overflow: hidden;
  background: linear-gradient(140deg, #e3ebf2, #b9c8d4);
}

urdf-manipulator {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 620px;
  touch-action: none;
}

urdf-manipulator canvas { display: block; cursor: grab; }
urdf-manipulator canvas:active { cursor: grabbing; }

.viewer-status,
.viewer-help {
  position: absolute;
  left: 18px;
  z-index: 2;
  color: #5d7084;
  background: rgba(246, 246, 239, 0.92);
  pointer-events: none;
  font-size: 13px;
  line-height: 1.45;
}

.viewer-status {
  top: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
}

.viewer-status > span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #a5a9ae;
}

.viewer-status.ready > span { background: #2f7d4a; }
.viewer-status.error > span { background: #8c1515; }

.viewer-help {
  bottom: 18px;
  display: flex;
  flex-direction: column;
  padding: 8px 11px;
}

.joint-panel {
  padding: 28px 24px 22px;
  border-left: 1px solid rgba(12, 12, 12, 0.12);
  background: #f6f6ef;
}

.joint-panel .kicker { color: #5d7084; }

.joint-panel h3 {
  margin: 8px 0 10px;
  color: #10263d;
  font-size: 28px;
}

.joint-panel p,
.urdf-note { color: #5d7084; font-size: 14px; }

.joint-control {
  display: block;
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid rgba(12, 12, 12, 0.12);
}

.joint-control.active { border-top-color: #797af2; }

.joint-control-title,
.joint-scale {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.joint-control-title { align-items: baseline; margin-bottom: 10px; }
.joint-control-title output { color: #797af2; font-variant-numeric: tabular-nums; }
.joint-control input { width: 100%; accent-color: #797af2; cursor: ew-resize; }
.joint-scale { margin-top: 6px; color: #5d7084; font-size: 12px; }

.reset-joints {
  width: 100%;
  margin-top: 22px;
  padding: 10px 14px;
  border: 0;
  border-radius: 999px;
  background: #10263d;
  color: #f6f6ef;
  font: inherit;
  font-size: 15px;
  cursor: pointer;
}

.reset-joints:hover { background: #797af2; }
.joint-panel :disabled { cursor: not-allowed; opacity: 0.5; }
.urdf-note { margin-top: 18px; }

@media (max-width: 900px) {
  .urdf-viewer { grid-template-columns: 1fr; }
  .joint-panel { border-left: 0; border-top: 1px solid rgba(12, 12, 12, 0.12); }
  .urdf-canvas,
  urdf-manipulator { min-height: 460px; }
}

@media (max-width: 800px) {
  .nav, .page { width: min(100% - 32px, var(--wide)); }
  .stats, .gallery, .pair, .specs { grid-template-columns: 1fr; }
  .specs dt { margin-top: 8px; }
  section { margin-top: 64px; }
}
