/* ─── Light Theme (default) ──────────────────────────────────── */
:root {
  --bg-base:        #faf9f7;
  --bg-surface:     #f0ede8;
  --bg-hover:       #e8e4de;
  --bg-border:      #ddd8d0;
  --text-primary:   #1c1917;
  --text-secondary: #78716c;
  --accent-primary: #c15f3c;
  --accent-hover:   #a84f30;
  --accent-subtle:  rgba(193, 95, 60, 0.08);
  --shadow:         0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
  --font-serif: 'Playfair Display', Georgia, 'Times New Roman', serif;
  --topbar-height:  52px;
  --radius-sm:      4px;
  --radius-md:      8px;
  --radius-lg:      12px;
  --content-max:    800px;
  /* 3D pipeline */
  --p3d-stage-bg:       #e8e4de;
  --p3d-stage-border:   #d4cfc9;
  --p3d-node-bg:        #f0ede8;
  --p3d-node-border:    #ddd8d0;
  --p3d-muted:          #9a9490;
  --p3d-role-color:     #4a4540;
  --p3d-flow-line-bg:   #c8c0b4;
  --p3d-hint-color:     #8a8480;
  --p3d-node-active-bg: #e4e0da;
  /* demo terminal */
  --demo-bg:            #edeae5;
  --demo-header-bg:     #e8e4de;
  --demo-border:        #d4cfc9;
  --demo-muted:         #9a9490;
  --demo-agent-name:    #3a3530;
  --demo-log-done-color:#6a6058;
  --demo-user-bg:       #e4e0da;
  --demo-user-border:   #d4cfc9;
  --demo-prompt-color:  #9a9490;
  --demo-user-cmd:      #1c1917;
}

/* ─── Dark Theme ─────────────────────────────────────────────── */
[data-theme="dark"] {
  --bg-base:        #0a0a0a;
  --bg-surface:     #111111;
  --bg-hover:       #1a1a1a;
  --bg-border:      #2a2a2a;
  --text-primary:   #f0ece6;
  --text-secondary: #b1ada1;
  --accent-primary: #c15f3c;
  --accent-hover:   #d4714a;
  --accent-subtle:  rgba(193, 95, 60, 0.12);
  --shadow:         0 1px 3px rgba(0,0,0,0.4), 0 1px 2px rgba(0,0,0,0.3);
  /* 3D pipeline */
  --p3d-stage-bg:       #181410;
  --p3d-stage-border:   #2e2822;
  --p3d-node-bg:        #1f1b17;
  --p3d-node-border:    #2e2822;
  --p3d-muted:          #5a5248;
  --p3d-role-color:     #c8c0b4;
  --p3d-flow-line-bg:   #2e2822;
  --p3d-hint-color:     #3d3830;
  --p3d-node-active-bg: #231e18;
  /* demo terminal */
  --demo-bg:            #0d0b09;
  --demo-header-bg:     #111009;
  --demo-border:        #1e1a16;
  --demo-muted:         #5a5248;
  --demo-agent-name:    #c8c0b4;
  --demo-log-done-color:#8a7a6a;
  --demo-user-bg:       #111009;
  --demo-user-border:   #1e1a16;
  --demo-prompt-color:  #5a5248;
  --demo-user-cmd:      #f0ece6;
}

/* ─── Reset & Base ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; font-size: 16px; }

body {
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-sans);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  transition: background 0.2s, color 0.2s;
  padding-top: var(--topbar-height);
}

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

ul, ol { padding-left: 1.5rem; }

hr.section-divider {
  border: none;
  border-top: 1px solid var(--bg-border);
  margin: 4rem 0;
}

/* ─── Topbar ─────────────────────────────────────────────────── */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-height);
  background: color-mix(in srgb, var(--bg-base) 90%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--bg-border);
  z-index: 100;
  transition: background 0.2s, border-color 0.2s;
}

.topbar-inner {
  max-width: calc(var(--content-max) + 4rem);
  margin: 0 auto;
  padding: 0 2rem;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
}

.topbar-logo {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  color: var(--text-primary);
  text-decoration: none;
  flex-shrink: 0;
}

.topbar-logo:hover { text-decoration: none; }

