/* ─── NeuralCleave Docs — complete design system ─── */

/* ── Tokens ────────────────────────────────────────── */
:root {
  --bg:            #0B0B10;
  --bg-sidebar:    #0F0F15;
  --bg-card:       #141419;
  --bg-code:       #09090D;
  --bg-callout:    #13131A;
  --border:        #1E1E2A;
  --border-subtle: #16161F;

  --text:          #E2E2EE;
  --text-muted:    #80809A;
  --text-faint:    #4A4A62;
  --text-code:     #C9C9E8;

  --accent:        #7C6FFF;
  --accent-hover:  #9588FF;
  --accent-bg:     rgba(124, 111, 255, 0.10);
  --accent-border: rgba(124, 111, 255, 0.28);

  --green:   #22C55E;
  --yellow:  #F59E0B;
  --red:     #EF4444;
  --blue:    #3B82F6;
  --orange:  #F97316;

  --nav-h:       56px;
  --sidebar-w:   264px;
  --content-max: 780px;
  --radius:      6px;
  --radius-lg:   10px;

  --mono: 'JetBrains Mono', 'Cascadia Code', 'Fira Code', Consolas, 'Courier New', monospace;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, Helvetica, Arial, sans-serif;
}

[data-theme="light"] {
  --bg:            #FFFFFF;
  --bg-sidebar:    #F6F6FA;
  --bg-card:       #F0F0F6;
  --bg-code:       #0F0F14;
  --bg-callout:    #F3F3F9;
  --border:        #E0E0EC;
  --border-subtle: #EAEAF4;

  --text:          #18182C;
  --text-muted:    #5C5C7A;
  --text-faint:    #9898B2;
  --text-code:     #D0D0F0;

  --accent:        #6254EE;
  --accent-hover:  #7264FF;
  --accent-bg:     rgba(98, 84, 238, 0.08);
  --accent-border: rgba(98, 84, 238, 0.22);
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg:            #FFFFFF;
    --bg-sidebar:    #F6F6FA;
    --bg-card:       #F0F0F6;
    --bg-code:       #0F0F14;
    --bg-callout:    #F3F3F9;
    --border:        #E0E0EC;
    --border-subtle: #EAEAF4;
    --text:          #18182C;
    --text-muted:    #5C5C7A;
    --text-faint:    #9898B2;
    --text-code:     #D0D0F0;
    --accent:        #6254EE;
    --accent-hover:  #7264FF;
    --accent-bg:     rgba(98, 84, 238, 0.08);
    --accent-border: rgba(98, 84, 238, 0.22);
  }
}

/* ── Reset ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; font-size: 16px; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }
img { max-width: 100%; }
button { cursor: pointer; font: inherit; border: none; background: none; }

/* ── Top nav ───────────────────────────────────────── */
.top-nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--nav-h);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 20px;
  z-index: 100;
}
.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  flex-shrink: 0;
}
.nav-brand:hover { text-decoration: none; color: var(--accent); }
.nav-brand img { width: 26px; height: 26px; border-radius: 5px; }
.nav-brand .sep { color: var(--text-faint); font-weight: 300; margin: 0 4px; }
.nav-brand .section { color: var(--text-muted); font-weight: 400; }
.nav-search-wrap { flex: 1; max-width: 420px; }
.nav-search {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 7px 12px 7px 34px;
  font-size: 13.5px;
  color: var(--text);
  outline: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='none' viewBox='0 0 24 24' stroke='%23666688' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 11px center;
  transition: border-color 0.15s;
  cursor: pointer;
}
.nav-search::placeholder { color: var(--text-faint); }
.nav-search:focus { border-color: var(--accent); }
.nav-links { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.nav-links a {
  font-size: 13.5px;
  color: var(--text-muted);
  padding: 5px 10px;
  border-radius: var(--radius);
  transition: color 0.15s, background 0.15s;
}
.nav-links a:hover { color: var(--text); background: var(--bg-card); text-decoration: none; }
.theme-toggle {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius);
  color: var(--text-muted);
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}
.theme-toggle:hover { background: var(--bg-card); color: var(--text); }
.mobile-menu-btn {
  display: none;
  width: 36px; height: 36px;
  align-items: center; justify-content: center;
  border-radius: var(--radius);
  color: var(--text-muted);
  margin-left: auto;
}
.mobile-menu-btn:hover { background: var(--bg-card); color: var(--text); }

