* { box-sizing: border-box; }

body {
  font-family: Palatino, "Palatino Linotype", "Palatino LT STD", "Book Antiqua", Georgia, serif;
  line-height: 1.6;
  color: #333;
  background: #fff;
  max-width: 60em;
  margin: 0 auto;
  padding: 28px 20px 40px;
}

header { text-align: center; margin-bottom: 40px; }
h1 { color: #2c3e50; line-height: 1.2; margin: 0.6em 0; font-size: 2.25em; text-wrap: balance; }
h2, h3 { color: #34495e; line-height: 1.35; text-wrap: balance; }
h2 { font-size: 1.55em; margin: 1em 0; }
h3 { font-size: 1.18em; margin: 2em 0 0.8em; }
p { margin: 0.9em 0; }
a { color: #20638f; text-decoration: none; }
a:hover { color: #aa551c; text-decoration: underline; }
sup { font-size: 0.65em; }

.authors, .affiliations, .links {
  display: flex;
  justify-content: center;
  align-items: baseline;
  flex-wrap: wrap;
}
.authors { gap: 0.25em 1.2em; font-size: 1.2em; }
.author { font-weight: bold; white-space: nowrap; }
.author sup { font-weight: normal; margin-left: 0.15em; }
.affiliations { gap: 0.2em 1.5em; margin-top: 0.4em; font-size: 1.1em; }
.affiliations > span { white-space: nowrap; }
.links { gap: 1em; margin-top: 20px; }
.button {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  background: #363636;
  color: #fff;
  padding: 0.45em 1.25em;
  border: 1px solid #363636;
  border-radius: 999px;
  font-size: 1rem;
  white-space: nowrap;
}
.button:hover { background: #4a4a4a; color: #fff; text-decoration: none; }
.button svg { width: 1em; height: 1em; fill: currentColor; }

section { padding: 0 1em; }
section + section { margin-top: 2.25em; padding-top: 1em; border-top: 2px solid #eee; }
.abstract { margin: 1em 10% 2em; text-align: justify; }
.abstract h2 { text-align: center; color: #1a1a1a; font-size: 1.25em; margin-bottom: 0; }

.theorem {
  margin: 1.5em 8%;
  padding: 0.3em 1.2em;
  border: 1px solid #aaa;
  background: #f4f4f4;
  border-radius: 4px;
}
.theorem h3 { margin-top: 0.7em; }

.math-block { overflow-x: auto; overflow-y: hidden; padding: 0.3em 0; }

figure { margin: 2.2em 0; }
figure img, figure video { display: block; width: 100%; height: auto; }
figcaption { width: 90%; margin: 1em auto 0; font-size: 0.9em; color: #666; }
figcaption .fig-num { font-weight: bold; color: #555; }
.panel-caption { margin: 0.6em 0 0; text-align: center; font-size: 0.9em; font-weight: bold; color: #666; }

.maps-row { display: grid; grid-template-columns: 2.36fr 1.15fr 1.52fr; gap: 1.6em; align-items: end; }
.maps-row > div { min-width: 0; }

.figure-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 1.6em; align-items: start; }
.figure-pair > * { min-width: 0; }

/* Trajectory panels: video on top, synced empowerment plot below */
.traj-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 2.2em 1.8em; align-items: start; margin: 1.5em 0 2em; }
.traj { min-width: 0; }
.traj-title { margin: 0 0 0.4em; text-align: center; font-weight: bold; color: #444; }
.traj-desc { font-size: 0.92em; color: #555; margin: 0.6em 0 0; }
.traj video { display: block; width: 100%; height: auto; border-radius: 4px; background: #1b2236; aspect-ratio: 840 / 680; object-fit: cover; }
.traj video.contain { object-fit: contain; background: #fff; }
.traj .stage { position: relative; }
.traj svg.overlay { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; pointer-events: none; cursor: auto; overflow: hidden; }
.traj svg { display: block; width: 100%; height: auto; margin-top: 0.4em; touch-action: none; cursor: ew-resize; user-select: none; font-family: inherit; }
.traj .controls { display: flex; align-items: center; gap: 0.6em; margin-top: 0.3em; font-size: 0.85em; color: #666; }
.traj .controls button {
  font: inherit; font-size: 0.9em; background: #363636; color: #fff; border: 0; border-radius: 999px;
  padding: 0.15em 0.9em; cursor: pointer;
}
.traj .controls button:hover { background: #4a4a4a; }
.traj .controls .tval { margin-left: auto; font-variant-numeric: tabular-nums; }

.baseline-stack img + img { margin-top: 0.8em; }
.row-label { font-size: 0.85em; color: #666; margin: 0.8em 0 0.2em; font-weight: bold; }

.algo { margin: 1.5em 8%; padding: 0.6em 1.2em; border-top: 2px solid #555; border-bottom: 2px solid #555; font-size: 0.95em; }
.algo-title { font-weight: bold; border-bottom: 1px solid #999; padding-bottom: 0.3em; margin-bottom: 0.4em; }
.algo ol { margin: 0.3em 0; padding-left: 1.6em; }
.algo li { margin: 0.15em 0; }
.algo .cm { color: #888; float: right; font-size: 0.85em; }

/* Online curves */
.toggle { display: flex; justify-content: center; gap: 0.6em; margin-bottom: 1em; }
.toggle button {
  font: inherit; font-size: 0.95rem; background: #fff; color: #363636; border: 1px solid #363636;
  border-radius: 999px; padding: 0.3em 1.1em; cursor: pointer;
}
.toggle button.active, .toggle button:hover { background: #363636; color: #fff; }
.online-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.2em; }
.online-panel { position: relative; min-width: 0; }
.online-panel h5 { margin: 0 0 0.2em; font-size: 0.95em; font-weight: normal; color: #333; text-align: center; line-height: 1.3; }
.online-panel h5 span { color: #888; }
.online-panel svg { display: block; width: 100%; height: auto; overflow: visible; font-family: inherit; }
.legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.3em 1.4em; margin-top: 0.8em; font-size: 0.9em; color: #555; }
.legend .item { display: inline-flex; align-items: center; gap: 0.45em; cursor: pointer; user-select: none; }
.legend .item.off { opacity: 0.35; }
.legend svg { width: 28px; height: 10px; }
.tip {
  position: absolute; pointer-events: none; z-index: 5;
  background: #fff; color: #333; border: 1px solid #ccc; border-radius: 4px;
  padding: 0.3em 0.6em; font-size: 0.78em; line-height: 1.45; white-space: nowrap;
  opacity: 0; box-shadow: 0 2px 6px rgba(0,0,0,0.12); font-variant-numeric: tabular-nums;
}
.tip .sw { display: inline-block; width: 0.7em; height: 0.7em; border-radius: 2px; margin-right: 0.4em; }

pre {
  margin: 1em 0; padding: 1em; background: #f0f0f0; border-radius: 4px;
  font-size: 0.85rem; overflow-x: auto; white-space: pre-wrap; overflow-wrap: anywhere;
}

@media (max-width: 767px) {
  body { padding: 20px 16px 32px; }
  header { margin-bottom: 28px; }
  h1 { font-size: 1.9em; }
  h2 { font-size: 1.35em; }
  section { padding-left: 0; padding-right: 0; }
  .abstract { margin: 1em 0; text-align: left; }
  .theorem, .algo { margin: 1.25em 0; padding-left: 0.9em; padding-right: 0.9em; }
  .algo .cm { display: none; }
  .maps-row, .figure-pair, .online-grid, .traj-grid { grid-template-columns: 1fr; }
  figcaption { width: 100%; }
  .authors { font-size: 1.08em; gap: 0.3em 1em; }
  .affiliations { font-size: 1em; }
}
