:root {
  --bg: #f4f1ea;
  --ink: #0d0d0d;
  --ink-2: #2a2a2a;
  --muted: #6b6b6b;
  --line: #0d0d0d;
  --line-soft: rgba(13, 13, 13, 0.18);
  --grid: rgba(13, 13, 13, 0.08);
  --accent: #0d0d0d;
  --highlight: #ffd84d;
  --cell: 24px;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg); color: var(--ink);
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
body {
  background-image:
    linear-gradient(to right,  var(--grid) 1px, transparent 1px),
    linear-gradient(to bottom, var(--grid) 1px, transparent 1px);
  background-size: var(--cell) var(--cell);
}
::selection { background: var(--ink); color: var(--bg); }

a { color: inherit; text-decoration: none; }
a.link { border-bottom: 1px solid var(--line-soft); }
a.link:hover { border-bottom-color: var(--ink); }

.frame {
  max-width: 1200px;
  margin: 0 auto;
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
  background: var(--bg);
  position: relative;
}

.frame::before, .frame::after,
.frame > .corner-bl, .frame > .corner-br {
  content: "+";
  position: absolute;
  width: 12px; height: 12px;
  color: var(--ink);
  font-size: 14px;
  line-height: 12px;
  text-align: center;
}
.frame::before { top: -6px; left: -6px; }
.frame::after  { top: -6px; right: -6px; }
.corner-bl { bottom: -6px; left: -6px; }
.corner-br { bottom: -6px; right: -6px; }

/* ===== Top bar ===== */
header.bar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  font-size: 12px;
  letter-spacing: 0.02em;
}
header.bar .brand { display: flex; gap: 14px; align-items: center; }
header.bar .brand .dot {
  width: 9px; height: 9px; background: var(--ink);
  display: inline-block;
}
header.bar .brand strong { font-weight: 600; }
header.bar nav { display: flex; gap: 22px; }
header.bar nav a:hover { color: var(--muted); }
header.bar .right { display: flex; gap: 14px; align-items: center; }
header.bar .repo {
  border: 1px solid var(--line);
  padding: 4px 10px;
  transition: background 120ms, color 120ms;
}
header.bar .repo:hover { background: var(--ink); color: var(--bg); }
header.bar .lang-toggle {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.08em;
  padding: 4px 6px;
  transition: color 120ms;
}
header.bar .lang-toggle:hover { color: var(--ink); }

/* ===== Hero ===== */
section.hero {
  padding: 72px 20px 64px;
  border-bottom: 1px solid var(--line);
  position: relative;
}
.meta-row {
  display: flex; gap: 20px;
  font-size: 11px; color: var(--muted);
  margin-bottom: 36px;
  flex-wrap: wrap;
}
.meta-row span { white-space: nowrap; }
.meta-row .sep { color: var(--line-soft); }

h1.title {
  font-family: "JetBrains Mono", monospace;
  font-weight: 600;
  font-size: clamp(32px, 5.2vw, 64px);
  line-height: 1.05;
  letter-spacing: -0.03em;
  margin: 0 0 28px;
  text-wrap: balance;
  max-width: 24ch;
}
h1.title em {
  font-style: italic;
  color: var(--muted);
  font-weight: 400;
}
h1.title .caret {
  display: inline-block;
  width: 0.55em;
  height: 0.82em;
  background: var(--ink);
  vertical-align: -0.08em;
  margin-left: 0.05em;
  animation: blink 1s steps(2) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.lede {
  max-width: 660px;
  font-size: 15px;
  color: var(--ink-2);
  margin: 0 0 36px;
}
.lede strong { background: var(--highlight); padding: 0 3px; font-weight: 500; }

.cta-row { display: flex; gap: 12px; flex-wrap: wrap; }
.btn {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 10px 16px;
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.02em;
  background: var(--bg);
  cursor: pointer;
  transition: transform 120ms, background 120ms, color 120ms;
}
.btn:hover { background: var(--ink); color: var(--bg); transform: translate(-1px, -1px); box-shadow: 2px 2px 0 var(--ink); }
.btn.solid { background: var(--ink); color: var(--bg); }
.btn.solid:hover { background: var(--bg); color: var(--ink); }
.btn .arr { display: inline-block; transition: transform 120ms; }
.btn:hover .arr { transform: translateX(3px); }

/* ===== Section helpers ===== */
section {
  padding: 64px 20px;
  border-bottom: 1px solid var(--line);
  position: relative;
}
section:last-of-type { border-bottom: 0; }
.section-head {
  display: flex; align-items: baseline; gap: 16px;
  margin-bottom: 32px;
  font-size: 11px; color: var(--muted);
  letter-spacing: 0.06em; text-transform: uppercase;
}
.section-head .num { color: var(--ink); }
.section-head .label { flex: 0 0 auto; }
.section-head .rule { flex: 1; height: 1px; background: var(--line); }
.section-title {
  font-size: clamp(24px, 3.4vw, 40px);
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0 0 18px;
  line-height: 1.05;
}
.section-body {
  max-width: 680px;
  color: var(--ink-2);
  font-size: 14px;
}

/* ===== What is harness engineering ===== */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  border-top: 1px solid var(--line-soft);
}
.two-col > div {
  padding: 28px 24px 28px 0;
  border-right: 1px solid var(--line-soft);
}
.two-col > div:last-child { border-right: 0; padding-right: 0; padding-left: 24px; }
.two-col h4 {
  margin: 0 0 12px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink);
}
.two-col p { margin: 0; color: var(--ink-2); }

/* ===== Architecture diagram ===== */
.diagram-wrap {
  border: 1px solid var(--line);
  padding: 32px;
  background:
    linear-gradient(to right,  var(--grid) 1px, transparent 1px),
    linear-gradient(to bottom, var(--grid) 1px, transparent 1px),
    var(--bg);
  background-size: 12px 12px;
  position: relative;
}
.diagram-wrap .legend {
  position: absolute; top: 10px; right: 14px;
  font-size: 10px; color: var(--muted);
  letter-spacing: 0.06em;
}
.diagram {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  grid-auto-rows: 64px;
  gap: 12px;
  position: relative;
}
.node {
  border: 1px solid var(--line);
  background: var(--bg);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 8px 10px;
  text-align: center;
  font-size: 12px;
  transition: background 140ms, color 140ms, transform 140ms;
  cursor: default;
  position: relative;
  z-index: 2;
}
.node:hover { background: var(--ink); color: var(--bg); transform: translate(-1px,-1px); box-shadow: 2px 2px 0 var(--ink); }
.node .k {
  font-size: 9px; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 2px;
}
.node:hover .k { color: var(--bg); opacity: 0.6; }
.node .n { font-weight: 600; }
.node small { font-size: 10px; color: var(--muted); font-weight: 400; margin-top: 2px;}
.node:hover small { color: var(--bg); opacity: 0.7; }

.node.user        { grid-column: 1 / span 5;  grid-row: 1; }
.node.provider    { grid-column: 7 / span 6;  grid-row: 1; }

.node.loop        { grid-column: 1 / span 12; grid-row: 3; background: var(--ink); color: var(--bg); }
.node.loop .k     { color: rgba(255,255,255,0.55); }
.node.loop:hover  { background: var(--bg); color: var(--ink); }
.node.loop:hover .k { color: var(--muted); }

.node.ctx         { grid-column: 1 / span 3;  grid-row: 5; }
.node.mem         { grid-column: 4 / span 3;  grid-row: 5; }
.node.tools       { grid-column: 7 / span 3;  grid-row: 5; }
.node.io          { grid-column: 10 / span 3; grid-row: 5; }

.node.mcp         { grid-column: 1 / span 6;  grid-row: 7; }
.node.sub         { grid-column: 7 / span 6;  grid-row: 7; }

/* ===== Curriculum ===== */
.chapters {
  display: grid;
  grid-template-columns: 1fr;
  border-top: 1px solid var(--line);
}
.chapter {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 32px;
  padding: 28px 0;
  border-bottom: 1px solid var(--line);
}
.chapter:last-child { border-bottom: 0; }
.chapter-head {
  position: sticky;
  top: 56px;
  align-self: start;
}
.chapter-kicker {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.08em;
  margin-bottom: 8px;
}
.chapter-title {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin-bottom: 10px;
}
.chapter-blurb {
  font-size: 12.5px;
  color: var(--muted);
  max-width: 240px;
  line-height: 1.55;
}
.chapter-list {
  list-style: none;
  margin: 0; padding: 0;
  border-top: 1px solid var(--line-soft);
}
.chapter-list li { border-bottom: 1px solid var(--line-soft); }
.chapter-list li:last-child { border-bottom: 0; }
.chapter-lesson {
  display: grid;
  grid-template-columns: 48px 1fr 24px;
  gap: 16px;
  padding: 12px 12px 12px 4px;
  align-items: baseline;
  transition: background 120ms, color 120ms, padding-left 120ms;
}
.chapter-lesson:hover {
  background: var(--ink);
  color: var(--bg);
  padding-left: 12px;
}
.chapter-lesson:hover .cl-num { color: rgba(255,255,255,0.55); }
.chapter-lesson:hover .cl-arrow { transform: translateX(4px); }
.cl-num {
  font-size: 11px;
  color: var(--muted);
}
.cl-title {
  font-size: 15px;
  font-weight: 500;
  letter-spacing: -0.005em;
}
.cl-arrow {
  color: inherit;
  text-align: right;
  transition: transform 120ms;
}

/* ===== How-to recipes ===== */
.recipes {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  border-top: 1px solid var(--line);
  padding-top: 24px;
}
.recipe {
  display: flex; flex-direction: column;
  gap: 10px;
  padding: 20px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  text-decoration: none;
  transition: background 120ms, color 120ms, transform 120ms, box-shadow 120ms;
}
.recipe:hover {
  background: var(--ink);
  color: var(--bg);
  transform: translate(-2px,-2px);
  box-shadow: 4px 4px 0 var(--ink);
}
.recipe-head {
  display: flex; justify-content: space-between; align-items: center;
}
.recipe-kicker {
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}
.recipe:hover .recipe-kicker { color: rgba(255,255,255,0.55); }
.recipe-arrow {
  font-size: 16px;
  color: var(--muted);
  transition: transform 120ms;
}
.recipe:hover .recipe-arrow {
  color: var(--bg);
  transform: translateX(4px);
}
.recipe-title {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.25;
}
.recipe-blurb {
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--muted);
}
.recipe:hover .recipe-blurb { color: rgba(255,255,255,0.7); }

/* Difficulty badges — used on exercise cards and exercise headers. */
.difficulty {
  display: inline-block;
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 2px 8px;
  border: 1px solid var(--ink);
  font-weight: 600;
}
.difficulty-easy   { background: #d7e4c5; color: #2a3a18; border-color: #2a3a18; }
.difficulty-medium { background: var(--highlight); color: #4a3a00; border-color: #4a3a00; }
.difficulty-hard   { background: #e8b4a0; color: #4a1a0a; border-color: #4a1a0a; }
.difficulty-fácil  { background: #d7e4c5; color: #2a3a18; border-color: #2a3a18; }
.difficulty-media  { background: var(--highlight); color: #4a3a00; border-color: #4a3a00; }
.difficulty-difícil{ background: #e8b4a0; color: #4a1a0a; border-color: #4a1a0a; }
.recipe:hover .difficulty {
  background: var(--bg);
  color: var(--ink);
  border-color: var(--bg);
}

/* Lead paragraph on a guide page — sits between H1 and prose. */
.chapter-blurb-lead {
  font-size: 14.5px;
  line-height: 1.6;
  color: var(--ink-2);
  margin: -4px 0 28px;
  max-width: 720px;
}

/* ===== Snippet ===== */
.snippet {
  background: var(--ink); color: var(--bg);
  padding: 0;
  border: 1px solid var(--line);
  position: relative;
  overflow: hidden;
}
.snippet .filebar {
  padding: 8px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.18);
  font-size: 10.5px;
  color: rgba(255,255,255,0.62);
  letter-spacing: 0.08em; text-transform: uppercase;
  display: flex; justify-content: space-between;
  background: rgba(255,255,255,0.04);
}
.snippet pre {
  margin: 0; padding: 22px 24px;
  font-family: inherit; font-size: 12.5px;
  line-height: 1.7;
  overflow-x: auto;
}
.snippet .cm { color: rgba(255,255,255,0.45); }
.snippet .kw { color: var(--bg); font-weight: 600; }
.snippet .st { color: #ffd84d; }
.snippet .fn { color: #8be9fd; }

/* ===== Chapter page (markdown body) ===== */
.chapter-page {
  padding: 56px 20px 72px;
  border-bottom: 1px solid var(--line);
}
.chapter-meta {
  display: flex; gap: 14px; align-items: baseline;
  font-size: 11px; color: var(--muted);
  letter-spacing: 0.06em; text-transform: uppercase;
  margin-bottom: 18px;
}
.chapter-meta .sep { color: var(--line-soft); }
.chapter-meta .back { transition: color 120ms; }
.chapter-meta .back:hover { color: var(--ink); }
.chapter-meta .chapter-num { color: var(--ink); }

.chapter-h1 {
  font-size: clamp(28px, 4.4vw, 48px);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.08;
  margin: 0 0 36px;
}

.chapter-prose {
  max-width: 760px;
  font-size: 14.5px;
  line-height: 1.7;
  color: var(--ink-2);
}
.chapter-prose h2 {
  margin: 48px 0 16px;
  font-size: 22px;
  letter-spacing: -0.01em;
  color: var(--ink);
  padding-top: 8px;
  border-top: 1px solid var(--line-soft);
}
.chapter-prose h3 {
  margin: 32px 0 12px;
  font-size: 16px;
  color: var(--ink);
}
.chapter-prose h4 {
  margin: 24px 0 10px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink);
}
.chapter-prose p { margin: 0 0 16px; }
.chapter-prose ul, .chapter-prose ol { margin: 0 0 18px; padding-left: 22px; }
.chapter-prose li { margin: 0 0 6px; }
.chapter-prose strong { color: var(--ink); font-weight: 600; }
.chapter-prose em { color: var(--ink-2); }
.chapter-prose a {
  color: var(--ink);
  border-bottom: 1px solid var(--line-soft);
  transition: border-bottom-color 120ms;
}
.chapter-prose a:hover { border-bottom-color: var(--ink); }
.chapter-prose code {
  background: rgba(13, 13, 13, 0.06);
  padding: 1px 5px;
  font-size: 0.92em;
  border-radius: 2px;
}
.chapter-prose pre {
  background: var(--ink);
  color: var(--bg);
  margin: 16px 0 22px;
  padding: 18px 22px;
  overflow-x: auto;
  border: 1px solid var(--line);
  font-size: 12.5px;
  line-height: 1.6;
}
.chapter-prose pre code {
  background: transparent;
  padding: 0;
  font-size: inherit;
  color: inherit;
}
.chapter-prose blockquote {
  margin: 18px 0;
  padding: 14px 18px;
  border-left: 3px solid var(--ink);
  background: rgba(13, 13, 13, 0.03);
  font-style: normal;
}
.chapter-prose blockquote p:last-child { margin: 0; }
.chapter-prose table {
  margin: 18px 0;
  border-collapse: collapse;
  font-size: 13px;
  width: 100%;
}
.chapter-prose th, .chapter-prose td {
  border: 1px solid var(--line-soft);
  padding: 8px 12px;
  text-align: left;
  vertical-align: top;
}
.chapter-prose th {
  background: rgba(13, 13, 13, 0.04);
  font-weight: 600;
  color: var(--ink);
}
.chapter-prose hr {
  border: none;
  border-top: 1px solid var(--line-soft);
  margin: 32px 0;
}
.chapter-prose img { max-width: 100%; }

.chapter-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 56px;
  border-top: 1px solid var(--line-soft);
  padding-top: 24px;
}
.chapter-nav a {
  display: grid;
  grid-template-rows: auto auto;
  padding: 14px 16px;
  border: 1px solid var(--line);
  transition: background 120ms, color 120ms, transform 120ms;
}
.chapter-nav .nav-prev { text-align: left; }
.chapter-nav .nav-next { text-align: right; }
.chapter-nav a:hover { background: var(--ink); color: var(--bg); transform: translate(-1px,-1px); box-shadow: 2px 2px 0 var(--ink); }
.chapter-nav .nav-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 4px;
}
.chapter-nav a:hover .nav-label { color: rgba(255,255,255,0.6); }
.chapter-nav .nav-title {
  font-size: 14px;
  font-weight: 500;
}
.chapter-nav .nav-arrow {
  font-size: 12px;
  color: var(--muted);
  margin: 0 6px;
}
.chapter-nav a:hover .nav-arrow { color: var(--bg); }

/* ===== Footer ===== */
footer {
  padding: 36px 20px 28px;
  font-size: 11px;
  color: var(--muted);
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 12px;
}
footer .ascii {
  font-size: 10px; line-height: 1.2; white-space: pre;
  color: var(--line-soft);
}
footer .built-by {
  margin-top: 6px;
  color: var(--ink-2);
  font-weight: 500;
}
footer .built-by .heart {
  color: var(--ink);
  font-weight: 700;
  animation: pulse 1.6s ease-in-out infinite;
  display: inline-block;
}
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.15); }
}
footer .academy {
  margin-top: 4px;
  color: var(--ink-2);
  font-size: 12px;
}
footer .academy a {
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px dashed var(--rule);
}
footer .academy a:hover {
  border-bottom-style: solid;
}

/* ===== small-screen fixes ===== */
@media (max-width: 760px) {
  .two-col { grid-template-columns: 1fr; }
  .two-col > div { border-right: 0; padding: 18px 0; border-bottom: 1px solid var(--line-soft); }
  .two-col > div:last-child { padding-left: 0; border-bottom: 0; }
  .chapter { grid-template-columns: 1fr; gap: 16px; padding: 22px 0; }
  .chapter-head { position: static; }
  .diagram { grid-auto-rows: 64px; }
  .chapter-nav { grid-template-columns: 1fr; }
  header.bar nav { display: none; }
}
