/* =========================================================
   Qihao Zhu — personal academic page
   Layout idea: the page is typeset like a paper.
   Numbered sections, a left gutter for headings, figures with captions.
   ========================================================= */

:root {
  --paper: #f7f5ef;
  --paper-2: #efebe1;
  --card: #fbfaf6;
  --ink: #1b1b1f;
  --ink-2: #44444c;
  --muted: #7b786f;
  --rule: #dcd7ca;
  --red: #9b1b1e;      /* PKU red */
  --blue: #3f5ef5;     /* DeepSeek blue */
  --green: #2c7a4b;
  --amber: #b26d12;
  --shadow: 0 1px 0 rgba(0,0,0,.03), 0 12px 32px -18px rgba(40,30,10,.25);

  --serif: "Newsreader", "Source Serif 4", "Noto Serif SC", "Songti SC", Georgia, "Times New Roman", serif;
  --mono: "JetBrains Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;

  --gutter: 210px;
}

html[data-theme="dark"] {
  --paper: #0f1115;
  --paper-2: #161a21;
  --card: #141820;
  --ink: #e9e7e0;
  --ink-2: #bdbab1;
  --muted: #8a8880;
  --rule: #2a3039;
  --red: #e2655e;
  --blue: #8196ff;
  --green: #5fc489;
  --amber: #e3b25e;
  --shadow: 0 1px 0 rgba(255,255,255,.02), 0 16px 40px -20px rgba(0,0,0,.8);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 72px; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 18.5px;
  line-height: 1.6;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color .35s ease, color .35s ease;
  overflow-x: hidden;
}
/* faint dot-grid "graph paper" */
body::before {
  content: "";
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: -1;
  background-image: radial-gradient(var(--rule) .6px, transparent .6px);
  background-size: 22px 22px;
  opacity: .45;
}

a { color: inherit; text-decoration-color: color-mix(in srgb, currentColor 35%, transparent); text-underline-offset: 3px; }
a:hover { color: var(--blue); text-decoration-color: currentColor; }
::selection { background: color-mix(in srgb, var(--blue) 25%, transparent); }

.mono { font-family: var(--mono); font-size: .82em; letter-spacing: -.01em; }
.muted { color: var(--muted); }

.wrap { max-width: 1240px; margin: 0 auto; padding: 0 32px; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: saturate(1.2) blur(10px);
  -webkit-backdrop-filter: saturate(1.2) blur(10px);
  background: color-mix(in srgb, var(--paper) 82%, transparent);
  border-bottom: 1px solid transparent;
  transition: border-color .3s;
}
.topbar.scrolled { border-bottom-color: var(--rule); }
.topbar .wrap { display: flex; align-items: center; gap: 24px; height: 60px; }
.brand { font-family: var(--mono); font-size: 14px; text-decoration: none; white-space: nowrap; }
.brand b { color: var(--red); font-weight: 500; }
.nav { display: flex; gap: 4px; margin-left: auto; overflow-x: auto; scrollbar-width: none; min-width: 0; }
.nav::-webkit-scrollbar { display: none; }
.nav a {
  font-family: var(--mono); font-size: 12.5px; text-decoration: none;
  padding: 6px 10px; border-radius: 6px; color: var(--ink-2); white-space: nowrap;
}
.nav a span { color: var(--muted); margin-right: 4px; }
.nav a:hover, .nav a.active { color: var(--ink); background: var(--paper-2); }
.nav a.active span { color: var(--red); }
.theme-btn {
  flex: none; width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid var(--rule); background: var(--card); color: var(--ink);
  cursor: pointer; display: grid; place-items: center; font-size: 15px;
}
.theme-btn:hover { border-color: var(--ink-2); }

