:root {
  --bg: #faf8f4;
  --surface: #ffffff;
  --surface-muted: #f2eee6;
  --ink: #1e1d1a;
  --ink-muted: #5e5a52;
  --ink-subtle: #857f74;
  --accent: #8c2f1b;
  --accent-hover: #6c2212;
  --accent-soft: #f5eae6;
  --border: #e4ded2;
  --border-strong: #cfc7b7;
  --font-serif: "Newsreader", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --measure: 720px;
  --radius: 8px;
}

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

html {
  font-size: 100%;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-serif);
  font-size: 1.125rem;
  line-height: 1.72;
  text-rendering: optimizeLegibility;
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.16em;
  transition: color 0.15s ease;
}

a:hover {
  color: var(--accent-hover);
}

.site-header {
  border-bottom: 1px solid var(--border);
  background: rgba(250, 248, 244, 0.92);
  backdrop-filter: blur(8px);
}

.site-header-inner {
  max-width: calc(var(--measure) + 80px);
  margin: 0 auto;
  padding: 1.25rem 1.5rem;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
}

.site-brand {
  text-decoration: none;
  color: var(--ink);
  display: flex;
  flex-direction: column;
}

.site-title {
  font-family: var(--font-serif);
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.site-tagline {
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  color: var(--ink-muted);
  margin-top: 0.15rem;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  font-family: var(--font-sans);
  font-size: 0.9375rem;
}

.site-nav a {
  color: var(--ink-muted);
  text-decoration: none;
  font-weight: 500;
  padding: 0.25rem 0;
  border-bottom: 2px solid transparent;
}

.site-nav a:hover,
.site-nav a[aria-current="page"] {
  color: var(--ink);
  border-bottom-color: var(--accent);
}

.main-container {
  max-width: calc(var(--measure) + 48px);
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4.5rem;
}

/* Archive Header & Controls */
.archive-intro {
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.archive-intro h1 {
  font-size: 2rem;
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin: 0 0 0.6rem;
}

.archive-intro p {
  margin: 0;
  color: var(--ink-muted);
  font-size: 1.05rem;
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1.75rem;
  font-family: var(--font-sans);
}

.filter-tabs {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.filter-tab {
  appearance: none;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--ink-muted);
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.filter-tab:hover {
  border-color: var(--accent);
  color: var(--ink);
}

.filter-tab.is-active {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

.tag-explainer {
  background: var(--surface-muted);
  border-left: 3px solid var(--accent);
  padding: 0.85rem 1.1rem;
  border-radius: 0 var(--radius) var(--radius) 0;
  margin-bottom: 1.75rem;
  font-size: 0.96rem;
  color: var(--ink-muted);
}

.post-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.post-card {
  padding: 1.45rem 0;
  border-bottom: 1px solid var(--border);
}

.post-card:first-child {
  padding-top: 0.25rem;
}

.post-card.is-hidden {
  display: none;
}

.post-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.85rem;
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  color: var(--ink-subtle);
  margin-bottom: 0.35rem;
}

.badge-tag {
  display: inline-block;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid rgba(140, 47, 27, 0.22);
  font-family: var(--font-sans);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.12rem 0.5rem;
  border-radius: 4px;
  vertical-align: middle;
}

.post-card-title {
  margin: 0 0 0.45rem;
  font-size: 1.38rem;
  line-height: 1.3;
  letter-spacing: -0.015em;
}

.post-card-title a {
  color: var(--ink);
  text-decoration: none;
}

.post-card-title a:hover {
  color: var(--accent);
  text-decoration: underline;
}

.post-excerpt {
  margin: 0;
  color: var(--ink-muted);
  font-size: 1rem;
  line-height: 1.6;
}

.post-companion-inline {
  margin-top: 0.5rem;
  font-family: var(--font-sans);
  font-size: 0.82rem;
  color: var(--ink-muted);
}

/* Single Article */
.article-header {
  margin-bottom: 2rem;
  padding-bottom: 1.35rem;
  border-bottom: 1px solid var(--border);
}

.article-header h1 {
  font-size: clamp(1.75rem, 3.5vw, 2.35rem);
  line-height: 1.2;
  letter-spacing: -0.025em;
  margin: 0.35rem 0 0.75rem;
}

.companion-banner {
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 0.85rem 1.1rem;
  margin-bottom: 1.75rem;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  color: var(--ink-muted);
}

.companion-banner strong {
  color: var(--ink);
}

.article-body {
  font-size: 1.125rem;
  line-height: 1.76;
}

.article-body > *:first-child {
  margin-top: 0;
}

.article-body h2,
.article-body h3,
.article-body h4,
.article-body h5 {
  font-family: var(--font-serif);
  line-height: 1.3;
  letter-spacing: -0.015em;
  margin: 2rem 0 0.75rem;
  color: var(--ink);
}

.article-body h2 { font-size: 1.55rem; }
.article-body h3 { font-size: 1.32rem; }
.article-body h4 { font-size: 1.15rem; }

.article-body p {
  margin: 0 0 1.25rem;
}

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

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

.article-body blockquote {
  margin: 1.5rem 0;
  padding: 0.25rem 0 0.25rem 1.25rem;
  border-left: 3px solid var(--border-strong);
  color: var(--ink-muted);
  font-style: italic;
}

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

.article-body img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 1rem auto;
  border-radius: var(--radius);
}

.author-portrait {
  margin: 0 0 1.5rem;
  max-width: 240px;
}

.author-portrait img {
  margin: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.article-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.96rem;
  line-height: 1.5;
  background: var(--surface);
  border: 1px solid var(--border);
}

.article-body th,
.article-body td {
  border: 1px solid var(--border);
  padding: 0.65rem 0.85rem;
  vertical-align: top;
  text-align: left;
}

.article-body table table {
  border: none;
  margin: 0;
  background: transparent;
}

.article-body table table td {
  border: none;
  padding: 0.25rem;
  text-align: center;
}

/* Toggle / Accordion sections */
.post-toggle,
.accordion-card {
  margin: 1.5rem 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.post-toggle summary {
  padding: 0.85rem 1.15rem;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.post-toggle summary::-webkit-details-marker {
  display: none;
}

.post-toggle summary::after {
  content: "+";
  font-size: 1.15rem;
  color: var(--ink-subtle);
  font-weight: 400;
}

.post-toggle[open] summary {
  border-bottom: 1px solid var(--border);
}

.post-toggle[open] summary::after {
  content: "−";
}

.toggle-body {
  padding: 1rem 1.15rem;
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--ink-muted);
  overflow-wrap: anywhere;
}

.toggle-body p:last-child {
  margin-bottom: 0;
}

.accordion-card {
  padding: 1rem 1.2rem;
}

.accordion-card h3 {
  margin: 0 0 0.5rem;
  font-size: 1.15rem;
}

.accordion-card p:last-child {
  margin-bottom: 0;
}

/* Video embed */
.video-embed {
  position: relative;
  padding-bottom: 56.25%;
  height: 0;
  overflow: hidden;
  border-radius: var(--radius);
  background: #111;
  margin: 1.5rem 0 0.65rem;
}

.video-embed iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.video-fallback {
  font-family: var(--font-sans);
  font-size: 0.875rem;
  color: var(--ink-subtle);
  text-align: center;
  margin-bottom: 1.5rem;
}

/* Prev / Next Navigation */
.post-nav {
  margin-top: 3rem;
  padding-top: 1.75rem;
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  font-family: var(--font-sans);
}

.post-nav-link {
  display: block;
  padding: 0.9rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--ink);
}

.post-nav-link:hover {
  border-color: var(--accent);
}

.post-nav-label {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-subtle);
  margin-bottom: 0.25rem;
}

.post-nav-title {
  display: block;
  font-size: 0.94rem;
  font-weight: 600;
  line-height: 1.35;
}

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

/* 404 */
.not-found {
  text-align: center;
  padding: 3.5rem 1rem;
}

.not-found h1 {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
}

.not-found p {
  color: var(--ink-muted);
  margin-bottom: 1.5rem;
}

.btn-primary {
  display: inline-block;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 600;
  padding: 0.6rem 1.25rem;
  border-radius: 6px;
  background: var(--ink);
  color: #fff;
  text-decoration: none;
}

.btn-primary:hover {
  background: var(--accent);
  color: #fff;
}

/* Vocabulary tooltips (from 2021 posts) */
.vocab-term {
  border-bottom: 1.5px dotted var(--accent);
  cursor: help;
  position: relative;
}

.missing-media-note {
  display: inline-block;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  color: var(--ink-subtle);
  background: var(--surface-muted);
  border: 1px dashed var(--border-strong);
  border-radius: 6px;
  padding: 0.35rem 0.65rem;
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 1.75rem 1.5rem;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  color: var(--ink-subtle);
  text-align: center;
}

.site-footer a {
  color: var(--ink-muted);
}

@media (max-width: 640px) {
  body {
    font-size: 1.05rem;
  }
  .main-container {
    padding: 1.75rem 1.1rem 3.5rem;
  }
  .post-nav-next {
    text-align: left;
  }
}
