:root {
  --bg: #fbfaf7;
  --surface: #ffffff;
  --ink: #1b1c20;
  --ink-2: #474a52;
  --ink-3: #7b7e86;
  --line: #e6e3dc;
  --line-2: #d6d2c8;
  --accent: #0f6b62;
  --accent-soft: #e7f1ee;
  --accent-ink: #0b544d;
  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  --maxw: 1060px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 60px; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--sans); font-size: 16.5px; line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
img { display: block; max-width: 100%; }
/* KaTeX's hidden MathML is absolutely positioned; keep it inside its scroll box */
.katex { position: relative; }
code { font-family: var(--mono); font-size: .9em; background: #f1efe9; padding: 1px 5px; border-radius: 4px; }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 28px; }
@media (max-width: 640px) { .wrap { padding: 0 16px; } }

/* ---------- nav ---------- */
.nav { position: sticky; top: 0; z-index: 20; background: rgba(251,250,247,.94); border-bottom: 1px solid var(--line); }
.nav .wrap { display: flex; align-items: center; gap: 22px; height: 48px; overflow-x: auto; scrollbar-width: none; }
.nav .wrap::-webkit-scrollbar { display: none; }
.nav .brand { font-family: var(--serif); font-weight: 700; font-size: 18px; color: var(--ink); text-decoration: none; margin-right: 6px; }
.nav a.nl { color: var(--ink-2); font-size: 13.5px; text-decoration: none; white-space: nowrap; }

/* ---------- hero ---------- */
.hero { padding: 64px 0 56px; }
.kicker { font-family: var(--mono); font-size: 12.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.hero h1 {
  font-family: var(--serif); font-weight: 700; font-size: clamp(36px, 5.6vw, 60px); line-height: 1.04;
  letter-spacing: -.015em; margin: 14px 0 12px; max-width: 900px;
}
.hero .subtitle { font-family: var(--serif); font-size: clamp(19px, 2.3vw, 25px); color: var(--ink-2); margin: 0 0 30px; max-width: 820px; line-height: 1.35; }
.authors { font-size: 17px; font-weight: 500; }
.authors span { display: inline-block; margin-right: 16px; white-space: nowrap; }
.authors sup, .affils sup { color: var(--accent); font-weight: 600; margin-left: 1px; }
.authors a { color: var(--ink); text-decoration: underline; text-decoration-color: var(--line-2); text-underline-offset: 4px; text-decoration-thickness: 1px; }
.affils { margin-top: 8px; font-size: 14px; color: var(--ink-3); line-height: 1.7; }
.affils span { display: inline-block; margin-right: 16px; }
.links { margin-top: 26px; display: flex; flex-wrap: wrap; gap: 10px; }
.btn {
  display: inline-flex; align-items: center; gap: 9px; padding: 9px 18px; border-radius: 8px;
  background: var(--ink); color: #fff; font-weight: 500; font-size: 15px; text-decoration: none;
}
.btn.ghost { background: var(--surface); color: var(--ink); border: 1px solid var(--line-2); }
.btn svg { width: 17px; height: 17px; }

.tldr {
  margin-top: 40px; background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--accent);
  border-radius: 4px 10px 10px 4px; padding: 18px 24px; font-size: 17px; max-width: 920px;
}
.tldr .k { font-family: var(--mono); font-size: 12.5px; letter-spacing: .08em; color: var(--accent); margin-right: 8px; font-weight: 500; }

.figures-row { display: grid; grid-template-columns: repeat(4, 1fr); margin-top: 36px; border-top: 1px solid var(--line-2); border-bottom: 1px solid var(--line-2); }
.figures-row > div { padding: 18px 20px 18px 0; }
.figures-row > div + div { padding-left: 20px; border-left: 1px solid var(--line); }
.figures-row .n { font-family: var(--serif); font-weight: 700; font-size: 32px; line-height: 1.1; color: var(--accent); }
.figures-row .l { font-size: 13.5px; color: var(--ink-2); margin-top: 6px; line-height: 1.45; }
@media (max-width: 760px) {
  .figures-row { grid-template-columns: 1fr 1fr; }
  .figures-row > div { padding: 14px 12px 14px 0; }
  .figures-row > div + div { padding-left: 0; border-left: 0; }
  .figures-row > div:nth-child(even) { padding-left: 14px; border-left: 1px solid var(--line); }
  .figures-row > div:nth-child(n+3) { border-top: 1px solid var(--line); }
}

/* ---------- sections ---------- */
section { padding: 72px 0 20px; border-top: 1px solid var(--line); }
.label { font-family: var(--mono); font-size: 12.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
h2 { font-family: var(--serif); font-weight: 700; font-size: clamp(27px, 3.4vw, 36px); line-height: 1.15; letter-spacing: -.01em; margin: 8px 0 18px; }
h3 { font-family: var(--serif); font-weight: 600; font-size: 22px; margin: 44px 0 12px; }
h4 { font-size: 16px; font-weight: 600; margin: 0 0 6px; }
p { margin: 10px 0; }
.lead { font-size: 18px; color: var(--ink-2); max-width: 820px; }
.note { font-size: 13.5px; color: var(--ink-3); margin-top: 8px; }
b, strong { font-weight: 600; }

/* ---------- figures ---------- */
figure { margin: 26px 0 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 22px; }
figure img { width: 100%; height: auto; }
figure.narrow { max-width: 760px; margin-left: auto; margin-right: auto; }
figcaption { font-size: 14px; color: var(--ink-3); margin-top: 14px; line-height: 1.55; max-width: 860px; }
@media (max-width: 640px) { figure { padding: 12px; } }

/* ---------- method ---------- */
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin: 26px 0 0; padding: 0; list-style: none; counter-reset: s; }
.steps li { counter-increment: s; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 20px 20px 18px; }
.steps li::before { content: "0" counter(s); display: block; font-family: var(--serif); font-weight: 700; font-size: 26px; color: var(--accent); line-height: 1; margin-bottom: 12px; }
.steps p { font-size: 15px; color: var(--ink-2); margin: 6px 0 0; }
@media (max-width: 860px) { .steps { grid-template-columns: 1fr; } }

.eq { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px 22px; margin: 18px 0; overflow-x: auto; }
.eq .note { margin-top: 2px; }

.algo { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 18px; }
@media (max-width: 860px) { .algo { grid-template-columns: 1fr; } }
.algo .col { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px; }
.algo .col.ours { border-color: var(--accent); }
.algo .ttl { font-family: var(--mono); font-size: 12.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 10px; }
.algo .col.ours .ttl { color: var(--accent); }
.algo ol { margin: 0; padding-left: 22px; font-size: 15px; color: var(--ink-2); }
.algo li { margin: 7px 0; padding: 3px 8px; border-radius: 6px; }
.algo li.add { background: var(--accent-soft); color: var(--ink); }

.inline-note { display: flex; gap: 12px; align-items: baseline; margin: 22px 0 0; padding: 14px 18px; border: 1px dashed var(--line-2); border-radius: 10px; font-size: 15.5px; color: var(--ink-2); }
.inline-note .ic { font-family: var(--mono); font-size: 12px; color: var(--accent); letter-spacing: .08em; text-transform: uppercase; white-space: nowrap; }

/* ---------- tables ---------- */
.tbl { position: relative; overflow-x: auto; margin: 14px 0 4px; }
table { border-collapse: collapse; width: 100%; font-size: 14.5px; font-variant-numeric: tabular-nums; background: transparent; }
table thead tr:first-child th { border-top: 1.5px solid var(--ink); }
table tbody tr:last-child td { border-bottom: 1.5px solid var(--ink); }
th, td { padding: 7px 10px; text-align: center; white-space: nowrap; }
th { font-weight: 600; color: var(--ink-2); font-size: 13.5px; }
thead tr:last-child th { border-bottom: 1px solid var(--line-2); }
th.span { border-bottom: 1px solid var(--line); }
td:first-child, th:first-child { text-align: left; }
tr.blk td { font-family: var(--serif); font-style: italic; color: var(--ink-3); font-size: 14.5px; padding-top: 12px; }
tr.blk + tr td { border-top: 0; }
tr.rule td { border-top: 1px solid var(--line); }
tr.ours td { background: var(--accent-soft); }
tr.ours td:first-child { font-weight: 600; color: var(--accent-ink); }
td b { font-weight: 700; color: var(--ink); }
.sd { font-size: 10.5px; color: var(--ink-3); margin-left: 1px; vertical-align: -2px; }
table.methods td { white-space: normal; text-align: left; vertical-align: top; }
table.methods td:first-child { white-space: nowrap; font-weight: 600; }
table.methods td:nth-child(3) { white-space: nowrap; }
table.methods .all { font-size: 12.5px; color: var(--ink-3); margin-left: 4px; }
table.methods th { text-align: left; }

/* ---------- stat strip (faster learning) ---------- */
.strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin: 24px 0 8px; }
.strip > div { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; }
.strip .n { font-family: var(--serif); font-weight: 700; font-size: 28px; color: var(--accent); line-height: 1.1; }
.strip .l { font-size: 13.5px; color: var(--ink-2); margin-top: 6px; line-height: 1.45; }
@media (max-width: 860px) { .strip { grid-template-columns: 1fr 1fr; } }
@media (max-width: 440px) { .strip { grid-template-columns: 1fr; } }

