/* ---------- Tokens ---------- */
:root {
  --bg: #fbfaf7;
  --surface: #ffffff;
  --surface-2: #f3f1ec;
  --text: #1b1c1f;
  --muted: #5d6068;
  --faint: #8a8d94;
  --line: #e7e4dc;
  --accent: #0e6b6b;
  --accent-soft: #e2efed;
  --gold: #a87b06;
  --gold-soft: #f6ecd2;
  --silver: #66707f;
  --silver-soft: #e9ecf0;
  --bronze: #9a5530;
  --bronze-soft: #f4e3d8;
  --special: #6b4fb3;
  --special-soft: #ece6f8;
  --shadow: 0 1px 2px rgba(20, 20, 20, .04), 0 8px 24px rgba(20, 20, 20, .05);
  --serif: "Newsreader", "Iowan Old Style", Georgia, "Songti SC", serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121314; --surface: #1a1b1d; --surface-2: #202224;
    --text: #e9e7e2; --muted: #a6a8ad; --faint: #7b7e85; --line: #2b2d30;
    --accent: #6ccabd; --accent-soft: #1b2f2c;
    --gold: #e2b84f; --gold-soft: #322a17;
    --silver: #b8c0cc; --silver-soft: #262a30;
    --bronze: #d9926a; --bronze-soft: #33241c;
    --special: #b6a1ee; --special-soft: #2a2438;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121314; --surface: #1a1b1d; --surface-2: #202224;
  --text: #e9e7e2; --muted: #a6a8ad; --faint: #7b7e85; --line: #2b2d30;
  --accent: #6ccabd; --accent-soft: #1b2f2c;
  --gold: #e2b84f; --gold-soft: #322a17;
  --silver: #b8c0cc; --silver-soft: #262a30;
  --bronze: #d9926a; --bronze-soft: #33241c;
  --special: #b6a1ee; --special-soft: #2a2438;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 24px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.65 var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
img { max-width: 100%; display: block; }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
h1, h2, h3 { margin: 0; font-weight: 600; }
.icon { width: 1em; height: 1em; flex: none; vertical-align: -0.125em; }
.icon-sm { width: .85em; height: .85em; }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 16px; top: 16px; z-index: 10; background: var(--surface); padding: 8px 12px; }

/* ---------- Layout ---------- */
.page {
  max-width: 1140px;
  margin: 0 auto;
  padding: 0 32px;
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  gap: 80px;
}
.sidebar {
  position: sticky; top: 0;
  height: 100vh;
  padding: 72px 0 32px;
  display: flex; flex-direction: column;
}
main { padding: 72px 0 64px; min-width: 0; }

/* ---------- Sidebar ---------- */
.avatar {
  width: 148px; height: 148px;
  border-radius: 50%;
  object-fit: cover;
  margin-bottom: 24px;
  box-shadow: 0 0 0 4px var(--surface), 0 0 0 5px var(--line);
}
.avatar-mono {
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent) 0%, color-mix(in srgb, var(--accent) 55%, #000) 100%);
  color: #fbfaf7;
  font: 500 56px/1 var(--serif);
  letter-spacing: .02em;
}
.name { font: 600 2.1rem/1.1 var(--serif); letter-spacing: -.01em; }
.role { margin-top: 10px; color: var(--muted); }
.name-alt { margin-top: 4px; color: var(--faint); font-size: .92rem; letter-spacing: .02em; }
.org a { color: var(--text); font-weight: 500; }
.visiting { margin-top: 8px; color: var(--muted); font-size: .88rem; line-height: 1.45; }
.visiting a { color: var(--text); font-weight: 500; }
.links { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 20px; }
.links a {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px;
  border: 1px solid var(--line); border-radius: 999px;
  color: var(--muted); font-size: .82rem; font-weight: 500;
  background: var(--surface);
  transition: color .15s, border-color .15s;
}
.links a:hover { color: var(--accent); border-color: var(--accent); text-decoration: none; }

.toc { display: flex; flex-direction: column; gap: 2px; margin-top: 40px; }
.toc a {
  color: var(--faint); font-size: .9rem; font-weight: 500;
  padding: 4px 0 4px 14px;
  border-left: 2px solid var(--line);
  transition: color .15s, border-color .15s;
}
.toc a:hover { color: var(--text); text-decoration: none; }
.toc a.active { color: var(--accent); border-left-color: var(--accent); }

