:root {
  --bg: #fcfcfd;
  --bg-elev: #ffffff;
  --fg: #141418;
  --fg-rgb: 20, 20, 24;
  --fg-2: #3d3d46;
  --muted: #6c6c77;
  --line: rgba(20, 20, 30, 0.09);
  --line-strong: rgba(20, 20, 30, 0.16);
  --chip: rgba(20, 20, 30, 0.05);
  --accent: #2a53c4;
  --accent-rgb: 42, 83, 196;
  --accent-soft: rgba(42, 83, 196, 0.07);
  --nav-bg: rgba(252, 252, 253, 0.74);
  --sun: none;
  --moon: block;
  --maxw: 1080px;
  --gutter: 24px;
  --nav-h: 56px;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0b0d;
    --bg-elev: #121215;
    --fg: #ececef;
    --fg-rgb: 236, 236, 239;
    --fg-2: #c3c3cb;
    --muted: #8e8e99;
    --line: rgba(255, 255, 255, 0.08);
    --line-strong: rgba(255, 255, 255, 0.16);
    --chip: rgba(255, 255, 255, 0.06);
    --accent: #91abff;
    --accent-rgb: 145, 171, 255;
    --accent-soft: rgba(145, 171, 255, 0.08);
    --nav-bg: rgba(11, 11, 13, 0.72);
    --sun: block;
    --moon: none;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0b0b0d;
  --bg-elev: #121215;
  --fg: #ececef;
  --fg-rgb: 236, 236, 239;
  --fg-2: #c3c3cb;
  --muted: #8e8e99;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.16);
  --chip: rgba(255, 255, 255, 0.06);
  --accent: #91abff;
  --accent-rgb: 145, 171, 255;
  --accent-soft: rgba(145, 171, 255, 0.08);
  --nav-bg: rgba(11, 11, 13, 0.72);
  --sun: block;
  --moon: none;
  color-scheme: dark;
}

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  transition: background-color 0.3s, color 0.3s;
}

a {
  color: inherit;
  text-decoration: none;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

::selection {
  background: rgba(var(--accent-rgb), 0.22);
}

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

/* Navigation */

.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 1px solid transparent;
  transition: background-color 0.3s, border-color 0.3s;
}

.nav.is-scrolled {
  background: var(--nav-bg);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  backdrop-filter: saturate(180%) blur(16px);
  border-bottom-color: var(--line);
}

.nav-inner {
  display: flex;
  align-items: center;
  gap: 16px;
  height: var(--nav-h);
}

.nav-name {
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
  opacity: 0;
  transform: translateY(4px);
  pointer-events: none;
  transition: opacity 0.3s var(--ease), transform 0.3s var(--ease);
}

.nav.show-name .nav-name {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

.nav-links {
  position: relative;
  display: flex;
  gap: 2px;
  margin-left: auto;
}

.nav-links a {
  position: relative;
  z-index: 1;
  padding: 5px 11px;
  font-size: 14px;
  color: var(--muted);
  white-space: nowrap;
  border-radius: 7px;
  transition: color 0.2s;
}

.nav-links a:hover,
.nav-links a.is-active {
  color: var(--fg);
}

.nav-indicator {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 0;
  border-radius: 7px;
  background: var(--chip);
  opacity: 0;
  transition: transform 0.4s var(--ease), width 0.4s var(--ease), opacity 0.3s;
}

.theme-toggle {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: none;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.2s, background-color 0.2s;
}

.theme-toggle:hover {
  color: var(--fg);
  background: var(--chip);
}

.theme-toggle svg {
  width: 17px;
  height: 17px;
}

.icon-sun {
  display: var(--sun);
}

.icon-moon {
  display: var(--moon);
}

/* Hero */

.hero {
  position: relative;
  overflow: hidden;
  margin-top: calc(-1 * var(--nav-h));
  padding: calc(var(--nav-h) + clamp(40px, 8vh, 88px)) 0 clamp(40px, 7vh, 72px);
}

.hero-inner {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 560px);
  justify-content: start;
  gap: 32px;
  align-items: start;
}

.avatar {
  display: block;
  width: 116px;
  height: 116px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 0 0 1px var(--line), 0 10px 30px -14px rgba(0, 0, 0, 0.35);
}

.hero h1 {
  margin: 0;
  font-size: clamp(2.25rem, 4.4vw, 3.25rem);
  font-weight: 650;
  line-height: 1.05;
  letter-spacing: -0.035em;
}

.tagline {
  margin: 0.55rem 0 0;
  font-size: clamp(1.02rem, 1.5vw, 1.15rem);
  color: var(--muted);
  letter-spacing: -0.01em;
}

