/* ---------- Theme ---------- */
:root {
  --bg: #fbfbfa;
  --surface: #ffffff;
  --text: #1f2328;
  --muted: #5f6670;
  --subtle: #8b929b;
  --border: #e6e6e3;
  --accent: #2f5bd3;
  --accent-soft: rgba(47, 91, 211, 0.08);
  --highlight: #c2410c;
  --highlight-soft: rgba(194, 65, 12, 0.08);
  --radius: 12px;
  --maxw: 880px;
  --font: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, "Helvetica Neue",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0f1115;
  --surface: #161920;
  --text: #e6e8eb;
  --muted: #a1a7b0;
  --subtle: #747b85;
  --border: #262a33;
  --accent: #7ea2ff;
  --accent-soft: rgba(126, 162, 255, 0.12);
  --highlight: #fb923c;
  --highlight-soft: rgba(251, 146, 60, 0.12);
  color-scheme: dark;
}

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

html { scroll-behavior: smooth; scroll-padding-top: 72px; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  transition: background-color .2s ease, color .2s ease;
}

/* Soft, slowly drifting pastel backdrop */
body::before {
  content: ""; position: fixed; inset: -25%; z-index: -1; pointer-events: none;
  background:
    radial-gradient(38% 42% at 18% 22%, var(--blob-1), transparent 70%),
    radial-gradient(34% 40% at 82% 18%, var(--blob-2), transparent 70%),
    radial-gradient(40% 44% at 75% 78%, var(--blob-3), transparent 70%),
    radial-gradient(36% 40% at 22% 80%, var(--blob-4), transparent 70%);
  filter: blur(40px) saturate(115%);
  animation: drift 28s ease-in-out infinite alternate;
}
@keyframes drift {
  0%   { transform: translate3d(0, 0, 0) rotate(0deg) scale(1); }
  50%  { transform: translate3d(3%, -2%, 0) rotate(8deg) scale(1.05); }
  100% { transform: translate3d(-3%, 2%, 0) rotate(-6deg) scale(1.02); }
}
:root {
  --blob-1: rgba(134, 239, 200, 0.45);  /* mint */
  --blob-2: rgba(147, 197, 253, 0.45);  /* sky */
  --blob-3: rgba(196, 181, 253, 0.38);  /* lavender */
  --blob-4: rgba(253, 207, 176, 0.40);  /* peach */
}
:root[data-theme="dark"] {
  --blob-1: rgba(16, 185, 129, 0.16);
  --blob-2: rgba(59, 130, 246, 0.18);
  --blob-3: rgba(139, 92, 246, 0.16);
  --blob-4: rgba(236, 72, 153, 0.10);
}

/* ---------- Palettes (default = aurora above) ---------- */
:root[data-palette="ocean"] {
  --blob-1: rgba(125, 211, 252, 0.50);
  --blob-2: rgba(103, 232, 249, 0.40);
  --blob-3: rgba(165, 180, 252, 0.40);
  --blob-4: rgba(94, 234, 212, 0.35);
  --accent: #0369a1; --accent-soft: rgba(3, 105, 161, 0.08);
}
:root[data-theme="dark"][data-palette="ocean"] {
  --blob-1: rgba(14, 165, 233, 0.20);
  --blob-2: rgba(6, 182, 212, 0.16);
  --blob-3: rgba(99, 102, 241, 0.18);
  --blob-4: rgba(20, 184, 166, 0.14);
  --accent: #7dd3fc; --accent-soft: rgba(125, 211, 252, 0.12);
}
:root[data-palette="sunset"] {
  --blob-1: rgba(253, 186, 116, 0.45);
  --blob-2: rgba(251, 113, 133, 0.30);
  --blob-3: rgba(216, 180, 254, 0.38);
  --blob-4: rgba(252, 211, 77, 0.35);
  --accent: #be3a6a; --accent-soft: rgba(190, 58, 106, 0.08);
}
:root[data-theme="dark"][data-palette="sunset"] {
  --blob-1: rgba(249, 115, 22, 0.16);
  --blob-2: rgba(244, 63, 94, 0.16);
  --blob-3: rgba(168, 85, 247, 0.16);
  --blob-4: rgba(234, 179, 8, 0.10);
  --accent: #f9a8d4; --accent-soft: rgba(249, 168, 212, 0.12);
}
:root[data-palette="forest"] {
  --blob-1: rgba(134, 239, 172, 0.45);
  --blob-2: rgba(217, 249, 157, 0.40);
  --blob-3: rgba(94, 234, 212, 0.35);
  --blob-4: rgba(187, 247, 208, 0.45);
  --accent: #047857; --accent-soft: rgba(4, 120, 87, 0.08);
}
:root[data-theme="dark"][data-palette="forest"] {
  --blob-1: rgba(34, 197, 94, 0.16);
  --blob-2: rgba(132, 204, 22, 0.12);
  --blob-3: rgba(20, 184, 166, 0.16);
  --blob-4: rgba(16, 185, 129, 0.12);
  --accent: #6ee7b7; --accent-soft: rgba(110, 231, 183, 0.12);
}
:root[data-palette="plain"] body::before { display: none; }

