*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --accent: #3b82f6;
  --accent-light: #60a5fa;
  --accent-dark: #2563eb;
  --bg-deep: #111113;
  --bg-main: #18181b;
  --bg-sidebar: #141416;
  --bg-card: #1e1e22;
  --bg-card-hover: #26262b;
  --bg-code: #1a1a1f;
  --border: #2a2a30;
  --border-light: #33333a;
  --text-primary: #e4e4e7;
  --text-secondary: #a1a1aa;
  --text-muted: #6b6b76;
  --green: #22c55e;
  --yellow: #eab308;
  --purple: #a855f7;
  --red: #ef4444;
  --orange: #f97316;
  --cyan: #06b6d4;
  --pink: #ec4899;

  --nav-h: 56px;
  --sidebar-w: 260px;
  --toc-w: 210px;
  --content-max: 760px;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--nav-h) + 24px);
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-deep);
  color: var(--text-primary);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ===== Top Nav ===== */
.docs-nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: var(--nav-h);
  background: rgba(17, 17, 19, 0.88);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
}
.docs-nav-inner {
  max-width: 1440px;
  margin: 0 auto;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
}
.nav-logo {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none; color: #fff;
  font-weight: 700; font-size: 17px;
}
.nav-logo img { height: 28px; width: auto; }
.nav-badge {
  font-size: 11px; font-weight: 600;
  background: var(--accent);
  color: #fff;
  padding: 2px 8px;
  border-radius: 6px;
  letter-spacing: 0.5px;
}
.nav-right { display: flex; align-items: center; gap: 6px; }
.nav-link {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13px; font-weight: 500;
  padding: 6px 14px;
  border-radius: 7px;
  transition: color 0.15s, background 0.15s;
}
.nav-link:hover { color: var(--text-primary); background: rgba(255,255,255,0.05); }
.nav-cta {
  background: var(--accent) !important;
  color: #fff !important;
  font-weight: 600 !important;
  box-shadow: 0 0 12px rgba(59,130,246,0.2);
}
.nav-cta:hover {
  background: var(--accent-dark) !important;
  box-shadow: 0 0 18px rgba(59,130,246,0.3);
}

/* ===== Layout ===== */
.docs-layout {
  box-sizing: border-box;
  width: 100%;
  display: flex;
  min-height: 100vh;
  padding-top: var(--nav-h);
  padding-left: var(--sidebar-w);
  padding-right: var(--toc-w);
}

