:root {
  --bg: #ffffff;
  --bg-soft: #f6f7fb;
  --bg-accent: #eef2ff;
  --ink: #1a1d29;
  --ink-soft: #4a4f63;
  --ink-mute: #6c7385;
  --line: #e4e6ee;
  --brand: #4338ca;
  --brand-dark: #312e81;
  --brand-soft: #eef0ff;
  --accent: #f97316;
  --good: #16a34a;
  --bad: #dc2626;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 24, 50, .06), 0 8px 24px rgba(20, 24, 50, .06);
  --maxw: 1080px;
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-serif: "Noto Serif", "Source Serif Pro", "Iowan Old Style", Georgia, serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img { max-width: 100%; display: block; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Top nav ---------- */
.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, .85);
  backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--line);
}
.nav-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.nav-brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.01em;
  font-size: 15px;
  text-decoration: none;
}
.nav-brand:hover { text-decoration: none; }
.nav-brand .nav-logo {
  width: 28px;
  height: 28px;
  object-fit: contain;
  border-radius: 6px;
}
.nav-brand .dot { color: var(--accent); }
.nav-links { display: flex; gap: 18px; }
.nav-links a {
  color: var(--ink-soft);
  font-size: 14px;
  text-decoration: none;
}
.nav-links a:hover { color: var(--brand); }

/* ---------- Hero ---------- */
.hero {
  padding: 56px 24px 32px;
  text-align: center;
  background:
    radial-gradient(1200px 400px at 50% -10%, rgba(67, 56, 202, .12), transparent 70%),
    linear-gradient(180deg, #fafbff 0%, #ffffff 100%);
  border-bottom: 1px solid var(--line);
}
.hero-inner { max-width: var(--maxw); margin: 0 auto; }

.hero-logo {
  width: 168px;
  height: 168px;
  object-fit: contain;
  margin: 0 auto 22px;
  filter: drop-shadow(0 6px 20px rgba(67, 56, 202, .18));
  transition: transform .4s cubic-bezier(.2, .8, .2, 1);
}
.hero-logo:hover { transform: translateY(-3px) scale(1.02); }

.venue {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand-dark);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  margin-bottom: 18px;
}

h1.title {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: clamp(28px, 4.4vw, 44px);
  line-height: 1.18;
  margin: 0 0 6px;
  letter-spacing: -0.01em;
  color: var(--ink);
}
h1.title .accent { color: var(--brand); }
.subtitle {
  font-family: var(--font-serif);
  font-size: clamp(18px, 2.4vw, 22px);
  font-weight: 500;
  color: var(--ink-soft);
  margin: 0 0 28px;
}

.authors {
  font-size: 16px;
  color: var(--ink);
  margin: 18px 0 6px;
  line-height: 1.9;
}
.authors .author { white-space: nowrap; margin: 0 6px; }
.authors sup { color: var(--brand); font-weight: 700; }
.affil {
  font-size: 14px;
  color: var(--ink-mute);
  margin-bottom: 24px;
}
.affil sup { color: var(--brand); font-weight: 700; margin-right: 2px; }
.corresp {
  font-size: 13px;
  color: var(--ink-mute);
  margin-bottom: 28px;
}

/* ---------- Link buttons ---------- */
.btn-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin: 8px 0 4px;
}
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  border: 1px solid var(--ink);
  text-decoration: none;
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}
.btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow);
  text-decoration: none;
  background: #000;
}
.btn.outline {
  background: #fff;
  color: var(--ink);
  border-color: var(--line);
}
.btn.outline:hover { background: var(--bg-soft); }
.btn .ic { width: 16px; height: 16px; }

/* ---------- Sections ---------- */
section {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 56px 24px;
  border-bottom: 1px solid var(--line);
}
section:last-of-type { border-bottom: none; }

