:root {
  /* color — light (default): neutral paper + ink + tea/clay accents */
  --bg: #FFFFFF;
  --bg-raised: #FFFFFF;
  --ink: #000000;
  --ink-soft: #666666;
  --line: #DADADA;
  --accent: #000000;
  --accent-soft: #8A8A8A;
  --grid: rgba(0, 0, 0, 0.06);

  /* type */
  --font-display: 'Jakarta Sans';
  --font-body: 'Jakarta Sans';
  --font-mono: 'IBM Plex Mono', monospace;

  /* radius */
  --radius: 3px;
}

[data-theme="dark"] {
  /* pitch black — accents carry all the color now, background stays neutral */
  --bg: #000000;
  --bg-raised: #000000;
  --ink: #FFFFFF;
  --ink-soft: #999999;
  --line: #2A2A2A;
  --accent: #FFFFFF;
  --accent-soft: #888888;
  --grid: rgba(255, 255, 255, 0.08);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.7;
  letter-spacing: 0.01em;
  -webkit-font-smoothing: antialiased;
  transition: background 0.3s ease, color 0.3s ease;
}

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

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.01em;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* ============================================================
   NAV
   ============================================================ */
.nav {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 6vw;
  background: var(--ink);
  color: var(--bg);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(6px);
}

.brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.3rem;
}

.nav-links {
  display: flex;
  gap: 2rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.nav-links a { opacity: 0.7; transition: opacity 0.15s; }
.nav-links a:hover { opacity: 1; }

.theme-toggle {
  background: none;
  border: 1px solid var(--line);
  border-radius: 50%;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--bg);
}
.theme-toggle svg { width: 16px; height: 16px; }
.theme-toggle .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-moon { display: block; }

/* ============================================================
   HERO
   ============================================================ */
.hero {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 4vw;
  align-items: center;
  padding: 9vh 6vw 10vh;
  max-width: 1280px;
  margin: 0 auto;
}
.hero-avatar {
  width: 300px;
  height: 300px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--line);
  margin-right: 0.9rem;
}
.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 1.1rem;
}

.hero h1 {
  font-size: clamp(2.1rem, 4vw, 3.1rem);
  line-height: 1.12;
  margin-bottom: 1.4rem;
}

.hero-sub {
  color: var(--ink-soft);
  font-size: 1.02rem;
  max-width: 36ch;
  margin: 0 0 2.2rem;
}

.hero-links { display: flex; gap: 1rem; align-items: center; }

.btn-primary, .btn-ghost {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  padding: 0.75rem 1.3rem;
  border-radius: var(--radius);
  display: inline-block;
}
.btn-primary {
  background: var(--accent);
  color: var(--bg-raised);
  font-weight: 500;
}
.btn-ghost {
  border: 1px solid var(--line);
}
.btn-primary:hover { opacity: 0.88; }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }

/* hero graph */
.hero-graph { position: relative; }
.graph-svg { width: 100%; height: auto; }

.grid-lines line {
  stroke: var(--grid);
  stroke-width: 1;
}

.edges .edge {
  stroke: var(--accent);
  stroke-width: 1.2;
  opacity: 0.55;
  stroke-dasharray: 4 4;
  stroke-dashoffset: 200;
  animation: draw 0.9s ease forwards;
  animation-delay: calc(var(--d) * 0.12s + 0.2s);
}

.nodes .node circle {
  fill: var(--accent-soft);
  opacity: 0;
  animation: pop 0.5s ease forwards;
  animation-delay: calc(var(--d) * 0.18s + 0.5s);
}
.nodes .node text {
  font-family: var(--font-mono);
  font-size: 11px;
  fill: var(--ink-soft);
  opacity: 0;
  animation: fadein 0.6s ease forwards;
  animation-delay: calc(var(--d) * 0.18s + 0.65s);
}

@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes pop { to { opacity: 1; } }
@keyframes fadein { to { opacity: 1; } }

.graph-caption {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--ink-soft);
  text-align: center;
  margin-top: 0.6rem;
  letter-spacing: 0.03em;
}

@media (prefers-reduced-motion: reduce) {
  .edges .edge, .nodes .node circle, .nodes .node text {
    animation: none;
    opacity: 1;
    stroke-dashoffset: 0;
  }
}

/* ============================================================
   SECTION HEADERS
   ============================================================ */
section { padding: 8vh 6vw; max-width: 1280px; margin: 0 auto; }

h2 {
  font-size: 1.5rem;
  display: flex;
  align-items: baseline;
  gap: 0.9rem;
  margin-bottom: 2.6rem;
}
h2 .num {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--accent-soft);
  font-weight: 500;
}

