:root {
  --bg: #ffffff;
  --bg-alt: #f7f8fa;
  --panel: #ffffff;
  --panel-2: #f3f4f6;
  --border: #e5e7eb;
  --text: #111827;
  --muted: #6b7280;
  --faint: #9ca3af;
  --accent: #7c3aed;
  --accent-soft: #f3effe;
  --maxw: 800px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 72px; }

body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

code, pre { font-family: 'JetBrains Mono', ui-monospace, Menlo, monospace; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2 { line-height: 1.2; letter-spacing: -0.02em; margin: 0; }

/* ---------- NAV ---------- */
.nav {
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: blur(12px);
  background: rgba(255, 255, 255, 0.8);
  border-bottom: 1px solid var(--border);
}
.nav-inner {
  max-width: var(--maxw); margin: 0 auto; padding: 12px 24px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.brand { display: inline-flex; align-items: center; gap: 9px; font-weight: 700; font-size: 16px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand b { font-weight: 800; color: var(--accent); }
.brand-mark { color: var(--accent); display: inline-flex; }
.nav-links { display: flex; align-items: center; gap: 20px; }
.nav-links a { color: var(--muted); font-size: 14px; font-weight: 500; }
.nav-links a:hover { color: var(--text); text-decoration: none; }

/* ---------- DOC LAYOUT ---------- */
.doc { max-width: var(--maxw); margin: 0 auto; padding: 24px; }
.doc section { padding: 30px 0; border-top: 1px solid var(--border); }
.doc section:first-child { border-top: none; }
.doc h2 { font-size: 22px; margin-bottom: 12px; }
.doc h3 { font-size: 16px; margin: 26px 0 8px; }
.doc p { color: var(--muted); margin: 0 0 12px; }
.doc p:last-child { margin-bottom: 0; }
.doc b { color: var(--text); font-weight: 600; }
.doc em { color: var(--text); font-style: italic; }

code {
  color: var(--accent); background: var(--accent-soft);
  padding: 1px 6px; border-radius: 5px; font-size: .86em;
}

/* lead */
.lead { padding-top: 40px; }
.lead h1 { font-size: clamp(34px, 6vw, 48px); font-weight: 800; margin-bottom: 16px; color: var(--accent); }
.lead p { font-size: 17px; color: var(--muted); }
.lead-eg { font-size: 15.5px; }
.lead-eg b { color: var(--text); font-weight: 600; }
.hero-diagram-link {
  display: block; margin-top: 22px; padding: 12px; overflow: hidden;
  border: 1px solid var(--border); border-radius: 12px; background: var(--bg-alt);
}
.hero-diagram { width: 100%; max-width: 100%; height: auto; display: block; }

/* four principles */
.principles { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.principles li {
  display: flex; gap: 12px; padding: 16px 18px;
  border: 1px solid var(--border); border-radius: 12px; background: var(--panel);
}
.principle-n {
  flex: none; width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center;
  font-weight: 800; font-size: 14px; color: #fff; background: var(--accent);
}
.principles b { color: var(--text); font-size: 15px; }
.principles p { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
@media (max-width: 620px) { .principles { grid-template-columns: 1fr; } }

/* three-step flow */
.flow3 { display: flex; align-items: stretch; gap: 12px; margin-top: 26px; flex-wrap: wrap; }
.flow-step {
  flex: 1 1 0; min-width: 150px;
  display: flex; flex-direction: column; gap: 4px;
  padding: 16px 18px; border: 1px solid var(--border); border-radius: 12px;
  background: var(--panel); transition: border-color .18s, box-shadow .18s;
}
.flow-step:hover { border-color: var(--accent); text-decoration: none; box-shadow: 0 2px 10px rgba(124,58,237,.08); }
.flow-n {
  width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center;
  font-weight: 800; font-size: 14px; color: #fff; background: var(--accent); margin-bottom: 4px;
}
.flow-t { font-weight: 700; color: var(--text); font-size: 16px; }
.flow-d { color: var(--muted); font-size: 13.5px; }
.flow-arrow { display: flex; align-items: center; color: var(--faint); font-size: 22px; }
@media (max-width: 620px) {
  .flow3 { flex-direction: column; }
  .flow-arrow { transform: rotate(90deg); justify-content: center; }
}

/* anatomy */
.stages { margin: 0; display: grid; gap: 6px; }
.stages > div {
  display: grid; grid-template-columns: 150px 1fr; gap: 16px; align-items: baseline;
  padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--panel);
}
.stages dt {
  font-family: 'JetBrains Mono', monospace; font-weight: 600; font-size: 14px; color: var(--accent);
  position: relative; padding-left: 16px;
}
.stages dt::before { content: ""; position: absolute; left: 0; top: .5em; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.stages dd { margin: 0; color: var(--muted); }
.note { font-size: 14px; color: var(--faint) !important; margin-top: 14px !important; }
.more { font-weight: 600; }
.more-row { display: flex; gap: 20px; flex-wrap: wrap; margin-top: 14px; }

/* code panel */
.code-panel { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--bg-alt); margin: 4px 0; }
.code-head { display: flex; align-items: center; gap: 7px; padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--panel-2); }
.dot { width: 11px; height: 11px; border-radius: 50%; background: var(--border); }
.code-file { margin-left: 8px; color: var(--faint); font-size: 12.5px; }
.code { margin: 0; padding: 18px 20px; overflow-x: auto; font-size: 13px; line-height: 1.65; }
.code.plain { border: 1px solid var(--border); border-radius: 12px; background: var(--bg-alt); }
.code code { background: none; padding: 0; color: var(--text); font-size: inherit; }
/* restrained syntax colours */
.c-key { color: var(--accent); }
.c-str { color: #0f766e; }
.c-num, .c-bool { color: var(--text); }
.c-cmt { color: var(--faint); font-style: italic; }
.c-p { color: var(--accent); }

/* diagram tabs */
.flow-tabs { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.flow-tab {
  font-family: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer;
  padding: 7px 14px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--panel); color: var(--muted);
}
.flow-tab:hover { border-color: var(--accent); color: var(--text); }
.flow-tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.flow-tab-eg { font-weight: 500; opacity: .55; }

/* The interactive react-flow diagram (.flow) is styled in visualizer/visualizer.css
   so the visualizer module is self-contained and reusable. */

/* steps list (loop storming) */
.steps-list { margin: 0; padding-left: 20px; color: var(--muted); }
.steps-list li { margin-bottom: 10px; }
.steps-list b { color: var(--text); }
.storm-photo {
  display: block; width: 100%; height: auto; margin-top: 6px;
  border: 1px solid var(--border); border-radius: 12px;
}

/* examples */
.examples-list { margin: 0; padding-left: 20px; color: var(--muted); }
.examples-list li { margin-bottom: 8px; }
.examples-list code { font-size: .82em; }

/* faq */
.faq { margin: 0; }
.faq dt { font-weight: 700; color: var(--text); margin-top: 16px; }
.faq dt:first-child { margin-top: 0; }
.faq dd { margin: 4px 0 0; color: var(--muted); }
.faq dd code { font-size: .85em; }

/* origin */
.origin-lede { font-size: 16px; color: var(--text) !important; }
.origin-lede time { color: var(--muted); }
.authors { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 16px; }
.author { display: flex; flex-direction: column; gap: 1px; border: 1px solid var(--border); background: var(--panel); border-radius: 10px; padding: 10px 18px; }
.author:hover { border-color: var(--accent); text-decoration: none; }
.author-name { font-weight: 700; color: var(--text); }
.author-link { color: var(--accent); font-size: 12.5px; }

/* footer */
.footer { border-top: 1px solid var(--border); }
.footer-inner { max-width: var(--maxw); margin: 0 auto; padding: 24px; }
.footer-fine { color: var(--faint); font-size: 13px; margin: 0; }
.footer-links { margin: 6px 0 0; font-size: 13px; display: flex; gap: 8px; align-items: center; }
.footer-links span { color: var(--faint); }

@media (max-width: 560px) {
  .nav-links { gap: 12px; }
  .nav-links a { font-size: 13px; }
  .stages > div { grid-template-columns: 1fr; gap: 4px; }
  .flow-panel { width: 84%; }
}
