:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --text: #22272d;
  --muted: #66707a;
  --line: #e6e9ed;
  --accent: #4e2a84;
  --accent-dark: #3f1f70;
  --warm: #6f579c;
  --news: #20895a;
  --alert: #b42318;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --klee: var(--font-note);
  /* Home headings use the more compact Aptos; Blog keeps DM Sans from typography.css.
     Aptos is not licensed for web embedding, so visitors without it get the system sans. */
  --font-heading: Aptos, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --shadow: none;
  --header-height: 60px;
}

* {
  box-sizing: border-box;
}

html {
  font-size: 93.75%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-height) + 24px);
}

body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font: 0.875rem/1.6 var(--font);
}

a {
  color: var(--accent-dark);
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.18em;
}

a:hover {
  color: var(--warm);
}

a:focus-visible,
button:focus-visible {
  outline: 3px solid rgba(78, 42, 132, 0.32);
  outline-offset: 4px;
}

.skip-link {
  position: absolute;
  left: 24px;
  top: 12px;
  z-index: 20;
  transform: translateY(-140%);
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.skip-link:focus {
  transform: translateY(0);
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  height: var(--header-height);
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.nav {
  width: min(1380px, calc(100% - 28px));
  height: 100%;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand {
  color: var(--text);
  font-size: 0.96rem;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

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

.nav-links a {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0 9px;
  border-radius: 4px;
  color: var(--muted);
  font-size: 0.96rem;
  font-weight: 620;
  text-decoration: none;
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--accent-dark);
  background: transparent;
}

.menu-toggle {
  display: none;
  width: 44px;
  height: 44px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.menu-icon,
.menu-icon::before,
.menu-icon::after {
  display: block;
  width: 20px;
  height: 2px;
  background: currentColor;
  border-radius: 999px;
}

.menu-icon {
  position: relative;
}

.menu-icon::before,
.menu-icon::after {
  content: "";
  position: absolute;
  left: 0;
}

.menu-icon::before {
  top: -6px;
}

.menu-icon::after {
  top: 6px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.page-shell {
  width: min(1380px, calc(100% - 28px));
  margin: 0 auto;
  padding: 30px 0 48px;
  display: grid;
  grid-template-columns: minmax(250px, 280px) minmax(0, 1fr);
  gap: 52px;
  align-items: start;
}

.profile {
  position: sticky;
  top: calc(var(--header-height) + 24px);
  padding: 0;
}

.profile-photo {
  display: block;
  width: 78%;
  margin: 0 auto;
  aspect-ratio: 1;
  height: auto;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--line);
}

.profile-copy {
  margin-top: 16px;
}

.profile h1 {
  margin: 0;
  font-size: clamp(1.28rem, 1.36vw, 1.55rem);
  line-height: 1.12;
  letter-spacing: 0;
  white-space: nowrap;
}

.profile h1 span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
}

.profile-role,
.profile-affiliation {
  margin: 8px 0 0;
}

.profile-role {
  font-family: var(--klee);
  font-weight: 650;
}

.profile-affiliation,
.meta {
  color: var(--muted);
}

.profile-affiliation {
  font-family: var(--klee);
  margin-top: 2px;
}

.profile-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 13px;
}

.profile-tags span {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 3px 8px;
  border: 1px solid rgba(78, 42, 132, 0.2);
  border-radius: 999px;
  background: rgba(78, 42, 132, 0.065);
  color: var(--accent-dark);
  font-size: 0.75rem;
  font-weight: 650;
}

.profile-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.profile-links a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--accent-dark);
  text-decoration: none;
}

.profile-links a:hover {
  background: rgba(78, 42, 132, 0.08);
}

.profile-links svg {
  width: 19px;
  height: 19px;
  fill: currentColor;
}

.content {
  position: relative;
  min-width: 0;
}

.content::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: -26px;
  width: 1px;
  background: linear-gradient(
    180deg,
    transparent 0,
    rgba(78, 42, 132, 0.24) 7%,
    var(--line) 36%,
    var(--line) 64%,
    rgba(78, 42, 132, 0.24) 93%,
    transparent 100%
  );
  box-shadow: 0 0 12px rgba(78, 42, 132, 0.1);
}