h2.section-title {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 28px;
  letter-spacing: -0.01em;
  margin: 0 0 8px;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 12px;
}
h2.section-title::before {
  content: "";
  display: inline-block;
  width: 6px; height: 26px;
  border-radius: 3px;
  background: linear-gradient(180deg, var(--brand), var(--accent));
}
.section-lead {
  color: var(--ink-soft);
  margin: 0 0 28px;
  font-size: 15.5px;
  max-width: 760px;
}

/* Abstract */
.abstract {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px 32px;
  font-size: 16px;
  color: var(--ink-soft);
  line-height: 1.75;
}
.abstract p:first-child { margin-top: 0; }
.abstract p:last-child { margin-bottom: 0; }
.abstract strong { color: var(--ink); }

/* Figure wrapper — image + caption together in one bordered card */
.figure {
  margin: 28px 0 0;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.figure img {
  display: block;
  margin: 0 auto;
  width: 100%;
  height: auto;
  background: #fff;
  border: none;
  border-radius: 0;
  box-shadow: none;
  padding: 18px 18px 12px;
}
.figure figcaption {
  margin: 0;
  padding: 14px 22px 16px;
  border-top: 1px solid var(--line);
  background: var(--bg-soft);
  font-size: 14px;
  color: var(--ink-soft);
  line-height: 1.6;
  text-align: center;
}
.figure figcaption strong { color: var(--ink); }

/* Subplot grids inside a figure card (e.g. ablation Figures 4–7) */
.figure .subplots {
  display: grid;
  gap: 14px;
  padding: 18px 18px 12px;
  background: #fff;
}
.figure .subplots-2 { grid-template-columns: 1fr 1fr; }
.figure .subplots-4 { grid-template-columns: repeat(4, 1fr); }
.figure .subplots-fig7 {
  grid-template-columns: 3fr 1fr;  /* right column ≈ same width as one of the 4-col ablation plots */
  align-items: center;
}
.figure .subplots .sub {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.figure .subplots .sub img {
  padding: 0;
  max-width: 100%;
  height: auto;
}
.figure .subplots .sublabel {
  font-size: 12.5px;
  color: var(--ink-mute);
  font-style: italic;
  text-align: center;
}
@media (max-width: 900px) {
  .figure .subplots-4 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 540px) {
  .figure .subplots-2,
  .figure .subplots-4,
  .figure .subplots-fig7 { grid-template-columns: 1fr; }
}

/* Stats row */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin: 32px 0 8px;
}
.stat {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 18px;
  text-align: center;
}
.stat .num {
  font-family: var(--font-serif);
  font-size: 32px;
  font-weight: 700;
  color: var(--brand);
  line-height: 1.1;
}
.stat .num.bad  { color: var(--bad); }
.stat .num.good { color: var(--good); }
.stat .lbl {
  margin-top: 6px;
  font-size: 13px;
  color: var(--ink-mute);
  text-transform: uppercase;
  letter-spacing: .05em;
}

/* Corruption grid */
.corr-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-top: 24px;
}
.corr {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 18px 16px;
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.corr:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: #c7c9d6;
}
.corr .tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 10px;
}
.corr.t-visual .tag { background: #e0f2fe; color: #075985; }
.corr.t-op     .tag { background: #fef3c7; color: #92400e; }
.corr.t-env    .tag { background: #fee2e2; color: #991b1b; }
.corr h3 {
  margin: 0 0 6px;
  font-size: 17px;
  color: var(--ink);
  font-weight: 600;
}
.corr p {
  margin: 0;
  font-size: 14px;
  color: var(--ink-soft);
  line-height: 1.55;
}

/* Findings list */
.findings {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-top: 8px;
}
.finding {
  background: linear-gradient(180deg, #fff 0%, var(--bg-soft) 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
}
.finding .num {
  font-family: var(--font-serif);
  font-weight: 700;
  color: var(--brand);
  font-size: 14px;
  letter-spacing: .04em;
}
.finding h4 {
  margin: 6px 0 8px;
  font-size: 16px;
  color: var(--ink);
}
.finding p {
  margin: 0;
  font-size: 14px;
  color: var(--ink-soft);
  line-height: 1.6;
}

/* Method modules */
.modules {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-top: 24px;
}
.module {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  background: #fff;
}
.module .badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 6px;
  background: var(--brand-soft);
  color: var(--brand-dark);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  margin-bottom: 10px;
}
.module h4 {
  margin: 0 0 8px;
  font-size: 17px;
  color: var(--ink);
}
.module p {
  margin: 0;
  font-size: 14.5px;
  color: var(--ink-soft);
  line-height: 1.6;
}

/* Results highlight */
.headline {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin: 0 0 24px;
}
.headline .pill {
  background: linear-gradient(180deg, #fff 0%, var(--bg-accent) 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 18px;
  text-align: center;
}
.headline .pill .big {
  font-family: var(--font-serif);
  font-size: 30px;
  font-weight: 700;
  color: var(--brand);
}
.headline .pill .big .delta {
  display: inline-block;
  margin-left: 6px;
  color: var(--good);
  font-size: 18px;
  vertical-align: 4px;
}
.headline .pill .cap {
  font-size: 13px;
  color: var(--ink-mute);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: .05em;
}

/* Comparison table (transposed: properties as rows, benchmarks as columns) */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow);
  margin-top: 8px;
}
.compare-table {
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13.5px;
  width: max-content;
  min-width: 100%;
}
.compare-table th,
.compare-table td {
  padding: 10px 12px;
  text-align: center;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  color: var(--ink-soft);
  vertical-align: middle;
}
.compare-table thead th {
  background: var(--bg-soft);
  color: var(--ink);
  font-weight: 600;
  font-size: 12.5px;
  border-bottom: 1.5px solid #d3d6e0;
  padding: 12px 10px;
}
.compare-table tbody tr:last-child th,
.compare-table tbody tr:last-child td { border-bottom: none; }
.compare-table tbody th.attr-col {
  font-weight: 600;
  color: var(--ink);
  background: var(--bg-soft);
  text-align: left;
}
.compare-table .attr-col {
  position: sticky;
  left: 0;
  z-index: 2;
  text-align: left;
  min-width: 150px;
  border-right: 1.5px solid #d3d6e0;
  box-shadow: 4px 0 6px -4px rgba(20, 24, 50, .12);
}
.compare-table thead th.attr-col { z-index: 3; }
.compare-table .num  { font-variant-numeric: tabular-nums; }
.compare-table tbody tr:hover td:not(.ours-col),
.compare-table tbody tr:hover th { background: #fbfbff; }

/* Highlight the AgentHijack column — four-sided brand-color frame */
.compare-table .ours-col {
  background: var(--bg-accent);
  border-left: 2px solid var(--brand);
  border-right: 2px solid var(--brand);
  color: var(--ink);
  font-weight: 600;
}
.compare-table thead th.ours-col {
  background: linear-gradient(180deg, var(--brand-soft) 0%, var(--bg-accent) 100%);
  color: var(--brand-dark);
  position: relative;
  border-top: 2px solid var(--brand);
  border-bottom: 1.5px solid var(--brand);
  border-left: 2px solid var(--brand);
  border-right: 2px solid var(--brand);
}
/* If AgentHijack is the right-most column, match its top-right corner to the wrapper */
.compare-table thead th.ours-col:last-child {
  border-top-right-radius: calc(var(--radius) - 2px);
}
.compare-table tbody tr:last-child td.ours-col,
.compare-table tbody tr:last-child th.ours-col {
  border-bottom: 2px solid var(--brand);
}
.compare-table tbody tr:last-child td.ours-col:last-child,
.compare-table tbody tr:last-child th.ours-col:last-child {
  border-bottom-right-radius: calc(var(--radius) - 2px);
}

.compare-table .yes { color: var(--good); font-weight: 700; font-size: 16px; }
.compare-table .no  { color: var(--bad);  font-weight: 700; font-size: 16px; }
.compare-table .na  { color: var(--ink-mute); font-size: 11.5px; font-style: italic; }
.compare-table .ours-tag {
  display: block;
  margin: 4px auto 0;
  padding: 2px 8px;
  font-size: 10px;
  letter-spacing: .08em;
  text-transform: uppercase;
  background: var(--brand);
  color: #fff;
  border-radius: 999px;
  font-weight: 700;
  width: fit-content;
}

.table-note {
  margin: 16px 4px 0;
  font-size: 13px;
  color: var(--ink-mute);
  line-height: 1.7;
}
.table-note strong { color: var(--ink-soft); }

/* When a table is wrapped inside a .figure card, drop its own outer chrome */
.figure .table-wrap {
  border: none;
  border-radius: 0;
  box-shadow: none;
  margin: 0;
}

/* Results table (Table 2) — agents in rows, corruptions in columns */
.results-table .attr-col {
  min-width: 170px;
  background: #fff;
}
.results-table tbody th.attr-col {
  background: #fff;
}
.results-table tbody tr:hover th.attr-col,
.results-table tbody tr:hover td:not(.avg-col) {
  background: #fbfbff;
}

/* Group header rows (Open-source / Closed-source / SOTA / AgentHijack-Agent) */
.results-table tr.group td {
  background: var(--bg-soft);
  color: var(--ink-soft);
  font-size: 12.5px;
  letter-spacing: .04em;
  text-align: center;
  padding: 8px 12px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.results-table tr.group em { font-style: italic; }
.results-table tr.ours-group td {
  background: linear-gradient(90deg, var(--brand-soft) 0%, var(--bg-accent) 100%);
  color: var(--brand-dark);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: .05em;
  text-transform: uppercase;
}

/* Average column highlight */
.results-table .avg-col {
  background: #fafbff;
  border-left: 1px solid var(--line);
  font-weight: 600;
  color: var(--ink);
}
.results-table thead th.avg-col {
  background: linear-gradient(180deg, var(--bg-soft) 0%, #ecedf5 100%);
}

/* The baseline row gets a subtle marker */
.results-table tr.baseline th.attr-col small {
  color: var(--ink-mute);
  font-weight: 400;
  font-size: 11px;
  margin-left: 6px;
}

/* Ours row */
.results-table tr.ours-row th.attr-col,
.results-table tr.ours-row td {
  background: var(--bg-accent);
  color: var(--ink);
}
.results-table tr.ours-row td.avg-col {
  background: #e2e6ff;
}
.results-table tr.ours-row { border-top: 2px solid var(--brand); }

/* Delta row */
.results-table tr.delta-row th.attr-col,
.results-table tr.delta-row td {
  background: #f0fdf4;
  color: var(--good);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.results-table tr.delta-row td.avg-col {
  background: #dcfce7;
}
.results-table tr.delta-row th.attr-col {
  color: var(--good);
  font-size: 18px;
  text-align: center;
  padding-left: 18px;
}

/* Citation block */
.cite {
  background: #0b0e1a;
  color: #e6e7ee;
  border-radius: var(--radius);
  padding: 22px 24px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.7;
  overflow-x: auto;
  position: relative;
}
.cite pre {
  margin: 0;
  white-space: pre;
}
.cite .copy {
  position: absolute;
  top: 12px;
  right: 12px;
  background: rgba(255, 255, 255, .08);
  color: #cdd0db;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
  transition: background .15s ease;
}
.cite .copy:hover { background: rgba(255, 255, 255, .16); }

/* Footer */
footer {
  padding: 28px 24px 60px;
  text-align: center;
  color: var(--ink-mute);
  font-size: 13px;
}
footer a { color: var(--ink-mute); text-decoration: underline; text-underline-offset: 3px; }

/* ---------- Responsive ---------- */
@media (max-width: 880px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .corr-grid { grid-template-columns: 1fr 1fr; }
  .findings, .modules, .headline { grid-template-columns: 1fr; }
  .nav-links { display: none; }
}
@media (max-width: 540px) {
  .corr-grid { grid-template-columns: 1fr; }
  section { padding: 40px 18px; }
  .hero { padding: 40px 18px 24px; }
  .hero-logo { width: 128px; height: 128px; margin-bottom: 18px; }
}