/* ===== Sidebar ===== */
.docs-sidebar {
  position: fixed;
  top: var(--nav-h);
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  z-index: 50;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.sidebar-inner {
  padding: 16px 12px 32px;
}
.sidebar-search {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  margin-bottom: 20px;
}
.sidebar-search svg { color: var(--text-muted); flex-shrink: 0; }
.sidebar-search input {
  background: none; border: none; outline: none;
  color: var(--text-primary);
  font-size: 13px; width: 100%;
  font-family: inherit;
}
.sidebar-search input::placeholder { color: var(--text-muted); }

.sidebar-group { margin-bottom: 20px; }
.sidebar-heading {
  font-size: 11px; font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  padding: 6px 12px 4px;
  margin-bottom: 2px;
}
.sidebar-link {
  display: block;
  font-size: 13.5px; font-weight: 450;
  color: var(--text-secondary);
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 6px;
  transition: color 0.12s, background 0.12s;
  border-left: 2px solid transparent;
  margin-left: 2px;
}
.sidebar-link:hover {
  color: var(--text-primary);
  background: rgba(255,255,255,0.04);
}
.sidebar-link.active {
  color: var(--accent-light);
  background: rgba(59,130,246,0.08);
  border-left-color: var(--accent);
  font-weight: 550;
}
.sidebar-link.hidden { display: none; }
.sidebar-group.hidden { display: none; }

/* Mobile sidebar toggle */
.sidebar-toggle {
  display: none;
  position: fixed;
  bottom: 20px; left: 20px;
  z-index: 200;
  width: 44px; height: 44px;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  align-items: center; justify-content: center;
}

/* ===== Content ===== */
.docs-content {
  flex: 1;
  min-width: 0;
  width: 100%;
  max-width: calc(var(--content-max) + 96px);
  margin-left: auto;
  margin-right: auto;
  padding: 40px 48px 80px;
}
.doc-section {
  display: none;
  animation: fadeIn 0.2s ease;
}
.doc-section.active { display: block; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.doc-header { margin-bottom: 36px; }
.doc-category {
  display: inline-block;
  font-size: 11px; font-weight: 600;
  letter-spacing: 1.8px;
  text-transform: uppercase;
  color: var(--accent-light);
  margin-bottom: 8px;
}
.doc-header h1 {
  font-size: 32px; font-weight: 750;
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin-bottom: 12px;
}
.doc-lead {
  font-size: 17px;
  color: var(--text-secondary);
  line-height: 1.7;
  max-width: 640px;
}

/* Headings */
.doc-section h2 {
  font-size: 20px; font-weight: 650;
  margin: 40px 0 14px;
  padding-top: 8px;
  letter-spacing: -0.01em;
  scroll-margin-top: calc(var(--nav-h) + 20px);
}
.doc-section h2:first-of-type { margin-top: 0; }
.doc-section h3 {
  font-size: 16px; font-weight: 600;
  margin: 28px 0 10px;
}

/* Text */
.doc-section p {
  margin-bottom: 14px;
  color: var(--text-secondary);
  font-size: 15px; line-height: 1.75;
}
.doc-section ul, .doc-section ol {
  margin: 0 0 16px 20px;
  color: var(--text-secondary);
  font-size: 15px;
}
.doc-section li { margin-bottom: 6px; line-height: 1.65; }
.doc-section li strong { color: var(--text-primary); font-weight: 600; }
.doc-section a { color: var(--accent-light); text-decoration: none; }
.doc-section a:hover { text-decoration: underline; }

/* Code */
.doc-section code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  background: var(--bg-code);
  border: 1px solid var(--border);
  padding: 2px 7px;
  border-radius: 5px;
  color: var(--accent-light);
}
.code-block {
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 20px;
  margin: 12px 0 20px;
  overflow-x: auto;
}
.code-block code {
  background: none; border: none; padding: 0;
  font-size: 13.5px; line-height: 1.6;
  color: var(--text-primary);
  white-space: pre-wrap;
}

/* Tables */
.docs-table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0 24px;
  font-size: 14px;
}
.docs-table th {
  text-align: left;
  font-weight: 600;
  color: var(--text-primary);
  padding: 10px 14px;
  border-bottom: 2px solid var(--border);
  font-size: 13px;
  letter-spacing: 0.3px;
}
.docs-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
  vertical-align: top;
}
.docs-table tr:last-child td { border-bottom: none; }
.docs-table tr:hover td { background: rgba(255,255,255,0.02); }

/* Shortcuts table */
.shortcuts-table td:first-child { white-space: nowrap; }
kbd {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-bottom-width: 2px;
  padding: 3px 8px;
  border-radius: 5px;
  color: var(--text-primary);
}

/* Info cards */
.info-card {
  display: flex; gap: 14px;
  background: rgba(59,130,246,0.06);
  border: 1px solid rgba(59,130,246,0.15);
  border-radius: 10px;
  padding: 16px 20px;
  margin: 16px 0 20px;
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.65;
}
.info-card-icon {
  flex-shrink: 0;
  margin-top: 2px;
  width: 20px; height: 20px;
  display: flex; align-items: center; justify-content: center;
  color: var(--accent-light);
}
.info-card strong { color: var(--text-primary); }
.info-card-warn {
  background: rgba(234,179,8,0.06);
  border-color: rgba(234,179,8,0.15);
}

/* Feature grid */
.feature-grid-docs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  margin: 16px 0 24px;
}
.feature-card-docs {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px;
}
.feature-card-docs h3 {
  font-size: 14px; font-weight: 600;
  margin: 0 0 6px; color: var(--text-primary);
}
.feature-card-docs p {
  font-size: 13px; margin: 0;
  color: var(--text-muted);
  line-height: 1.55;
}

