:root {
  --bg: #0b0f17;
  --bg-card: #121826;
  --bg-hover: #1a2234;
  --border: #2a3142;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --sidebar-width: 260px;
  --content-max: 920px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
}

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

.site {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  padding: 1.25rem 1rem;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  z-index: 100;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--text);
  text-decoration: none;
  padding: 0.5rem 0.75rem;
  margin-bottom: 1.25rem;
}

.sidebar-brand:hover { text-decoration: none; color: var(--text); }

.sidebar-logo {
  width: 36px;
  height: 36px;
  background: rgba(59, 130, 246, 0.15);
  color: var(--primary);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.sidebar-brand strong { display: block; font-size: 0.95rem; }
.sidebar-brand small { display: block; color: var(--muted); font-size: 0.75rem; }

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  flex: 1;
}

.nav-link {
  display: block;
  padding: 0.45rem 0.75rem;
  border-radius: 6px;
  color: var(--muted);
  font-size: 0.875rem;
  text-decoration: none;
}

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

.nav-link.active {
  background: rgba(59, 130, 246, 0.15);
  color: var(--primary);
  font-weight: 500;
}

.sidebar-footer {
  padding: 1rem 0.75rem 0;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--muted);
}

.sidebar-footer a { color: var(--muted); }
.sidebar-footer a:hover { color: var(--primary); }

.main {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.content {
  flex: 1;
  max-width: var(--content-max);
  padding: 2rem 2.5rem 3rem;
  width: 100%;
}

.page-header {
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.page-header h1 {
  margin: 0 0 0.35rem;
  font-size: 1.75rem;
  font-weight: 700;
}

.page-lead {
  margin: 0;
  color: var(--muted);
  font-size: 1rem;
}

.content h1 { font-size: 1.75rem; margin-top: 0; }
.content h2 {
  font-size: 1.25rem;
  margin-top: 2rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--border);
}
.content h3 { font-size: 1.05rem; margin-top: 1.5rem; }

.content p, .content li { color: #cbd5e1; }
.content strong { color: var(--text); }

.content img,
.content .banner {
  max-width: 100%;
  height: auto;
  border-radius: 10px;
  border: 1px solid var(--border);
  display: block;
  margin: 1rem auto;
}

.content .banner { margin-bottom: 1.5rem; }

.content pre {
  background: #0a0e14;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  overflow-x: auto;
  font-size: 0.85rem;
}

.content code {
  background: var(--bg-hover);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-size: 0.875em;
}

.content pre code {
  background: none;
  padding: 0;
}

.content table {
  width: 100%;
  border-collapse: collapse;
  margin: 0;
  font-size: 0.9rem;
}

.content th,
.content td {
  border: 1px solid var(--border);
  padding: 0.6rem 0.75rem;
  text-align: left;
}

.content th {
  background: var(--bg-card);
  color: var(--text);
  font-weight: 600;
}

.content tr:nth-child(even) td {
  background: rgba(18, 24, 38, 0.5);
}

.table-scroll {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 1rem 0;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.table-scroll table {
  margin: 0;
  min-width: 100%;
}

.content blockquote {
  margin: 1rem 0;
  padding: 0.75rem 1rem;
  border-left: 3px solid var(--primary);
  background: var(--bg-card);
  color: var(--muted);
}

.content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2rem 0;
}

.content ul, .content ol { padding-left: 1.25rem; }

.quick-links {
  text-align: center;
  margin: 1.25rem 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.quick-links a { margin: 0 0.15rem; }

.site-footer {
  max-width: var(--content-max);
  padding: 1rem 2.5rem 2rem;
  color: var(--muted);
  font-size: 0.8rem;
}

.site-footer p { margin: 0; }

/* Mobile header + hamburger */
.mobile-header {
  display: none;
}

.sidebar-overlay {
  display: none;
}

.menu-toggle {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 40px;
  height: 40px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-hover);
  cursor: pointer;
  flex-shrink: 0;
}

.menu-toggle-bar {
  display: block;
  height: 2px;
  width: 100%;
  background: var(--text);
  border-radius: 1px;
  transition: transform 0.2s, opacity 0.2s;
}

body.nav-open .menu-toggle-bar:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

body.nav-open .menu-toggle-bar:nth-child(2) {
  opacity: 0;
}

body.nav-open .menu-toggle-bar:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

@media (max-width: 900px) {
  .mobile-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    padding: 0 1rem;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    z-index: 150;
  }

  .mobile-title {
    font-size: 0.95rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 180;
  }

  body.nav-open .sidebar-overlay {
    display: block;
  }

  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    width: min(280px, 85vw);
    z-index: 200;
    border-bottom: none;
  }

  body.nav-open .sidebar {
    transform: translateX(0);
  }

  .main {
    margin-left: 0;
    padding-top: 56px;
    width: 100%;
  }

  .content {
    padding: 1.25rem 1rem 2rem;
    max-width: 100%;
  }

  .site-footer {
    padding: 1rem 1rem 2rem;
    max-width: 100%;
  }

  .table-scroll th,
  .table-scroll td {
    min-width: 100px;
    font-size: 0.85rem;
    padding: 0.5rem 0.6rem;
  }
}