/* ── Layout ────────────────────────────────────────── */
.docs-root {
  display: flex;
  margin-top: var(--nav-h);
  min-height: calc(100vh - var(--nav-h));
}

/* ── Sidebar ───────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: var(--nav-h);
  left: 0;
  width: var(--sidebar-w);
  height: calc(100vh - var(--nav-h));
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 0 40px;
  z-index: 50;
  transition: transform 0.22s ease;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
.sidebar-section { margin-bottom: 2px; }
.sidebar-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 14px 18px 4px;
}
.sidebar-link {
  display: block;
  font-size: 13.5px;
  color: var(--text-muted);
  padding: 5px 18px;
  border-left: 2px solid transparent;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
  text-decoration: none;
}
.sidebar-link:hover { color: var(--text); background: var(--accent-bg); text-decoration: none; }
.sidebar-link.active { color: var(--accent); border-left-color: var(--accent); background: var(--accent-bg); }
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 49;
}
.sidebar-overlay.active { display: block; }

/* ── Main content ──────────────────────────────────── */
.main-wrap {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
  padding: 48px 56px 80px;
  display: flex;
  gap: 48px;
}
.doc-content {
  flex: 1;
  min-width: 0;
  max-width: var(--content-max);
}

/* ── Page TOC ──────────────────────────────────────── */
.page-toc {
  width: 196px;
  flex-shrink: 0;
  position: sticky;
  top: calc(var(--nav-h) + 24px);
  height: max-content;
  max-height: calc(100vh - var(--nav-h) - 48px);
  overflow-y: auto;
}
.page-toc-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 10px;
}
.page-toc a {
  display: block;
  font-size: 12.5px;
  color: var(--text-muted);
  padding: 3px 0 3px 10px;
  border-left: 2px solid var(--border);
  transition: color 0.15s, border-color 0.15s;
  text-decoration: none;
}
.page-toc a:hover { color: var(--text); text-decoration: none; }
.page-toc a.active { color: var(--accent); border-left-color: var(--accent); }
.page-toc a.toc-h3 { padding-left: 20px; font-size: 12px; }

/* ── Typography ────────────────────────────────────── */
.doc-content h1 {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--text);
  margin-bottom: 12px;
  letter-spacing: -0.02em;
}
.page-meta {
  font-size: 13px;
  color: var(--text-faint);
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.page-lead {
  font-size: 16.5px;
  color: var(--text-muted);
  line-height: 1.65;
  margin-bottom: 36px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--border);
}
.doc-content h2 {
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
  margin: 40px 0 14px;
  letter-spacing: -0.01em;
  scroll-margin-top: calc(var(--nav-h) + 16px);
}
.doc-content h3 {
  font-size: 15.5px;
  font-weight: 600;
  color: var(--text);
  margin: 28px 0 10px;
  scroll-margin-top: calc(var(--nav-h) + 16px);
}
.doc-content h4 {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-faint);
  margin: 20px 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.doc-content p { margin-bottom: 16px; font-size: 15px; line-height: 1.7; }
.doc-content ul, .doc-content ol { padding-left: 22px; margin-bottom: 16px; }
.doc-content li { font-size: 15px; line-height: 1.7; margin-bottom: 4px; }
.doc-content strong { font-weight: 600; }
.doc-content hr { border: none; border-top: 1px solid var(--border); margin: 36px 0; }
.doc-content code {
  font-family: var(--mono);
  font-size: 13px;
  background: var(--bg-card);
  color: var(--accent-hover);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
}