.tools { margin-top: 28px; display: flex; align-items: center; gap: 8px; }
.lang-switch {
  display: inline-flex; align-items: center;
  border: 1px solid var(--line); border-radius: 999px;
  color: var(--muted); font: 500 .8rem var(--sans);
  padding: 6px 12px;
}
.lang-switch:hover { color: var(--accent); border-color: var(--accent); text-decoration: none; }
.theme-toggle {
  display: inline-flex; align-items: center; gap: 8px;
  background: none; border: 1px solid var(--line); border-radius: 999px;
  color: var(--muted); font: 500 .8rem var(--sans);
  padding: 6px 12px; cursor: pointer;
}
.theme-toggle:hover { color: var(--text); }
.when-dark { display: none; }
:root[data-theme="dark"] .when-dark { display: inline-flex; }
:root[data-theme="dark"] .when-light { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .when-dark { display: inline-flex; }
  :root:not([data-theme="light"]) .when-light { display: none; }
}

/* ---------- Sections ---------- */
.section { padding-bottom: 56px; }
.section + .section { padding-top: 8px; }
.section-title {
  display: flex; align-items: center; gap: 16px;
  font: 600 1.55rem/1.2 var(--serif);
  margin-bottom: 24px;
}
.section-title::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.prose p + p { margin-top: 14px; }
.prose { font-size: 1.02rem; color: var(--text); max-width: 68ch; }
.interests { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 22px; }
.interests li {
  font-size: .82rem; font-weight: 500;
  color: var(--accent); background: var(--accent-soft);
  padding: 4px 12px; border-radius: 999px;
}

/* ---------- News ---------- */
.news li {
  display: grid; grid-template-columns: 84px minmax(0, 1fr); gap: 16px;
  padding: 10px 0;
  border-bottom: 1px dashed var(--line);
}
.news li:last-child { border-bottom: 0; }
.news time {
  color: var(--faint); font-size: .85rem; font-weight: 500;
  font-variant-numeric: tabular-nums; padding-top: 1px;
  white-space: nowrap;
}
.more { margin-top: 4px; }
.more summary {
  cursor: pointer; color: var(--accent);
  font-size: .88rem; font-weight: 500; padding: 8px 0;
  list-style: none;
}
.more summary::-webkit-details-marker { display: none; }
.more summary::before { content: "+ "; }
.more[open] summary::before { content: "− "; }

/* ---------- Publications ---------- */
.pubs { display: flex; flex-direction: column; gap: 28px; }
.pub { display: grid; grid-template-columns: 212px minmax(0, 1fr); gap: 24px; align-items: start; }
.pub-thumb {
  position: relative;
  aspect-ratio: 16 / 10;
  border-radius: 10px; overflow: hidden;
  background: #fff;
  border: 1px solid var(--line);
}
.pub-thumb img { width: 100%; height: 100%; object-fit: contain; padding: 26px 8px 8px; }
.pub-tile {
  width: 100%; height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background:
    radial-gradient(circle at 20% 15%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 55%),
    linear-gradient(135deg, var(--accent-soft), var(--surface-2));
  color: var(--accent);
}
.pub-tile span { font: 600 2.2rem/1 var(--serif); }
.pub-tile small { margin-top: 6px; font-size: .8rem; letter-spacing: .12em; color: var(--muted); }
.pub-thumb:has(.pub-tile) { background: var(--surface-2); }
.venue-badge {
  position: absolute; left: 8px; top: 8px;
  font-size: .7rem; font-weight: 600; letter-spacing: .03em;
  color: #fff; background: var(--accent);
  padding: 2px 8px; border-radius: 6px;
}
:root[data-theme="dark"] .venue-badge { color: #0f1a19; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .venue-badge { color: #0f1a19; } }
.pub-body { min-width: 0; }
.pub-title { font: 600 1.14rem/1.35 var(--serif); }
.pub-title a { color: var(--text); }
.pub-title a:hover { color: var(--accent); }
.pub-authors { margin-top: 6px; color: var(--muted); font-size: .92rem; }
.me { color: var(--text); font-weight: 600; text-decoration: underline; text-decoration-color: var(--accent); text-decoration-thickness: 2px; text-underline-offset: 3px; }
.pub-venue { margin-top: 2px; color: var(--muted); font-size: .92rem; font-style: italic; }
.pub-note { margin-top: 6px; font-size: .85rem; font-weight: 500; color: var(--gold); }
.pub-note::before { content: "🏆 "; }
.pub-links { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: .78rem; font-weight: 500;
  color: var(--text);
  padding: 3px 10px; border-radius: 6px;
  border: 1px solid var(--line); background: var(--surface);
  transition: border-color .15s, color .15s;
}
.pill:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }

.pub-highlight {
  display: inline-block; margin-left: 4px;
  font-style: normal; font-size: .72rem; font-weight: 600; letter-spacing: .04em;
  color: var(--special); background: var(--special-soft);
  padding: 1px 8px; border-radius: 5px; vertical-align: 1px;
}
.bib { display: contents; }
.bib[open] { display: block; flex-basis: 100%; min-width: 0; max-width: 100%; }
.bib summary { cursor: pointer; list-style: none; width: max-content; }
.bib summary::-webkit-details-marker { display: none; }
.bib[open] summary { border-color: var(--accent); color: var(--accent); }
.bib-box {
  position: relative; margin-top: 8px; width: 100%; min-width: 0; overflow: hidden;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px;
}
.bib-box pre {
  margin: 0; padding: 14px 16px; overflow-x: auto;
  font: 400 .76rem/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--text); white-space: pre;
}
.bib-copy {
  position: absolute; top: 8px; right: 8px;
  font: 500 .72rem var(--sans); color: var(--muted);
  background: var(--surface); border: 1px solid var(--line); border-radius: 6px;
  padding: 3px 9px; cursor: pointer;
}
.bib-copy:hover { color: var(--accent); border-color: var(--accent); }

/* ---------- Job market ---------- */
.status-badge {
  display: inline-flex; align-items: center; gap: 7px;
  margin-top: 12px; padding: 3px 11px;
  font-size: .78rem; font-weight: 600; color: var(--accent);
  background: var(--accent-soft); border-radius: 999px;
}
.dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent);
}
.job-card {
  margin-bottom: 48px; padding: 26px 28px;
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--line));
  border-radius: 16px;
  background:
    radial-gradient(120% 140% at 100% 0%, var(--accent-soft), transparent 60%),
    var(--surface);
}
.job-eyebrow {
  display: flex; align-items: center; gap: 9px;
  font-size: .76rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
  color: var(--accent);
}
.job-headline { margin-top: 12px; font: 600 1.45rem/1.3 var(--serif); max-width: 34ch; }
.job-seeking { margin-top: 8px; color: var(--muted); max-width: 62ch; }
.job-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 14px; border-radius: 8px;
  font-size: .86rem; font-weight: 600; color: var(--text);
  border: 1px solid var(--line); background: var(--surface);
}
.btn:hover { text-decoration: none; border-color: var(--accent); color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { color: #fff; filter: brightness(1.08); }
:root[data-theme="dark"] .btn-primary, :root[data-theme="dark"] .btn-primary:hover { color: #0f1a19; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .btn-primary, :root:not([data-theme="light"]) .btn-primary:hover { color: #0f1a19; }
}

/* ---------- Awards ---------- */
.awards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.award {
  display: flex; gap: 14px; align-items: flex-start;
  padding: 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
}
.medal {
  flex: none; width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center;
  font: 600 .9rem/1 var(--serif);
}
.medal-gold { color: var(--gold); background: var(--gold-soft); box-shadow: inset 0 0 0 1.5px var(--gold); }
.medal-silver { color: var(--silver); background: var(--silver-soft); box-shadow: inset 0 0 0 1.5px var(--silver); }
.medal-bronze { color: var(--bronze); background: var(--bronze-soft); box-shadow: inset 0 0 0 1.5px var(--bronze); }
.medal-special { color: var(--special); background: var(--special-soft); box-shadow: inset 0 0 0 1.5px var(--special); font-size: 1.1rem; }
.award-body { min-width: 0; }
.award-rank { font-size: .8rem; font-weight: 600; color: var(--text); }
.award-venue { color: var(--faint); font-weight: 500; }
.award-title { margin-top: 2px; font: 600 1.02rem/1.3 var(--serif); }
.award-title a { color: var(--text); }
.award-title a:hover { color: var(--accent); }
.award-track { margin-top: 2px; font-size: .85rem; color: var(--muted); }
.award-note { margin-top: 4px; font-size: .78rem; color: var(--faint); font-style: italic; }

/* ---------- Projects ---------- */
.project-featured, .project {
  display: block; color: inherit;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  transition: border-color .15s, transform .15s, box-shadow .15s;
}
.project-featured:hover, .project:hover {
  text-decoration: none; border-color: color-mix(in srgb, var(--accent) 50%, var(--line));
  transform: translateY(-2px); box-shadow: var(--shadow);
}
.project-featured {
  display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  overflow: hidden; margin-bottom: 12px;
}
.project-shot { background: var(--surface-2); padding: 18px 0 0 18px; overflow: hidden; }
.project-shot img {
  width: 100%; height: 100%; min-height: 200px;
  object-fit: cover; object-position: left top;
  border-radius: 8px 0 0 0;
  box-shadow: var(--shadow);
}
.project-info { padding: 24px; display: flex; flex-direction: column; gap: 10px; }
.eyebrow { font-size: .72rem; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); }
.project-info h3 { font: 600 1.35rem/1.2 var(--serif); display: flex; align-items: center; gap: 6px; }
.project-info p:not(.eyebrow) { color: var(--muted); font-size: .92rem; }
.projects { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.projects li { display: flex; }
.project { padding: 18px; display: flex; flex-direction: column; gap: 8px; width: 100%; }
.project h3 { font: 600 1rem/1.3 var(--sans); display: flex; align-items: center; gap: 8px; color: var(--text); overflow-wrap: anywhere; }
.project p { color: var(--muted); font-size: .86rem; flex: 1; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.tags li { font-size: .72rem; color: var(--muted); background: var(--surface-2); padding: 2px 8px; border-radius: 5px; }

/* ---------- Service & footer ---------- */
.service-role { font-size: .8rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); margin-bottom: 8px; }
.service-list li { padding: 2px 0; }
.service-list a { color: var(--text); }
.service-list a:hover { color: var(--accent); }
.footer {
  margin-top: 24px; padding-top: 24px;
  border-top: 1px solid var(--line);
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 16px;
  color: var(--faint); font-size: .82rem;
}
.visitors { max-width: 200px; opacity: .85; }

/* ---------- Responsive ---------- */
@media (max-width: 1000px) {
  .projects { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .project-featured { grid-template-columns: 1fr; }
  .project-shot { padding: 18px 18px 0; max-height: 240px; }
  .project-shot img { border-radius: 8px 8px 0 0; }
}
@media (max-width: 860px) {
  .page { grid-template-columns: 1fr; gap: 0; padding: 0 16px; }
  .sidebar {
    position: static; height: auto;
    padding: 40px 0 0;
    align-items: center; text-align: center;
  }
  .avatar { width: 120px; height: 120px; margin: 0 auto 18px; }
  .avatar-mono { font-size: 46px; }
  .name { font-size: 1.85rem; }
  .links { justify-content: center; }
  .toc {
    position: sticky; top: 0; z-index: 5;
    flex-direction: row; gap: 4px;
    margin: 24px -16px 0; padding: 10px 16px;
    overflow-x: auto; scrollbar-width: none;
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--line);
  }
  .toc::-webkit-scrollbar { display: none; }
  .toc a { border-left: 0; padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
  .toc a.active { background: var(--accent-soft); }
  .tools { position: absolute; top: 16px; right: 16px; margin: 0; }
  .theme-label { display: none; }
  main { padding-top: 32px; }
  html { scroll-padding-top: 64px; }
  /* the sticky nav lives inside the sidebar, so let the sidebar not clip it */
  .sidebar { display: contents; }
  .profile { padding-top: 40px; text-align: center; }
}
@media (max-width: 640px) {
  .pub { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .pub-thumb { max-width: 100%; aspect-ratio: 16 / 9; }
  .awards, .projects { grid-template-columns: 1fr; }
  .news li, :lang(zh-CN) .news li { grid-template-columns: 1fr; gap: 2px; }
  .section-title { font-size: 1.4rem; }
  .job-card { padding: 20px; }
  .job-headline { font-size: 1.25rem; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
}

/* ---------- Chinese ---------- */
:root:lang(zh-CN) {
  --serif: "Newsreader", "Noto Serif SC", "Songti SC", "STSong", "SimSun", serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
}
:lang(zh-CN) body { line-height: 1.8; }
:lang(zh-CN) .prose { max-width: 42em; }
:lang(zh-CN) .medal { font-size: .78rem; }
:lang(zh-CN) .news li { grid-template-columns: 104px minmax(0, 1fr); }
