/* ============================================================
   Cristian Estévez — personal site
   Design tokens + global styles
   ============================================================ */

:root {
  /* Type stack — system-ui renders as SF Pro on Apple, Segoe on Win */
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
               "Inter", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-serif: "Newsreader", "Iowan Old Style", "Georgia", serif;
  --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;

  /* Light theme */
  --bg: #ffffff;
  --bg-soft: #f5f5f7;
  --bg-elev: #fbfbfd;
  --fg: #0b0b0c;
  --fg-2: #1d1d1f;
  --fg-3: #6e6e73;
  --fg-4: #a1a1a6;
  --line: #e6e6e7;
  --line-2: #d2d2d7;
  --accent: #0071e3;          /* iOS blue */
  --accent-hover: #0058b0;
  --shadow-1: 0 1px 2px rgba(0,0,0,0.04), 0 0 0 1px rgba(0,0,0,0.04);
  --shadow-2: 0 20px 60px -20px rgba(0,0,0,0.18), 0 8px 24px -12px rgba(0,0,0,0.10);

  /* Density (driven by tweak) */
  --density: 1;
  --space-1: calc(8px  * var(--density));
  --space-2: calc(16px * var(--density));
  --space-3: calc(24px * var(--density));
  --space-4: calc(40px * var(--density));
  --space-5: calc(64px * var(--density));
  --space-6: calc(96px * var(--density));
  --space-7: calc(160px * var(--density));

  --radius-sm: 10px;
  --radius-md: 18px;
  --radius-lg: 28px;
  --radius-xl: 40px;

  --max-w: 1280px;
}

[data-theme="dark"] {
  --bg: #000000;
  --bg-soft: #0d0d0f;
  --bg-elev: #1a1a1c;
  --fg: #f5f5f7;
  --fg-2: #e8e8ea;
  --fg-3: #98989d;
  --fg-4: #6e6e73;
  --line: #2a2a2c;
  --line-2: #3a3a3c;
  --accent: #2997ff;
  --accent-hover: #5db0ff;
  --shadow-1: 0 1px 2px rgba(0,0,0,0.6), 0 0 0 1px rgba(255,255,255,0.06);
  --shadow-2: 0 20px 60px -20px rgba(0,0,0,0.8), 0 8px 24px -12px rgba(0,0,0,0.6);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "ss01", "cv11";
  letter-spacing: -0.011em;
  transition: background-color .35s ease, color .35s ease;
}

body { overflow-x: hidden; }

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

::selection { background: var(--accent); color: #fff; }

/* ============================================================
   Typography scale
   ============================================================ */
.eyebrow {
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--accent);
  text-transform: none;
  margin: 0;
}
.h-display {
  font-size: clamp(56px, 9vw, 128px);
  line-height: 0.96;
  letter-spacing: -0.045em;
  font-weight: 600;
  margin: 0;
}
.h-hero {
  font-size: clamp(40px, 5.5vw, 80px);
  line-height: 1.04;
  letter-spacing: -0.035em;
  font-weight: 600;
  margin: 0;
  text-wrap: balance;
}
.h-section {
  font-size: clamp(32px, 4vw, 56px);
  line-height: 1.05;
  letter-spacing: -0.03em;
  font-weight: 600;
  margin: 0;
  text-wrap: balance;
}
.h-card {
  font-size: 22px;
  line-height: 1.2;
  letter-spacing: -0.018em;
  font-weight: 600;
  margin: 0;
}
.body-lg {
  font-size: clamp(18px, 1.4vw, 22px);
  line-height: 1.45;
  color: var(--fg-3);
  font-weight: 400;
  letter-spacing: -0.005em;
  margin: 0;
  text-wrap: pretty;
}
.body {
  font-size: 17px;
  line-height: 1.5;
  color: var(--fg-3);
  margin: 0;
}
.meta {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--fg-3);
  text-transform: uppercase;
}

/* ============================================================
   Container
   ============================================================ */
.container {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 clamp(20px, 4vw, 40px);
}
.container-narrow {
  max-width: 880px;
  margin: 0 auto;
  padding: 0 clamp(20px, 4vw, 40px);
}

/* ============================================================
   Nav (sticky, blurred)
   ============================================================ */
