/* ========== Reset & base ========== */
*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  --fg: #1a1a1a;
  --fg-muted: #555;
  --bg: #ffffff;
  --bg-alt: #f7f7f8;
  --border: #e5e5e7;
  --accent: #b11f3a;        /* paper red */
  --accent-soft: #fde4e9;
  --accent-blue: #2f5f8f;   /* paper blue */
  --max-width: 1100px;
  --narrow-width: 820px;
  --paper-title-width: min(900px, calc(100vw - 2.5rem));
  --radius: 8px;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
    'Helvetica Neue', Arial, sans-serif;
  font-size: 17px;
  line-height: 1.65;
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.15s ease;
}
a:hover {
  color: #8a1a2e;
  text-decoration: underline;
}

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

h1,
h2,
h3 {
  font-family: 'Noto Serif', Georgia, 'Times New Roman', serif;
  font-weight: 700;
  line-height: 1.25;
  color: var(--fg);
  margin: 0 0 0.5em;
}

h2 {
  font-size: 1.95rem;
  text-align: center;
  margin-bottom: 1.4em;
}

h3.subhead {
  font-size: 1.25rem;
  margin: 1.6em 0 0.6em;
  color: var(--fg);
}

p {
  margin: 0 0 1em;
}

code {
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  background: var(--bg-alt);
  padding: 0.1em 0.35em;
  border-radius: 4px;
  font-size: 0.92em;
}

em {
  color: var(--fg);
}

/* ========== Layout ========== */
.container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.25rem;
}
.container.narrow {
  max-width: var(--narrow-width);
}

.section {
  padding: 4rem 0;
  border-top: 1px solid var(--border);
}
.section.alt {
  background: var(--bg-alt);
}

/* ========== Hero (title + authors) ========== */
.hero {
  padding: 3rem 0;
  text-align: center;
  border-top: none;
}

.paper-title {
  font-size: 2.2rem;
  margin: 0 auto 1.1rem;
  max-width: 900px;
  letter-spacing: 0;
  line-height: 1.2;
}
.paper-title sub {
  font-size: 0.7em;
  vertical-align: -0.2em;
}
.paper-title sup {
  font-size: 0.7em;
  vertical-align: 0.5em;
}
.method-name {
  color: var(--accent);
}

/* KaTeX inline math should match surrounding text size and weight, and \text{}
   should inherit the page's font (Noto Serif / Inter) instead of KaTeX_Main.
   KaTeX's own CSS uses `font:` shorthand which forces font-weight to normal —
   we override so <h1>, <strong>, etc. carry through to LaST. */
.katex {
  font-size: 1em;
  font-weight: inherit;
}
.katex .text,
.katex .mord.text {
  font-family: inherit;
  font-weight: inherit;
}

.authors {
  margin: 0.5rem 0 0.75rem;
  font-size: 1.05rem;
}
.author {
  display: inline-block;
  margin: 0 0.5em;
}
.author a {
  color: var(--fg);
  border-bottom: 1px dashed transparent;
}
.author a:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
  text-decoration: none;
}

.affiliations,
.notes {
  color: var(--fg-muted);
  font-size: 0.95rem;
  margin-bottom: 0.4rem;
}
.affiliations span,
.notes span {
  display: inline-block;
  margin: 0 0.6em;
}
.notes {
  font-size: 0.85rem;
  margin-bottom: 1.6rem;
}

/* ========== Buttons ========== */
.action-buttons {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 0.5rem;
}

