/* PhasorPT project page: white / gray, colour only where it carries meaning.
   blue = ours and attention, amber = phasor operators (and sin), as in the figures. */
:root {
  --bg: #ffffff; --panel: #ffffff; --ink: #161b24; --muted: #5d6573; --faint: #9aa1ad; --rule: #e4e7eb;
  --soft: #f4f5f7; --soft2: #eceef1; --accent: #2f6fd0; --accent-ink: #1f4f9c; --amber: #c77a12;
  --display: "Newsreader", Georgia, serif; --body: "IBM Plex Sans", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --radius: 10px;
  color-scheme: light;
}
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16.5px/1.65 var(--body); -webkit-font-smoothing: antialiased; }
img, svg, canvas { max-width: 100%; display: block; }
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 3px; }
h1, h2, h3 { font-family: var(--display); font-weight: 600; line-height: 1.15; margin: 0; text-wrap: balance; }
h2 { font-size: clamp(1.6rem, 3vw, 2.05rem); letter-spacing: -.01em; }
h3 { font-size: 1.12rem; }
p { margin: 0; }
sup, sub { line-height: 0; }
.amb { color: var(--amber); font-weight: 500; }
.wrap { max-width: 1040px; margin: 0 auto; padding: 0 max(18px, env(safe-area-inset-left)); }
.narrow { max-width: 740px; }
.eyebrow { font: 500 .72rem/1 var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--faint); }

/* ---------- title ---------- */
.hero .wrap { padding-top: clamp(56px, 9vw, 104px); padding-bottom: clamp(36px, 5vw, 56px); text-align: center; }
.venue { font: 500 .72rem/1 var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--muted);
  border: 1px solid var(--rule); border-radius: 99px; padding: 6px 12px; display: inline-block; }