.logo-name {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.logo-sep {
  color: var(--bg-border);
  font-size: 0.9rem;
}

.logo-tag {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.topnav {
  display: flex;
  align-items: center;
  gap: 0.125rem;
}

.topnav-link {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  padding: 0.35rem 0.65rem;
  border-radius: var(--radius-sm);
  transition: color 0.15s, background 0.15s;
  white-space: nowrap;
}

.topnav-link:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
  text-decoration: none;
}

.topnav-link.active {
  color: var(--accent-primary);
  background: var(--accent-subtle);
  font-weight: 500;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  flex-shrink: 0;
}

.github-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8125rem;
  color: var(--text-secondary);
  padding: 0.3rem 0.6rem;
  border-radius: var(--radius-sm);
  transition: color 0.15s, background 0.15s;
}

.github-link:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
  text-decoration: none;
}

.theme-toggle {
  background: var(--bg-hover);
  border: 1px solid var(--bg-border);
  border-radius: var(--radius-md);
  padding: 0.3rem 0.5rem;
  cursor: pointer;
  font-size: 0.8125rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 0.3rem;
  transition: background 0.15s, color 0.15s;
  line-height: 1;
}

.theme-toggle:hover { color: var(--text-primary); background: var(--bg-border); }
.theme-toggle .icon-light { display: none; }
.theme-toggle .icon-dark  { display: inline; }
[data-theme="dark"] .theme-toggle .icon-light { display: inline; }
[data-theme="dark"] .theme-toggle .icon-dark  { display: none; }

/* ─── Cover Page ─────────────────────────────────────────────── */
.cover {
  min-height: calc(100vh - var(--topbar-height));
  background: var(--bg-surface);
  border-bottom: 1px solid var(--bg-border);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 5rem 2rem;
  position: relative;
  transition: background 0.2s, border-color 0.2s;
}

[data-theme="dark"] .cover {
  background: #181410;
  border-bottom-color: #2e2822;
}

.cover-inner {
  max-width: 680px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}

.cover-eyebrow {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.2em;
  color: var(--accent-primary);
  text-transform: uppercase;
  margin-bottom: 2rem;
}

.cover-label {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  font-family: var(--font-sans);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  color: var(--text-secondary);
  text-transform: uppercase;
  margin-bottom: 1.75rem;
}

.cover-rule {
  display: block;
  width: 2.5rem;
  height: 1px;
  background: var(--bg-border);
}

.cover-heading {
  font-family: var(--font-serif);
  font-size: clamp(2.5rem, 6vw, 4.25rem);
  font-weight: 800;
  line-height: 1.1;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  margin-bottom: 1.75rem;
}

.cover-accent {
  font-style: italic;
  color: var(--accent-primary);
}

.cover-sub {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1.0625rem;
  color: var(--text-secondary);
  line-height: 1.65;
  max-width: 520px;
  margin-bottom: 2.5rem;
}

.cover-tags {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  flex-wrap: wrap;
  justify-content: center;
}

.cover-tag {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  color: var(--text-secondary);
  border: 1px solid var(--bg-border);
  border-radius: 999px;
  padding: 0.4rem 1rem;
  transition: color 0.15s, border-color 0.15s;
}

.cover-tag:hover {
  color: var(--accent-primary);
  border-color: var(--accent-primary);
}

/* ─── Page Body ──────────────────────────────────────────────── */
.page-body {
  max-width: calc(var(--content-max) + 4rem);
  margin: 0 auto;
  padding: 4rem 2rem 6rem;
}

/* ─── Section Hero ───────────────────────────────────────────── */
.section-hero {
  padding: 2.5rem 0 2rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--bg-border);
}

.section-kicker {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--accent-primary);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 0.75rem;
}

.section-hero h1 {
  font-size: 2.25rem;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin-bottom: 0.75rem;
  color: var(--text-primary);
}

.section-hero .lead {
  font-size: 1.0625rem;
  color: var(--text-secondary);
  max-width: 640px;
  margin-bottom: 0;
}