.section {
  padding: 24px 0;
  border-bottom: 1px solid var(--line);
}

.section:first-child {
  padding-top: 8px;
}

.section:last-child {
  border-bottom: 0;
}

h1, h2, h3, .brand, .nav-links {
  font-family: var(--font-heading);
}

h2 {
  margin: 0 0 12px;
  font: 550 var(--section-title-size)/1.22 var(--font-heading);
  letter-spacing: 0;
}

h3 {
  margin: 0 0 7px;
  font-size: 0.94rem;
  line-height: 1.35;
  letter-spacing: 0;
}

p {
  margin: 0 0 10px;
}

ul {
  margin: 10px 0 0;
  padding-left: 1.15rem;
}

li {
  margin: 5px 0;
}

.intro > p {
  font-size: 0.96rem;
}

.intro a {
  color: var(--accent-dark);
  font-weight: 720;
  text-decoration-color: rgba(78, 42, 132, 0.34);
}

.intro a:hover {
  color: var(--accent);
  text-decoration-color: currentColor;
}

.phd-note {
  color: var(--alert);
  font-weight: 760;
}

.news-panel {
  margin-top: 22px;
  padding: 16px 0 0;
  background: transparent;
  border-top: 1px solid var(--line);
}

.news-list {
  position: relative;
  list-style: none;
  margin: 0;
  padding: 0;
}

/* home.js caps the height at the first four items once there are more. */
.news-list.is-scrollable {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 8px;
  scrollbar-width: thin;
}

/* Fade the peeking item while older ones remain below (18px matches NEWS_PEEK in home.js). */
.news-list.has-more {
  -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 18px), transparent);
  mask-image: linear-gradient(to bottom, #000 calc(100% - 18px), transparent);
}

.news-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 10px;
  min-height: 26px;
  padding: 3px 10px;
  border: 1px solid rgba(78, 42, 132, 0.2);
  border-radius: 999px;
  background: rgba(78, 42, 132, 0.055);
  color: var(--accent-dark);
  font: inherit;
  font-size: 0.75rem;
  font-weight: 650;
  line-height: 1.6;
  cursor: pointer;
  transition: background-color 160ms ease, border-color 160ms ease;
}

.news-toggle[hidden] {
  display: none;
}

.news-toggle:hover {
  background: rgba(78, 42, 132, 0.1);
  border-color: rgba(78, 42, 132, 0.35);
}

.news-toggle:focus-visible {
  outline: 3px solid rgba(78, 42, 132, 0.25);
  outline-offset: 3px;
}

.news-list li {
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr);
  gap: 12px;
  margin: 8px 0 0;
}

.news-list time {
  color: var(--news);
  font-weight: 720;
  white-space: nowrap;
}

.news-list span {
  font-family: var(--klee);
}

.news-highlight {
  color: var(--accent);
}

