:root {
  --red: #9e1128;
  --red-bright: #ce0e2d;
  --ink: #1a1a1a;
  --muted: #5a5a5a;
  --rule: #d8d4cf;
  --bg: #ffffff;
  --bg-soft: #f7f5f2;
  --focus: #0b5fff;
  --max: 68rem;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --red: #ff8fa0;
    --red-bright: #ff8fa0;
    --ink: #eceaea;
    --muted: #b4afac;
    --rule: #3a3634;
    --bg: #15120f;
    --bg-soft: #1e1a17;
    --focus: #8ab4ff;
  }
}
:root[data-theme="dark"] {
  --red: #ff8fa0;
  --red-bright: #ff8fa0;
  --ink: #eceaea;
  --muted: #b4afac;
  --rule: #3a3634;
  --bg: #15120f;
  --bg-soft: #1e1a17;
  --focus: #8ab4ff;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 1.0625rem/1.65 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--ink);
  color: var(--bg);
  padding: .75rem 1rem;
  z-index: 100;
}
.skip:focus { left: 0; }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.wrap {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 1rem;
}

/* ---------- masthead ---------- */

.masthead {
  border-bottom: 1px solid var(--rule);
  background: var(--bg);
}
.masthead .wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: .5rem 1.5rem;
  padding-top: 1.1rem;
  padding-bottom: 1.1rem;
}
.wordmark {
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -.01em;
  color: var(--ink);
  text-decoration: none;
}
.wordmark span { color: var(--red); }
.tagline {
  color: var(--muted);
  font-size: .9rem;
  margin: 0;
}

nav.primary { border-bottom: 1px solid var(--rule); background: var(--bg-soft); }
nav.primary ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  max-width: var(--max);
  margin-inline: auto;
  padding-inline: 1rem;
}
nav.primary a {
  display: block;
  padding: .7rem .9rem;
  color: var(--ink);
  text-decoration: none;
  font-size: .95rem;
  border-bottom: 3px solid transparent;
}
nav.primary a:hover { background: var(--bg); }
nav.primary a[aria-current="page"] {
  border-bottom-color: var(--red);
  font-weight: 600;
}
nav.primary li:first-child a { padding-left: 0; }

/* ---------- type ---------- */

main { padding-block: 2.5rem 4rem; }

h1 {
  font-size: clamp(1.8rem, 1.2rem + 2.2vw, 2.6rem);
  line-height: 1.15;
  letter-spacing: -.02em;
  margin: 0 0 .6rem;
}
h2 {
  font-size: clamp(1.25rem, 1rem + 1vw, 1.6rem);
  line-height: 1.25;
  letter-spacing: -.01em;
  margin: 2.6rem 0 .75rem;
  padding-top: 1.4rem;
  border-top: 1px solid var(--rule);
}
h2:first-of-type { border-top: 0; padding-top: 0; margin-top: 1.8rem; }
h3 {
  font-size: 1.08rem;
  margin: 1.6rem 0 .4rem;
}
p, li { max-width: 62ch; }
a { color: var(--red); }
a:hover { text-decoration-thickness: 2px; }

.lede {
  font-size: 1.18rem;
  color: var(--muted);
  max-width: 55ch;
}

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

/* ---------- call-out ---------- */

.callout {
  background: var(--bg-soft);
  border-left: 5px solid var(--red);
  padding: 1.25rem 1.4rem;
  margin: 2rem 0;
  border-radius: 0 6px 6px 0;
}
.callout h2, .callout h3 { margin-top: 0; border-top: 0; padding-top: 0; }
.callout p:last-child { margin-bottom: 0; }

/* ---------- cards ---------- */

.grid {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 17rem));
  justify-content: start;
  margin: 1.5rem 0;
}
.card {
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 1.1rem 1.2rem;
  background: var(--bg);
}
.card h3 { margin-top: 0; }
.card p { margin-bottom: 0; }

.person { text-align: left; }
.person img {
  width: 100%;
  max-width: 15rem;
  height: auto;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 6px;
  background: var(--bg-soft);
  display: block;
  margin-bottom: .7rem;
}
.person .name { font-weight: 650; display: block; }
.person .role { color: var(--muted); font-size: .92rem; }

/* ---------- stats ---------- */

