:root {
  --primary: #222222;
  --secondary: #666666;
  --tertiary: #F8F8F8;
  --white: #FFFFFF;
  --border: rgba(34, 34, 34, 0.08);
  --max-width: 880px;
  --gutter: clamp(20px, 4vw, 48px);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--tertiary);
  color: var(--primary);
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
a { color: inherit; text-decoration: none; }
::selection { background: var(--primary); color: var(--white); }

.container { max-width: var(--max-width); margin: 0 auto; padding: 0 var(--gutter); }

/* ============== NAV ============== */
.nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  padding: 20px 0;
  background: rgba(248, 248, 248, 0.82);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.nav .container { max-width: 1280px; }
.nav-inner { display: flex; justify-content: space-between; align-items: center; }
.logo { font-weight: 700; font-size: 20px; letter-spacing: -0.02em; }
.nav-links { display: flex; gap: 32px; list-style: none; }
.nav-links a { font-size: 14px; color: var(--primary); transition: opacity 0.2s ease; }
.nav-links a:hover { opacity: 0.55; }
.nav-links a[aria-current="page"] { opacity: 0.55; }
.nav-cta { font-size: 14px; border-bottom: 1px solid var(--primary); padding-bottom: 2px; transition: opacity 0.2s ease; }
.nav-cta:hover { opacity: 0.6; }

/* ============== BLOG LIST HERO ============== */
.blog-hero { padding: 168px 0 56px; }
.section-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px; letter-spacing: 0.25em; text-transform: uppercase;
  color: var(--secondary); margin-bottom: 20px;
}
.blog-title { font-size: clamp(40px, 5.5vw, 84px); font-weight: 200; letter-spacing: -0.035em; line-height: 1.02; margin-bottom: 24px; }
.blog-lead { font-size: clamp(16px, 1.3vw, 19px); color: var(--secondary); max-width: 620px; line-height: 1.7; }

/* ============== CATEGORY FILTER ============== */
.cat-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 4px 0 28px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}
.cat-chip {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--secondary);
  background: var(--white);
  border: 1px solid var(--border);
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.cat-chip:hover { color: var(--primary); border-color: var(--primary); }
.cat-chip.is-active { background: var(--primary); color: var(--white); border-color: var(--primary); }
.cat-chip .cat-count {
  font-size: 10px;
  opacity: 0.7;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(0,0,0,0.05);
}
.cat-chip.is-active .cat-count { background: rgba(255,255,255,0.18); opacity: 0.9; }
.post-empty {
  padding: 60px 0;
  text-align: center;
  color: var(--secondary);
  font-size: 14px;
}

/* ============== POST LIST ============== */
.blog-list-section { padding-bottom: 120px; }
.post-list { display: flex; flex-direction: column; }
.post-category {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--secondary);
  margin-bottom: 8px;
}
.post-item {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 40px;
  padding: 36px 0;
  border-top: 1px solid var(--border);
  transition: padding-left 0.3s ease;
}
.post-item:hover { padding-left: 12px; }
.post-item:last-child { border-bottom: 1px solid var(--border); }
.post-item .post-date {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  color: var(--secondary);
  letter-spacing: 0.04em;
  padding-top: 6px;
}
.post-item .post-title-link {
  font-size: clamp(20px, 2.2vw, 28px);
  font-weight: 400;
  letter-spacing: -0.01em;
  margin-bottom: 10px;
  line-height: 1.25;
  display: block;
  transition: opacity 0.2s ease;
}
.post-item .post-title-link:hover { opacity: 0.6; }
.post-item .post-excerpt {
  font-size: 15px;
  color: var(--secondary);
  line-height: 1.7;
  margin-bottom: 14px;
  max-width: 620px;
}
.post-item .post-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.post-item .tag {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--secondary);
  background: var(--white);
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: 999px;
}

