:root {
  color-scheme: light;
  --bg: #f4f4f2;
  --bg-pre: #ebebea;
  --ink: #1a1b1e;
  --muted: #5a5e66;
  --link: #0b44a8;
  --border: #d0d2d6;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121315;
  --bg-pre: #191b1f;
  --ink: #d6dae0;
  --muted: #8a919c;
  --link: #7aa2f7;
  --border: #2a2e35;
}

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

html {
  font-size: 15px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-mono);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--link);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

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

code {
  font-family: inherit;
  background: var(--bg-pre);
  padding: 0.05em 0.3em;
}

/* RFC 76-character column */
.rfc {
  max-width: 78ch;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4.5rem;
}

/* Standard two-column RFC metadata header */
.rfc-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.15rem 1rem;
  font-size: 0.88rem;
  color: var(--muted);
  margin-bottom: 2rem;
}

.rfc-meta .right {
  text-align: right;
}

.theme-btn {
  background: none;
  border: none;
  font-family: inherit;
  font-size: inherit;
  color: var(--muted);
  cursor: pointer;
  padding: 0;
  margin-left: 0.75rem;
}

.theme-btn:hover {
  color: var(--ink);
  text-decoration: underline;
}

/* Title & Abstract */
.rfc-title {
  margin-bottom: 1.75rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.rfc-title h1 {
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.35;
  margin-bottom: 1rem;
}

.rfc-abstract-label {
  font-weight: 600;
  font-size: 0.92rem;
  margin-bottom: 0.4rem;
}

.rfc-title p {
  color: var(--ink);
  margin-bottom: 1rem;
}

.rfc-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.25rem;
  font-size: 0.9rem;
}

/* Table of Contents */
.rfc-toc {
  margin-bottom: 2.25rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
}

.rfc-toc-title {
  font-weight: 600;
  font-size: 0.92rem;
  margin-bottom: 0.65rem;
}

.rfc-toc-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.rfc-toc-sub {
  list-style: none;
  padding-left: 3ch;
  margin: 0.2rem 0 0.35rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.toc-row {
  display: grid;
  grid-template-columns: 15ch 1fr auto;
  gap: 0.75rem;
  align-items: baseline;
}

.toc-row a {
  color: var(--ink);
  font-weight: 500;
}

.toc-row a:hover {
  color: var(--link);
}

.toc-desc {
  color: var(--muted);
}

.toc-lang {
  color: var(--muted);
  font-size: 0.82rem;
  text-align: right;
}

/* Sections */
section {
  margin-bottom: 2.75rem;
}

.sec-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  margin-bottom: 1.35rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
}

.sec-body {
  padding-left: 2.5ch;
}

section > pre,
section > .rfc-list,
section > .facts {
  margin-left: 2.5ch;
}

h2 {
  font-size: 1.05rem;
  font-weight: 600;
}

h3 {
  font-size: 0.98rem;
  font-weight: 600;
}

.pilcrow {
  color: var(--border);
  margin-left: 0.45rem;
  font-weight: 400;
  text-decoration: none;
}

h2:hover .pilcrow,
h3:hover .pilcrow,
.pilcrow:focus-visible {
  color: var(--muted);
  text-decoration: none;
}

/* Bracketed RFC-style filters */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  font-size: 0.86rem;
}

.filter-btn {
  background: none;
  border: none;
  font-family: inherit;
  font-size: inherit;
  color: var(--muted);
  cursor: pointer;
  padding: 0;
}

.filter-btn:hover {
  color: var(--ink);
  text-decoration: underline;
}

.filter-btn.active {
  color: var(--ink);
  font-weight: 600;
}

/* Project entries */
.project {
  margin-bottom: 2rem;
  padding-bottom: 1.75rem;
  border-bottom: 1px dashed var(--border);
}

.project:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.project-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.35rem 1rem;
  margin-bottom: 0.55rem;
}

.project-head h3 a.proj-name {
  color: var(--ink);
}

.project-head h3 a.proj-name:hover {
  color: var(--link);
}

.lang {
  color: var(--muted);
  font-weight: 400;
  font-size: 0.86rem;
  margin-left: 0.4rem;
}

.project-links {
  display: flex;
  gap: 0.9rem;
  font-size: 0.88rem;
}

.project-body {
  padding-left: 4.5ch;
}

.project-desc {
  margin-bottom: 0.85rem;
}

/* Aligned key-value specs */
.facts {
  display: grid;
  grid-template-columns: 14ch 1fr;
  gap: 0.25rem 1rem;
  font-size: 0.9rem;
  margin-bottom: 0.85rem;
}

.facts dt {
  color: var(--muted);
}

.facts dd {
  color: var(--ink);
}

/* Collapsible output */
details {
  margin-top: 0.4rem;
}

summary {
  display: inline-block;
  font-size: 0.88rem;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}

summary:hover {
  color: var(--ink);
}

details[open] summary {
  color: var(--ink);
  margin-bottom: 0.65rem;
}

pre {
  background: var(--bg-pre);
  border: 1px solid var(--border);
  padding: 0.85rem 1rem;
  font-family: inherit;
  font-size: 0.84rem;
  line-height: 1.5;
  overflow-x: auto;
  color: var(--ink);
}

.figure {
  border: 1px solid var(--border);
  background: #ffffff;
}

.figure img {
  display: block;
  width: 100%;
  height: auto;
}

:root[data-theme="dark"] .figure img {
  filter: brightness(0.88);
}

.figure figcaption {
  padding: 0.55rem 0.85rem;
  font-size: 0.82rem;
  color: var(--muted);
  background: var(--bg-pre);
  border-top: 1px solid var(--border);
}

/* Prose & Lists */
.prose {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.rfc-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.rfc-list li {
  padding-left: 2ch;
  text-indent: -2ch;
}

.rfc-list li::before {
  content: "* ";
  color: var(--muted);
}

.rfc-list strong {
  font-weight: 600;
}

/* Footer */
.rfc-footer {
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  font-size: 0.84rem;
  color: var(--muted);
}

@media (max-width: 580px) {
  html {
    font-size: 14px;
  }

  .rfc {
    padding: 1.5rem 1rem 3rem;
  }

  .rfc-meta {
    grid-template-columns: 1fr;
  }

  .rfc-meta .right {
    text-align: left;
  }

  .facts {
    grid-template-columns: 1fr;
    gap: 0.1rem;
  }

  .facts dt {
    margin-top: 0.4rem;
  }

  .facts dt:first-child {
    margin-top: 0;
  }

  .sec-body,
  .project-body {
    padding-left: 0;
  }

  section > pre,
  section > .rfc-list,
  section > .facts {
    margin-left: 0;
  }

  .rfc-toc-sub {
    padding-left: 2ch;
  }

  .toc-row {
    grid-template-columns: 1fr auto;
  }

  .toc-desc {
    display: none;
  }
}
