/* ═══════════════════════════════════════════════════════════════
   CLAUDE CODE ANALYSIS — Terminal Archaeology Theme
   Font: JetBrains Mono (mono-first, full terminal aesthetic)
   Palette: void black + electric cyan + amber
   ═══════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:ital,wght@0,100..800;1,100..800&display=swap');

:root {
  /* Core palette — dark mode (default) */
  --bg-void:        #060a0f;
  --bg-deep:        #0a0f16;
  --bg-surface:     #0f1822;
  --bg-raised:      #141f2e;
  --bg-hover:       #1a2740;

  /* Borders */
  --border-dim:     #1e2d42;
  --border-mid:     #253650;
  --border-bright:  #2e4566;

  /* Text */
  --text-ghost:     #2a3f5c;
  --text-muted:     #4a6a8a;
  --text-dim:       #6a8faf;
  --text-body:      #9ab8d4;
  --text-primary:   #c8dff0;
  --text-bright:    #e8f4ff;

  /* Accents */
  --cyan:           #00d9ff;
  --cyan-dim:       #0099bb;
  --cyan-glow:      rgba(0, 217, 255, 0.12);
  --cyan-glow-lg:   rgba(0, 217, 255, 0.06);
  --amber:          #ffb347;
  --amber-dim:      #cc7a00;
  --amber-glow:     rgba(255, 179, 71, 0.12);
  --green:          #39d353;
  --green-dim:      #1a7a2e;
  --red:            #ff5c5c;

  /* Scanline texture */
  --scanline: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.08) 2px,
    rgba(0, 0, 0, 0.08) 4px
  );
}

/* ── Light mode overrides ── */
html.light {
  /* 背景：接近 #F8FAFC 文档站标准 */
  --bg-void:        #f8fafc;
  --bg-deep:        #f1f5f9;
  --bg-surface:     #e9eef5;
  --bg-raised:      #dde4ee;
  --bg-hover:       #cfd8e8;

  /* 边框 */
  --border-dim:     #cbd5e1;
  --border-mid:     #94a3b8;
  --border-bright:  #64748b;

  /* 文字：确保 4.5:1+ 对比度 */
  --text-ghost:     #94a3b8;
  --text-muted:     #64748b;  /* #64748b on #f8fafc = 4.6:1 ✓ */
  --text-dim:       #475569;
  --text-body:      #1e293b;  /* #1e293b on #f8fafc = 12:1 ✓ */
  --text-primary:   #0f172a;
  --text-bright:    #020617;

  /* 强调色：#2563eb 是文档站标准蓝，对比度 5.9:1 */
  --cyan:           #2563eb;
  --cyan-dim:       #1d4ed8;
  --cyan-glow:      rgba(37, 99, 235, 0.10);
  --cyan-glow-lg:   rgba(37, 99, 235, 0.05);
  --amber:          #92400e;
  --amber-dim:      #78350f;
  --amber-glow:     rgba(146, 64, 14, 0.10);
  --green:          #166534;
  --green-dim:      #14532d;
  --red:            #b91c1c;

  --scanline: none;
}

/* ── Skip Link ── */
.skip-link {
  position: absolute;
  top: -100px;
  left: 12px;
  z-index: 9999;
  background: var(--cyan);
  color: var(--bg-void);
  font-size: 13px;
  font-weight: 700;
  padding: 8px 16px;
  border-radius: 0 0 6px 6px;
  text-decoration: none;
  transition: top 0.15s;
}
.skip-link:focus { top: 0; }

/* ── Focus Styles ── */
:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
  border-radius: 3px;
}
button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; scroll-behavior: smooth; }
/* Smooth theme transition */
body, #sidebar, #toc, #content, #drawer, pre, code, table, .callout, .stat-card, .flow-card {
  transition: background-color 0.25s ease, border-color 0.25s ease, color 0.2s ease;
}
body {
  font-family: 'JetBrains Mono', 'Fira Code', Consolas, monospace;
  background: var(--bg-void);
  background-image: var(--scanline);
  color: var(--text-body);
  display: flex;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── Sidebar ── */
#sidebar-wrapper {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-shrink: 0;
  width: 252px;
  transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: visible;
}
#sidebar-wrapper.collapsed { width: 0 !important; min-width: 0; overflow: visible; }
#sidebar {
  flex: 1;
  min-width: 0;
  background: var(--bg-deep);
  border-right: 1px solid var(--border-dim);
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0;
  transition: opacity 0.2s;
  scrollbar-width: thin;
  scrollbar-color: var(--border-mid) transparent;
}
#sidebar::-webkit-scrollbar { width: 3px; }
#sidebar::-webkit-scrollbar-track { background: transparent; }
#sidebar::-webkit-scrollbar-thumb { background: var(--border-mid); border-radius: 2px; }
#sidebar-wrapper.collapsed #sidebar {
  opacity: 0;
  pointer-events: none;
  display: none;
}
#sidebar-resize-handle {
  width: 4px;
  cursor: col-resize;
  background: transparent;
  transition: background 0.15s;
  flex-shrink: 0;
  position: relative;
  z-index: 5;
}
#sidebar-resize-handle:hover { background: var(--cyan); }
#sidebar-wrapper.collapsed #sidebar-resize-handle { display: none; }
#sidebar-toggle {
  position: absolute;
  top: 48px;
  right: -20px;
  width: 20px;
  height: 28px;
  background: var(--bg-deep);
  border: 1px solid var(--border-dim);
  border-left: none;
  border-radius: 0 4px 4px 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: color 0.15s, background 0.15s;
  z-index: 10;
}
#sidebar-toggle:hover { color: var(--cyan); background: var(--bg-raised); }
#sidebar-toggle svg { width: 10px; height: 10px; transition: transform 0.2s; }
#sidebar-wrapper #sidebar-toggle svg { transform: rotate(180deg); }
#sidebar-wrapper.collapsed #sidebar-toggle svg { transform: rotate(0deg); }

/* Sidebar header */
#sidebar .logo {
  padding: 24px 20px 18px;
  border-bottom: 1px solid var(--border-dim);
  margin-bottom: 0;
  position: relative;
}
#sidebar .logo::before {
  content: '//';
  position: absolute;
  top: 24px;
  left: 20px;
  color: var(--cyan);
  font-size: 11px;
  font-weight: 700;
  opacity: 0.6;
}
#sidebar .logo h2 {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-bright);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding-left: 20px;
  line-height: 1.3;
}
#theme-toggle {
  position: fixed;
  top: 16px;
  right: 20px;
  z-index: 50;
  background: var(--bg-raised);
  border: 1px solid var(--border-mid);
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
#theme-toggle:hover {
  color: var(--cyan);
  border-color: var(--cyan-dim);
  background: var(--cyan-glow);
}
#sidebar .logo p {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 5px;
  padding-left: 20px;
  letter-spacing: 0.03em;
}

/* Nav */
#sidebar nav { padding: 12px 0 24px; }
#sidebar nav ul { list-style: none; }
#sidebar nav > ul > li {
  margin: 0;
  opacity: 0;
  animation: navItemIn 0.4s forwards;
}
#sidebar nav > ul > li:nth-child(1)  { animation-delay: 0.05s; }
#sidebar nav > ul > li:nth-child(2)  { animation-delay: 0.10s; }
#sidebar nav > ul > li:nth-child(3)  { animation-delay: 0.15s; }
#sidebar nav > ul > li:nth-child(4)  { animation-delay: 0.20s; }
#sidebar nav > ul > li:nth-child(5)  { animation-delay: 0.25s; }
#sidebar nav > ul > li:nth-child(6)  { animation-delay: 0.30s; }
#sidebar nav > ul > li:nth-child(7)  { animation-delay: 0.35s; }
#sidebar nav > ul > li:nth-child(8)  { animation-delay: 0.40s; }
#sidebar nav > ul > li:nth-child(9)  { animation-delay: 0.45s; }
#sidebar nav > ul > li:nth-child(10) { animation-delay: 0.50s; }
#sidebar nav > ul > li:nth-child(11) { animation-delay: 0.55s; }
@keyframes navItemIn {
  from { opacity: 0; transform: translateX(-8px); }
  to   { opacity: 1; transform: translateX(0); }
}
#sidebar nav .section-title {
  display: block;
  padding: 6px 20px;
  font-size: 9px;
  font-weight: 700;
  color: var(--text-ghost);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  margin-top: 12px;
}
#sidebar nav a {
  display: block;
  padding: 7px 20px 7px 22px;
  font-size: 13px;
  color: var(--text-dim);
  text-decoration: none;
  border-left: 2px solid transparent;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
  letter-spacing: 0.02em;
  position: relative;
}
#sidebar nav a::before {
  content: '';
  position: absolute;
  left: 22px;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  transition: width 0.15s;
}
#sidebar nav a:hover {
  color: var(--text-primary);
  background: var(--bg-raised);
}
#sidebar nav a.active {
  color: var(--cyan);
  border-left-color: var(--cyan);
  background: linear-gradient(90deg, var(--cyan-glow) 0%, transparent 100%);
  font-weight: 600;
}
#sidebar nav a.active::before {
  content: '▸';
  color: var(--cyan);
  font-size: 9px;
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: auto;
}
#sidebar nav ul ul a { padding-left: 36px; font-size: 11px; }

/* ── Main Content ── */
#main {
  flex: 1;
  display: flex;
  min-width: 0;
}
#content {
  flex: 1;
  padding: 52px 64px;
  min-width: 0;
}

/* ── TOC (right) ── */
#toc-wrapper {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-shrink: 0;
  width: 172px;
  transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: visible;
}
#toc-wrapper.collapsed { width: 0 !important; min-width: 0; overflow: visible; }
#toc-toggle {
  position: absolute;
  top: 48px;
  left: -20px;
  width: 20px;
  height: 28px;
  background: var(--bg-deep);
  border: 1px solid var(--border-dim);
  border-right: none;
  border-radius: 4px 0 0 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: color 0.15s, background 0.15s;
  z-index: 10;
}
#toc-toggle:hover { color: var(--cyan); background: var(--bg-raised); }
#toc-toggle svg { width: 10px; height: 10px; transition: transform 0.2s; }
#toc-wrapper #toc-toggle svg { transform: rotate(0deg); }
#toc-wrapper.collapsed #toc-toggle svg { transform: rotate(180deg); }
#toc-resize-handle {
  width: 4px;
  cursor: col-resize;
  background: transparent;
  transition: background 0.15s;
  flex-shrink: 0;
}
#toc-resize-handle:hover { background: var(--cyan); }
#toc-wrapper.collapsed #toc-resize-handle { display: none; }
#toc {
  flex: 1;
  padding: 52px 14px 48px;
  overflow-y: auto;
  overflow-x: hidden;
  min-width: 0;
  border-left: 1px solid var(--border-dim);
  scrollbar-width: thin;
  scrollbar-color: var(--border-mid) transparent;
}
#toc::-webkit-scrollbar { width: 3px; }
#toc::-webkit-scrollbar-track { background: transparent; }
#toc::-webkit-scrollbar-thumb { background: var(--border-mid); border-radius: 2px; }
#toc-wrapper.collapsed #toc { display: none; }
#toc h4 {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-ghost);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  margin-bottom: 14px;
}
#toc ul { list-style: none; }
#toc ul li { margin-bottom: 4px; }
#toc ul a {
  font-size: 12px;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.15s, padding-left 0.15s;
  display: block;
  word-break: break-word;
  line-height: 1.5;
  padding: 2px 0 2px 0;
  border-left: 2px solid transparent;
  padding-left: 6px;
  margin-left: -8px;
}
#toc ul a:hover { color: var(--cyan); }
#toc ul a.toc-active {
  color: var(--cyan);
  border-left-color: var(--cyan);
  padding-left: 8px;
}
#toc ul ul { margin-left: 10px; margin-top: 2px; }

/* ── Typography ── */
.page-section { display: none; }
.page-section.active {
  display: block;
  animation: pageIn 0.3s ease;
}
@keyframes pageIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

h1 {
  font-size: 26px;
  font-weight: 800;
  color: var(--text-bright);
  margin-bottom: 10px;
  letter-spacing: -0.02em;
  line-height: 1.2;
}
h2 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 44px 0 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-dim);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  position: relative;
}
h2::before {
  content: none;
}
h3 {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 28px 0 12px;
  letter-spacing: 0.02em;
}
h3::before {
  content: none;
}
h4 {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-body);
  margin: 20px 0 8px;
  letter-spacing: 0.02em;
}
p {
  line-height: 1.8;
  color: var(--text-body);
  margin-bottom: 16px;
  font-size: 14px;
}
ul, ol { padding-left: 20px; margin-bottom: 16px; }
li {
  line-height: 1.8;
  color: var(--text-body);
  margin-bottom: 4px;
  font-size: 14px;
}
ul li::marker { color: var(--cyan-dim); }
ol li::marker { color: var(--cyan-dim); font-weight: 600; }
a { color: var(--cyan); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

code {
  font-family: 'JetBrains Mono', 'Fira Code', Consolas, monospace;
  font-size: 12px;
  background: var(--bg-raised);
  color: var(--cyan);
  padding: 2px 6px;
  border-radius: 3px;
  border: 1px solid var(--border-mid);
}
pre {
  background: var(--bg-deep);
  border: 1px solid var(--border-dim);
  border-left: 2px solid var(--border-mid);
  border-radius: 0 4px 4px 0;
  padding: 16px 20px;
  overflow-x: auto;
  margin: 20px 0;
  position: relative;
  scrollbar-width: thin;
  scrollbar-color: var(--border-mid) transparent;
}
pre::-webkit-scrollbar { height: 4px; }
pre::-webkit-scrollbar-track { background: transparent; }
pre::-webkit-scrollbar-thumb { background: var(--border-mid); border-radius: 2px; }
pre code {
  background: none;
  border: none;
  padding: 0;
  color: var(--text-primary);
  font-size: 12.5px;
  line-height: 1.7;
}
.subtitle {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 36px;
  line-height: 1.7;
  border-left: 2px solid var(--border-mid);
  padding-left: 14px;
}

/* ── Callout / Info Box ── */
.callout {
  border-left: 2px solid var(--cyan-dim);
  background: var(--bg-surface);
  border-radius: 0 4px 4px 0;
  padding: 12px 16px;
  margin: 20px 0;
  position: relative;
}
.callout::before {
  content: 'INFO';
  position: absolute;
  top: -8px;
  left: 12px;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--cyan-dim);
  background: var(--bg-surface);
  padding: 0 4px;
}
.callout.warning { border-left-color: var(--amber-dim); }
.callout.warning::before { content: 'WARN'; color: var(--amber-dim); background: var(--bg-surface); }
.callout.tip { border-left-color: var(--green-dim); }
.callout.tip::before { content: 'TIP'; color: var(--green-dim); background: var(--bg-surface); }
.callout p { margin-bottom: 0; font-size: 12.5px; }
.callout strong { color: var(--text-bright); }

/* ── Table ── */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 20px 0;
  font-size: 12.5px;
  border: 1px solid var(--border-dim);
  border-radius: 6px;
  overflow: hidden;
}
th {
  background: var(--bg-surface);
  color: var(--text-primary);
  font-weight: 700;
  padding: 9px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border-mid);
  font-size: 11px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
td {
  padding: 8px 14px;
  border-bottom: 1px solid var(--border-dim);
  color: var(--text-body);
  font-size: 12.5px;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg-surface); }

/* ── Badge ── */
.badge {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 2px;
  margin-left: 8px;
  vertical-align: middle;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.badge-blue { background: rgba(0, 217, 255, 0.1); color: var(--cyan); border: 1px solid rgba(0, 217, 255, 0.25); }
.badge-green { background: rgba(57, 211, 83, 0.1); color: var(--green); border: 1px solid rgba(57, 211, 83, 0.25); }
.badge-yellow { background: rgba(255, 179, 71, 0.1); color: var(--amber); border: 1px solid rgba(255, 179, 71, 0.25); }

/* ── Prompt Trigger Button ── */
.prompt-trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-dim);
  background: var(--bg-surface);
  border: 1px solid var(--border-mid);
  border-radius: 3px;
  padding: 5px 12px;
  cursor: pointer;
  transition: all 0.15s;
  margin: 8px 0;
  user-select: none;
  letter-spacing: 0.03em;
  font-family: 'JetBrains Mono', monospace;
}
.prompt-trigger:hover {
  color: var(--cyan);
  border-color: var(--cyan-dim);
  background: var(--cyan-glow);
  box-shadow: 0 0 12px var(--cyan-glow);
}
.prompt-trigger svg { width: 12px; height: 12px; }

/* ── Drawer ── */
#drawer-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 100;
  backdrop-filter: blur(3px);
}
#drawer-overlay.open { display: block; }
#drawer {
  position: fixed;
  top: 0;
  right: -540px;
  width: 540px;
  height: 100vh;
  background: var(--bg-deep);
  border-left: 1px solid var(--border-mid);
  z-index: 101;
  display: flex;
  flex-direction: column;
  transition: right 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}
#drawer.open { right: 0; }
#drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-dim);
  flex-shrink: 0;
  background: var(--bg-surface);
}
#drawer-title { font-size: 12px; font-weight: 700; color: var(--text-bright); letter-spacing: 0.04em; }
#drawer-source { font-size: 10px; color: var(--text-muted); margin-top: 3px; letter-spacing: 0.03em; }
#drawer-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 3px;
  transition: color 0.15s;
}
#drawer-close:hover { color: var(--text-bright); }
#drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-mid) transparent;
}
#drawer-body::-webkit-scrollbar { width: 3px; }
#drawer-body::-webkit-scrollbar-track { background: transparent; }
#drawer-body::-webkit-scrollbar-thumb { background: var(--border-mid); border-radius: 2px; }
#drawer-body pre {
  margin: 0;
  font-size: 11.5px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
  background: none;
  border: none;
  padding: 0;
  color: var(--text-body);
}
#drawer-body pre::before { display: none; }
#drawer-lang {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.lang-btn {
  font-size: 10px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 2px;
  border: 1px solid var(--border-mid);
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
  letter-spacing: 0.05em;
  font-family: 'JetBrains Mono', monospace;
}
.lang-btn.active { background: var(--cyan-glow); color: var(--cyan); border-color: var(--cyan-dim); }
.lang-btn:hover:not(.active) { color: var(--text-primary); background: var(--bg-raised); }
#drawer-copy {
  flex-shrink: 0;
  padding: 10px 20px;
  border-top: 1px solid var(--border-dim);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-surface);
}
#drawer-copy button#copy-btn {
  font-size: 11px;
  color: var(--text-dim);
  background: var(--bg-raised);
  border: 1px solid var(--border-mid);
  border-radius: 3px;
  padding: 5px 14px;
  cursor: pointer;
  transition: all 0.15s;
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 0.03em;
}
#drawer-copy button#copy-btn:hover { color: var(--cyan); border-color: var(--cyan-dim); background: var(--cyan-glow); }

/* ── Flow Diagram ── */
.flow {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0;
  margin: 20px 0;
}
.flow-step {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  width: 100%;
}
.flow-step-left {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
  width: 28px;
}
.flow-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 8px var(--cyan-glow);
  flex-shrink: 0;
  margin-top: 16px;
}
.flow-line {
  width: 1px;
  flex: 1;
  min-height: 16px;
  background: var(--border-mid);
  margin: 2px 0;
}
.flow-card {
  flex: 1;
  background: var(--bg-surface);
  border: 1px solid var(--border-dim);
  border-left: 2px solid var(--border-mid);
  border-radius: 0 4px 4px 0;
  padding: 10px 14px;
  margin-bottom: 4px;
  transition: border-left-color 0.2s;
}
.flow-card:hover { border-left-color: var(--cyan); }
.flow-card-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 5px;
  letter-spacing: 0.02em;
}
.flow-card-items {
  list-style: none;
  padding: 0;
  margin: 0;
}
.flow-card-items li {
  font-size: 11.5px;
  color: var(--text-dim);
  line-height: 1.7;
  margin: 0;
}
.flow-card-items li code { font-size: 11px; }
.flow-card-items li .tag {
  display: inline-block;
  font-size: 9px;
  padding: 1px 5px;
  border-radius: 2px;
  margin-left: 6px;
  vertical-align: middle;
  letter-spacing: 0.05em;
  font-weight: 700;
}
.tag-blue { background: rgba(0,217,255,0.1); color: var(--cyan); border: 1px solid rgba(0,217,255,0.2); }
.tag-green { background: rgba(57,211,83,0.1); color: var(--green); border: 1px solid rgba(57,211,83,0.2); }
.tag-yellow { background: rgba(255,179,71,0.1); color: var(--amber); border: 1px solid rgba(255,179,71,0.2); }
.tag-red { background: rgba(255,92,92,0.1); color: var(--red); border: 1px solid rgba(255,92,92,0.2); }

/* ── Diagram Box ── */
.diagram {
  background: var(--bg-deep);
  border: 1px solid var(--border-dim);
  border-radius: 4px;
  padding: 20px 24px;
  margin: 20px 0;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.9;
  overflow-x: auto;
}
.diagram .highlight { color: var(--cyan); }
.diagram .arrow { color: var(--green); }

/* ── Loading state ── */
.page-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  color: var(--text-muted);
  font-size: 12px;
  letter-spacing: 0.05em;
}
.page-loading::before {
  content: '> ';
  color: var(--cyan);
  animation: blink 1s step-end infinite;
}
@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* ── Architecture Diagram ── */
.arch-diagram {
  margin: 20px 0 28px;
  background: var(--bg-void);
  border: 1px solid var(--border-dim);
  border-radius: 6px;
  padding: 20px;
}
.arch-svg {
  width: 100%;
  max-width: 680px;
  display: block;
  margin: 0 auto;
}

/* ── Stats Grid ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 28px 0 40px;
}
.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-dim);
  border-radius: 4px;
  padding: 18px 14px 14px;
  text-align: center;
  transition: border-color 0.2s, box-shadow 0.2s;
  cursor: default;
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--cyan-dim), transparent);
  opacity: 0;
  transition: opacity 0.2s;
}
.stat-card:hover {
  border-color: var(--border-bright);
  box-shadow: 0 0 20px var(--cyan-glow-lg);
}
.stat-card:hover::before { opacity: 1; }
.stat-icon {
  font-size: 18px;
  margin-bottom: 8px;
  line-height: 1;
  filter: grayscale(0.3);
}
.stat-number {
  font-size: 26px;
  font-weight: 800;
  color: var(--cyan);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
}
.stat-unit {
  font-size: 14px;
  font-weight: 600;
  color: var(--cyan-dim);
  margin-left: 1px;
}
.stat-label {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 6px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
@media (max-width: 600px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ── Agent Loop Diagram ── */
.agent-loop-diagram {
  margin: 24px 0;
  background: var(--bg-void);
  border: 1px solid var(--border-dim);
  border-radius: 4px;
  padding: 20px;
}
.loop-diagram-controls {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
}
.loop-play-btn {
  padding: 5px 16px;
  background: transparent;
  color: var(--cyan);
  border: 1px solid var(--cyan-dim);
  border-radius: 2px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s;
  flex-shrink: 0;
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.loop-play-btn:hover {
  background: var(--cyan-glow);
  box-shadow: 0 0 12px var(--cyan-glow);
}
.loop-step-label {
  font-size: 11px;
  color: var(--text-muted);
  font-style: italic;
}
.loop-svg {
  width: 100%;
  max-width: 760px;
  display: block;
  margin: 0 auto;
}
.loop-node { cursor: default; }
.loop-step rect, .loop-step polygon {
  transition: stroke 0.3s, filter 0.3s;
}
.loop-arrow { transition: stroke 0.3s, opacity 0.3s; }

/* Detail cards */
.loop-detail-cards {
  margin-top: 8px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
}
.loop-detail-card {
  display: none;
  background: var(--bg-surface);
  border: 1px solid var(--border-dim);
  border-left: 2px solid var(--cyan-dim);
  border-radius: 0 4px 4px 0;
  padding: 12px 16px;
  margin-top: 8px;
  animation: fadeSlideIn 0.25s ease;
}
.loop-detail-card.active { display: block; }
.loop-detail-card .loop-detail-title {
  font-weight: 700;
  font-size: 12px;
  color: var(--cyan);
  margin-bottom: 8px;
  letter-spacing: 0.03em;
}
.loop-detail-card ul {
  margin: 0;
  padding-left: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.loop-detail-card li {
  font-size: 12px;
  color: var(--text-body);
  line-height: 1.6;
}
@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Sequence Diagram ── */
.seq-diagram {
  margin: 24px 0;
  background: var(--bg-void);
  border: 1px solid var(--border-dim);
  border-radius: 4px;
  padding: 20px;
}
.seq-controls {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
}
.seq-play-btn {
  padding: 5px 16px;
  background: transparent;
  color: var(--cyan);
  border: 1px solid var(--cyan-dim);
  border-radius: 2px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s;
  flex-shrink: 0;
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.seq-play-btn:hover {
  background: var(--cyan-glow);
  box-shadow: 0 0 12px var(--cyan-glow);
}
.seq-step-label { font-size: 11px; color: var(--text-muted); font-style: italic; }

.seq-stage { overflow-x: auto; }
.seq-lifelines {
  display: flex;
  justify-content: space-around;
  margin-bottom: 0;
  position: relative;
}
.seq-actor {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
}
.seq-actor-box {
  background: var(--bg-surface);
  border: 1px solid var(--cyan-dim);
  border-radius: 3px;
  padding: 5px 10px;
  font-size: 11px;
  font-weight: 700;
  color: var(--cyan);
  white-space: nowrap;
  z-index: 1;
  letter-spacing: 0.04em;
}
.seq-lifeline-line {
  width: 1px;
  background: var(--border-mid);
  flex: 1;
  min-height: 320px;
}

.seq-messages {
  position: relative;
  margin-top: -320px;
  padding: 40px 0 20px;
  display: flex;
  flex-direction: column;
  gap: 0;
  pointer-events: none;
}
.seq-msg {
  display: flex;
  align-items: center;
  height: 44px;
  opacity: 0;
  transform: translateX(-8px);
  transition: opacity 0.3s, transform 0.3s;
  position: relative;
}
.seq-msg.active { opacity: 1; transform: translateX(0); }
.seq-msg-return { transform: translateX(8px); }
.seq-msg-return.active { transform: translateX(0); }

.seq-msg[data-from="0"][data-to="1"] { padding-left: 12.5%; width: 25%; }
.seq-msg[data-from="1"][data-to="2"] { padding-left: 37.5%; width: 25%; }
.seq-msg[data-from="2"][data-to="1"] { padding-left: 37.5%; width: 25%; flex-direction: row-reverse; }
.seq-msg[data-from="1"][data-to="3"] { padding-left: 37.5%; width: 50%; }
.seq-msg[data-from="3"][data-to="1"] { padding-left: 37.5%; width: 50%; flex-direction: row-reverse; }
.seq-msg[data-from="1"][data-to="0"] { padding-left: 12.5%; width: 25%; flex-direction: row-reverse; }

.seq-msg-arrow {
  position: relative;
  height: 1px;
  background: var(--cyan-dim);
  flex: 1;
}
.seq-msg-return .seq-msg-arrow { background: var(--green-dim); }
.seq-msg-arrow::after {
  content: '';
  position: absolute;
  right: -1px;
  top: -4px;
  border: 5px solid transparent;
  border-left: 8px solid var(--cyan-dim);
}
.seq-msg-return .seq-msg-arrow::after {
  right: auto;
  left: -1px;
  border-left: none;
  border-right: 8px solid var(--green-dim);
}
.seq-msg-label {
  font-size: 10px;
  color: var(--text-body);
  white-space: nowrap;
  padding: 0 6px;
  background: var(--bg-void);
  line-height: 1.4;
  text-align: center;
}
.seq-msg-label small { color: var(--text-muted); display: block; }

.seq-detail {
  margin-top: 14px;
  padding: 10px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border-dim);
  border-left: 2px solid var(--cyan-dim);
  border-radius: 0 4px 4px 0;
  font-size: 12px;
  color: var(--text-body);
  display: none;
  animation: fadeSlideIn 0.2s ease;
  min-height: 36px;
}
.seq-detail.active { display: block; }

/* ── Responsive ── */

/* Mobile menu button (hidden on desktop) */
#mobile-menu-btn {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 200;
  background: var(--bg-raised);
  border: 1px solid var(--border-mid);
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 8px 10px;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, background 0.15s;
}
#mobile-menu-btn:hover { color: var(--cyan); }
#mobile-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 150;
  backdrop-filter: blur(2px);
}
#mobile-overlay.open { display: block; }

@media (max-width: 768px) {
  /* Show mobile menu button */
  #mobile-menu-btn { display: flex; }

  /* Sidebar becomes a fixed drawer */
  #sidebar-wrapper {
    position: fixed;
    top: 0;
    left: -280px;
    height: 100vh;
    width: 260px !important;
    z-index: 160;
    transition: left 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  }
  #sidebar-wrapper.mobile-open { left: 0; }
  #sidebar-wrapper.collapsed { width: 260px !important; }
  #sidebar-wrapper.collapsed #sidebar { opacity: 1; pointer-events: auto; display: block; }
  #sidebar-toggle { display: none; }
  #sidebar-resize-handle { display: none; }
  #sidebar { width: 260px; }

  /* Hide TOC on mobile */
  #toc-wrapper { display: none; }

  /* Content full width */
  #content { padding: 56px 20px 32px; }

  /* Theme toggle position */
  #theme-toggle { top: 12px; right: 12px; }

  /* Tables: horizontal scroll */
  table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* Footer stack */
  .footer-inner { flex-direction: column; gap: 16px; }
  .footer-right { align-items: flex-start; text-align: left; }

  /* Pre: reduce padding */
  pre { padding: 12px 14px; }

  /* Stats grid: 2 columns */
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 480px) {
  #content { padding: 52px 14px 28px; }
  h1 { font-size: 20px; }
  h2 { font-size: 13px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
}

/* ── Footer ── */
#site-footer {
  margin-top: 64px;
  border-top: 1px solid var(--border-dim);
  padding: 24px 0 40px;
}
.footer-inner {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}
.footer-left {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.footer-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.04em;
}
.footer-meta {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.6;
  max-width: 360px;
}
.footer-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 5px;
  font-size: 11px;
  color: var(--text-muted);
  text-align: right;
}
.footer-right a {
  color: var(--cyan-dim);
}
.footer-right a:hover {
  color: var(--cyan);
  text-decoration: none;
}
