:root {
  color-scheme: light dark;
  --background: #f8f7f3;
  --surface: #fffefa;
  --surface-muted: #efede6;
  --text: #212723;
  --muted: #555d56;
  --line: #d9d8cf;
  --accent: #8e432c;
  --accent-hover: #73321e;
  --on-accent: #fffefa;
  --focus: #8e432c;
  --serif: Georgia, 'Times New Roman', serif;
  --sans: 'Segoe UI', system-ui, sans-serif;
}

:root[data-theme='dark'] {
  color-scheme: dark;
  --background: #171e21;
  --surface: #1e272b;
  --surface-muted: #232e33;
  --text: #f4f2ec;
  --muted: #b7c0bc;
  --line: #3a4547;
  --accent: #f2ad90;
  --accent-hover: #ffd0ba;
  --on-accent: #211a16;
  --focus: #f2ad90;
}

:root[data-theme='light'] { color-scheme: light; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
    --background: #171e21;
    --surface: #1e272b;
    --surface-muted: #232e33;
    --text: #f4f2ec;
    --muted: #b7c0bc;
    --line: #3a4547;
    --accent: #f2ad90;
    --accent-hover: #ffd0ba;
    --on-accent: #211a16;
    --focus: #f2ad90;
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  min-height: 100vh;
  margin: 0;
  display: flex;
  flex-direction: column;
  background: var(--background);
  color: var(--text);
  font: 1rem/1.65 var(--sans);
}

main { flex: 1; }
img { display: block; max-width: 100%; }
figure, p { margin: 0; }
a { color: var(--accent); text-underline-offset: .2em; }
button { font: inherit; }
h1, h2, h3 { margin: 0; font-family: var(--serif); font-weight: 400; line-height: 1.1; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 4px; }
.wrap { width: min(72rem, calc(100% - 5rem)); margin-inline: auto; }

.skip-link {
  position: fixed;
  z-index: 5;
  inset: .5rem auto auto .5rem;
  transform: translateY(-150%);
  padding: .65rem 1rem;
  background: var(--surface);
}

.skip-link:focus { transform: none; }
.site-header, .site-footer { border-color: var(--line); border-style: solid; border-width: 0; }
.site-header { border-bottom-width: 1px; }
.site-footer { border-top-width: 1px; }

.header-inner {
  min-height: 4.75rem;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: clamp(1rem, 3vw, 3rem);
}

.wordmark {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  gap: .75rem;
  color: var(--text);
  font-size: .875rem;
  font-weight: 650;
  white-space: nowrap;
  text-decoration: none;
}

.monogram {
  display: grid;
  place-items: center;
  width: 2.375rem;
  aspect-ratio: 1;
  border: 1px solid var(--accent);
  color: var(--accent);
  font: 400 .98rem/1 var(--serif);
  letter-spacing: -.05em;
}

.site-nav { display: flex; flex-wrap: wrap; align-items: center; column-gap: clamp(.9rem, 2.4vw, 2rem); }
.site-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  border-bottom: 1px solid transparent;
  color: var(--muted);
  text-decoration: none;
  font-size: .875rem;
  font-weight: 550;
}
.site-nav a:hover, .site-nav a[aria-current] { color: var(--accent); border-bottom-color: currentColor; }

.theme-button {
  display: grid;
  place-items: center;
  justify-self: end;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}
.theme-button:hover { color: var(--accent); border-color: var(--accent); }
.theme-button span { line-height: 0; }
.theme-button svg { width: 1.12rem; height: 1.12rem; }
.sun-icon, .theme-button[aria-pressed='true'] .moon-icon { display: none; }
.theme-button[aria-pressed='true'] .sun-icon { display: block; }

.home { padding-block: clamp(2.75rem, 6vw, 5.5rem) 4.4rem; }
.hero { display: grid; grid-template-columns: 1.045fr 1fr; gap: clamp(2rem, 5.2vw, 5rem); align-items: center; }
.eyebrow {
  display: flex;
  align-items: center;
  gap: .65rem;
  color: var(--accent);
  font-size: .875rem;
  font-weight: 650;
  letter-spacing: .13em;
  text-transform: uppercase;
}
.eyebrow::before { content: ''; display: inline-block; width: 1.75rem; height: 1px; background: currentColor; }
.hero h1 { margin: 1.35rem 0 1.3rem; font-size: clamp(3.55rem, 6.25vw, 6rem); line-height: .99; letter-spacing: -.062em; }
.specialties { color: var(--accent); font-size: clamp(.875rem, 1.4vw, 1rem); font-weight: 650; }
.specialties span { margin-inline: .12em; }
.lede { max-width: 38rem; color: var(--muted); font-size: clamp(1.05rem, 1.5vw, 1.23rem); }
.hero .lede { max-width: 29rem; margin-top: 1.15rem; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; margin-top: 1.85rem; }

.button {
  display: inline-flex;
  min-height: 3rem;
  align-items: center;
  justify-content: center;
  width: fit-content;
  padding: .6rem 1.2rem;
  border: 1px solid var(--accent);
  border-radius: 2px;
  font-size: .875rem;
  font-weight: 650;
  text-decoration: none;
}
.primary { background: var(--accent); color: var(--on-accent); }
.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.secondary { color: var(--text); border-color: var(--line); }
.secondary:hover { color: var(--accent); border-color: var(--accent); }