/* ---------- own task ---------- */
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 16px; }
@media (max-width: 760px) { .two { grid-template-columns: 1fr; } }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px; }
.card p { font-size: 15px; color: var(--ink-2); margin: 6px 0 0; }
.card .tag { font-family: var(--mono); font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--accent); }
ul.rules { margin: 14px 0 0; padding: 0; list-style: none; display: grid; grid-template-columns: 1fr 1fr; gap: 10px 28px; }
ul.rules li { font-size: 15px; color: var(--ink-2); padding-left: 16px; position: relative; }
ul.rules li::before { content: ""; position: absolute; left: 0; top: .62em; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
ul.rules b { color: var(--ink); }
@media (max-width: 760px) { ul.rules { grid-template-columns: 1fr; } }

/* ---------- bibtex ---------- */
.bib { position: relative; }
.bib pre {
  margin: 14px 0 0; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px;
  font-family: var(--mono); font-size: 13px; line-height: 1.6; overflow-x: auto; color: var(--ink);
}
.copy { position: absolute; top: 10px; right: 10px; font: inherit; font-size: 13px; padding: 4px 12px; border-radius: 6px; border: 1px solid var(--line-2); background: var(--bg); cursor: pointer; }

footer { margin-top: 72px; padding: 28px 0 48px; border-top: 1px solid var(--line); font-size: 13.5px; color: var(--ink-3); }