.interest-grid,
.two-column {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.interest-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.interest-grid article,
.two-column article {
  padding: 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.publications-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px 22px;
  margin-bottom: 16px;
}

.publications-heading h2 {
  margin: 0;
}

.publication-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.publication-filters[hidden],
.work-item[hidden] {
  display: none;
}

.publication-filters button {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 3px 8px;
  border: 1px solid rgba(78, 42, 132, 0.2);
  border-radius: 999px;
  background: rgba(78, 42, 132, 0.055);
  color: var(--accent-dark);
  font: inherit;
  font-size: 0.75rem;
  font-weight: 650;
  line-height: 1.6;
  cursor: pointer;
  transition: background-color 160ms ease, border-color 160ms ease;
}

.publication-filters button:hover {
  background: rgba(78, 42, 132, 0.1);
  border-color: rgba(78, 42, 132, 0.35);
}

.publication-filters button[aria-pressed="true"] {
  background: rgba(78, 42, 132, 0.14);
  border-color: rgba(78, 42, 132, 0.45);
}

.publication-filters button:focus-visible {
  outline: 3px solid rgba(78, 42, 132, 0.25);
  outline-offset: 3px;
}

.work-list {
  display: grid;
  gap: 20px;
}

.work-item {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.work-item h3 {
  color: var(--accent-dark);
}

.work-item .authors {
  color: var(--muted);
  font-family: var(--klee);
  font-weight: 400;
}

.author-me {
  color: var(--alert);
  font-weight: 400;
}

.publication-visual {
  position: relative;
  width: 220px;
  max-width: 100%;
}

.publication-image {
  display: block;
  width: 220px;
  max-width: 100%;
  height: 110px;
  object-fit: contain;
  object-position: center;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--surface);
}

.publication-logo {
  object-fit: contain;
  padding: 8px;
}

.publication-wide {
  object-fit: contain;
  padding: 0;
}

.publication-badge {
  position: absolute;
  top: 6px;
  left: -5px;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 3px 7px;
  color: #ffffff;
  background: linear-gradient(135deg, #6844a3, var(--accent));
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 4px;
  box-shadow: 0 2px 6px rgba(78, 42, 132, 0.24);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.015em;
  line-height: 1;
  white-space: nowrap;
}

/* "Paper" floats left so the Details toggle sits beside it; the abstract clears below. */
.work-item .text-link {
  float: left;
  margin-right: 14px;
}

.publication-details {
  color: var(--muted);
}

.publication-details summary {
  /* A block summary would drop below the floated "Paper"; flow-root sits beside it. */
  display: flow-root;
  width: fit-content;
  color: #8b929a;
  cursor: pointer;
  font-family: var(--klee);
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.4rem;
  user-select: none;
  list-style: none;
}

.publication-details summary::-webkit-details-marker {
  display: none;
}

.publication-details summary::before {
  content: "";
  display: inline-block;
  margin-right: 5px;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  border-left: 4px solid currentColor;
  vertical-align: 1px;
}

.publication-details[open] summary::before {
  transform: rotate(90deg);
}

.publication-details summary:hover {
  color: var(--accent);
}

.publication-details summary:focus-visible {
  outline: 3px solid rgba(78, 42, 132, 0.24);
  outline-offset: 3px;
  border-radius: 2px;
}

.publication-details p {
  clear: both;
  margin: 8px 0 0;
  padding: 10px 12px;
  color: #59626c;
  background: #f7f7f9;
  border-left: 3px solid rgba(78, 42, 132, 0.28);
  border-radius: 0 5px 5px 0;
  font-family: var(--font-prose);
  font-size: 0.86rem;
  line-height: 1.62;
}

.text-link {
  font-weight: 720;
}

.timeline-item {
  position: relative;
  display: grid;
  grid-template-columns: minmax(140px, 0.24fr) minmax(0, 1fr);
  gap: 28px;
  padding: 0 0 24px 34px;
  border-top: 0;
}

.timeline-item::before {
  content: "";
  position: absolute;
  left: 8px;
  top: 6px;
  bottom: -6px;
  width: 2px;
  background: rgba(78, 42, 132, 0.18);
}

.timeline-item::after {
  content: "";
  position: absolute;
  left: 4px;
  top: 8px;
  box-sizing: border-box;
  width: 10px;
  height: 10px;
  border: 1px solid var(--surface);
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 2px rgba(78, 42, 132, 0.14);
}

.timeline-item:last-child {
  padding-bottom: 0;
}

.timeline-item:last-child::before {
  display: none;
}

.timeline-date {
  color: var(--accent-dark);
  font-size: 0.88rem;
  font-weight: 760;
}

.education-timeline {
  position: relative;
  display: grid;
  gap: 10px;
  margin-top: 4px;
}

.education-timeline::before {
  content: "";
  position: absolute;
  left: 193px;
  top: 18px;
  bottom: 18px;
  width: 2px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(78, 42, 132, 0.42), rgba(78, 42, 132, 0.1));
}

.education-item {
  position: relative;
  display: grid;
  grid-template-columns: 170px minmax(0, 1fr);
  gap: 46px;
  align-items: stretch;
}

.education-item::before {
  content: "";
  position: absolute;
  left: 189px;
  top: 17px;
  box-sizing: border-box;
  width: 10px;
  height: 10px;
  border: 1px solid var(--surface);
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 2px rgba(78, 42, 132, 0.13);
}

.education-item.future::before {
  background: var(--warm);
}

.education-year {
  padding-top: 12px;
  color: var(--accent-dark);
  font-size: 0.84rem;
  font-weight: 700;
  white-space: nowrap;
}

.education-card {
  padding: 12px 0;
  background: transparent;
  border: 0;
  border-radius: 0;
}

.education-card-with-logo {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
  gap: 16px;
  align-items: center;
}

.organization-logo-link {
  display: flex;
  align-items: center;
  justify-content: center;
}

.organization-logo {
  display: block;
  width: 48px;
  max-height: 50px;
  object-fit: contain;
}

.organization-logo-tall {
  width: 42px;
}

.organization-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 10px;
}

