:root {
  color-scheme: dark;
  --bg: #0b0c13;
  --bg-raised: #11141b;
  --text: #e8ebf1;
  --text-muted: #9aa3b2;
  --line: rgba(226, 237, 255, 0.14);
  --line-strong: rgba(226, 237, 255, 0.32);
  --accent: #a58bff;
  --accent-contrast: #0b0c13;
  --col-text: 46rem;
  --col-wide: 66rem;
  --gutter: clamp(1.1rem, 4vw, 2.5rem);
  --section-space: clamp(3rem, 6vw, 4.5rem);
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #ffffff;
  --bg-raised: #f5f6f8;
  --text: #1a1d23;
  --text-muted: #5b6472;
  --line: rgba(20, 24, 35, 0.14);
  --line-strong: rgba(20, 24, 35, 0.32);
  --accent: #5f45c9;
  --accent-contrast: #ffffff;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 4.5rem;
  background: var(--bg);
}

body {
  min-width: 320px;
  margin: 0;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 1.02rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--accent) 45%, transparent);
  text-underline-offset: 0.18em;
}

a:hover {
  text-decoration-color: var(--accent);
}

img,
video {
  display: block;
  max-width: 100%;
}

button,
input,
textarea,
select {
  font: inherit;
}

h1,
h2,
h3,
p,
figure,
pre,
ol,
ul {
  margin: 0;
}

h1,
h2,
h3 {
  font-weight: 600;
  line-height: 1.2;
  text-wrap: balance;
}

p {
  text-wrap: pretty;
}

h1,
h2,
h3,
p,
figcaption {
  overflow-wrap: anywhere;
}

code,
pre {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  clip-path: inset(50%) !important;
  white-space: nowrap !important;
}

.skip-link {
  position: fixed;
  top: 0.8rem;
  left: 1rem;
  z-index: 200;
  padding: 0.6rem 0.9rem;
  background: var(--accent);
  color: var(--accent-contrast);
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  transform: translateY(-180%);
  transition: transform 180ms ease;
}

.skip-link:focus {
  transform: translateY(0);
}

/* Navigation */

.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}

.site-nav {
  display: flex;
  align-items: center;
  gap: clamp(1rem, 3vw, 2.2rem);
  max-width: var(--col-wide);
  min-height: 3.4rem;
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.nav-mark {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: none;
}

.nav-mark-dot {
  width: 0.5rem;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--accent);
}

.nav-links {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  gap: clamp(0.9rem, 2vw, 1.6rem);
}

.nav-links a {
  color: var(--text-muted);
  font-size: 0.88rem;
  text-decoration: none;
  transition: color 160ms ease;
}

.nav-links a:hover {
  color: var(--text);
}

.nav-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 0.7rem;
  margin-left: auto;
}

.theme-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  width: 3.2rem;
  height: 1.75rem;
  border: 1px solid var(--line-strong);
  border-radius: 1rem;
  background: var(--bg-raised);
  cursor: pointer;
  padding: 0 0.42rem;
  transition: border-color 160ms ease;
}

.theme-toggle:hover {
  border-color: var(--accent);
}

.theme-toggle-icon {
  color: var(--text-muted);
  font-size: 0.72rem;
  line-height: 1;
}

.theme-toggle-knob {
  position: absolute;
  top: 50%;
  left: 0.2rem;
  width: 1.25rem;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--accent);
  transform: translateY(-50%);
  transition: transform 220ms cubic-bezier(0.3, 0.9, 0.4, 1);
}

:root[data-theme="light"] .theme-toggle-knob {
  transform: translate(1.45rem, -50%);
}

.flexify-button {
  position: relative;
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  padding: 0.52rem 0.7rem;
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.11em;
  line-height: 1;
  text-transform: uppercase;
  transition:
    border-color 160ms ease,
    background 160ms ease,
    color 160ms ease;
}

.flexify-button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Twinkle + glow inviting the click while Flexify is off. */
.flexify-button[aria-pressed="false"] {
  animation: flexify-glow 2.8s ease-in-out infinite;
}

.flexify-button[aria-pressed="false"]::before,
.flexify-button[aria-pressed="false"]::after {
  position: absolute;
  color: var(--accent);
  font-size: 0.85rem;
  line-height: 1;
  opacity: 0;
  pointer-events: none;
  content: "✦";
  text-shadow: 0 0 6px var(--accent);
  animation: flexify-sparkle 2.8s ease-in-out infinite;
}

.flexify-button[aria-pressed="false"]::before {
  top: -0.6rem;
  right: -0.45rem;
}