.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  background: color-mix(in oklab, var(--bg) 72%, transparent);
  border-bottom: 1px solid color-mix(in oklab, var(--line) 60%, transparent);
  transition: background-color .35s ease, border-color .35s ease;
}
.nav-inner {
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}
.nav-brand {
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--fg);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.nav-brand-mark {
  width: 18px; height: 18px;
  border-radius: 5px;
  background: var(--fg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--bg);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
}
.nav-links {
  display: flex;
  gap: clamp(16px, 2.5vw, 32px);
  align-items: center;
}
.nav-link {
  font-size: 13px;
  font-weight: 400;
  color: var(--fg-3);
  transition: color .15s ease;
}
.nav-link:hover { color: var(--fg); }
.nav-right {
  display: flex;
  align-items: center;
  gap: 12px;
}
.lang-toggle {
  display: inline-flex;
  background: var(--bg-soft);
  border-radius: 999px;
  padding: 2px;
  font-size: 12px;
  font-family: var(--font-mono);
  border: 1px solid var(--line);
}
.lang-toggle button {
  appearance: none;
  border: 0; background: transparent;
  color: var(--fg-3);
  font: inherit;
  padding: 4px 10px;
  border-radius: 999px;
  cursor: pointer;
  transition: all .2s ease;
}
.lang-toggle button.active {
  background: var(--bg);
  color: var(--fg);
  box-shadow: var(--shadow-1);
}
.theme-toggle {
  width: 32px; height: 32px;
  border-radius: 999px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--fg-2);
  cursor: pointer;
  transition: all .2s ease;
}
.theme-toggle:hover { background: var(--bg-elev); }

/* ============================================================
   Buttons / pills
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 22px;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 500;
  letter-spacing: -0.005em;
  cursor: pointer;
  border: 0;
  transition: all .2s ease;
  text-decoration: none;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost {
  background: transparent;
  color: var(--accent);
  padding-left: 6px;
  padding-right: 6px;
}
.btn-ghost:hover { color: var(--accent-hover); gap: 12px; }
.btn-outline {
  background: var(--bg-soft);
  color: var(--fg);
  border: 1px solid var(--line);
}
.btn-outline:hover { background: var(--bg-elev); }

.pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--fg-3);
  text-transform: uppercase;
}

/* ============================================================
   Reveal-on-scroll
   ============================================================ */
.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity .9s cubic-bezier(.2,.7,.2,1), transform .9s cubic-bezier(.2,.7,.2,1);
}
.reveal.in {
  opacity: 1;
  transform: none;
}

/* Apple-style scale-in for hero media: starts smaller, grows to full as it enters */
.scale-on-scroll {
  --p: 0;                                /* 0 -> 1 progress */
  transform: scale(calc(0.88 + 0.12 * var(--p)));
  transform-origin: 50% 60%;
  transition: transform .1s linear;
  will-change: transform;
}

/* ============================================================
   Hero
   ============================================================ */
.hero {
  padding: clamp(80px, 12vw, 160px) 0 var(--space-5);
  text-align: center;
  position: relative;
  overflow: hidden;
}
.hero > .container { position: relative; z-index: 2; }

