:root {
  color-scheme: light dark;
  font-family:
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  font-size: 16px;
  line-height: 1.6;
  --background: #f5f0e7;
  --surface: #ece5d9;
  --text: #25221e;
  --heading: #171411;
  --muted: #675f55;
  --link: #74401d;
  --border: #cfc4b3;
  --accent: #b45d22;
  --focus: #ffbf47;
}

@media (prefers-color-scheme: dark) {
  :root {
    --background: #040506;
    --surface: #0b0b0a;
    --text: #b6aa99;
    --heading: #e0e0e0;
    --muted: #a69987;
    --link: #e8dcc0;
    --border: #6b5a35;
    --accent: #ff9800;
  }
}

* {
  box-sizing: border-box;
}

html {
  background: var(--background);
  color: var(--text);
}

body {
  margin: 0;
}

a {
  color: var(--link);
  text-decoration: none;
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.15em;
}

a:hover,
a:focus-visible {
  color: var(--accent);
  text-decoration-line: underline;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  color: var(--heading);
  font-family:
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  line-height: 1.18;
}

h1 {
  margin: 0 0 1.25rem;
  font-size: clamp(2rem, 4vw, 2.75rem);
  font-weight: 680;
  letter-spacing: -0.035em;
}

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

.skip-link {
  position: absolute;
  left: 1rem;
  top: -5rem;
  z-index: 3;
  padding: 0.5rem 0.75rem;
  color: var(--heading);
  background: var(--background);
  border: 1px solid var(--border);
}

.skip-link:focus {
  top: 0.5rem;
}

.site-header {
  border-bottom: 1px solid var(--border);
}

.site-header-inner {
  display: flex;
  align-items: center;
  gap: 0.75rem clamp(1rem, 2vw, 2rem);
  margin: 0 auto;
  padding: 0.8rem clamp(1rem, 2.5vw, 2rem);
}

.site-name {
  color: var(--heading);
  font-weight: 720;
  letter-spacing: -0.02em;
  text-decoration: none;
}

.primary-nav,
.site-search {
  display: flex;
  align-items: center;
  gap: 0.55rem 1rem;
}

.primary-nav {
  flex-wrap: wrap;
  margin-right: auto;
  font-size: 0.95rem;
}

.primary-nav a {
  white-space: nowrap;
}

.site-search input {
  min-width: 0;
  width: 12rem;
  padding: 0.35rem 0.55rem;
  color: var(--text);
  background: var(--background);
  border: 1px solid var(--border);
}

.site-search button {
  padding: 0.35rem 0.7rem;
  color: var(--heading);
  background: var(--surface);
  border: 1px solid var(--border);
}

.layout {
  margin: 0 auto;
  padding: clamp(2.25rem, 5vw, 4.5rem) clamp(1rem, 2.5vw, 2rem) 6rem;
}

.single-column {
  margin: 0 auto;
  padding: clamp(2.25rem, 5vw, 4.5rem) clamp(1rem, 2.5vw, 2rem) 6rem;
}

article,
.rail {
  min-width: 0;
}

.layout > article {
  display: flow-root;
}

.prose {
  overflow-wrap: anywhere;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.04rem, 1.6vw, 1.15rem);
  line-height: 1.72;
}

.prose > :first-child {
  margin-top: 0;
}

.content-page .prose > h1:first-child,
.raw-capture .prose > h1:first-child {
  display: none;
}

.prose h1 {
  font-size: clamp(2rem, 4vw, 2.75rem);
}

.prose h2 {
  margin-top: 2.6em;
  font-size: 1.55rem;
}

.prose h3 {
  margin-top: 2em;
  font-size: 1.2rem;
}

.prose li + li {
  margin-top: 0.35rem;
}

.prose blockquote {
  margin-left: 0;
  padding-left: 1.1rem;
  color: var(--muted);
  border-left: 3px solid var(--border);
}

.prose img,
.prose video {
  max-width: 100%;
  height: auto;
}

.prose pre {
  overflow-x: auto;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
}

.prose code,
.prose pre {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.9em;
}

.prose table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
  font-family:
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  font-size: 0.9rem;
  line-height: 1.45;
}

.prose th,
.prose td {
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border);
}

.raw-capture .prose {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1rem;
}

.eyebrow,
.result-meta,
.term-list span,
.index-rows span,
.directory-index li > span,
.directory-index time {
  color: var(--muted);
}

.eyebrow {
  margin: 0 0 0.6rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.rail > *,
.backlinks {
  margin: 0 0 0.9rem;
  padding: 0.75rem 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.rail {
  float: right;
  width: clamp(15rem, 22vw, 19rem);
  margin: 0 0 2rem clamp(1.5rem, 3vw, 3rem);
  font-size: 0.95rem;
}

.toc ol,
.page-facets ul,
.backlinks ul {
  padding-left: 1.15rem;
}

.toc ol ol {
  margin-top: 0.35rem;
}

.toc li + li,
.backlinks li + li {
  margin-top: 0.3rem;
}

.toc summary,
.backlinks summary {
  cursor: pointer;
  color: var(--heading);
  font-weight: 650;
}

.page-facets h2 {
  margin: 0 0 0.35rem;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.page-facets ul {
  margin: 0;
}

.facet-group + .facet-group {
  margin-top: 1rem;
}

.directory-index {
  clear: both;
  margin-top: 1.5rem;
}

.directory-index h2 {
  font-size: 1.1rem;
}

.directory-index ul,
.term-list,
.page-list,
.search-results {
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--border);
}

.directory-index li,
.term-list li,
.index-rows li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--border);
}

.backlinks {
  clear: both;
}

.directory-index li > span,
.directory-index time,
.index-rows span,
.term-list span {
  font-size: 0.78rem;
}

.directory-index li > span,
.index-rows span,
.term-list span {
  text-transform: lowercase;
}

.directory-index time {
  font-variant-numeric: tabular-nums;
}

.topic-entry {
  margin: 1.5rem 0 2rem;
  padding-left: 0.8rem;
  border-left: 3px solid var(--accent);
}

.search-results > li {
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
}

.search-results h2 {
  margin: 0 0 0.2rem;
  font-size: 1.2rem;
}

.search-results p {
  margin: 0.25rem 0;
}

.search-results article {
  display: grid;
  grid-template-columns: minmax(14rem, 0.45fr) minmax(0, 1fr);
  gap: 0 1.5rem;
}

.search-results article > p:not(.result-meta) {
  grid-column: 2;
  grid-row: 1 / span 2;
}

mark {
  color: var(--heading);
  background: color-mix(in srgb, var(--accent) 25%, transparent);
}

@media (max-width: 70rem) {
  .site-header-inner {
    flex-wrap: wrap;
  }

  .site-search {
    flex-basis: 100%;
  }

  .site-search input {
    flex: 1;
    width: auto;
  }
}

@media (max-width: 52rem) {
  .site-header-inner {
    align-items: flex-start;
    padding-inline: 1rem;
  }

  .site-name {
    order: 1;
  }

  .primary-nav {
    order: 2;
    flex-basis: 100%;
    margin-right: 0;
  }

  .site-search {
    order: 3;
  }

  .layout {
    padding-inline: 1rem;
  }

  .rail {
    float: none;
    width: auto;
    margin: 0 0 1.75rem;
  }

  .single-column {
    padding-inline: 1rem;
  }

  .prose {
    font-size: 1.03rem;
  }

  .prose h2 {
    font-size: 1.375rem;
  }

  .search-results article {
    display: block;
  }
}

@media (max-width: 30rem) {
  .directory-index li,
  .term-list li,
  .index-rows li {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.15rem;
  }
}
