/* ---------- tokens ---------- */
:root {
  --bg: #f7f8fa;
  --bg-elevated: #ffffff;
  --text: #16202a;
  --text-muted: #5a6573;
  --text-faint: #8b94a0;
  --border: #e1e5eb;
  --accent: #0b6e8a;
  --accent-strong: #08556b;
  --accent-soft: rgba(11, 110, 138, 0.10);
  --shadow: 0 1px 2px rgba(22, 32, 42, 0.04), 0 6px 20px rgba(22, 32, 42, 0.05);

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', Menlo, Consolas, monospace;
  --max-width: 1040px;
  --side-width: 240px;
  --content-width: 720px;
  --radius: 8px;
  --nav-h: 52px;
}
:root[data-theme="dark"] {
  --bg: #0f1419;
  --bg-elevated: #161c23;
  --text: #e6ebf0;
  --text-muted: #a3adb8;
  --text-faint: #6c7682;
  --border: #252d37;
  --accent: #4cc2dd;
  --accent-strong: #7dd6ea;
  --accent-soft: rgba(76, 194, 221, 0.14);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 20px rgba(0, 0, 0, 0.35);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1419;
    --bg-elevated: #161c23;
    --text: #e6ebf0;
    --text-muted: #a3adb8;
    --text-faint: #6c7682;
    --border: #252d37;
    --accent: #4cc2dd;
    --accent-strong: #7dd6ea;
    --accent-soft: rgba(76, 194, 221, 0.14);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 20px rgba(0, 0, 0, 0.35);
  }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--nav-h) + 16px); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-strong); text-decoration: underline; text-underline-offset: 3px; }
h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: -0.01em; }
p { margin: 0 0 1em; }
p:last-child { margin-bottom: 0; }
b { font-weight: 600; }
sup { font-size: 0.7em; }

.page {
  max-width: var(--max-width); margin: 0 auto; padding: 0 20px 56px;
  display: grid; grid-template-columns: var(--side-width) minmax(0, var(--content-width));
  justify-content: center; column-gap: 64px; align-items: start;
}
.content { min-width: 0; }

/* ---------- nav ---------- */
.nav {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.nav-inner {
  max-width: var(--max-width); margin: 0 auto; padding: 0 20px;
  height: var(--nav-h);
  display: flex; align-items: center; gap: 20px;
}
.nav-home { display: inline-flex; border-radius: 50%; overflow: hidden; line-height: 0; }
.nav-home img { width: 28px; height: 28px; object-fit: cover; border-radius: 50%; border: 1px solid var(--border); }
.nav-home:hover img { border-color: var(--accent); }
.nav-links { list-style: none; margin: 0; padding: 0; display: flex; gap: 18px; flex: 1; }
.nav-links a { color: var(--text-muted); font-size: 14px; font-weight: 500; }
.nav-links a:hover { color: var(--text); text-decoration: none; }
.nav-right { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 6px;
  border: 1px solid var(--border); background: transparent; color: var(--text-muted);
  cursor: pointer;
}
.icon-btn:hover { color: var(--text); border-color: var(--text-faint); }
.nav-toggle { display: none; }
.icon-moon { display: none; }
:root[data-theme="dark"] .icon-sun { display: none; }
:root[data-theme="dark"] .icon-moon { display: inline; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-sun { display: none; }
  :root:not([data-theme="light"]) .icon-moon { display: inline; }
}

/* ---------- sidebar ---------- */
.side {
  position: sticky; top: var(--nav-h);
  padding-top: 56px;
}
.side-photo {
  position: relative; width: 150px; height: 150px; border-radius: 14px; overflow: hidden;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
  box-shadow: var(--shadow); display: grid; place-items: center; margin-bottom: 18px;
}
.side-photo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: 1; }
.side-initials { font-family: var(--font-mono); font-size: 40px; font-weight: 500; color: #fff; opacity: 0.9; }
.side-name { font-size: 20px; font-weight: 700; line-height: 1.25; letter-spacing: -0.01em; margin-bottom: 6px; }
.side-role { font-family: var(--font-mono); font-size: 12.5px; color: var(--accent); margin-bottom: 2px; }
.side-affil { font-size: 14px; color: var(--text-muted); line-height: 1.45; margin-bottom: 18px; }
.side-affil a { color: var(--text-muted); }
.side-affil a:hover { color: var(--accent); }
.side-links { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 7px; }
.side-links a { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text-muted); }
.side-links a:hover { color: var(--accent); text-decoration: none; }
.side-links svg { flex: none; opacity: 0.85; }