.toast {
  position: fixed; top: 66px; right: 24px; z-index: 20;
  padding: 6px 12px; border-radius: 8px; font-size: 13px;
  color: var(--text); background: var(--surface); border: 1px solid var(--border);
  box-shadow: 0 6px 20px rgba(0, 0, 0, .08);
  opacity: 0; transform: translateY(-4px); pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}
.toast.show { opacity: 1; transform: none; }

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

strong { font-weight: 650; }

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

/* ---------- Nav ---------- */
.nav {
  position: sticky; top: 0; z-index: 10;
  background: transparent;
  border-bottom: 1px solid transparent;
  transition: border-color .2s ease, background-color .2s ease;
}
.nav.scrolled {
  border-bottom-color: var(--border);
  background: color-mix(in srgb, var(--bg) 60%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.nav-inner {
  display: flex; align-items: center; justify-content: space-between;
  height: 56px;
}
.brand { font-weight: 650; color: var(--text); letter-spacing: -0.01em; }
.brand:hover { text-decoration: none; }
.nav-links { display: flex; align-items: center; gap: 4px; }
.nav-links a {
  color: var(--muted); font-size: 14px; padding: 6px 10px; border-radius: 8px;
}
.nav-links a:hover { color: var(--text); background: var(--accent-soft); text-decoration: none; }
.nav-links a.active { color: var(--text); }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 34px; height: 34px; margin-left: 6px;
  border: 1px solid var(--border); border-radius: 8px;
  background: transparent; color: var(--muted); cursor: pointer;
}
.icon-btn:hover { color: var(--text); border-color: var(--subtle); }
.icon-btn svg { width: 16px; height: 16px; }
.icon-sun { display: none; }
:root[data-theme="dark"] .icon-sun { display: block; }
:root[data-theme="dark"] .icon-moon { display: none; }

/* ---------- Hero ---------- */
.hero {
  display: grid; grid-template-columns: 168px 1fr; gap: 40px; align-items: center;
  padding: 64px 0 40px;
}
.avatar {
  width: 168px; height: 168px; border-radius: 50%;
  object-fit: cover; display: block;
  border: 1px solid var(--border);
  box-shadow: 0 8px 30px rgba(0, 0, 0, .08);
}
.hero h1 {
  margin: 0; font-size: 36px; line-height: 1.2; letter-spacing: -0.025em; font-weight: 700;
}
.hero h1 .cn { color: var(--subtle); font-weight: 500; font-size: 26px; margin-left: 6px; }
.role { margin: 10px 0 0; color: var(--muted); font-size: 17px; }
.role a { color: inherit; border-bottom: 1px solid var(--border); }
.role a:hover { color: var(--accent); text-decoration: none; border-color: var(--accent); }

.socials { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 20px; }
.socials a {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 12px; font-size: 14px;
  color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 999px;
  transition: border-color .15s ease, transform .15s ease;
}
.socials a:hover { text-decoration: none; border-color: var(--accent); transform: translateY(-1px); }
.socials svg { width: 15px; height: 15px; flex: none; }

/* ---------- Sections ---------- */
section { padding: 36px 0; border-top: 1px solid var(--border); }
h2 {
  margin: 0 0 20px; font-size: 13px; font-weight: 650;
  letter-spacing: .12em; text-transform: uppercase; color: var(--subtle);
}
p { margin: 0 0 14px; }
.lead { font-size: 17px; }

.tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.tag {
  font-size: 13px; padding: 4px 10px; border-radius: 6px;
  background: var(--accent-soft); color: var(--accent);
}

/* ---------- Timeline ---------- */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; }
.two-col h3 {
  margin: 0 0 14px; font-size: 15px; font-weight: 650; color: var(--text);
}
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li {
  position: relative; padding: 0 0 18px 20px;
  border-left: 1px solid var(--border);
}
.timeline li:last-child { padding-bottom: 0; }
.timeline li::before {
  content: ""; position: absolute; left: -4.5px; top: 8px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--bg); border: 1.5px solid var(--subtle);
}
.timeline li.now::before { background: var(--accent); border-color: var(--accent); }
.t-org { font-weight: 600; }
.t-role { color: var(--muted); font-size: 14.5px; }
.t-meta { color: var(--subtle); font-size: 13px; font-family: var(--mono); }

