/* ---------- tokens ---------- */
:root {
  --bg: #f6f3ee;
  --bg-alt: #efeae2;
  --surface: #fffdf9;
  --ink: #1f1a22;
  --ink-2: #3d3640;
  --muted: #6e6672;
  --line: #e2dbd0;
  --accent: #7a2f57;
  --accent-soft: #f3e4ec;
  --green: #2c7a55;
  --shadow: 0 1px 2px rgba(31, 26, 34, .05), 0 8px 24px -12px rgba(31, 26, 34, .18);

  --serif: "Newsreader", "Songti SC", Georgia, serif;
  --sans: "Inter", -apple-system, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141216; --bg-alt: #1a171d; --surface: #1f1b23; --ink: #efe9e3; --ink-2: #d4ccd2;
    --muted: #a198a5; --line: #2f2a34; --accent: #e7a3c6; --accent-soft: #3a2331; --green: #74d3a3;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 10px 30px -14px rgba(0,0,0,.6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #141216; --bg-alt: #1a171d; --surface: #1f1b23; --ink: #efe9e3; --ink-2: #d4ccd2;
  --muted: #a198a5; --line: #2f2a34; --accent: #e7a3c6; --accent-soft: #3a2331; --green: #74d3a3;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 10px 30px -14px rgba(0,0,0,.6);
  color-scheme: dark;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 72px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 400 16px/1.65 var(--sans); -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
img { max-width: 100%; display: block; }
a { color: var(--accent); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; text-decoration-color: color-mix(in srgb, var(--accent) 35%, transparent); }
a:hover { text-decoration-color: var(--accent); }
h1, h2, h3, h4 { font-family: var(--serif); font-weight: 500; line-height: 1.2; margin: 0; letter-spacing: -.01em; }
p { margin: 0 0 1em; }
.mono { font-family: var(--mono); font-size: .8em; letter-spacing: 0; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.wrap { width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 24px; }
.wrap.narrow { max-width: 820px; }
.pixel img { image-rendering: auto; }
.eyebrow { font: 500 .75rem/1 var(--mono); text-transform: uppercase; letter-spacing: .12em; color: var(--accent); margin-bottom: 14px; }
.label { display: inline-block; text-transform: uppercase; letter-spacing: .1em; font-size: .68rem; color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 2px 6px; margin-right: 8px; vertical-align: 2px; }

/* ---------- top bar ---------- */
.topbar { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.topbar-inner { display: flex; align-items: center; gap: 24px; height: 58px; }
.brand { font: 500 1.15rem var(--serif); color: var(--ink); text-decoration: none; white-space: nowrap; }
.nav { display: flex; gap: 22px; margin-left: auto; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a { color: var(--muted); text-decoration: none; font-size: .9rem; white-space: nowrap; }
.nav a:hover, .nav a.active { color: var(--ink); }
.theme-toggle { flex: none; width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); cursor: pointer; display: grid; place-items: center; }
.theme-toggle:hover { color: var(--accent); }

/* ---------- hero ---------- */
.hero { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 56px; align-items: start; padding-top: 64px; padding-bottom: 64px; }
.hero-visuals { display: grid; gap: 24px; justify-items: center; padding-top: 12px; }
.hero h1 { font-size: clamp(2.6rem, 6vw, 4.2rem); margin-bottom: 22px; }
.thesis { margin: 26px 0 30px; padding: 14px 16px; border-left: 3px solid var(--accent); background: var(--surface); border-radius: 0 var(--radius) var(--radius) 0; font: 500 1.02rem/1.5 var(--serif); box-shadow: var(--shadow); }
.thesis .muted { font: 400 .9rem var(--sans); }
.links { display: flex; flex-wrap: wrap; gap: 10px; }
.btn { display: inline-flex; align-items: center; height: 38px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); text-decoration: none; font: 500 .9rem var(--sans); cursor: pointer; transition: border-color .15s, transform .15s; }
.btn:hover { border-color: var(--accent); transform: translateY(-1px); }
.btn.primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }

.name-animation { margin: 0; max-width: 320px; width: 100%; }
#nameCanvas, .name-animation img { width: 100%; height: auto; image-rendering: pixelated; display: block; }

/* ---------- sections ---------- */
.section { padding: 96px 0; }
.section.alt { background: var(--bg-alt); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.section h2 { font-size: clamp(1.8rem, 3.6vw, 2.5rem); margin-bottom: 18px; max-width: 22em; }
.section-lede { color: var(--ink-2); max-width: 44em; font-size: 1.05rem; margin-bottom: 44px; }

/* arc */
.arc { list-style: none; margin: 0; padding: 0; position: relative; }
.arc::before { content: ""; position: absolute; left: 56px; top: 8px; bottom: 8px; width: 1px; background: var(--line); }
.arc-item { display: grid; grid-template-columns: 56px 1fr; gap: 0 40px; padding: 34px 0; position: relative; }
.arc-item::before { content: ""; position: absolute; left: 51px; top: 42px; width: 11px; height: 11px; border-radius: 50%; background: var(--bg-alt); border: 2px solid var(--accent); }
.arc-item.featured::before { background: var(--accent); }
.arc-item.ongoing::before { border-style: dashed; }
.arc-meta { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding-top: 4px; padding-right: 20px; }
.arc-phase { color: var(--accent); text-transform: uppercase; letter-spacing: .08em; }
.arc-body { min-width: 0; }
.arc-body h3 { font-size: clamp(1.3rem, 2.4vw, 1.6rem); margin-bottom: 6px; }
.arc-body h3 a { color: var(--ink); text-decoration: none; }
.arc-body h3 a:hover { color: var(--accent); }
.authors { color: var(--muted); font-size: .9rem; margin-bottom: 12px; }
.authors b { color: var(--ink); font-weight: 600; }
.arc-body > p { max-width: 42em; color: var(--ink-2); }
.caption { font-size: .82rem; color: var(--muted); margin-top: 10px; }
.project-resources { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 10px; margin: 18px 0; max-width: 760px; }
.citation { min-width: 0; }
.citation[open] { width: 100%; }
.citation summary { list-style: none; }
.citation summary::-webkit-details-marker { display: none; }
.citation summary::after { content: '▾'; margin-left: 8px; }
.citation[open] summary::after { content: '▴'; }
.citation-content { margin-top: 12px; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.citation pre { margin: 12px 0 0; max-height: 320px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; font: .78rem/1.65 var(--mono); color: var(--ink-2); }
.citation code { font: inherit; }

.strip { display: grid; gap: 8px; margin-top: 18px; max-width: 760px; }
.strip-5 { grid-template-columns: repeat(5, 1fr); }
.strip-4 { grid-template-columns: repeat(4, 1fr); }
.strip img { border-radius: 6px; width: 100%; aspect-ratio: 1; object-fit: cover; border: 1px solid var(--line); }
.strip figure, .steps figure, .harness-grid figure, .smb figure { margin: 0; }
.strip figcaption, .steps figcaption { text-align: center; color: var(--muted); margin-top: 4px; }

.project-video { display: block; width: 100%; height: auto; max-width: 760px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }

.gallery { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; margin-top: 18px; max-width: 760px; }
.gallery button { padding: 0; border: 1px solid var(--line); background: var(--surface); border-radius: 6px; overflow: hidden; cursor: zoom-in; position: relative; }
.gallery img { width: 100%; aspect-ratio: 1; object-fit: cover; transition: transform .25s; }
.gallery button:hover img { transform: scale(1.04); }
.gallery span { position: absolute; left: 4px; bottom: 4px; background: rgba(20,12,18,.78); color: #fff; padding: 1px 5px; border-radius: 3px; font-size: .64rem; }
.gallery.project-gallery { grid-template-columns: minmax(0, 1fr); gap: 16px; }
.project-gallery button { width: fit-content; max-width: 100%; }
.project-gallery img { width: auto; height: auto; aspect-ratio: auto; object-fit: contain; }
.project-gallery .portrait-demo { max-width: min(100%, 520px); }
#localAgenticGallery { grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); align-items: start; }
.gallery.multiagent-gallery { grid-template-columns: repeat(2, minmax(0, 288px)); }
.multiagent-gallery img { image-rendering: pixelated; }

.pcgrl-media { display: grid; grid-template-columns: minmax(0, 280px) minmax(0, 1fr); gap: 20px; align-items: start; max-width: 760px; }
.pcgrl-media .project-video { max-width: 280px; }
.pcgrl-gallery { grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: center; margin-top: 0; }
.pcgrl-gallery button { justify-self: center; width: fit-content; max-width: 100%; padding: 6px; }
.pcgrl-gallery img { width: auto; height: auto; aspect-ratio: auto; object-fit: contain; image-rendering: pixelated; }

.steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 10px; max-width: 760px; }
.steps img { border-radius: 4px; width: 100%; border: 1px solid var(--line); }
.harness-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; max-width: 560px; }
.harness-grid img { border-radius: 6px; border: 1px solid var(--line); width: 100%; }
.harness-grid figcaption, .smb figcaption { font: italic .88rem/1.45 var(--serif); color: var(--ink-2); margin-top: 8px; }
.smb { margin-top: 18px; max-width: 760px; }
.smb img { width: 100%; border-radius: 6px; border: 1px solid var(--line); }
.ok { font-style: normal; color: var(--green); display: inline-block; margin-top: 4px; }

.next-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 16px; }
.next-grid article { background: var(--surface); border: 1px dashed color-mix(in srgb, var(--accent) 45%, var(--line)); border-radius: var(--radius); padding: 20px; }
.next-grid h4 { font-size: 1.15rem; margin-bottom: 8px; }
.next-grid p { font-size: .9rem; color: var(--ink-2); margin: 0; }

/* language switch */
.lang-switch { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 28px; }
.chip { border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); border-radius: 999px; padding: 6px 14px; font: 500 .85rem var(--sans); cursor: pointer; }
.chip:hover { border-color: var(--accent); }
.chip.active { background: var(--accent); border-color: var(--accent); color: var(--bg); }
/* news */
.news { list-style: none; padding: 0; margin: 0; }
.news li { display: grid; grid-template-columns: 84px 1fr; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.news time { color: var(--muted); padding-top: 3px; }

/* about */
.portrait { width: 100%; height: auto; border-radius: 14px; aspect-ratio: 4 / 5; object-fit: cover; box-shadow: var(--shadow); }
.bio p { color: var(--ink-2); max-width: 40em; }
.bio em { color: var(--accent); }
.pron { font-size: .9rem; color: var(--muted) !important; }
.edu { margin: 28px 0 0; border-top: 1px solid var(--line); }
.edu div { display: grid; grid-template-columns: 110px 1fr; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: .92rem; }
.edu dt { color: var(--muted); padding-top: 2px; }
.edu dd { margin: 0; }
.edu dd b { font-weight: 600; }
.sub { font-size: 1.2rem; margin: 32px 0 4px; }
#background h2 { font-size: 1.2rem; }
.service { margin: 10px 0 0; padding-left: 18px; color: var(--ink-2); font-size: .92rem; }
.service li { margin-bottom: 6px; }

/* footer */
.footer { border-top: 1px solid var(--line); padding: 40px 0 48px; }
.footer-inner { display: flex; justify-content: space-between; align-items: center; gap: 24px; flex-wrap: wrap; }
.footer-name { font: 500 1.2rem var(--serif); margin: 0 0 2px; }
.footer .small { margin: 0; }
.socials { list-style: none; display: flex; flex-wrap: wrap; gap: 18px; margin: 0; padding: 0; }
.text-button { border: 0; padding: 0; background: none; cursor: pointer; font: inherit; }
.socials a, .socials .text-button { color: var(--ink-2); text-decoration: none; font-size: .9rem; }
.socials a:hover, .socials .text-button:hover { color: var(--accent); }
.copy-status { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 30; width: max-content; max-width: calc(100% - 32px); padding: 10px 18px; margin: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--ink); box-shadow: var(--shadow); font-size: .9rem; }
.copy-status:empty { display: none; }

/* lightbox */
.lightbox { border: none; padding: 0; background: transparent; width: min(92vw, 720px); max-width: 92vw; }
.lightbox::backdrop { background: rgba(15, 8, 13, .82); }
.lightbox img { width: 100%; border-radius: 8px; }
.lightbox-close { position: absolute; top: 8px; right: 8px; width: 34px; height: 34px; border-radius: 50%; border: none; background: rgba(0,0,0,.6); color: #fff; font-size: 1.3rem; cursor: pointer; }

/* reveal */
.reveal { opacity: 0; transform: translateY(14px); transition: opacity .6s ease, transform .6s ease; }
.reveal.in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; transition: none; }
}

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; gap: 40px; padding-top: 48px; padding-bottom: 32px; }
  .hero-visuals { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: center; padding-top: 0; }
  .next-grid { grid-template-columns: 1fr; }
  .portrait { max-width: 260px; }
  .gallery { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 720px) {
  .wrap { padding: 0 16px; }
  .hero { padding-top: 40px; padding-bottom: 40px; }
  .section { padding: 64px 0; }
  .nav { display: none; }
  .brand { margin-right: auto; }
  .arc::before { left: 5px; }
  .arc-item { grid-template-columns: 1fr; padding: 28px 0 28px 28px; }
  .arc-item::before { left: 0; top: 34px; }
  .arc-meta { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 10px; padding-right: 0; }
  .strip-5 { grid-template-columns: repeat(3, 1fr); }
  .strip-5 img:nth-child(n+4) { display: none; }
  .pcgrl-media { grid-template-columns: 1fr; }
  .pcgrl-gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: 360px; }
  .strip-4, .steps { grid-template-columns: repeat(2, 1fr); }
  .harness-grid { grid-template-columns: 1fr; }
  .news li { grid-template-columns: 1fr; gap: 2px; }
  .edu div { grid-template-columns: 1fr; gap: 0; }
}
