:root {
  --bg: #0A0A0A;
  --primary: #EDEDED;
  --muted: #737373;
  --subtle: #A3A3A3;
  --hairline: #1A1A1A;
  --hairline-hover: #333333;
  --container: 720px;
  --u: 8px;
  --gap-section: 160px;
  --gap-section-sm: 96px;
  --gap-element: 32px;
  --gap-list: 64px;
  --pad-x: 32px;
  --nav-h: 80px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

body {
  background: var(--bg);
  color: var(--primary);
  font-family: 'Inter', sans-serif;
  font-size: 15px;
  font-weight: 400;
  line-height: 1.6;
  letter-spacing: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

::selection {
  background: #3c4a5e;
  color: var(--primary);
}

a {
  color: inherit;
  text-decoration: none;
  transition: color .25s ease, border-color .25s ease;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* ─── Nav ──────────────────────────────────────────────────────── */
.site-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: var(--bg);
  border-bottom: 1px solid var(--hairline);
  z-index: 50;
}

.nav-inner {
  max-width: var(--container);
  margin: 0 auto;
  height: var(--nav-h);
  padding: 0 var(--pad-x);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--primary);
}

.nav-links {
  display: flex;
  gap: 28px;
}

.nav-links a,
.nav-email {
  font-size: 14px;
  font-weight: 300;
  letter-spacing: -0.01em;
  color: var(--muted);
}

.nav-links a:hover,
.nav-email:hover,
.nav-links a.active {
  color: var(--primary);
}

/* ─── Page ─────────────────────────────────────────────────────── */
.page {
  max-width: var(--container);
  margin: 0 auto;
  padding: calc(var(--nav-h) + 96px) var(--pad-x) 64px;
}

/* ─── Typography helpers ───────────────────────────────────────── */
.display {
  font-size: 48px;
  font-weight: 500;
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--primary);
}

.h1 {
  font-size: 24px;
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: -0.01em;
  color: var(--primary);
}

.h2 {
  font-size: 18px;
  font-weight: 500;
  line-height: 1.4;
  letter-spacing: -0.01em;
  color: var(--primary);
}

.body-lg {
  font-size: 18px;
  line-height: 1.6;
  color: var(--muted);
}

.body-md {
  font-size: 15px;
  line-height: 1.6;
  color: var(--subtle);
}

.label-caps {
  display: inline-block;
  font-size: 12px;
  font-weight: 500;
  line-height: 1;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.metadata {
  font-size: 13px;
  font-weight: 400;
  line-height: 1.4;
  color: var(--muted);
}

/* ─── Section primitives ───────────────────────────────────────── */
.section {
  margin-bottom: var(--gap-section);
}

.section-header {
  border-top: 1px solid var(--hairline);
  padding-top: 24px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 48px;
}

.section-header .count {
  color: var(--hairline-hover);
}

/* ─── Home page density override ───────────────────────────────── */
body.page-home .page { padding-top: calc(var(--nav-h) + 56px); padding-bottom: 32px; }
body.page-home .hero { margin-bottom: 72px; }
body.page-home .section { margin-bottom: 72px; }
body.page-home .section:last-of-type { margin-bottom: 0; }
body.page-home .section-header { padding-top: 16px; margin-bottom: 24px; }
body.page-home .role-row { padding: 18px 0; }
body.page-home .site-footer { margin-top: 48px; }
body.page-home .site-footer .footer-inner { padding: 56px var(--pad-x); }

/* ─── Hero (Home) ──────────────────────────────────────────────── */
.hero {
  margin-bottom: var(--gap-section);
}

.hero .label-caps {
  margin-bottom: 16px;
}

.hero .display {
  max-width: 500px;
  margin-bottom: 32px;
}

.hero .body-lg {
  max-width: 580px;
  margin-bottom: 20px;
}

.hero .body-lg:last-child {
  margin-bottom: 0;
}

.hero-lede { color: var(--primary); }
.hero-bio { color: var(--muted); }

.hero-actions {
  display: flex;
  gap: 32px;
  align-items: center;
}

.hero-actions a {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--primary);
  border-bottom: 1px solid var(--hairline-hover);
  padding-bottom: 4px;
}

.hero-actions a:hover {
  border-color: var(--primary);
}

/* ─── Selected experience (Home) ───────────────────────────────── */
.role-list {
  display: flex;
  flex-direction: column;
}

.role-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 24px 0;
  border-bottom: 1px solid var(--hairline);
  gap: 24px;
}

.role-row .role-title {
  color: var(--primary);
}

.role-row .role-sub {
  display: block;
  margin-top: 6px;
}

/* ─── Featured role (Home) ─────────────────────────────────────── */
a.featured-role { display: block; color: inherit; }
.featured-role + .featured-role { margin-top: 48px; padding-top: 48px; border-top: 1px solid var(--hairline); }
.featured-role-meta { display: flex; flex-direction: column; gap: 6px; margin-bottom: 20px; }
.featured-role-meta .role-title { color: var(--primary); transition: color .25s ease; }
.featured-role-summary { color: var(--muted); max-width: 620px; }
a.featured-role:hover .role-title { color: var(--subtle); }
.role-sub-line { color: var(--muted); }

/* ─── Selected projects (Home) ─────────────────────────────────── */
.featured-list {
  display: flex;
  flex-direction: column;
  gap: var(--gap-list);
}

.featured-item .h1 {
  margin-bottom: 12px;
}

.featured-item .body-md {
  max-width: 560px;
  margin-bottom: 16px;
}

.read-more {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--primary);
}

.read-more:hover {
  gap: 14px;
}

.read-more .arrow {
  transition: transform .25s ease;
}

.read-more:hover .arrow {
  transform: translateX(4px);
}

/* ─── Page header (sub-pages) ──────────────────────────────────── */
.page-header {
  margin-bottom: 96px;
}

.page-header .display {
  margin-bottom: 16px;
}

.page-header .body-lg {
  max-width: 540px;
}

/* ─── Experience timeline ──────────────────────────────────────── */
.timeline {
  position: relative;
  padding-left: 48px;
}

.timeline::before {
  content: "";
  position: absolute;
  left: 0;
  top: 4px;
  bottom: 4px;
  width: 1px;
  background: var(--hairline);
}

.timeline-entry {
  position: relative;
  margin-bottom: 96px;
}

.timeline-entry:last-child {
  margin-bottom: 0;
}

.timeline-entry::before {
  content: "";
  position: absolute;
  left: -52px;
  top: 8px;
  width: 8px;
  height: 8px;
  background: var(--primary);
  border: 4px solid var(--bg);
  box-sizing: content-box;
}

.timeline-entry.dim::before {
  background: var(--hairline-hover);
}

.timeline-meta {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 32px;
}

.timeline-meta .role-title {
  color: var(--primary);
}

.timeline-meta .role-company {
  color: var(--muted);
  font-size: 18px;
  font-weight: 500;
}

.timeline-bullets {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.timeline-bullets li {
  display: flex;
  gap: 16px;
  font-size: 15px;
  line-height: 1.6;
  color: var(--subtle);
}

.timeline-bullets li::before {
  content: "—";
  color: var(--hairline);
  padding-top: 2px;
  flex-shrink: 0;
}

/* ─── Projects (categorized) ───────────────────────────────────── */
.project-group {
  margin-bottom: var(--gap-section);
}

.project-group:last-child {
  margin-bottom: 0;
}

.project-list {
  display: flex;
  flex-direction: column;
  gap: var(--gap-list);
}

.project-item .project-title {
  color: var(--primary);
  margin-bottom: 8px;
}

.project-item .project-meta {
  margin-bottom: 12px;
}

.project-item .project-desc {
  color: var(--muted);
  max-width: 600px;
}

.project-item a.project-title:hover {
  color: var(--subtle);
}

/* ─── Writing (Logbook) ────────────────────────────────────────── */
.logbook-group {
  margin-bottom: var(--gap-section);
}

.logbook-group:last-child {
  margin-bottom: 0;
}

.logbook-feed {
  display: flex;
  flex-direction: column;
  gap: 80px;
}

.logbook-entry .entry-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}

.logbook-entry .entry-meta .meta-rule {
  flex: 1;
  height: 1px;
  background: var(--hairline);
}

.logbook-entry .h1 {
  margin-bottom: 16px;
}

.logbook-entry .body-md {
  color: var(--muted);
  margin-bottom: 16px;
  max-width: 600px;
}

