/* ---- Theme tokens ---- */
:root {
  --bg: #ffffff;
  --bg-soft: #f5f6f8;
  --surface: #ffffff;
  --border: #e3e6ea;
  --text: #1a1c1f;
  --text-soft: #5a6068;
  --accent: #2563eb;
  --accent-soft: rgba(37, 99, 235, 0.12);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 8px 24px rgba(0, 0, 0, 0.04);
  --radius: 12px;
  --maxw: 820px;
}

[data-theme="dark"] {
  --bg: #0b0e13;
  --bg-soft: #1c232e;
  --surface: #161d27;
  --border: #38424f;
  --text: #f2f5f8;
  --text-soft: #b9c2cf;
  --accent: #7fb4ff;
  --accent-soft: rgba(127, 180, 255, 0.20);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.6), 0 10px 28px rgba(0, 0, 0, 0.5);
}

/* ---- Base ---- */
* { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  transition: background 0.25s ease, color 0.25s ease;
}

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

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

h1 { font-size: 2rem; margin: 0 0 4px; letter-spacing: -0.02em; }
h2 {
  font-size: 1.35rem;
  margin: 0 0 18px;
  letter-spacing: -0.01em;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}

section { padding: 40px 0; }

/* ---- Top bar ---- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.nav { display: flex; align-items: center; justify-content: space-between; height: 60px; }
.brand { font-weight: 700; color: var(--text); font-size: 1.05rem; }
.brand:hover { text-decoration: none; }
.nav-links { display: flex; align-items: center; gap: 20px; }
.nav-links a { color: var(--text-soft); font-size: 0.95rem; font-weight: 500; }
.nav-links a:hover { color: var(--accent); text-decoration: none; }

.theme-toggle {
  width: 36px; height: 36px;
  padding: 0;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-soft);
  border-radius: 50%;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: border-color 0.2s, color 0.2s, transform 0.2s;
}
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); transform: scale(1.05); }
.theme-toggle svg { width: 18px; height: 18px; display: block; }
/* moon shown in light mode (click -> dark); sun shown in dark mode (click -> light) */
.theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: block; }

/* ---- About ---- */
.about { display: flex; gap: 28px; align-items: center; flex-wrap: wrap; padding-top: 48px; }
.avatar {
  width: 150px; height: 150px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--border);
  background: var(--bg-soft);
  flex-shrink: 0;
}
.about-text { flex: 1; min-width: 260px; }
.title { color: var(--text-soft); font-size: 1.05rem; margin: 0 0 14px; font-weight: 500; }
.bio { margin: 0 0 18px; }
.bio code { background: var(--bg-soft); padding: 1px 5px; border-radius: 5px; font-size: 0.85em; }

.stats { list-style: none; display: flex; flex-wrap: wrap; gap: 8px 22px; margin: 0 0 18px; padding: 0; }
.stats li { color: var(--text-soft); font-size: 0.9rem; }
.stats strong { color: var(--text); font-size: 1.05rem; }

.links { display: flex; flex-wrap: wrap; gap: 10px; }
.link-btn {
  display: inline-block;
  padding: 7px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 500;
  transition: border-color 0.2s, background 0.2s, transform 0.15s;
}
.link-btn:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; transform: translateY(-1px); }

/* ---- News ---- */
.news-list { list-style: none; margin: 0; padding: 0; }
.news-list li { display: flex; gap: 14px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.news-list li:last-child { border-bottom: none; }
.news-date {
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  font-weight: 600;
  font-size: 0.9rem;
  min-width: 72px;
}
.news-text { color: var(--text); }
.news-link {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 1px 7px;
  border-radius: 5px;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid transparent;
  vertical-align: middle;
  white-space: nowrap;
}
.news-link:hover { border-color: var(--accent); text-decoration: none; }
.news-toggle {
  display: inline-block;
  margin-top: 14px;
  padding: 6px 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-soft);
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}
.news-toggle:hover { border-color: var(--accent); color: var(--accent); }

/* ---- Publications ---- */
.pub-controls { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.pub-search {
  flex: 1; min-width: 200px;
  padding: 9px 13px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.92rem;
}
.pub-search:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.year-filters { display: flex; flex-wrap: wrap; gap: 6px; }
.year-btn {
  padding: 5px 11px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-soft);
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.year-btn:hover { border-color: var(--accent); color: var(--accent); }
.year-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.pub-list { list-style: none; margin: 0; padding: 0; counter-reset: pub; }
.pub-item {
  display: flex;
  gap: 16px;
  padding: 16px;
  margin-bottom: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: transform 0.18s ease, border-color 0.18s ease;
}
.pub-item:hover { transform: translateY(-2px); border-color: var(--accent); }

/* sentinel + count shown while lazy-loading more publications */
.pub-sentinel { height: 1px; }
.pub-more { text-align: center; color: var(--text-soft); font-size: 0.85rem; padding: 6px 0 2px; }

.pub-badge {
  flex-shrink: 0;
  width: 58px;
  text-align: center;
}
.pub-venue { font-weight: 700; font-size: 0.92rem; color: var(--accent); }
.pub-year { display: block; font-size: 0.8rem; color: var(--text-soft); font-variant-numeric: tabular-nums; }

.pub-body { flex: 1; min-width: 0; }
.pub-title { font-weight: 600; font-size: 1.02rem; margin: 0 0 4px; }
.pub-note {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 2px 8px;
  border-radius: 6px;
  vertical-align: middle;
}
.pub-authors { color: var(--text-soft); font-size: 0.9rem; margin: 0 0 8px; }
.pub-authors .me { color: var(--text); font-weight: 600; }

.pub-links { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 3px; }
.chip {
  font-size: 0.78rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid transparent;
}
.chip:hover { text-decoration: none; border-color: var(--accent); }
.chip-bib { font: inherit; font-size: 0.78rem; font-weight: 600; line-height: 1.45; cursor: pointer; }
.chip.copied { background: var(--accent); color: #fff; border-color: var(--accent); }

.loading { color: var(--text-soft); font-style: italic; padding: 10px 0; }
.error { color: #e5484d; }
.empty { color: var(--text-soft); font-style: italic; }

/* ---- Footer ---- */
.footer { padding: 30px 20px 50px; color: var(--text-soft); font-size: 0.85rem; text-align: center; border-top: 1px solid var(--border); margin-top: 20px; }

/* ---- Responsive ---- */
@media (max-width: 600px) {
  .about { flex-direction: column; text-align: center; }
  .avatar { width: 200px; height: 200px; }
  .links { justify-content: center; }
  .stats { flex-direction: column; align-items: center; gap: 4px; }
  .nav-links { gap: 12px; }
  .nav-links a { font-size: 0.88rem; }
  .pub-item { flex-direction: column; gap: 8px; }
  .pub-badge { width: auto; text-align: left; }
  .pub-year { display: inline; margin-left: 8px; }
}
