:root {
  --ink: #283126;
  --muted: #687064;
  --green: #5b3a70;
  --purple: #76558b;
  --yellow: #f7f3e8;
  --pale: #d8cbe2;
  --cream: #fff;
  --surface: #fff;
  --line: #d9ddce;
  --page: 720px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
section[id] { scroll-margin-top: 28px; }
body {
  margin: 0;
  background: #fff;
  color: var(--ink);
  font-family: "Inter", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.65;
}
a { color: var(--green); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
a:focus-visible { outline: 2px solid var(--purple); outline-offset: 3px; }
.skip-link { position: fixed; z-index: 100; top: 10px; left: 10px; padding: 8px 12px; background: var(--surface); border: 2px solid var(--purple); transform: translateY(-160%); }
.skip-link:focus { transform: translateY(0); }

.site-shell { width: min(calc(100% - 40px), var(--page)); margin: 0 auto; }
.site-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 28px;
  padding: 34px 0 24px;
}
.wordmark { color: var(--ink); font-size: 15px; font-weight: 600; }
.wordmark-en { color: var(--purple); }
.wordmark-zh { margin-left: 5px; color: var(--purple); font-weight: 500; }
.site-header nav { display: flex; gap: 22px; font-size: 13px; }
.site-header nav a { font-weight: 500; transition: color 140ms ease; }
.site-header .page-nav {
  margin-left: auto;
}
.site-header .page-nav a { color: var(--purple); font-weight: 600; }
.home-nav {
  position: fixed;
  top: 142px;
  left: max(24px, calc(50% - (var(--page) / 2) - 118px));
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 7px;
  padding-left: 13px;
  border-left: 1px solid var(--line);
  font-size: 12px;
}
.home-nav a { color: var(--muted); font-weight: 500; }
.home-nav a:hover, .home-nav a:focus-visible { color: var(--purple); }
.home-nav a[aria-current="location"] {
  color: var(--purple);
  font-weight: 600;
}
.site-header nav .nav-research { color: var(--green); }
.site-header nav .nav-writing { color: var(--green); }
.site-header a:hover, .site-header a:focus-visible,
.site-header a:hover .wordmark-en, .site-header a:hover .wordmark-zh,
.site-header a:focus-visible .wordmark-en, .site-header a:focus-visible .wordmark-zh {
  color: var(--purple);
  text-decoration: underline;
  text-underline-offset: 4px;
}

main { padding-top: 72px; }
.intro {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto auto auto;
  gap: 0;
  max-width: 700px;
}
.intro-main { grid-column: 1; grid-row: 1; }
.intro-story { grid-column: 1; grid-row: 2; }
.intro-main h1 { margin-bottom: 6px; }
.intro-pronouns { margin: 0 0 20px; color: var(--muted); font-size: 12px; }
.microbe-simulation {
  grid-column: 1;
  grid-row: 3;
  width: 100%;
  margin: 30px 0 0;
}
.microbe-simulation iframe {
  display: block;
  width: 100%;
  height: 150px;
  border: 1px solid rgba(91, 58, 112, .28);
}
.microbe-simulation p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.4;
}
h1, h2, h3 { margin-top: 0; color: var(--ink); font-weight: 600; letter-spacing: -.025em; }
h1 { margin-bottom: 24px; font-size: clamp(34px, 6vw, 46px); line-height: 1.15; }
.intro h1 { color: var(--purple); }
.greeting-toggle {
  position: relative;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  font-weight: inherit;
  letter-spacing: inherit;
  cursor: pointer;
}
.greeting-toggle::after {
  content: "↔";
  position: absolute;
  right: -25px;
  top: 2px;
  color: var(--yellow);
  font-size: 13px;
  opacity: 0;
  transform: translateX(-4px);
  transition: opacity 150ms ease, transform 150ms ease;
}
.greeting-toggle:hover::after, .greeting-toggle:focus-visible::after { opacity: 1; transform: none; }
.greeting-toggle:focus-visible { outline: 2px solid var(--green); outline-offset: 5px; }
.intro-copy { max-width: 680px; margin: 0; font-size: 17px; line-height: 1.7; }
.intro-copy::first-letter { color: inherit; font-size: inherit; }
.intro-quote {
  max-width: 640px;
  margin: 34px 0 0;
  padding: 20px 24px 18px;
  border-left: 3px solid var(--purple);
  border-radius: 0 7px 7px 0;
  background: #faf8fc;
  color: var(--ink);
}
.intro-quote p {
  margin: 0;
  font-size: 15px;
  line-height: 1.72;
  letter-spacing: -.01em;
}
.intro-quote footer {
  margin-top: 12px;
  color: var(--purple);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .025em;
  text-align: right;
}
.intro-quote cite { font-style: normal; }
.accent-primary { color: #5b3a70; font-weight: 600; }
.eyebrow, .meta, .muted { color: var(--muted); font-size: 12px; }

.home-section { margin-top: 78px; }
.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 5px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}
.section-heading h2 { margin: 0; font-size: 19px; font-weight: 600; }
.section-heading h2::first-letter { color: var(--green); }
.section-heading a, .section-heading span { font-size: 12px; }

