:root {
  color-scheme: light dark;
  --bg: #f6f3ea;
  --panel: #fffaf0;
  --text: #171715;
  --muted: #6f6a5f;
  --line: #d8d0bf;
  --accent: #8c3f24;
  --code-bg: #eee6d6;
  --font-body: ui-serif, "Noto Serif SC", "Source Han Serif SC", "Songti SC", Georgia, serif;
  --font-sans: ui-sans-serif, "Noto Sans SC", "Source Han Sans SC", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171715;
    --panel: #201f1b;
    --text: #eee8dc;
    --muted: #aaa193;
    --line: #3a372f;
    --accent: #e0a06f;
    --code-bg: #2a2923;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 12% 0%, rgba(140, 63, 36, 0.12), transparent 34rem),
    linear-gradient(180deg, var(--bg), var(--bg));
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.72;
}

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

.site-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem clamp(1rem, 3vw, 3rem);
  border-bottom: 1px solid var(--line);
  font-family: var(--font-sans);
}

.site-title,
.site-nav a {
  color: var(--text);
  text-decoration: none;
}

.site-title {
  font-family: var(--font-mono);
  font-weight: 700;
  letter-spacing: 0.04em;
}

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

.home-hero,
.doc-index,
.page-shell {
  max-width: 76ch;
  margin: 0 auto;
  padding: clamp(2rem, 7vw, 6rem) 1rem;
}

.eyebrow,
.doc-id,
.toc-title {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  line-height: 1.18;
}

.article-shell {
  display: grid;
  grid-template-columns: minmax(11rem, 0.8fr) minmax(0, 76ch) minmax(12rem, 0.9fr);
  gap: clamp(1rem, 3vw, 3rem);
  padding: clamp(2rem, 4vw, 4rem);
}

.article-meta,
.article-toc {
  color: var(--muted);
  font-family: var(--font-sans);
  font-size: 0.9rem;
}

.article-toc {
  position: sticky;
  top: 1rem;
  align-self: start;
}

.article-header {
  border-bottom: 1px solid var(--line);
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
}

.article-header h1 {
  font-size: clamp(2rem, 5vw, 4.25rem);
  letter-spacing: -0.04em;
}

.summary {
  color: var(--muted);
  font-family: var(--font-sans);
}

.article-body {
  max-width: 76ch;
}

.article-license {
  margin-top: 3rem;
  padding: 1rem 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-family: var(--font-sans);
  font-size: 0.92rem;
}

.article-license p {
  margin: 0;
}

.article-body pre {
  overflow-x: auto;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 0.35rem;
  background: var(--code-bg);
}

.article-body code {
  font-family: var(--font-mono);
}

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

.doc-list li {
  display: grid;
  grid-template-columns: 7rem 1fr auto;
  gap: 1rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--line);
}

.comments {
  margin-top: 4rem;
  padding-top: 2rem;
  border-top: 1px solid var(--line);
}

.comment-list {
  display: grid;
  gap: 1rem;
  margin: 1.5rem 0;
}

.comment {
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: color-mix(in srgb, var(--panel), transparent 20%);
}

.comment-replies {
  display: grid;
  gap: 0.75rem;
  margin-top: 1rem;
  padding-left: 1rem;
  border-left: 2px solid var(--line);
}

.comment-reply {
  background: transparent;
}

.comment-header {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  align-items: baseline;
  color: var(--muted);
  font-family: var(--font-sans);
  font-size: 0.9rem;
}

.comment-header strong {
  color: var(--text);
}

.comment-body {
  margin-top: 0.75rem;
}

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

.comment-body > :last-child {
  margin-bottom: 0;
}

.comment-actions {
  margin-top: 0.75rem;
}

.comment-form {
  display: grid;
  gap: 1rem;
  margin-top: 2rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: var(--panel);
}

.comment-form label {
  display: grid;
  gap: 0.35rem;
  color: var(--muted);
  font-family: var(--font-sans);
  font-size: 0.9rem;
}

.comment-form input,
.comment-form select,
.comment-form textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 0.35rem;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  padding: 0.65rem 0.75rem;
}

.comment-form textarea {
  resize: vertical;
}

.checkbox-label {
  grid-template-columns: auto 1fr;
  align-items: center;
}

.checkbox-label input {
  width: auto;
}

.comment-form button,
.comment-actions button {
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  font-family: var(--font-sans);
  padding: 0.45rem 0.9rem;
}

.comment-error {
  min-height: 1.4em;
  color: var(--accent);
  font-family: var(--font-sans);
  margin: 0;
}

.honeypot {
  display: none;
}

.comment-highlight {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

@media (max-width: 900px) {
  .article-shell {
    display: block;
    padding: 1rem;
  }

  .article-meta,
  .article-toc {
    position: static;
    margin: 1rem 0 2rem;
  }

  .doc-list li {
    grid-template-columns: 1fr;
    gap: 0.25rem;
  }
}