/* Hero backdrop: full-bleed SVG with engineering gears, scroll-driven */
.hero-backdrop {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  color: var(--fg);
  opacity: 1;
  -webkit-mask-image: radial-gradient(ellipse 80% 70% at 50% 45%, transparent 35%, #000 75%);
          mask-image: radial-gradient(ellipse 80% 70% at 50% 45%, transparent 35%, #000 75%);
}
.hero-backdrop svg {
  display: block;
  width: 100%;
  height: 100%;
  /* The whole SVG is rendered at ~7% strength so it reads as a watermark */
  color: color-mix(in oklab, var(--fg) 16%, transparent);
}
[data-theme="dark"] .hero-backdrop svg {
  color: color-mix(in oklab, var(--fg) 22%, transparent);
}
.hero-backdrop .gear {
  transform-box: fill-box;
  /* origin is each gear's own center */
}
.hero .eyebrow { margin-bottom: 24px; }
.hero h1 { margin-bottom: var(--space-3); white-space: pre-line; }
.hero-sub { max-width: 720px; margin: 0 auto var(--space-4); }
.hero-ctas {
  display: inline-flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

.hero-portrait {
  margin-top: var(--space-6);
  width: min(100%, 1180px);
  margin-left: auto; margin-right: auto;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-xl);
  overflow: hidden;
  background: var(--bg-soft);
  position: relative;
  box-shadow: var(--shadow-2);
}

/* ============================================================
   Featured project — full-bleed dark tile
   ============================================================ */
.featured {
  margin: var(--space-6) 0 var(--space-5);
}
.featured-tile {
  background: var(--bg-soft);
  border-radius: var(--radius-xl);
  overflow: hidden;
  position: relative;
  padding: clamp(48px, 6vw, 96px);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(32px, 5vw, 80px);
  align-items: center;
  min-height: 520px;
}
@media (max-width: 900px) {
  .featured-tile { grid-template-columns: 1fr; padding: 40px 28px; }
}
.featured-art {
  aspect-ratio: 4 / 3;
  border-radius: var(--radius-lg);
  background: var(--bg);
  border: 1px solid var(--line);
  overflow: hidden;
  position: relative;
}

/* ============================================================
   Projects grid
   ============================================================ */
.section { padding-block: var(--space-6); }
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 40px;
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
}
.section-head-text { max-width: 720px; }
.section-head .h-section { margin-bottom: 16px; }

.project-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: clamp(16px, 1.5vw, 24px);
}
@media (max-width: 720px) { .project-grid { grid-template-columns: 1fr; } }

.project-card {
  background: var(--bg-soft);
  border-radius: var(--radius-lg);
  padding: clamp(28px, 3vw, 44px);
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-height: 420px;
  position: relative;
  overflow: hidden;
  cursor: pointer;
  transition: transform .4s cubic-bezier(.2,.7,.2,1), background-color .3s ease;
}
.project-card:hover { transform: translateY(-2px); background: var(--bg-elev); }
.project-card-media {
  flex: 1;
  border-radius: var(--radius-md);
  background: var(--bg);
  border: 1px solid var(--line);
  overflow: hidden;
  position: relative;
}
.project-card-meta {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
}
.project-card-title-block { display: flex; flex-direction: column; gap: 8px; }
.project-card-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform .5s cubic-bezier(.2,.7,.2,1);
}
.project-card:hover .project-card-img { transform: scale(1.03); }
.project-card-desc {
  font-size: clamp(12px, 1.2vw, 13px);
  color: var(--fg-muted);
  line-height: 1.55;
  margin-top: 2px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ============================================================
   Articles
   ============================================================ */
.articles-list {
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--line);
}
.article-row {
  display: grid;
  grid-template-columns: 120px 1fr auto auto;
  gap: clamp(20px, 3vw, 48px);
  align-items: center;
  padding: clamp(24px, 2.5vw, 32px) 8px;
  border-bottom: 1px solid var(--line);
  transition: background-color .25s ease, padding .25s ease;
  cursor: pointer;
}
.article-row:hover {
  background: color-mix(in oklab, var(--bg-soft) 60%, transparent);
  padding-left: 24px;
}
.article-cat { color: var(--fg-3); }
.article-title {
  font-family: var(--font-serif);
  font-size: clamp(22px, 2vw, 30px);
  line-height: 1.2;
  letter-spacing: -0.015em;
  font-weight: 400;
  color: var(--fg);
  text-wrap: balance;
}
.article-arrow {
  width: 32px; height: 32px;
  border-radius: 999px;
  background: var(--bg-soft);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--fg-2);
  transition: transform .25s ease, background .25s ease;
}
.article-row:hover .article-arrow {
  background: var(--accent);
  color: #fff;
  transform: translateX(4px);
}
@media (max-width: 720px) {
  .article-row { grid-template-columns: 1fr auto; }
  .article-cat, .article-row .meta:not(.article-date) { display: none; }
}

/* ============================================================
   Experience timeline
   ============================================================ */