.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 1.1rem;
  background: var(--fg);
  color: #fff;
  border-radius: 999px;
  font-size: 0.95rem;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.05s ease;
}
.btn:hover {
  background: #000;
  color: #fff;
  text-decoration: none;
  transform: translateY(-1px);
}
.btn-disabled {
  cursor: not-allowed;
}
.btn-disabled:hover {
  transform: none;
}
.btn-disabled::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 0.6rem);
  transform: translateX(-50%) translateY(0.2rem);
  padding: 0.35rem 0.55rem;
  border-radius: 6px;
  background: #222;
  color: #fff;
  font-size: 0.75rem;
  line-height: 1;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
  z-index: 10;
}
.btn-disabled::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: calc(100% + 0.25rem);
  transform: translateX(-50%) translateY(0.2rem);
  border: 0.35rem solid transparent;
  border-top-color: #222;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
  z-index: 10;
}
.btn-disabled:hover::after,
.btn-disabled:hover::before {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.btn.small {
  padding: 0.4rem 0.85rem;
  font-size: 0.85rem;
}
.btn i {
  font-style: normal;
  font-size: 0.95em;
}

/* ========== Stat callouts ========== */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin: 0 auto 2.8rem;
  max-width: 1000px;
}
.stat {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.4rem 1rem;
  text-align: center;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}
.stat-num {
  font-family: 'Noto Serif', Georgia, serif;
  font-size: 2.6rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
}
.stat-unit {
  font-size: 0.55em;
  color: var(--fg-muted);
  font-weight: 500;
  margin-left: 0.1em;
}
.stat-label {
  margin-top: 0.5rem;
  font-size: 0.92rem;
  color: var(--fg-muted);
  line-height: 1.4;
}
.stat.stat-text {
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.stat.stat-text .stat-num {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
    'Helvetica Neue', Arial, sans-serif;
  font-size: 1.55rem;
  line-height: 1.12;
  letter-spacing: 0;
}
.stat.stat-text .stat-label {
  max-width: 14rem;
  margin-left: auto;
  margin-right: auto;
}
.stat-label strong {
  color: var(--fg-muted);
  font-weight: 700;
}

/* ========== Figures & captions ========== */
figure {
  margin: 1.5rem 0;
}
figure img,
figure video {
  width: 100%;
  border-radius: var(--radius);
  background: #fff;
}
.overview-figure {
  margin: 0 0 3rem;
}
.overview-figure figcaption {
  max-width: 920px;
}
.framework-figure {
  margin: 1.75rem auto 0;
}
.framework-figure img {
  border: 1px solid var(--border);
}
.figure-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.25rem;
  align-items: start;
  margin: 1.5rem 0;
}
.figure-grid figure {
  margin: 0;
}
.figure-grid figcaption {
  font-size: 0.86rem;
}
figcaption {
  margin-top: 0.6rem;
  font-size: 0.92rem;
  color: var(--fg-muted);
  text-align: center;
  line-height: 1.55;
  max-width: 850px;
  margin-left: auto;
  margin-right: auto;
}

.lead {
  text-align: center;
  color: var(--fg-muted);
  margin: 0 auto 1.6rem;
  max-width: 780px;
}

.caption-lead {
  text-align: center;
  color: var(--fg-muted);
  font-size: 0.95rem;
  margin: 0 auto 1rem;
}
.caption-note {
  text-align: center;
  color: var(--fg-muted);
  font-size: 0.85rem;
  margin: 0.6rem auto 0;
}
.ours {
  color: var(--accent);
  font-weight: 600;
}