/* ---------- hero ---------- */
.hero { padding: 56px 0 40px; }
.hero .wrap { display: grid; grid-template-columns: minmax(0, 4.6fr) minmax(0, 7.4fr); gap: 44px; align-items: center; }
.kicker { font-family: var(--mono); font-size: 12.5px; color: var(--muted); letter-spacing: .02em; }
.kicker .dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--green); margin-right: 8px; vertical-align: 1px; box-shadow: 0 0 0 4px color-mix(in srgb, var(--green) 18%, transparent); }
h1.name {
  font-weight: 400; font-size: clamp(46px, 6.2vw, 84px); line-height: .98; letter-spacing: -.025em;
  margin: 18px 0 6px;
}
h1.name em { font-style: italic; color: var(--red); }
.cn { font-family: "Noto Serif SC", "Songti SC", "STSong", serif; font-size: 22px; color: var(--ink-2); letter-spacing: .25em; }
.tagline { font-size: 22px; line-height: 1.45; color: var(--ink-2); margin: 22px 0 22px; max-width: 30em; }
.tagline b { color: var(--ink); font-weight: 500; }
.affil { font-size: 16px; color: var(--ink-2); line-height: 1.7; margin: 0 0 24px; padding-left: 14px; border-left: 2px solid var(--rule); }
.affil sup { font-family: var(--mono); font-size: 10px; color: var(--muted); margin-right: 3px; }
.links { display: flex; flex-wrap: wrap; gap: 8px; }
.btn {
  font-family: var(--mono); font-size: 12.5px; text-decoration: none;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 13px; border-radius: 999px;
  border: 1px solid var(--rule); background: var(--card); color: var(--ink);
  transition: transform .2s, border-color .2s, background .2s;
}
.btn:hover { transform: translateY(-1px); border-color: var(--ink-2); color: var(--ink); }
.btn.primary { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.btn.primary:hover { color: var(--paper); }
.btn svg { width: 14px; height: 14px; }

/* ---------- Figure 1 (3D) ---------- */
.figure {
  position: relative; margin: 0;
  border: 1px solid var(--rule);
  background: var(--card);
  border-radius: 14px;
  box-shadow: var(--shadow);
  overflow: hidden;
  min-width: 0;
}
.fig-head {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  padding: 10px 12px; border-bottom: 1px solid var(--rule);
  font-family: var(--mono); font-size: 12px;
}
.fig-head .label { color: var(--muted); margin-right: 6px; }
.fig-tab {
  font: inherit; cursor: pointer; color: var(--ink-2);
  background: transparent; border: 1px solid transparent; border-radius: 6px; padding: 5px 9px;
}
.fig-tab:hover { background: var(--paper-2); }
.fig-tab[aria-selected="true"] { color: var(--ink); border-color: var(--rule); background: var(--paper); }
.fig-tab i { font-style: normal; color: var(--muted); margin-right: 4px; }
.fig-tab[aria-selected="true"] i { color: var(--red); }
.fig-head .hint { margin-left: auto; color: var(--muted); }
.fig-body { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) 228px; }
.fig-stage { position: relative; height: 470px; cursor: grab; touch-action: pan-y; overflow: hidden; }
.fig-stage:active { cursor: grabbing; }
.fig-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.fig-stage .axis {
  position: absolute; left: 12px; bottom: 10px; font-family: var(--mono); font-size: 10.5px; color: var(--muted); pointer-events: none; z-index: 1;
}
.fig-log {
  border-left: 1px solid var(--rule);
  background: var(--paper);
  font-family: var(--mono); font-size: 11.5px; line-height: 1.55;
  padding: 12px 12px 12px 14px;
  overflow: hidden;
  display: flex; flex-direction: column;
  min-width: 0;
}
.fig-log .title { color: var(--muted); font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; margin-bottom: 8px; display: flex; justify-content: space-between; }
.fig-log ol { list-style: none; margin: 0; padding: 0 4px 0 0; display: flex; flex-direction: column; justify-content: flex-start; flex: 1; overflow-y: auto; overflow-x: hidden; scrollbar-width: thin; scrollbar-color: var(--rule) transparent; }
.fig-log ol::-webkit-scrollbar { width: 4px; }
.fig-log ol::-webkit-scrollbar-thumb { background: var(--rule); border-radius: 4px; }
.fig-log ol::-webkit-scrollbar-track { background: transparent; }
.fig-log li { white-space: pre-wrap; word-break: break-word; color: var(--ink-2); animation: logIn .35s ease both; }
.fig-log li.c { color: var(--muted); }
.fig-log li.a { color: var(--blue); }
.fig-log li.note { color: var(--blue); }
.fig-log li.bad { color: var(--red); }
.fig-log li.ok { color: var(--green); }
.fig-log li.warn { color: var(--amber); }
.fig-log li.code { color: var(--ink); }
@keyframes logIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.figcaption {
  font-size: 14.5px; line-height: 1.5; color: var(--ink-2);
  padding: 12px 16px 14px; border-top: 1px solid var(--rule);
}
.figcaption b { font-weight: 600; color: var(--ink); }
.no-webgl .fig-stage::after {
  content: "This figure needs WebGL. The trace on the right still tells the story.";
  position: absolute; inset: 0; display: grid; place-items: center; padding: 30px; text-align: center;
  font-family: var(--mono); font-size: 12px; color: var(--muted);
}

