:root {
  color-scheme: light;
  --ink: #1c1730;
  --muted: #3f3a52;
  --paper: #f6f3ee;
  --paper-2: #fffdf9;
  --line: #e2d9c8;
  --header: #1b1724;
  --header-ink: #f7f4ef;
  --gold: #8a6a2f;
  --link: #2a2460;
  --mark: #f3e2b0;
  --focus: #8a6a2f;
  --serif: "Iowan Old Style", Palatino, "Palatino Linotype", Georgia, serif;
  --sans: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --measure: 68ch;
}

* { box-sizing: border-box; }

html { scroll-behavior: auto; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 0 0, rgba(138, 106, 47, 0.08), transparent 36%),
    var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1.05rem;
  line-height: 1.65;
}

a { color: var(--link); }

a:hover { text-decoration-thickness: 2px; }

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

.skip-link {
  position: absolute;
  left: 0.75rem;
  top: 0.75rem;
  transform: translateY(-150%);
  background: var(--header);
  color: var(--header-ink);
  padding: 0.6rem 1rem;
  z-index: 20;
}

.skip-link:focus { transform: none; }

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

.site-header {
  background: var(--header);
  color: var(--header-ink);
  border-bottom: 4px solid var(--gold);
}

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0.9rem 1.1rem 1rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.1rem;
}

.brand {
  color: var(--header-ink);
  font-family: var(--serif);
  font-size: 1.35rem;
  font-weight: 700;
  text-decoration: none;
  letter-spacing: 0.01em;
}

.tagline {
  margin: 0;
  flex-basis: 100%;
  order: 5;
  color: #d9d0c2;
  font-size: 0.95rem;
}

.menu-button {
  margin-left: auto;
  min-height: 44px;
  min-width: 44px;
  border: 1px solid #d9d0c2;
  background: transparent;
  color: var(--header-ink);
  border-radius: 999px;
  padding: 0.4rem 0.9rem;
  font: inherit;
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.site-nav a {
  color: var(--header-ink);
  text-decoration: none;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
}

.site-nav a[aria-current="page"],
.site-nav a:hover {
  background: rgba(255, 255, 255, 0.1);
  text-decoration: underline;
}

.header-search {
  display: flex;
  gap: 0.4rem;
  margin-left: auto;
  flex: 1 1 220px;
  max-width: 360px;
}

.header-search input,
.library-tools input,
.search-box input {
  flex: 1;
  min-height: 44px;
  border-radius: 999px;
  border: 1px solid #d9d0c2;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 1rem;
  padding: 0.45rem 0.9rem;
}

.header-search button,
.search-box button,
.header-search input,
.library-tools input,
.search-box input {
  font-size: 1rem;
}

.header-search button,
.search-box button {
  min-height: 44px;
  border-radius: 999px;
  border: 0;
  background: var(--gold);
  color: #fff;
  font: inherit;
  padding: 0.4rem 0.9rem;
}

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem 1.1rem 3rem;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1.5rem;
  align-items: center;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 1.4rem 1.3rem;
}

.hero h1 {
  font-family: var(--serif);
  font-size: clamp(2rem, 4vw, 3.1rem);
  line-height: 1.15;
  margin: 0 0 0.4rem;
}

.lede { font-size: 1.15rem; margin-top: 0; }

.hero-mark { margin: 0; text-align: center; }

.hero-mark img { width: 168px; height: auto; }

.hero-mark figcaption {
  color: var(--muted);
  font-size: 0.92rem;
  max-width: 16rem;
}

.excerpt {
  margin-top: 1.4rem;
  max-width: var(--measure);
  font-family: var(--serif);
  font-size: 1.12rem;
}

.excerpt blockquote {
  margin: 0 0 1rem;
  padding-left: 1rem;
  border-left: 3px solid var(--gold);
}

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

.card {
  display: block;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.9rem 1rem;
  text-decoration: none;
  color: var(--ink);
  min-height: 44px;
}

.card strong { display: block; color: var(--link); }

.card span { color: var(--muted); font-size: 0.95rem; }

.article {
  max-width: 78ch;
  font-family: var(--serif);
  font-size: 1.12rem;
}

.article h1, .article h2, .article h3, .page-title {
  font-family: var(--serif);
  line-height: 1.25;
}

.meta, .tags { color: var(--muted); font-family: var(--sans); font-size: 0.95rem; }

.crumb { font-family: var(--sans); font-size: 0.95rem; margin: 0 0 0.8rem; }

.article img { max-width: 100%; height: auto; }

.article table {
  border-collapse: collapse;
  width: 100%;
  font-family: var(--sans);
  font-size: 0.98rem;
}

.article th, .article td {
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  padding: 0.4rem 0.55rem;
}

.article pre {
  overflow: auto;
  background: #241f33;
  color: #f7f4ef;
  padding: 0.9rem 1rem;
  border-radius: 10px;
  font-size: 0.92rem;
}

.article code { font-size: 0.95em; }

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

.unresolved {
  border-bottom: 1px dashed var(--gold);
  cursor: help;
}

.missing-file {
  display: inline-block;
  background: #fff6e4;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.15rem 0.45rem;
  font-family: var(--sans);
  font-size: 0.95rem;
}

mark { background: var(--mark); }

.library-tools, .search-box { margin: 0.5rem 0 1rem; max-width: 40rem; }

.note-group { margin: 0 0 1.4rem; }

.note-group h2 { font-family: var(--serif); font-size: 1.45rem; }

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

.note-list li { border-bottom: 1px solid var(--line); }

.note-list a {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.55rem 0;
  min-height: 44px;
  align-items: baseline;
  text-decoration: none;
}

.note-list a:hover { text-decoration: underline; }

.note-list small { color: var(--muted); font-size: 0.82rem; }

.result {
  display: block;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.8rem 1rem;
  margin: 0 0 0.7rem;
  text-decoration: none;
  color: var(--ink);
}

.result strong { color: var(--link); display: block; }

.site-footer {
  border-top: 1px solid var(--line);
  padding: 1.2rem 1.1rem 2rem;
  color: var(--muted);
  font-size: 0.95rem;
}

.site-footer .inner { max-width: 1100px; margin: 0 auto; }

.site-footer p { margin: 0.3rem 0; }

.download-list { list-style: none; padding: 0; }

.download-list li {
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.8rem 1rem;
  margin: 0 0 0.7rem;
}

@media (max-width: 800px) {
  .menu-button { display: inline-flex; align-items: center; justify-content: center; }
  .site-nav { display: none; flex-basis: 100%; flex-direction: column; }
  .site-nav.is-open { display: flex; }
  .header-search { max-width: none; flex-basis: 100%; margin-left: 0; }
  .hero { grid-template-columns: 1fr; }
  .tagline { order: 0; flex-basis: auto; }
  .article table { display: block; overflow-x: auto; }
}

@media (min-width: 801px) {
  .menu-button { display: none; }
  .tagline { flex-basis: auto; order: 0; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}