.hero-image { position: relative; background: #111b23; }
.hero-image img { width: 100%; height: auto; aspect-ratio: 1.14; object-fit: cover; object-position: 50% 15%; }
.hero-image figcaption {
  position: absolute;
  inset: auto .8rem .8rem auto;
  margin-left: .8rem;
  padding: .28rem .65rem;
  border: 1px solid #ffffff50;
  background: #121a20;
  color: #f3eee6;
  font-size: .78rem;
  letter-spacing: .015em;
}

.home-sections { margin-top: clamp(2.8rem, 6vw, 5rem); padding-top: 1.9rem; border-top: 1px solid var(--line); }
.home-sections h2 { margin-bottom: 1.3rem; font-size: 1.8rem; letter-spacing: -.032em; }
.card-grid, .gallery-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.section-card {
  display: block;
  min-height: 10.25rem;
  padding: 1.35rem;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
}
.section-card:hover { border-color: var(--accent); }
.section-card:hover h3 { color: var(--accent); }
.card-icon { display: inline-block; color: var(--accent); line-height: 0; margin-bottom: .85rem; }
.section-card h3 { margin-bottom: .45rem; font-size: 1.45rem; letter-spacing: -.025em; }
.section-card p { color: var(--muted); font-size: .95rem; }

.inner-page { padding-block: clamp(2.9rem, 6vw, 5.5rem) 5rem; }
.page-intro { display: flex; gap: 1.25rem 2rem; align-items: end; justify-content: space-between; margin-bottom: 2.5rem; }
.page-intro h1 { margin-block: .95rem .85rem; font-size: clamp(3.15rem, 7vw, 5.5rem); letter-spacing: -.06em; }
.detail-list { border-top: 1px solid var(--line); }
.detail-row {
  display: grid;
  grid-template-columns: minmax(11rem, .75fr) 1.4fr;
  align-items: baseline;
  gap: .5rem 1.8rem;
  padding-block: 1.5rem;
  border-bottom: 1px solid var(--line);
}
.detail-row h2, .contact-panel h2 { font-size: 1.45rem; letter-spacing: -.025em; }
.detail-row p, .detail-row ul { max-width: 39rem; }
.placeholder { color: var(--muted); }
.interest-list { margin: 0; padding-left: 1.25rem; }

.cv-intro h1 { margin-top: 0; }
.cv-name { margin-bottom: .2rem; font: 400 1.6rem/1.25 var(--serif); }
.cv-links { display: flex; flex-wrap: wrap; gap: .25rem 1.2rem; margin: .85rem 0 0; padding: 0; list-style: none; }
.cv-links a { display: inline-flex; align-items: center; min-height: 1.75rem; }
.cv-contents { padding-block: .55rem; border-top: 1px solid var(--line); }
.cv-contents .cv-links { margin: 0; font-size: .875rem; }
.cv-section { grid-template-columns: minmax(0, 1fr) minmax(0, 2.45fr); scroll-margin-top: 1rem; }
.cv-section h2 { max-width: 17rem; }
.cv-section p, .cv-section ul { max-width: 65ch; }
.cv-timeline { display: grid; gap: 1.25rem; margin: 0; padding: 0; list-style: none; }
.cv-entry { display: grid; grid-template-columns: 9.5rem minmax(0, 1fr); gap: .25rem 1.25rem; align-items: baseline; }
.cv-entry + .cv-entry { padding-top: 1.25rem; border-top: 1px solid var(--line); }
.cv-entry h3 { margin-bottom: .25rem; font-size: 1.2rem; line-height: 1.35; }
.cv-date { color: var(--muted); font-variant-numeric: tabular-nums; font-size: .875rem; }
.cv-entry dd { margin: 0; }
.cv-bullets { display: grid; gap: .65rem; margin: 0; padding-left: 1.25rem; }

.profile-layout { display: grid; grid-template-columns: minmax(0, 2.3fr) minmax(10rem, 1fr); gap: 2rem; align-items: start; margin-bottom: 2.5rem; }
.profile-introduction, .profile-section-copy { display: grid; gap: .9rem; min-width: 0; }
.profile-introduction { max-width: 41rem; }
.profile-introduction .lede { max-width: none; }
.profile-portrait {
  position: relative;
  width: 100%;
  min-width: 0;
  max-width: 24rem;
  aspect-ratio: 1;
  overflow: hidden;
  background: var(--surface-muted);
}
.profile-portrait img {
  position: absolute;
  top: 0;
  left: -15%;
  width: 150%;
  max-width: none;
  height: auto;
}
.contact-panel { max-width: 40rem; padding: clamp(1.2rem, 3.5vw, 2.25rem); border: 1px solid var(--line); background: var(--surface); }
.email-link { display: inline-block; margin-block: .5rem 1rem; font-family: var(--serif); font-size: clamp(1.25rem, 3.4vw, 2rem); overflow-wrap: anywhere; }

.gallery-image { display: block; position: relative; overflow: hidden; background: #182428; }
.gallery-image img { width: 100%; height: auto; aspect-ratio: 1.28; object-fit: cover; }
.gallery-section-nav { display: flex; flex-wrap: wrap; gap: .25rem 1.2rem; margin: 0 0 2rem; }
.gallery-section-nav a { display: inline-flex; align-items: center; min-height: 2.75rem; font-size: .875rem; }
.gallery-section h2 { margin-bottom: 1.25rem; font-size: 1.8rem; }
.gallery-section h2[id] { scroll-margin-top: 1rem; }
.gallery-section + .gallery-section { margin-top: 3rem; padding-top: 1.75rem; border-top: 1px solid var(--line); }
.research-figure .gallery-image { background: #fff; border: 1px solid var(--line); }
.research-figure .gallery-image img { object-fit: contain; }
.gallery-document-link { display: block; color: var(--text); text-decoration: none; }
.gallery-document-link .gallery-caption { display: block; padding-top: .65rem; }
.gallery-document-link:hover .gallery-caption { color: var(--accent); text-decoration: underline; }
.gallery-document-meta { display: block; margin-top: .2rem; color: var(--muted); font-size: .875rem; }
.gallery-controls { display: flex; flex-wrap: wrap; align-items: center; gap: .65rem 1.2rem; margin-top: 1.65rem; }
.gallery-controls p { color: var(--muted); font-size: .875rem; }
.gallery-controls button { background: transparent; cursor: pointer; }
.expand-icon { position: absolute; display: grid; place-items: center; inset: auto .65rem .65rem auto; width: 2.35rem; height: 2.35rem; color: #fff; background: #121a20; }
.expand-icon svg { width: 1.1rem; height: 1.1rem; }
.gallery-image:hover .expand-icon { background: #8e432c; }
.gallery-item figcaption { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .15rem .65rem; padding-top: .65rem; color: var(--muted); font-size: .875rem; }
.gallery-caption { color: var(--text); font: 400 1.2rem/1.25 var(--serif); }
.lightbox {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  padding: 3.5rem 1rem 1rem;
  border: 0;
  background: #10161b;
  color: #f6f3ea;
  overflow: auto;
}
.lightbox[open] { display: grid; grid-template-rows: minmax(0, 1fr) auto; gap: .65rem; }
.lightbox::backdrop { background: #10161b; }
body:has(.lightbox[open]) { overflow: hidden; }
.lightbox-figure { min-height: 0; display: grid; grid-template-rows: minmax(0, 1fr) auto; gap: .5rem; text-align: center; }
.lightbox-figure img { width: 100%; height: 100%; min-height: 0; object-fit: contain; }
.lightbox-figure figcaption { display: flex; flex-wrap: wrap; justify-content: center; gap: .4rem 1rem; }
.lightbox-controls { display: flex; justify-content: center; gap: .75rem; }
.lightbox button { min-height: 2.75rem; padding: .35rem .85rem; border: 1px solid #899395; background: #1a2329; color: #f6f3ea; cursor: pointer; }
.lightbox button:hover { border-color: #f6f3ea; }
.lightbox button:focus-visible { outline-color: #f2ad90; }
.lightbox .lightbox-close { position: absolute; top: .5rem; right: 1rem; min-width: 2.75rem; padding: .15rem; font-size: 1.5rem; }

.footer-inner { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .8rem 1.25rem; padding-block: 1.5rem; color: var(--muted); font-size: .875rem; }
.footer-inner a { color: var(--muted); }
.footer-inner a:hover { color: var(--accent); }
.visit-counter { display: flex; align-items: center; flex-wrap: wrap; gap: .45rem .55rem; }
.visit-total { padding-inline: .4rem; border: 1px solid var(--line); background: var(--surface-muted); color: var(--text); font-variant-numeric: tabular-nums; }

@media (max-width: 56rem) {
  .wrap { width: calc(100% - 3rem); }
  .header-inner { gap: 0 1rem; grid-template-columns: 1fr auto; padding-top: .75rem; }
  .site-nav { grid-row: 2; grid-column: 1 / -1; }
  .theme-button { grid-row: 1; grid-column: 2; }
  .hero h1 { font-size: clamp(3.15rem, 7.2vw, 5rem); }
}

@media (max-width: 42rem) {
  .wrap { width: calc(100% - 2rem); }
  .hero, .card-grid, .profile-layout, .detail-row { grid-template-columns: 1fr; }
  .hero { gap: 2rem; }
  .hero-image img { aspect-ratio: 1.24; }
  .hero h1 { font-size: clamp(3.1rem, 10.8vw, 4.45rem); }
  .section-card { min-height: 0; }
  .page-intro { flex-wrap: wrap; }
  .cv-section h2 { max-width: none; margin-bottom: .5rem; }
  .cv-entry { grid-template-columns: minmax(0, 1fr); }
  .profile-portrait { order: -1; }
  .gallery-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 29rem) {
  .gallery-grid { grid-template-columns: 1fr; gap: 1.5rem; }
  .visit-counter { flex-basis: 100%; order: 1; }
}
