:root {
  color-scheme: light dark;
  --bg: #fbfaf7;
  --fg: #2b2f36;
  --muted: #6b7280;
  --line: #e4e1d9;
  --accent: #0f766e;
  --warm: #d97706;
  --code-bg: #f1efe9;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17191d;
    --fg: #d5d8de;
    --muted: #9299a5;
    --line: #2d3139;
    --accent: #5fd4c4;
    --warm: #f2b866;
    --code-bg: #21242b;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 1.0625rem;
  line-height: 1.7;
}

body::before {
  content: "";
  display: block;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--warm));
}

::selection {
  background: var(--accent);
  color: var(--bg);
}

a {
  color: var(--accent);
  text-underline-offset: 0.15em;
}

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

.site-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
  padding: 0.9rem 1.5rem;
  border-bottom: 1px solid var(--line);
}

.site-header a {
  text-decoration: none;
}

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

.site-title {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--fg);
  font-family: var(--serif);
  font-size: 1.125rem;
  font-weight: 600;
}

.loop {
  width: 1.15rem;
  height: 1.15rem;
  fill: none;
  stroke: var(--accent);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.6s ease;
}

.site-title:hover .loop {
  transform: rotate(360deg);
}

@media (prefers-reduced-motion: reduce) {
  .loop {
    transition: none;
  }
}

.page {
  display: grid;
  grid-template-columns: 17rem minmax(0, 46rem);
  justify-content: center;
  gap: 3rem;
  padding: 2rem 1.5rem 4rem;
}

.sidebar {
  position: sticky;
  top: 2rem;
  align-self: start;
  font-size: 0.9375rem;
  line-height: 1.4;
}

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

.sidebar a {
  display: block;
  padding: 0.35rem 0.75rem;
  border-left: 2px solid transparent;
  color: var(--muted);
  text-decoration: none;
}

.sidebar a:hover {
  color: var(--fg);
}

.sidebar a[aria-current] {
  border-left-color: var(--accent);
  color: var(--fg);
  font-weight: 600;
}

.sidebar ul {
  counter-reset: module;
}

.sidebar li a {
  display: flex;
  gap: 0.6rem;
}

.sidebar li a::before {
  counter-increment: module;
  content: counter(module);
  flex: none;
  display: grid;
  place-items: center;
  width: 1.35rem;
  height: 1.35rem;
  border-radius: 50%;
  background: var(--code-bg);
  font-size: 0.75rem;
  font-weight: 600;
}

.sidebar li a[aria-current]::before {
  background: var(--accent);
  color: var(--bg);
}

main h1,
main h2,
main h3 {
  font-family: var(--serif);
  line-height: 1.25;
}

main h1 {
  margin-top: 0;
  font-size: 2.25rem;
}

main h1::after {
  content: "";
  display: block;
  width: 3.5rem;
  height: 3px;
  margin-top: 0.75rem;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--accent), var(--warm));
}

main h2 {
  margin-top: 2.5rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--line);
  font-size: 1.5rem;
}

main h3 {
  margin-top: 2rem;
  font-size: 1.2rem;
}

main li {
  margin: 0.3rem 0;
}

main img {
  max-width: 100%;
}

code {
  padding: 0.15em 0.35em;
  border-radius: 4px;
  background: var(--code-bg);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.875em;
}

pre {
  overflow-x: auto;
  padding: 1rem;
  border-radius: 6px;
  background: var(--code-bg);
  line-height: 1.5;
}

pre code {
  padding: 0;
  background: none;
}

/* block display lets wide tables scroll instead of stretching the page */
table {
  display: block;
  overflow-x: auto;
  border-collapse: collapse;
  font-size: 0.9375rem;
}

th,
td {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  background: var(--code-bg);
}

.empty {
  color: var(--muted);
  font-style: italic;
}

footer {
  margin-top: 4rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.9375rem;
}

@media (max-width: 60rem) {
  .page {
    grid-template-columns: minmax(0, 46rem);
    gap: 2rem;
  }

  .sidebar {
    position: static;
    order: 2;
    padding-top: 1.5rem;
    border-top: 1px solid var(--line);
  }
}
