@font-face {
  font-family: "Hanken Grotesk";
  font-style: normal;
  font-weight: 300 800;
  font-display: swap;
  src: url("../assets/fonts/hanken-grotesk-latin-var.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC,
    U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F,
    U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --bg: #f3f5fc;
  --card: #ffffff;
  --ink: #1a1b2a;
  --ink-soft: #4f5273;
  --ink-faint: #8a8da9;
  --line: #e3e7f3;
  --line-soft: #edf0f9;
  --accent: #6054e4;
  --accent-deep: #4a3ed1;
  --accent-soft: #eae8fd;
  --maxw-wide: 1120px;
  --measure: 720px;
  --display: "Hanken Grotesk", -apple-system, BlinkMacSystemFont, "Segoe UI",
    Roboto, "Helvetica Neue", Arial, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", sans-serif;
  --font: "Hanken Grotesk", -apple-system, BlinkMacSystemFont, "Segoe UI",
    Roboto, "Helvetica Neue", Arial, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --shadow-soft: 0 1px 2px rgba(24,24,52,.05), 0 12px 30px -22px rgba(40,40,96,.32);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 84px; }
body {
  margin: 0; font-family: var(--font); color: var(--ink-soft);
  background: var(--bg);
  background-image:
    radial-gradient(880px 520px at 84% -8%, rgba(96,84,228,.10), transparent 60%),
    radial-gradient(720px 480px at 2% 2%, rgba(58,196,214,.07), transparent 56%),
    radial-gradient(760px 560px at 50% 116%, rgba(150,118,232,.06), transparent 60%);
  line-height: 1.72; font-size: 17px; font-weight: 370;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  letter-spacing: .002em;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-deep); }
img { max-width: 100%; display: block; }
strong, b { font-weight: 600; color: var(--ink); }

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

/* ---------- Top bar ---------- */
.topbar { position: sticky; top: 0; z-index: 50;
  background: rgba(252,253,255,.82); backdrop-filter: saturate(150%) blur(14px);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 2px rgba(40,40,96,.04); }
.topbar-inner { display: flex; align-items: center; height: 64px; gap: 12px; }
.topbar .brand { font-family: var(--display); font-weight: 700; font-size: 19.5px;
  color: var(--ink); letter-spacing: -.02em; }
.topbar .brand:hover { color: var(--accent); }
.ver-select { position: relative; display: inline-flex; align-items: center; }
.ver-select::after { content: ""; position: absolute; right: 11px; top: 50%; width: 6px; height: 6px;
  border-right: 1.6px solid var(--ink-faint); border-bottom: 1.6px solid var(--ink-faint);
  transform: translateY(-65%) rotate(45deg); pointer-events: none; }
.ver-select select { appearance: none; -webkit-appearance: none; font-family: var(--font);
  font-size: 12.5px; font-weight: 600; color: var(--ink-soft); background: var(--accent-soft);
  border: 1px solid rgba(96,84,228,.18); border-radius: 999px; padding: 4px 26px 4px 12px;
  cursor: pointer; line-height: 1.4; }
.ver-select select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.lang-toggle { margin-left: auto; border: 1px solid var(--line); background: #fff; border-radius: 999px;
  padding: 5px 14px; font-size: 13px; font-weight: 600; cursor: pointer; color: var(--ink);
  font-family: var(--font); transition: border-color .15s, color .15s; }
.lang-toggle:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- Article header (full width) ---------- */
.art-head { padding: 52px 0 28px; }
.art-head .wrap-wide { max-width: var(--maxw-wide); }
.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase;
  color: var(--accent); margin-bottom: 16px; }
.art-head h1 { font-family: var(--display);
  font-size: clamp(30px, 4vw, 46px); line-height: 1.1; font-weight: 700;
  margin: 0 0 18px; letter-spacing: -.026em; color: var(--ink); max-width: 940px; }
.dek { font-size: 20px; line-height: 1.6; color: var(--ink-soft); margin: 0 0 26px;
  font-weight: 380; max-width: 860px; }
.art-actions { display: flex; gap: 11px; flex-wrap: wrap; }

.divider-wrap { }
hr.divider { border: none; border-top: 1px solid var(--line); margin: 0; }

/* ---------- Layout: TOC + article ---------- */
.layout { max-width: var(--maxw-wide); margin: 0 auto; padding: 0 24px;
  display: grid; grid-template-columns: 216px minmax(0, 1fr); gap: 56px; }

.toc-col { position: relative; }
.toc { position: sticky; top: 84px; padding-top: 34px; }
.toc-label { font-size: 11.5px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase;
  color: var(--ink-faint); margin-bottom: 14px; }
.toc a { display: block; color: var(--ink-soft); font-size: 14px; font-weight: 450;
  padding: 6px 0 6px 14px; border-left: 2px solid var(--line); line-height: 1.4;
  transition: color .15s, border-color .15s; }
