:root {
  --bg: #f4f4f1;
  --fg: #111;
  --muted: #555;
  --rule: #111;
  --rule-soft: #ccc;
  --max-w: 920px;
  --sans: "Helvetica Neue", Helvetica, Arial, system-ui, sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
}

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

body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--fg);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

a:hover {
  text-decoration: none;
}

code {
  font-family: var(--mono);
  font-size: 0.9em;
}

pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
}

button {
  font: inherit;
  cursor: pointer;
}

/* ── layout ────────────────────────────────────────────────── */

.page {
  width: min(calc(100% - 3rem), var(--max-w));
  margin: 0 auto;
  padding: 3rem 0 5rem;
}

.rule {
  border: none;
  border-top: 2px solid var(--rule);
  margin: 2.5rem 0;
}

.rule--soft {
  border-top: 1px solid var(--rule-soft);
  margin: 2rem 0;
}

/* ── header ────────────────────────────────────────────────── */

.site-header {
  padding-bottom: 2.5rem;
  border-bottom: 3px solid var(--fg);
}

.site-name {
  font-size: clamp(2.4rem, 5.5vw, 4rem);
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1;
  text-transform: uppercase;
}

.site-desc {
  margin-top: 0.75rem;
  color: var(--muted);
  font-size: 0.95rem;
  max-width: 52ch;
}

/* ── section headings ──────────────────────────────────────── */

.section-label {
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

.section-title {
  font-size: clamp(1.5rem, 3vw, 2rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.section-head {
  margin-bottom: 1.5rem;
}

/* ── corpus grid ───────────────────────────────────────────── */

.corpus-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 2px;
  background: var(--fg);
  border: 2px solid var(--fg);
}

.corpus-item {
  background: var(--bg);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
}

.corpus-native {
  font-size: 1.8rem;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.corpus-english {
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 0.15rem;
}

.corpus-license {
  display: inline-block;
  margin-top: 0.6rem;
  font-size: 0.7rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--muted);
  border: 1px solid var(--rule-soft);
  padding: 0.15rem 0.5rem;
}

.corpus-meta {
  margin-top: auto;
  padding-top: 1rem;
}

.corpus-meta dl {
  display: grid;
  grid-template-columns: 6rem 1fr;
  gap: 0.25rem 0.75rem;
  font-size: 0.85rem;
  border-top: 1px solid var(--rule-soft);
  padding-top: 0.75rem;
}

.corpus-meta dt {
  color: var(--muted);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  align-self: baseline;
}

.corpus-meta dd {
  margin: 0;
}

.corpus-links {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.75rem;
  font-size: 0.85rem;
}

.corpus-links a {
  text-decoration: none;
  border-bottom: 1px solid var(--rule-soft);
  padding-bottom: 1px;
}

.corpus-links a:hover {
  border-color: var(--fg);
}

.corpus-links button {
  background: none;
  border: none;
  border-bottom: 1px solid var(--rule-soft);
  padding: 0 0 1px;
  font-size: 0.85rem;
  color: var(--muted);
}

.corpus-links button:hover {
  color: var(--fg);
  border-color: var(--fg);
}

.corpus-links button.is-copied {
  color: var(--fg);
  border-color: var(--fg);
}

/* ── principles ────────────────────────────────────────────── */

.principles {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2rem;
}

.principle h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
}

.principle p {
  color: var(--muted);
  font-size: 0.88rem;
}

/* ── endpoints ─────────────────────────────────────────────── */

.endpoints {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

.endpoint-block h3 {
  font-size: 0.7rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

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

.endpoint-list li {
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--rule-soft);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
}

.endpoint-list code {
  font-size: 0.82rem;
}

.endpoint-list span {
  font-size: 0.8rem;
  color: var(--muted);
  text-align: right;
}

/* ── sources ───────────────────────────────────────────────── */

.sources {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2rem;
}

.source h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
}

.source p {
  color: var(--muted);
  font-size: 0.88rem;
}

/* ── faq ───────────────────────────────────────────────────── */

.faq-list {
  border-top: 1px solid var(--rule-soft);
}

.faq-item {
  border-bottom: 1px solid var(--rule-soft);
  padding: 0.75rem 0;
}

.faq-item summary {
  cursor: pointer;
  list-style: none;
  font-size: 0.95rem;
  font-weight: 500;
}

.faq-item summary::-webkit-details-marker {
  display: none;
}

.faq-item summary::before {
  content: "+";
  display: inline-block;
  width: 1.2rem;
  font-weight: 400;
  color: var(--muted);
}

.faq-item[open] summary::before {
  content: "\2212";
}

.faq-item p {
  margin: 0.5rem 0 0 1.2rem;
  color: var(--muted);
  font-size: 0.88rem;
}

/* ── footer ────────────────────────────────────────────────── */

.site-footer {
  padding-top: 1.5rem;
  border-top: 2px solid var(--fg);
  font-size: 0.8rem;
  color: var(--muted);
}

/* ── actions row ───────────────────────────────────────────── */

.actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  padding: 0.5rem 1rem;
  font-size: 0.82rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-decoration: none;
  border: 1px solid var(--fg);
  background: transparent;
  color: var(--fg);
  cursor: pointer;
  transition: background 100ms, color 100ms;
}

.btn:hover {
  background: var(--fg);
  color: var(--bg);
}

.btn--primary {
  background: var(--fg);
  color: var(--bg);
}

.btn--primary:hover {
  background: transparent;
  color: var(--fg);
}

.btn.is-copied {
  background: var(--fg);
  color: var(--bg);
}

/* ── terms ──────────────────────────────────────────────────── */

.terms {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem 2rem;
}

.terms-block h3 {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.terms-block p {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.65;
}

/* ── browse ─────────────────────────────────────────────────── */

.browse-collection {
  border-bottom: 1px solid var(--rule-soft);
}

.browse-collection summary {
  cursor: pointer;
  list-style: none;
  padding: 0.65rem 0;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  font-size: 0.95rem;
}

.browse-collection summary::-webkit-details-marker {
  display: none;
}

.browse-collection summary::before {
  content: "+";
  display: inline-block;
  width: 1rem;
  flex-shrink: 0;
  font-weight: 400;
  color: var(--muted);
}

.browse-collection[open] summary::before {
  content: "\2212";
}

.browse-name {
  font-weight: 600;
  flex: 1;
}

.browse-count {
  font-size: 0.8rem;
  color: var(--muted);
}

.browse-books {
  list-style: none;
  padding: 0 0 0.75rem 1rem;
  margin: 0;
  columns: 3;
  column-gap: 1.5rem;
}

.browse-books li {
  padding: 0.15rem 0;
  font-size: 0.82rem;
  break-inside: avoid;
}

.browse-books a {
  text-decoration: none;
  border-bottom: 1px solid var(--rule-soft);
}

.browse-books a:hover {
  border-color: var(--fg);
}

.browse-books .book-detail {
  color: var(--muted);
  font-size: 0.75rem;
  margin-left: 0.25rem;
}

/* ── responsive ────────────────────────────────────────────── */

@media (max-width: 720px) {
  .page {
    width: min(calc(100% - 2rem), var(--max-w));
    padding: 2rem 0 3rem;
  }

  .corpus-grid {
    grid-template-columns: 1fr;
  }

  .principles,
  .sources,
  .terms {
    grid-template-columns: 1fr;
    gap: 1.25rem;
  }

  .endpoints {
    grid-template-columns: 1fr;
  }

  .site-name {
    font-size: clamp(1.8rem, 8vw, 3rem);
  }

  .browse-books {
    columns: 1;
  }
}
