:root {
  --bg-primary: #faf7f1;
  --bg-code: #2f2a30;
  --text-primary: #24201d;
  --text-secondary: #7a746b;
  --accent: #8a7a67;
  --accent-light: #cdbfa9;
  --border: #ddd4c8;
  --link: #708aa2;
  --link-hover: #516a81;
  --top-rule: #4b4742;
}

* {
  box-sizing: border-box;
}

body.editorial-blog {
  margin: 0;
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.72), rgba(255, 255, 255, 0) 36%),
    var(--bg-primary);
  color: var(--text-primary);
  font-family: 'Crimson Pro', Georgia, serif;
  font-size: 18px;
  line-height: 1.92;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.book-container {
  max-width: 980px;
  margin: 0 auto;
  padding: 5.5rem 2rem 5rem;
}

.post-header {
  max-width: 860px;
  margin: 0 auto 6.5rem;
  text-align: center;
  position: relative;
}

.post-topper {
  display: grid;
  place-items: center;
  margin: 0 auto 3.6rem;
  color: var(--accent);
  border: none;
  background: none;
}

.post-topper[data-variant='glyph'] {
  width: auto;
  height: auto;
  font-size: 1.2rem;
}

.post-topper[data-variant='image'] {
  width: min(100%, 300px);
  padding: 0;
  border: none;
  border-radius: 0;
  background: none;
  box-shadow: none;
}

.post-topper[data-variant='image'] img {
  display: block;
  max-width: 100%;
  max-height: 220px;
  width: auto;
  height: auto;
  margin: 0 auto;
  border-radius: 0;
}

.post-header::after {
  content: '';
  width: 86px;
  height: 1px;
  background: var(--accent-light);
  opacity: 0.7;
  display: block;
  margin: 3rem auto 0;
}

.back-link {
  display: inline-block;
  margin-bottom: 3rem;
  font-size: 0.72rem;
  color: var(--text-secondary);
  text-decoration: none;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  border-bottom: none;
  opacity: 0.8;
}

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

.post-title {
  max-width: 28ch;
  margin: 0 auto 1.55rem;
  font-family: 'Cormorant Garamond', 'Times New Roman', serif;
  font-size: 2.5rem;
  font-weight: 300;
  letter-spacing: 0.05em;
  line-height: 1.16;
  text-wrap: balance;
}

.post-meta {
  margin: 0;
  font-size: 1rem;
  color: var(--text-secondary);
  letter-spacing: 0.04em;
}

.post-content {
  max-width: 760px;
  margin: 0 auto;
}

.post-content p {
  margin: 1.75rem 0;
  line-height: 1.95;
}

.post-content p.lede {
  margin: 0 auto 4rem;
  padding-bottom: 2.5rem;
  max-width: 42ch;
  text-align: center !important;
  font-size: 1.24rem;
  font-style: italic;
  color: #4e4a44;
  border-bottom: 1px solid rgba(176, 154, 126, 0.5);
}

.post-content p.lede::first-letter {
  all: unset;
  float: none;
  margin: 0;
  color: inherit;
  font-size: inherit;
  line-height: inherit;
}

.post-content p.dropcap::first-letter {
  float: none;
  font-family: inherit;
  font-size: inherit;
  font-weight: inherit;
  line-height: inherit;
  margin: 0;
  color: inherit;
}

.post-content h2,
.post-content h3 {
  font-family: 'Cormorant Garamond', 'Times New Roman', serif;
  letter-spacing: 0.02em;
}

.post-content h2 {
  font-size: 2rem;
  font-weight: 300;
  text-align: center;
  margin: 4.8rem 0 1.75rem;
  position: relative;
}

.post-content h2::before {
  content: '';
  width: 54px;
  height: 1px;
  background: var(--accent-light);
  opacity: 0.9;
  position: absolute;
  top: -1.25rem;
  left: 50%;
  transform: translateX(-50%);
}

.post-content h3 {
  margin: 2.6rem 0 1rem;
  font-size: 1.4rem;
  font-weight: 400;
}

.post-content hr {
  width: 86px;
  border: 0;
  border-top: 1px solid rgba(176, 154, 126, 0.7);
  margin: 3.4rem auto;
}

.post-content a {
  color: var(--link);
  text-decoration: none;
  border-bottom: 1px solid rgba(93, 122, 138, 0.3);
  transition:
    color 0.2s ease,
    border-bottom-color 0.2s ease;
}

.post-content a:hover {
  color: var(--link-hover);
  border-bottom-color: rgba(61, 90, 106, 0.6);
}

.post-content ul,
.post-content ol {
  margin: 1.5rem 0 1.5rem 1.3rem;
  padding: 0;
}

.post-content li {
  margin-bottom: 0.6rem;
  line-height: 1.75;
}

.post-content blockquote {
  margin: 2rem 0;
  padding: 0.1rem 0 0.1rem 1.75rem;
  border-left: 2px solid var(--accent-light);
  color: #5f5b54;
  font-style: italic;
}

.post-content pre {
  background: var(--bg-code);
  border: 1px solid #3a343c;
  border-radius: 3px;
  padding: 1.75rem;
  margin: 2.5rem 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  overflow-x: auto;
}

.post-content pre code {
  font-family: 'JetBrains Mono', 'SFMono-Regular', Menlo, monospace;
  font-size: 0.82rem;
  line-height: 1.7;
  font-weight: 300;
}

.post-content :not(pre) > code {
  font-family: 'JetBrains Mono', 'SFMono-Regular', Menlo, monospace;
  font-size: 0.85rem;
  font-weight: 300;
  background: #f5f1eb;
  border: 1px solid #e8e3dc;
  border-radius: 3px;
  color: #3f3a35 !important;
  padding: 0.18em 0.46em;
}

.post-content .katex-display {
  margin: 2rem 0;
  padding: 1.05rem 0.2rem;
  border-radius: 4px;
  overflow-x: auto;
  background: linear-gradient(
    135deg,
    rgba(139, 115, 85, 0.02),
    rgba(176, 154, 126, 0.03)
  );
}

.post-content .katex-display::-webkit-scrollbar {
  height: 4px;
}

.post-content .katex-display::-webkit-scrollbar-thumb {
  background: var(--accent-light);
  border-radius: 999px;
}

.post-signoff {
  margin-top: 2.5rem;
  text-align: right;
  color: var(--text-secondary);
  font-style: italic;
}

.blog-conclusion {
  margin: 2.6rem 0;
  text-align: center;
  font-style: italic;
  font-size: 1.15rem;
}

.post-content img {
  display: block;
  width: 100%;
  max-width: 100%;
  margin: 2rem auto 0.65rem;
  border: none;
  border-radius: 0;
  background: transparent;
}

.post-content figure {
  margin: 2.25rem 0;
}

.post-content figcaption {
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.8rem;
  line-height: 1.55;
}

.project-links {
  margin: 2rem 0;
  text-align: center;
}

.notes-button {
  display: inline-block;
  border: 1px solid var(--accent-light);
  border-radius: 3px;
  padding: 0.85rem 1.75rem;
  color: var(--accent);
  font-family: 'Crimson Pro', Georgia, serif;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-decoration: none;
}

.notes-button:hover {
  background: rgba(176, 154, 126, 0.15);
  color: #6f5b44;
}

.analytics-snapshot {
  margin: 3rem 0;
  padding: 2rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: rgba(176, 154, 126, 0.05);
}

.analytics-snapshot h3 {
  margin-top: 0;
}

.stats-row {
  display: flex;
  gap: 3rem;
  margin: 1.5rem 0;
}

.stat-label {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.stat-value {
  font-size: 2rem;
  font-family: 'Cormorant Garamond', 'Times New Roman', serif;
}

.analytics-snapshot .post-meta {
  margin: 0;
  font-size: 0.8rem;
}

.post-footer {
  margin-top: 7rem;
  padding-top: 3rem;
  text-align: center;
  position: relative;
}

.post-footer::before {
  content: '';
  width: 86px;
  height: 1px;
  background: var(--accent-light);
  opacity: 0.65;
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
}

.footer-ornament {
  color: var(--accent-light);
  opacity: 0.6;
  font-size: 1.1rem;
}

@media (max-width: 768px) {
  body.editorial-blog {
    font-size: 17px;
  }

  .book-container {
    padding: 4.5rem 1.5rem 4rem;
  }

  .post-header {
    margin-bottom: 5rem;
  }

  .post-topper[data-variant='image'] {
    width: min(100%, 250px);
  }

  .post-topper[data-variant='image'] img {
    max-height: 190px;
  }

  .post-content p.lede {
    font-size: 1.16rem;
  }
}

@media (max-width: 480px) {
  body.editorial-blog {
    font-size: 16px;
  }

  .book-container {
    padding: 3.25rem 1.1rem 3rem;
  }

  .post-header {
    margin-bottom: 4rem;
  }

  .back-link {
    margin-bottom: 2.2rem;
  }

  .post-title {
    font-size: 2.5rem;
  }

  .post-content .katex-display {
    font-size: 0.95em;
  }

  .stats-row {
    flex-direction: column;
    gap: 1rem;
  }

  .post-topper {
    margin-bottom: 2.4rem;
  }

  .post-topper[data-variant='image'] {
    width: min(100%, 205px);
  }

  .post-topper[data-variant='image'] img {
    max-height: 158px;
  }

  .post-content p.lede {
    margin-bottom: 3.2rem;
    padding-bottom: 2rem;
    font-size: 1.08rem;
  }
}

@media print {
  body.editorial-blog {
    background: #fff;
    color: #000;
  }

  .post-content a {
    border-bottom: none;
    color: #000;
  }

  .post-content .katex-display {
    background: transparent;
  }
}
