/* === Design Tokens === */
:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-card: #1a1a25;
  --bg-code: #0d0d14;
  --border: #2a2a3a;
  --border-hover: #3a3a4f;
  --text-primary: #e8e8f0;
  --text-secondary: #9898a8;
  --text-muted: #6a6a7a;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --green: #22c55e;
  --yellow: #eab308;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
  --max-width: 860px;
  --radius: 8px;
}

/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; font-size: 16px; }
body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

/* === Layout === */
.container { max-width: var(--max-width); margin: 0 auto; padding: 0 1.5rem; }

/* === Navigation === */
nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(10, 10, 15, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
nav .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  max-width: 1000px;
}
.nav-brand {
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--text-primary);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.nav-brand span { color: var(--accent); }
.nav-links { display: flex; gap: 1.5rem; list-style: none; }
.nav-links a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: color 0.2s;
  cursor: pointer;
}
.nav-links a:hover, .nav-links a.active { color: var(--text-primary); }
.nav-toggle { display: none; background: none; border: none; color: var(--text-primary); font-size: 1.5rem; cursor: pointer; }

/* === Markdown Body === */
.markdown-body {
  padding: 3rem 0 5rem;
}

.markdown-body h1 {
  font-size: 2.25rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.2;
  margin-bottom: 1rem;
}

.markdown-body h2 {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-top: 3rem;
  margin-bottom: 1rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.markdown-body h3 {
  font-size: 1.2rem;
  font-weight: 600;
  margin-top: 2rem;
  margin-bottom: 0.75rem;
  color: var(--text-primary);
}

.markdown-body h4 {
  font-size: 1rem;
  font-weight: 600;
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
  color: var(--text-secondary);
}

.markdown-body p {
  color: var(--text-secondary);
  margin-bottom: 1rem;
}

.markdown-body strong {
  color: var(--text-primary);
}

.markdown-body a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.2s;
}
.markdown-body a:hover { color: var(--accent-hover); }

.markdown-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2.5rem 0;
}

/* Lists */
.markdown-body ul, .markdown-body ol {
  margin-bottom: 1rem;
  padding-left: 1.5rem;
  color: var(--text-secondary);
}
.markdown-body li {
  margin-bottom: 0.4rem;
  line-height: 1.6;
}
.markdown-body li strong {
  color: var(--text-primary);
}

/* Code */
.markdown-body code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--bg-card);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  color: var(--accent-hover);
}
.markdown-body pre {
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  overflow-x: auto;
  margin: 1rem 0 1.5rem;
  line-height: 1.5;
}
.markdown-body pre code {
  background: none;
  padding: 0;
  color: var(--text-secondary);
  font-size: 0.85rem;
}

/* Tables */
.markdown-body table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  margin: 1rem 0 1.5rem;
  display: block;
  overflow-x: auto;
}
.markdown-body thead {
  background: var(--bg-secondary);
}
.markdown-body th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
.markdown-body td {
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
  vertical-align: top;
}
.markdown-body tr:last-child td { border-bottom: none; }
.markdown-body tr:hover td { background: rgba(26, 26, 37, 0.5); }
.markdown-body td:first-child { font-weight: 600; color: var(--text-primary); white-space: nowrap; }

/* Blockquotes */
.markdown-body blockquote {
  border-left: 3px solid var(--accent);
  padding: 0.5rem 1rem;
  margin: 1rem 0;
  background: rgba(99, 102, 241, 0.05);
  border-radius: 0 var(--radius) var(--radius) 0;
}
.markdown-body blockquote p {
  color: var(--text-secondary);
  margin-bottom: 0;
}

/* Loading state */
.loading {
  color: var(--text-muted);
  text-align: center;
  padding: 4rem 0;
}

/* === Footer === */
footer {
  border-top: 1px solid var(--border);
  padding: 2rem 0;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}
footer a { color: var(--accent); text-decoration: none; }

/* === Responsive === */
@media (max-width: 768px) {
  .markdown-body h1 { font-size: 1.75rem; }
  .markdown-body h2 { font-size: 1.35rem; }
  .markdown-body { padding: 2rem 0 3rem; }
  .nav-links { display: none; }
  .nav-links.open {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: 56px;
    left: 0;
    right: 0;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border);
    padding: 1rem 1.5rem;
    gap: 1rem;
  }
  .nav-toggle { display: block; }
}
