/* ==========================================================================
   TANDEM project page
   ========================================================================== */
:root {
  --accent: #2c5d93;          /* teleop blue, from the paper figures */
  --accent-ink: #234c79;
  --accent-soft: #e2ebf5;
  --ink: #1c1d1a;
  --ink-2: #2d2e2a;
  --muted: #6b6c64;
  --line: #e3e2da;
  --bg: #fafaf6;
  --bg-alt: #f1f0e8;
  --card: #ffffff;
  --grid: #e8e7e0;
  --axis: #c3c2b7;

  /* phase executors, matching the task figure */
  --tamp: #2e7d4f;
  --tamp-soft: #e1efe6;
  --teleop: #2c5d93;
  --teleop-soft: #e2ebf5;

  /* chart series: fixed order, the color follows the entity */
  --s-pre: #4a3aa7;           /* π0.5-DROID (pretrained) */
  --s-hitl: #eb6834;          /* HITL-TAMP */
  --s-ours: #2a78d6;          /* TANDEM */
  --s-human: #1baf7a;         /* Human teleop */

  --max: 1080px;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(30,30,20,.05), 0 10px 30px rgba(30,30,20,.05);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-serif: 'Fraunces', Georgia, 'Times New Roman', serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 70px; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
img, video { max-width: 100%; display: block; }

.wrap { max-width: var(--max); margin: 0 auto; padding: 0 24px; }

/* ---------- sticky nav ---------- */
nav.top {
  position: sticky; top: 0; z-index: 50;
  background: rgba(250,250,246,.86);
  backdrop-filter: saturate(180%) blur(10px);
  -webkit-backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--line);
}
nav.top .wrap { display: flex; align-items: center; gap: 20px; height: 56px; }
nav.top .brand { font-family: var(--font-serif); font-weight: 600; font-size: 19px; letter-spacing: .3px; margin-right: auto; color: var(--ink); }
nav.top .brand span { color: var(--accent); }
nav.top .brand:hover { text-decoration: none; }
nav.top a.link { color: var(--muted); font-size: 14px; font-weight: 500; }
nav.top a.link:hover { color: var(--ink); text-decoration: none; }
@media (max-width: 820px) { nav.top a.link { display: none; } }

/* ---------- left table of contents (wide screens) ---------- */
.toc { display: none; }
@media (min-width: 1480px) {
  .toc { display: block; position: fixed; top: 120px; left: calc((100vw - 1080px) / 2 - 188px); width: 168px; z-index: 40; }
  nav.top a.link { display: none; }
}
.toc-hd { font-size: 11px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); margin: 0 0 12px 15px; }
.toc-list { list-style: none; margin: 0; padding: 0; border-left: 2px solid var(--line); }
.toc-list a {
  display: block; padding: 7px 0 7px 15px; margin-left: -2px;
  border-left: 2px solid transparent; color: var(--muted);
  font-size: 13px; font-weight: 500; line-height: 1.3;
  transition: color .15s ease, border-color .15s ease;
}
.toc-list a:hover { color: var(--ink); text-decoration: none; }
.toc-list a.active { color: var(--accent); border-left-color: var(--accent); font-weight: 700; }

/* ---------- hero ---------- */
header.hero { padding: 60px 0 30px; text-align: center; }
h1.title { font-family: var(--font-serif); font-size: clamp(27px, 3.9vw, 42px); line-height: 1.16; margin: 0 auto 22px; max-width: 960px; font-weight: 600; letter-spacing: -.01em; }
h1.title .name { color: var(--accent); }
.authors { font-size: 18px; margin: 0 auto 6px; color: var(--ink-2); font-weight: 600; }
.affil { color: var(--muted); font-size: 15px; margin: 0 auto; }