/* ============================================================
   BUILDS LIST
   ============================================================ */
.build-list { list-style: none; margin: 0; padding: 0; }

.build-row {
  display: grid;
  grid-template-columns: 92px 160px 1fr 64px;
  gap: 1.4rem;
  align-items: baseline;
  padding: 1.1rem 0;
  border-bottom: 1px solid var(--line);
}

.status {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.05em;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius);
  width: fit-content;
}
.status.live { background: var(--ink); color: var(--bg); }
.status.build { background: none; border: 1px solid var(--ink); color: var(--ink); }
.status.proto { background: var(--line); color: var(--ink-soft); border: none; }

.build-name { font-family: var(--font-display); font-weight: 600; }
.build-desc { color: var(--ink-soft); font-size: 0.94rem; }
.build-date {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--ink-soft);
  text-align: right;
}

/* ============================================================
   WORK CARDS
   ============================================================ */
.work-card {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 2.4rem;
  padding: 2.4rem 0;
  border-bottom: 1px solid var(--line);
  transition: background 0.15s ease;
}
.work-card:hover { background: var(--line); }
.work-card:hover .work-link { text-decoration: underline; }

.work-visual {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  aspect-ratio: 1;
}
.doc-thumb-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  filter: grayscale(1);
  transition: filter 0.2s ease;
}
.work-card:hover .doc-thumb-img { filter: grayscale(0.4); }

.work-body h3 { font-size: 1.4rem; margin-bottom: 0.4rem; }
.work-meta {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--accent-soft);
  margin: 0 0 1rem;
}
.work-abstract { color: var(--ink-soft); margin: 0 0 1.3rem; max-width: 70ch; }

.tags { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1.2rem; }
.tags span {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.25rem 0.6rem;
  color: var(--ink-soft);
}

.work-link {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--accent);
}

/* ============================================================
   FOOTER
   ============================================================ */
footer {
  padding: 6vh 6vw 4vh;
  border-top: 1px solid var(--line);
  max-width: 1280px;
  margin: 0 auto;
}
.footer-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.footer-line { color: var(--ink-soft); margin: 0; }
.footer-links { display: flex; gap: 1.4rem; font-family: var(--font-mono); font-size: 0.85rem; }
.footer-links a:hover { color: var(--accent); }
.footer-bottom {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--ink-soft);
  margin: 0;
}

/* ============================================================
   RESPONSIVE (base site)
   ============================================================ */
@media (max-width: 880px) {
  .hero { grid-template-columns: 1fr; padding-top: 6vh; }
  .hero-graph { order: -1; max-width: 380px; margin: 0 auto 2rem; }
  .hero-graph {
  overflow: hidden;
  }

  .profile-photo {
  max-width: 100%;
  height: auto;
  display: block;
  }
  .build-row { grid-template-columns: 76px 1fr; }
  .build-row .build-desc { grid-column: 1 / -1; order: 3; }
  .build-row .build-date { display: none; }
  .work-card { grid-template-columns: 1fr; }
  .work-visual { max-width: 160px; }
  .nav-links { gap: 1.1rem; }
}

@media (max-width: 540px) {
  .nav { padding: 18px 5vw; }
  .nav-links a:nth-child(3) { display: none; }
}

/* ============================================================
   BLOG — listing page
   ============================================================ */
.blog-hero {
  padding: 7vh 6vw 5vh;
  max-width: 1280px;
  margin: 0 auto;
  border-bottom: 1px solid var(--line);
}
.blog-hero h1 {
  font-size: clamp(1.9rem, 3.4vw, 2.6rem);
  margin-bottom: 0.9rem;
}
.blog-hero p {
  color: var(--ink-soft);
  max-width: 56ch;
  margin: 0;
}

.blog-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-width: 1280px;
  margin: 0 auto;
  padding: 2vh 6vw 8vh;
}

.blog-row {
  display: block;
  padding: 2.2rem 0;
  border-bottom: 1px solid var(--line);
  transition: background 0.15s ease;
}
.blog-row:hover { background: var(--line); }
.blog-row:hover .blog-row-link { text-decoration: underline; }

.blog-row-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.6rem;
}
.blog-row-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.3rem;
}
.blog-row-date {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--ink-soft);
  white-space: nowrap;
}
.blog-row-excerpt {
  color: var(--ink-soft);
  max-width: 70ch;
  margin: 0 0 0.9rem;
}
.blog-row-link {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--accent);
}
.blog-row-tag {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.15rem 0.5rem;
  margin-right: 0.5rem;
}

.status.soon { background: none; border: 1px dashed var(--line); color: var(--ink-soft); }

/* ============================================================
   BLOG — post page
   ============================================================ */
