:root {
  --bg: #ffffff;
  --text: #1f2328;
  --muted: #6b7280;
  --border: #e5e7eb;
  --accent: #2f5d8a;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111418;
    --text: #e6e8eb;
    --muted: #9aa1ab;
    --border: #262b33;
    --accent: #8ab4e0;
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: "Inter", system-ui, sans-serif;
  font-size: 17px;
  line-height: 1.65;
  background: var(--bg);
  color: var(--text);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.nav {
  max-width: 760px; margin: 0 auto;
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 0.5rem;
  padding: 1.5rem 1rem;
}
.nav .name { color: var(--text); font-weight: 600; }
.nav nav { display: flex; gap: 1.25rem; font-size: 0.95rem; }
.nav nav a { color: var(--muted); }
.nav nav a:hover { color: var(--text); text-decoration: none; }

main { max-width: 760px; margin: 0 auto; padding: 0 1rem; }
section { padding: 2.5rem 0; border-top: 1px solid var(--border); }
section.intro { border-top: none; padding-top: 3rem; }

h1 { font-size: 2.4rem; font-weight: 600; letter-spacing: -0.02em; line-height: 1.2; }
.lead { color: var(--muted); font-size: 1.15rem; margin: 0.25rem 0 1.5rem; }
.intro p + p { margin-top: 1rem; }
.links { display: flex; gap: 1.25rem; font-weight: 500; }

h2 { font-size: 1.4rem; font-weight: 600; margin-bottom: 1.25rem; }
h3 {
  font-size: 0.8rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--muted); margin: 1.75rem 0 0.75rem;
}
h2 + h3 { margin-top: 0; }

.papers { list-style: none; display: flex; flex-direction: column; gap: 1.1rem; }
.papers li { display: flex; flex-direction: column; }
.papers a, .papers strong { font-weight: 500; }
.papers span { color: var(--muted); font-size: 0.93rem; }
.papers .venue { font-size: 0.88rem; }

.plain { list-style: none; display: flex; flex-direction: column; gap: 0.35rem; }
.muted { color: var(--muted); font-size: 0.9rem; }
#teaching > .muted { margin: -0.75rem 0 1.25rem; }

footer {
  max-width: 760px; margin: 2rem auto 0; padding: 2rem 1rem 3rem;
  border-top: 1px solid var(--border);
  color: var(--muted); font-size: 0.88rem;
}

/* Sticky menu that follows you down the page */
.nav-wrap {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.nav { padding: 1rem; }
section { scroll-margin-top: 4rem; }

/* Intro with photo */
.intro-grid { display: grid; grid-template-columns: 1fr 180px; gap: 2.5rem; align-items: start; }
.photo {
  width: 180px; height: 180px; object-fit: cover; object-position: center 25%;
  border-radius: 50%; border: 1px solid var(--border);
}
@media (max-width: 640px) {
  .intro-grid { grid-template-columns: 1fr; gap: 1.5rem; }
  .photo { order: -1; width: 140px; height: 140px; }
}

/* Coauthor links: quiet, underlined on hover */
.papers a.co {
  font-weight: 400; color: inherit;
  text-decoration: underline; text-decoration-color: var(--border); text-underline-offset: 3px;
}
.papers a.co:hover { color: var(--accent); text-decoration-color: currentColor; }

/* Larger portrait, rounded rectangle */
.intro-grid { grid-template-columns: 1fr 240px; }
.photo {
  width: 240px; height: 300px; object-position: center 20%;
  border-radius: 8px;
}
@media (max-width: 640px) {
  .intro-grid { grid-template-columns: 1fr; }
  .photo { width: 200px; height: 250px; }
}

/* Vertically centre the photo against the intro text; name needs spacing without the subtitle */
.intro-grid { align-items: center; }
.intro h1 { margin-bottom: 1.25rem; }

/* Research: stronger subsection headings */
#research h3 {
  display: flex; align-items: center; gap: 0.6rem;
  font-size: 1.1rem; font-weight: 600; letter-spacing: -0.01em; text-transform: none;
  color: var(--text);
  margin: 2.75rem 0 1.25rem;
}
#research h2 + h3 { margin-top: 0.5rem; }
#research h3::after { content: ""; flex: 1; height: 1px; background: var(--border); }
#research h3 .count {
  font-size: 0.75rem; font-weight: 500; line-height: 1;
  padding: 0.25rem 0.5rem; border-radius: 999px;
  color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent);
}

/* Research: paper entries */
#research .papers { gap: 1.4rem; }
#research .papers li { padding-left: 1rem; border-left: 2px solid var(--border); transition: border-color 0.2s; }
#research .papers li:hover { border-left-color: var(--accent); }
#research .papers > li > a:first-child, #research .papers strong { font-size: 1.02rem; line-height: 1.45; margin-bottom: 0.2rem; }
#research .papers .venue { margin-top: 0.1rem; color: var(--text); opacity: 0.75; }