/* ---------- link buttons ---------- */
.buttons { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; margin: 28px 0 6px; }
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--ink); color: #fff; font-weight: 600; font-size: 15px;
  padding: 11px 20px; border-radius: 999px; transition: transform .12s ease, background .2s;
}
.btn:hover { text-decoration: none; transform: translateY(-2px); background: #000; }
.btn.ghost { background: var(--card); color: var(--ink); border: 1.5px solid var(--line); }
.btn.ghost:hover { border-color: var(--ink); }
.btn.soon { opacity: .5; cursor: default; }
.btn.soon:hover { transform: none; border-color: var(--line); }
.btn svg { width: 17px; height: 17px; }

/* ---------- headline stats ---------- */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; max-width: 900px; margin: 40px auto 0; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 16px 16px; text-align: center; }
.stat .num { font-family: var(--font-serif); font-size: 38px; font-weight: 600; line-height: 1.05; color: var(--ink); white-space: nowrap; }
.stat .num small { font-size: 20px; color: var(--muted); font-weight: 500; }
.stat .num .vs { font-family: var(--font); font-size: 15px; color: var(--muted); font-weight: 500; vertical-align: 6px; margin: 0 2px; }
.stat .lbl { font-size: 13.5px; color: var(--muted); margin-top: 6px; line-height: 1.4; }
.stat .lbl b { color: var(--ink-2); font-weight: 600; }
@media (max-width: 680px) { .stats { grid-template-columns: 1fr; } }

/* ---------- sections ---------- */
section { padding: 64px 0; }
section.alt { background: var(--bg-alt); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
h2.sec { font-family: var(--font-serif); font-size: 31px; font-weight: 600; text-align: center; margin: 0 0 10px; letter-spacing: -.005em; }
h3.sub { font-family: var(--font-serif); font-size: 22px; font-weight: 600; margin: 56px 0 8px; text-align: center; }
.sec-sub { text-align: center; color: var(--muted); max-width: 760px; margin: 0 auto 34px; }
.prose { max-width: 820px; margin: 0 auto; font-size: 17px; color: var(--ink-2); }
.prose p { margin: 0 0 18px; }
.prose p:last-child { margin-bottom: 0; }
.prose b { color: var(--ink); }
.prose.limits { font-size: 16px; text-align: center; color: var(--muted); max-width: 760px; }

/* ---------- figures ---------- */
figure { margin: 0; }
.fig {
  margin: 8px auto 0; background: #fff; border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px 24px 18px;
}
.fig img { width: 100%; height: auto; margin: 0 auto; }
.fig figcaption, .caption { color: var(--muted); font-size: 14px; line-height: 1.55; margin: 14px auto 0; max-width: 880px; text-align: left; }
.fig figcaption b, .caption b { color: var(--ink-2); }
.teaser { max-width: 1040px; margin-top: 40px; }
@media (max-width: 700px) { .fig { padding: 14px 12px 12px; } }

.pred { font-family: var(--font-mono); font-size: .9em; background: var(--bg-alt); padding: 0 5px; border-radius: 4px; color: var(--ink-2); white-space: nowrap; }

.js .reveal { opacity: 0; transform: translateY(16px); transition: opacity .6s ease, transform .6s ease; }
.reveal.in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { .reveal { opacity: 1; transform: none; transition: none; } html { scroll-behavior: auto; } }

/* ---------- method cards ---------- */
.pillars { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; margin: 36px 0 0; }
.pillars.four { grid-template-columns: repeat(4, 1fr); }
.pillar { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px 20px 18px; }
.pillar .step { font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--accent-ink); }
.pillar h4 { font-family: var(--font-serif); font-size: 19px; font-weight: 600; margin: 4px 0 6px; line-height: 1.25; }
.pillar .what { font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.pillar .what code { font-family: var(--font-mono); font-size: 12px; background: var(--bg-alt); padding: 1px 6px; border-radius: 5px; color: var(--ink-2); }
.pillar p { font-size: 14.5px; color: var(--ink-2); margin: 0; line-height: 1.6; }
@media (max-width: 1020px) { .pillars.four { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 860px) { .pillars { grid-template-columns: 1fr; } }
@media (max-width: 620px) { .pillars.four { grid-template-columns: 1fr; } }

/* ---------- executor chips ---------- */
.chip { display: inline-block; font-size: 10.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; padding: 1px 8px; border-radius: 999px; vertical-align: 1px; }
.chip.tamp { background: var(--tamp-soft); color: var(--tamp); }
.chip.teleop { background: var(--teleop-soft); color: var(--teleop); }

/* ---------- task cards ---------- */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; align-items: center; }
.two-col .fig { margin: 0; }
@media (max-width: 860px) { .two-col { grid-template-columns: 1fr; } }
.task-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; counter-reset: task; }
.task-list li { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; font-size: 14.5px; color: var(--ink-2); line-height: 1.5; counter-increment: task; }
.task-list li b { display: block; color: var(--ink); font-size: 15px; }
.task-list li b::before { content: counter(task) ". "; color: var(--muted); font-weight: 600; }
.task-list .phases { display: flex; gap: 4px; margin-top: 7px; }
.task-list .phases .chip { vertical-align: 0; }