.empty-state {
  color: var(--muted);
  font-size: 15px;
  padding: 32px 0;
}

/* ─── Post page ────────────────────────────────────────────────── */
.post {
  max-width: var(--container);
}

.post-header {
  margin-bottom: 48px;
}

.post-header .label-caps {
  margin-bottom: 16px;
}

.post-title {
  font-size: 36px;
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: -0.02em;
  color: var(--primary);
  margin-bottom: 16px;
}

.post-blurb {
  color: var(--muted);
  font-size: 18px;
  line-height: 1.6;
  max-width: 560px;
}

.post-body {
  color: var(--subtle);
  font-size: 16px;
  line-height: 1.75;
}

.post-body h1,
.post-body h2,
.post-body h3 {
  color: var(--primary);
  font-weight: 500;
  letter-spacing: -0.01em;
  margin-top: 64px;
  margin-bottom: 16px;
  line-height: 1.25;
}

.post-body h1 {
  font-size: 28px;
}

.post-body h2 {
  font-size: 22px;
}

.post-body h3 {
  font-size: 18px;
}

.post-body p {
  margin-bottom: 20px;
}

.post-body strong {
  color: var(--primary);
  font-weight: 500;
}

.post-body em {
  color: var(--primary);
  font-style: italic;
}

.post-body a {
  color: var(--primary);
  border-bottom: 1px solid var(--hairline-hover);
  padding-bottom: 1px;
}

.post-body a:hover {
  border-color: var(--primary);
}

.post-body ul,
.post-body ol {
  margin: 0 0 20px 24px;
}

.post-body li {
  margin-bottom: 8px;
}

.post-body img {
  margin: 32px 0;
  filter: grayscale(60%) contrast(1.05);
  border: 1px solid var(--hairline);
}

.post-body code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  background: #121212;
  border: 1px solid var(--hairline);
  padding: 2px 6px;
}

.post-body pre {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  background: #121212;
  border: 1px solid var(--hairline);
  padding: 24px;
  overflow-x: auto;
  margin-bottom: 24px;
}

.post-body pre code {
  background: none;
  border: none;
  padding: 0;
}

.post-body blockquote {
  border-left: 1px solid var(--hairline-hover);
  padding-left: 24px;
  color: var(--muted);
  font-style: italic;
  margin: 24px 0;
}

.post-footer {
  margin-top: 96px;
  padding-top: 24px;
  border-top: 1px solid var(--hairline);
}

.link-back {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.link-back:hover {
  color: var(--primary);
}

/* ─── Footer ───────────────────────────────────────────────────── */
.site-footer {
  border-top: 1px solid var(--hairline);
  background: var(--bg);
  margin-top: 96px;
}

.footer-inner {
  max-width: var(--container);
  margin: 0 auto;
  padding: 80px var(--pad-x);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.footer-copy {
  font-size: 10px;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--muted);
}

.footer-links {
  display: flex;
  gap: 32px;
}

.footer-links a {
  font-size: 10px;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--muted);
}

.footer-links a:hover {
  color: var(--primary);
  text-decoration: underline;
  text-underline-offset: 8px;
}

/* ─── Responsive ───────────────────────────────────────────────── */
@media (max-width: 720px) {
  :root {
    --gap-section: 96px;
    --gap-list: 48px;
    --pad-x: 24px;
  }

  .display {
    font-size: 36px;
  }

  .post-title {
    font-size: 28px;
  }

  .nav-inner {
    gap: 16px;
  }

  .nav-links {
    gap: 16px;
  }

  .nav-links a,
  .nav-email {
    font-size: 13px;
  }

  .brand {
    font-size: 11px;
    letter-spacing: 0.18em;
  }

  .page {
    padding-top: calc(var(--nav-h) + 64px);
  }

  .role-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .timeline {
    padding-left: 32px;
  }

  .timeline-entry::before {
    left: -36px;
  }

  .footer-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: 24px;
  }
}

@media (max-width: 480px) {
  .nav-email {
    display: none;
  }

  .nav-links {
    gap: 14px;
  }

  .nav-links a {
    font-size: 12px;
  }

  .brand {
    font-size: 10px;
  }

  .display {
    font-size: 32px;
  }

  .hero-actions {
    gap: 20px;
    flex-wrap: wrap;
  }
}