/* ---------- sections ---------- */
.sec { padding: 44px 0; border-top: 1px solid var(--rule); }
.sec .wrap { display: grid; grid-template-columns: var(--gutter) minmax(0, 1fr); gap: 32px; }
.sec-head { position: relative; }
.sec-head .num { font-family: var(--mono); font-size: 13px; color: var(--red); display: block; }
.sec-head h2 { font-weight: 500; font-size: 27px; line-height: 1.15; margin: 4px 0 0; letter-spacing: -.01em; }
.sec-head p { font-size: 14.5px; color: var(--muted); margin: 10px 0 0; line-height: 1.45; }
.sec-head .sticky { position: sticky; top: 92px; }
.sec-body { max-width: 900px; min-width: 0; }

/* abstract */
.abstract { display: grid; grid-template-columns: minmax(0, 1fr) 230px; gap: 36px; align-items: start; }
.abstract p { margin: 0 0 14px; }
.abstract p:first-child::first-letter {
  float: left; font-size: 3.6em; line-height: .86; padding: 6px 8px 0 0; color: var(--red); font-weight: 500;
}
.keywords { font-size: 15.5px; color: var(--ink-2); margin-top: 18px !important; }
.keywords b { font-style: italic; font-weight: 600; color: var(--ink); }
.portrait { margin: 0; }
.portrait img { width: 100%; height: auto; aspect-ratio: 4/5; object-fit: cover; object-position: 40% 40%; border-radius: 10px; display: block; filter: saturate(.92); border: 1px solid var(--rule); }
.portrait figcaption { font-size: 13.5px; color: var(--muted); margin-top: 8px; line-height: 1.4; }
.listing {
  margin: 26px 0 0; border: 1px solid var(--rule); border-radius: 10px; background: var(--card); overflow: hidden;
}
.listing .lh { font-family: var(--mono); font-size: 11px; color: var(--muted); padding: 8px 14px; border-bottom: 1px solid var(--rule); display: flex; justify-content: space-between; gap: 12px; }
.listing pre { margin: 0; padding: 14px 16px; font-family: var(--mono); font-size: 13px; line-height: 1.65; overflow-x: auto; color: var(--ink-2); }
.listing .k { color: var(--red); }
.listing .t { color: var(--blue); }
.listing .cm { color: var(--muted); font-style: italic; }
.listing .ok { color: var(--green); }

/* news / changelog */
.log { list-style: none; margin: 0; padding: 0; font-size: 16.5px; }
.log li { display: grid; grid-template-columns: 76px 66px minmax(0, 1fr); gap: 12px; padding: 9px 0; border-bottom: 1px dashed var(--rule); align-items: baseline; }
.log li:last-child { border-bottom: 0; }
.log time { font-family: var(--mono); font-size: 12.5px; color: var(--muted); }
/* compact, borderless status marker: dot + micro-label, not a pill */
.log .tag {
  font-family: var(--mono); font-size: 9.5px; letter-spacing: .06em; text-transform: uppercase;
  display: inline-flex; align-items: center; gap: 5px; justify-self: start;
  border: 0; padding: 0; background: none; white-space: nowrap;
}
.log .tag::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; flex: none; }
.tag.release { color: var(--blue); }
.tag.paper { color: var(--red); }
.tag.pub { color: var(--green); }

