:root {
  --ink: #171612;
  --muted: #565149;
  --paper: #f2efe6;
  --card: #fbfaf5;
  --line: rgba(23, 22, 18, 0.3);
  --dark: #171612;
  --green: #ef4b2c;
  --green-deep: #a82d19;
  --amber: #e8a23b;
  --cyan: #246c82;
}

body {
  background: var(--paper);
  color: var(--ink);
  font-family: "Segoe UI", "Malgun Gothic", Arial, sans-serif;
}

.topbar {
  min-height: 64px;
  align-items: center;
  color: var(--ink);
  background: rgba(242, 239, 230, 0.97);
  border-bottom: 1px solid rgba(23, 22, 18, 0.72);
}

.topbar a:first-child::before {
  content: "";
  display: inline-block;
  width: 13px;
  height: 13px;
  margin-right: 9px;
  vertical-align: -1px;
  background: var(--green);
  transform: skew(-18deg);
}

.topbar a:last-child {
  color: var(--muted);
  font-family: Consolas, "Cascadia Mono", monospace;
  font-size: 11px;
}

.hero {
  position: relative;
  overflow: hidden;
  color: var(--ink);
  background: var(--paper);
  border-bottom: 1px solid rgba(23, 22, 18, 0.72);
}

.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: url("../assets/hero-embedded.png") 90% center / 58% auto no-repeat;
  filter: grayscale(1) contrast(1.2);
  opacity: 0.04;
  pointer-events: none;
}

.hero-inner,
.layout,
.footer-inner {
  width: min(1240px, calc(100% - 48px));
}

.hero-inner {
  position: relative;
  z-index: 1;
  padding: 54px 0 48px;
}

.eyebrow {
  color: var(--green);
  font-family: Consolas, "Cascadia Mono", monospace;
  font-size: 11px;
  letter-spacing: 0;
}

h1,
h2,
h3 {
  font-family: "Arial Black", "Malgun Gothic", sans-serif;
  font-weight: 900;
  letter-spacing: 0;
}

h1 {
  max-width: 1060px;
  font-size: clamp(36px, 5vw, 56px);
  line-height: 1.08;
}

.lead {
  max-width: 960px;
  color: var(--muted);
  font-size: 17px;
}

.post-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0;
  max-width: 1050px;
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
}

.post-meta span {
  min-height: 48px;
  padding: 10px 12px;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  font-family: Consolas, "Cascadia Mono", monospace;
  font-size: 11px;
}

.layout {
  grid-template-columns: 238px minmax(0, 1fr);
  gap: 32px;
  padding: 42px 0 84px;
}

.toc {
  top: 78px;
  padding: 4px 22px 4px 0;
  background: transparent;
  border: 0;
  border-right: 1px solid var(--line);
}

.toc strong {
  margin-bottom: 14px;
  color: var(--green);
  font-family: Consolas, "Cascadia Mono", monospace;
  font-size: 12px;
  text-transform: uppercase;
}

.toc a {
  padding: 7px 0;
  border-bottom: 1px solid rgba(23, 22, 18, 0.16);
  font-size: 12px;
}

.toc a:hover,
.toc a:focus-visible {
  color: var(--green);
}

article > section {
  padding-bottom: 38px;
  border-bottom: 1px solid rgba(23, 22, 18, 0.28);
}

h2 {
  font-size: 32px;
}

h3 {
  font-size: 19px;
}

p,
.read-points {
  color: var(--muted);
}

.note,
.code-explain,
.kernel-figure,
.source-panel,
.map-card {
  background: var(--card);
  border-color: var(--line);
  box-shadow: none;
}

.note {
  border-left-color: var(--green);
}

.label {
  color: var(--green-deep);
}

code {
  color: #6e2417;
}

pre {
  color: var(--ink);
  background: #fffefa;
  border-color: var(--line);
}

.diagram-canvas {
  background: var(--card);
  border-color: var(--line);
}

.diagram-node {
  background: #fffefa;
  border-color: rgba(23, 22, 18, 0.34);
}

.diagram-node strong,
.map-card strong {
  color: var(--ink);
}

.diagram-node span {
  color: var(--muted);
}

.diagram-arrow {
  color: var(--green);
}

.source-actions {
  gap: 0;
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
}

.source-actions a {
  padding: 8px 10px;
  color: var(--green-deep);
  background: transparent;
  border: 0;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.footer {
  color: rgba(255, 255, 255, 0.7);
  background: var(--ink);
  border-top: 1px solid rgba(255, 255, 255, 0.2);
}

@media (max-width: 860px) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
  }

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

  .toc {
    position: static;
    padding: 0 0 18px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  article,
  article > section,
  .code-explain,
  .code-explain > *,
  .kernel-figure,
  .source-panel,
  .diagram-canvas,
  .map-card {
    min-width: 0;
    max-width: 100%;
  }

  pre {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
  }

  .diagram-canvas {
    width: 100%;
    overflow-x: auto;
  }
}