/* ─── Typography ─────────────────────────────────────────────── */
.doc-section h2 {
  font-size: 1.125rem;
  font-weight: 600;
  margin-top: 2.75rem;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--bg-border);
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.doc-section h3 {
  font-size: 0.8125rem;
  font-weight: 600;
  margin-top: 1.75rem;
  margin-bottom: 0.5rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.doc-section p {
  margin-bottom: 1rem;
  max-width: var(--content-max);
  color: var(--text-primary);
}

.doc-section ul,
.doc-section ol {
  margin-bottom: 1rem;
  max-width: var(--content-max);
}

.doc-section li { margin-bottom: 0.35rem; }

.lead {
  font-size: 1.0625rem;
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
  max-width: var(--content-max);
}

/* ─── Code ───────────────────────────────────────────────────── */
code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--bg-hover);
  color: var(--accent-primary);
  padding: 0.15em 0.45em;
  border-radius: var(--radius-sm);
  border: 1px solid var(--bg-border);
}

pre {
  background: var(--bg-surface);
  border: 1px solid var(--bg-border);
  border-radius: var(--radius-md);
  padding: 1.25rem 1.5rem;
  overflow-x: auto;
  margin: 1.25rem 0;
  max-width: var(--content-max);
  box-shadow: var(--shadow);
}

pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 0.875rem;
  color: var(--text-primary);
}

/* ─── Pipeline Diagram ───────────────────────────────────────── */
.pipeline {
  display: flex;
  align-items: center;
  margin: 2rem 0;
  max-width: var(--content-max);
  flex-wrap: wrap;
  gap: 0;
}

.pipeline-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--bg-surface);
  border: 1px solid var(--bg-border);
  border-radius: var(--radius-md);
  padding: 1rem 1.5rem;
  min-width: 110px;
  text-align: center;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
  box-shadow: var(--shadow);
}

.pipeline-step:hover {
  border-color: var(--accent-primary);
  background: var(--accent-subtle);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}

.step-cmd {
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 600;
  color: var(--accent-primary);
}

.step-label {
  font-size: 0.6875rem;
  color: var(--text-secondary);
  margin-top: 0.3rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.pipeline-arrow {
  font-size: 1.125rem;
  color: var(--bg-border);
  padding: 0 0.6rem;
  user-select: none;
  flex-shrink: 0;
}

/* ─── Agent Chain ────────────────────────────────────────────── */
.agent-chain {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin: 1.5rem 0;
  max-width: 520px;
}

.agent-node {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  background: var(--bg-surface);
  border: 1px solid var(--bg-border);
  border-radius: var(--radius-md);
  padding: 0.75rem 1.125rem;
  box-shadow: var(--shadow);
  transition: border-color 0.15s;
}

.agent-node:hover { border-color: var(--accent-primary); }

.agent-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-subtle);
  border: 1.5px solid var(--accent-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8125rem;
  color: var(--accent-primary);
  font-weight: 700;
  flex-shrink: 0;
}

.agent-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
  font-family: var(--font-mono);
}

.agent-desc {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 0.1rem;
}

.agent-connector {
  width: 1.5px;
  height: 14px;
  background: var(--bg-border);
  margin-left: calc(16px + 0.875rem);
}

/* ─── Callout ────────────────────────────────────────────────── */
.callout {
  background: var(--accent-subtle);
  border: 1px solid color-mix(in srgb, var(--accent-primary) 30%, transparent);
  border-left: 3px solid var(--accent-primary);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  padding: 1rem 1.25rem;
  margin: 1.5rem 0;
  max-width: var(--content-max);
}

.callout p { margin: 0; color: var(--text-secondary); font-size: 0.9375rem; }
.callout strong { color: var(--text-primary); }

/* ─── Mode Badges ────────────────────────────────────────────── */
.mode-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 1rem 0;
}

.badge {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  border: 1px solid var(--bg-border);
  color: var(--text-secondary);
  background: var(--bg-surface);
}

.badge.accent {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
  background: var(--accent-subtle);
  font-weight: 500;
}

/* ─── Hero Install ───────────────────────────────────────────── */
.hero-install {
  margin-top: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 600px;
}

.install-method {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.install-label {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-secondary);
  opacity: 0.7;
  min-width: 90px;
  flex-shrink: 0;
}

.install-cmd {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  background: var(--bg-surface);
  border: 1px solid var(--bg-border);
  border-radius: var(--radius-md);
  padding: 0.6rem 1rem;
  color: var(--text-primary);
  letter-spacing: 0.01em;
  user-select: all;
}

