:root {
  --bg: #0e0f0c;
  --bg-rail: #12130f;
  --ink: #eceae3;
  --muted: #c2c0b6;
  --line: #2c2d27;
  --accent: #d6ff4a;
  --code: #171812;
  --measure: 66ch;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Syne, "Avenir Next", "Segoe UI", sans-serif;
  font-weight: 400;
  font-size: 1.0625rem;
  line-height: 1.55;
}

::selection {
  background: var(--accent);
  color: #14150f;
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

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

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

.skip {
  position: absolute;
  left: 1rem;
  top: 0;
  transform: translateY(-120%);
  background: var(--accent);
  color: #14150f;
  padding: 0.5rem 0.8rem;
  z-index: 5;
}

.skip:focus { transform: none; }

.frame {
  display: grid;
  grid-template-columns: 15.5rem minmax(0, 1fr);
  min-height: 100vh;
}

.rail {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  padding: 1.6rem 1.3rem 1.4rem;
  background: var(--bg-rail);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.mark {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  color: inherit;
  text-decoration: none;
}

.mark strong {
  font-weight: 700;
  letter-spacing: -0.04em;
  font-size: 1.15rem;
}

.mark span,
.rail nav a,
.kicker,
.meta,
code,
pre,
th {
  font-family: "IBM Plex Mono", ui-monospace, "Cascadia Mono", Menlo, Consolas, monospace;
}

.mark span {
  color: var(--muted);
  font-size: 0.75rem;
}

.rail nav {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

  .rail nav a {
    color: var(--muted);
    text-decoration: none;
    font-size: 0.78rem;
    letter-spacing: 0.02em;
    padding: 0.28rem 0;
    white-space: nowrap;
  }

.rail nav a:hover,
.rail nav a:focus-visible { color: var(--ink); }

.rail-foot {
  margin-top: auto;
  color: var(--muted);
  font-size: 0.75rem;
  font-family: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
}

.sheet {
  padding: clamp(2.2rem, 5vw, 4.5rem) clamp(1.3rem, 4vw, 4.5rem) 5rem;
  max-width: 76rem;
  min-width: 0;
}

h1 {
  margin: 0;
  max-width: 3.15em;
  font-size: clamp(3.3rem, 8vw, 6.1rem);
  line-height: 1;
  letter-spacing: -0.055em;
  font-weight: 700;
}

.trace {
  display: flex;
  align-items: center;
  margin: 1.6rem 0 1.4rem;
  max-width: 36rem;
}

.trace::before {
  content: "";
  width: 6.5rem;
  height: 1px;
  background: var(--accent);
}

.trace i {
  width: 0.45rem;
  height: 0.45rem;
  margin-left: -1px;
  border: 1px solid var(--accent);
  transform: rotate(45deg);
}

.trace::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.lede {
  max-width: 38rem;
  font-size: 1.2rem;
  font-weight: 500;
  color: var(--ink);
}

.meta {
  color: var(--muted);
  font-size: 0.82rem;
}

section { margin-top: 4.5rem; }

h2 {
  margin: 0 0 0.9rem;
  font-size: clamp(1.8rem, 3vw, 2.4rem);
  letter-spacing: -0.04em;
  line-height: 1.05;
  font-weight: 700;
}

.kicker {
  display: block;
  margin-bottom: 0.55rem;
  color: var(--accent);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

p { max-width: var(--measure); }

ul, ol { max-width: 70ch; padding-left: 1.15rem; }

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

pre {
  max-width: min(46rem, 100%);
  background: var(--code);
  border: 1px solid var(--line);
  padding: 1rem 1.1rem;
  overflow-x: auto;
  font-size: 0.86rem;
  line-height: 1.55;
}

code {
  font-size: 0.92em;
}

p code, li code, td code {
  background: var(--code);
  border: 1px solid var(--line);
  padding: 0.05em 0.3em;
  overflow-wrap: anywhere;
}

table {
  width: min(100%, 46rem);
  max-width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

th, td {
  text-align: left;
  vertical-align: top;
  padding: 0.7rem 0.8rem 0.7rem 0;
  border-bottom: 1px solid var(--line);
}

th {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

td:first-child { white-space: nowrap; }

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

.missing {
  border-left: 2px solid var(--accent);
  padding-left: 0.9rem;
}

footer.colophon {
  margin-top: 4.5rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.85rem;
  max-width: 46rem;
}

@media (max-width: 800px) {
  .frame { grid-template-columns: minmax(0, 1fr); }
  .rail {
    position: sticky;
    top: 0;
    height: auto;
    z-index: 3;
    max-width: 100%;
    min-width: 0;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 0.85rem 1rem 0.7rem;
    gap: 0.7rem;
    background: rgba(18, 19, 15, 0.94);
  }
  .rail nav {
    flex-direction: row;
    gap: 0.9rem;
    overflow-x: auto;
  }
  .rail-foot { display: none; }
  section { scroll-margin-top: 7.5rem; }
  .sheet { padding-top: 1.8rem; }
  table { display: block; overflow-x: auto; }
  td:first-child { white-space: normal; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}
