:root {
  --bg:        #ffffff;
  --fg:        #1a1a1a;
  --muted:     #6b6b6b;
  --faint:     #8e8e8e;
  --rule:      #e6e6e6;
  --chip-bd:   #dcdcdc;
  --chip-bg:   #fafafa;
  --accent:    #1f5fd0;
  --mark:      #f3f4f6;
  --maxw:      46rem;
  --navh:      2.9rem;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:      #131417;
    --fg:      #e6e6e6;
    --muted:   #a0a0a6;
    --faint:   #85858c;
    --rule:    #2a2c31;
    --chip-bd: #34363c;
    --chip-bg: #1c1e22;
    --accent:  #7aa7f0;
    --mark:    #21242a;
  }
}
:root[data-theme="dark"] {
  --bg:      #131417;
  --fg:      #e6e6e6;
  --muted:   #a0a0a6;
  --faint:   #85858c;
  --rule:    #2a2c31;
  --chip-bd: #34363c;
  --chip-bg: #1c1e22;
  --accent:  #7aa7f0;
  --mark:    #21242a;
}

* { box-sizing: border-box; }

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto,
               Helvetica, Arial, sans-serif;
  font-size: 16.5px;
  line-height: 1.62;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 3rem 16px 6rem;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- header ---------- */

header.id {
  display: flex;
  align-items: center;
  gap: 1.6rem;
  margin-bottom: 1.6rem;
}

header.id img {
  width: 116px;
  height: 116px;
  flex: 0 0 116px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--mark);
}

h1 {
  font-size: 1.85rem;
  font-weight: 650;
  letter-spacing: -0.021em;
  margin: 0 0 0.25rem;
  line-height: 1.15;
}

h1 a { color: inherit; }
h1 a:hover { text-decoration: none; color: var(--accent); }

.tagline {
  margin: 0 0 0.7rem;
  color: var(--muted);
  font-size: 1.02rem;
  line-height: 1.45;
}

.links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.45rem;
  font-size: 0.855rem;
}

.links a {
  border: 1px solid var(--chip-bd);
  background: var(--chip-bg);
  border-radius: 999px;
  padding: 0.16rem 0.68rem;
  color: var(--muted);
  white-space: nowrap;
}

.links a:hover {
  border-color: var(--accent);
  color: var(--accent);
  text-decoration: none;
}

/* ---------- nav ---------- */

.nav {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  border-bottom: 1px solid var(--rule);
  margin-bottom: 2.4rem;
}

.nav ul {
  display: flex;
  gap: 1.25rem;
  margin: 0;
  padding: 0.72rem 0;
  list-style: none;
  font-size: 0.875rem;
  overflow-x: auto;
  scrollbar-width: none;
}

.nav ul::-webkit-scrollbar { display: none; }

.nav a {
  color: var(--muted);
  white-space: nowrap;
}

.nav a:hover { color: var(--accent); text-decoration: none; }
.nav a.here { color: var(--fg); font-weight: 600; }

/* ---------- sections ---------- */

section {
  margin-top: 2.9rem;
  scroll-margin-top: calc(var(--navh) + 0.8rem);
}

h2 {
  font-size: 0.775rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--faint);
  margin: 0 0 1.15rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--rule);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
}

h2 .more {
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
  font-size: 0.8rem;
  color: var(--accent);
}

p { margin: 0 0 0.95rem; }
p:last-child { margin-bottom: 0; }

/* ---------- dated lists (news, talks) ---------- */

.dated { margin: 0; padding: 0; list-style: none; }

.dated li {
  display: flex;
  gap: 0.9rem;
  margin-bottom: 0.55rem;
  font-size: 0.955rem;
}

.dated .when {
  flex: 0 0 6.4rem;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
  font-size: 0.875rem;
  padding-top: 0.08rem;
}

.dated.roomy li { margin-bottom: 1.15rem; }

.dated .what { flex: 1; }

.dated .sub {
  display: block;
  color: var(--muted);
  font-size: 0.885rem;
  line-height: 1.5;
}

.upcoming {
  display: inline-block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 3px;
  padding: 0 0.3rem;
  vertical-align: 1px;
  margin-left: 0.35rem;
}

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

.pubs { margin: 0; padding: 0; list-style: none; }

.pubs > li {
  margin-bottom: 1.75rem;
  padding-bottom: 1.75rem;
  border-bottom: 1px solid var(--rule);
}

.pubs > li:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: 0;
}

.pubs .title {
  font-weight: 600;
  display: block;
  margin-bottom: 0.22rem;
  line-height: 1.4;
}

.pubs .authors {
  color: var(--muted);
  font-size: 0.9rem;
  display: block;
  line-height: 1.5;
}

.pubs .authors .me { color: var(--fg); font-weight: 600; }

.pubs .venue {
  color: var(--faint);
  font-size: 0.875rem;
  display: block;
  margin-top: 0.1rem;
}

.pubs .tldr {
  margin: 0.62rem 0 0;
  font-size: 0.925rem;
  color: var(--muted);
  line-height: 1.58;
}