.hero h1 { margin-top: 20px; font-size: clamp(2.8rem, 8vw, 4.6rem); letter-spacing: -.02em; }
.hero .sub { margin: 8px auto 0; max-width: 32ch; font-family: var(--display); font-size: clamp(1.2rem, 2.5vw, 1.55rem); line-height: 1.3; color: var(--muted); font-weight: 500; }
.authors { margin-top: 22px; color: var(--ink); font-size: 1rem; }
.links { margin-top: 24px; display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 9px 17px; border-radius: 99px; font: 500 .92rem/1 var(--body);
  color: #fff; text-decoration: none; background: var(--ink); border: 1px solid var(--ink); transition: background .15s, transform .15s; }
.btn:hover { background: #2b3340; transform: translateY(-1px); }
.btn svg { width: 16px; height: 16px; }
.btn[aria-disabled="true"] { background: var(--soft2); border-color: var(--soft2); color: var(--faint); pointer-events: none; }
.links-note { margin-top: 10px; font-size: .8rem; color: var(--faint); }
.tldr { margin: 34px auto 0; max-width: 46ch; font-size: 1.12rem; line-height: 1.55; color: var(--ink); }
.tldr b { font-weight: 600; }

/* ---------- nav ---------- */
nav.toc { position: sticky; top: 0; z-index: 20; background: rgba(255, 255, 255, .9); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
nav.toc .wrap { display: flex; gap: 4px 22px; align-items: center; overflow-x: auto; scrollbar-width: none; height: 48px; }
nav.toc a { color: var(--muted); text-decoration: none; font-size: .86rem; white-space: nowrap; padding: 4px 0; border-bottom: 2px solid transparent; }
nav.toc a:hover, nav.toc a.on { color: var(--ink); border-bottom-color: var(--ink); }
nav.toc .brand { font: 600 1.02rem/1 var(--display); color: var(--ink); margin-right: auto; border: 0; }

/* ---------- sections ---------- */
section.block { padding: clamp(52px, 7vw, 84px) 0 0; scroll-margin-top: 40px; }
.head { display: flex; flex-direction: column; gap: 10px; margin-bottom: 22px; }
.head p { color: var(--muted); }
.abstract h2 { margin-bottom: 16px; }
.abstract p { font-size: 1.02rem; color: #2b313c; }
.abstract p + p { margin-top: .9em; }
.card { background: var(--panel); border: 1px solid var(--rule); border-radius: var(--radius); }
.two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 720px) { .two { grid-template-columns: minmax(0, 1fr); } }
.problem { padding: 20px 22px; display: flex; flex-direction: column; gap: 8px; text-decoration: none; color: inherit; transition: border-color .15s; }
.problem:hover { border-color: var(--faint); }
.problem .tag { font: 500 .72rem/1 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--faint); }
.problem .lost { font-size: 1.05rem; color: var(--ink); }
.problem .fix { color: var(--muted); }
.problem .fix b { color: var(--amber); font-weight: 600; }

/* ---------- figures ---------- */
.paperfig { padding: 18px 22px; }
.paperfig svg { width: 100%; height: auto; }
.paperfig svg text { font-family: var(--body) !important; }
#pooling .paperfig svg { max-width: 640px; margin: 0 auto; }
.paperfig.tall { padding: 14px; }
.side-by-side { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr); gap: 24px; align-items: center; }
@media (max-width: 760px) { .side-by-side { grid-template-columns: minmax(0, 1fr); } }
.side-text { display: flex; flex-direction: column; gap: 12px; color: var(--muted); }
.side-text p:first-child { color: var(--ink); }

/* ---------- demos ---------- */
.demo { margin-top: 16px; padding: 18px; display: flex; flex-direction: column; gap: 14px; background: var(--soft); border-color: var(--soft); }
.demo-title { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.cap { font-size: .8rem; color: var(--muted); line-height: 1.5; }
.controls { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; font-size: .85rem; color: var(--muted); }
.controls label { display: inline-flex; align-items: center; gap: 8px; }
input[type=range] { accent-color: var(--ink); width: 120px; }
.seg { display: inline-flex; background: var(--soft2); border-radius: 8px; padding: 3px; gap: 2px; }
.seg button { font: 500 .82rem/1 var(--body); color: var(--muted); background: transparent; border: 0; border-radius: 6px; padding: 7px 11px; cursor: pointer; white-space: nowrap; }
.seg button[aria-pressed="true"] { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .12); }
button.ghost { font: 500 .82rem/1 var(--body); color: var(--ink); background: #fff; border: 1px solid var(--rule); border-radius: 7px; padding: 7px 11px; cursor: pointer; }
button.ghost:hover { border-color: var(--faint); }
button:focus-visible, input:focus-visible, canvas:focus-visible, a:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.pool-grid { display: grid; grid-template-columns: minmax(0, 360px) minmax(0, 1fr); gap: 16px; align-items: stretch; }
@media (max-width: 720px) { .pool-grid { grid-template-columns: minmax(0, 1fr); } }
.pool-grid canvas, .attn-wrap canvas { width: 100%; touch-action: none; background: #fff; border-radius: 8px; }
.pool-side { display: flex; flex-direction: column; gap: 12px; }
.see { background: #fff; border-radius: 8px; padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; flex: 1; justify-content: center; }
.see h4 { margin: 0; font: 600 .86rem/1.2 var(--body); display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.status { font: 500 .74rem/1 var(--mono); color: var(--faint); padding: 4px 7px; border-radius: 5px; background: var(--soft); }
.status.changed { color: #fff; background: var(--amber); }
.status.same { color: var(--muted); background: var(--soft2); }
.attn-wrap { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 18px; align-items: start; }
@media (max-width: 760px) { .attn-wrap { grid-template-columns: minmax(0, 1fr); } }
.attn-side { display: flex; flex-direction: column; gap: 14px; }
.legend-inline { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: .8rem; color: var(--muted); }
.legend-inline i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; }
.legend-inline i.ring { background: transparent; border: 2px solid var(--accent); }
.callout { border-left: 3px solid var(--rule); padding: 2px 0 2px 14px; color: var(--muted); font-size: .92rem; }
.demo-tools { display: inline-flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; }
.callout.miss { border-left-color: var(--amber); }

/* ---------- results ---------- */
.table-card { padding: 14px 8px 12px; }
.table-card .note { padding: 0 12px; }
.res-grid { margin-top: 16px; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: stretch; }
@media (max-width: 840px) { .res-grid { grid-template-columns: minmax(0, 1fr); } }
.chart { padding: 18px 18px 14px; position: relative; display: flex; flex-direction: column; gap: 10px; }
.chart-sub { font-size: .86rem; color: var(--muted); }
.chart svg { width: 100%; height: auto; overflow: visible; }
.chart text { font-family: var(--body); fill: var(--muted); }
.tip { position: absolute; pointer-events: none; background: var(--ink); color: #fff; font-size: .78rem; padding: 6px 9px; border-radius: 6px;
  opacity: 0; transition: opacity .12s; white-space: nowrap; transform: translate(-50%, calc(-100% - 10px)); }
.tablewrap { overflow-x: auto; }
table.res { border-collapse: collapse; width: 100%; font-size: .9rem; font-variant-numeric: tabular-nums; }
table.res th, table.res td { padding: 7px 10px; text-align: center; white-space: nowrap; }
table.res th:first-child, table.res td:first-child { text-align: left; }
table.res thead th { font-weight: 500; color: var(--muted); font-size: .8rem; border-bottom: 1px solid var(--rule); }
table.res thead tr.grp th { border-bottom: 0; font-family: var(--mono); text-transform: uppercase; letter-spacing: .08em; font-size: .66rem; color: var(--faint); padding-bottom: 0; }
table.res tbody tr { border-bottom: 1px solid var(--soft); }
table.res tbody tr.sep { border-top: 1px solid var(--rule); }
table.res td.sub { padding-left: 26px; color: var(--muted); font-style: italic; }
table.res tr.ours { background: #f0f5fd; }
table.res tr.ours td:first-child { font-weight: 600; }
table.res .best { font-weight: 700; color: var(--ink); }
table.res .second { text-decoration: underline; text-underline-offset: 3px; }
table.res .na { color: var(--faint); }
.chk { color: var(--ink); }
.note { font-size: .8rem; color: var(--muted); margin-top: 8px; }
.bars { display: flex; flex-direction: column; gap: 9px; margin-top: 4px; }
.bar-row { display: grid; grid-template-columns: 330px minmax(0, 1fr) 76px; gap: 12px; align-items: center; font-size: .85rem; }
@media (max-width: 520px) { .bar-row { grid-template-columns: 1fr; gap: 4px; font-size: .8rem; } }
.bar-row .lab { line-height: 1.3; }
.bar-row .lab b { color: var(--ink); font-weight: 600; display: block; margin-bottom: 3px; }
.bar-row .track { position: relative; height: 20px; background: var(--soft); border-radius: 4px; overflow: hidden; }
.bar-row .fill { position: absolute; inset: 0 auto 0 0; background: #c9ced6; border-radius: 4px; transition: width .6s cubic-bezier(.2, .8, .2, 1); }
.bar-row.ours .fill { background: var(--accent); }
.bar-row .val { font-family: var(--mono); font-size: .84rem; font-variant-numeric: tabular-nums; display: grid; grid-template-columns: 34px 36px; gap: 6px; }
.bar-row .val span { text-align: right; }
.bar-row .val small { color: var(--muted); font-size: .74rem; }
.pills { display: grid; grid-template-columns: 112px 96px 92px; gap: 4px; }
.pill { white-space: nowrap; text-align: center; }
.pill { font: 500 .68rem/1 var(--mono); padding: 4px 6px; border-radius: 4px; background: var(--soft); color: var(--faint); }
.pill.on { background: #fbefdc; color: #8a5208; }

/* ---------- viewer ---------- */
.viewer { overflow: hidden; }
.vbar { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--rule); }
.vbar .spacer { flex: 1; }
.scenes { display: flex; gap: 6px; flex-wrap: wrap; padding: 10px 14px; border-bottom: 1px solid var(--rule); }
.scenes button { font: 500 .76rem/1 var(--mono); color: var(--muted); background: var(--soft); border: 1px solid transparent; border-radius: 6px; padding: 7px 10px; cursor: pointer; }
.scenes button[aria-pressed="true"] { color: var(--ink); border-color: var(--ink); background: #fff; }
.stage { position: relative; height: min(64vh, 600px); min-height: 360px; background: radial-gradient(ellipse at 50% 35%, #ffffff, #eef0f3 80%); touch-action: none; }
.stage canvas { width: 100%; height: 100%; }
.stage .split { position: absolute; top: 0; bottom: 0; width: 1.5px; background: var(--ink); opacity: .55; transform: translateX(-.75px); pointer-events: none; }
.stage .handle { position: absolute; top: 50%; width: 32px; height: 32px; margin: -16px 0 0 -16px; border-radius: 50%; background: #fff; color: var(--ink);
  border: 1px solid var(--rule); display: grid; place-items: center; cursor: ew-resize; box-shadow: 0 2px 8px rgba(0, 0, 0, .15); touch-action: none; }
.stage .handle svg { width: 16px; height: 16px; }
.stage .lbl { position: absolute; top: 12px; font: 500 .7rem/1 var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--ink);
  background: rgba(255, 255, 255, .85); border: 1px solid var(--rule); padding: 6px 9px; border-radius: 6px; pointer-events: none; }
.stage .lbl.l { left: 12px; } .stage .lbl.r { right: 12px; }
.stage .loading { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font: 500 .85rem/1 var(--mono); pointer-events: none; }
.stage .stat-chip, .stage .help-chip { position: absolute; bottom: 12px; font: 400 .72rem/1.4 var(--mono); color: var(--muted); background: rgba(255, 255, 255, .85); padding: 5px 8px; border-radius: 6px; pointer-events: none; }
.stage .stat-chip { left: 12px; } .stage .help-chip { right: 12px; }
@media (max-width: 640px) { .stage .help-chip { display: none; } }
.vlegend { display: flex; flex-wrap: wrap; gap: 6px 14px; padding: 12px 14px; font-size: .78rem; color: var(--muted); border-top: 1px solid var(--rule); }
.vlegend span { display: inline-flex; align-items: center; gap: 6px; }
.vlegend i { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }
select { font: 500 .82rem/1 var(--body); color: var(--ink); background: #fff; border: 1px solid var(--rule); border-radius: 7px; padding: 6px 8px; }

/* ---------- bibtex / footer ---------- */
.bib { position: relative; padding: 18px 20px; background: var(--soft); border-color: var(--soft); }
.bib pre { margin: 0; font: 400 .82rem/1.6 var(--mono); overflow-x: auto; color: var(--ink); }
.bib button { position: absolute; top: 12px; right: 12px; }
footer { margin-top: clamp(60px, 8vw, 100px); border-top: 1px solid var(--rule); padding: 26px 0 40px; color: var(--faint); font-size: .82rem; }
footer .wrap { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.reveal { opacity: 0; transform: translateY(10px); 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; } }

/* ---------- title background, abstract grid ---------- */
.hero { position: relative; overflow: hidden; }
#hero-bg { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; }
.hero .wrap { position: relative; z-index: 1; }
.abs-grid { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 36px; align-items: center; }
@media (max-width: 860px) { .abs-grid { grid-template-columns: minmax(0, 1fr); } }
.res-grid.single { grid-template-columns: minmax(0, 1fr); }

/* ---------- interactive phasor pooling figure ---------- */
.pw { background: #fff; border-color: var(--rule); }
.pw .hint { font-size: .85rem; color: var(--muted); }
.pw-actions { display: inline-flex; gap: 8px; }
.pw-scroll { overflow-x: auto; }
.pw-fig { position: relative; min-width: 820px; padding-bottom: 50px; }
.pw-fig canvas { width: 100%; touch-action: manipulation; }
.pw-eq { position: absolute; bottom: 6px; transform: translateX(-50%); text-align: center; font: 500 .95rem/1.35 var(--display); color: var(--ink); white-space: nowrap; }
.pw-eq.right { right: 0; transform: none; text-align: right; }
.pw-eq i { font-style: italic; }
.pw-eq .tl { position: relative; display: inline-block; }
.pw-eq .tl::before { content: "~"; position: absolute; left: 50%; top: -.62em; transform: translateX(-38%); font-style: normal; font-size: .9em; }
.pw-eq sub, .pw-eq sup { font-size: .7em; }
.frac { display: inline-flex; flex-direction: column; vertical-align: middle; text-align: center; font-size: .78em; line-height: 1.05; margin: 0 2px; }
.frac span:first-child { border-bottom: 1px solid currentColor; padding: 0 2px; }

/* ---------- title with the ScanNet chart ---------- */
.hero-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: 32px; align-items: center; text-align: left; }
.hero-grid .links { justify-content: flex-start; }
.hero-grid .sub { margin-left: 0; }
.hero-plot { margin: 0; position: relative; display: flex; flex-direction: column; gap: 6px; }
.hero-plot svg { width: 100%; height: auto; overflow: visible; }
.hero-plot text { font-family: var(--body); fill: var(--muted); }
.hero-plot .legend-inline { justify-content: center; font-size: .76rem; }
@media (max-width: 860px) {
  .hero-grid { grid-template-columns: minmax(0, 1fr); text-align: center; }
  .hero-grid .links { justify-content: center; }
  .hero-grid .sub { margin-left: auto; }
  .hero-plot { max-width: 520px; margin: 8px auto 0; }
}

/* ---------- live demo ---------- */
.demo-start { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; text-align: center; padding: 24px; }
.demo-start .demo-lead { font: 500 1.15rem/1.4 var(--display); color: var(--ink); }
.demo-start .cap { max-width: 44ch; }
.demo-start .btn { cursor: pointer; font-size: .95rem; }
.demo-start.err .demo-lead { color: var(--amber); }
.ghost-file { font: 500 .82rem/1 var(--body); color: var(--ink); background: #fff; border: 1px solid var(--rule); border-radius: 7px; padding: 7px 11px; cursor: pointer; }
.ghost-file:has(input:disabled) { opacity: .45; cursor: default; }
.seg button:disabled, button.ghost:disabled { opacity: .45; cursor: default; }
#demo-stage .stat-chip { max-width: calc(100% - 24px); white-space: normal; }
#demo-stage .help-chip { top: 12px; bottom: auto; }
.pw-eq.stack { display: grid; grid-template-columns: auto auto auto; column-gap: .3em; row-gap: .1em; align-items: baseline; }
.pw-eq.stack > span:nth-child(3n + 1) { text-align: right; }
.pw-eq.stack > span:nth-child(3n) { text-align: left; }

/* ---------- viewer hover readout ---------- */
.hover-tip { position: absolute; display: none; grid-template-columns: auto auto auto auto; align-items: center; column-gap: 6px; row-gap: 4px;
  pointer-events: none; z-index: 3; background: rgba(255, 255, 255, .95); border: 1px solid var(--rule); border-radius: 7px; padding: 6px 9px;
  font: 400 .78rem/1.2 var(--body); color: var(--ink); white-space: nowrap; box-shadow: 0 2px 8px rgba(0, 0, 0, .08); }
/* fixed columns: a row without the check mark (unlabeled ground truth) must not shift the next row */
.hover-tip i { grid-column: 2; width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex: none; }
.hover-tip b { grid-column: 3; font-weight: 600; }
.hover-tip small { grid-column: 1; color: var(--faint); font-size: .7rem; text-align: right; }
.hover-tip em { grid-column: 4; grid-row: 1 / span 2; font-style: normal; font-weight: 600; font-size: .95rem; margin-left: 4px; }
.hover-tip em.ok { color: var(--accent); } .hover-tip em.bad { color: #e0452e; }
.hover-dot { position: absolute; display: none; width: 12px; height: 12px; margin: -6px 0 0 -6px; border-radius: 50%;
  border: 2px solid var(--ink); box-shadow: 0 0 0 2px rgba(255, 255, 255, .9); pointer-events: none; z-index: 2; }