.email {
  margin: 0.2rem 0 0;
  font-size: 15px;
  color: var(--muted);
}

.bio {
  margin: 1.1rem 0 0;
  color: var(--fg-2);
}

.bio strong {
  color: var(--fg);
  font-weight: 600;
}

.inline-link {
  color: var(--fg);
  border-bottom: 1px solid var(--line-strong);
  transition: color 0.2s, border-color 0.2s;
}

.inline-link:hover {
  color: var(--accent);
  border-color: currentColor;
}

.links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 1.4rem 0 0;
  padding: 0;
  list-style: none;
}

.links a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 0 13px;
  font-size: 14px;
  color: var(--fg-2);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--bg);
  transition: color 0.2s, border-color 0.2s, transform 0.25s var(--ease);
}

.links a:hover {
  color: var(--fg);
  border-color: var(--fg);
  transform: translateY(-1px);
}

.links svg {
  width: 15px;
  height: 15px;
  flex: none;
}

/* Sections */

.section {
  padding: clamp(32px, 5.5vh, 52px) 0;
  border-top: 1px solid var(--line);
  scroll-margin-top: calc(var(--nav-h) - 1px);
}

.section > .container {
  display: grid;
  grid-template-columns: 124px minmax(0, 1fr);
  gap: 24px;
}

.section-title {
  position: sticky;
  top: calc(var(--nav-h) + 20px);
  align-self: start;
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.6;
  letter-spacing: -0.005em;
}

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

.row {
  display: grid;
  grid-template-columns: 156px minmax(0, 1fr);
  gap: 20px;
}

.row-meta {
  font-size: 14px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  padding-top: 1px;
}

.row p {
  margin: 0;
}

.news .row {
  padding: 5px 0;
  color: var(--fg-2);
}

.news a,
.row-sub a {
  color: var(--fg);
  border-bottom: 1px solid var(--line-strong);
  transition: color 0.2s, border-color 0.2s;
}

.news a:hover,
.row-sub a:hover {
  color: var(--accent);
  border-color: currentColor;
}

/* Hover spotlight */

.spot {
  position: relative;
  isolation: isolate;
  margin: 0 -14px;
  padding-left: 14px;
  padding-right: 14px;
  border-radius: 12px;
}

.spot::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  z-index: -1;
  background: linear-gradient(110deg, rgba(var(--accent-rgb), 0.08), rgba(var(--accent-rgb), 0.025) 75%);
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}

.spot:hover::before {
  opacity: 1;
}

/* Publications */

.pub {
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 28px;
  padding-top: 16px;
  padding-bottom: 16px;
}

.pub-fig {
  position: relative;
  display: block;
  align-self: center;
  width: 100%;
  padding: 10px;
  overflow: hidden;
  border: 0;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 8px 24px -6px rgba(0, 0, 0, 0.16);
  transition: box-shadow 0.3s, transform 0.3s var(--ease);
}

.pub-fig img {
  display: block;
  width: 100%;
  height: auto;
  transition: transform 0.5s var(--ease);
}

.pub-fig:has(img[src$="apertus.png"]) {
  padding: 24px 0;
}

.pub-fig img[src$="apertus.png"] {
  width: 60%;
  margin: 0 auto;
}

button.pub-fig {
  font: inherit;
  cursor: zoom-in;
}

button.pub-fig:hover {
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08), 0 14px 34px -8px rgba(0, 0, 0, 0.24);
  transform: translateY(-1px);
}

button.pub-fig:hover img {
  transform: scale(1.02);
}

.chips-venue {
  display: flex;
  align-items: center;
  margin-right: 6px;
  padding-right: 12px;
  border-right: 1px solid var(--line-strong);
}

.chips .venue {
  display: inline-flex;
  align-items: center;
  height: 24px;
  margin: 0;
  padding: 0 9px;
  font-weight: 600;
  border: 1px solid var(--line-strong);
  background: transparent;
}

.chips .venue.is-accepted {
  border-color: rgba(var(--accent-rgb), 0.4);
  background: var(--accent-soft);
}

.venue {
  justify-self: start;
  align-self: start;
  display: inline-block;
  padding: 1px 8px;
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1.6;
  white-space: nowrap;
  border-radius: 6px;
  color: var(--muted);
  background: var(--chip);
  margin-top: 1px;
}

.venue.is-accepted {
  color: var(--accent);
  background: var(--accent-soft);
}

.pub-title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.45;
  letter-spacing: -0.01em;
}

.pub-title a {
  transition: color 0.2s;
}

.pub-title a:hover {
  color: var(--accent);
}

