:root {
  --bg: #fcfcfa;
  --text: #1f2328;
  --muted: #5d6670;
  --rule: #e4e4df;
  --accent: #1d4f8a;
  --figure-bg: #ffffff;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15171a;
    --text: #e6e6e3;
    --muted: #9aa1a9;
    --rule: #2c3036;
    --accent: #8fb8ea;
    --figure-bg: #ffffff;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 72px; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 56px 24px 48px;
}

/* Top bar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(150%) blur(8px);
  -webkit-backdrop-filter: saturate(150%) blur(8px);
  border-bottom: 1px solid var(--rule);
}
.topbar-inner {
  max-width: 720px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px 24px;
  flex-wrap: wrap;
}
.brand {
  font-family: var(--serif);
  font-size: 1.08rem;
  color: var(--text);
}
.brand:hover { border-bottom-color: transparent; color: var(--accent); }
.sections { display: flex; flex-wrap: wrap; gap: 4px 20px; font-size: 0.92rem; }
.sections a { color: var(--muted); }
.sections a:hover { color: var(--accent); }

a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.15s ease;
}
a:hover { border-bottom-color: currentColor; }

h1, h2, h3 { font-family: var(--serif); font-weight: 500; line-height: 1.25; }

h1 { font-size: 2.3rem; margin: 0 0 4px; letter-spacing: -0.01em; }

h2 {
  font-size: 1.3rem;
  margin: 56px 0 18px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--rule);
}

h3 { font-size: 1.12rem; margin: 0 0 2px; }
h3 a { color: var(--text); }
h3 a:hover { color: var(--accent); }

p { margin: 0 0 14px; }

/* Intro */
.intro {
  display: flex;
  align-items: center;
  gap: 32px;
  margin-bottom: 36px;
}
.portrait {
  width: 136px;
  height: 136px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--rule);
}
.tagline { color: var(--muted); margin: 0 0 12px; font-size: 1.02rem; }
.links { display: flex; flex-wrap: wrap; gap: 6px 20px; font-size: 0.95rem; }

.about p:last-child { margin-bottom: 0; }

/* Interests */
.interests { list-style: none; padding: 0; margin: 0; }
.interests li { margin-bottom: 10px; color: var(--muted); }
.interests span {
  display: block;
  color: var(--text);
  font-weight: 600;
}

/* Research and projects */
.item { margin-bottom: 36px; }
.item:last-child { margin-bottom: 0; }
.meta { color: var(--muted); font-size: 0.92rem; margin-bottom: 10px; }
.item-links { font-size: 0.92rem; margin: 0; }

figure { margin: 22px 0; }
figure img {
  display: block;
  width: 100%;
  height: auto;
  background: var(--figure-bg);
  border: 1px solid var(--rule);
  border-radius: 6px;
}
figcaption { color: var(--muted); font-size: 0.88rem; margin-top: 10px; line-height: 1.55; }

/* Experience and education */
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li {
  display: grid;
  grid-template-columns: 112px 1fr;
  gap: 16px;
  margin-bottom: 18px;
}
.timeline li:last-child { margin-bottom: 0; }
.when { color: var(--muted); font-size: 0.92rem; padding-top: 1px; font-variant-numeric: tabular-nums; }
.timeline strong { font-weight: 600; }

/* Contact */
.contact { list-style: none; padding: 0; margin: 18px 0 0; }
.contact li {
  display: grid;
  grid-template-columns: 112px 1fr;
  gap: 16px;
  margin-bottom: 8px;
  overflow-wrap: anywhere;
}
.contact span { color: var(--muted); font-size: 0.92rem; padding-top: 1px; }

footer {
  margin-top: 64px;
  padding-top: 20px;
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-size: 0.88rem;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}
footer p { margin: 0; }

@media (max-width: 600px) {
  body { font-size: 16px; }
  main { padding-top: 36px; }
  html { scroll-padding-top: 96px; }
  .topbar-inner { padding: 10px 20px; }
  .sections { gap: 2px 12px; font-size: 0.82rem; }
  .wide-only { display: none; }
  .intro { flex-direction: column; align-items: flex-start; gap: 20px; }
  .portrait { width: 112px; height: 112px; }
  h1 { font-size: 2rem; }
  .timeline li, .contact li { grid-template-columns: 1fr; gap: 2px; }
  .contact li { margin-bottom: 12px; }
}

/* Tools page */
.tool {
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 20px 22px;
  margin-top: 28px;
}
.tool-actions { margin: 4px 0 0; }
.tool-open {
  display: inline-block;
  padding: 6px 14px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  font-size: 0.92rem;
}
.tool-open:hover { background: var(--accent); color: var(--bg); border-bottom-color: var(--accent); }
