:root {
  --bg: #111110;
  --panel: #151514;
  --panel-2: #191918;
  --text: #c8c4bc;
  --text-strong: #efede8;
  --muted: #77746d;
  --faint: #353431;
  --line: #292825;
  --sidebar-width: 238px;
  --content-max: 1040px;
}

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

html {
  scroll-behavior: smooth;
  background: var(--bg);
}

body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-weight: 300;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

a {
  color: inherit;
}

::selection {
  background: #dedbd4;
  color: #111110;
}

.site-shell {
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-width);
  border-right: 1px solid var(--line);
  background: rgba(17, 17, 16, 0.97);
  padding: 34px 28px 28px;
  display: flex;
  flex-direction: column;
  z-index: 20;
}

.brand {
  display: inline-flex;
  align-items: center;
  width: 150px;
  text-decoration: none;
}

.brand img {
  width: 100%;
  height: auto;
  mix-blend-mode: lighten;
}

.sidebar-nav {
  margin-top: 54px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-kicker,
.eyebrow,
.project-meta,
.footer-copy,
.back-link,
.material-link,
.code-label {
  font-family: 'DM Mono', monospace;
  font-weight: 300;
  text-transform: uppercase;
  letter-spacing: 0.13em;
}

.nav-kicker {
  color: #51504c;
  font-size: 9px;
  margin: 24px 0 8px;
}

.nav-link {
  position: relative;
  padding: 8px 0 8px 14px;
  color: #77746e;
  font-size: 13px;
  line-height: 1.35;
  text-decoration: none;
  transition: color 160ms ease;
}

.nav-link::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  width: 5px;
  height: 1px;
  background: #4b4945;
  transition: width 160ms ease, background 160ms ease;
}

.nav-link:hover,
.nav-link[aria-current='page'] {
  color: var(--text-strong);
}

.nav-link:hover::before,
.nav-link[aria-current='page']::before {
  width: 8px;
  background: var(--text-strong);
}

.nav-link.project-link {
  color: #68665f;
  font-size: 11px;
  padding-left: 14px;
}

.nav-link.project-link[aria-current='page'] {
  color: #d8d5ce;
}

.sidebar-foot {
  margin-top: auto;
  color: #373633;
  font: 9px/1.6 'DM Mono', monospace;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.main-column {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
}

.hero {
  position: relative;
  height: clamp(280px, 45vw, 540px);
  overflow: hidden;
  border-bottom: 1px solid var(--line);
  background: #0d0d0c;
}

.hero video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 54%;
}

.hero::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(0,0,0,0.04), rgba(0,0,0,0.2));
}

.hero-tag {
  position: absolute;
  left: 32px;
  bottom: 24px;
  z-index: 2;
  color: rgba(255,255,255,0.7);
  font: 9px/1.3 'DM Mono', monospace;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.page-content {
  width: min(calc(100% - 72px), var(--content-max));
  margin: 0 auto;
  padding: 88px 0 96px;
}

.home-intro {
  max-width: 720px;
  min-height: 310px;
}

.eyebrow {
  color: #5f5d57;
  font-size: 9px;
  margin-bottom: 22px;
}

h1,
h2,
h3 {
  color: var(--text-strong);
  font-weight: 300;
}

h1 {
  max-width: 880px;
  font-size: clamp(36px, 5vw, 66px);
  line-height: 1.02;
  letter-spacing: -0.035em;
}

.home-intro h1 {
  font-size: clamp(34px, 4.8vw, 58px);
  max-width: 650px;
}

.lede {
  margin-top: 30px;
  max-width: 720px;
  color: #97938b;
  font-size: clamp(16px, 1.6vw, 20px);
  line-height: 1.72;
}

.edit-note {
  margin-top: 36px;
  max-width: 620px;
  border-left: 1px solid #3d3b37;
  padding-left: 18px;
  color: #5f5d58;
  font: 11px/1.8 'DM Mono', monospace;
}

.article-header {
  padding-bottom: 58px;
  border-bottom: 1px solid var(--line);
}

.project-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 9px 20px;
  color: #5f5d58;
  font-size: 9px;
  margin-bottom: 18px;
}

.article-header .lede {
  max-width: 790px;
}

.article {
  max-width: 820px;
  padding-top: 68px;
}

.article section + section {
  margin-top: 70px;
}

.article h2 {
  margin-bottom: 24px;
  font-size: clamp(24px, 3vw, 34px);
  letter-spacing: -0.025em;
}