.exp-list { display: flex; flex-direction: column; }
.exp-row {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: clamp(20px, 4vw, 64px);
  padding: clamp(28px, 3vw, 40px) 0;
  border-top: 1px solid var(--line);
}
.exp-row:last-child { border-bottom: 1px solid var(--line); }
.exp-range { color: var(--fg-3); padding-top: 6px; }
.exp-body { display: flex; flex-direction: column; gap: 8px; }
.exp-role { font-size: clamp(22px, 2vw, 28px); font-weight: 500; letter-spacing: -0.018em; line-height: 1.2; }
.exp-org { color: var(--fg-3); font-size: 15px; }
.exp-desc { color: var(--fg-3); max-width: 640px; margin-top: 8px; font-size: 16px; line-height: 1.5; }
@media (max-width: 720px) { .exp-row { grid-template-columns: 1fr; } }

/* ============================================================
   Services
   ============================================================ */
.services-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: clamp(16px, 1.5vw, 24px);
}
@media (max-width: 900px) { .services-grid { grid-template-columns: 1fr; } }
.service-card {
  background: var(--bg-soft);
  border-radius: var(--radius-lg);
  padding: clamp(28px, 3vw, 44px);
  min-height: 320px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  transition: background-color .25s ease, transform .4s cubic-bezier(.2,.7,.2,1);
}
.service-card:hover { background: var(--bg-elev); transform: translateY(-2px); }
.service-n {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--fg-4);
  letter-spacing: 0.04em;
}
.service-title { font-size: 28px; font-weight: 500; letter-spacing: -0.022em; line-height: 1.1; margin-top: auto; }
.service-desc { color: var(--fg-3); font-size: 15px; line-height: 1.5; max-width: 320px; }

/* ============================================================
   Contact
   ============================================================ */
.contact {
  padding: var(--space-7) 0 var(--space-6);
  text-align: center;
}
.contact .eyebrow { margin-bottom: 24px; }
.contact .h-section { margin-bottom: var(--space-3); }
.contact-sub { max-width: 560px; margin: 0 auto var(--space-4); }

.contact-portrait {
  width: 96px;
  height: 96px;
  border-radius: 999px;
  overflow: hidden;
  margin: 0 auto var(--space-3);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-1);
}
.contact-portrait > * { width: 100%; height: 100%; }
.contact-email {
  font-family: var(--font-serif);
  font-size: clamp(28px, 3.5vw, 48px);
  font-weight: 400;
  letter-spacing: -0.02em;
  color: var(--accent);
  display: inline-block;
  margin-bottom: var(--space-3);
  border-bottom: 1px solid transparent;
  transition: border-color .3s ease;
}
.contact-email:hover { border-bottom-color: var(--accent); }
.contact-meta { color: var(--fg-4); }

/* ============================================================
   Contact form
   ============================================================ */
.contact-form {
  margin: var(--space-4) auto 0;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 22px;
}
.cf-row { display: flex; flex-direction: column; gap: 10px; }
.cf-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 600px) { .cf-row-2 { grid-template-columns: 1fr; } }
.cf-field { display: flex; flex-direction: column; gap: 8px; }
.cf-label {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--fg-3);
  text-transform: uppercase;
}
.contact-form input,
.contact-form textarea {
  appearance: none;
  width: 100%;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-family: var(--font-sans);
  font-size: 16px;
  color: var(--fg);
  line-height: 1.5;
  transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
  resize: vertical;
}
.contact-form input::placeholder,
.contact-form textarea::placeholder { color: var(--fg-4); }
.contact-form input:focus,
.contact-form textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--bg);
  box-shadow: 0 0 0 4px color-mix(in oklab, var(--accent) 16%, transparent);
}

.cf-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.cf-chip {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--fg-3);
  font: inherit;
  font-size: 14px;
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: all .15s ease;
}
.cf-chip:hover { color: var(--fg); border-color: var(--line-2); }
.cf-chip.on {
  background: var(--fg);
  color: var(--bg);
  border-color: var(--fg);
}

.cf-actions {
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}
.cf-actions .btn-primary[disabled] { opacity: 0.7; cursor: progress; }
.cf-or { font-size: 13px; color: var(--fg-3); }
.cf-email { color: var(--accent); }
.cf-email:hover { text-decoration: underline; }

