/* === Reset & Base === */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg: #0a0a0a;
  --bg-subtle: #171717;
  --border: #262626;
  --text-primary: #ededed;
  --text-secondary: #a3a3a3;
  --text-muted: #737373;
  --accent: #3b82f6;
  --accent-dim: #1e3a5f;
  --code-bg: #161616;
  --sidebar-width: 240px;
  --header-height: 52px;
  --content-max: 720px;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

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

/* === Header === */
.header {
  position: sticky;
  top: 0;
  z-index: 30;
  height: var(--header-height);
  background: var(--bg);
  display: flex;
  align-items: center;
  padding: 0 24px;
  border-bottom: 1px solid var(--border);
}

.header-logo {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.header-logo span {
  color: var(--accent);
}

.header-nav {
  margin-left: auto;
  display: flex;
  gap: 24px;
  align-items: center;
}

.header-nav a {
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 400;
  transition: color 0.15s;
}
.header-nav a:hover {
  color: var(--text-primary);
  text-decoration: none;
}

.github-link {
  display: flex;
  align-items: center;
  gap: 6px;
}

.github-link svg {
  width: 18px;
  height: 18px;
  fill: var(--text-secondary);
}

/* === Mobile Menu Toggle === */
.menu-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
}

.menu-toggle svg {
  width: 24px;
  height: 24px;
}

/* === Layout === */
.layout {
  max-width: 1152px;
  margin: 0 auto;
  display: flex;
  padding: 0 16px;
}

/* === Sidebar === */
.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  position: sticky;
  top: var(--header-height);
  height: calc(100vh - var(--header-height));
  overflow-y: auto;
  padding: 24px 16px 24px 0;
}

.sidebar-section {
  margin-bottom: 24px;
}

.sidebar-heading {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 0 12px;
  margin-bottom: 8px;
}

.sidebar nav a {
  display: block;
  padding: 6px 12px;
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 400;
  transition: all 0.15s;
  margin-bottom: 2px;
}

.sidebar nav a:hover {
  color: var(--text-primary);
  background: var(--bg-subtle);
  text-decoration: none;
}

.sidebar nav a.active {
  color: var(--text-primary);
  background: var(--bg-subtle);
  font-weight: 500;
}

.sidebar nav a.nested {
  padding-left: 24px;
  font-size: 13px;
}

/* === Content === */
.content {
  flex: 1;
  min-width: 0;
  max-width: var(--content-max);
  padding: 40px 0 80px 48px;
}

.content h1 {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 8px;
  letter-spacing: -0.02em;
}

.content h2 {
  font-size: 22px;
  font-weight: 600;
  margin-top: 48px;
  margin-bottom: 16px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.content h3 {
  font-size: 18px;
  font-weight: 600;
  margin-top: 32px;
  margin-bottom: 12px;
}

.content p {
  margin-bottom: 16px;
  color: var(--text-secondary);
}

.content .lead {
  font-size: 18px;
  color: var(--text-secondary);
  margin-bottom: 32px;
}

.content ul, .content ol {
  margin-bottom: 16px;
  padding-left: 24px;
}

.content li {
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.content li strong {
  color: var(--text-primary);
}

.content strong {
  color: var(--text-primary);
  font-weight: 600;
}

/* === Code === */
code {
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 13px;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 6px;
}

pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 20px;
  overflow-x: auto;
  margin-bottom: 24px;
}

pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 13px;
  line-height: 1.6;
  color: #e1e4e8;
}

/* === Callout === */
.callout {
  border-left: 3px solid var(--accent);
  background: var(--accent-dim);
  padding: 16px 20px;
  border-radius: 0 8px 8px 0;
  margin-bottom: 24px;
}

.callout p {
  color: var(--text-primary);
  margin: 0;
  font-size: 14px;
}

.callout strong {
  color: var(--accent);
}

/* === Table === */
table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 24px;
  font-size: 14px;
}

th, td {
  text-align: left;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}

th {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

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

/* === Diagram (ASCII) === */
.diagram {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 24px;
  margin-bottom: 24px;
  text-align: center;
  overflow-x: auto;
}

.diagram pre {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  display: inline-block;
  text-align: left;
}

/* === Card Grid === */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.card {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
}

.card h4 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 8px;
}

.card p {
  font-size: 14px;
  color: var(--text-secondary);
  margin: 0;
}

.card .badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--accent-dim);
  color: var(--accent);
  margin-bottom: 8px;
}

/* === Conversation Quotes === */
.conversation-quotes {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
  margin: 24px 0 32px;
}

.conversation-quotes blockquote {
  margin: 0;
  padding: 14px 18px;
  background: var(--bg-subtle);
  border-left: 3px solid var(--accent);
  border-radius: 0 8px 8px 0;
  color: var(--text-primary);
  font-size: 15px;
  font-style: italic;
  line-height: 1.55;
}

/* === Hero Figure === */
.hero-figure {
  margin: 24px 0 32px;
  text-align: center;
}

.hero-figure img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 0 auto;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.hero-figure figcaption {
  margin-top: 12px;
  font-size: 13px;
  color: var(--text-muted);
}

/* === Navigation (Prev/Next) === */
.page-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 64px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.page-nav a {
  color: var(--text-secondary);
  font-size: 14px;
  transition: color 0.15s;
}
.page-nav a:hover {
  color: var(--text-primary);
}

.page-nav .next {
  margin-left: auto;
}

/* === Footer === */
.footer {
  margin-top: 64px;
  border-top: 1px solid var(--border);
  padding: 48px 24px 32px;
}

.footer-inner {
  max-width: 1152px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 32px;
}

.footer-col h5 {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.footer-col a {
  display: block;
  color: var(--text-secondary);
  font-size: 13px;
  margin-bottom: 8px;
}
.footer-col a:hover {
  color: var(--text-primary);
}

.footer-bottom {
  max-width: 1152px;
  margin: 32px auto 0;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
}

/* === Flow Diagram === */
.flow-step {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 24px;
}

.flow-number {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-dim);
  color: var(--accent);
  font-weight: 700;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.flow-content {
  flex: 1;
}

.flow-content h4 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 4px;
}

.flow-content p {
  font-size: 14px;
  margin: 0;
}

.flow-arrow {
  text-align: center;
  color: var(--text-muted);
  margin: -8px 0 16px 8px;
  font-size: 20px;
}

/* === Responsive === */
@media (max-width: 768px) {
  .menu-toggle {
    display: block;
  }

  .header-nav .nav-links {
    display: none;
  }

  .sidebar {
    display: none;
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    z-index: 20;
    background: var(--bg);
    padding: 24px;
    height: auto;
  }

  .sidebar.open {
    display: block;
  }

  .layout {
    flex-direction: column;
  }

  .content {
    padding: 24px 0 60px;
    max-width: 100%;
  }

  .content h1 {
    font-size: 24px;
  }

  .content h2 {
    font-size: 20px;
  }

  .card-grid {
    grid-template-columns: 1fr;
  }

  .page-nav {
    flex-direction: column;
    gap: 12px;
  }

  .footer-inner {
    flex-direction: column;
  }
}