.flexify-button[aria-pressed="false"]::after {
  bottom: -0.55rem;
  left: -0.42rem;
  font-size: 0.65rem;
  animation-delay: 1.4s;
}

@keyframes flexify-sparkle {
  0%,
  30%,
  100% {
    opacity: 0;
    transform: scale(0.3) rotate(0deg);
  }

  50% {
    opacity: 1;
    transform: scale(1.15) rotate(45deg);
  }

  75% {
    opacity: 0;
    transform: scale(0.4) rotate(90deg);
  }
}

@keyframes flexify-glow {
  0%,
  100% {
    border-color: var(--line-strong);
    box-shadow: 0 0 0 rgba(165, 139, 255, 0);
  }

  50% {
    border-color: var(--accent);
    box-shadow: 0 0 10px rgba(165, 139, 255, 0.45);
  }
}

.flexify-button[aria-pressed="true"] {
  border-color: transparent;
  background: linear-gradient(
    90deg,
    #ff5470 0 16.6%,
    #ffae45 16.6% 33.2%,
    #f3ec5b 33.2% 49.8%,
    #57df9b 49.8% 66.4%,
    #5ee7f4 66.4% 83%,
    #c06cff 83% 100%
  );
  color: #05060a;
}

/* Paper header */

.paper-header {
  max-width: var(--col-wide);
  margin: 0 auto;
  padding: clamp(1.5rem, 3.5vw, 2.5rem) var(--gutter) var(--section-space);
  text-align: center;
}

.hero-mosaic {
  position: relative;
  width: 100%;
  aspect-ratio: 2406 / 396;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  touch-action: pan-y;
}

.hero-mosaic-layer,
.hero-mosaic-layer img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.hero-mosaic-layer img {
  object-fit: fill;
}

.hero-mosaic-prediction {
  /* Default and no-JS state is grayscale; JS reveals the sheet left of the
     handle by shrinking the right inset of this clip. */
  clip-path: inset(0 100% 0 0);
}

html.js .hero-mosaic-prediction {
  /* Match the slider's initial half-revealed state from the first paint so
     the overlay does not flicker on when main.js starts the sweep. */
  clip-path: inset(0 50% 0 0);
}

.hero-mosaic-handle {
  display: none;
  position: absolute;
  top: 0;
  bottom: 0;
  /* Pre-JS paint keeps the handle centered; main.js re-bases it to left: 0
     and drives position with a compositor-only translateX from then on. */
  left: 50%;
  width: 2.75rem;
  transform: translateX(-50%);
  cursor: ew-resize;
  touch-action: none;
}

html.js .hero-mosaic-handle {
  display: block;
}

.hero-mosaic-handle[hidden] {
  display: none !important;
}

.hero-mosaic-handle::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  transform: translateX(-50%);
  background: var(--accent);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35);
}

.hero-mosaic-knob {
  position: absolute;
  top: 50%;
  left: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  width: 2.1rem;
  height: 2.1rem;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: var(--bg-raised);
  color: var(--text);
  font-size: 0.6rem;
  cursor: grab;
}

.hero-mosaic-handle.is-dragging,
.hero-mosaic-handle.is-dragging .hero-mosaic-knob {
  cursor: grabbing;
}

.hero-mosaic-handle:focus-visible {
  outline: none;
}

.hero-mosaic-handle:focus-visible .hero-mosaic-knob {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.paper-header h1 {
  max-width: 54rem;
  margin: 0 auto;
  font-size: clamp(2.2rem, 4.6vw, 3.4rem);
}

.paper-authors {
  max-width: 44rem;
  margin: 1.1rem auto 0;
  color: var(--text);
  font-size: 1rem;
}

.paper-authors a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--text) 30%, transparent);
  text-underline-offset: 0.18em;
  transition:
    color 160ms ease,
    text-decoration-color 160ms ease;
}

.paper-authors a:hover,
.paper-authors a:focus-visible {
  color: var(--accent);
  text-decoration-color: var(--accent);
}

.paper-affiliations {
  max-width: 43rem;
  margin: 0.35rem auto 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.paper-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.55rem;
  margin-top: 1.4rem;
}

.action {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  border: 1px solid var(--line-strong);
  border-radius: 2rem;
  padding: 0.45rem 1.05rem;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 500;
  text-decoration: none;
  transition:
    border-color 160ms ease,
    color 160ms ease;
}

.action:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.action-disabled {
  border-style: dashed;
  color: var(--text-muted);
  cursor: not-allowed;
}