/* ========== Tables ========== */
.table-wrap {
  overflow-x: auto;
  margin: 0.5rem auto 1rem;
  max-width: 1000px;
}
.table-wrap.wide {
  max-width: 100%;
}
.table-wrap.small {
  max-width: 800px;
}
.results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.93rem;
  background: #fff;
  border-radius: var(--radius);
  overflow: hidden;
}
.results-table thead th {
  background: #2a2a2a;
  color: #fff;
  font-weight: 600;
  padding: 0.75rem 0.9rem;
  text-align: center;
  font-size: 0.9rem;
}
.results-table thead th:first-child {
  text-align: left;
}
.results-table tbody td {
  padding: 0.55rem 0.9rem;
  border-bottom: 1px solid var(--border);
  text-align: center;
}
.results-table tbody td:first-child {
  text-align: left;
  font-weight: 500;
}
.results-table tbody tr:hover {
  background: var(--bg-alt);
}
.results-table tr.sep td {
  padding: 0;
  height: 4px;
  border-bottom: 2px solid #2a2a2a;
}
.results-table tr.ours-row {
  background: var(--accent-soft);
}
.results-table tr.ours-row td {
  font-weight: 600;
}
.results-table tr.ours-row:hover {
  background: var(--accent-soft);
}
.results-table tr.baseline-row {
  background: #e8f5e9;
}
.results-table tr.baseline-row:hover {
  background: #d8edda;
}
.results-table tr.baseline-row td {
  font-weight: 600;
}
.results-table tr.group-row td {
  background: #e5edf8;
  color: var(--fg);
  font-weight: 700;
  text-align: left;
  border-top: 2px solid #2a2a2a;
  border-bottom: 1px solid var(--border);
}
.context-table {
  min-width: 1180px;
  font-size: 0.78rem;
}
.context-table thead th {
  padding: 0.55rem 0.5rem;
  font-size: 0.78rem;
  vertical-align: middle;
}
.context-table tbody td {
  padding: 0.38rem 0.5rem;
  line-height: 1.25;
  white-space: nowrap;
}
.context-table tbody td:first-child {
  white-space: normal;
  min-width: 180px;
}
.generalization-table {
  min-width: 1500px;
  font-size: 0.76rem;
}
.generalization-table thead th {
  padding: 0.5rem 0.42rem;
  font-size: 0.76rem;
  vertical-align: middle;
}
.generalization-table tbody td {
  padding: 0.34rem 0.42rem;
  line-height: 1.22;
  white-space: nowrap;
}
.generalization-table tbody td:first-child {
  white-space: normal;
  min-width: 170px;
}
.pm {
  color: var(--fg-muted);
  font-size: 0.78em;
  margin-left: 0.08em;
}
.results-table tr.task-header td {
  background: #2a2a2a;
  color: #fff;
  text-align: left;
  font-size: 0.9rem;
  padding: 0.55rem 0.9rem;
}
.results-table tr.task-header:hover td {
  background: #2a2a2a;
}
.placeholder {
  color: #b8b8b8;
  font-style: italic;
  font-weight: 400;
}

/* ========== Highlight callout (used after learning curves) ========== */
.callout-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
  margin: 1.5rem auto 0;
  max-width: 900px;
}
.callout {
  background: #fff;
  border-left: 4px solid var(--accent);
  border-radius: 4px;
  padding: 1rem 1.2rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}
.callout .callout-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  color: var(--accent);
  font-size: 1.05rem;
  margin-bottom: 0.3rem;
  white-space: nowrap;
}
.callout .callout-title i {
  font-size: 1.1em;
}
.callout p {
  margin: 0;
  font-size: 0.95rem;
  color: var(--fg);
  line-height: 1.55;
}

/* ========== Formulas (KaTeX display math) ========== */
.formula {
  margin: 1.2rem 0;
  padding: 0.6rem 0;
  text-align: center;
  overflow-x: auto;
  overflow-y: hidden;
}
.formula .katex-display {
  margin: 0;
}
.formula .katex {
  font-size: 1.1em;
}

/* ========== BibTeX ========== */
pre {
  background: #0f1115;
  color: #e6edf3;
  padding: 1.1rem 1.25rem;
  border-radius: var(--radius);
  overflow-x: auto;
  font-size: 0.88rem;
  line-height: 1.55;
  margin: 0 0 0.75rem;
}
pre code {
  background: none;
  padding: 0;
  color: inherit;
}

/* ========== Footer ========== */
footer {
  padding: 2rem 0 3rem;
  border-top: 1px solid var(--border);
  font-size: 0.9rem;
  color: var(--fg-muted);
  text-align: center;
}

/* ========== Responsive ========== */
@media (max-width: 700px) {
  .paper-title {
    font-size: 1.6rem;
  }
  h2 {
    font-size: 1.4rem;
  }
  .section {
    padding: 3rem 0;
  }
  .hero {
    padding: 2.25rem 0 2rem;
  }
  body {
    font-size: 16px;
  }
  .stat-num {
    font-size: 2.1rem;
  }
  .results-table {
    font-size: 0.82rem;
  }
  .results-table thead th,
  .results-table tbody td {
    padding: 0.5rem 0.55rem;
  }
  .figure-grid {
    grid-template-columns: 1fr;
  }
}