.updates-section .section-heading { margin-bottom: 12px; border-bottom: 0; }
.update-list { display: grid; gap: 9px; }
.update-row { display: grid; grid-template-columns: 112px 1fr; gap: 14px; padding: 0; }
.update-row { position: relative; transition: transform 150ms ease; }
.update-row::before { content: ""; position: absolute; top: 9px; left: -13px; width: 5px; height: 5px; border-radius: 50%; background: var(--yellow); opacity: 0; transform: scale(.5); transition: opacity 150ms ease, transform 150ms ease; }
.update-row:hover, .update-row:focus-within { transform: translateX(5px); }
.update-row:hover::before, .update-row:focus-within::before { opacity: 1; transform: scale(1); }
.update-row time { display: block; padding-top: 2px; color: var(--muted); font-size: 11px; white-space: nowrap; }
.update-row p { margin: 0; }
.update-row a { text-decoration: underline; text-underline-offset: 3px; }

.featured-list { padding-top: 18px; }
.featured-list article { display: block; padding: 0; }
.featured-list p { margin: 4px 0 0; }
.featured-list .meta { margin: 0 0 5px; text-transform: uppercase; letter-spacing: .06em; }
.featured-list h3 { max-width: 650px; margin: 0; font-size: 18px; line-height: 1.4; }
.featured-list h3 a { color: var(--ink); }
.research-image { display: block; align-self: start; overflow: hidden; background: #f7f3e8; }
.research-image img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; transition: transform 180ms ease; }
.research-image:hover img { transform: scale(1.025) rotate(.35deg); }
.research-copy { transition: transform 160ms ease; }
.featured-list article:hover .research-copy, .featured-list article:focus-within .research-copy { transform: translateX(5px); }
.research-authors, .research-venue { font-size: 12px; }
.research-venue { color: var(--muted); }
.research-abstract { margin-top: 12px !important; color: #465044; font-size: 13px; line-height: 1.6; }
.research-coming-soon { margin-top: 12px !important; color: var(--muted); font-size: 12px; }
.research-abstract summary, .catalog-abstract summary { width: fit-content; color: var(--green); cursor: pointer; font-size: 12px; }
.research-abstract p, .catalog-abstract p { margin: 8px 0 0; }
.research-links { margin-top: 10px !important; font-size: 12px; }

.about-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 34px; padding-top: 14px; }
.about-grid p { margin: 0; }

.popup-word { position: relative; color: var(--green); border-bottom: 1px dotted currentColor; cursor: help; outline: none; }
.popup-word:focus-visible { outline: 2px solid var(--purple); outline-offset: 3px; border-radius: 2px; }
.popup-card {
  position: absolute;
  z-index: 10;
  left: -16px;
  bottom: calc(100% + 12px);
  display: grid;
  gap: 9px;
  width: min(290px, 78vw);
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 5px;
  box-shadow: 0 12px 32px rgba(0,0,0,.11);
  color: var(--ink);
  font-size: 12px;
  line-height: 1.5;
  opacity: 0;
  visibility: hidden;
  transform: translateY(5px);
  transition: opacity 140ms ease, transform 140ms ease, visibility 140ms;
  pointer-events: none;
}
.popup-card--right { right: -16px; left: auto; }
.popup-card img { width: 100%; max-height: 145px; object-fit: cover; border-radius: 2px; }
.popup-word:hover .popup-card, .popup-word:focus .popup-card, .popup-word:focus-within .popup-card { opacity: 1; visibility: visible; transform: none; }

