:root {
  --sidebar-width: 260px;
  --header-height: 56px;
}

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--bg-alt);
  border-right: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform 0.3s;
  overflow-y: auto;
}

.sidebar::-webkit-scrollbar-thumb { background: var(--accent-dim); }
.sidebar::-webkit-scrollbar-thumb:hover { background: var(--accent); }

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem;
  border-bottom: 1px solid var(--border-light);
  height: var(--header-height);
  position: sticky;
  top: 0;
  background: var(--bg-alt);
}

.sidebar-header .logo {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  font-size: 1.1rem;
}

.sidebar-header .logo img { border-radius: 6px; }

.sidebar-close {
  display: none;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.375rem;
  border-radius: 4px;
}

.sidebar-close:hover {
  color: var(--text);
  background: var(--border);
}

.sidebar-nav { flex: 1; padding: 1rem 0.75rem; }

.nav-group { margin-bottom: 1.5rem; }

.nav-label {
  display: block;
  padding: 0.375rem 0.5rem;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  opacity: 0.7;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.625rem 0.75rem;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: var(--radius);
  border: 1px solid transparent;
  transition: all 0.15s;
  margin-bottom: 0.25rem;
}

.nav-link:hover {
  color: var(--text);
  background: var(--surface);
  border-color: var(--border-light);
}

.nav-link.active {
  color: var(--accent);
  background: var(--accent-bg);
  border-color: var(--accent-dim);
}

.nav-link svg { flex-shrink: 0; opacity: 0.7; }
.nav-link:hover svg, .nav-link.active svg { opacity: 1; }

.sidebar-footer {
  padding: 1rem;
  border-top: 1px solid var(--border-light);
  position: sticky;
  bottom: 0;
  background: var(--bg-alt);
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.8125rem;
  border-radius: var(--radius);
  transition: all 0.15s;
}

.sidebar-link:hover {
  color: var(--accent);
  background: var(--accent-bg);
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  z-index: 99;
  opacity: 0;
  transition: opacity 0.3s;
  backdrop-filter: blur(4px);
}

.sidebar-overlay.visible { opacity: 1; }

.mobile-header {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: var(--bg);
  border-bottom: 1px solid var(--border-light);
  padding: 0 1rem;
  align-items: center;
  justify-content: space-between;
  z-index: 90;
}

.mobile-header .logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  font-size: 1rem;
}

.mobile-header .logo img {
  border-radius: 6px;
  width: 28px;
  height: 28px;
}

.menu-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  border-radius: var(--radius);
  transition: all 0.15s;
}

.menu-toggle:hover {
  background: var(--surface);
  border-color: var(--accent);
  color: var(--accent);
}

.main-content {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
}

.content-body {
  max-width: 800px;
  margin: 0 auto;
  padding: 2rem;
}

.doc-section {
  padding: 2.5rem 0;
  border-bottom: 1px solid var(--border-light);
}

.doc-section:last-child { border-bottom: none; }

.doc-section h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.doc-section h2::before {
  content: '>';
  color: var(--accent);
  font-family: var(--font-mono);
}

.doc-section h3 {
  font-size: 1.0625rem;
  font-weight: 600;
  margin: 1.5rem 0 0.75rem;
  color: var(--text);
}

.doc-section p {
  margin-bottom: 1rem;
  color: var(--text-secondary);
  line-height: 1.75;
}

.doc-section ul {
  margin-bottom: 1rem;
  padding-left: 1.25rem;
  color: var(--text-secondary);
}

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

.doc-section li strong { color: var(--text); font-weight: 600; }

.doc-section a {
  color: var(--accent);
  text-decoration: none;
}

.doc-section a:hover { opacity: 0.8; text-decoration: underline; }

.doc-section code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: var(--bg-code);
  padding: 0.2em 0.45em;
  border-radius: 4px;
  color: var(--accent);
  border: 1px solid var(--border-light);
}

.doc-section pre {
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin: 1rem 0;
  overflow-x: auto;
}

.doc-section pre code {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  line-height: 1.7;
  background: none;
  padding: 0;
  color: var(--text-secondary);
  border: none;
}

.modules-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
  margin: 1.25rem 0;
}

.module-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  transition: all 0.2s;
}

.module-card:hover {
  border-color: var(--accent-dim);
  transform: translateY(-2px);
}

.module-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.module-header svg { color: var(--accent); }

.module-header h3 {
  font-size: 0.9375rem;
  font-weight: 600;
  margin: 0;
  color: var(--text);
}

.module-card > p {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
  line-height: 1.5;
}

.module-card > code {
  display: inline-block;
  font-size: 0.7rem;
  padding: 0.2rem 0.4rem;
}

.table-wrapper {
  overflow-x: auto;
  margin: 1.25rem 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.table-wrapper table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.table-wrapper th,
.table-wrapper td {
  text-align: left;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-light);
}

.table-wrapper th {
  background: var(--bg-alt);
  font-weight: 600;
  color: var(--text);
  font-size: 0.8125rem;
}

.table-wrapper td { color: var(--text-secondary); }

.table-wrapper tr:last-child td { border-bottom: none; }

.table-wrapper tr:hover td { background: var(--bg-alt); }

.table-wrapper code { font-size: 0.8125em; }

.faq-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 0.75rem;
  overflow: hidden;
}

.faq-item:hover { border-color: var(--accent-dim); }

.faq-item summary {
  padding: 1rem 1.25rem;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--text);
  transition: background 0.15s;
}

.faq-item summary:hover { background: var(--bg-alt); }

.faq-item summary::after {
  content: '+';
  font-family: var(--font-mono);
  font-size: 1.25rem;
  color: var(--accent);
}

.faq-item[open] summary::after { transform: rotate(45deg); }

.faq-item p,
.faq-item pre {
  padding: 0 1.25rem 1rem;
  margin: 0;
}

.faq-item pre {
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.875rem 1rem;
  margin-top: 0.75rem;
}

.faq-item pre code {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  background: none;
  padding: 0;
  border: none;
}

@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close { display: flex; }
  .sidebar-overlay { display: block; }
  .mobile-header { display: flex; }
  .main-content { margin-left: 0; padding-top: var(--header-height); }
}

@media (max-width: 640px) {
  .content-body { padding: 0 1rem; }
  .doc-section { padding: 2rem 0; }
  .doc-section pre {
    margin: 1rem -1rem;
    border-radius: 0;
    border-left: none;
    border-right: none;
  }
  .table-wrapper {
    margin: 1rem -1rem;
    border-radius: 0;
    border-left: none;
    border-right: none;
  }
  .modules-grid { grid-template-columns: 1fr; }
  .module-card { padding: 1rem; }
}

@media (max-width: 375px) {
  .nav-label { font-size: 0.6rem; }
  .nav-link { font-size: 0.875rem; }
}

@media print {
  .sidebar, .mobile-header, .sidebar-overlay { display: none !important; }
  .main-content { margin-left: 0; padding-top: 0; }
  .content-body { max-width: 100%; padding: 0; }
  .doc-section { page-break-inside: avoid; }
}