/* Card-based technical layout: Inter for text, JetBrains Mono for labels and counters. */

:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --ink: #0f1115;
  --text: #2a2e37;
  --muted: #646b78;
  --faint: #9aa1ad;
  --line: #e3e6eb;
  --accent: #3554e0;
  --accent-ink: #2440c4;
  --accent-soft: #e8edfd;
  --noop: #cfd4dc;
  --filler: #e3cf9f;
  --frame-bg: #1b1e24;
  --radius: 14px;
  --sans: 'Inter', -apple-system, 'Segoe UI', Helvetica, Arial, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
strong { color: var(--ink); font-weight: 600; }

.container { max-width: 1080px; margin: 0 auto; padding: 0 16px; }

/* ---------------------------- Masthead ---------------------------- */

.masthead { text-align: center; padding-top: 72px; padding-bottom: 40px; }
.eyebrow { margin: 10px 0 0; font-size: 15px; font-weight: 500; color: var(--muted); }
.title {
  font-size: 50px; line-height: 1.1; font-weight: 800; letter-spacing: -0.03em;
  color: var(--ink); margin: 0 0 24px;
}
.title-accent { color: var(--accent); }
.title-ace { height: 1.05em; width: auto; flex: 0 0 auto; filter: drop-shadow(0 4px 10px rgba(15, 17, 21, 0.18)); }
.title-name {
  display: flex; align-items: center; justify-content: center; gap: 0.18em; margin-bottom: 14px;
  font-size: 1.5em; line-height: 1; letter-spacing: -0.04em; color: var(--ink);
}
.authors { margin: 0; font-size: 17px; display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 22px; }
.authors a { color: var(--ink); font-weight: 500; }
.authors .author-name { color: var(--ink); font-weight: 500; }
.authors sup { color: var(--accent); font-weight: 600; margin-left: 1px; line-height: 0; }
.equal { margin: 8px 0 0; font-size: 13px; color: var(--muted); }