/* ---------- sections ---------- */
.block { padding: 40px 0 8px; }
.content > .block:first-child { padding-top: 56px; }
.block > h2 {
  font-size: 13px; font-weight: 500; font-family: var(--font-mono);
  text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-faint);
  margin-bottom: 18px;
}
.block-intro { color: var(--text-muted); margin-bottom: 20px; }
.chips { list-style: none; margin: 18px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.chips li {
  font-family: var(--font-mono); font-size: 12.5px;
  padding: 3px 10px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent-strong);
}

/* news */
.news { list-style: none; margin: 0; padding: 0; }
.news li { display: grid; grid-template-columns: 84px 1fr; gap: 12px; padding: 6px 0; }
.news-date { font-family: var(--font-mono); font-size: 13px; color: var(--text-faint); padding-top: 2px; }

/* projects */
.projects { display: grid; gap: 14px; }
.project {
  background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px 22px; box-shadow: var(--shadow);
}
.project-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.project-head h3 { font-size: 18px; font-weight: 600; }
.tag {
  font-family: var(--font-mono); font-size: 12px; color: var(--accent-strong);
  background: var(--accent-soft); padding: 2px 8px; border-radius: 4px; white-space: nowrap;
}
.project-problem { font-weight: 500; margin-bottom: 6px; }
.project-desc { color: var(--text-muted); font-size: 15px; }
.links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.links a {
  font-size: 13px; font-weight: 500; padding: 4px 10px; border-radius: 6px;
  border: 1px solid var(--border); color: var(--text);
}
.links a:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }

/* publications */
.year {
  font-family: var(--font-mono); font-size: 13px; font-weight: 500; color: var(--text-faint);
  margin: 18px 0 8px; padding-bottom: 4px; border-bottom: 1px solid var(--border);
}
.pubs { list-style: none; margin: 0; padding: 0; }
.pub { padding: 10px 0; }
.pub-title { font-weight: 600; margin-bottom: 2px; }
.pub-authors { font-size: 14.5px; color: var(--text-muted); margin-bottom: 4px; }
.pub-meta { font-size: 13.5px; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.venue { font-family: var(--font-mono); font-size: 12.5px; color: var(--accent-strong); }
.venue-muted { color: var(--text-faint); }
.pub-note { color: var(--text-faint); font-style: italic; }
.footnote { font-size: 13px; color: var(--text-faint); margin-top: 14px; }

/* rows (teaching, students) */
.rows { list-style: none; margin: 0; padding: 0; }
.rows li {
  display: grid; grid-template-columns: 84px 1fr; gap: 4px 12px;
  padding: 9px 0; border-bottom: 1px solid var(--border);
}
.rows li:last-child { border-bottom: none; }
.rows-compact li { padding: 6px 0; }
.row-date { font-family: var(--font-mono); font-size: 13px; color: var(--text-faint); padding-top: 2px; grid-row: span 2; }
.row-title { font-weight: 500; }
.row-sub { grid-column: 2; font-size: 14px; color: var(--text-muted); }
.sub { font-size: 15px; font-weight: 600; margin: 26px 0 6px; }

/* callout */
.callout {
  border-left: 3px solid var(--accent); background: var(--accent-soft);
  border-radius: 0 var(--radius) var(--radius) 0; padding: 12px 16px; margin-bottom: 4px;
}
.callout h3 { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.callout p { color: var(--text); font-size: 14px; line-height: 1.5; }
.btn {
  display: inline-block; margin-top: 8px; padding: 5px 12px; border-radius: 6px;
  background: var(--accent); color: #fff; font-size: 13px; font-weight: 500;
}
.btn:hover { background: var(--accent-strong); color: #fff; text-decoration: none; }

.placeholder { color: var(--text-faint); font-style: italic; }

/* footer */
.site-footer { border-top: 1px solid var(--border); }
.footer-inner {
  max-width: var(--max-width); margin: 0 auto; padding: 20px;
  display: flex; flex-wrap: wrap; gap: 8px 24px;
  font-size: 13px; color: var(--text-faint);
}

/* ---------- responsive ---------- */
@media (max-width: 920px) {
  .page { grid-template-columns: 1fr; }
  .side {
    position: static; padding: 32px 0 0;
    display: grid; grid-template-columns: 96px 1fr; column-gap: 20px; align-items: start;
  }
  .side-photo { width: 96px; height: 96px; grid-row: span 4; margin-bottom: 0; }
  .side-initials { font-size: 28px; }
  .side-affil { margin-bottom: 10px; }
  .side-links { flex-direction: row; flex-wrap: wrap; gap: 6px 16px; grid-column: 2; }
  .content > .block:first-child { padding-top: 24px; }
}
@media (max-width: 640px) {
  .side { grid-template-columns: 72px 1fr; column-gap: 16px; }
  .side-photo { width: 72px; height: 72px; }
  .side-initials { font-size: 22px; }
  .side-name { font-size: 18px; }
  .side-links { grid-column: 1 / -1; margin-top: 4px; }
  .nav-toggle { display: inline-flex; }
  .nav-links {
    display: none; position: absolute; left: 0; right: 0; top: var(--nav-h);
    flex-direction: column; gap: 0; background: var(--bg); border-bottom: 1px solid var(--border);
    padding: 8px 20px 12px;
  }
  .nav-links.open { display: flex; }
  .nav-links li a { display: block; padding: 8px 0; }
  .news li, .rows li { grid-template-columns: 1fr; gap: 0; }
  .row-date, .news-date { grid-row: auto; }
  .row-sub { grid-column: 1; }
  .project { padding: 16px; }
}

/* ---------- research directions ---------- */
.directions { list-style: none; margin: 0; padding: 0; counter-reset: dir; }
.direction {
  position: relative; padding: 18px 0 18px 44px; border-top: 1px solid var(--border);
  counter-increment: dir;
}
.direction:last-child { border-bottom: 1px solid var(--border); }
.direction::before {
  content: counter(dir, decimal-leading-zero);
  position: absolute; left: 0; top: 21px;
  font-family: var(--font-mono); font-size: 13px; color: var(--accent);
}
.direction h3 { font-size: 17px; font-weight: 600; margin-bottom: 6px; }
.direction p { color: var(--text-muted); font-size: 15px; margin-bottom: 8px; }
.direction-papers { display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: baseline; font-size: 14px; }
.direction-papers a, .direction-papers .pp-text { color: var(--text); font-weight: 500; }
.direction-papers a:hover { color: var(--accent); }
.direction-papers .v { font-family: var(--font-mono); font-size: 12px; color: var(--text-faint); margin-right: 10px; white-space: nowrap; }
.muted { color: var(--text-faint); }

/* direction tag on publications and theses */
.dir {
  display: inline-block; font-family: var(--font-mono); font-size: 11.5px; line-height: 1.5;
  color: var(--text-faint); border: 1px solid var(--border); border-radius: 4px; padding: 0 6px;
  vertical-align: middle;
}
.row-sub .dir { margin-left: 6px; }

/* chips are links now */
.chips li { padding: 0; }
.chips a { display: inline-block; padding: 3px 10px; color: var(--accent-strong); }
.chips a:hover { background: var(--accent); color: #fff; border-radius: 999px; text-decoration: none; }

@media (max-width: 640px) {
  .direction { padding-left: 32px; }
}
.direction-papers .pp { display: inline-block; }
.row-title a { color: var(--text); }
.row-title a:hover { color: var(--accent); }
.row-sub a { color: var(--text-muted); }
.row-sub a:hover { color: var(--accent); }

/* collapsible completed theses */
.fold summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px; }
.fold summary::-webkit-details-marker { display: none; }
.fold summary::before {
  content: ''; width: 6px; height: 6px; border-right: 1.5px solid var(--text-faint); border-bottom: 1.5px solid var(--text-faint);
  transform: rotate(-45deg); transition: transform 0.15s; margin-left: 2px;
}
.fold[open] summary::before { transform: rotate(45deg); }
.fold-count { font-family: var(--font-mono); font-size: 12px; font-weight: 400; color: var(--text-faint); }
.fold summary:hover { color: var(--accent); }