/* Selected work */
.nav nav { flex-wrap: wrap; row-gap: 0.25rem; }
.feature { padding: 0.5rem 0 2.5rem; }
.feature + .feature { border-top: 1px solid var(--border); padding-top: 2.5rem; }
.feature:last-child { padding-bottom: 0.5rem; }
h3.feature-title {
  font-size: 1.2rem; font-weight: 600; letter-spacing: -0.01em; line-height: 1.4;
  text-transform: none; color: var(--text); margin: 0 0 0.4rem;
}
.feature-title a { color: var(--text); }
.feature-title a:hover { color: var(--accent); text-decoration: none; }
.feature-meta { color: var(--muted); font-size: 0.93rem; }
.feature-meta > span:first-child { color: inherit; }
.feature-meta a.co {
  color: inherit; text-decoration: underline; text-decoration-color: var(--border); text-underline-offset: 3px;
}
.feature-meta a.co:hover { color: var(--accent); text-decoration-color: currentColor; }
.feature-meta .venue { color: var(--text); opacity: 0.75; }
.feature figure {
  margin: 1.5rem 0 1.25rem;
  background: #fff; border: 1px solid var(--border); border-radius: 8px;
  padding: 1rem;
}
.feature figure img { display: block; width: 100%; height: auto; }
.feature figure.narrow img { max-width: 420px; margin: 0 auto; }
.feature figcaption { font-size: 0.85rem; color: #6b7280; margin-top: 0.75rem; text-align: center; }
.abstract { font-size: 0.95rem; line-height: 1.7; }
.feature figure.medium img { max-width: 620px; margin: 0 auto; }

/* IOS11 interactive demo */
.ios-tool { max-width: 480px; margin-left: auto !important; margin-right: auto !important; }
#ios-screen { display: block; width: 100%; height: auto; border: 1px solid #d3d3d3; border-radius: 4px; }
#ios-screen circle { fill: none; stroke: #1f2328; stroke-width: 1.5; transition: cx 0.15s ease-out; }
#ios-screen text { font: 22px Inter, Arial, sans-serif; fill: #1f2328; text-anchor: middle; dominant-baseline: middle; transition: x 0.15s ease-out; }
#ios-slider { width: 100%; margin-top: 1rem; accent-color: #2f5d8a; cursor: pointer; }
.ios-ticks { display: flex; justify-content: space-between; padding: 0 8px; }
.ios-ticks span { width: 1px; height: 8px; background: #a3a3a3; }
.ios-value { display: block; margin-top: 0.35rem; color: #1f2328; }

/* Collapsible abstracts */
.papers details { margin-top: 0.35rem; }
.papers summary {
  display: inline-flex; align-items: center; gap: 0.35rem;
  font-size: 0.82rem; font-weight: 500; color: var(--accent);
  cursor: pointer; list-style: none; user-select: none;
}
.papers summary::-webkit-details-marker { display: none; }
.papers summary::before { content: "▸"; font-size: 0.75rem; transition: transform 0.15s; }
.papers details[open] summary::before { transform: rotate(90deg); }
.papers summary:hover { text-decoration: underline; }
.papers details p {
  margin-top: 0.5rem; font-size: 0.9rem; line-height: 1.65; color: var(--text); opacity: 0.85;
}

/* Footer */
footer.site-footer {
  max-width: none; margin: 3rem 0 0; padding: 2.5rem 1rem 2rem;
  border-top: 1px solid var(--border);
  background: color-mix(in srgb, var(--text) 3%, var(--bg));
}
.footer-grid {
  max-width: 760px; margin: 0 auto;
  display: grid; grid-template-columns: 1.2fr 1fr 1fr; gap: 2rem;
}
.site-footer p { line-height: 1.6; }
.site-footer p + p { margin-top: 0.35rem; }
.footer-name { color: var(--text); font-weight: 600; }
.footer-label {
  font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text); margin-bottom: 0.5rem;
}
.footer-copy { max-width: 760px; margin: 2rem auto 0 !important; font-size: 0.8rem; }
@media (max-width: 640px) { .footer-grid { grid-template-columns: 1fr; gap: 1.5rem; } }

/* Teaching headings match Research */
#teaching h3 {
  font-size: 1.1rem; font-weight: 600; letter-spacing: -0.01em; text-transform: none;
  color: var(--text); margin: 2rem 0 0.9rem;
}
#teaching > .muted + h3 { margin-top: 0; }

/* Tool pages */
.tool-page section > p + p, .tool-page section > p + .tool-frame, .tool-page section > .papers + p { margin-top: 1rem; }
.tool-page .ios-tool {
  margin: 0.5rem auto 0; background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 1rem;
}
.tool-page .ios-tool figcaption { font-size: 0.85rem; color: #6b7280; margin-top: 0.75rem; text-align: center; }
.tool-frame { margin-top: 1rem; background: #fff; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.tool-frame iframe { display: block; width: 100%; height: 1000px; border: 0; overflow: hidden; }
.tool-note { color: var(--muted); font-size: 0.93rem; }
.citation {
  margin-top: 1rem; padding: 1rem 1.25rem; border-left: 3px solid var(--accent);
  background: color-mix(in srgb, var(--accent) 6%, var(--bg)); border-radius: 0 8px 8px 0;
  font-size: 0.93rem; line-height: 1.65;
}
.citation a { display: block; margin-top: 0.4rem; }

/* Keep subscripts from stretching line height */
sub { font-size: 0.7em; line-height: 0; vertical-align: -0.25em; }