/* ---------- Publications ---------- */
.pub-head {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 12px; margin-bottom: 8px;
}
.pub-head h2 { margin: 0; }
.filters {
  display: inline-flex; padding: 3px; gap: 2px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
}
.filters button {
  font: inherit; font-size: 13px; padding: 5px 12px;
  border: 0; border-radius: 7px; cursor: pointer;
  background: transparent; color: var(--muted);
}
.filters button:hover { color: var(--text); }
.filters button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.note { color: var(--subtle); font-size: 13px; margin: 0 0 8px; }

.year-group { display: grid; grid-template-columns: 64px 1fr; gap: 16px; padding-top: 18px; }
.year-group[hidden] { display: none; }
.year {
  font-family: var(--mono); font-size: 14px; color: var(--subtle);
  padding-top: 14px; position: sticky; top: 64px; align-self: start;
}
.pubs { list-style: none; margin: 0; padding: 0; }
.pub {
  padding: 14px 16px; margin: 0 -16px; border-radius: var(--radius);
  transition: background-color .15s ease;
}
.pub:hover { background: var(--surface); box-shadow: 0 0 0 1px var(--border); }
.pub[hidden] { display: none; }
.pub-title { font-weight: 600; line-height: 1.45; }
.pub-authors { color: var(--muted); font-size: 14.5px; margin-top: 3px; }
.pub-authors strong { color: var(--text); }
.pub-meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 8px; font-size: 13px;
}
.venue {
  font-family: var(--mono); font-size: 12px; font-weight: 600;
  padding: 2px 8px; border-radius: 6px;
  color: var(--text); background: var(--bg); border: 1px solid var(--border);
}
.award {
  font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 6px;
  color: var(--highlight); background: var(--highlight-soft);
}
.pub-meta a {
  font-size: 13px; padding: 2px 8px; border-radius: 6px; border: 1px solid var(--border);
  color: var(--muted);
}
.pub-meta a:hover { color: var(--accent); border-color: var(--accent); text-decoration: none; }

.more { display: flex; justify-content: center; padding-top: 20px; position: relative; }
.more[hidden] { display: none; }

.more-btn {
  font: inherit; font-size: 14px; font-weight: 500; cursor: pointer;
  padding: 8px 18px; border-radius: 999px;
  color: var(--text); background: var(--surface); border: 1px solid var(--border);
  transition: border-color .15s ease, color .15s ease;
}
.more-btn:hover { color: var(--accent); border-color: var(--accent); }
.more-btn::after { content: " ↓"; }
.more-btn[aria-expanded="true"]::after { content: " ↑"; }

/* ---------- Awards ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list li {
  display: grid; grid-template-columns: 64px 1fr; gap: 16px;
  padding: 10px 0; border-bottom: 1px dashed var(--border);
}
.list li:last-child { border-bottom: 0; }
.list .t-meta { padding-top: 2px; }

/* ---------- Footer ---------- */
footer {
  border-top: 1px solid var(--border);
  padding: 28px 0 48px; color: var(--subtle); font-size: 13px;
}

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  .nav-links a:not(.keep) { display: none; }
  .hero { grid-template-columns: 1fr; gap: 20px; padding: 40px 0 28px; text-align: left; }
  .avatar { width: 112px; height: 112px; }
  .hero h1 { font-size: 28px; }
  .hero h1 .cn { font-size: 20px; }
  .two-col { grid-template-columns: 1fr; gap: 28px; }
  .year-group { grid-template-columns: 1fr; gap: 0; }
  .year { position: static; padding-top: 0; font-weight: 600; color: var(--text); }
  .pub { margin: 0 -12px; padding: 12px; }
  .list li { grid-template-columns: 52px 1fr; gap: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}
