:root {
  --bg: #ffffff;
  --bg-alt: #f6f6f4;
  --text: #14161a;
  --text-dim: #55585f;
  --border: #e5e5e2;
  --accent: #14161a;
  --accent-contrast: #ffffff;
  --radius: 10px;
  --max-width: 920px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
}

:root[data-theme="dark"] {
  --bg: #121212;
  --bg-alt: #191a1c;
  --text: #f2f2f0;
  --text-dim: #9a9da3;
  --border: #2a2b2e;
  --accent: #f2f2f0;
  --accent-contrast: #121212;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121212;
    --bg-alt: #191a1c;
    --text: #f2f2f0;
    --text-dim: #9a9da3;
    --border: #2a2b2e;
    --accent: #f2f2f0;
    --accent-contrast: #121212;
  }
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background 0.2s ease, color 0.2s ease;
}

a {
  color: inherit;
  text-decoration: none;
}

img, svg { display: block; max-width: 100%; }

.progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 2px;
  width: 0%;
  background: var(--text);
  z-index: 1000;
  transition: width 0.1s linear;
}

/* Nav */
.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px max(24px, calc((100% - var(--max-width)) / 2));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.nav-logo {
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.02em;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 28px;
  font-size: 0.92rem;
  color: var(--text-dim);
}

.nav-links a {
  transition: color 0.15s ease;
}

.nav-links a:hover {
  color: var(--text);
}

.nav-cta {
  padding: 7px 16px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text) !important;
}

.nav-cta:hover {
  border-color: var(--text);
}

.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 32px;
  height: 32px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}

.nav-toggle span {
  display: block;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  margin-left: 20px;
}

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

.icon-moon { display: none; }
:root[data-theme="dark"] .icon-sun { display: none; }
:root[data-theme="dark"] .icon-moon { display: block; }

/* Layout */
.section {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 100px 24px;
  border-bottom: 1px solid var(--border);
}

.section:last-of-type { border-bottom: none; }

.section-title {
  display: flex;
  align-items: baseline;
  gap: 12px;
  font-size: 1.6rem;
  margin: 0 0 48px;
}

.section-num {
  font-size: 0.85rem;
  color: var(--text-dim);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.subsection-title {
  font-size: 1.1rem;
  margin: 56px 0 24px;
  color: var(--text-dim);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.85rem;
}

/* Hero */
.hero {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 120px 24px 90px;
}

.hero-eyebrow {
  color: var(--text-dim);
  font-size: 0.95rem;
  margin: 0 0 18px;
  font-weight: 500;
}

.hero-title {
  font-size: clamp(2.6rem, 7vw, 4.4rem);
  line-height: 1.05;
  margin: 0 0 24px;
  letter-spacing: -0.02em;
  font-weight: 700;
}

.hero-sub {
  font-size: 1.15rem;
  color: var(--text-dim);
  max-width: 620px;
  margin: 0 0 40px;
}

.hero-actions {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 64px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 13px 26px;
  border-radius: 999px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: transform 0.15s ease, opacity 0.15s ease, border-color 0.15s ease;
}

.btn:hover { transform: translateY(-1px); }

.btn-primary {
  background: var(--accent);
  color: var(--accent-contrast);
}

.btn-primary:hover { opacity: 0.85; }

.btn-ghost {
  border-color: var(--border);
  color: var(--text);
}

.btn-ghost:hover { border-color: var(--text); }

.hero-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 24px;
  margin: 0;
  padding-top: 40px;
  border-top: 1px solid var(--border);
}

.hero-stats dt {
  font-size: 1.8rem;
  font-weight: 700;
  margin: 0;
}

.hero-stats dd {
  margin: 4px 0 0;
  color: var(--text-dim);
  font-size: 0.88rem;
}

/* About */
.about-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 56px;
}

.about-text {
  color: var(--text-dim);
  font-size: 1.02rem;
  margin: 0;
}

.about-facts {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  font-size: 0.95rem;
}

.about-facts a { text-decoration: underline; text-underline-offset: 2px; }

.stack {
  margin-top: 72px;
}