.action small {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.action-icon {
  font-size: 1.05em;
  line-height: 1;
}

/*
 * The row centers on the pill alone: the copy button is out of flow, hanging
 * off the pill's right edge, so it does not shift the centering.
 */
.install-row {
  position: relative;
  display: inline-flex;
  margin-top: 1.3rem;
}

.paper-install {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  border: 1px solid var(--line);
  border-radius: 0.35rem;
  background: var(--bg-raised);
  padding: 0.6rem 1rem;
  color: var(--text);
  font-size: 0.88rem;
}

.paper-install > span {
  color: var(--accent);
}

.install-copy {
  position: absolute;
  top: 50%;
  left: calc(100% + 0.6rem);
  transform: translateY(-50%);
  min-width: 5.4em;
  padding: 0.45rem 0.7rem;
  font-size: 0.75rem;
  text-align: center;
}

.hero-figure {
  margin-top: clamp(2rem, 4.5vw, 3rem);
}

/* Sections */

.section {
  max-width: var(--col-wide);
  margin: 0 auto;
  padding: 0 var(--gutter) var(--section-space);
}

.section > h2,
.section > h3,
.section > p,
.section > ol,
.section > ul,
.section > .bibtex-wrap {
  max-width: var(--col-text);
  margin-left: auto;
  margin-right: auto;
}

.section > h2 {
  margin-bottom: 1rem;
  padding-top: 0.5rem;
  font-size: 1.45rem;
}

.abstract-card {
  max-width: calc(var(--col-text) + 4.4rem);
  margin: 0 auto;
  border: 1px solid rgba(165, 139, 255, 0.4);
  border-radius: 1rem;
  background: rgba(165, 139, 255, 0.08);
  background: color-mix(in srgb, var(--accent) 8%, var(--bg));
  padding: 1.7rem 2.2rem 1.9rem;
}

:root[data-theme="light"] .abstract-card {
  border-color: rgba(95, 69, 201, 0.35);
  background: rgba(95, 69, 201, 0.06);
  background: color-mix(in srgb, var(--accent) 6%, var(--bg));
}

.abstract-card h2 {
  margin-bottom: 1rem;
  font-size: 1.45rem;
}

.section > h3 {
  margin-top: 1.8rem;
  margin-bottom: 0.6rem;
  font-size: 1.1rem;
}

.section > p + p {
  margin-top: 1rem;
}

.method-steps {
  margin-top: 1rem;
  padding-left: 1.4rem;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.method-steps li + li {
  margin-top: 0.35rem;
}

/* Figures */

.paper-figure,
.motion-figure {
  width: 100%;
  margin-top: clamp(1.6rem, 3.5vw, 2.4rem);
}

.figure-narrow {
  max-width: 30rem;
  margin-left: auto;
  margin-right: auto;
}

/* Two-column section: prose beside a narrow figure. */
.section-split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(16rem, 24rem);
  gap: clamp(2rem, 5vw, 4.5rem);
  align-items: center;
}

.section-split .section-copy {
  max-width: var(--col-text);
  justify-self: end;
  width: 100%;
}

.section-split .section-copy h2 {
  margin-bottom: 1rem;
  padding-top: 0.5rem;
  font-size: 1.45rem;
}

.section-split .paper-figure {
  margin-top: 0;
}

.section-split figcaption {
  max-width: none;
}

.paper-figure img,
.motion-poster {
  width: 100%;
  height: auto;
  background: var(--bg);
}

figcaption {
  max-width: var(--col-text);
  margin: 0 auto;
  padding-top: 0.8rem;
  color: var(--text-muted);
  font-size: 0.88rem;
  line-height: 1.5;
  text-align: left;
}

figcaption strong {
  color: var(--text);
  font-weight: 600;
}

.motion-frame {
  position: relative;
  overflow: hidden;
  background: var(--bg);
  isolation: isolate;
}

.motion-dark {
  background: #000000;
}

.motion-frame video {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  background: #06070a;
  object-fit: cover;
  opacity: 0;
  transition: opacity 300ms ease;
}

.motion-frame.video-ready video {
  opacity: 1;
}

.motion-poster {
  transition: opacity 300ms ease;
}

.motion-frame.video-ready .motion-poster {
  opacity: 0;
}

.motion-dark .motion-poster {
  background: #000000;
}

/* Attributions page */

.attribution-list {
  margin-top: 1rem;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.45rem;
  font-size: 0.92rem;
}

.attribution-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0.8rem;
}