/* ============== SINGLE POST ============== */
.post { padding: 140px 0 80px; }
.post-container { max-width: 720px; }
.post-back {
  display: inline-block;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--secondary);
  margin-bottom: 48px;
  transition: opacity 0.2s ease;
}
.post-back:hover { opacity: 0.6; color: var(--primary); }
.post-header { margin-bottom: 56px; }
.post-meta-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin-bottom: 20px; }
.post-date {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--secondary);
}
.post-meta-row .tag {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--secondary);
  background: var(--white);
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: 999px;
}
.post-title { font-size: clamp(34px, 4.4vw, 56px); font-weight: 200; letter-spacing: -0.03em; line-height: 1.08; margin-bottom: 18px; }
.post-excerpt { font-size: clamp(17px, 1.4vw, 20px); color: var(--secondary); line-height: 1.6; }

/* ============== POST BODY (PROSE) ============== */
.post-body { font-size: 17px; line-height: 1.78; color: var(--primary); }
.post-body p { margin: 0 0 22px; }
.post-body h2 { font-size: clamp(24px, 2.6vw, 32px); font-weight: 400; letter-spacing: -0.015em; margin: 56px 0 16px; }
.post-body h3 { font-size: 20px; font-weight: 500; margin: 40px 0 12px; }
.post-body h4 { font-size: 16px; font-weight: 600; margin: 32px 0 10px; letter-spacing: 0.02em; }
.post-body ul, .post-body ol { margin: 0 0 22px 24px; }
.post-body li { margin-bottom: 8px; }
.post-body li > ul, .post-body li > ol { margin-top: 8px; }
.post-body a { color: var(--primary); border-bottom: 1px solid var(--secondary); transition: border-color 0.2s ease; }
.post-body a:hover { border-bottom-color: var(--primary); }
.post-body strong { font-weight: 600; }
.post-body em { font-style: italic; }
.post-body blockquote {
  border-left: 2px solid var(--primary);
  padding: 4px 0 4px 24px;
  margin: 28px 0;
  color: var(--secondary);
  font-style: italic;
}
.post-body code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  background: rgba(34, 34, 34, 0.06);
  padding: 2px 6px;
  border-radius: 4px;
}
.post-body pre {
  background: var(--primary);
  color: #f5f5f5;
  padding: 22px 24px;
  border-radius: 6px;
  overflow-x: auto;
  margin: 26px 0;
  font-size: 13px;
  line-height: 1.65;
}
.post-body pre code {
  background: transparent;
  padding: 0;
  font-size: inherit;
  color: inherit;
}
.post-body img { max-width: 100%; height: auto; display: block; margin: 28px 0; border-radius: 4px; }
.post-body .diagram { margin: 32px 0; }
.post-body .diagram svg { width: 100%; height: auto; display: block; border: 1px solid var(--border); background: var(--white); border-radius: 6px; padding: 20px; }
.post-body hr { border: none; border-top: 1px solid var(--border); margin: 48px 0; }
.post-body table { width: 100%; border-collapse: collapse; margin: 26px 0; font-size: 15px; }
.post-body th, .post-body td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--border); }
.post-body th { font-weight: 600; background: var(--white); }

/* ============== POST FOOTER ============== */
.post-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 80px;
  padding-top: 32px;
  border-top: 1px solid var(--border);
}
.post-cta {
  font-size: 14px;
  border-bottom: 1px solid var(--primary);
  padding-bottom: 2px;
  transition: opacity 0.2s ease;
}
.post-cta:hover { opacity: 0.6; }

/* ============== FOOTER ============== */
.footer { padding: 32px 0; background: var(--primary); color: rgba(255, 255, 255, 0.4); font-size: 12px; }
.footer-inner { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 16px; max-width: 1280px; }

/* ============== RESPONSIVE ============== */
@media (max-width: 720px) {
  .nav-inner { flex-wrap: wrap; row-gap: 16px; }
  .nav-links { display: flex; order: 3; flex-basis: 100%; gap: 20px; overflow-x: auto; white-space: nowrap; padding-bottom: 4px; }
  .post-item { grid-template-columns: 1fr; gap: 12px; }
  .post-item .post-date { padding-top: 0; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
}
