:root {
  --bg: #fbfaf7;
  --surface: #ffffff;
  --text: #1c1c1e;
  --muted: #6b6b70;
  --accent: #1f5f3f;
  --accent-soft: #e4efe7;
  --rule: #e4e1da;
  --max: 46rem;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #131416;
    --surface: #1b1d20;
    --text: #e8e6e1;
    --muted: #9a9a9f;
    --accent: #86cfa6;
    --accent-soft: #1d2b24;
    --rule: #2b2e33;
  }
}

:root[data-theme="dark"] {
  --bg: #131416;
  --surface: #1b1d20;
  --text: #e8e6e1;
  --muted: #9a9a9f;
  --accent: #86cfa6;
  --accent-soft: #1d2b24;
  --rule: #2b2e33;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 3.5rem; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 1.0625rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 1rem;
}

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

/* Masthead */
.masthead {
  padding: 4rem 0 2.5rem;
  border-bottom: 1px solid var(--rule);
  background: linear-gradient(180deg, var(--accent-soft) 0%, var(--bg) 100%);
}
.masthead h1 {
  margin: 0;
  font-size: clamp(2.25rem, 6vw, 3.25rem);
  line-height: 1.1;
  letter-spacing: -0.02em;
  font-weight: 700;
}
.tagline {
  margin: 0.5rem 0 0;
  color: var(--muted);
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 500;
}
.intro {
  margin: 1.5rem 0 0;
  max-width: 38rem;
  font-size: 1.125rem;
}
.links {
  margin-top: 1.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}
.links a {
  display: inline-block;
  padding: 0.4rem 0.9rem;
  border: 1px solid var(--accent);
  border-radius: 999px;
  font-size: 0.95rem;
  font-weight: 500;
}
.links a:hover { background: var(--accent); color: var(--bg); text-decoration: none; }

/* Section nav */
.toc {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--rule);
}
.toc .wrap {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  overflow-x: auto;
  padding-top: 0.6rem;
  padding-bottom: 0.6rem;
  font-size: 0.9rem;
  font-weight: 500;
  letter-spacing: 0.02em;
}
.toc a { color: var(--muted); white-space: nowrap; }
.toc a:hover { color: var(--accent); text-decoration: none; }
.theme-toggle {
  margin-left: auto;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.9rem;
  height: 1.9rem;
  padding: 0;
  border: 1px solid var(--rule);
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.theme-toggle:hover { color: var(--accent); border-color: var(--accent); }
.theme-toggle svg { width: 1rem; height: 1rem; }
.theme-toggle .moon { display: none; }
:root[data-theme="dark"] .theme-toggle .sun { display: none; }
:root[data-theme="dark"] .theme-toggle .moon { display: inline; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .sun { display: none; }
  :root:not([data-theme="light"]) .theme-toggle .moon { display: inline; }
}

/* Sections */
main { padding: 1rem 1rem 3rem; }
section { padding: 2.5rem 0; border-bottom: 1px solid var(--rule); }
section:last-of-type { border-bottom: 0; }
h2 {
  margin: 0 0 1.5rem;
  font-size: 1.5rem;
  letter-spacing: -0.01em;
}
h3 { margin: 0; font-size: 1.15rem; }
.subhead {
  margin: 2.25rem 0 0.75rem;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}

/* Jobs */
.job { margin-bottom: 2rem; }
.job:last-child { margin-bottom: 0; }
.job-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}
.role { margin: 0.1rem 0 0; color: var(--muted); }
.meta {
  margin: 0;
  flex-shrink: 0;
  text-align: right;
  font-size: 0.9rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.meta span { font-size: 0.85rem; }
.job ul { margin: 0.75rem 0 0; padding-left: 1.2rem; }
.job li { margin: 0.3rem 0; }
.job li::marker { color: var(--accent); }
sup { font-size: 0.7em; line-height: 0; }
sup a { color: var(--muted); }

/* Timelines */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li {
  display: grid;
  grid-template-columns: 5rem 1fr;
  gap: 0.75rem;
  padding: 0.5rem 0;
  border-top: 1px solid var(--rule);
}
.timeline li:first-child { border-top: 0; }
.year {
  color: var(--muted);
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
  padding-top: 0.15rem;
}
.pubs em { font-style: italic; }
.more { margin: 1.25rem 0 0; color: var(--muted); font-size: 0.95rem; }

/* Skills */
.skills { margin: 0; display: grid; grid-template-columns: 7rem 1fr; gap: 0.5rem 1rem; }
.skills dt { color: var(--muted); font-weight: 500; }
.skills dd { margin: 0; }

/* References */
.refs { margin: 0; padding-left: 1.4rem; }
.refs li { margin: 0.4rem 0; }
.src { color: var(--muted); font-size: 0.9rem; }
.src::before { content: "— "; }

footer { padding: 2rem 1rem 3rem; color: var(--muted); font-size: 0.9rem; }

@media (max-width: 600px) {
  .masthead { padding-top: 2.75rem; }
  .job-head { flex-direction: column; gap: 0.25rem; }
  .meta { text-align: left; }
  .meta br { display: none; }
  .meta span::before { content: " · "; }
  .timeline li { grid-template-columns: 4rem 1fr; }
  .skills { grid-template-columns: 1fr; gap: 0.1rem 0; }
  .skills dd { margin-bottom: 0.75rem; }
}
