:root {
  --paper: #f4efe6;
  --ink: #1c1712;
  --soft: #3a332b;
  --muted: #4a433a;
  --rule: #d4cbb8;
  --oxblood: #6e2424;
  --highlight: #e7d7b0;
  --current: #efe6d4;
  --serif: "Source Serif 4", "Iowan Old Style", Palatino, "Palatino Linotype", "Book Antiqua", Georgia, serif;
  --sans: "Source Sans 3", "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --theme: var(--oxblood);
  --topbar: 4.4rem;
  --measure: 65ch;
  color-scheme: light;
}

[data-theme="1"] { --theme: #6e2424; }
[data-theme="2"] { --theme: #2e3644; }
[data-theme="3"] { --theme: #3f4a28; }
[data-theme="4"] { --theme: #1e4444; }
[data-theme="5"] { --theme: #6a4518; }
[data-theme="6"] { --theme: #24345c; }
[data-theme="7"] { --theme: #2c4534; }

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

[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

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

::selection {
  background: var(--highlight);
  color: var(--ink);
}

a { color: inherit; }

a:focus-visible,
.nav-toggle:focus-visible {
  outline: 2px solid var(--oxblood);
  outline-offset: 3px;
}

.skip {
  position: absolute;
  left: 1rem;
  top: -4rem;
  z-index: 80;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--sans);
  font-size: 0.875rem;
  padding: 0.55rem 0.8rem;
  text-decoration: none;
}

.skip:focus { top: 0.6rem; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.nav-state {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  border: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
}

.topbar-inner,
.layout,
.site-footer-inner {
  width: min(76rem, calc(100% - 3rem));
  margin-inline: auto;
}

.topbar-inner {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  min-height: var(--topbar);
  padding: 0.55rem 0;
}

.nav-toggle {
  display: none;
  flex: none;
  align-items: center;
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink);
  border: 1px solid var(--rule);
  background: transparent;
  padding: 0.45rem 0.6rem;
  cursor: pointer;
}

.when-open { display: none; }

body:has(#nav-toggle:checked) .when-open { display: inline; }
body:has(#nav-toggle:checked) .when-closed { display: none; }

body:has(#nav-toggle:focus-visible) .nav-toggle {
  outline: 2px solid var(--oxblood);
  outline-offset: 3px;
}

.brand {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.12rem;
  text-decoration: none;
  color: var(--ink);
  line-height: 1.1;
}

.brand-name {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.12rem;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-sub {
  font-family: var(--sans);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.langs {
  display: flex;
  flex: none;
  align-items: center;
  font-family: var(--sans);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.08em;
}

.langs a {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  padding: 0 0.5rem;
  color: var(--muted);
  text-decoration: none;
}

.langs a[aria-current="true"] {
  color: var(--ink);
  box-shadow: inset 0 -2px 0 var(--oxblood);
}

.scrim { display: none; }

.layout {
  display: grid;
  grid-template-columns: 17.75rem minmax(0, 1fr);
  column-gap: 3.25rem;
  align-items: start;
}

.toc {
  position: sticky;
  top: var(--topbar);
  height: calc(100vh - var(--topbar));
  display: flex;
  flex-direction: column;
  padding: 1.35rem 0 1rem;
  min-width: 0;
}

.toc-head { padding: 0 0.15rem 0.85rem 0; }

.toc-search {
  width: 100%;
  font-family: var(--sans);
  font-size: 0.92rem;
  color: var(--ink);
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--rule);
  border-radius: 0;
  padding: 0.4rem 0.05rem 0.45rem;
}

.toc-search::placeholder { color: var(--muted); opacity: 1; }

.toc-search:focus {
  outline: none;
  border-bottom-color: var(--oxblood);
}

.toc-scroll {
  overflow: auto;
  min-height: 0;
  flex: 1;
  padding: 0.35rem 0.7rem 1.5rem 0;
  scrollbar-width: thin;
  scrollbar-color: var(--rule) transparent;
}

.toc-themes,
.toc-essays,
.contents {
  list-style: none;
  margin: 0;
  padding: 0;
}

.toc-theme { margin: 0 0 1.15rem; }

.toc-label { margin: 0 0 0.3rem; }

.toc-label a {
  display: flex;
  align-items: baseline;
  gap: 0.55rem;
  text-decoration: none;
  color: var(--theme);
  font-family: var(--sans);
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  line-height: 1.35;
  padding: 0.2rem 0;
}

.toc-label a::before {
  content: "";
  width: 0.9rem;
  height: 1px;
  background: var(--theme);
  flex: none;
  transform: translateY(-0.28em);
}

.toc-name { flex: 1; }

.toc-count {
  font-weight: 500;
  letter-spacing: 0;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.toc-essays a {
  display: block;
  padding: 0.32rem 0.4rem 0.32rem 0.65rem;
  border-left: 2px solid transparent;
  color: var(--soft);
  text-decoration: none;
  font-family: var(--sans);
  font-size: 0.84rem;
  line-height: 1.35;
}

.toc-essays a:hover {
  color: var(--ink);
  border-left-color: var(--theme);
}

.toc-essays a[aria-current="page"] {
  color: var(--ink);
  background: var(--current);
  border-left-color: var(--theme);
  font-weight: 600;
}

.search-empty {
  font-family: var(--sans);
  font-size: 0.9rem;
  color: var(--muted);
  margin: 0.5rem 0 0;
}

.reading {
  width: min(var(--measure), 100%);
  padding: 1.6rem 0 4.5rem;
  font-size: 1.25rem;
  line-height: 1.65;
  font-optical-sizing: auto;
}

.masthead {
  padding: 0.85rem 0 1.7rem;
  margin-bottom: 0.4rem;
}

.eyebrow {
  margin: 0;
  font-family: var(--sans);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.masthead h1,
.essay-head h1 {
  font-family: var(--serif);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.12;
  margin: 0.35rem 0 0;
  font-optical-sizing: auto;
  text-wrap: balance;
}

.masthead h1 {
  font-size: clamp(2.7rem, 5vw, 3.7rem);
}

.deck {
  margin: 0.7rem 0 0;
  font-family: var(--sans);
  font-size: 1rem;
  color: var(--muted);
}

.theme-block {
  margin: 0 0 2.6rem;
  scroll-margin-top: calc(var(--topbar) + 0.8rem);
}

.theme-block h2 {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  margin: 0 0 0.35rem;
  padding-top: 0.15rem;
  font-family: var(--sans);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--theme);
}

.theme-block h2 span:last-child {
  margin-left: auto;
  letter-spacing: 0;
  font-weight: 500;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.contents a {
  display: grid;
  grid-template-columns: 2rem minmax(0, 1fr);
  gap: 0.65rem;
  align-items: baseline;
  padding: 0.72rem 0;
  border-top: 1px solid var(--rule);
  color: var(--ink);
  text-decoration: none;
  font-size: 1.16rem;
  line-height: 1.35;
}

.contents li:last-child a { border-bottom: 1px solid var(--rule); }

.contents a:hover .ttl { color: var(--theme); }

.ord {
  font-family: var(--sans);
  font-size: 0.75rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.essay-head {
  padding-top: 0.35rem;
  border-top: 3px solid var(--theme);
}

.kicker {
  margin: 1rem 0 0.85rem;
  font-family: var(--sans);
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.kicker a {
  color: var(--theme);
  text-decoration: none;
}

.kicker a:hover { text-decoration: underline; text-underline-offset: 0.2em; }

.essay-head h1 {
  font-size: clamp(1.85rem, 3vw, 2.45rem);
}

.byline {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.55rem;
  align-items: baseline;
  margin: 1.05rem 0 2rem;
  font-family: var(--sans);
  font-size: 0.92rem;
  color: var(--muted);
}

.byline a {
  color: var(--soft);
  text-underline-offset: 0.18em;
}

.prose { text-wrap: pretty; }

.prose p {
  margin: 0 0 1.05em;
  hyphens: auto;
  hyphenate-limit-chars: 7 4 3;
}

.prose p.num {
  padding-left: 2.6em;
  text-indent: -2.6em;
}

.prose a {
  color: var(--oxblood);
  text-underline-offset: 0.16em;
  overflow-wrap: anywhere;
}

.pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem 1.5rem;
  margin-top: 3rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--rule);
}

.pager a {
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
  text-decoration: none;
  color: var(--ink);
  min-width: 0;
}

.pager .next { text-align: right; align-items: flex-end; }

.pager span {
  font-family: var(--sans);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.pager strong {
  font-weight: 600;
  font-size: 1.02rem;
  line-height: 1.35;
}

.pager a:hover strong { color: var(--oxblood); }

.page-missing .reading h1 {
  font-weight: 600;
  font-size: clamp(2rem, 4vw, 2.8rem);
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin: 0.4rem 0 0.8rem;
}

.page-missing .reading a {
  color: var(--oxblood);
  text-underline-offset: 0.16em;
}

.site-footer {
  border-top: 1px solid var(--rule);
  padding: 1.35rem 0 2rem;
}

.site-footer p {
  margin: 0;
  font-family: var(--sans);
  font-size: 0.86rem;
  color: var(--muted);
}

.site-footer a {
  color: var(--soft);
  text-underline-offset: 0.16em;
  overflow-wrap: anywhere;
}

@media (min-width: 921px) {
  body.page-home .toc-essays { display: none; }
  body.page-home.searching .toc-essays { display: block; }
}

@media (max-width: 920px) {
  .topbar-inner,
  .layout,
  .site-footer-inner {
    width: auto;
    margin-inline: 1.1rem;
  }

  .topbar-inner { gap: 0.4rem; }

  .nav-toggle {
    display: inline-flex;
    letter-spacing: 0.08em;
    padding: 0.42rem 0.5rem;
  }

  .brand-sub { display: none; }

  :root { --topbar: 4.85rem; }

  .brand-name {
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    font-size: 1rem;
    line-height: 1.15;
    letter-spacing: -0.015em;
  }

  .langs { letter-spacing: 0.04em; }

  .langs a { padding: 0 0.38rem; }

  .layout { display: block; }

  .scrim {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(28, 23, 18, 0.38);
    z-index: 35;
  }

  body:has(#nav-toggle:checked) .scrim { display: block; }

  .toc {
    position: fixed;
    z-index: 40;
    top: var(--topbar);
    left: 0;
    right: 0;
    bottom: 0;
    height: auto;
    background: var(--paper);
    padding: 0.85rem 1.15rem 2rem;
    transform: translateX(-100%);
    visibility: hidden;
  }

  body:has(#nav-toggle:checked) .toc {
    transform: none;
    visibility: visible;
  }

  body:has(#nav-toggle:checked) { overflow: hidden; }

  .reading {
    font-size: 1.125rem;
    padding-top: 1.25rem;
  }

  .contents a { font-size: 1.08rem; }

  .pager { grid-template-columns: 1fr; }
  .pager .next { text-align: left; align-items: flex-start; }
}

@media (max-width: 380px) {
  .brand-name { font-size: 0.98rem; }
  .langs a { padding: 0 0.35rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .toc { transition: none; }
}

@media print {
  .topbar,
  .toc,
  .scrim,
  .nav-toggle,
  .pager { display: none !important; }

  body { background: white; }

  .layout,
  .site-footer-inner { width: auto; margin: 0; display: block; }

  .reading {
    width: auto;
    max-width: none;
    font-size: 12pt;
    padding: 0;
  }

  .essay-head { border-top: none; }

  a { text-decoration: none; }
}