/* Success state */
.contact-ok {
  margin: var(--space-4) auto 0;
  padding: 32px 28px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
  max-width: 560px;
}
.contact-ok-mark {
  width: 44px; height: 44px;
  border-radius: 999px;
  background: color-mix(in oklab, var(--accent) 14%, transparent);
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.contact-ok p { margin: 0; font-size: 17px; color: var(--fg); }
.contact-ok .contact-or { font-size: 14px; color: var(--fg-3); }
.contact-ok a { color: var(--accent); }

/* ============================================================
   Clients / trust strip
   ============================================================ */
.clients {
  padding: var(--space-4) clamp(20px, 4vw, 40px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  text-align: center;
}
.clients-label {
  color: var(--fg-4);
}
.clients-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 14px 18px;
  max-width: 880px;
}
.client-name {
  font-family: var(--font-sans);
  font-size: clamp(15px, 1.2vw, 17px);
  font-weight: 500;
  color: var(--fg-3);
  letter-spacing: -0.005em;
  transition: color .2s ease;
}
.client-name:hover { color: var(--fg); }
.client-sep {
  color: var(--fg-4);
  opacity: 0.5;
  font-size: 14px;
}

/* ============================================================
   Footer (richer)
   ============================================================ */
.footer {
  border-top: 1px solid var(--line);
  padding: 40px 0 32px;
  font-size: 12px;
  color: var(--fg-4);
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.footer-inner {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-start;
  flex-wrap: wrap;
}
.footer-col {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.footer-rights { text-transform: none; letter-spacing: 0; font-family: var(--font-sans); color: var(--fg-3); }
.footer-socials {
  list-style: none;
  margin: 0; padding: 0;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.footer-socials a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  color: var(--fg-3);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  transition: all .2s ease;
}
.footer-socials a:hover {
  background: var(--bg-elev);
  color: var(--fg);
  border-color: var(--line-2);
}

/* ============================================================
   Placeholder media (striped SVG bg with mono label)
   ============================================================ */
.media-ph {
  width: 100%; height: 100%;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background-image: repeating-linear-gradient(
    135deg,
    color-mix(in oklab, var(--fg) 4%, transparent) 0 1px,
    transparent 1px 14px
  );
  background-color: var(--bg-soft);
}
[data-theme="dark"] .media-ph {
  background-image: repeating-linear-gradient(
    135deg,
    color-mix(in oklab, var(--fg) 6%, transparent) 0 1px,
    transparent 1px 14px
  );
}
.media-ph-label {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.05em;
  color: var(--fg-4);
  text-transform: uppercase;
  text-align: center;
  padding: 6px 10px;
  background: color-mix(in oklab, var(--bg) 75%, transparent);
  border-radius: 6px;
  backdrop-filter: blur(8px);
}

/* ============================================================
   Article reading page
   ============================================================ */
.article-page { background: var(--bg); }
.article-page .nav { backdrop-filter: saturate(180%) blur(20px); }

.article-back {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--fg-3);
  text-transform: uppercase;
  text-decoration: none;
  transition: color .2s ease;
}
.article-back:hover { color: var(--fg); }

.article-head {
  max-width: 760px;
  margin: 0 auto;
  padding: clamp(48px, 8vw, 96px) clamp(20px, 4vw, 40px) clamp(32px, 4vw, 48px);
  text-align: left;
}
.article-meta-row {
  display: flex;
  gap: 16px;
  align-items: center;
  margin-bottom: 28px;
  flex-wrap: wrap;
  color: var(--fg-3);
}
.article-cat-pill {
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.article-h1 {
  font-family: var(--font-serif);
  font-size: clamp(36px, 5.5vw, 64px);
  line-height: 1.05;
  letter-spacing: -0.02em;
  font-weight: 400;
  margin: 0 0 24px;
  color: var(--fg);
  text-wrap: balance;
}
.article-lede {
  font-family: var(--font-serif);
  font-size: clamp(20px, 1.8vw, 24px);
  line-height: 1.45;
  color: var(--fg-3);
  font-weight: 300;
  margin: 0;
  max-width: 60ch;
}

.article-byline {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 clamp(20px, 4vw, 40px);
  display: flex;
  gap: 14px;
  align-items: center;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding-top: 20px;
  padding-bottom: 20px;
}
.byline-avatar {
  width: 40px; height: 40px;
  border-radius: 999px;
  background: var(--bg-soft);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--fg-2);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--line);
}
.byline-text { display: flex; flex-direction: column; gap: 2px; }
.byline-name { font-size: 14px; color: var(--fg); }
.byline-meta { font-size: 12px; color: var(--fg-3); }

.article-body {
  max-width: 680px;            /* ~ 65ch at this font-size */
  margin: 0 auto;
  padding: clamp(40px, 5vw, 64px) clamp(20px, 4vw, 40px) clamp(64px, 8vw, 96px);
  font-family: var(--font-serif);
  font-size: 19px;
  line-height: 1.7;
  color: var(--fg-2);
}
.article-body > * + * { margin-top: 1em; }
.article-body p { margin: 0; text-wrap: pretty; }
.article-body p + p { margin-top: 1em; }
.article-body h2 {
  font-family: var(--font-sans);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.018em;
  color: var(--fg);
  margin-top: 2.2em;
  margin-bottom: 0.4em;
  line-height: 1.25;
}
.article-body h3 {
  font-family: var(--font-sans);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--fg);
  margin-top: 1.6em;
  margin-bottom: 0.2em;
}
.article-body a {
  color: var(--accent);
  border-bottom: 1px solid color-mix(in oklab, var(--accent) 30%, transparent);
  transition: border-color .2s ease;
}
.article-body a:hover { border-bottom-color: var(--accent); }
.article-body strong { color: var(--fg); font-weight: 600; }
.article-body em { font-style: italic; }
.article-body ul, .article-body ol { padding-left: 1.4em; }
.article-body li { margin-top: 0.3em; }