.attribution-list code {
  color: var(--text-muted);
  font-size: 0.82rem;
}

.attribution-pending {
  color: var(--text-muted);
  font-style: italic;
}

/* Resources */

.resource-links {
  margin-top: 1.2rem;
  padding: 0;
  border-top: 1px solid var(--line-strong);
  list-style: none;
}

.resource-links a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--line);
  color: var(--text);
  text-decoration: none;
  transition: color 160ms ease;
}

.resource-links a:hover {
  color: var(--accent);
}

.resource-links span {
  font-size: 1rem;
  font-weight: 500;
}

.resource-links small {
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* Citation */

pre {
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-left: 2px solid var(--accent);
  background: var(--bg-raised);
  color: var(--text);
  font-size: clamp(0.72rem, 1vw, 0.85rem);
  line-height: 1.7;
  padding: 1.1rem 1.3rem;
  tab-size: 2;
}

.bibtex-wrap {
  position: relative;
  min-width: 0;
  margin-top: 1.2rem;
  padding-top: 3rem;
}

.copy-button {
  border: 1px solid var(--line-strong);
  border-radius: 2rem;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  padding: 0.5rem 0.95rem;
  font-size: 0.8rem;
  font-weight: 500;
  transition:
    border-color 160ms ease,
    background 160ms ease,
    color 160ms ease;
}

.copy-button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.copy-button.copy-done {
  border-color: var(--accent);
  color: var(--accent);
}

.bibtex-wrap .copy-button {
  position: absolute;
  top: 0;
  right: 0;
}

.copy-status {
  position: absolute;
  top: 0.6rem;
  left: 0;
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* Footer */

.site-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  max-width: var(--col-wide);
  margin: 0 auto;
  padding: 2rem var(--gutter) 3rem;
  border-top: 1px solid var(--line);
  color: var(--text-muted);
  font-size: 0.85rem;
}

.footer-copy {
  display: grid;
  gap: 0.35rem;
}

.site-footer .footer-credit {
  color: var(--text-muted);
}

.footer-credit a {
  margin: 0 0.1em;
}

/* Flexify easter egg: smooth accent-family gradient text */

:root {
  --flex-grad-a: #8fb0ff;
  --flex-grad-b: #b39bff;
  --flex-grad-c: #e39bd4;
}

:root[data-theme="light"] {
  --flex-grad-a: #3f63c9;
  --flex-grad-b: #5f45c9;
  --flex-grad-c: #a03e93;
}

@supports ((-webkit-background-clip: text) or (background-clip: text)) {
  html.is-flexified body :where(
      h1,
      h2,
      h3,
      p,
      figcaption,
      code,
      .nav-mark,
      .nav-links a,
      .resource-links span,
      .resource-links small,
      .site-footer a
    ),
  html.is-flexified body :where(h1, h2, h3, p, figcaption) * {
    background-image: linear-gradient(
      96deg,
      var(--flex-grad-a),
      var(--flex-grad-b) 55%,
      var(--flex-grad-c)
    );
    background-clip: text;
    color: transparent !important;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
  }
}

/* Responsive */

@media (max-width: 1050px) {
  .hero-mosaic {
    aspect-ratio: 1602 / 664;
  }
}

@media (max-width: 780px) {
  .section-split {
    grid-template-columns: 1fr;
  }

  .section-split .section-copy {
    justify-self: center;
  }

  .site-nav {
    gap: 1rem;
  }

  .nav-links {
    justify-content: flex-start;
    gap: 1rem;
    min-width: 0;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .nav-links::-webkit-scrollbar {
    display: none;
  }

  .nav-links a:nth-child(4) {
    display: none;
  }

  .site-footer {
    align-items: flex-start;
    flex-direction: column;
    gap: 1rem;
  }
}

@media (max-width: 640px) {
  .hero-mosaic {
    aspect-ratio: 1200 / 798;
  }
}

@media (max-width: 480px) {
  .title-break {
    display: none;
  }

  .nav-links a:nth-child(2) {
    display: none;
  }

  .paper-actions {
    gap: 0.45rem;
  }

  pre {
    font-size: 0.68rem;
    padding: 0.9rem;
  }

  .bibtex-wrap .copy-button {
    position: static;
    margin-bottom: 0.8rem;
  }

  /* No horizontal room for the hanging button; drop it below the pill. */
  .install-row {
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
  }

  .install-copy {
    position: static;
    transform: none;
  }

  .copy-status {
    top: 0.75rem;
    right: 0;
    left: auto;
  }

  .bibtex-wrap {
    padding-top: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