.listing-page, .simple-page { min-height: 60vh; }
.listing-page > h1, .simple-page > h1 { margin-bottom: 48px; }
.listing-page h2, .prose h2, .cv-page section h2 { margin: 48px 0 14px; font-size: 19px; }
.publication-list article { padding: 18px 0; border-bottom: 1px solid var(--line); }
.publication-list p { margin: 3px 0; }
.publication-list a, .prose a { text-decoration: underline; text-underline-offset: 3px; }
.research-page { min-height: 60vh; }
.research-page-header { max-width: 610px; margin-bottom: 72px; }
.research-page-header h1 { margin-bottom: 14px; }
.research-page-header > p:last-child { color: var(--muted); }
.publication-group { margin-top: 68px; }
.publication-group > h2 { margin: 0 0 24px; padding-bottom: 9px; border-bottom: 1px solid var(--line); font-size: 17px; text-transform: lowercase; }
.research-catalog { display: grid; gap: 58px; }
.catalog-paper { max-width: 760px; }
.catalog-copy h3 {
  max-width: 720px;
  margin: 0 0 12px;
  font-size: clamp(23px, 3.8vw, 29px);
  line-height: 1.22;
  letter-spacing: -.03em;
  text-wrap: balance;
}
.catalog-copy h3 a {
  color: var(--ink);
  text-decoration-color: transparent;
  text-decoration-thickness: 1px;
  text-underline-offset: 5px;
  transition: color 140ms ease, text-decoration-color 140ms ease;
}
.catalog-copy h3 a:hover,
.catalog-copy h3 a:focus-visible {
  color: var(--purple);
  text-decoration-color: currentColor;
}
.catalog-subtitle { margin: 0 0 11px; color: #465044; font-size: 14px; line-height: 1.55; }
.catalog-authors { margin: 0 0 7px; font-size: 13px; }
.catalog-meta { margin: 0; font-size: 12px; }
.catalog-meta strong { color: var(--purple); font-weight: 600; }
.catalog-award { margin: 7px 0 0; font-size: 12px; }
.catalog-abstract { margin: 15px 0 0; color: var(--muted); font-size: 12px; line-height: 1.65; }
.post-index a { display: grid; grid-template-columns: 90px 1fr 18px; gap: 16px; padding: 17px 0; border-bottom: 1px solid var(--line); }
.post-index time, .post-index b { color: var(--muted); font-size: 11px; }
.prose { font-size: 16px; }

.cv-title { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; margin-bottom: 34px; }
.cv-title h1 { font-size: 34px; }
.cv-title .meta { margin-top: 8px; }
.download { padding: 7px 11px; border: 1px solid var(--line); border-radius: 4px; white-space: nowrap; }
.cv-page section { margin-top: 48px; }
.cv-page section h2 { padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.tags { display: flex; flex-wrap: wrap; gap: 7px; }
.tags span { padding: 3px 9px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: 11px; }
.cv-rows > div { display: grid; grid-template-columns: 160px 1fr; gap: 16px; padding: 13px 0; border-bottom: 1px solid var(--line); }
.cv-rows time, .cv-rows small { color: var(--muted); font-size: 11px; }
.cv-rows p, .cv-rows strong, .cv-rows small { display: block; margin: 0; }
.cv-rows strong { font-weight: 500; }

.site-footer { display: flex; justify-content: space-between; gap: 22px; margin-top: 90px; padding: 22px 0 34px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; }
.site-footer div { display: flex; gap: 18px; }
.site-footer p { margin: 0; }

@media (max-width: 980px) {
  .home-nav {
    position: static;
    flex-direction: row;
    gap: 18px;
    margin-top: 8px;
    padding: 10px 0 0;
    border-top: 1px solid var(--line);
    border-left: 0;
  }
}

@media (max-width: 600px) {
  .site-header { align-items: flex-start; }
  .site-header nav { flex-wrap: wrap; justify-content: flex-end; gap: 2px 14px; }
  main { padding-top: 48px; }
  .home-section { margin-top: 64px; }
  .about-grid { grid-template-columns: 1fr; gap: 18px; }
  .featured-list article { grid-template-columns: 1fr; gap: 18px; }
  .research-image { max-width: 360px; }
  .research-page-header { margin-bottom: 54px; }
  .update-row { grid-template-columns: 1fr; gap: 0; }
  .popup-card, .popup-card--right { right: auto; left: -8px; }
  .cv-title { flex-direction: column; }
  .cv-rows > div { grid-template-columns: 1fr; gap: 3px; }
  .site-footer { flex-direction: column; }
  .microbe-simulation { margin-top: 24px; }
  .microbe-simulation iframe { height: 125px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; }
  .update-row:hover, .update-row:focus-within,
  .featured-list article:hover .research-copy,
  .featured-list article:focus-within .research-copy,
  .research-image:hover img { transform: none; }
}