/* trajectory */
.traj { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; perspective: 1100px; }
.stage {
  position: relative; padding: 18px 18px 16px; border: 1px solid var(--rule); border-radius: 12px; background: var(--card);
  box-shadow: var(--shadow); transform-style: preserve-3d; transition: transform .25s ease, border-color .25s;
  will-change: transform;
}
.stage:hover { border-color: var(--ink-2); }
.stage::after { /* rewrite arrow between stages */
  content: "⇒"; position: absolute; right: -7px; top: 50%; transform: translate(50%, -50%);
  font-size: 16px; color: var(--muted); background: var(--paper); line-height: 1; padding: 2px 0; z-index: 1;
}
.stage:last-child::after { display: none; }
.stage .yrs { font-family: var(--mono); font-size: 11.5px; color: var(--muted); }
.stage h3 { font-weight: 500; font-size: 20px; line-height: 1.2; margin: 6px 0 8px; transform: translateZ(24px); }
.stage p { font-size: 15px; line-height: 1.5; color: var(--ink-2); margin: 0 0 12px; transform: translateZ(14px); }
.stage .rule { font-family: var(--mono); font-size: 11.5px; color: var(--red); margin-bottom: 10px; display: block; transform: translateZ(18px); }
.stage ul { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 5px; transform: translateZ(10px); }
.stage li { font-family: var(--mono); font-size: 11px; padding: 2px 7px; border-radius: 4px; background: var(--paper-2); color: var(--ink-2); }
.stage .glyph { position: absolute; right: 14px; top: 12px; font-size: 26px; color: var(--rule); transform: translateZ(30px); font-style: italic; transition: color .25s; }
.stage:hover .glyph { color: var(--red); }

/* metrics strip */
.facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-top: 22px; border: 1px solid var(--rule); border-radius: 12px; overflow: hidden; background: var(--card); }
.fact { padding: 14px 16px; border-right: 1px solid var(--rule); }
.fact:last-child { border-right: 0; }
.fact b { display: block; font-weight: 400; font-size: 30px; line-height: 1.1; letter-spacing: -.02em; }
.fact span { font-size: 13.5px; color: var(--muted); line-height: 1.35; display: block; margin-top: 4px; }

/* publications */
.filters { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 8px; }
.chip {
  font-family: var(--mono); font-size: 12px; cursor: pointer;
  padding: 6px 11px; border-radius: 999px; border: 1px solid var(--rule); background: var(--card); color: var(--ink-2);
}
.chip:hover { border-color: var(--ink-2); }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.chip .n { opacity: .6; margin-left: 5px; }
.legend { font-size: 13.5px; color: var(--muted); margin: 0 0 6px; }
.legend b { color: var(--ink); }
.year-group[hidden] { display: none; }
.year { font-family: var(--mono); font-size: 13px; color: var(--muted); margin: 24px 0 4px; display: flex; align-items: center; gap: 12px; }
.year::after { content: ""; flex: 1; height: 1px; background: var(--rule); }
.pubs { list-style: none; margin: 0; padding: 0; }
.pub { display: grid; grid-template-columns: 78px minmax(0, 1fr); gap: 16px; padding: 12px 0; border-bottom: 1px dashed var(--rule); }
.pub:last-child { border-bottom: 0; }
.pub[hidden] { display: none; }
.venue {
  font-family: var(--mono); font-size: 11.5px; line-height: 1.3; text-align: center;
  padding: 5px 4px; border-radius: 6px; align-self: start;
  border: 1px solid var(--rule); color: var(--ink-2); background: var(--card);
}
.pub.llm .venue { color: var(--blue); border-color: color-mix(in srgb, var(--blue) 40%, transparent); }
.pub.se .venue { color: var(--red); border-color: color-mix(in srgb, var(--red) 40%, transparent); }
.pub.ai .venue { color: var(--amber); border-color: color-mix(in srgb, var(--amber) 45%, transparent); }
.pub.sensing .venue { color: var(--green); border-color: color-mix(in srgb, var(--green) 45%, transparent); }
.ptitle { font-size: 18px; font-weight: 500; line-height: 1.35; text-decoration: none; }
.ptitle:hover { text-decoration: underline; }
.star { color: var(--amber); font-size: 14px; margin-left: 6px; }
.authors { font-size: 15.5px; color: var(--ink-2); line-height: 1.45; margin-top: 2px; }
.authors b { color: var(--ink); font-weight: 600; text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--red) 60%, transparent); text-underline-offset: 3px; text-decoration-thickness: 1.5px; }
.where { font-size: 14.5px; color: var(--muted); margin-top: 2px; }
.where i { color: var(--ink-2); }
.plinks { display: inline-flex; flex-wrap: wrap; gap: 6px; margin-left: 8px; }
.plinks a { font-family: var(--mono); font-size: 11px; text-decoration: none; padding: 0 6px; border: 1px solid var(--rule); border-radius: 4px; color: var(--ink-2); }
.plinks a:hover { border-color: var(--blue); color: var(--blue); }
.tldr { font-size: 15px; color: var(--ink-2); margin: 6px 0 0; padding-left: 10px; border-left: 2px solid var(--rule); font-style: italic; }

