/* THEME COLORS */
:root {
  color-scheme: light;
  --bg: #fbfaf8;
  --text: #1c1c1c;
  --muted: #5a5854;
  --subtle: #666460;
  --faint: #767470;
  --border: #dcdad5;
  --border-strong: #b9b7b2;
  --surface: #ffffff;
  --accent: #2b4a7a;
  --accent-line: rgba(43, 74, 122, 0.35);
  --on-accent: #ffffff;
  --fig-border: #e3e1dc;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #1a1b1e;
  --text: #e4e2dd;
  --muted: #a8a6a0;
  --subtle: #9a9892;
  --faint: #8a8880;
  --border: #3a3b3f;
  --border-strong: #55565b;
  --surface: #2a2b2f;
  --accent: #7fa8d9;
  --accent-line: rgba(127, 168, 217, 0.35);
  --on-accent: #1a1b1e;
  --fig-border: transparent;
}

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
}

img {
  max-width: 100%;
  height: auto;
}

.page {
  position: relative;
  max-width: 720px;
  margin: 0 auto;
  padding: 64px 24px 96px;
}

/* THEME TOGGLE */
.theme-toggle {
  position: absolute;
  top: 20px;
  right: 24px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
}

.theme-toggle:hover {
  color: var(--accent);
  border-color: var(--border-strong);
}

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

@media (max-width: 700px) {
  .theme-toggle {
    width: 44px;
    height: 44px;
    top: 16px;
    right: 16px;
  }

  .theme-toggle.floating {
    position: fixed;
    top: auto;
    bottom: 72px;
    border-color: var(--border-strong);
    color: var(--text);
    opacity: 0.9;
    z-index: 10;
  }
}

/* HEADER */
.header-top {
  display: flex;
  align-items: center;
  gap: 22px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.headshot {
  width: 108px;
  height: 108px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.header-text {
  min-width: 240px;
}

.header h1 {
  font-size: 30px;
  font-weight: 700;
  margin: 0 0 6px;
}

.title {
  font-size: 16px;
  margin: 0 0 2px;
}

.affil {
  font-size: 14px;
  color: var(--muted);
  margin: 0 0 10px;
}

.tagline {
  font-size: 14px;
  font-style: italic;
  color: var(--accent);
  margin: 0 0 14px;
}

.contact-line {
  font-size: 14px;
  margin: 0;
}

/* KEY NUMBERS */
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin: 28px 0 0;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-left: 16px;
  border-left: 1px solid var(--border);
}

.stat:first-child {
  padding-left: 0;
  border-left: none;
}

.stat-num {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.stat-label {
  font-size: 13px;
  line-height: 1.4;
  color: var(--muted);
}

@media (max-width: 520px) {
  .stats {
    gap: 10px;
  }

  .stat {
    padding-left: 10px;
  }

  .stat:first-child {
    padding-left: 0;
  }

  .stat-num {
    font-size: 17px;
  }

  .stat-label {
    font-size: 11.5px;
  }

  .stat-label br {
    display: none;
  }
}

/* TOC NAV */
html {
  scroll-behavior: smooth;
}

.toc {
  margin: 24px 0 40px;
  padding: 10px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  background: var(--bg);
  display: flex;
  flex-wrap: wrap;
  gap: 4px 18px;
}

@media (min-width: 701px) {
  .toc {
    position: sticky;
    top: 0;
    z-index: 10;
  }

  section {
    scroll-margin-top: 56px;
  }
}

.to-top {
  display: none;
}

@media (max-width: 700px) {
  .to-top {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    right: 16px;
    bottom: 16px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--text);
    font-size: 20px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    z-index: 10;
  }

  .to-top.visible {
    opacity: 0.9;
    pointer-events: auto;
  }
}

.toc a {
  color: var(--text);
}

.toc a.toc-contact {
  margin-left: auto;
  color: var(--accent);
}

.toc a.active {
  color: var(--accent);
  border-bottom: 2px solid var(--accent);
}

/* SECTIONS */
section {
  margin-bottom: 36px;
}

h2 {
  font-size: 17px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
  margin: 0 0 14px;
}

h3 {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 18px 0 8px;
}

h3:first-of-type {
  margin-top: 0;
}

p {
  font-size: 15px;
  margin: 0 0 10px;
}

a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid var(--accent-line);
}

a:hover {
  border-bottom-color: var(--accent);
}

/* CV LISTS (education, appointments, grants, awards) */
.cv-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.cv-list li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  font-size: 15px;
  padding: 5px 0;
  border-bottom: 1px dotted var(--border);
}

.cv-list li:last-child {
  border-bottom: none;
}

.cv-main {
  flex: 1;
}

.cv-date {
  flex-shrink: 0;
  color: var(--muted);
  font-size: 14px;
  white-space: nowrap;
}

.cv-sub {
  display: inline-block;
  margin-top: 3px;
  color: var(--subtle);
  font-size: 13px;
}

.cv-list-pending .cv-main {
  color: var(--faint);
}

/* RESEARCH THEMES */
.theme {
  margin-top: 32px;
}

.theme h3 {
  font-size: 16px;
  color: var(--text);
  text-transform: none;
  letter-spacing: 0;
  margin: 0 0 8px;
}

.theme figure {
  margin: 14px 0 12px;
}

.fig-link {
  display: block;
  border-bottom: none;
  cursor: zoom-in;
}

.theme figure img {
  display: block;
  width: 100%;
  height: auto;
  background: #fff;
  border: 1px solid var(--fig-border);
  border-radius: 6px;
  padding: 8px;
  box-sizing: border-box;
}

.theme figcaption {
  margin-top: 8px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
}

.paper-list {
  margin: 0;
  padding-left: 18px;
}

.paper-list li {
  font-size: 14px;
  margin-bottom: 6px;
}

.venue {
  color: var(--muted);
  font-style: italic;
}

.tag {
  display: inline-block;
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 10px;
  white-space: nowrap;
  vertical-align: 1px;
}

.tag-first {
  color: var(--on-accent);
  background: var(--accent);
}

.tag-collab {
  color: var(--muted);
  border: 1px solid var(--border-strong);
}

/* PUBLICATIONS */
.pub-summary {
  color: var(--muted);
  font-size: 14px;
}

/* FOOTER */
.footer {
  border-top: 1px solid var(--border);
  padding-top: 16px;
  font-size: 14px;
  color: var(--muted);
}

.copyright {
  font-size: 12px;
  color: var(--faint);
}

.nowrap {
  white-space: nowrap;
}