.install-method.primary .install-cmd {
  border-color: var(--accent-primary);
  background: var(--accent-subtle);
}

/* ─── Plugin Grid ────────────────────────────────────────────── */
.plugin-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin: 1.25rem 0 1.5rem;
  max-width: var(--content-max);
}

@media (max-width: 700px) { .plugin-grid { grid-template-columns: 1fr; } }
@media (min-width: 701px) and (max-width: 900px) { .plugin-grid { grid-template-columns: repeat(2, 1fr); } }

.plugin-card {
  background: var(--bg-surface);
  border: 1px solid var(--bg-border);
  border-radius: var(--radius-md);
  padding: 0.875rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  transition: border-color 0.15s;
}

.plugin-card:hover { border-color: var(--accent-primary); }

.plugin-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.plugin-name {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent-primary);
}

.plugin-desc {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.45;
}

.plugin-install {
  margin-top: 0.35rem;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-secondary);
  opacity: 0.7;
  user-select: all;
}

/* ─── Feature Grid ───────────────────────────────────────────── */
.feature-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.875rem;
  margin: 1.25rem 0 1.5rem;
  max-width: var(--content-max);
}

.feature-card {
  background: var(--bg-surface);
  border: 1px solid var(--bg-border);
  border-radius: var(--radius-md);
  padding: 1rem 1.125rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.feature-card:hover {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}

.feature-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
  gap: 0.5rem;
}

.feature-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
}

.feature-desc {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  line-height: 1.55;
  margin: 0;
}

/* ─── Principle List ─────────────────────────────────────────── */
.principle-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 1.25rem 0;
  max-width: var(--content-max);
}

.principle-item {
  display: flex;
  align-items: baseline;
  gap: 0.875rem;
  padding: 0.6rem 0.875rem;
  background: var(--bg-surface);
  border: 1px solid var(--bg-border);
  border-radius: var(--radius-sm);
}

.principle-tag {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent-primary);
  flex-shrink: 0;
  min-width: 100px;
}

.principle-text {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* ─── Directory Table ────────────────────────────────────────── */
.dir-table {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin: 1.25rem 0;
  max-width: var(--content-max);
  border: 1px solid var(--bg-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.dir-row {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 1rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--bg-border);
  align-items: baseline;
}

.dir-row:last-child { border-bottom: none; }
.dir-row:nth-child(odd) { background: var(--bg-surface); }

.dir-name {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  background: none;
  border: none;
  padding: 0;
  color: var(--accent-primary);
  word-break: break-all;
}

.dir-desc {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  line-height: 1.55;
}

/* ─── Command Cards ──────────────────────────────────────────── */
.cmd-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin: 1.25rem 0;
  max-width: var(--content-max);
}

.cmd-card {
  background: var(--bg-surface);
  border: 1px solid var(--bg-border);
  border-radius: var(--radius-md);
  padding: 1rem 1.125rem;
  transition: border-color 0.15s;
}

.cmd-card:hover { border-color: var(--accent-primary); }

.cmd-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.625rem;
  gap: 0.75rem;
}

.cmd-name {
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 600;
  color: var(--accent-primary);
  background: none;
  border: none;
  padding: 0;
}

.cmd-card p {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin: 0;
  max-width: none;
}

/* ─── Step List ──────────────────────────────────────────────── */
.step-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin: 1.25rem 0;
  max-width: 520px;
}

.step-item {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 0.875rem 0;
  border-bottom: 1px solid var(--bg-border);
}

.step-item:last-child { border-bottom: none; }

.step-num {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent-primary);
  background: var(--accent-subtle);
  border: 1px solid color-mix(in srgb, var(--accent-primary) 30%, transparent);
  border-radius: var(--radius-sm);
  padding: 0.2rem 0.45rem;
  flex-shrink: 0;
  margin-top: 0.1rem;
  letter-spacing: 0.04em;
}

.step-body { flex: 1; }

.step-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.2rem;
}

.step-text {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* ─── Hook Cards ─────────────────────────────────────────────── */
.hook-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.875rem;
  margin: 1.25rem 0;
  max-width: var(--content-max);
}

.hook-card {
  background: var(--bg-surface);
  border: 1px solid var(--bg-border);
  border-radius: var(--radius-md);
  padding: 1rem 1.125rem;
  transition: border-color 0.15s;
}

.hook-card:hover { border-color: var(--accent-primary); }

.hook-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
  gap: 0.5rem;
}

.hook-name {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent-primary);
  background: none;
  border: none;
  padding: 0;
}

.hook-card p {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  line-height: 1.55;
  margin: 0;
}

/* ─── 3D Pipeline ────────────────────────────────────────────── */
.pipeline-3d-wrap {
  margin: 1.75rem 0 0.5rem;
  max-width: var(--content-max);
  perspective: 1200px;
}

.p3d-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2.5rem 2rem;
  background: var(--p3d-stage-bg);
  border: 1px solid var(--p3d-stage-border);
  border-radius: var(--radius-lg);
  transform: rotateX(-5deg) rotateY(8deg);
  transform-style: preserve-3d;
  box-shadow:
    0 32px 64px rgba(0,0,0,0.25),
    0 8px 20px rgba(0,0,0,0.15),
    inset 0 1px 0 rgba(255,255,255,0.04);
  will-change: transform;
  transition: transform 0.6s cubic-bezier(0.4,0,0.2,1);
}

.p3d-node {
  position: relative;
  background: var(--p3d-node-bg);
  border: 1.5px solid var(--p3d-node-border);
  border-radius: var(--radius-md);
  padding: 1.25rem 1.75rem;
  text-align: center;
  min-width: 145px;
  transform-style: preserve-3d;
  transition: border-color 0.2s, transform 0.25s, box-shadow 0.25s;
  cursor: default;
}

.p3d-node:hover {
  border-color: var(--accent-primary);
  transform: translateZ(20px) scale(1.03);
  box-shadow: 0 0 0 3px rgba(193,95,60,0.2), 0 12px 32px rgba(0,0,0,0.4);
}

.p3d-pulse-ring {
  position: absolute;
  inset: -7px;
  border: 1px solid var(--accent-primary);
  border-radius: calc(var(--radius-md) + 7px);
  opacity: 0;
  pointer-events: none;
  animation: p3d-pulse 3.5s ease-out infinite;
}

@keyframes p3d-pulse {
  0%   { opacity: 0; transform: scale(0.94); }
  15%  { opacity: 0.55; }
  100% { opacity: 0; transform: scale(1.1); }
}

.p3d-step-num {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--p3d-muted);
  margin-bottom: 0.4rem;
  text-transform: uppercase;
}

.p3d-cmd {
  font-family: var(--font-mono);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent-primary);
  margin-bottom: 0.25rem;
}

.p3d-role {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--p3d-role-color);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 0.5rem;
}

.p3d-sub {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  color: var(--p3d-muted);
  line-height: 1.5;
}

.p3d-conn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  padding: 0 0.875rem;
  flex-shrink: 0;
}

.p3d-flow-line {
  width: 56px;
  height: 2px;
  background: var(--p3d-flow-line-bg);
  border-radius: 999px;
  position: relative;
  overflow: hidden;
}

.p3d-flow-dot {
  position: absolute;
  top: 50%;
  left: -8px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-primary);
  transform: translateY(-50%);
  animation: p3d-flow 2s ease-in-out infinite;
  box-shadow: 0 0 8px var(--accent-primary), 0 0 16px rgba(193,95,60,0.4);
}

@keyframes p3d-flow {
  0%   { left: -8px;  opacity: 0; }
  8%   { opacity: 1; }
  92%  { opacity: 1; }
  100% { left: calc(100% + 8px); opacity: 0; }
}

.p3d-conn-label {
  font-family: var(--font-mono);
  font-size: 0.58rem;
  color: var(--p3d-hint-color);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.p3d-hint {
  text-align: center;
  font-size: 0.72rem;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
  margin-top: 0.75rem;
  opacity: 0.5;
}

.p3d-click-hint {
  font-family: var(--font-mono);
  font-size: 0.58rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--p3d-hint-color);
  margin-top: 0.625rem;
  transition: color 0.2s;
}

.p3d-node:hover .p3d-click-hint { color: var(--accent-primary); }

.p3d-node.p3d-active {
  border-color: var(--accent-primary);
  background: var(--p3d-node-active-bg);
  box-shadow: 0 0 0 3px rgba(193,95,60,0.25), 0 12px 32px rgba(0,0,0,0.5);
  transform: translateZ(24px) scale(1.04);
}

/* ─── Demo Terminal ───────────────────────────────────────────── */
.pipeline-demo {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.45s cubic-bezier(0.4, 0, 0.2, 1);
  margin-top: 0;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  background: var(--demo-bg);
  border: 1px solid transparent;
  border-top: none;
}

.pipeline-demo.open {
  max-height: 2000px;
  margin-top: -1px;
  border-color: var(--accent-primary);
  border-top: none;
}

.demo-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 1rem;
  border-bottom: 1px solid var(--demo-border);
  background: var(--demo-header-bg);
  gap: 1rem;
}

.demo-cmd-label {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--accent-primary);
  font-weight: 600;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.demo-status {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--demo-muted);
  flex-shrink: 0;
}

.demo-status.running { color: var(--accent-primary); }
.demo-status.done    { color: #7ab47a; }

.demo-close {
  background: none;
  border: none;
  color: var(--demo-muted);
  cursor: pointer;
  font-size: 0.875rem;
  padding: 0.15rem 0.35rem;
  border-radius: var(--radius-sm);
  line-height: 1;
  flex-shrink: 0;
  transition: color 0.15s, background 0.15s;
}

.demo-close:hover { color: var(--text-primary); background: var(--p3d-node-border); }

.demo-steps {
  padding: 1rem 1.25rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.demo-step {
  opacity: 0;
  transform: translateX(-10px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  border-left: 2px solid transparent;
  padding-left: 0.5rem;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.demo-step.visible {
  opacity: 1;
  transform: translateX(0);
}

/* per-type left border color */
.demo-step:not(.demo-step-user):not(.demo-step-output):not(.demo-step-hook):not(.demo-step-main):not(.demo-step-slash) {
  border-left-color: rgba(193, 95, 60, 0.5);     /* agent — orange */
}
.demo-step-hook   { border-left-color: rgba(107, 155, 210, 0.5); } /* hook  — blue   */
.demo-step-main   { border-left-color: rgba(167, 139, 250, 0.6); } /* main  — purple */
.demo-step-user   { border-left: none; padding-left: 0; }
.demo-step-output { border-left: none; padding-left: 0; }

.demo-step-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.demo-spinner {
  width: 13px;
  height: 13px;
  border: 1.5px solid var(--p3d-node-border);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: demo-spin 0.65s linear infinite;
  flex-shrink: 0;
}

@keyframes demo-spin { to { transform: rotate(360deg); } }

.demo-check {
  display: none;
  width: 13px;
  height: 13px;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  color: #7ab47a;
  flex-shrink: 0;
  font-weight: 700;
}

.demo-step.done .demo-spinner { display: none; }
.demo-step.done .demo-check   { display: flex; }

.demo-agent-icon {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(193,95,60,0.12);
  border: 1px solid rgba(193,95,60,0.3);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--accent-primary);
  flex-shrink: 0;
}

.demo-agent-name {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--demo-agent-name);
}

.demo-step.done .demo-agent-name { color: #7ab47a; }

.demo-log {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  padding-left: calc(13px + 20px + 0.5rem + 0.5rem);
  margin-top: 0.2rem;
  line-height: 1.5;
}

.demo-log-running { color: var(--demo-muted); }

.demo-log-done {
  color: var(--demo-log-done-color);
  opacity: 0;
  transition: opacity 0.4s ease;
}

.demo-log-done.visible { opacity: 1; }

/* agent step background tint */
.demo-step:not(.demo-step-user):not(.demo-step-output):not(.demo-step-hook):not(.demo-step-main):not(.demo-step-slash).visible {
  background: rgba(193, 95, 60, 0.03);
}
.demo-step-main.visible { background: rgba(167, 139, 250, 0.04); }

/* user input step */
.demo-step-user {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.625rem;
  background: var(--demo-user-bg);
  border: 1px solid var(--demo-user-border);
  border-radius: var(--radius-sm);
}

.demo-prompt {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--demo-prompt-color);
  flex-shrink: 0;
}

.demo-user-cmd {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--demo-user-cmd);
  letter-spacing: 0.01em;
}

/* hook step — blue */
.demo-step-hook .demo-spinner     { border-top-color: #6b9bd2; }
.demo-step-hook .demo-check       { color: #6b9bd2; }
.demo-step-hook .demo-agent-name  { color: #8baed4; font-weight: 500; }
.demo-step-hook.done .demo-agent-name { color: #6b9bd2; }
.demo-step-hook .demo-log-running { color: #3a4f66; }
.demo-step-hook .demo-log-done    { color: #4a6a8a; }

.demo-hook-icon {
  background: rgba(107, 155, 210, 0.1) !important;
  border-color: rgba(107, 155, 210, 0.35) !important;
  color: #6b9bd2 !important;
}

/* slash command step — amber */
.demo-step-slash .demo-spinner     { border-top-color: #d4920a; }
.demo-step-slash .demo-check       { color: #d4920a; }
.demo-step-slash .demo-agent-name  { color: #e4a820; font-weight: 700; }
.demo-step-slash.done .demo-agent-name { color: #d4920a; }
.demo-step-slash .demo-log-running { color: #4a3808; }
.demo-step-slash .demo-log-done    { color: #7a5a10; }
.demo-step-slash                   { border-left-color: rgba(212, 146, 10, 0.55); }
.demo-step-slash.visible           { background: rgba(212, 146, 10, 0.04); }

.demo-slash-icon {
  background: rgba(212, 146, 10, 0.12) !important;
  border-color: rgba(212, 146, 10, 0.4) !important;
  color: #d4920a !important;
  font-weight: 800 !important;
  font-size: 0.9rem !important;
}

/* main agent step — purple */
.demo-step-main .demo-spinner     { border-top-color: #a78bfa; }
.demo-step-main .demo-check       { color: #a78bfa; }
.demo-step-main .demo-agent-name  { color: #c4b5fd; font-weight: 600; }
.demo-step-main.done .demo-agent-name { color: #a78bfa; }
.demo-step-main .demo-log-running { color: #4a3f6a; }
.demo-step-main .demo-log-done    { color: #6e5fa8; }

.demo-main-icon {
  background: rgba(167, 139, 250, 0.12) !important;
  border-color: rgba(167, 139, 250, 0.4) !important;
  color: #a78bfa !important;
  font-size: 0.8rem !important;
}

/* output step */
.demo-step-output {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.625rem;
  background: rgba(122, 180, 122, 0.06);
  border: 1px solid rgba(122, 180, 122, 0.2);
  border-radius: var(--radius-sm);
  margin-top: 0.25rem;
}

.demo-output-prefix {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: #7ab47a;
  flex-shrink: 0;
}

.demo-output-text {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: #7ab47a;
  font-weight: 500;
}

/* ─── Expandable Command Cards ───────────────────────────────── */
.cmd-card-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  flex: 1;
}

.cmd-chevron {
  font-size: 1.125rem;
  color: var(--text-secondary);
  transition: transform 0.3s ease, color 0.2s;
  line-height: 1;
  flex-shrink: 0;
}

.cmd-open .cmd-chevron {
  transform: rotate(90deg);
  color: var(--accent-primary);
}

.cmd-toggle { cursor: pointer; }
.cmd-toggle:hover .cmd-chevron { color: var(--accent-primary); }

.cmd-open { border-color: var(--accent-primary); }
.cmd-open .cmd-card-header { border-bottom: 1px solid var(--bg-border); padding-bottom: 0.625rem; margin-bottom: 0.625rem; }

.cmd-detail { overflow: hidden; }

.cmd-detail-inner {
  padding: 1rem 0 0.25rem;
}

/* ─── Token Cost Notice ──────────────────────────────────────── */
.token-cost {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 10px;
  padding: 6px 10px;
  background: var(--bg-surface);
  border: 1px solid var(--bg-border);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.71rem;
  color: var(--text-secondary);
  line-height: 1;
}

.token-cost-icon {
  font-size: 0.8rem;
  opacity: 0.55;
  flex-shrink: 0;
}

.token-cost-range {
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: 0.01em;
}

.token-cost-sep { opacity: 0.4; }

.token-cost-note { opacity: 0.65; }

.token-breakdown {
  margin-top: 14px;
  border-top: 1px solid var(--bg-border);
  padding-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 0;
  max-width: 460px;
}

.token-breakdown-title {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-secondary);
  opacity: 0.7;
  margin-bottom: 6px;
}

.token-breakdown-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 8px;
  font-family: var(--font-mono);
  font-size: 0.73rem;
  border-bottom: 1px solid var(--bg-border);
}

.token-breakdown-row:last-child { border-bottom: none; }

.token-breakdown-flag { color: var(--accent-primary); font-weight: 500; }

.token-breakdown-cost {
  color: var(--text-primary);
  font-weight: 600;
}

.token-breakdown-agents { color: var(--text-secondary); opacity: 0.7; font-size: 0.67rem; }

/* ─── Agent Flow (inline) ────────────────────────────────────── */
.cmd-agent-flow {
  display: flex;
  flex-direction: column;
  gap: 0;
  max-width: 460px;
}

.caf-node {
  display: grid;
  grid-template-columns: 28px 1fr;
  grid-template-rows: auto auto;
  column-gap: 0.75rem;
  padding: 0.625rem 0.875rem;
  background: var(--bg-hover);
  border: 1px solid var(--bg-border);
  border-radius: var(--radius-sm);
  align-items: center;
  transition: border-color 0.15s;
  animation: caf-in 0.3s ease both;
}

.caf-node:hover { border-color: var(--accent-primary); }

@keyframes caf-in {
  from { opacity: 0; transform: translateX(-8px); }
  to   { opacity: 1; transform: translateX(0); }
}

.caf-node:nth-child(3) { animation-delay: 0.06s; }
.caf-node:nth-child(5) { animation-delay: 0.12s; }

.caf-icon {
  grid-row: 1 / 3;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-subtle);
  border: 1.5px solid var(--accent-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent-primary);
  font-family: var(--font-mono);
  flex-shrink: 0;
}

.caf-name {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.2;
}

.caf-desc {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.caf-arrow {
  text-align: left;
  padding-left: calc(28px + 0.75rem + 0.875rem);
  font-size: 0.75rem;
  color: var(--bg-border);
  line-height: 1.4;
  user-select: none;
}

/* ─── Scroll Fade-up ─────────────────────────────────────────── */
.fade-up {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.fade-up.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ─── Responsive ─────────────────────────────────────────────── */
@media (max-width: 800px) {
  .topbar-inner { padding: 0 1rem; }

  .logo-tag { display: none; }
  .logo-sep { display: none; }

  .topnav {
    gap: 0;
    overflow-x: auto;
  }

  .topnav-link { padding: 0.35rem 0.5rem; font-size: 0.75rem; }

  .page-body { padding: 2.5rem 1rem 4rem; }

  .cover { padding: 3rem 1.25rem; }
  .cover-heading { font-size: clamp(2rem, 9vw, 2.75rem); }

  .feature-grid  { grid-template-columns: 1fr; }
  .hook-list     { grid-template-columns: 1fr; }

  .dir-row { grid-template-columns: 1fr; gap: 0.25rem; }
  .cmd-card-header { flex-direction: column; align-items: flex-start; }

  .p3d-stage { flex-direction: column; padding: 1.75rem 1.25rem; transform: none !important; }
  .p3d-conn { flex-direction: row; padding: 0.4rem 0; }
  .p3d-flow-line { width: 2px; height: 32px; }
  .p3d-flow-dot {
    top: -8px; left: 50%;
    transform: translateX(-50%);
    animation-name: p3d-flow-vert;
  }
  @keyframes p3d-flow-vert {
    0%   { top: -8px;  opacity: 0; }
    8%   { opacity: 1; }
    92%  { opacity: 1; }
    100% { top: calc(100% + 8px); opacity: 0; }
  }
  .p3d-hint { display: none; }

  .pipeline { flex-direction: column; align-items: flex-start; }
  .pipeline-arrow { transform: rotate(90deg); padding: 0.2rem 0; }
}

@media (max-width: 560px) {
  .feature-grid { grid-template-columns: 1fr; }
  .topnav { display: none; }
}