.article h3 {
  margin: 34px 0 12px;
  font-size: 17px;
  letter-spacing: -0.01em;
}

.article p,
.article li {
  color: #a29e95;
  font-size: 15px;
  line-height: 1.8;
}

.article p + p {
  margin-top: 16px;
}

.article ul,
.article ol {
  padding-left: 22px;
}

.article li + li {
  margin-top: 8px;
}

.article strong {
  color: #d8d5ce;
  font-weight: 400;
}

.article code {
  font-family: 'DM Mono', monospace;
  font-size: 0.92em;
  color: #d8d5ce;
}

.diagram {
  margin: 28px 0;
  padding: 20px 22px;
  border: 1px solid var(--line);
  background: var(--panel);
  overflow-x: auto;
  color: #bdb9b1;
  font: 12px/1.65 'DM Mono', monospace;
  white-space: pre;
}

.parts-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 24px;
}

.part-card {
  min-height: 130px;
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 20px;
}

.part-card h3 {
  margin: 0 0 9px;
  font-size: 15px;
}

.part-card p {
  color: #78756f;
  font-size: 12px;
  line-height: 1.65;
}

.material-link {
  display: inline-block;
  margin-top: 16px;
  color: #a7a39b;
  font-size: 8px;
  text-decoration: none;
}

.material-link:hover {
  color: var(--text-strong);
}

.step-list {
  list-style: none;
  padding: 0 !important;
  counter-reset: steps;
}

.step-list > li {
  position: relative;
  padding: 0 0 34px 56px;
  counter-increment: steps;
}

.step-list > li::before {
  content: counter(steps, decimal-leading-zero);
  position: absolute;
  left: 0;
  top: 2px;
  color: #55534e;
  font: 10px/1 'DM Mono', monospace;
  letter-spacing: 0.08em;
}

.step-list > li + li {
  margin-top: 0;
}

.step-list > li strong {
  display: block;
  margin-bottom: 7px;
}

.note {
  margin: 28px 0;
  padding: 18px 20px;
  border-left: 2px solid #76726a;
  background: #151514;
  color: #8d8981;
  font-size: 13px;
  line-height: 1.75;
}

.page-footer {
  width: min(calc(100% - 72px), var(--content-max));
  margin: 0 auto;
  border-top: 1px solid var(--line);
  padding: 28px 0 36px;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  color: #44423e;
}

.footer-copy,
.back-link {
  font-size: 8px;
}

.back-link {
  text-decoration: none;
}

.back-link:hover {
  color: #a29e95;
}

@media (max-width: 820px) {
  :root {
    --sidebar-width: 0px;
  }

  .sidebar {
    position: sticky;
    top: 0;
    width: 100%;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 17px 20px;
    flex-direction: row;
    align-items: center;
    gap: 24px;
    backdrop-filter: blur(12px);
  }

  .brand {
    flex: 0 0 auto;
    width: 118px;
  }

  .sidebar-nav {
    margin-top: 0;
    margin-left: auto;
    flex-direction: row;
    align-items: center;
    gap: 16px;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .sidebar-nav::-webkit-scrollbar {
    display: none;
  }

  .nav-kicker,
  .sidebar-foot {
    display: none;
  }

  .nav-link,
  .nav-link.project-link {
    flex: 0 0 auto;
    padding: 5px 0;
    font-size: 10px;
    white-space: nowrap;
  }

  .nav-link::before {
    display: none;
  }

  .main-column {
    margin-left: 0;
  }

  .hero {
    height: min(52vw, 390px);
    min-height: 230px;
  }

  .hero-tag {
    left: 20px;
    bottom: 16px;
  }

  .page-content,
  .page-footer {
    width: min(calc(100% - 40px), var(--content-max));
  }

  .page-content {
    padding: 62px 0 72px;
  }

  .parts-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .sidebar {
    gap: 14px;
  }

  .brand {
    width: 100px;
  }

  .sidebar-nav {
    gap: 13px;
  }

  .nav-link.project-link {
    display: none;
  }

  .hero {
    height: 250px;
  }

  .page-content,
  .page-footer {
    width: calc(100% - 32px);
  }

  .page-content {
    padding-top: 52px;
  }

  .article {
    padding-top: 48px;
  }

  .article section + section {
    margin-top: 56px;
  }

  .step-list > li {
    padding-left: 42px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .hero video {
    display: none;
  }

  .hero {
    background: url('assets/hero-poster.jpg') center 54% / cover no-repeat;
  }
}
