:root {
  --bg: #fbfaf7;
  --surface: #ffffff;
  --text: #1d2125;
  --muted: #5b6470;
  --border: #e4e1da;
  --accent: #0b6e8a;
  --accent-soft: #e3f1f5;
  --code-bg: #f3f1ec;
  --serif: "Source Serif 4", Georgia, serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14171a;
    --surface: #1b1f23;
    --text: #e7e9ec;
    --muted: #9aa3ad;
    --border: #2c3238;
    --accent: #5cc3df;
    --accent-soft: #17323b;
    --code-bg: #1f2428;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #14171a;
  --surface: #1b1f23;
  --text: #e7e9ec;
  --muted: #9aa3ad;
  --border: #2c3238;
  --accent: #5cc3df;
  --accent-soft: #17323b;
  --code-bg: #1f2428;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 4.5rem; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.65 var(--sans);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
a:focus-visible, button:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}

.skip {
  position: absolute;
  left: -999px;
  top: 0.5rem;
  background: var(--surface);
  padding: 0.5rem 1rem;
  z-index: 20;
}
.skip:focus { left: 1rem; }

/* Top bar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.6rem max(16px, calc((100vw - 1080px) / 2));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.nav {
  display: flex;
  gap: 1.25rem;
  overflow-x: auto;
  scrollbar-width: none;
  font-size: 0.9rem;
  font-weight: 500;
}
.nav::-webkit-scrollbar { display: none; }
.nav a { color: var(--muted); white-space: nowrap; padding: 0.25rem 0; }
.nav a:hover, .nav a.active { color: var(--text); text-decoration: none; }
.nav a.active { box-shadow: inset 0 -2px 0 var(--accent); }

.theme-toggle {
  flex: none;
  display: grid;
  place-items: center;
  width: 2.1rem;
  height: 2.1rem;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.theme-toggle svg { width: 1.05rem; height: 1.05rem; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.icon-moon { display: none; }
:root[data-theme="dark"] .icon-sun { display: none; }
:root[data-theme="dark"] .icon-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-sun { display: none; }
  :root:not([data-theme="light"]) .icon-moon { display: block; }
}

/* Layout */
.layout {
  max-width: 1080px;
  margin: 0 auto;
  padding: 2.5rem 16px 3rem;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 3.5rem;
}

.profile {
  position: sticky;
  top: 5rem;
  align-self: start;
}
.avatar {
  width: 168px;
  height: 168px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--border);
}
.name {
  margin: 1.25rem 0 0.25rem;
  font: 700 1.6rem/1.2 var(--serif);
}
.role { margin: 0; font-weight: 600; }
.affil { margin: 0.25rem 0 1.25rem; color: var(--muted); font-size: 0.95rem; }
.links { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.45rem; font-size: 0.93rem; }
.links a { display: inline-flex; align-items: center; gap: 0.55rem; color: var(--text); }
.links a:hover { color: var(--accent); }
.links svg { width: 1.1rem; height: 1.1rem; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; color: var(--muted); }

/* Sections */
section { margin-bottom: 3.25rem; }
h2 {
  margin: 0 0 1.1rem;
  padding-bottom: 0.4rem;
  font: 700 1.55rem/1.25 var(--serif);
  border-bottom: 1px solid var(--border);
}
h3 { margin: 1.6rem 0 0.7rem; font-size: 1rem; font-weight: 600; }
h4 { margin: 0; font-size: 1rem; font-weight: 600; line-height: 1.4; }
p { margin: 0 0 0.9rem; }
.muted { color: var(--muted); font-size: 0.93rem; }

.tags { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 0.5rem; }
.tags li {
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.87rem;
  font-weight: 500;
}

/* News */
.news { list-style: none; margin: 0; padding: 0; }
.news li {
  display: grid;
  grid-template-columns: 5.5rem 1fr;
  gap: 1rem;
  padding: 0.55rem 0;
  border-bottom: 1px dashed var(--border);
}
.news li:last-child { border-bottom: 0; }
.news time { color: var(--muted); font-size: 0.88rem; font-variant-numeric: tabular-nums; padding-top: 0.1rem; }

/* Publications */
h3.year { color: var(--muted); font-size: 0.9rem; letter-spacing: 0.06em; }
.pub {
  display: grid;
  grid-template-columns: 6.5rem 1fr;
  gap: 1rem;
  padding: 1.1rem 0;
  border-bottom: 1px solid var(--border);
}
.pub:last-of-type { border-bottom: 0; }
.venue {
  align-self: start;
  justify-self: start;
  padding: 0.2rem 0.55rem;
  border: 1px solid var(--accent);
  border-radius: 4px;
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}
.pub h4 { font-size: 1.05rem; margin-bottom: 0.3rem; }
.authors { margin: 0 0 0.15rem; font-size: 0.93rem; }
.authors b { font-weight: 600; text-decoration: underline; text-decoration-color: var(--accent); text-underline-offset: 3px; }
.where { margin: 0 0 0.5rem; color: var(--muted); font-size: 0.88rem; font-style: italic; }
.summary { font-size: 0.93rem; margin-bottom: 0.6rem; }
.pub-links { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: flex-start; font-size: 0.85rem; }
.pub-links > a, .pub-links summary {
  display: inline-block;
  padding: 0.15rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  background: var(--surface);
  cursor: pointer;
  list-style: none;
}
.pub-links > a.presented { background: var(--accent-soft); border-color: transparent; color: var(--accent); font-weight: 500; }
.pub-links summary::-webkit-details-marker { display: none; }
.pub-links > a:hover, .pub-links summary:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.pub-links details { flex-basis: 100%; }
.pub-links details:not([open]) { flex-basis: auto; }
.pub-links pre {
  position: relative;
  margin: 0.5rem 0 0;
  padding: 0.9rem 1rem;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow-x: auto;
  font-size: 0.78rem;
  line-height: 1.5;
}
.copy-btn {
  position: absolute;
  top: 0.4rem;
  right: 0.4rem;
  padding: 0.1rem 0.5rem;
  font: 500 0.75rem var(--sans);
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
}
code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 0.9em; }

/* Projects */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem; }
.card {
  display: block;
  padding: 1.1rem 1.2rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  transition: border-color 0.15s, transform 0.15s;
}
.card:hover { border-color: var(--accent); text-decoration: none; transform: translateY(-2px); }
.card h4 { color: var(--accent); margin-bottom: 0.35rem; }
.card p { margin: 0; font-size: 0.92rem; color: var(--muted); }

/* Timeline */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li {
  display: grid;
  grid-template-columns: 9rem 1fr;
  gap: 1rem;
  padding: 0.75rem 0;
}
.timeline .when { color: var(--muted); font-size: 0.88rem; padding-top: 0.1rem; font-variant-numeric: tabular-nums; }
.timeline p { margin: 0.1rem 0 0; }

address { font-style: normal; }

.footer {
  max-width: 1080px;
  margin: 0 auto;
  padding: 1.5rem 16px 2.5rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.85rem;
}
.footer p { margin: 0; }

/* Responsive */
@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; gap: 2rem; padding-top: 1.75rem; }
  .profile { position: static; text-align: center; }
  .avatar { width: 128px; height: 128px; margin: 0 auto; display: block; }
  .links { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.6rem 1.1rem; }
}

@media (max-width: 560px) {
  .pub, .news li, .timeline li { grid-template-columns: 1fr; gap: 0.35rem; }
  .links { font-size: 0.88rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .card { transition: none; }
}

@media print {
  .topbar, .theme-toggle, .pub-links { display: none; }
  .layout { display: block; }
  .profile { position: static; }
}