.stats {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  margin: 1.5rem 0 .5rem;
  padding: 0;
  list-style: none;
}
.stats li {
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 1rem;
  max-width: none;
}
.stats .n {
  display: block;
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.1;
  color: var(--red);
}
.stats .k { color: var(--muted); font-size: .9rem; }

/* ---------- publications ---------- */

.pubs { list-style: none; padding: 0; }
.pubs li {
  border-top: 1px solid var(--rule);
  padding: 1rem 0;
  max-width: 68ch;
}
.pubs li:first-child { border-top: 0; }
.pub-venue { font-style: italic; }
.key {
  background: var(--bg-soft);
  padding: .8rem 1rem;
  border-radius: 6px;
  font-size: .92rem;
  max-width: 62ch;
}

/* ---------- footer ---------- */

footer {
  border-top: 1px solid var(--rule);
  background: var(--bg-soft);
  padding-block: 2rem 3rem;
}
footer p { margin: .3rem 0; font-size: .92rem; color: var(--muted); }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* figures: hand-drawn inline SVG diagrams */
.fig {
  margin: 2rem 0 2.25rem;
  padding: 1.25rem 0 0;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  color: var(--ink);
}
.fig svg {
  display: block;
  width: 100%;
  max-width: 54rem;
  height: auto;
  margin: 0 auto;
}
.fig figcaption {
  max-width: 44rem;
  margin: 0.75rem auto 1.1rem;
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--muted);
  text-align: center;
}

/* figures built on artwork: keep the white plate in dark mode so the
   illustration is not a lit slab, and so the typeset labels stay legible */
.fig.art {
  background: #ffffff;
  border: 1px solid var(--rule);
  border-top: 1px solid var(--rule);
  border-radius: 8px;
  padding: 0.5rem 0.5rem 0;
}
.fig.art figcaption { margin-bottom: 0.9rem; color: #5a5a5a; }

/* photographic figures: dark micrographs, so no white plate */
.fig.photo img {
  display: block;
  width: 100%;
  max-width: 48rem;
  height: auto;
  margin: 0 auto;
  border-radius: 6px;
}

/* visitor art */
.art-hero img {
  display: block; width: 100%; max-width: 34rem; height: auto;
  margin: 0 auto; border-radius: 6px;
}
.art-hero figcaption { font-style: italic; }
.artgrid {
  display: grid; gap: 1.5rem;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  margin: 1.5rem 0 1rem;
}
.artcard { margin: 0; }
.artcard img {
  width: 100%; height: auto; display: block;
  border: 1px solid var(--rule); border-radius: 6px; background: #fff;
}
.artcard figcaption { font-size: .9rem; line-height: 1.5; margin-top: .6rem; }
.artcard .art-text { display: block; color: var(--muted); margin-top: .3rem; }
.artcard .art-by { display: block; color: var(--muted); margin-top: .3rem; font-style: italic; }

/* Section headings that double as links to the full treatment */
h3 > a:only-child {
  color: inherit;
  text-decoration-color: var(--red);
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
}
h3 > a:only-child:hover {
  color: var(--red);
}

/* Progressive disclosure on the join page */
details {
  border-top: 1px solid var(--rule);
  padding: 0.6rem 0;
}
details:last-of-type { border-bottom: 1px solid var(--rule); }
details > summary {
  cursor: pointer;
  font-weight: 600;
  padding: 0.35rem 0;
  list-style-position: outside;
}
details > summary:hover { color: var(--red); }
details > summary:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}
details[open] > summary { color: var(--red); }
details > p { margin-top: 0.4rem; }

