/* ---------- Theme ---------- */
:root {
  --bg: #ffffff;
  --surface: #f6f7f9;
  --text: #1d2129;
  --muted: #5f6670;
  --border: #e4e6ea;
  --accent: #1f5fae;
  --accent-soft: #e9f0fa;
  --logo-invert: 0;
}

:root[data-theme="dark"] {
  --bg: #121418;
  --surface: #1a1d23;
  --text: #e4e6ea;
  --muted: #9aa1ab;
  --border: #2a2e36;
  --accent: #7eb0ff;
  --accent-soft: #1b2940;
  --logo-invert: 1;
}

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

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.2s ease, color 0.2s ease;
}

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

h1, h2, h3 {
  font-family: "Source Serif 4", Georgia, serif;
  font-weight: 600;
  line-height: 1.25;
}

.container {
  max-width: 800px;
  margin: 0 auto;
  padding: 40px 20px 24px;
}

/* ---------- Navbar ---------- */
.navbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.nav-inner {
  max-width: 800px;
  margin: 0 auto;
  padding: 0 20px;
  min-height: 56px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 16px;
}

.brand {
  color: var(--text);
  font-size: 1.05rem;
  font-weight: 300;
}
.brand b { font-weight: 600; }
.brand:hover { text-decoration: none; color: var(--accent); }

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

.nav-links a {
  color: var(--text);
  font-size: 0.95rem;
}
.nav-links a:hover { color: var(--accent); text-decoration: none; }
.nav-links a.active { color: var(--accent); font-weight: 600; }

.theme-toggle {
  background: none;
  border: none;
  padding: 4px;
  color: var(--text);
  font-size: 1rem;
  cursor: pointer;
}
.theme-toggle:hover { color: var(--accent); }

/* ---------- Page header ---------- */
.page-title {
  font-size: 2.6rem;
  font-weight: 300;
  margin: 8px 0 4px;
}
.page-title b { font-weight: 600; }

.page-subtitle {
  margin: 0 0 24px;
  color: var(--muted);
  font-size: 1.05rem;
}

/* ---------- About ---------- */
.profile-photo {
  float: right;
  width: 190px;
  margin: 0 0 16px 28px;
  border-radius: 8px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.12);
}

.interests {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 20px 0;
}

.chip {
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.85rem;
  font-weight: 500;
  padding: 3px 12px;
  border-radius: 999px;
}

.social {
  display: flex;
  gap: 20px;
  font-size: 1.45rem;
  margin: 20px 0 8px;
}
.social a { color: var(--muted); transition: color 0.15s ease; }
.social a:hover { color: var(--accent); text-decoration: none; }

/* ---------- Sections ---------- */
section { clear: both; margin-top: 44px; }

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
  margin-bottom: 18px;
}

.section-head h2 { font-size: 1.5rem; margin: 0; }

.section-meta { color: var(--muted); font-size: 0.85rem; }

/* ---------- Affiliations ---------- */
.affiliations {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.affiliation {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.affiliation:hover { text-decoration: none; border-color: var(--accent); transform: translateY(-1px); }

.affiliation .logo {
  width: 72px;
  height: 40px;
  object-fit: contain;
  flex-shrink: 0;
}
.affiliation .logo.apple { filter: invert(var(--logo-invert)); }

.affiliation .org { font-weight: 600; }
.affiliation .what, .affiliation .when { display: block; color: var(--muted); font-size: 0.88rem; line-height: 1.45; }

/* ---------- News ---------- */
.news { width: 100%; border-collapse: collapse; }
.news td { padding: 7px 0; vertical-align: top; }
.news td.date {
  width: 96px;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.9rem;
  white-space: nowrap;
  padding-top: 8px;
}

/* ---------- Publications ---------- */
.year { font-size: 1.25rem; color: var(--muted); margin: 28px 0 8px; }

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

.pub {
  display: flex;
  gap: 18px;
  padding: 14px 0;
}
.pub + .pub { border-top: 1px dashed var(--border); }

.badge {
  display: inline-block;
  width: 96px;
  text-align: center;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 4px 0;
  border-radius: 4px;
  background: var(--accent);
  color: var(--bg);
  flex-shrink: 0;
  align-self: flex-start;
  margin-top: 3px;
}
.badge.preprint { background: var(--surface); color: var(--muted); border: 1px solid var(--border); }

.pub-title { font-weight: 600; }
.pub-authors { color: var(--muted); font-size: 0.95rem; }
.pub-authors b { color: var(--text); font-weight: 600; }
.pub-venue { font-style: italic; font-size: 0.95rem; }
.pub-tldr { margin: 6px 0 0; font-size: 0.93rem; }

.pub-links { margin-top: 6px; display: flex; gap: 8px; flex-wrap: wrap; }

.btn {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 500;
  padding: 1px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.btn:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }

.more-link { font-size: 0.9rem; }

/* ---------- CV ---------- */
.cv-download {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 16px;
  border-radius: 6px;
  background: var(--accent);
  color: var(--bg);
  font-weight: 500;
  font-size: 0.92rem;
}
.cv-download:hover { text-decoration: none; opacity: 0.9; }

.cv-list { list-style: none; padding: 0; margin: 0; }
.cv-item { display: flex; gap: 20px; padding: 8px 0; }
.cv-item .when {
  width: 140px;
  flex-shrink: 0;
  color: var(--muted);
  font-size: 0.9rem;
  padding-top: 1px;
}
.cv-item .what { flex: 1; }
.cv-item .role { color: var(--muted); font-size: 0.95rem; }
.cv-item .note { font-size: 0.93rem; margin-top: 2px; }

/* ---------- Footer ---------- */
footer {
  clear: both;
  max-width: 800px;
  margin: 56px auto 0;
  padding: 20px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.82rem;
  text-align: center;
}

/* ---------- Mobile ---------- */
@media (max-width: 600px) {
  .container { padding-top: 28px; }
  .page-title { font-size: 2.1rem; }
  .profile-photo { float: none; display: block; width: 160px; margin: 0 0 20px; }
  .nav-links { gap: 16px; }
  .pub { flex-direction: column; gap: 6px; }
  .cv-item { flex-direction: column; gap: 0; }
  .cv-item .when { width: auto; }
  .news td.date { width: 80px; }
}
