:root {
  color-scheme: dark;
  --bg: #292524;
  --surface: #302c2a;
  --text: #f4f4f2;
  --body: #e7e2df;
  --muted: #b6aaa4;
  --faint: #8d827d;
  --border: #403b38;
  --soft: #211e1d;
  --accent: #ea580c;
  --accent-soft: rgba(234, 88, 12, 0.16);
  --max: 1180px;
  --article: 680px;
  --ui: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

* {
  box-sizing: border-box;
}

::selection {
  background: rgba(234, 88, 12, 0.28);
  color: var(--text);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--ui);
  font-size: 16px;
  line-height: 1.72;
  text-rendering: optimizeLegibility;
}

a {
  color: inherit;
  text-decoration-color: rgba(234, 88, 12, 0.55);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

a:hover {
  color: var(--accent);
  text-decoration-color: var(--accent);
}

.site-header {
  border-bottom: 1px solid var(--border);
  background: rgba(41, 37, 36, 0.96);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-inner {
  align-items: center;
  display: flex;
  gap: 24px;
  justify-content: space-between;
  margin: 0 auto;
  max-width: var(--max);
  min-height: 56px;
  padding: 0 24px;
}

.brand {
  color: var(--text);
  font-family: var(--mono);
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 0;
  text-decoration: none;
}

.nav {
  display: flex;
  gap: 20px;
  font-size: 14px;
}

.nav a {
  color: var(--muted);
  text-decoration: none;
}

.nav a:hover {
  color: var(--text);
}

.layout {
  display: grid;
  gap: 36px;
  grid-template-columns: 190px minmax(0, var(--article)) 180px;
  margin: 0 auto;
  max-width: var(--max);
  padding: 42px 24px 80px;
}

.sidebar,
.toc {
  align-self: start;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  max-height: calc(100vh - 88px);
  overflow: auto;
  padding-top: 7px;
  position: sticky;
  top: 80px;
}

.toc {
  color: var(--faint);
}

.sidebar-title,
.toc-title {
  color: var(--faint);
  font-size: 11px;
  font-family: var(--mono);
  font-weight: 700;
  letter-spacing: 0.09em;
  margin: 0 0 12px;
  text-transform: uppercase;
}

.sidebar-section {
  margin: 0 0 24px;
}

.sidebar a,
.toc a {
  border-left: 2px solid transparent;
  color: inherit;
  display: block;
  margin: 0 0 8px;
  padding: 1px 0 1px 10px;
  text-decoration: none;
}

.sidebar a:hover,
.toc a:hover {
  border-left-color: var(--accent);
  color: var(--text);
}

.article {
  min-width: 0;
}

.meta {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 16px;
}

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

h1 {
  font-family: var(--mono);
  font-size: clamp(36px, 4.8vw, 48px);
  font-weight: 800;
  letter-spacing: 0;
  margin: 0 0 16px;
}

h2 {
  color: var(--text);
  font-family: var(--mono);
  font-size: 25px;
  font-weight: 750;
  margin: 44px 0 14px;
  padding-top: 0;
}

h3 {
  color: var(--text);
  font-family: var(--mono);
  font-size: 19px;
  font-weight: 750;
  margin: 28px 0 10px;
}

p,
ul,
ol,
blockquote,
table,
pre {
  margin: 0 0 18px;
}

ul,
ol {
  padding-left: 1.35em;
}

li {
  margin: 0 0 8px;
}

p,
li {
  color: var(--body);
}

blockquote {
  border-left: 0;
  color: var(--text);
  font-size: 20px;
  font-weight: 600;
  line-height: 1.55;
  margin: 4px 0 30px;
  padding: 0;
}

code {
  background: var(--soft);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em;
  padding: 0.1em 0.35em;
  color: var(--text);
}

pre {
  background: var(--soft);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow-x: auto;
  padding: 16px;
}

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

table {
  border-collapse: collapse;
  display: block;
  font-size: 14px;
  margin-top: 10px;
  overflow-x: auto;
  width: 100%;
}

th,
td {
  border-bottom: 1px solid var(--border);
  padding: 10px 12px 10px 0;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--text);
  font-weight: 700;
}

td {
  color: var(--body);
}

.footer {
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 14px;
  margin-top: 56px;
  padding-top: 24px;
}

.footer a {
  color: var(--text);
}

.substack-links {
  border-top: 1px solid var(--border);
  margin-top: 48px;
  padding-top: 4px;
}

.substack-links h2 {
  font-size: 22px;
  margin-top: 24px;
}

.substack-links ul {
  list-style: none;
  padding-left: 0;
}

.substack-links li {
  border-bottom: 1px solid var(--border);
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1fr) auto;
  margin: 0;
  padding: 11px 0;
}

.substack-links a {
  color: var(--body);
  text-decoration: none;
}

.substack-links a:hover {
  color: var(--accent);
}

.substack-links span {
  color: var(--faint);
  font-family: var(--mono);
  font-size: 12px;
  white-space: nowrap;
}

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 18px 0 28px;
}

.pill {
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
  font-size: 13px;
  padding: 5px 9px;
  text-decoration: none;
}

.pill:hover {
  background: var(--accent-soft);
  border-color: rgba(234, 88, 12, 0.5);
  color: var(--text);
}

@media (max-width: 980px) {
  .layout {
    display: block;
    max-width: 780px;
  }

  .sidebar,
  .toc {
    border: 0;
    padding: 0;
  }

  .sidebar {
    border-bottom: 1px solid var(--border);
    max-height: none;
    margin-bottom: 28px;
    padding-bottom: 16px;
    position: static;
  }

  .toc {
    display: none;
  }
}

@media (max-width: 640px) {
  .header-inner,
  .layout {
    padding-left: 18px;
    padding-right: 18px;
  }

  .nav {
    gap: 12px;
    font-size: 13px;
  }

  h1 {
    font-size: 34px;
  }

  .sidebar-section {
    margin-bottom: 18px;
  }

  .substack-links li {
    display: block;
  }

  .substack-links span {
    display: block;
    margin-top: 2px;
  }
}