/* News entries */
.newsitem {
  border-top: 1px solid var(--rule);
  padding: 1.1rem 0 .2rem;
}
.newsitem h3 { margin: .15rem 0 .35rem; }
.newstag {
  display: inline-block;
  background: var(--red);
  color: #fff;
  border-radius: 3px;
  padding: .05rem .4rem;
  font-size: .78rem;
  letter-spacing: .02em;
  margin-right: .35rem;
}
@media (prefers-color-scheme: dark) { .newstag { color: #15120f; } }
.newsfig { margin: .6rem 0 .2rem; max-width: 34rem; }
.newsfig img { width: 100%; height: auto; border-radius: 6px; }

/* Back to top */
.totop {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 50;
  font: inherit;
  font-size: 0.9rem;
  line-height: 1;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--rule);
  border-radius: 2rem;
  background: var(--bg);
  color: var(--ink);
  cursor: pointer;
  box-shadow: 0 1px 6px rgba(0,0,0,.14);
}
.totop:hover { background: var(--bg-soft); }
.totop:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.totop[hidden] { display: none; }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
@media print { .totop { display: none; } }

/* Jump links */
.jump {
  margin: 1.25rem 0 1.75rem;
  padding: 0.75rem 0;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem 1.25rem;
  font-size: 0.95rem;
}
.jump span { color: var(--muted); }
.jump a { white-space: nowrap; }

/* Justified body text. Hyphenation keeps word spacing even; narrow screens stay
   ragged right because justification opens rivers below about 45 characters a line. */
@media (min-width: 40em){
  p, li, figcaption, .lede { text-align: justify; hyphens: auto; -webkit-hyphens: auto; text-wrap: pretty; }
  .meta, .newstag, nav, .jump, .totop, h1, h2, h3, h4, .person, figcaption.small { text-align: left; }
}

/* ---------- logo ---------- */
.masthead .wrap { align-items: center; }
.brand { display: inline-flex; flex-shrink: 0; line-height: 0; }
.brand .logo { width: 56px; height: 56px; display: block; }
.masthead .tagline { flex-basis: 100%; }
@media (min-width: 40em) { .masthead .tagline { flex-basis: auto; margin-left: auto; } }
footer .footlogo { float: right; width: 120px; height: 120px; margin: 0 0 1rem 1.5rem; opacity: .9; }
footer .wrap::after { content: ""; display: block; clear: both; }
@media (max-width: 40em) { footer .footlogo { width: 80px; height: 80px; } }
footer p, .skip { text-align: left; }

/* ---------- PI card: portrait beside text on wide screens ---------- */
@media (min-width: 40em) {
  .grid.pi { grid-template-columns: minmax(0, 44rem); }
  .grid.pi .person {
    display: grid;
    grid-template-columns: 12rem 1fr;
    gap: 0 1.4rem;
    align-items: start;
  }
  .grid.pi .person img { grid-row: 1 / span 2; margin-bottom: 0; max-width: 12rem; }
  .grid.pi .person .name { margin-bottom: .3rem; }
}

/* ---------- outreach: things we make, as rows with a picture at left ---------- */
.mediarows { display: grid; gap: 1rem; margin: 1.25rem 0 2rem; max-width: 44rem; }
.mediarow {
  display: grid; grid-template-columns: 7rem 1fr; gap: 1.1rem; align-items: center;
  border: 1px solid var(--rule); border-radius: 8px; padding: .9rem 1.1rem;
  color: var(--ink); text-decoration: none; background: var(--bg);
}
.mediarow:hover { background: var(--bg-soft); }
.mediarow img { width: 7rem; height: 7rem; object-fit: cover; border-radius: 6px; display: block; }
.mediarow .mediatext { font-size: .95rem; color: var(--muted); text-align: left; }
.mediarow .name { display: block; font-weight: 650; color: var(--ink); margin-bottom: .2rem; }
.mediarow .go { color: var(--red); text-decoration: underline; white-space: nowrap; }
.mediarow:not(:has(img)) { grid-template-columns: 1fr; }
@media (max-width: 40em) { .mediarow { grid-template-columns: 5rem 1fr; } .mediarow img { width: 5rem; height: 5rem; } }
.mediarow img.tall { height: auto; aspect-ratio: 420 / 593; }

.award { color: var(--red-bright); font-weight: 700; }

.fig.photo video.figvideo { display:block; width:100%; max-width:48rem; height:auto; margin:0 auto; border-radius:6px; background:#000; }
.vidpair { display:grid; grid-template-columns:1fr 1fr; gap:.6rem; max-width:60rem; margin:0 auto; }
.vidpair > div { position:relative; }
.vidpair video.figvideo { max-width:none; }
.vidlabel { position:absolute; top:.5rem; left:.6rem; background:rgba(0,0,0,.6); color:#fff; font-size:.85rem; padding:.15rem .5rem; border-radius:4px; }
@media (max-width: 40em) { .vidpair { grid-template-columns:1fr; } }