.refs {
  margin-top: 0.62rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  font-size: 0.79rem;
}

.refs a {
  border: 1px solid var(--chip-bd);
  background: var(--chip-bg);
  border-radius: 4px;
  padding: 0.06rem 0.44rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.refs a:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }

/* ---------- categorised groups (current projects) ---------- */

.cat { margin-bottom: 1.7rem; }
.cat:last-child { margin-bottom: 0; }

.cat h3 {
  font-size: 0.775rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 0 0 0.65rem;
}

/* ---------- collapse toggle (injected by site.js) ---------- */

.morebtn {
  margin-top: 1rem;
  cursor: pointer;
  border: 1px solid var(--chip-bd);
  background: var(--chip-bg);
  border-radius: 999px;
  padding: 0.22rem 0.85rem;
  font: inherit;
  font-size: 0.855rem;
  color: var(--muted);
}

.morebtn:hover { border-color: var(--accent); color: var(--accent); }

.morebtn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.morebtn[aria-expanded="false"]::after { content: " ↓"; }
.morebtn[aria-expanded="true"]::after  { content: " ↑"; }

.pubs + .morebtn { margin-top: 0.4rem; }

/* ---------- readings ---------- */

.readings { margin: 0; padding: 0; list-style: none; }

.readings li {
  margin-bottom: 1.05rem;
  font-size: 0.955rem;
  line-height: 1.5;
}

.readings li:last-child { margin-bottom: 0; }

.readings .who {
  color: var(--faint);
  font-size: 0.875rem;
}

.readings .why {
  display: block;
  color: var(--muted);
  font-size: 0.885rem;
  line-height: 1.5;
  margin-top: 0.1rem;
}

/* ---------- media ---------- */

.media { margin: 0; padding: 0; list-style: none; }

.media li {
  margin-bottom: 1.15rem;
  font-size: 0.96rem;
}

.media li:last-child { margin-bottom: 0; }

.media .outlet {
  color: var(--faint);
  font-size: 0.79rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  display: block;
  margin-bottom: 0.1rem;
}

.media .note {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0.14rem 0 0;
  line-height: 1.55;
}

/* ---------- plain lists (academic info, projects) ---------- */

.plain { margin: 0; padding: 0; list-style: none; }

.plain li {
  margin-bottom: 0.85rem;
  font-size: 0.96rem;
  line-height: 1.55;
}

.plain li:last-child { margin-bottom: 0; }

.plain .sub {
  display: block;
  color: var(--muted);
  font-size: 0.9rem;
}

.plain strong { font-weight: 600; }

/* ---------- affiliations ---------- */

.affs {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(13.5rem, 1fr));
  gap: 0.8rem;
}

.aff {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  height: 100%;
  padding: 0.85rem;
  border: 1px solid var(--rule);
  border-radius: 8px;
  color: inherit;
}

.aff:hover { border-color: var(--accent); text-decoration: none; }
.aff:hover .affname { color: var(--accent); }

/* Logos sit on a white plate so dark-on-transparent marks and marks with a
   baked-in white background both stay legible in either theme. */
.plate {
  display: flex;
  align-items: center;
  height: 44px;
  padding: 0.3rem 0.5rem;
  background: #fff;
  border-radius: 5px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.07);
}

.plate img {
  display: block;
  max-height: 28px;
  max-width: 100%;
  width: auto;
}

.plate .initials {
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: #5a5a5a;
}

.affname {
  font-weight: 600;
  font-size: 0.915rem;
  line-height: 1.35;
}

.affrole {
  color: var(--muted);
  font-size: 0.845rem;
  line-height: 1.4;
  margin-top: -0.25rem;
}

/* ---------- affiliation tags on papers and projects ----------
   Not applied anywhere yet — see the README for how to attach one. */

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.55rem;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 0.32rem;
  border: 1px solid var(--chip-bd);
  background: var(--chip-bg);
  border-radius: 999px;
  padding: 0.1rem 0.52rem;
  font-size: 0.74rem;
  color: var(--muted);
}

.tag:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }

.tag img {
  height: 13px;
  width: auto;
  background: #fff;
  border-radius: 2px;
  padding: 1px 2px;
}

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

footer {
  margin-top: 3.6rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--rule);
  color: var(--faint);
  font-size: 0.82rem;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

footer a { color: var(--faint); }
footer a:hover { color: var(--accent); }

#theme {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: var(--faint);
  cursor: pointer;
}
#theme:hover { color: var(--accent); }

/* ---------- mobile ---------- */

@media (max-width: 560px) {
  .wrap { padding-top: 2.25rem; }
  header.id {
    flex-direction: column;
    align-items: flex-start;
    gap: 1.05rem;
  }
  header.id img { width: 92px; height: 92px; flex-basis: 92px; }
  h1 { font-size: 1.62rem; }
  .nav ul { gap: 1rem; }
  .dated li { flex-direction: column; gap: 0.1rem; }
  .dated .when { flex-basis: auto; }
  h2 { flex-direction: column; gap: 0.15rem; }
}