.pub-authors {
  margin: 4px 0 0;
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--muted);
}

.pub-authors strong {
  color: var(--fg);
  font-weight: 600;
}

.pub-note {
  margin: 2px 0 0;
  font-size: 14px;
  color: var(--muted);
  font-style: italic;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
}

.chips li {
  display: flex;
}

.chips a {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 9px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--fg-2);
  border-radius: 6px;
  background: var(--chip);
  transition: color 0.2s, background-color 0.2s;
}

.chips a:hover {
  color: var(--bg);
  background: var(--fg);
}

.footnote {
  margin: 12px 0 0;
  font-size: 13px;
  color: var(--muted);
}

/* Figure lightbox */

.lightbox {
  width: min(1200px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  padding: 0;
  border: 0;
  border-radius: 16px;
  color: var(--fg);
  background: var(--bg-elev);
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.5);
}

.lightbox[open] {
  animation: lightbox-in 0.35s var(--ease);
}

.lightbox::backdrop {
  background: rgba(10, 10, 12, 0.55);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

.lightbox[open]::backdrop {
  animation: backdrop-in 0.35s ease;
}

.lightbox figure {
  margin: 0;
  padding: 20px;
}

.lightbox img {
  display: block;
  width: 100%;
  height: auto;
  max-height: calc(100vh - 72px);
  object-fit: contain;
  padding: 16px;
  border-radius: 10px;
  background: #fff;
}

.lightbox-close {
  position: absolute;
  top: 26px;
  right: 26px;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #3d3d46;
  background: rgba(255, 255, 255, 0.9);
  cursor: pointer;
}

.lightbox-close svg {
  width: 16px;
  height: 16px;
}

@keyframes lightbox-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
}

@keyframes backdrop-in {
  from {
    opacity: 0;
  }
}

/* Experience and education */

.xp {
  padding-top: 10px;
  padding-bottom: 10px;
}

.row-head {
  margin: 0;
  font-size: 15.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.row-head span {
  font-weight: 400;
  color: var(--fg-2);
}

.row-sub {
  margin: 2px 0 0;
  font-size: 14.5px;
  color: var(--muted);
}

/* Projects */

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}

.card {
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 16px 16px 14px;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  transition: border-color 0.25s, transform 0.3s var(--ease);
}

.card:hover {
  border-color: var(--line-strong);
  transform: translateY(-2px);
}

.card h3 {
  margin: 0;
  font-size: 15.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.card p {
  margin: 4px 0 0;
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--muted);
}

.card .chips {
  margin-top: auto;
  padding-top: 12px;
}

/* Footer */

.footer {
  padding: 28px 0 40px;
  border-top: 1px solid var(--line);
  font-size: 13px;
  color: var(--muted);
}

/* Scroll reveal */

.js [data-reveal] {
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.7s var(--ease), transform 0.7s var(--ease);
  transition-delay: var(--d, 0ms);
}

.js [data-reveal].is-in {
  opacity: 1;
  transform: none;
}

.js .hero [data-reveal] {
  transition-duration: 0.9s;
}

/* Responsive */

@media (max-width: 960px) {
  .section > .container {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }

  .pub {
    grid-template-columns: 280px minmax(0, 1fr);
    gap: 24px;
  }

  .section-title {
    position: static;
  }
}

@media (max-width: 720px) {
  :root {
    --gutter: 16px;
  }

  .nav-name {
    display: none;
  }

  .nav-links {
    flex: 1;
    min-width: 0;
    margin-left: -8px;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .nav-links::-webkit-scrollbar {
    display: none;
  }

  .nav-links a {
    padding: 5px 8px;
    font-size: 13.5px;
  }

  .hero-inner {
    grid-template-columns: minmax(0, 1fr);
    gap: 20px;
  }

  .avatar {
    width: 84px;
    height: 84px;
  }

  .row {
    grid-template-columns: minmax(0, 1fr);
    gap: 4px;
  }

  .news .row {
    gap: 0;
    padding: 6px 0;
  }

  .rows .spot {
    margin: 0;
    padding-left: 0;
    padding-right: 0;
  }

  .pub {
    gap: 12px;
  }

  .pub-fig {
    order: 2;
    padding: 8px;
  }

  .pub-fig:has(img[src$="apertus.png"]) {
    padding: 16px 0;
  }

  .pub-fig img[src$="apertus.png"] {
    width: 40%;
  }

  .rows .spot::before {
    display: none;
  }

}

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

  .js [data-reveal] {
    opacity: 1;
    transform: none;
    transition: none;
  }

  .nav-indicator,
  .links a,
  .card {
    transition: none;
  }
}