/* ---------- charts ---------- */
.chart-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px 22px 18px; }
.chart-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.chart-title { font-size: 12px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.seg { display: inline-flex; background: var(--bg-alt); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.seg button { border: 0; background: transparent; color: var(--muted); font: 600 13px var(--font); padding: 5px 14px; border-radius: 999px; cursor: pointer; }
.seg button:hover { color: var(--ink); }
.seg button.active { background: var(--ink); color: #fff; }
.seg button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (max-width: 480px) { .seg button { padding: 5px 10px; font-size: 12px; } }
.legend { display: flex; flex-wrap: wrap; gap: 8px 18px; font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 10px; }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart text { font-family: var(--font); }
.chart .tick { font-size: 11px; fill: var(--muted); font-variant-numeric: tabular-nums; }
.chart .cat { font-size: 13px; fill: var(--ink-2); font-weight: 600; }
.chart .val { font-size: 11px; fill: var(--ink-2); font-weight: 700; font-variant-numeric: tabular-nums; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .baseline { stroke: var(--axis); stroke-width: 1; }
.chart .bar { transition: opacity .15s ease; }
.chart .hit { fill: transparent; cursor: default; }
.chart.dim .bar { opacity: .35; }
.chart.dim .bar.on { opacity: 1; }
.tip {
  position: absolute; pointer-events: none; z-index: 5; min-width: 150px;
  background: var(--ink); color: #fff; border-radius: 8px; padding: 8px 11px;
  font-size: 12.5px; line-height: 1.45; box-shadow: 0 6px 20px rgba(0,0,0,.18);
  opacity: 0; transform: translate(-50%, calc(-100% - 10px)); transition: opacity .12s ease; white-space: nowrap;
}
.tip.show { opacity: 1; }
.tip .t { font-weight: 700; margin-bottom: 2px; }
.tip .r { display: flex; justify-content: space-between; gap: 14px; }
.tip .r span:last-child { font-variant-numeric: tabular-nums; font-weight: 600; }
.tip i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 6px; vertical-align: 0; }
.chart-note { font-size: 13px; color: var(--muted); margin: 10px 0 0; }

/* ---------- failure attribution (stacked horizontal bars) ---------- */
.fail-chart { position: relative; display: grid; gap: 14px; margin-top: 6px; }
.frow { display: grid; grid-template-columns: 300px 1fr; gap: 16px; align-items: center; }
.flabel { font-size: 13.5px; font-weight: 600; color: var(--ink-2); line-height: 1.3; }
.flabel small { display: block; font-weight: 500; color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; margin-top: 2px; }
.ftrack { display: flex; height: 26px; gap: 2px; }
.fseg { height: 100%; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums; overflow: hidden; transition: opacity .15s ease; min-width: 2px; }
.fseg:first-child { border-radius: 4px 0 0 4px; }
.fseg:last-child { border-radius: 0 4px 4px 0; }
.fail-chart.dim .frow { opacity: .4; }
.fail-chart.dim .frow.on { opacity: 1; }
.faxis { display: grid; grid-template-columns: 300px 1fr; gap: 16px; }
.faxis .ticks { position: relative; height: 18px; border-top: 1px solid var(--axis); }
.faxis .ticks span { position: absolute; top: 3px; transform: translateX(-50%); font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.faxis .ticks span:first-child { transform: none; }
@media (max-width: 760px) {
  .frow { grid-template-columns: 1fr; gap: 5px; }
  .faxis { grid-template-columns: 1fr; gap: 0; }
  .faxis > div:first-child { display: none; }
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; margin-top: 22px; }
@media (max-width: 860px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; margin-top: 14px; }
details.table-toggle { margin-top: 14px; }
details.table-toggle summary { cursor: pointer; font-size: 13.5px; font-weight: 600; color: var(--accent-ink); list-style: none; display: inline-flex; align-items: center; gap: 6px; }
details.table-toggle summary::-webkit-details-marker { display: none; }
details.table-toggle summary::before { content: "▸"; transition: transform .15s ease; display: inline-block; }
details.table-toggle[open] summary::before { transform: rotate(90deg); }
table.res { border-collapse: collapse; width: 100%; min-width: 640px; font-size: 13.5px; font-variant-numeric: tabular-nums; }
table.res th, table.res td { padding: 7px 10px; text-align: center; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.res th { font-size: 12px; font-weight: 700; color: var(--muted); }
table.res thead tr:first-child th { color: var(--ink-2); font-size: 12.5px; }
table.res td:first-child, table.res th:first-child { text-align: left; }
table.res td.ours { background: var(--accent-soft); color: var(--ink); }
table.res tr.total td { border-top: 1.5px solid var(--axis); font-weight: 600; }
table.res .grp { border-left: 1px solid var(--line); }

/* ---------- key findings ---------- */
.findings { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; margin-top: 30px; }
.finding { background: var(--card); border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: 10px; padding: 14px 18px; font-size: 15px; color: var(--ink-2); line-height: 1.55; }
.finding b { color: var(--ink); }
@media (max-width: 760px) { .findings { grid-template-columns: 1fr; } }

/* ---------- bibtex ---------- */
.bib { position: relative; max-width: 820px; margin: 0 auto; }
.bib pre { background: #1f201c; color: #e9e8e0; border-radius: var(--radius); padding: 20px 22px; font-family: var(--font-mono); font-size: 13.5px; line-height: 1.6; overflow-x: auto; margin: 0; }
.copy { position: absolute; top: 10px; right: 10px; background: rgba(255,255,255,.1); color: #e9e8e0; border: 1px solid rgba(255,255,255,.18); border-radius: 8px; font: 600 12px var(--font); padding: 5px 10px; cursor: pointer; }
.copy:hover { background: rgba(255,255,255,.18); }

footer { text-align: center; color: var(--muted); font-size: 14px; padding: 40px 0; border-top: 1px solid var(--line); }
footer a { color: var(--muted); }

@media (max-width: 640px) { h1.title br { display: none; } }
@media (max-width: 480px) {
  .wrap { padding: 0 16px; }
  h2.sec { font-size: 25px; }
  .stat .num { font-size: 32px; }
}

/* ---------- videos ---------- */
.vgrid { display: flex; flex-wrap: wrap; justify-content: center; gap: 18px; }
.vcard { flex: 0 1 calc((100% - 36px) / 3); background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); overflow: hidden; }
.vcard video, .vfig video { width: 100%; height: auto; aspect-ratio: 16 / 9; object-fit: cover; background: var(--bg-alt); }
.vcard figcaption { padding: 9px 12px 10px; font-size: 13.5px; font-weight: 600; color: var(--ink-2); line-height: 1.35; }
.vcard figcaption .n { color: var(--muted); }
.vfig video { aspect-ratio: 962 / 270; border-radius: 8px; }
@media (max-width: 860px) { .vcard { flex-basis: calc((100% - 18px) / 2); } }
@media (max-width: 560px) { .vcard { flex-basis: 100%; } }