/* artifacts */
.repos { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.repo {
  display: block; text-decoration: none; padding: 14px 16px; border: 1px solid var(--rule); border-radius: 10px; background: var(--card);
  transition: transform .2s, border-color .2s;
}
.repo:hover { transform: translateY(-2px); border-color: var(--ink-2); color: var(--ink); }
.repo .rn { font-family: var(--mono); font-size: 13.5px; font-weight: 500; overflow-wrap: anywhere; }
.repo .rn span { color: var(--muted); font-weight: 400; }
.repo p { margin: 6px 0 0; font-size: 14.5px; color: var(--ink-2); line-height: 1.45; }
.repo .rt { font-family: var(--mono); font-size: 10.5px; color: var(--muted); margin-top: 8px; display: block; }

/* honors */
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; }
.cols h3 { font-weight: 500; font-size: 13px; font-family: var(--mono); color: var(--muted); margin: 0 0 8px; letter-spacing: .02em; }
.plain { list-style: none; padding: 0; margin: 0; }
.plain li { padding: 7px 0; border-bottom: 1px dashed var(--rule); font-size: 16.5px; }
.plain li:last-child { border-bottom: 0; }
.plain li span { color: var(--muted); font-size: 14px; }

/* contact */
.contact { font-size: 20px; line-height: 1.55; }
.contact .addr { font-family: var(--mono); font-size: 15px; padding: 12px 16px; display: inline-block; margin: 6px 0 14px; border: 1px solid var(--rule); background: var(--card); border-radius: 8px; }
.contact .addr button { font: inherit; font-size: 11px; margin-left: 10px; cursor: pointer; border: 1px solid var(--rule); background: var(--paper); color: var(--ink-2); border-radius: 4px; padding: 2px 7px; }

footer { border-top: 1px solid var(--rule); padding: 28px 0 48px; font-size: 13.5px; color: var(--muted); }
footer .wrap { display: flex; flex-wrap: wrap; gap: 8px 24px; justify-content: space-between; }
footer .mono { font-size: 12px; }

/* reveal */
.js .reveal { opacity: 0; transform: translateY(14px); transition: opacity .7s ease, transform .7s ease; }
.js .reveal.in { opacity: 1; transform: none; }

/* ---------- responsive ---------- */
@media (max-width: 1080px) {
  .hero .wrap { grid-template-columns: 1fr; gap: 32px; }
  .traj { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stage:nth-child(2)::after { display: none; }
  :root { --gutter: 170px; }
}
@media (max-width: 820px) {
  body { font-size: 17.5px; }
  .wrap { padding: 0 20px; }
  .sec .wrap { grid-template-columns: 1fr; gap: 14px; }
  .sec-head .sticky { position: static; }
  .abstract { grid-template-columns: 1fr; }
  .portrait { max-width: 280px; }
  .fig-body { grid-template-columns: 1fr; }
  .fig-stage { height: 360px; }
  .fig-log { border-left: 0; border-top: 1px solid var(--rule); height: 180px; }
  .fig-head .hint { display: none; }
  .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fact:nth-child(2) { border-right: 0; }
  .fact:nth-child(-n+2) { border-bottom: 1px solid var(--rule); }
  .cols { grid-template-columns: 1fr; }
  .nav a span { display: none; }
  .tagline { font-size: 20px; }
}
@media (max-width: 560px) {
  .traj { grid-template-columns: 1fr; }
  .stage::after { display: none; }
  .pub { grid-template-columns: 1fr; gap: 6px; }
  .venue { justify-self: start; padding: 2px 8px; }
  .venue br { display: none; }
  .log li { grid-template-columns: 64px minmax(0, 1fr); }
  .log .tag { display: none; }
  .tagline { font-size: 19px; }
  .contact { font-size: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .js .reveal { opacity: 1; transform: none; transition: none; }
  .fig-log li { animation: none; }
}
@media print {
  .topbar, .figure, .theme-btn, .filters { display: none !important; }
  body::before { display: none; }
  .js .reveal { opacity: 1; transform: none; }
}