/* ── Code blocks ───────────────────────────────────── */
.doc-content pre {
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow-x: auto;
  margin: 20px 0;
  position: relative;
}
.doc-content pre code {
  display: block;
  padding: 16px 20px;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.65;
  color: #C8C8E8;
  background: none;
  border: none;
  tab-size: 2;
}
.code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 14px;
  border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,0.018);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.code-lang { font-family: var(--mono); font-size: 11px; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.06em; }
.copy-btn {
  font-size: 11.5px; color: var(--text-faint);
  padding: 3px 8px; border-radius: 4px;
  border: 1px solid var(--border); background: var(--bg-card);
  transition: color 0.15s, border-color 0.15s;
}
.copy-btn:hover { color: var(--text); border-color: var(--text-faint); }
.copy-btn.copied { color: var(--green); border-color: var(--green); }

/* Syntax tokens */
.tok-k  { color: #B48EFF; }
.tok-s  { color: #98D9A0; }
.tok-c  { color: #4E5070; }
.tok-n  { color: #88B4FF; }
.tok-nb { color: #FFB76B; }
.tok-o  { color: #94A3B8; }
.tok-m  { color: #F9A870; }

/* ── Tables ────────────────────────────────────────── */
.table-wrap { overflow-x: auto; margin: 20px 0; border-radius: var(--radius-lg); border: 1px solid var(--border); }
.doc-content table { width: 100%; border-collapse: collapse; font-size: 14px; }
.doc-content table th {
  text-align: left; padding: 10px 16px;
  font-size: 11.5px; font-weight: 600; color: var(--text-faint);
  text-transform: uppercase; letter-spacing: 0.06em;
  background: var(--bg-card); border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.doc-content table td {
  padding: 10px 16px; border-bottom: 1px solid var(--border-subtle);
  vertical-align: top;
}
.doc-content table tr:last-child td { border-bottom: none; }
.doc-content table tr:hover td { background: rgba(255,255,255,0.012); }
.doc-content table td code { font-size: 12px; }

/* ── Callout boxes ─────────────────────────────────── */
.callout {
  display: flex; gap: 12px;
  border-radius: var(--radius-lg); padding: 14px 16px; margin: 20px 0;
  border: 1px solid; font-size: 14.5px; line-height: 1.6;
}
.callout-icon { font-size: 16px; flex-shrink: 0; margin-top: 1px; }
.callout p { margin: 0; font-size: inherit; }
.callout code { font-size: 12px; }
.callout.note   { background: rgba(124,111,255,0.07); border-color: rgba(124,111,255,0.25); color: #B8B0FF; }
.callout.tip    { background: rgba(34,197,94,0.07);   border-color: rgba(34,197,94,0.25);   color: #86EFAC; }
.callout.warn   { background: rgba(245,158,11,0.07);  border-color: rgba(245,158,11,0.25);  color: #FCD34D; }
.callout.danger { background: rgba(239,68,68,0.07);   border-color: rgba(239,68,68,0.25);   color: #FCA5A5; }
[data-theme="light"] .callout.note   { color: #4A3FCC; }
[data-theme="light"] .callout.tip    { color: #166534; }
[data-theme="light"] .callout.warn   { color: #92400E; }
[data-theme="light"] .callout.danger { color: #991B1B; }

/* ── Method badges ─────────────────────────────────── */
.method {
  display: inline-flex; align-items: center;
  font-family: var(--mono); font-size: 11px; font-weight: 700;
  padding: 2px 7px; border-radius: 4px; letter-spacing: 0.04em;
  vertical-align: middle; margin-right: 6px;
}
.method-get    { background: rgba(34,197,94,0.15);  color: #22C55E; }
.method-post   { background: rgba(59,130,246,0.15); color: #60A5FA; }
.method-delete { background: rgba(239,68,68,0.15);  color: #F87171; }
.method-patch  { background: rgba(245,158,11,0.15); color: #FBBF24; }
.method-put    { background: rgba(249,115,22,0.15); color: #FB923C; }
.method-ws     { background: rgba(168,85,247,0.15); color: #C084FC; }

/* ── Endpoint blocks ───────────────────────────────── */
.endpoint {
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  margin: 24px 0; overflow: hidden;
}
.endpoint-header {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 16px; background: var(--bg-card);
  border-bottom: 1px solid var(--border); flex-wrap: wrap;
}
.endpoint-path { font-family: var(--mono); font-size: 14px; flex: 1; }
.endpoint-desc { padding: 12px 16px; font-size: 13.5px; color: var(--text-muted); }
.endpoint pre  { margin: 0; border: none; border-radius: 0; border-top: 1px solid var(--border); }
.endpoint pre code { padding: 13px 16px; }

/* ── Channel cards ─────────────────────────────────── */
.channel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px; margin: 20px 0;
}
.channel-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 12px 14px; font-size: 13.5px;
}
.channel-card-name { font-weight: 600; margin-bottom: 3px; }
.channel-card-tag  { font-size: 11.5px; color: var(--text-faint); }

/* ── CLI command blocks ────────────────────────────── */
.cli-block { border: 1px solid var(--border); border-radius: var(--radius-lg); margin: 16px 0; overflow: hidden; }
.cli-cmd {
  background: var(--bg-code); padding: 11px 16px;
  font-family: var(--mono); font-size: 13.5px; color: #D0D0F0;
  display: flex; align-items: center; gap: 8px;
  border-bottom: 1px solid var(--border);
}
.cli-prompt { color: var(--accent); user-select: none; }
.cli-desc   { padding: 9px 16px; font-size: 13.5px; color: var(--text-muted); }
.cli-flags  { padding: 0 16px 10px; }
.flag-row   { display: flex; gap: 12px; padding: 4px 0; font-size: 13px; border-top: 1px solid var(--border-subtle); }
.flag-row:first-child { border-top: none; }
.flag      { font-family: var(--mono); color: var(--text-code); font-size: 12.5px; min-width: 180px; flex-shrink: 0; }
.flag-desc { color: var(--text-muted); }

/* ── Config key blocks ─────────────────────────────── */
.config-key { border: 1px solid var(--border); border-radius: var(--radius-lg); margin: 14px 0; overflow: hidden; }
.config-key-header {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 14px; background: var(--bg-card);
  border-bottom: 1px solid var(--border); flex-wrap: wrap;
}
.config-key-path    { font-family: var(--mono); font-size: 13.5px; }
.config-key-type    { font-family: var(--mono); font-size: 11px; color: var(--text-faint); padding: 2px 7px; background: var(--bg-callout); border: 1px solid var(--border); border-radius: 4px; }
.config-key-default { font-size: 12px; color: var(--text-faint); margin-left: auto; }
.config-key-desc    { padding: 9px 14px; font-size: 13.5px; color: var(--text-muted); line-height: 1.6; }

/* ── Home grid ─────────────────────────────────────── */
.home-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px; margin: 28px 0;
}
.home-card {
  display: flex; flex-direction: column; gap: 5px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 18px 20px;
  transition: border-color 0.15s, background 0.15s; text-decoration: none;
}
.home-card:hover { border-color: var(--accent-border); background: var(--accent-bg); text-decoration: none; }
.home-card-icon  { font-size: 20px; margin-bottom: 4px; }
.home-card-title { font-size: 14.5px; font-weight: 600; color: var(--text); }
.home-card-desc  { font-size: 13px; color: var(--text-muted); line-height: 1.5; }
.home-card-arrow { font-size: 13px; color: var(--accent); margin-top: auto; padding-top: 8px; }

/* ── Stats strip ───────────────────────────────────── */
.stats-strip {
  display: flex; flex-wrap: wrap; gap: 0;
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  overflow: hidden; margin: 24px 0;
}
.stat-item { flex: 1; min-width: 110px; padding: 18px 20px; border-right: 1px solid var(--border); }
.stat-item:last-child { border-right: none; }
.stat-val { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-lbl { font-size: 12px; color: var(--text-muted); margin-top: 3px; }

/* ── Search modal ──────────────────────────────────── */
.search-modal {
  display: none; position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,0.65);
  align-items: flex-start; justify-content: center; padding-top: 80px;
}
.search-modal.open { display: flex; }
.search-box {
  width: 100%; max-width: 580px;
  background: var(--bg-sidebar); border: 1px solid var(--border);
  border-radius: var(--radius-lg); overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.search-input {
  width: 100%; background: transparent; border: none;
  padding: 15px 20px; font-size: 16px; color: var(--text); outline: none;
  border-bottom: 1px solid var(--border);
}
.search-input::placeholder { color: var(--text-faint); }
.search-results { max-height: 360px; overflow-y: auto; }
.search-result {
  display: block; padding: 12px 20px;
  border-bottom: 1px solid var(--border-subtle);
  text-decoration: none; transition: background 0.1s;
}
.search-result:hover { background: var(--accent-bg); text-decoration: none; }
.search-result-title   { font-size: 14px; font-weight: 600; color: var(--text); }
.search-result-section { font-size: 12px; color: var(--text-faint); margin-top: 2px; }
.search-empty { padding: 24px 20px; font-size: 14px; color: var(--text-faint); text-align: center; }
.search-hint  {
  padding: 9px 20px; font-size: 12px; color: var(--text-faint);
  display: flex; justify-content: space-between; border-top: 1px solid var(--border);
}
.search-hint kbd {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 4px; padding: 1px 5px; font-size: 11px; font-family: var(--mono);
}

/* ── Breadcrumb ────────────────────────────────────── */
.breadcrumb {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--text-faint); margin-bottom: 16px;
}
.breadcrumb a { color: var(--text-faint); }
.breadcrumb a:hover { color: var(--text-muted); }
.breadcrumb .sep { color: var(--border); }
.breadcrumb .current { color: var(--text-muted); }

/* ── Version badge ─────────────────────────────────── */
.version-badge {
  display: inline-flex; align-items: center;
  font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 20px;
  background: var(--accent-bg); border: 1px solid var(--accent-border);
  color: var(--accent); font-family: var(--mono);
}

/* ── Doc footer ────────────────────────────────────── */
.doc-footer {
  margin-top: 56px; padding-top: 24px; border-top: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 12px;
}
.doc-footer-nav { display: flex; gap: 8px; }
.doc-footer-nav a {
  display: flex; flex-direction: column; gap: 2px;
  padding: 10px 14px; background: var(--bg-card);
  border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 13px; color: var(--text);
  transition: border-color 0.15s; text-decoration: none;
}
.doc-footer-nav a:hover { border-color: var(--accent-border); text-decoration: none; }
.nav-dir { font-size: 11px; color: var(--text-faint); }

/* ── Responsive ────────────────────────────────────── */
@media (max-width: 1100px) { .page-toc { display: none; } .main-wrap { padding: 40px 36px 60px; } }
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: 4px 0 20px rgba(0,0,0,0.4); }
  .main-wrap { margin-left: 0; padding: 28px 20px 60px; }
  .mobile-menu-btn { display: flex; }
  .nav-search-wrap { display: none; }
  .nav-links { display: none; }
  .doc-content h1 { font-size: 22px; }
  .stats-strip { flex-direction: column; }
  .stat-item { border-right: none; border-bottom: 1px solid var(--border); }
  .stat-item:last-child { border-bottom: none; }
}
@media (max-width: 480px) { .home-grid { grid-template-columns: 1fr; } .channel-grid { grid-template-columns: 1fr 1fr; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }
