:root {
  --bg-paper: #FAF9F6;
  --bg-surface: #FFFFFF;
  --bg-code: #F4F2EC;
  --ink-primary: #1C1917;
  --ink-secondary: #44403C;
  --ink-muted: #57534E;
  --border-hairline: #E7E5E4;
  --border-strong: #D6D3D1;
  --accent: #292524;
  --font-serif: "Newsreader", "Georgia", "Times New Roman", serif;
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

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

html, body {
  background-color: var(--bg-paper) !important;
  color: var(--ink-primary) !important;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.68;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1, h2, h3, h4 {
  font-family: var(--font-serif);
  letter-spacing: -0.015em;
  color: var(--ink-primary);
  line-height: 1.22;
}

a {
  color: inherit;
}

.site-container {
  box-sizing: border-box !important;
  width: 100%;
  max-width: 920px !important;
  margin-left: auto;
  margin-right: auto;
  padding-left: 1.25rem;
  padding-right: 1.25rem;
  margin-top: 0 !important;
}

.prose-width {
  max-width: 68ch;
  width: 100%;
  min-width: 0;
}

/* Header */
.site-header {
  border-bottom: 1px solid var(--border-hairline);
  padding: 1.35rem 0;
  margin-bottom: 3.25rem;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1.25rem;
  flex-wrap: wrap;
}

.site-brand {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  text-decoration: none;
  color: var(--ink-primary);
}

.site-nav {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.45rem 1.25rem;
}

.nav-link {
  font-size: 0.9rem;
  color: var(--ink-muted);
  text-decoration: none;
  transition: color 0.15s ease;
}

.nav-link:hover {
  color: var(--ink-primary);
  text-decoration: underline;
  text-underline-offset: 4px;
}

/* Typography utilities */
.meta-mono {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  color: var(--ink-muted);
}

.inline-link {
  color: var(--ink-primary);
  text-decoration: underline;
  text-decoration-color: var(--border-strong);
  text-underline-offset: 3px;
}

.inline-link:hover {
  text-decoration-color: var(--ink-primary);
}

.inline-code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--bg-code);
  padding: 0.1rem 0.32rem;
  border-radius: 3px;
}

/* Hero */
.section-hero {
  margin-bottom: 3.75rem;
  padding-bottom: 2.5rem;
  border-bottom: 1px solid var(--border-hairline);
}

.hero-title {
  font-size: clamp(2.1rem, 4.3vw, 3.05rem);
  font-weight: 500;
  line-height: 1.13;
  margin-bottom: 1.25rem;
}

.page-title {
  font-size: clamp(2rem, 4vw, 2.75rem);
  font-weight: 500;
  margin-bottom: 0.75rem;
}

.hero-lead {
  font-size: 1.06rem;
  color: var(--ink-secondary);
  line-height: 1.72;
  margin-bottom: 1.5rem;
}

.hero-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.9rem;
}

.hero-link {
  font-size: 0.94rem;
  color: var(--ink-primary);
  text-decoration: underline;
  text-decoration-color: var(--border-strong);
  text-underline-offset: 4px;
}

.hero-link:hover {
  text-decoration-color: var(--ink-primary);
}

/* Editorial sections */
.editorial-section {
  margin-bottom: 4.25rem;
}

.section-kicker {
  margin-bottom: 0.35rem;
}

.section-heading {
  font-size: 1.65rem;
  font-weight: 500;
  margin-bottom: 1.35rem;
}

.section-intro {
  color: var(--ink-muted);
  margin-top: -0.5rem;
  margin-bottom: 1.5rem;
  font-size: 0.975rem;
}

/* Monograph Research & Experiments list */
.monograph-list {
  list-style: none;
  padding: 0;
  margin: 0;
  border-top: 1px solid var(--border-hairline);
}

.monograph-row {
  display: grid;
  grid-template-columns: 185px 1fr;
  gap: 1.5rem;
  padding: 1.35rem 0;
  border-bottom: 1px solid var(--border-hairline);
  align-items: baseline;
}

.entry-label {
  font-size: 0.74rem;
  padding-top: 0.2rem;
}

.entry-content {
  min-width: 0;
  max-width: 68ch;
}

.entry-title {
  font-size: 1.2rem;
  font-weight: 500;
  margin: 0 0 0.45rem;
}

.entry-body {
  font-size: 0.95rem;
  color: var(--ink-secondary);
  line-height: 1.68;
  margin: 0;
}

.entry-links {
  margin: 0.65rem 0 0;
  font-family: var(--font-mono);
  font-size: 0.77rem;
}

.entry-link {
  color: var(--ink-primary);
}

/* Lab Notes callout */
.lab-notes-callout {
  background: var(--bg-surface);
  border: 1px solid var(--border-hairline);
  border-left: 3px solid var(--accent);
  border-radius: 4px;
  padding: 1.15rem 1.35rem;
}

.lab-notes-text {
  margin: 0;
  font-size: 0.95rem;
  color: var(--ink-secondary);
  line-height: 1.68;
}

.microblog-callout {
  font-size: 0.92rem;
  color: var(--ink-muted);
  margin-top: 0;
}

/* Background rows */
.highlight-list {
  list-style: none;
  padding: 0;
  margin: 0;
  border-top: 1px solid var(--border-hairline);
}

.highlight-row {
  display: grid;
  grid-template-columns: 185px 1fr;
  gap: 1.5rem;
  padding: 1.1rem 0;
  border-bottom: 1px solid var(--border-hairline);
  align-items: baseline;
}

.highlight-label {
  font-size: 0.74rem;
}

.highlight-body {
  min-width: 0;
  max-width: 68ch;
}

.highlight-body p {
  margin: 0;
  font-size: 0.95rem;
  color: var(--ink-secondary);
  line-height: 1.68;
}

.community-note {
  margin: 1.25rem 0 0;
  font-size: 0.9rem;
  color: var(--ink-muted);
  line-height: 1.6;
}

/* Post lists (homepage & articles index) */
.post-list {
  list-style: none;
  padding: 0;
  margin: 0;
  border-top: 1px solid var(--border-hairline);
}

.post-list-item {
  padding: 1.05rem 0;
  border-bottom: 1px solid var(--border-hairline);
}

.post-list-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1.5rem;
}

.post-list-main {
  min-width: 0;
  flex: 1;
}

.post-list-title {
  font-family: var(--font-serif);
  font-size: 1.16rem;
  font-weight: 500;
  color: var(--ink-primary);
  text-decoration: none;
  line-height: 1.35;
  display: inline-block;
}

.post-list-title:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.post-list-summary {
  font-size: 0.89rem;
  color: var(--ink-muted);
  margin: 0.35rem 0 0;
  line-height: 1.55;
  max-width: 64ch;
}

.post-list-meta {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  flex-shrink: 0;
  white-space: nowrap;
}

.post-cat {
  font-size: 0.72rem;
  padding: 0.15rem 0.45rem;
  border: 1px solid var(--border-hairline);
  border-radius: 3px;
  background: var(--bg-surface);
}

.year-group {
  margin-bottom: 2.75rem;
}

.year-heading {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--ink-muted);
  margin-bottom: 0.65rem;
  letter-spacing: 0.05em;
}

/* Category filter bar */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.filter-pill {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--ink-muted);
  background: var(--bg-surface);
  border: 1px solid var(--border-hairline);
  border-radius: 3px;
  padding: 0.35rem 0.7rem;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, background-color 0.15s ease;
}

.filter-pill:hover {
  border-color: var(--border-strong);
  color: var(--ink-primary);
}

.filter-pill.is-active {
  background: var(--ink-primary);
  border-color: var(--ink-primary);
  color: var(--bg-paper);
}

/* Article pages */
.back-link {
  text-decoration: none;
  color: var(--ink-muted);
}

.back-link:hover {
  color: var(--ink-primary);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.article-header {
  padding-bottom: 1.5rem;
  margin-bottom: 2rem;
  border-bottom: 1px solid var(--border-hairline);
}

.article-title {
  font-size: clamp(1.9rem, 4vw, 2.65rem);
  font-weight: 500;
  line-height: 1.15;
  margin: 0;
}

.article-prose {
  font-size: 1.02rem;
  line-height: 1.75;
  color: var(--ink-primary);
}

.article-prose h1,
.article-prose h2 {
  font-size: 1.55rem;
  font-weight: 500;
  margin-top: 2.4rem;
  margin-bottom: 0.85rem;
}

.article-prose h3 {
  font-size: 1.25rem;
  font-weight: 500;
  margin-top: 1.9rem;
  margin-bottom: 0.65rem;
}

.article-prose h4,
.article-prose h5 {
  font-family: var(--font-sans);
  font-size: 1rem;
  font-weight: 600;
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
}

.article-prose p {
  margin-top: 0;
  margin-bottom: 1.25rem;
}

.article-prose a {
  color: var(--ink-primary);
  text-decoration: underline;
  text-decoration-color: var(--border-strong);
  text-underline-offset: 3px;
  word-break: break-word;
}

.article-prose a:hover {
  text-decoration-color: var(--ink-primary);
}

.article-prose ul,
.article-prose ol {
  margin: 0 0 1.35rem 0;
  padding-left: 1.45rem;
}

.article-prose ul {
  list-style-type: disc;
}

.article-prose ol {
  list-style-type: decimal;
}

.article-prose li {
  margin-bottom: 0.45rem;
}

.article-prose blockquote {
  border-left: 2px solid var(--border-strong);
  margin: 1.5rem 0;
  padding: 0.2rem 0 0.2rem 1.15rem;
  color: var(--ink-secondary);
  font-style: italic;
}

.article-prose hr {
  border: 0;
  border-top: 1px solid var(--border-hairline);
  margin: 2rem 0;
}

.article-prose code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  background: var(--bg-code);
  padding: 0.14rem 0.35rem;
  border-radius: 3px;
}

.article-prose pre {
  font-family: var(--font-mono);
  font-size: 0.84rem;
  line-height: 1.6;
  background: var(--bg-surface);
  border: 1px solid var(--border-hairline);
  border-radius: 4px;
  padding: 1rem 1.15rem;
  margin: 1.5rem 0;
  overflow-x: auto;
  max-width: 100%;
}

.article-prose pre code {
  background: transparent;
  padding: 0;
  font-size: inherit;
}

.article-prose img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 1.6rem 0 0.6rem;
  border: 1px solid var(--border-hairline);
  border-radius: 4px;
  background: var(--bg-surface);
}

.article-prose p > img + em,
.article-prose p:has(> img) + p > em:only-child {
  display: block;
  font-size: 0.86rem;
  color: var(--ink-muted);
  line-height: 1.5;
}

.article-prose iframe {
  display: block;
  width: 100%;
  max-width: 100%;
  aspect-ratio: 16 / 9;
  height: auto;
  border: 1px solid var(--border-hairline);
  border-radius: 4px;
  margin: 1.5rem 0;
}

.table-scroll {
  width: 100%;
  overflow-x: auto;
  margin: 1.5rem 0;
  -webkit-overflow-scrolling: touch;
}

.article-prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  line-height: 1.5;
  background: var(--bg-surface);
  border: 1px solid var(--border-hairline);
}

.article-prose th,
.article-prose td {
  padding: 0.6rem 0.8rem;
  border-bottom: 1px solid var(--border-hairline);
  text-align: left;
  vertical-align: top;
}

.article-prose th {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-weight: 500;
  color: var(--ink-muted);
  background: var(--bg-paper);
  white-space: nowrap;
}

/* Author note & adjacent post nav */
.author-note {
  margin-top: 3rem;
  padding: 1.2rem 1.35rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-hairline);
  border-radius: 4px;
}

.author-note-text {
  margin: 0;
  font-size: 0.92rem;
  color: var(--ink-secondary);
  line-height: 1.6;
}

.post-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-top: 2.25rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-hairline);
}

.post-nav-next {
  text-align: right;
}

.post-nav-link {
  font-family: var(--font-serif);
  font-size: 1rem;
  color: var(--ink-primary);
  text-decoration: none;
  line-height: 1.35;
}

.post-nav-link:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border-hairline);
  padding: 2rem 0 2.5rem;
  margin-top: 4.5rem;
  color: var(--ink-muted);
  font-size: 0.84rem;
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem 1.25rem;
  flex-wrap: wrap;
}

.footer-copy {
  margin: 0;
}

.footer-links {
  display: flex;
  align-items: center;
  gap: 0.5rem 1.15rem;
  flex-wrap: wrap;
}

.footer-link {
  color: var(--ink-muted);
  text-decoration: none;
}

.footer-link:hover {
  color: var(--ink-primary);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* Mobile adjustments (390px and below) */
@media (max-width: 680px) {
  .site-header {
    margin-bottom: 2.25rem;
    padding: 1rem 0;
  }

  .site-nav {
    gap: 0.4rem 1rem;
  }

  .section-hero {
    margin-bottom: 2.75rem;
    padding-bottom: 2rem;
  }

  .monograph-row,
  .highlight-row {
    grid-template-columns: 1fr;
    gap: 0.35rem;
  }

  .post-list-row {
    flex-direction: column;
    gap: 0.5rem;
  }

  .post-list-meta {
    flex-wrap: wrap;
  }

  .post-nav {
    grid-template-columns: 1fr;
    gap: 1.25rem;
  }

  .post-nav-next {
    text-align: left;
  }
}