/* Layout diagram */
.layout-diagram {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  margin: 16px 0 24px;
  font-size: 12px;
  font-family: 'JetBrains Mono', monospace;
}
.layout-row { border-bottom: 1px solid var(--border); }
.layout-row:last-child { border-bottom: none; }
.layout-toolbar {
  padding: 10px 16px;
  background: rgba(59,130,246,0.06);
  color: var(--accent-light);
  text-align: center;
}
.layout-main {
  display: flex;
  min-height: 80px;
}
.layout-cell {
  padding: 16px;
  display: flex; align-items: center; justify-content: center;
  text-align: center;
}
.layout-timeline { flex: 1; color: var(--text-secondary); }
.layout-chat {
  width: 160px;
  border-left: 1px solid var(--border);
  color: var(--purple);
  background: rgba(168,85,247,0.04);
}
.layout-editor {
  padding: 10px 16px;
  text-align: center;
  color: var(--green);
  background: rgba(34,197,94,0.04);
}
.layout-transport {
  padding: 8px 16px;
  text-align: center;
  color: var(--text-muted);
  background: rgba(255,255,255,0.02);
}

/* Connection diagram */
.connection-diagram {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 20px 0 24px;
  padding: 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
}
.conn-node {
  padding: 8px 18px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-weight: 600;
}
.conn-partita { color: var(--accent-light); background: rgba(59,130,246,0.08); border-color: rgba(59,130,246,0.2); }
.conn-loop { color: var(--cyan); background: rgba(6,182,212,0.08); border-color: rgba(6,182,212,0.2); }
.conn-daw { color: var(--green); background: rgba(34,197,94,0.08); border-color: rgba(34,197,94,0.2); }
.conn-arrow { color: var(--text-muted); font-size: 16px; }

/* Trouble items */
.trouble-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 20px;
  margin: 8px 0 20px;
}
.trouble-item p { margin-bottom: 8px; }
.trouble-item ul { margin-bottom: 4px; }

/* ===== Right TOC ===== */
.docs-toc {
  position: fixed;
  top: var(--nav-h);
  right: 0;
  bottom: 0;
  width: var(--toc-w);
  overflow-y: auto;
  padding: 28px 16px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.toc-title {
  font-size: 11px; font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  margin-bottom: 12px;
  padding-left: 4px;
}
.toc-link {
  display: block;
  font-size: 12.5px;
  color: var(--text-muted);
  text-decoration: none;
  padding: 4px 4px 4px 10px;
  border-left: 2px solid transparent;
  transition: color 0.12s, border-color 0.12s;
  line-height: 1.5;
  margin-bottom: 2px;
}
.toc-link:hover { color: var(--text-secondary); }
.toc-link.active {
  color: var(--accent-light);
  border-left-color: var(--accent);
}

/* ===== Footer ===== */
.docs-footer {
  box-sizing: border-box;
  width: 100%;
  padding-left: var(--sidebar-w);
  padding-right: var(--toc-w);
  border-top: 1px solid var(--border);
  padding-top: 20px;
  padding-bottom: 20px;
}
.docs-footer-inner {
  box-sizing: border-box;
  max-width: calc(var(--content-max) + 96px);
  margin-left: auto;
  margin-right: auto;
  padding: 0 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-muted);
}
.docs-footer-links { display: flex; gap: 16px; }
.docs-footer-links a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.15s;
}
.docs-footer-links a:hover { color: var(--text-secondary); }

/* ===== Responsive ===== */
@media (max-width: 1200px) {
  .docs-toc { display: none; }
  .docs-layout { padding-right: 0; }
  .docs-footer { padding-right: 0; }
}

@media (max-width: 860px) {
  .docs-sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 150;
    width: 280px;
  }
  .docs-sidebar.open { transform: translateX(0); }
  .sidebar-toggle { display: flex; }
  .docs-layout { padding-left: 0; }
  .docs-content { padding: 28px 20px 60px; }
  .docs-footer { padding-left: 0; padding-right: 0; }
  .docs-footer-inner { padding: 0 20px; max-width: none; }

  .layout-main { flex-direction: column; }
  .layout-chat { width: 100%; border-left: none; border-top: 1px solid var(--border); }
  .feature-grid-docs { grid-template-columns: 1fr; }
  .connection-diagram { flex-direction: column; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }
