/* ============================================================
   LangChain Deep Dive — Design System
   Cool technical: off-white, deep blue, electric accent
   ============================================================ */

:root {
  /* Surfaces */
  --bg: #f5f6f8;
  --bg-elev: #ffffff;
  --bg-sunk: #eceef2;
  --bg-code: #0b1020;
  --bg-code-elev: #131a30;

  /* Ink */
  --ink: #0a1330;
  --ink-2: #2a345a;
  --ink-3: #56607f;
  --ink-4: #8189a4;
  --ink-on-dark: #e6ecff;
  --ink-on-dark-2: #9aa5cc;

  /* Brand */
  --deep: #122062;          /* deep blue */
  --deep-2: #1a2d8a;
  --electric: #2f5bff;      /* electric accent */
  --electric-2: #4d76ff;
  --cyan: #00d4ff;
  --lime: #b6ff3c;
  --amber: #ffb547;
  --rose: #ff5c8a;
  --violet: #8a5cff;

  /* Lines */
  --line: #d9dde6;
  --line-2: #c4cad8;
  --line-on-dark: #2a3358;

  /* Type */
  --sans: "Inter Tight", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --serif: "Fraunces", "Iowan Old Style", Georgia, serif;
  --mono: "JetBrains Mono", "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;

  /* Geometry */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 16px;
  --r-xl: 24px;

  /* Shadow */
  --shadow-1: 0 1px 2px rgba(10, 19, 48, 0.06), 0 2px 6px rgba(10, 19, 48, 0.04);
  --shadow-2: 0 4px 12px rgba(10, 19, 48, 0.08), 0 12px 32px rgba(10, 19, 48, 0.06);
  --shadow-electric: 0 8px 24px rgba(47, 91, 255, 0.25);

  /* Sidebar */
  --sidebar-w: 300px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-feature-settings: "ss01", "cv11";
}

a { color: var(--electric); text-decoration: none; }
a:hover { text-decoration: underline; }

code, pre, .mono { font-family: var(--mono); }

/* ===================== App layout ===================== */

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

/* ---- Sidebar ---- */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: var(--bg-elev);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-header {
  padding: 22px 22px 18px;
  border-bottom: 1px solid var(--line);
}

.brand-mark {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.brand-logo {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  background: var(--ink);
  color: white;
  border-radius: 8px;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.02em;
}

.brand-name {
  font-weight: 600;
  font-size: 14px;
  letter-spacing: -0.01em;
}

.brand-name .muted {
  color: var(--ink-3);
  font-weight: 400;
}

.sidebar-title {
  font-family: var(--serif);
  font-size: 22px;
  line-height: 1.15;
  letter-spacing: -0.02em;
  font-weight: 500;
  color: var(--ink);
  margin: 4px 0 6px;
}

.sidebar-meta {
  font-size: 12px;
  color: var(--ink-3);
  display: flex;
  gap: 10px;
  align-items: center;
}

.sidebar-meta .dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--ink-4);
}

.sidebar-progress {
  height: 3px;
  background: var(--bg-sunk);
  margin-top: 14px;
  border-radius: 999px;
  overflow: hidden;
}

.sidebar-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--electric), var(--cyan));
  width: 0%;
  transition: width 200ms ease;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 10px 20px;
}

.nav-section-label {
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.12em;
  color: var(--ink-4);
  padding: 14px 12px 6px;
  font-weight: 600;
}

.nav-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--r-sm);
  cursor: pointer;
  font-size: 13.5px;
  color: var(--ink-2);
  line-height: 1.4;
  user-select: none;
  border-left: 2px solid transparent;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}
.nav-item:hover { background: var(--bg-sunk); color: var(--ink); }
.nav-item.active {
  background: rgba(47, 91, 255, 0.08);
  color: var(--ink);
  border-left-color: var(--electric);
  font-weight: 500;
}

.nav-num {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-4);
  min-width: 22px;
  padding-top: 2px;
}

.nav-item.active .nav-num { color: var(--electric); }

.sidebar-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--line);
  font-size: 11.5px;
  color: var(--ink-3);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.kbd {
  display: inline-block;
  font-family: var(--mono);
  font-size: 10.5px;
  background: var(--bg-sunk);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 1px 6px;
  color: var(--ink-2);
}

/* ---- Main content ---- */
.main {
  min-width: 0;
  position: relative;
}

.chapter {
  max-width: 880px;
  margin: 0 auto;
  padding: 80px 64px 120px;
  scroll-margin-top: 24px;
}

.chapter-header {
  margin-bottom: 48px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--electric);
  text-transform: uppercase;
  font-weight: 500;
  margin-bottom: 16px;
}
.eyebrow::before {
  content: "";
  width: 18px;
  height: 1px;
  background: var(--electric);
}

h1.chapter-title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 56px;
  line-height: 1.02;
  letter-spacing: -0.035em;
  margin: 0 0 18px;
  color: var(--ink);
  text-wrap: balance;
}

.chapter-lede {
  font-size: 19px;
  line-height: 1.55;
  color: var(--ink-2);
  max-width: 70ch;
  text-wrap: pretty;
}

h2.section-title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 34px;
  line-height: 1.15;
  letter-spacing: -0.025em;
  margin: 64px 0 16px;
  color: var(--ink);
  text-wrap: balance;
}

h3.sub-title {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 19px;
  letter-spacing: -0.01em;
  margin: 36px 0 10px;
  color: var(--ink);
}

h4.mini-title {
  font-family: var(--mono);
  font-weight: 500;
  font-size: 11.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin: 24px 0 8px;
}

.chapter p {
  font-size: 16.5px;
  line-height: 1.7;
  color: var(--ink-2);
  margin: 0 0 16px;
  max-width: 72ch;
  text-wrap: pretty;
}

.chapter p strong, .chapter li strong {
  color: var(--ink);
  font-weight: 600;
}

.chapter p code, .chapter li code {
  font-size: 0.88em;
  background: var(--bg-sunk);
  padding: 1px 6px;
  border-radius: 4px;
  color: var(--deep);
  border: 1px solid var(--line);
}

.chapter ul, .chapter ol {
  font-size: 16.5px;
  line-height: 1.7;
  color: var(--ink-2);
  padding-left: 22px;
  margin: 0 0 16px;
}
.chapter li { margin-bottom: 6px; }

/* Callouts */
.callout {
  border-radius: var(--r-md);
  padding: 16px 20px;
  margin: 24px 0;
  font-size: 15px;
  line-height: 1.6;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  position: relative;
}

.callout-label {
  font-family: var(--mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 600;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.callout-label::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.callout.intuition { border-left: 3px solid var(--electric); }
.callout.intuition .callout-label { color: var(--electric); }

.callout.warning { border-left: 3px solid var(--amber); background: #fff8ed; }
.callout.warning .callout-label { color: #c87a00; }

.callout.gotcha { border-left: 3px solid var(--rose); background: #fff3f6; }
.callout.gotcha .callout-label { color: var(--rose); }

.callout.tip { border-left: 3px solid var(--lime); background: #f5ffe6; }
.callout.tip .callout-label { color: #5a8a00; }

.callout.note { border-left: 3px solid var(--ink-4); }
.callout.note .callout-label { color: var(--ink-3); }

/* Code blocks */
.code-block {
  background: var(--bg-code);
  color: var(--ink-on-dark);
  border-radius: var(--r-md);
  margin: 22px 0;
  overflow: hidden;
  font-size: 13.5px;
  border: 1px solid var(--line-on-dark);
}

.code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg-code-elev);
  border-bottom: 1px solid var(--line-on-dark);
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--ink-on-dark-2);
}

.code-head .lang {
  display: flex;
  align-items: center;
  gap: 8px;
}
.code-head .lang::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--cyan);
}

.code-head .file { color: var(--ink-on-dark-2); }

.code-block pre {
  margin: 0;
  padding: 16px 18px;
  overflow: auto;
  font-family: var(--mono);
  line-height: 1.6;
  white-space: pre;
  max-width: 100%;
}
.code-block pre::-webkit-scrollbar { height: 8px; width: 8px; }
.code-block pre::-webkit-scrollbar-thumb { background: #2a3358; border-radius: 4px; }
.code-block pre::-webkit-scrollbar-track { background: transparent; }

/* Token colors */
.tok-key { color: #ff8aa9; }     /* def class import */
.tok-str { color: #b6ff3c; }     /* strings */
.tok-num { color: #ffb547; }
.tok-com { color: #6a7aa8; font-style: italic; }
.tok-fn  { color: #4d9aff; }
.tok-cls { color: #00d4ff; }
.tok-var { color: #e6ecff; }
.tok-op  { color: #8a5cff; }
.tok-pun { color: #9aa5cc; }
.tok-bool{ color: #ff8aa9; }

/* Inline diagram cards */
.diagram {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 24px;
  margin: 28px 0;
  box-shadow: var(--shadow-1);
}

.diagram-title {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.diagram-title .controls {
  display: flex;
  gap: 6px;
}

.btn {
  font-family: var(--sans);
  font-size: 12.5px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  color: var(--ink-2);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 120ms ease;
  text-transform: none;
  letter-spacing: 0;
}
.btn:hover { background: var(--bg-sunk); border-color: var(--line-2); }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: var(--electric);
  color: white;
  border-color: var(--electric);
}
.btn.primary:hover { background: var(--electric-2); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-3); }
.btn.ghost:hover { color: var(--ink); background: var(--bg-sunk); }
.btn[disabled] { opacity: 0.4; cursor: not-allowed; }

.btn-icon {
  width: 28px; height: 28px; padding: 0;
  display: grid; place-items: center;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  color: var(--ink-2);
  letter-spacing: 0.02em;
}
.tag.electric { color: var(--electric); border-color: rgba(47, 91, 255, 0.3); background: rgba(47, 91, 255, 0.05); }
.tag.lime { color: #5a8a00; border-color: #c4e066; background: #f5ffe6; }
.tag.amber { color: #c87a00; border-color: #ffd58a; background: #fff8ed; }
.tag.rose { color: var(--rose); border-color: #ffb3c8; background: #fff3f6; }
.tag.violet { color: var(--violet); border-color: #c8b3ff; background: #f3eeff; }

/* Two column layout */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin: 22px 0;
}
.two-col.tight { gap: 12px; }
@media (max-width: 920px) {
  .two-col { grid-template-columns: 1fr; }
}

/* Stat / number callout */
.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin: 22px 0;
}
.stat {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 16px;
}
.stat .num {
  font-family: var(--serif);
  font-size: 32px;
  font-weight: 500;
  letter-spacing: -0.02em;
  color: var(--ink);
  line-height: 1;
}
.stat .label {
  font-size: 12px;
  color: var(--ink-3);
  margin-top: 6px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-family: var(--mono);
}

/* TOC bottom of chapter */
.chapter-end {
  margin-top: 80px;
  padding-top: 28px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 16px;
}
.chapter-end .nav-card {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 14px 18px;
  cursor: pointer;
  background: var(--bg-elev);
  transition: all 150ms ease;
}
.chapter-end .nav-card:hover {
  border-color: var(--electric);
  transform: translateY(-1px);
  box-shadow: var(--shadow-1);
}
.chapter-end .nav-card .label {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.chapter-end .nav-card .title {
  font-weight: 500;
  font-size: 16px;
  margin-top: 6px;
  color: var(--ink);
}
.chapter-end .nav-card.next { text-align: right; }

/* ===================== Animated agent loop ===================== */

.agent-loop {
  position: relative;
  height: 380px;
}

.agent-loop svg { display: block; width: 100%; height: 100%; }

.loop-node {
  position: absolute;
  background: var(--bg-elev);
  border: 1.5px solid var(--line-2);
  border-radius: var(--r-md);
  padding: 12px 14px;
  width: 168px;
  transition: all 280ms cubic-bezier(.2,.7,.3,1);
  font-size: 13px;
}
.loop-node.active {
  border-color: var(--electric);
  box-shadow: var(--shadow-electric), 0 0 0 4px rgba(47, 91, 255, 0.1);
  transform: scale(1.03);
}
.loop-node .label {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 4px;
}
.loop-node .name {
  font-weight: 600;
  color: var(--ink);
  font-size: 14px;
}
.loop-node .desc {
  font-size: 12px;
  color: var(--ink-3);
  margin-top: 4px;
  line-height: 1.4;
}
.loop-node.active .label { color: var(--electric); }

/* ===================== Tool simulator ===================== */

.tool-sim {
  display: block;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--bg-elev);
}
.tool-sim-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 6px;
  padding: 10px;
  background: var(--bg-sunk);
  border-bottom: 1px solid var(--line);
  border-right: none;
  max-height: none;
  overflow: visible;
}
.tool-sim-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 6px;
  padding: 10px;
  background: var(--bg-sunk);
  border-bottom: 1px solid var(--line);
}
.tool-card {
  padding: 10px 12px;
  border-radius: var(--r-sm);
  cursor: pointer;
  margin-bottom: 0;
  transition: background 120ms;
  border: 1px solid transparent;
  background: var(--bg-elev);
}
.tool-card:hover { background: rgba(47,91,255,0.05); }
.tool-card.active { background: var(--bg-elev); border-color: var(--electric); }
.tool-card .tname {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
}
.tool-card .tdesc {
  font-size: 11.5px;
  color: var(--ink-3);
  margin-top: 3px;
  line-height: 1.35;
}

.tool-detail {
  padding: 18px 22px;
  width: 100%;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.tool-detail .code-block { flex-shrink: 0; max-width: 100%; }
.tool-detail .code-block pre {
  max-height: 480px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}
.tool-detail::-webkit-scrollbar { width: 8px; }
.tool-detail::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 4px; }

/* ===================== ReAct trace ===================== */
.trace {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--bg-elev);
  overflow: hidden;
}
.trace-step {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 14px;
  font-size: 13.5px;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 320ms ease, transform 320ms ease;
}
.trace-step.visible { opacity: 1; transform: none; }
.trace-step:last-child { border-bottom: none; }
.trace-step .role {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 600;
  padding-top: 2px;
}
.trace-step.thought .role { color: var(--violet); }
.trace-step.action .role { color: var(--electric); }
.trace-step.obs .role { color: #5a8a00; }
.trace-step.final .role { color: var(--ink); }

.trace-step .body { color: var(--ink-2); line-height: 1.55; }
.trace-step .body code, .trace-step pre {
  font-family: var(--mono);
  font-size: 12.5px;
  background: var(--bg-sunk);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--deep);
  border: 1px solid var(--line);
}
.trace-step pre {
  display: block;
  padding: 8px 10px;
  margin: 4px 0 0;
  white-space: pre-wrap;
}

/* ===================== LCEL builder ===================== */
.lcel-builder {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 18px;
}
.lcel-canvas {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 18px;
  background: var(--bg-sunk);
  border-radius: var(--r-sm);
  min-height: 88px;
  border: 1.5px dashed var(--line-2);
}
.lcel-canvas.empty { justify-content: center; color: var(--ink-4); font-size: 13px; }

.lcel-block {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg-elev);
  border: 1.5px solid var(--line);
  border-radius: 8px;
  font-family: var(--mono);
  font-size: 12.5px;
  cursor: pointer;
  transition: all 150ms;
  user-select: none;
}
.lcel-block:hover { border-color: var(--electric); }
.lcel-block.in-canvas { background: white; box-shadow: var(--shadow-1); }
.lcel-block.active { border-color: var(--electric); box-shadow: 0 0 0 3px rgba(47,91,255,0.12); }
.lcel-block .dot {
  width: 8px; height: 8px; border-radius: 50%;
}
.lcel-block.prompt .dot { background: var(--violet); }
.lcel-block.model .dot { background: var(--electric); }
.lcel-block.parser .dot { background: var(--lime); }
.lcel-block.retriever .dot { background: var(--cyan); }
.lcel-block.tool .dot { background: var(--amber); }
.lcel-block.passthrough .dot { background: var(--ink-4); }

.lcel-pipe {
  font-family: var(--mono);
  font-size: 18px;
  color: var(--electric);
  font-weight: 600;
  user-select: none;
}

.lcel-palette {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.lcel-output {
  margin-top: 14px;
  padding: 12px 14px;
  background: var(--bg-code);
  color: var(--ink-on-dark);
  border-radius: var(--r-sm);
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.6;
  white-space: pre-wrap;
  min-height: 48px;
}

/* ===================== MCP diagram ===================== */
.mcp-stage {
  position: relative;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 28px;
  min-height: 320px;
}

.mcp-col {
  position: relative;
  z-index: 2;
}

.mcp-card {
  background: white;
  border: 1.5px solid var(--line);
  border-radius: var(--r-md);
  padding: 14px;
  font-size: 13px;
  box-shadow: var(--shadow-1);
}
.mcp-card.host { border-color: var(--electric); }
.mcp-card.server { border-color: var(--violet); }
.mcp-card .title {
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-3);
  margin-bottom: 6px;
}
.mcp-card .name {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 4px;
}

/* Misc */
.divider {
  height: 1px;
  background: var(--line);
  margin: 48px 0;
}

.figure-caption {
  font-size: 12.5px;
  color: var(--ink-3);
  font-family: var(--mono);
  text-align: center;
  margin-top: 10px;
  letter-spacing: 0.02em;
}

/* Number badges */
.num-badge {
  display: inline-grid;
  place-items: center;
  width: 22px; height: 22px;
  background: var(--ink);
  color: white;
  border-radius: 50%;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  margin-right: 8px;
  vertical-align: middle;
}

/* Comparison table */
.comparison-table {
  margin: 22px 0;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--bg-elev);
  box-shadow: var(--shadow-1);
  overflow-x: auto;
}
.comparison-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  min-width: 640px;
}
.comparison-table thead th {
  background: var(--bg-sunk);
  border-bottom: 1px solid var(--line);
  text-align: left;
  padding: 12px 14px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 600;
}
.comparison-table thead th:first-child { background: var(--bg-elev); }
.comparison-table tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  color: var(--ink-2);
  vertical-align: top;
  line-height: 1.5;
}
.comparison-table tbody tr:last-child td { border-bottom: none; }
.comparison-table tbody td:first-child {
  font-weight: 500;
  color: var(--ink);
  background: var(--bg-sunk);
  border-right: 1px solid var(--line);
  white-space: nowrap;
}
.comparison-table tbody td code {
  font-size: 0.88em;
  background: rgba(47, 91, 255, 0.06);
  padding: 1px 5px;
  border-radius: 4px;
  color: var(--deep);
  border: 1px solid rgba(47, 91, 255, 0.15);
}
.comparison-table .good { color: #5a8a00; font-weight: 500; }
.comparison-table .warn { color: #c87a00; font-weight: 500; }
.comparison-table .bad  { color: var(--rose); font-weight: 500; }

/* Selection */
::selection { background: rgba(47, 91, 255, 0.2); }

/* Scrollbar */
.sidebar-nav::-webkit-scrollbar, .tool-sim-list::-webkit-scrollbar { width: 8px; }
.sidebar-nav::-webkit-scrollbar-thumb, .tool-sim-list::-webkit-scrollbar-thumb {
  background: var(--line-2); border-radius: 4px;
}

/* Responsive */
@media (max-width: 1080px) {
  .app { grid-template-columns: 240px 1fr; }
  :root { --sidebar-w: 240px; }
  .chapter { padding: 60px 40px 100px; }
  h1.chapter-title { font-size: 44px; }
}
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; }
  .chapter { padding: 40px 22px 80px; }
  h1.chapter-title { font-size: 36px; }
}

/* fade-in for chapters */
.chapter { animation: fadeUp 360ms ease both; }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* spin for active step */
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(47,91,255,0.35); }
  50% { box-shadow: 0 0 0 8px rgba(47,91,255,0); }
}
.pulse { animation: pulse 1.4s ease-in-out infinite; }

/* dashed connector */
.dashed-line {
  stroke: var(--line-2);
  stroke-width: 1.5;
  stroke-dasharray: 4 4;
  fill: none;
}
.flow-line {
  stroke: var(--electric);
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
}
.flow-arrow {
  fill: var(--electric);
}

/* Badges in headings */
.section-title .num {
  font-family: var(--mono);
  font-size: 14px;
  color: var(--electric);
  margin-right: 12px;
  font-weight: 500;
  vertical-align: middle;
  letter-spacing: 0.04em;
}
