/* ==========================================================================
   Academic theme — Zewen Liu
   Light-first palette with a deep-blue accent; dark mode follows the OS
   unless the visitor picks a side (see source/js/main.js).
   ========================================================================== */

:root {
  --bg:        #fcfbf9;
  --surface:   #ffffff;
  --text:      #14171d;
  --muted:     #5a616e;
  --soft:      #8a909c;
  --line:      #e7e4de;
  --line-soft: #f0ede8;
  --accent:    #17418c;
  --accent-bg: #eef2fb;
  --honour:    #b3261e;
  --shadow:    0 1px 2px rgba(20, 23, 29, .05), 0 8px 24px -16px rgba(20, 23, 29, .28);

  --serif: "Newsreader", Georgia, "Songti SC", "Source Han Serif SC", serif;
  --sans:  "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
           "Hiragino Sans GB", "Microsoft YaHei", sans-serif;

  --wrap: 800px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:        #101317;
    --surface:   #171b21;
    --text:      #e9eaee;
    --muted:     #a2a9b6;
    --soft:      #79808d;
    --line:      #262b33;
    --line-soft: #1e232a;
    --accent:    #8fb2f2;
    --accent-bg: #1a2233;
    --honour:    #f2857c;
    --shadow:    0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px -16px rgba(0, 0, 0, .8);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg:        #101317;
  --surface:   #171b21;
  --text:      #e9eaee;
  --muted:     #a2a9b6;
  --soft:      #79808d;
  --line:      #262b33;
  --line-soft: #1e232a;
  --accent:    #8fb2f2;
  --accent-bg: #1a2233;
  --honour:    #f2857c;
  --shadow:    0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px -16px rgba(0, 0, 0, .8);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15.5px;
  line-height: 1.72;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }

img { max-width: 100%; }

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

/* ---------- Header ------------------------------------------------------ */

.nav {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.6) blur(10px);
  -webkit-backdrop-filter: saturate(1.6) blur(10px);
  border-bottom: 1px solid var(--line-soft);
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 58px;
}

.nav-brand {
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 500;
  letter-spacing: -.01em;
  color: var(--text);
}
.nav-brand:hover { text-decoration: none; color: var(--accent); }

.nav-links { display: flex; align-items: center; gap: 22px; }

.nav-links a {
  font-size: 14px;
  color: var(--muted);
  padding-bottom: 2px;
  border-bottom: 1.5px solid transparent;
}
.nav-links a:hover { color: var(--text); text-decoration: none; }
.nav-links a.is-active { color: var(--text); border-bottom-color: var(--accent); }

.theme-toggle {
  display: grid;
  place-items: center;
  width: 30px; height: 30px;
  margin-left: -6px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 8px;
  background: none;
  color: var(--muted);
  cursor: pointer;
}
.theme-toggle:hover { color: var(--text); border-color: var(--line); }
.theme-toggle .i-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .i-sun  { display: none; }
  :root:not([data-theme="light"]) .theme-toggle .i-moon { display: block; }
}
:root[data-theme="dark"] .theme-toggle .i-sun  { display: none; }
:root[data-theme="dark"] .theme-toggle .i-moon { display: block; }
:root[data-theme="light"] .theme-toggle .i-sun  { display: block; }
:root[data-theme="light"] .theme-toggle .i-moon { display: none; }

/* ---------- Hero -------------------------------------------------------- */

.hero {
  display: grid;
  grid-template-columns: 190px 1fr;
  gap: 40px;
  align-items: start;
  padding: 72px 0 8px;
}

.hero-photo img {
  width: 190px;
  height: 190px;
  object-fit: cover;
  border-radius: 14px;
  box-shadow: var(--shadow);
  display: block;
}

.hero-name {
  font-family: var(--serif);
  font-size: 40px;
  font-weight: 500;
  letter-spacing: -.02em;
  line-height: 1.1;
  margin: 0 0 6px;
}

.hero-name-cn {
  font-size: 21px;
  font-weight: 400;
  color: var(--soft);
  margin-left: 12px;
  letter-spacing: 0;
  vertical-align: 3px;
}

.hero-role {
  margin: 0 0 18px;
  font-size: 14.5px;
  color: var(--muted);
}

.hero-bio p { margin: 0 0 12px; }
.hero-bio p:last-child { margin-bottom: 0; }

/* Interest chips */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  list-style: none;
  margin: 20px 0 0;
  padding: 0;
}
.chips li {
  font-size: 12.5px;
  line-height: 1;
  padding: 6px 11px;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
}

/* Contact row */
.contact {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  list-style: none;
  margin: 22px 0 0;
  padding: 0;
}
.contact a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: var(--muted);
}
.contact a:hover { color: var(--accent); text-decoration: none; }
.contact svg { flex: none; opacity: .85; }

/* ---------- Sections ---------------------------------------------------- */

.section { padding: 52px 0 0; }

.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  font-family: var(--serif);
  font-size: 23px;
  font-weight: 500;
  letter-spacing: -.01em;
  margin: 0 0 22px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.section-more {
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 400;
  color: var(--soft);
  white-space: nowrap;
}
.section-more:hover { color: var(--accent); text-decoration: none; }

/* ---------- News -------------------------------------------------------- */

.news { list-style: none; margin: 0; padding: 0; }

/* `hidden` must beat the `display: grid` below. */
.news li[hidden] { display: none; }

.news li {
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 16px;
  padding: 7px 0;
  font-size: 14.5px;
}

.news-date {
  color: var(--soft);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  padding-top: 1px;
}

.news-body { color: var(--muted); }
.news-body strong { color: var(--text); font-weight: 600; }

.more-btn {
  margin-top: 14px;
  padding: 7px 14px;
  font-family: var(--sans);
  font-size: 13px;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
}
.more-btn:hover { color: var(--accent); border-color: var(--accent); }

/* ---------- Publications ------------------------------------------------ */

.pub-list { list-style: none; margin: 0; padding: 0; }

.pub {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 28px;
  align-items: start;
  padding: 22px 0;
  border-bottom: 1px solid var(--line-soft);
}
.pub:last-child { border-bottom: 0; }

/* The card height follows the figure's own aspect so wide framework diagrams
   are not shrunk into a fixed box; min/max keep the column tidy. */
.pub-thumb {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 116px;
  overflow: hidden;
  padding: 8px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 9px;
  transition: box-shadow .18s ease, transform .18s ease;
}
.pub:hover .pub-thumb { box-shadow: var(--shadow); transform: translateY(-1px); }

.pub-thumb img {
  width: 100%;
  height: auto;
  max-height: 184px;
  object-fit: contain;
  display: block;
}

.pub-thumb.is-empty {
  min-height: 132px;
  background: linear-gradient(140deg, var(--accent-bg), var(--surface));
  border-style: dashed;
}
.pub-thumb.is-empty span {
  font-family: var(--serif);
  font-size: 16px;
  color: var(--accent);
  text-align: center;
  padding: 0 10px;
}

.pub-meta { display: flex; align-items: center; gap: 10px; margin-bottom: 7px; }

.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
  line-height: 1;
  padding: 5px 8px;
  border-radius: 5px;
  color: var(--accent);
  background: var(--accent-bg);
}
.badge-preprint,
.badge-oss { color: var(--muted); background: var(--line-soft); }

.pub-note { font-size: 12.5px; color: var(--soft); }

/* Oral / Spotlight / Best Paper — worth catching the eye. */
.pub-note.is-honour { color: var(--honour); font-weight: 600; }

.pub-title {
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 500;
  line-height: 1.4;
  letter-spacing: -.005em;
  margin: 0 0 5px;
}
.pub-title a { color: var(--text); }
.pub-title a:hover { color: var(--accent); text-decoration: none; }

.pub-authors {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--muted);
}
.pub-authors .me { color: var(--text); font-weight: 600; }
.pub-authors sup { font-size: 9px; vertical-align: super; }

.pub-links { margin: 8px 0 0; font-size: 13px; }
.pub-links .sep { color: var(--soft); margin: 0 7px; }

/* ---------- Page headers, prose ---------------------------------------- */

.page-head { padding: 64px 0 6px; }

.page-title {
  font-family: var(--serif);
  font-size: 34px;
  font-weight: 500;
  letter-spacing: -.02em;
  line-height: 1.15;
  margin: 0;
}

.page-sub { margin: 8px 0 0; font-size: 14px; color: var(--soft); }

.post-meta { margin: 0 0 10px; font-size: 13px; color: var(--soft); }

.prose { padding-top: 30px; }
.prose > *:first-child { margin-top: 0; }

.prose h1 {
  font-family: var(--serif);
  font-size: 27px;
  font-weight: 500;
  letter-spacing: -.015em;
  margin: 40px 0 16px;
}

.prose h2 {
  font-family: var(--serif);
  font-size: 23px;
  font-weight: 500;
  letter-spacing: -.01em;
  margin: 46px 0 16px;
  padding-bottom: 9px;
  border-bottom: 1px solid var(--line);
}

.prose h3 {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--soft);
  margin: 30px 0 12px;
}

.prose h4 { font-size: 15.5px; font-weight: 600; margin: 22px 0 8px; }

.prose p { margin: 0 0 14px; }
.prose ul { margin: 0 0 14px; padding-left: 20px; }
.prose li { margin-bottom: 6px; }
.prose li::marker { color: var(--soft); }

.prose hr { border: 0; border-top: 1px solid var(--line-soft); margin: 34px 0; }

.prose code {
  font-size: .9em;
  padding: 2px 5px;
  background: var(--line-soft);
  border-radius: 4px;
}
.prose pre {
  overflow-x: auto;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 9px;
}
.prose pre code { padding: 0; background: none; }

.prose blockquote {
  margin: 0 0 14px;
  padding-left: 16px;
  border-left: 2px solid var(--line);
  color: var(--muted);
}

.prose table { width: 100%; border-collapse: collapse; margin: 0 0 16px; font-size: 14px; }
.prose th, .prose td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line-soft); }

.prose img { border-radius: 8px; }

/* CV rows: "- **Label** <span class="when">date</span>" */
.prose .when {
  float: right;
  margin-left: 20px;
  color: var(--soft);
  font-size: 13px;
  font-style: normal;
}

/* ---------- Blog list --------------------------------------------------- */

.post-list { list-style: none; margin: 0; padding: 30px 0 0; }
.post-list li { padding: 16px 0; border-bottom: 1px solid var(--line-soft); }

.post-link { display: flex; align-items: baseline; gap: 16px; }
.post-link:hover { text-decoration: none; }

.post-date {
  flex: none;
  width: 92px;
  font-size: 13px;
  color: var(--soft);
  font-variant-numeric: tabular-nums;
}

.post-title {
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 500;
  color: var(--text);
}
.post-link:hover .post-title { color: var(--accent); }

.post-desc { margin: 4px 0 0 108px; font-size: 13.5px; color: var(--muted); }

.back { margin: 44px 0 0; font-size: 14px; }

/* ---------- Footer ------------------------------------------------------ */

.foot {
  margin-top: 76px;
  padding: 26px 0 40px;
  border-top: 1px solid var(--line-soft);
}
.foot p { margin: 0; font-size: 13px; color: var(--soft); }
.foot a { color: var(--soft); }

/* ---------- Responsive -------------------------------------------------- */

@media (max-width: 720px) {
  body { font-size: 15px; }

  .hero {
    grid-template-columns: 1fr;
    gap: 24px;
    padding-top: 44px;
  }
  .hero-photo img { width: 128px; height: 128px; }
  .hero-name { font-size: 32px; }
  .hero-name-cn { font-size: 18px; margin-left: 9px; }

  .page-head { padding-top: 44px; }
  .page-title { font-size: 28px; }

  .pub {
    grid-template-columns: 1fr;
    gap: 14px;
  }
  .pub-thumb { max-width: 340px; }

  .news li { grid-template-columns: 44px 1fr; gap: 12px; font-size: 14px; }

  .post-link { flex-direction: column; gap: 2px; }
  .post-date { width: auto; }
  .post-desc { margin-left: 0; }

  .nav-links { gap: 15px; }
  .nav-links a { font-size: 13.5px; }
}

@media (max-width: 420px) {
  .nav-brand { display: none; }
  .nav-inner { justify-content: flex-end; }
}

/* ---------- Math ------------------------------------------------------- */

.math-display {
  overflow-x: auto;
  overflow-y: hidden;
  margin: 18px 0;
  padding: 2px 0;
  text-align: center;
}
.math-inline { white-space: nowrap; }