.stack-heading {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  margin: 0 0 24px;
  font-weight: 600;
}

.stack-groups {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 24px;
}

.stack-group h4 {
  margin: 0 0 6px;
  font-size: 0.92rem;
}

.stack-group p {
  margin: 0;
  color: var(--text-dim);
  font-size: 0.88rem;
}

/* Timeline */
.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
}

.timeline-item {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 24px;
  padding: 28px 0;
  border-top: 1px solid var(--border);
}

.timeline-item:first-child { border-top: none; }

.timeline-date {
  color: var(--text-dim);
  font-size: 0.88rem;
  white-space: nowrap;
}

.timeline-body h3 {
  margin: 0 0 8px;
  font-size: 1.05rem;
}

.timeline-co {
  color: var(--text-dim);
  font-weight: 400;
}

.timeline-body p {
  margin: 0;
  color: var(--text-dim);
  font-size: 0.92rem;
}

/* Cards */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 20px;
}

.card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.card:hover {
  border-color: var(--text);
  transform: translateY(-2px);
}

.card h3 {
  margin: 0 0 4px;
  font-size: 1.05rem;
}

.card-sub {
  color: var(--text-dim);
  font-size: 0.82rem;
  margin: 0 0 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.card p:not(.card-sub) {
  margin: 0 0 16px;
  color: var(--text-dim);
  font-size: 0.92rem;
}

.card-links {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 0.85rem;
}

.card-links a {
  text-decoration: underline;
  text-underline-offset: 3px;
  color: var(--text);
}

/* Publications */
.pub-list {
  list-style: none;
  margin: 0 0 64px;
  padding: 0;
}

.pub-item {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 0;
  border-top: 1px solid var(--border);
}

.pub-item:first-child { border-top: none; }

.pub-item h3 {
  margin: 0 0 6px;
  font-size: 1rem;
}

.pub-item p {
  margin: 0;
  color: var(--text-dim);
  font-size: 0.88rem;
}

.pub-item > a {
  white-space: nowrap;
  text-decoration: underline;
  text-underline-offset: 3px;
  font-size: 0.88rem;
}

.misc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 24px;
}

.misc-block {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.misc-block h3 {
  margin: 0 0 10px;
  font-size: 1rem;
}

.misc-block p {
  margin: 0 0 16px;
  color: var(--text-dim);
  font-size: 0.92rem;
}

/* Contact */
.contact-section {
  text-align: center;
}

.contact-section .section-title {
  justify-content: center;
}

.contact-lead {
  color: var(--text-dim);
  font-size: 1.05rem;
  max-width: 480px;
  margin: 0 auto 36px;
}

.contact-actions {
  display: flex;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 44px;
}

.contact-social {
  display: flex;
  justify-content: center;
  gap: 28px;
  font-size: 0.9rem;
  color: var(--text-dim);
}

.contact-social a:hover { color: var(--text); }

/* Footer */
.footer {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 32px 24px 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--text-dim);
  font-size: 0.85rem;
}

.to-top {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-size: 1rem;
}

.to-top:hover { border-color: var(--text); }

/* Reveal animation */
.reveal {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
  .reveal {
    opacity: 1;
    transform: none;
    transition: none;
  }
  html { scroll-behavior: auto; }
}

/* Responsive */
@media (max-width: 760px) {
  .nav-toggle { display: flex; }

  .nav-links {
    position: fixed;
    top: 65px;
    left: 0;
    right: 0;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
    padding: 8px 24px 20px;
    transform: translateY(-8px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
  }

  .nav-links.is-open {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
  }

  .nav-links a {
    width: 100%;
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
  }

  .nav-links a:last-child { border-bottom: none; }

  .nav-cta {
    border: none;
    padding: 14px 0;
  }

  .hero { padding-top: 90px; }

  .hero-stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .about-grid {
    grid-template-columns: 1fr;
    gap: 32px;
  }

  .timeline-item {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .pub-item {
    flex-direction: column;
    align-items: flex-start;
  }

  .section { padding: 72px 20px; }
}