.organization-heading h3 {
  margin-bottom: 0;
}

.organization-heading .organization-role {
  margin: 0;
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.35;
}

.organization-heading + .meta {
  margin-top: 3px;
}

.organization-copy h3 a {
  color: var(--accent-dark);
  text-decoration-color: rgba(78, 42, 132, 0.28);
}

.organization-copy p:last-child {
  margin-bottom: 0;
}

.education-card p:last-child {
  margin-bottom: 0;
}

.education-card .meta {
  font-family: var(--klee);
}

.experience-timeline {
  gap: 4px;
}

.experience-item {
  min-height: 46px;
}

.experience-year,
.experience-content {
  padding-top: 12px;
}

.experience-content h3 {
  margin-bottom: 0;
  font-weight: 400;
}

.skill-list {
  padding-left: 1rem;
}

@media (max-width: 980px) {
  .page-shell {
    grid-template-columns: 1fr;
    gap: 30px;
    padding-top: 32px;
  }

  .profile {
    position: static;
    display: grid;
    grid-template-columns: 170px minmax(0, 1fr);
    gap: 24px;
    align-items: center;
  }

  .profile-copy {
    margin-top: 0;
  }

  .content::before {
    display: none;
  }

  .interest-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  :root {
    --header-height: 64px;
  }

  body {
    font-size: 0.875rem;
  }

  .nav {
    width: min(100% - 28px, 1180px);
  }

  .menu-toggle {
    display: inline-flex;
  }

  .nav-links {
    position: absolute;
    left: 14px;
    right: 14px;
    top: calc(100% + 8px);
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    padding: 8px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
  }

  .nav-links.open {
    display: flex;
  }

  .nav-links a {
    min-height: 44px;
    padding: 0 12px;
  }

  .page-shell {
    width: min(100% - 28px, 1180px);
  }

  .profile {
    grid-template-columns: 1fr;
    padding: 0;
  }

  .profile h1 {
    white-space: normal;
  }

  .profile-photo {
    width: min(220px, 84%);
  }

  .section {
    padding: 22px 0;
  }

  .news-list li,
  .work-item,
  .two-column {
    grid-template-columns: 1fr;
  }

  .education-timeline::before {
    left: 8px;
    top: 4px;
    bottom: 18px;
  }

  .education-item {
    grid-template-columns: 1fr;
    gap: 2px;
    padding-left: 34px;
  }

  .education-item::before {
    left: 4px;
    top: 5px;
  }

  .education-year {
    padding-top: 0;
  }

  .experience-content {
    padding-top: 0;
  }

  .education-card-with-logo {
    grid-template-columns: 50px minmax(0, 1fr);
    gap: 12px;
  }

  .organization-logo {
    width: 44px;
    max-height: 48px;
  }

  .organization-logo-tall {
    width: 40px;
  }

  .news-list li {
    grid-template-columns: 112px minmax(0, 1fr);
    gap: 8px;
  }

  .publication-image {
    max-width: 100%;
  }
}

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

  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