.post-header {
  max-width: 800px;
  margin: 0 auto;
  padding: 8vh 6vw 4vh;
}
.back-link {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--ink-soft);
  margin-bottom: 2.2rem;
}
.back-link:hover { color: var(--accent); }

.post-eyebrow {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 1rem;
}
.post-title {
  font-size: clamp(1.9rem, 4vw, 2.7rem);
  line-height: 1.15;
  margin-bottom: 1.1rem;
}
.post-meta {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--ink-soft);
}
.post-meta span:not(:last-child)::after {
  content: "·";
  margin: 0 0.6rem;
  color: var(--line);
}

.post-hero-image {
  max-width: 800px;
  margin: 0 auto;
  padding: 0 6vw 4vh;
}
.post-hero-image img {
  weight: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  filter: grayscale(0.15);
  display: block;
}

.post-body {
  max-width: 800px;
  margin: 0 auto;
  padding: 0 6vw 10vh;
}
.post-body p {
  margin: 0 0 1.3rem;
  color: var(--ink);
}
.post-body p.lead {
  font-size: 1.12rem;
  color: var(--ink-soft);
}
.post-body h2 {
  font-size: 1.35rem;
  margin: 3.2rem 0 1.4rem;
  padding-top: 2.2rem;
  border-top: 1px solid var(--line);
}
.post-body h2:first-child { border-top: none; padding-top: 0; margin-top: 0; }
.post-body h3 {
  font-size: 1.05rem;
  margin: 2rem 0 1rem;
}
.post-body ul, .post-body ol {
  color: var(--ink);
  padding-left: 1.3rem;
  margin: 0 0 1.3rem;
}
.post-body li { margin-bottom: 0.5rem; }
.post-body li::marker { color: var(--accent-soft); }
.post-body strong { font-weight: 600; }

.equation {
  font-family: var(--font-mono);
  font-size: 0.86rem;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
  overflow-x: auto;
  margin: 0 0 1.4rem;
  color: var(--ink-soft);
}

.post-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  margin: 0 0 1.6rem;
}
.post-table th, .post-table td {
  text-align: left;
  padding: 0.6rem 0.8rem;
  border-bottom: 1px solid var(--line);
}
.post-table th {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  font-weight: 500;
}

.post-callout {
  border-left: 2px solid var(--accent);
  padding: 0.2rem 0 0.2rem 1.2rem;
  color: var(--ink-soft);
  font-style: italic;
  margin: 0 0 1.6rem;
}

.built-with {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0 0 1.6rem;
}
.built-with span {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.25rem 0.6rem;
  color: var(--ink-soft);
}

.post-links {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin: 0 0 1.6rem;
}

.post-footer {
  max-width: 800px;
  margin: 0 auto;
  padding: 4vh 6vw 10vh;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.post-footer .btn-ghost {
  border: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  padding: 0.7rem 1.2rem;
  border-radius: var(--radius);
}
.post-footer .btn-ghost:hover { border-color: var(--accent); color: var(--accent); }

@media (max-width: 600px) {
  .post-header, .post-hero-image, .post-body, .post-footer, .blog-hero, .blog-list {
    padding-left: 6vw;
    padding-right: 6vw;
  }
  .blog-row-top { flex-direction: column; align-items: flex-start; gap: 0.3rem; }
}

/* ============================================================
   PAPERS
   ============================================================ */
.papers {
  padding: 8vh 6vw;
  max-width: 1280px;
  margin: 0 auto;
}

.papers h2 {
  font-size: 1.5rem;
  display: flex;
  align-items: baseline;
  gap: 0.9rem;
  margin-bottom: 2.6rem;
}

.paper-card-wrap {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 2.4rem;
}

.paper-card {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 2.4rem;
  padding: 2.4rem 0;
  border-bottom: 1px solid var(--line);
  transition: background 0.15s ease;
}
.paper-card:hover {
  background: var(--line);
}
.paper-card:hover .paper-link {
  text-decoration: underline;
}

.paper-visual {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  aspect-ratio: 1;
}
.paper-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--line);
  color: var(--ink-soft);
  font-family: var(--font-mono);
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.paper-body {
  padding: 0;
}
.paper-body h3 {
  font-size: 1.4rem;
  margin-bottom: 0.4rem;
}
.paper-meta {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--accent-soft);
  margin: 0 0 1rem;
}
.paper-link {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--accent);
}
.paper-link:hover {
  text-decoration: underline;
}

/* Responsive */
@media (max-width: 880px) {
  .paper-card {
    grid-template-columns: 1fr;
    text-align: center;
  }
  .paper-visual {
    margin: 0 auto 1.5rem;
    max-width: 180px;
  }
}