.pullquote {
  margin: 2em -16px !important;
  padding: 8px 24px;
  border-left: 2px solid var(--accent);
  font-family: var(--font-serif);
  font-size: clamp(22px, 2.2vw, 28px);
  line-height: 1.3;
  font-weight: 300;
  letter-spacing: -0.01em;
  color: var(--fg);
}

.code-block {
  margin: 1.6em 0 !important;
  padding: 18px 22px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  font-family: var(--font-mono);
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--fg-2);
  overflow-x: auto;
  white-space: pre;
}
.code-block .cm { color: var(--fg-4); }      /* comment */
.code-block .kw { color: var(--accent); }    /* keyword */
.code-block .nm { color: var(--fg); }        /* identifier */

.equation {
  margin: 1.8em 0 !important;
  text-align: center;
  font-family: "Newsreader", "Iowan Old Style", "Georgia", serif;
  font-style: italic;
  font-size: 22px;
  color: var(--fg);
  letter-spacing: 0.01em;
}
.equation sub, .equation sup { font-style: normal; font-size: 0.7em; }

.figure {
  margin: 2em 0 !important;
}
.figure-frame {
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--bg-soft);
}
.figure-caption {
  margin-top: 12px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--fg-3);
  text-align: center;
  letter-spacing: 0.02em;
  text-transform: none;
}

.article-end {
  margin: 3em 0 0 !important;
  padding-top: 2em;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--fg-3);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.article-end::before {
  content: "";
  display: inline-block;
  width: 8px; height: 8px;
  background: var(--fg);
  border-radius: 2px;
}

.article-next {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 clamp(20px, 4vw, 40px) clamp(64px, 8vw, 96px);
}
.article-next-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px;
  border-radius: var(--radius-lg);
  background: var(--bg-soft);
  border: 1px solid var(--line);
  text-decoration: none;
  color: var(--fg);
  transition: background-color .2s ease, transform .3s ease;
}
.article-next-card:hover { background: var(--bg-elev); transform: translateY(-2px); }
.article-next-label {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-4);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.article-next-title {
  font-family: var(--font-serif);
  font-size: 22px;
  margin-top: 4px;
}
.viz {
  width: 100%; height: 100%;
  position: relative;
  overflow: hidden;
}
.viz > svg { display: block; width: 100%; height: 100%; }
.viz-label {
  position: absolute;
  left: 14px; bottom: 12px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.06em;
  color: var(--fg);
  text-transform: uppercase;
  padding: 5px 9px;
  background: color-mix(in oklab, var(--bg) 78%, transparent);
  border-radius: 6px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid color-mix(in oklab, var(--line) 70%, transparent);
}
[data-theme="dark"] .viz-label {
  background: color-mix(in oklab, var(--bg-elev) 70%, transparent);
  color: var(--fg-2);
}