.toc a:hover { color: var(--ink); }
.toc a.active { color: var(--accent); border-left-color: var(--accent); font-weight: 600; }

/* ---------- Article ---------- */
.article { width: 100%; max-width: var(--measure); min-width: 0; padding: 30px 0 24px; }

.btn { display: inline-flex; align-items: center; gap: 8px; font-weight: 560; font-size: 14.5px;
  padding: 10px 20px; border-radius: 999px; cursor: pointer; border: 1px solid transparent;
  background: var(--ink); color: #fff; transition: transform .15s, box-shadow .15s, opacity .15s;
  font-family: var(--font); }
.btn:hover { transform: translateY(-1px); box-shadow: 0 8px 20px -10px rgba(28,28,40,.5); color: #fff; }
.btn .ic { width: 15px; height: 15px; }

/* ---------- Sections (prose) ---------- */
.article section { padding: 26px 0; border-top: 1px solid var(--line-soft); margin-top: 20px; }
.article section:first-of-type { border-top: none; margin-top: 0; }
.article h2 { font-family: var(--display); font-size: 27px; font-weight: 700; color: var(--ink);
  margin: 0 0 10px; letter-spacing: -.02em; scroll-margin-top: 88px; }
.article h3 { font-family: var(--display); margin: 16px 0 2px; font-size: 20px; font-weight: 650; color: var(--ink); letter-spacing: -.015em; }
.article p { margin: 14px 0; }
.muted { color: var(--ink-soft); }

figure { margin: 28px 0 6px; text-align: center; }
figure img { margin: 0 auto; border-radius: 12px; }
figure img.fig-img { cursor: zoom-in; transition: transform .35s ease, box-shadow .35s ease; }
figure:hover img.fig-img { transform: scale(1.02); box-shadow: var(--shadow-soft); }
figure figcaption { font-size: 14px; color: var(--ink-faint); margin-top: 14px; text-align: left;
  line-height: 1.6; }
figure figcaption b { color: var(--ink-soft); font-weight: 600; }

/* ---------- Version comparison ---------- */
.version-table-wrap { margin-top: 22px; overflow-x: auto; border: 1px solid var(--line); border-radius: 8px;
  background: rgba(255,255,255,.74); box-shadow: var(--shadow-soft); }
.version-table { width: 100%; border-collapse: collapse; min-width: 620px; font-size: 13px; text-align: left; }
.version-table th, .version-table td { padding: 11px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.version-table th { color: var(--ink); font-size: 12px; font-weight: 700; background: #f8f9fe; }
.version-table td:first-child { color: var(--ink); font-weight: 620; width: 28%; }
.version-table .diff { color: var(--accent-deep); font-weight: 720; }
.version-table tr:last-child td { border-bottom: none; }

/* ---------- Demo gallery ---------- */
.latency-proof {
  margin: 14px 0 4px; color: var(--ink-soft); font-size: 15px; line-height: 1.65;
}
.latency-proof strong { color: inherit; font-weight: 760; }
.demo-carousel { margin-top: 24px; }
.demo-carousel-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.demo-count { color: var(--ink-faint); font-size: 13px; font-weight: 700; letter-spacing: .04em; }
.demo-actions { display: flex; gap: 8px; flex: 0 0 auto; }
.demo-viewport {
  overflow-x: auto; scroll-snap-type: x mandatory; scroll-padding: 0; overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch; scrollbar-width: thin; scrollbar-color: rgba(96,84,228,.42) transparent;
  padding-bottom: 16px;
}
.demo-viewport:focus-visible { outline: 2px solid var(--accent); outline-offset: 6px; border-radius: 12px; }
.demo-viewport::-webkit-scrollbar { height: 8px; }
.demo-viewport::-webkit-scrollbar-track { background: transparent; }
.demo-viewport::-webkit-scrollbar-thumb { background: rgba(96,84,228,.28); border-radius: 999px; }
.demo-track { display: flex; }
.demo-slide { flex: 0 0 100%; min-width: 0; scroll-snap-align: start; }
.agent-thumb {
  position: relative; display: block; width: 100%; padding: 0; border: none; border-radius: 8px; overflow: hidden;
  aspect-ratio: 1488 / 1552; background: #10121e; cursor: pointer; box-shadow: var(--shadow-soft); font: inherit;
}
.agent-thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform .5s ease; }
.demo-slide:hover .agent-thumb img { transform: scale(1.025); }
.agent-thumb .ring {
  position: absolute; inset: 0; border-radius: 8px;
  box-shadow: inset 0 0 0 0 var(--accent); transition: box-shadow .22s; pointer-events: none;
}
.demo-slide:hover .agent-thumb .ring { box-shadow: inset 0 0 0 3px rgba(91,83,232,.55); }
.agent-thumb .callcue {
  position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%);
  background: rgba(20,20,28,.74); color: #fff; backdrop-filter: blur(5px); border-radius: 999px;
  padding: 8px 16px; font-size: 13px; font-weight: 600; display: inline-flex; gap: 7px;
  align-items: center; white-space: nowrap; transition: background .2s; pointer-events: none;
}
.demo-slide:hover .callcue { background: var(--accent); }
.demo-slide .desc { color: var(--ink-soft); font-size: 14px; margin: 10px 6px 0; line-height: 1.6; text-align: center; }
.gallery-nav {
  width: 38px; height: 38px; border-radius: 50%;
  border: 1px solid rgba(227,231,243,.92); background: rgba(255,255,255,.92); color: var(--ink);
  box-shadow: 0 14px 28px -18px rgba(26,27,42,.55); cursor: pointer; display: grid; place-items: center;
  font-size: 18px; line-height: 1; transition: transform .15s, opacity .15s, border-color .15s, color .15s;
}
.gallery-nav:hover { transform: translateY(-1px); border-color: rgba(96,84,228,.42); color: var(--accent); }
.gallery-nav:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.gallery-nav:disabled { cursor: default; opacity: .34; pointer-events: none; transform: none; }
.agent-lang {
  position: absolute; left: 12px; top: 12px; z-index: 2;
  background: rgba(255,255,255,.88); color: var(--ink); border: 1px solid rgba(255,255,255,.72);
  border-radius: 999px; padding: 4px 10px; font-size: 11.5px; font-weight: 700; line-height: 1.2;
  box-shadow: 0 8px 18px -14px rgba(15,16,28,.65); backdrop-filter: blur(6px); pointer-events: none;
}

/* ---------- Lightbox ---------- */
.modal { position: fixed; inset: 0; z-index: 100; display: none; align-items: center; justify-content: center;
  background: rgba(15,15,22,.8); backdrop-filter: blur(9px); padding: 20px; }
.modal.open { display: flex; }
.call-close { position: absolute; top: 8px; right: 8px; z-index: 4; width: 26px; height: 26px;
  border-radius: 50%; border: none; cursor: pointer; background: rgba(255,255,255,.18); color: #fff;
  font-size: 15px; line-height: 1; display: grid; place-items: center; backdrop-filter: blur(4px);
  transition: background .15s; }
.call-close:hover { background: rgba(255,255,255,.34); }

/* ---------- Demo video modal ---------- */
.vmodal .vbox {
  position: relative; width: auto; max-width: 94vw; max-height: 88vh;
  border-radius: 16px; overflow: hidden; background: #000;
  box-shadow: 0 36px 90px rgba(0,0,0,.55);
}
.vmodal .vbox video {
  display: block; width: auto; height: auto; max-width: 94vw; max-height: 84vh;
  background: #000; object-fit: contain;
}

/* ---------- Image lightbox ---------- */
.imodal .ibox { position: relative; width: auto; max-width: 94vw; border-radius: 16px; overflow: hidden;
  background: #fff; box-shadow: 0 36px 90px rgba(0,0,0,.55); }
.imodal .ibox img { display: block; max-width: 94vw; max-height: 88vh; width: auto; height: auto; }
.imodal .call-close { background: rgba(15,16,26,.55); }

/* ---------- BibTeX ---------- */
.bib-wrap { position: relative; margin-top: 18px; }
pre.bib { background: #f5f6fd; border: 1px solid var(--line); color: #2a2a3a; border-radius: 12px;
  padding: 20px; overflow-x: auto; font-family: var(--mono); font-size: 13px; line-height: 1.7; margin: 0; }
.copy-btn { position: absolute; right: 12px; top: 12px; background: #fff; color: var(--ink-soft);
  border: 1px solid var(--line); border-radius: 8px; padding: 5px 12px; font-size: 12.5px; cursor: pointer;
  font-family: var(--font); font-weight: 500; transition: border-color .15s, color .15s; z-index: 2; }
.copy-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- Footer ---------- */
footer { padding: 48px 0 54px; color: var(--ink-faint); font-size: 13.5px; text-align: center;
  margin-top: 28px; border-top: 1px solid var(--line); }
footer a { color: var(--ink-soft); }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; gap: 0; }
  .toc-col { display: none; }
  .article { max-width: 720px; margin: 0 auto; padding-top: 30px; }
}

/* ---------- i18n ---------- */
.lang-zh [data-en], .lang-en [data-zh] { display: none !important; }
.lang-zh .art-head h1, .lang-zh .article h2, .lang-zh .article h3,
.lang-zh .cmp-title { letter-spacing: 0; }
.lang-zh .art-head h1 [data-zh] { white-space: nowrap; }