.links { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 26px; }
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 18px; border-radius: 10px;
  background: var(--ink); color: #fff; font-weight: 600; font-size: 14px;
  transition: background 0.15s, transform 0.15s;
}
.btn:hover { background: #2a2f3a; text-decoration: none; transform: translateY(-1px); }
.btn svg { width: 16px; height: 16px; }
.btn svg.icon-arxiv { width: 19px; height: 19px; margin: -2px -1px; }
.btn-soon { background: #e4e7ec; color: var(--muted); cursor: default; }
.btn-soon:hover { background: #e4e7ec; transform: none; }
.btn-divider { width: 1px; align-self: stretch; margin: 2px 2px; background: #b9c0cb; }
.btn-note { font-weight: 500; }

/* ---------------------------- Cards ---------------------------- */

main { display: flex; flex-direction: column; gap: 20px; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 32px 36px; box-shadow: 0 1px 2px rgba(15, 17, 21, 0.04), 0 6px 24px rgba(15, 17, 21, 0.04);
}
.card-head { margin-bottom: 16px; }
.card-head h2 { margin: 0; font-size: 26px; font-weight: 700; letter-spacing: -0.02em; color: var(--ink); }

.prose p, p.prose { margin: 0 0 1em; }
.prose p:last-child { margin-bottom: 0; }
.card > p.prose { margin-bottom: 20px; color: var(--muted); }

.teaser-card { padding: 20px; }
.tldr-block { max-width: 900px; margin: 0 auto 8px; text-align: center; }
.tldr-label {
  margin: 0 0 10px; font-size: 14px; font-weight: 800; letter-spacing: 0.18em; color: var(--accent);
}
.tldr-text { margin: 0; font-size: 25px; line-height: 1.45; font-weight: 500; letter-spacing: -0.01em; color: var(--ink); }
.tldr-text mark {
  color: inherit; font-weight: 700; padding: 0 2px;
  background: linear-gradient(transparent 58%, #d6dffb 58%);
}
.teaser-caption { text-align: center; margin-top: 14px; }

.figure { margin: 28px 0 0; }
.figure figcaption, .caption {
  font-size: 13.5px; line-height: 1.6; color: var(--muted); margin-top: 14px;
}
.caption { margin-bottom: 0; }
.method-img { width: 100%; display: block; border-radius: 8px; }

.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.card.mini { padding: 24px; }
.card.mini h3 { margin: 0 0 6px; font-size: 17px; font-weight: 700; color: var(--ink); letter-spacing: -0.01em; }
.card.mini p { margin: 0; font-size: 14.5px; line-height: 1.6; }

.idea-icon { display: block; width: 30px; height: 30px; margin-bottom: 14px; color: var(--accent); }
.idea-icon svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

/* Asymmetric conditioning diagram: two lanes on one grid so the nodes line up. */
.ac-card { padding: 28px 36px 26px; }
.ac-title { margin: 0 0 18px; font-size: 18px; font-weight: 700; color: var(--ink); letter-spacing: -0.01em; }
.ac-lane + .ac-lane { margin-top: 18px; padding-top: 18px; border-top: 1px dashed var(--line); }
.ac-who { margin: 0 0 8px; font-size: 14px; font-weight: 700; color: var(--ink); }
.is-teacher .ac-who { color: var(--accent); }
.ac-flow {
  display: grid; align-items: end; column-gap: 6px;
  grid-template-columns: 46px 1fr 46px 1fr 46px 1fr 46px 1fr 46px;
}
.ac-flow-teacher .ac-arrow { grid-column: 2 / 9; }
.ac-flow-teacher .ac-node:last-child { grid-column: 9; }
.ac-node {
  width: 46px; height: 46px; border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-size: 15px; font-weight: 600; color: var(--ink);
  border: 1.5px solid; 
}
.ac-node.is-clean { background: #e9f7ef; border-color: #8fcfaa; }
.ac-node.is-own { background: #fdf3e1; border-color: #e5bf7c; }
.ac-node.is-out { background: #fff; border-color: var(--accent); color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.ac-arrow { display: flex; flex-direction: column; align-items: stretch; justify-content: flex-end; height: 46px; min-width: 0; }
.ac-arrow-text {
  font-size: 12.5px; line-height: 1.2; text-align: center; color: var(--muted);
  margin-bottom: 5px; overflow-wrap: anywhere;
}
.ac-arrow-line { position: relative; height: 2px; margin: 0 4px 22px; background: #c3c9d3; }
.ac-arrow-line::after {
  content: ""; position: absolute; right: -2px; top: -4px;
  border-left: 7px solid #c3c9d3; border-top: 5px solid transparent; border-bottom: 5px solid transparent;
}
.ac-arrow.is-now .ac-arrow-text { color: var(--ink); font-weight: 600; }
.ac-arrow.is-now .ac-arrow-line, .ac-arrow.is-compound .ac-arrow-line { background: var(--ink); }
.ac-arrow.is-now .ac-arrow-line::after { border-left-color: var(--ink); }
.ac-arrow.is-compound .ac-arrow-text { color: var(--accent); font-weight: 600; font-size: 14px; }
.ac-arrow.is-compound .ac-arrow-line { background: var(--accent); }
.ac-arrow.is-compound .ac-arrow-line::after { border-left-color: var(--accent); }
.xhat { position: relative; display: inline-block; }
.xhat::after {
  content: ""; position: absolute; left: 50%; top: 0.2em; width: 0.26em; height: 0.26em;
  border-left: 0.085em solid currentColor; border-top: 0.085em solid currentColor;
  transform: translateX(-50%) rotate(45deg);
}
.ac-note { margin: 10px 0 0; font-size: 13.5px; color: var(--muted); }
.ac-legend { display: flex; flex-wrap: wrap; gap: 6px 20px; margin: 20px 0 0; font-size: 12.5px; color: var(--muted); }
.ac-dot { display: inline-block; width: 11px; height: 11px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; border: 1.5px solid; }
.ac-dot.is-clean { background: #e9f7ef; border-color: #8fcfaa; }
.ac-dot.is-own { background: #fdf3e1; border-color: #e5bf7c; }
.ac-dot.is-out { background: #fff; border-color: var(--accent); }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.stat { padding: 20px 22px; display: flex; flex-direction: column; gap: 4px; }
.stat-v { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; color: var(--ink); line-height: 1.25; }
.stat-k { font-family: var(--mono); font-size: 11.5px; color: var(--muted); }

.footer { padding-top: 40px; padding-bottom: 48px; text-align: center; font-size: 13px; color: var(--faint); }
.footer p { margin: 0; }

/* ---------------------------- Turn viewer ---------------------------- */

.turn-viewer { outline: none; border-radius: 10px; }
.turn-viewer:focus-visible { box-shadow: 0 0 0 3px var(--accent-soft); }

.tv-panels { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tv-panel { position: relative; }
.tv-frame {
  position: relative; aspect-ratio: 1 / 1; overflow: hidden; border-radius: 10px;
  background: var(--frame-bg);
}
/* Two stacked buffers per panel; the hidden one decodes the next frame before it is shown. */
.tv-frame img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block;
  opacity: 0;
}
.tv-frame img.is-front { opacity: 1; }
.tv-label {
  position: absolute; left: 10px; top: 10px; z-index: 2;
  padding: 4px 10px; border-radius: 7px;
  font-family: var(--mono); font-size: 12px; font-weight: 600;
  color: #fff; background: rgba(15, 17, 21, 0.72); backdrop-filter: blur(6px);
}
.tv-ours .tv-label { background: rgba(53, 84, 224, 0.92); }

.tv-info { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; margin: 18px 2px 10px; min-height: 28px; }
.tv-turn {
  font-family: var(--mono); font-size: 13px; font-weight: 600; color: var(--ink);
  font-variant-numeric: tabular-nums; min-width: 7.5em;
}
.tv-kind { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
.tv-kind-edit { color: var(--accent); }
.tv-kind-noop, .tv-kind-orig { color: var(--faint); }
.tv-kind-filler { color: #a3803c; }
.tv-instr { flex: 1 1 260px; font-size: 15.5px; font-weight: 500; color: var(--ink); }

.tv-controls { display: flex; align-items: center; gap: 14px; margin: 0 2px; }
.tv-play {
  flex: 0 0 auto; width: 38px; height: 38px; padding: 0; border-radius: 10px;
  border: none; background: var(--ink); color: #fff; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; transition: background 0.15s;
}
.tv-play:hover { background: var(--accent); }
.tv-play svg { width: 13px; height: 13px; fill: currentColor; }

.tv-track { position: relative; flex: 1; height: 38px; }
.tv-ticks {
  position: absolute; left: 0; right: 0; top: 50%; transform: translateY(-50%);
  display: flex; gap: 3px; height: 10px;
}
.tv-tick { flex: 1; border-radius: 3px; background: #edf0f4; transition: background 0.12s; }
.tv-tick-edit { background: #cdd7fa; }
.tv-tick-filler { background: #f3e9cf; }
.tv-tick.is-past.tv-tick-noop, .tv-tick.is-past.tv-tick-orig { background: var(--noop); }
.tv-tick.is-past.tv-tick-edit { background: var(--accent); }
.tv-tick.is-past.tv-tick-filler { background: var(--filler); }

/* The range input sits on top of the ticks; only its thumb is visible. */
.tv-slider {
  position: absolute; inset: 0; width: 100%; margin: 0;
  -webkit-appearance: none; appearance: none; background: transparent; cursor: pointer;
}
.tv-slider::-webkit-slider-runnable-track { height: 38px; background: transparent; }
.tv-slider::-moz-range-track { height: 38px; background: transparent; }
.tv-slider::-webkit-slider-thumb {
  -webkit-appearance: none; width: 16px; height: 24px; margin-top: 7px;
  border-radius: 6px; background: #fff; border: 2px solid var(--ink);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}
.tv-slider::-moz-range-thumb { width: 12px; height: 20px; border-radius: 6px; background: #fff; border: 2px solid var(--ink); }

.tv-history { display: flex; flex-wrap: wrap; gap: 4px 18px; margin: 14px 2px 0; }
.tv-chip {
  font-family: var(--sans); font-size: 13px; cursor: pointer; text-align: left;
  border: none; background: none; padding: 2px 0; color: var(--faint); transition: color 0.12s;
}
.tv-chip b { font-family: var(--mono); font-weight: 600; margin-right: 5px; }
.tv-chip.is-done { color: var(--text); }
.tv-chip.is-current { color: var(--accent); font-weight: 600; box-shadow: inset 0 -2px 0 var(--accent); }
.tv-chip:hover { color: var(--accent); }

/* ---------------------------- Problem ---------------------------- */

.problem-line { margin: 0 0 4px; font-size: 18px; line-height: 1.55; color: var(--text); max-width: 820px; }

.drift-strip { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.drift-frame { margin: 0; position: relative; }
.drift-frame img { width: 100%; display: block; aspect-ratio: 1 / 1; object-fit: cover; border-radius: 8px; background: var(--frame-bg); }
.drift-frame figcaption {
  position: absolute; left: 6px; top: 6px; margin: 0;
  padding: 2px 7px; border-radius: 5px; background: rgba(15, 17, 21, 0.72); color: #fff;
  font-family: var(--mono); font-size: 11px; font-weight: 500;
}

/* ---------------------------- Results carousel ---------------------------- */

.carousel { outline: none; }
.carousel:focus-visible { box-shadow: 0 0 0 3px var(--accent-soft); border-radius: 10px; }
.carousel-track {
  display: flex; align-items: center;
  overflow-x: auto; overflow-y: hidden; scroll-snap-type: x mandatory; scroll-behavior: smooth;
  scrollbar-width: none; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain;
}
.carousel-track::-webkit-scrollbar { display: none; }
.carousel-slide { flex: 0 0 100%; min-width: 0; scroll-snap-align: start; }

.carousel-nav { display: flex; align-items: center; justify-content: center; gap: 18px; margin-top: 22px; }
.carousel-btn {
  width: 36px; height: 36px; padding: 0; border-radius: 50%; cursor: pointer;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  display: inline-flex; align-items: center; justify-content: center; transition: border-color 0.15s, color 0.15s;
}
.carousel-btn:hover { border-color: var(--accent); color: var(--accent); }
.carousel-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.carousel-dots { display: flex; gap: 8px; }
.carousel-dot {
  width: 8px; height: 8px; padding: 0; border: none; border-radius: 50%; cursor: pointer;
  background: #d3d8e0; transition: background 0.15s, width 0.15s;
}
.carousel-dot.is-active { background: var(--accent); width: 22px; border-radius: 4px; }

/* One slide: a paper-teaser grid. Labels and steps use display: contents on wide screens so
   their children flow into one grid, column by column (4 rows: instruction, base, ours, caption). */
.result { margin: 0; }
.result-grid {
  --gap: 8px; --label: 26px;
  display: grid; grid-template-columns: var(--label) repeat(var(--cols), minmax(0, 1fr));
  grid-template-rows: auto auto auto auto; grid-auto-flow: column;
  column-gap: var(--gap); row-gap: var(--gap);
}
.rg-labels, .rg-step { display: contents; }
.rg-mobile-head { display: none; }
.rg-img { width: 100%; aspect-ratio: 1 / 1; object-fit: cover; display: block; border-radius: 6px; background: var(--frame-bg); }

/* Instruction above the boundary between a column and the one before it. */
.rg-instr { position: relative; height: 56px; }
.rg-instr-inner {
  position: absolute; bottom: 0; height: 100%;
  left: calc(-50% - var(--gap) / 2); width: calc(100% + var(--gap));
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
}
.rg-instr-text {
  font-size: 13px; font-weight: 600; line-height: 1.25; text-align: center; color: var(--ink);
  padding: 0 4px; margin-bottom: 2px;
}
.rg-arc-wrap { position: relative; width: 100%; height: 16px; }
.rg-arc { position: absolute; inset: 0; width: 100%; height: 100%; display: block; overflow: visible; }
.rg-arc path { fill: none; stroke: var(--accent); stroke-width: 1.5; stroke-dasharray: 4 3; }
.rg-arrow {
  position: absolute; right: -4px; bottom: -5px;
  width: 0; height: 0; border-left: 4.5px solid transparent; border-right: 4.5px solid transparent;
  border-top: 7px solid var(--accent); transform: rotate(-28deg);
}

.rg-label { display: flex; align-items: center; justify-content: center; }
.rg-label span {
  writing-mode: vertical-rl; transform: rotate(180deg); white-space: nowrap;
  font-size: 12px; font-weight: 600; color: var(--muted);
}
.rg-label-ours span, .rg-mobile-head .rg-label-ours { color: var(--accent); }
.rg-cap { text-align: center; font-size: 12.5px; color: var(--muted); }

/* ---------------------------- Small screens ---------------------------- */

@media (max-width: 900px) {
  .grid-3, .stats { grid-template-columns: 1fr 1fr; }
  .grid-3 > :last-child, .stats > :last-child { grid-column: span 2; }
}

@media (max-width: 640px) {
  .masthead { padding-top: 48px; padding-bottom: 28px; }
  .title { font-size: 30px; }
  .authors { font-size: 15px; gap: 2px 14px; }
  .card { padding: 22px 18px; }
  .teaser-card { padding: 10px; }
  .card.mini { padding: 20px 18px; }
  .tldr-text { font-size: 19px; }
  .problem-line { font-size: 16px; }
  .card-head h2 { font-size: 22px; }
  .grid-3 { grid-template-columns: 1fr; }
  .grid-3 > :last-child { grid-column: auto; }
  .stats { gap: 12px; }
  .stat { padding: 16px; }
  .stat-v { font-size: 18px; }
  .tv-panels { gap: 6px; }
  .tv-label { font-size: 10px; left: 6px; top: 6px; padding: 2px 6px; }
  .tv-turn { min-width: auto; }
  .tv-instr { font-size: 14.5px; }
  .ac-card { padding: 22px 14px; }
  /* Lanes run top to bottom on phones: node, arrow with its instruction, node, ... */
  .ac-flow { display: flex; flex-direction: column; align-items: flex-start; }
  .ac-node { width: 38px; height: 38px; border-radius: 9px; font-size: 13px; }
  .ac-arrow { flex-direction: row-reverse; justify-content: flex-end; align-items: center; height: auto; padding: 4px 0; }
  .ac-arrow-text { font-size: 13.5px; text-align: left; margin: 0; }
  .ac-arrow.is-compound .ac-arrow-text { font-size: 14px; }
  .ac-arrow-line { width: 2px; height: 28px; margin: 0 14px 0 18px; }
  .ac-arrow-line::after {
    right: auto; left: -4px; top: auto; bottom: -2px;
    border-left: 5px solid transparent; border-right: 5px solid transparent; border-bottom: none;
    border-top: 7px solid #c3c9d3;
  }
  .ac-arrow.is-now .ac-arrow-line::after { border-left-color: transparent; border-top-color: var(--ink); }
  .ac-arrow.is-compound .ac-arrow-line::after { border-left-color: transparent; border-top-color: var(--accent); }
  .drift-strip { gap: 4px; }
  .drift-frame figcaption { font-size: 9px; left: 3px; top: 3px; padding: 1px 4px; }
  /* Results: one row per shown turn, the two methods side by side. */
  .result-grid { display: block; }
  .carousel-track { align-items: flex-start; }
  .rg-labels { display: none; }
  .rg-mobile-head {
    display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 4px;
    font-size: 12px; font-weight: 600; color: var(--muted);
  }
  .rg-step { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 14px; }
  .rg-cap { order: -1; grid-column: 1 / -1; text-align: left; font-size: 12px; }
  .rg-instr { grid-column: 1 / -1; height: auto; margin-top: -4px; }
  .rg-instr.is-empty { display: none; }
  .rg-instr-inner { position: static; width: auto; height: auto; display: block; }
  .rg-instr-text { display: block; text-align: left; font-size: 14px; padding: 0; margin: 0; }
  .rg-arc-wrap { display: none; }
  .carousel-nav { margin-top: 16px; }
}
.nowrap { white-space: nowrap; }
