:root {
  color-scheme: light;
  --bg: #f8f8f4;
  --text: #1f1f1b;
  --subtle: #4a4a44;
  --muted: #7c7c75;
  --card: #ffffff;
  --stroke: #e4e2da;
  --accent: #27425c;
  --accent-soft: #617c96;
  font-size: 16px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Iowan Old Style', 'Georgia', 'Inter', system-ui, -apple-system, serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

main {
  max-width: 1040px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

.article-shell {
  max-width: 760px;
  margin: 0 auto;
  padding: 3rem 1.5rem 4rem;
}

.site-header {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1.2rem 1.5rem;
  background: rgba(248, 248, 244, 0.92);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--stroke);
  max-width: 1040px;
  margin: 0 auto;
  z-index: 10;
}

.header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.identity {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.identity .dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--accent);
  display: inline-block;
}

.identity .title {
  font-weight: 600;
  margin: 0;
}

.primary-nav a {
  margin-left: 1.25rem;
  text-decoration: none;
  color: var(--subtle);
  font-size: 0.95rem;
}

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

.category-menu {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.category-menu .category-link {
  border: 1px solid var(--stroke);
  background: var(--card);
  color: var(--subtle);
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
  font-size: 0.85rem;
  text-decoration: none;
  transition: background 0.2s ease;
}

.category-menu .category-link:hover,
.category-menu .category-link:focus-visible {
  color: var(--accent);
}

.category-menu .category-link.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.filterable[hidden] {
  display: none !important;
}

section {
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid var(--stroke);
}

.essay section {
  border-top: none;
  margin-top: 2.5rem;
  padding-top: 0;
}

.intro {
  font-size: 1.1rem;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  gap: 2rem;
  align-items: flex-end;
}

.section-heading h2 {
  margin: 0.25rem 0 0;
  font-size: 1.9rem;
}

.note {
  max-width: 360px;
  margin: 0;
  color: var(--muted);
}

table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.95rem;
}

table thead {
  background: #f0f0ea;
}

table th,
table td {
  border: 1px solid var(--stroke);
  padding: 0.6rem 0.8rem;
  text-align: left;
}

.grid,
.notes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.5rem;
  margin-top: 2rem;
}

article {
  background: var(--card);
  border: 1px solid var(--stroke);
  padding: 1.5rem;
  border-radius: 0.8rem;
  min-height: 100%;
}

article h3 {
  margin: 0.4rem 0 0.5rem;
  font-size: 1.3rem;
}

article h3 a {
  color: inherit;
  text-decoration: none;
}

article h3 a:hover {
  text-decoration: underline;
}

article p {
  margin: 0 0 0.5rem;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.75rem;
  color: var(--accent-soft);
  margin: 0;
}

.note-category {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.7rem;
  color: var(--accent-soft);
  margin: 0 0 0.25rem;
}

.meta {
  font-size: 0.9rem;
  color: var(--muted);
}

.list {
  list-style: none;
  padding: 0;
  margin: 2rem 0 0;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.list li {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 1rem;
}

.list h3 {
  margin: 0.25rem 0;
}

.theme-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-top: 2rem;
}

.theme-grid div,
.timeline div {
  background: var(--card);
  border: 1px solid var(--stroke);
  padding: 1.25rem;
  border-radius: 0.8rem;
}

.notes-grid article {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.timeline {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-top: 2rem;
}

.timeline h3 {
  margin-top: 0;
}

.timeline ul {
  margin: 0.5rem 0 0;
  padding-left: 1rem;
}

footer {
  max-width: 1040px;
  margin: 2rem auto 3rem;
  padding: 1.5rem;
  border-top: 1px solid var(--stroke);
  color: var(--muted);
}

footer a {
  color: var(--accent);
  text-decoration: none;
}

footer a:hover {
  text-decoration: underline;
}

.essay h1 {
  font-size: 2.5rem;
  line-height: 1.2;
  margin-bottom: 0.5rem;
}

.essay .lead {
  font-size: 1.2rem;
  color: var(--subtle);
  margin-top: 0;
}

.essay pre {
  background: #11130f;
  color: #f6f3ec;
  padding: 1rem;
  border-radius: 0.6rem;
  overflow-x: auto;
  font-size: 0.9rem;
}

.essay code {
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
}

.essay ul,
.essay ol {
  margin: 0.5rem 0 0.5rem 1.2rem;
  padding: 0;
}

.essay hr {
  border: none;
  border-top: 1px solid var(--stroke);
  margin: 2.5rem 0;
}

.back-link {
  display: inline-block;
  margin: 1rem 0;
  color: var(--accent);
  text-decoration: none;
}

.back-link:hover {
  text-decoration: underline;
}

@media (max-width: 700px) {
  .header-top {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  .primary-nav a {
    margin-left: 0;
    margin-right: 1rem;
  }

  .section-heading {
    flex-direction: column;
    align-items: flex-start;
  }

  .list li {
    grid-template-columns: 1fr;
  }
}
