:root {
  --bg-color: #0d1117;
  --surface-color: #161b22;
  --border-color: #30363d;
  --primary-color: #58a6ff;
  --secondary-color: #bc8cff;
  --success-color: #3fb950;
  --warning-color: #d29922;
  --danger-color: #f85149;
  --text-primary: #e6edf3;
  --text-muted: #8b949e;
  --code-bg: #1f2428;
  --header-height: 64px;
  --sidebar-width: 260px;
  --toc-width: 240px;
}

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

body {
  background-color: var(--bg-color);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
header {
  height: var(--header-height);
  background-color: var(--surface-color);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  justify-content: space-between;
}

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

.header-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.github-link {
  color: var(--text-muted);
  transition: color 0.2s;
}

.github-link:hover {
  color: var(--text-primary);
}

.hamburger {
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 1.5rem;
  cursor: pointer;
  display: none;
}

/* Progress Bar */
.progress-container {
  position: fixed;
  top: var(--header-height);
  left: 0;
  width: 100%;
  height: 3px;
  background: transparent;
  z-index: 99;
}

.progress-bar {
  height: 100%;
  background: var(--primary-color);
  width: 0%;
  transition: width 0.1s;
}

/* Layout */
.wrapper {
  display: flex;
  margin-top: var(--header-height);
  min-height: calc(100vh - var(--header-height));
}

/* Sidebar Navigation */
.sidebar {
  width: var(--sidebar-width);
  background-color: var(--bg-color);
  border-right: 1px solid var(--border-color);
  padding: 2rem 1rem;
  height: calc(100vh - var(--header-height));
  overflow-y: auto;
  position: fixed;
  left: 0;
  top: var(--header-height);
  z-index: 90;
  transition: transform 0.3s ease;
}

.nav-links {
  list-style: none;
}

.nav-link {
  display: flex;
  align-items: center;
  padding: 0.75rem 1rem;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: 6px;
  margin-bottom: 0.25rem;
  transition: all 0.2s;
  font-size: 0.95rem;
}

.nav-link:hover {
  background-color: rgba(88, 166, 255, 0.1);
  color: var(--primary-color);
}

.nav-link.active {
  background-color: rgba(88, 166, 255, 0.15);
  color: var(--primary-color);
  border-left: 3px solid var(--primary-color);
  padding-left: calc(1rem - 3px); /* Compensate for border */
}

.nav-icon {
  margin-right: 0.75rem;
  opacity: 0.7;
}

/* Main Content */
main {
  flex: 1;
  margin-left: var(--sidebar-width);
  margin-right: var(--toc-width);
  padding: 3rem 4rem;
  max-width: 100%; /* Let flexbox handle width */
}

.content-container {
  max-width: 860px;
  margin: 0 auto;
}

h1, h2, h3, h4, h5, h6 {
  color: var(--text-primary);
  margin-bottom: 1rem;
  line-height: 1.25;
}

h1 { font-size: 2.5rem; margin-bottom: 1.5rem; border-bottom: 1px solid var(--border-color); padding-bottom: 0.5rem; }
h2 { font-size: 1.75rem; margin-top: 3rem; margin-bottom: 1rem; border-bottom: 1px solid var(--border-color); padding-bottom: 0.3rem; }
h3 { font-size: 1.4rem; margin-top: 2rem; }

p { margin-bottom: 1.2rem; color: #c9d1d9; }
ul, ol { margin-bottom: 1.2rem; padding-left: 1.5rem; color: #c9d1d9; }
li { margin-bottom: 0.5rem; }
a { color: var(--primary-color); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Code Blocks */
pre {
  background-color: var(--code-bg);
  border-radius: 6px;
  padding: 1rem;
  margin: 1.5rem 0;
  overflow-x: auto;
  border: 1px solid var(--border-color);
  position: relative;
}

code {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.9rem;
}
p code, li code {
  background-color: rgba(110, 118, 129, 0.4);
  padding: 0.2em 0.4em;
  border-radius: 4px;
  font-size: 0.85em;
}

.code-header {
  position: absolute;
  top: 0;
  right: 0;
  display: flex;
  border-bottom-left-radius: 6px;
  background: var(--surface-color);
  border-left: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
  z-index: 10;
}

.lang-badge {
  padding: 0.3rem 0.6rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  border-right: 1px solid var(--border-color);
  text-transform: uppercase;
  font-weight: bold;
}

.copy-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.3rem 0.6rem;
  font-size: 0.75rem;
  transition: color 0.2s;
}

.copy-btn:hover {
  color: var(--text-primary);
  background-color: rgba(255,255,255,0.05);
}

/* Callouts */
.callout {
  padding: 1rem 1rem 1rem 1.2rem;
  margin: 1.5rem 0;
  border-radius: 0 6px 6px 0;
  background-color: rgba(22, 27, 34, 0.5);
  border-left-width: 4px;
  border-left-style: solid;
}

.callout-title {
  font-weight: bold;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.callout.tip { border-left-color: var(--success-color); }
.callout.tip .callout-title { color: var(--success-color); }

.callout.note { border-left-color: var(--primary-color); }
.callout.note .callout-title { color: var(--primary-color); }

.callout.warning { border-left-color: var(--warning-color); }
.callout.warning .callout-title { color: var(--warning-color); }

.callout.sanity { border-left-color: var(--secondary-color); }
.callout.sanity .callout-title { color: var(--secondary-color); }

/* Table of Contents */
.toc {
  width: var(--toc-width);
  position: fixed;
  right: 0;
  top: var(--header-height);
  height: calc(100vh - var(--header-height));
  padding: 2rem 1rem;
  border-left: 1px solid var(--border-color);
  overflow-y: auto;
}

.toc h4 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.toc ul {
  list-style: none;
  padding: 0;
  border-left: 1px solid var(--border-color);
}

.toc li {
  margin: 0;
}

.toc a {
  display: block;
  padding: 0.3rem 0 0.3rem 1rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  border-left: 2px solid transparent;
  margin-left: -2px; /* Overlap border */
  transition: all 0.2s;
}

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

.toc a.active {
  color: var(--primary-color);
  border-left-color: var(--primary-color);
  font-weight: 500;
}

/* Page Nav Buttons */
.page-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 4rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border-color);
}

.nav-btn {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  padding: 1rem;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  width: 48%;
  transition: border-color 0.2s, background-color 0.2s;
}

.nav-btn:hover {
  border-color: var(--primary-color);
  background-color: var(--surface-color);
  text-decoration: none;
}

.nav-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
}

.nav-title {
  color: var(--primary-color);
  font-weight: 600;
}

/* Landing Page Specifics */
.hero {
  text-align: center;
  padding: 4rem 1rem;
  position: relative;
  overflow: hidden;
  background: radial-gradient(circle at center, #161b22 0%, #0d1117 70%);
}

#particle-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  opacity: 0.6;
}

.hero-content {
  position: relative;
  z-index: 1;
  max-width: 800px;
  margin: 0 auto;
}

.hero h1 {
  font-size: 3.5rem;
  margin-bottom: 1rem;
  background: linear-gradient(120deg, var(--primary-color), var(--secondary-color));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  border-bottom: none;
}

.hero p {
  font-size: 1.25rem;
  color: var(--text-muted);
  margin-bottom: 2rem;
}

.cta-buttons {
  display: flex;
  gap: 1rem;
  justify-content: center;
}

.btn {
  display: inline-block;
  padding: 0.8rem 1.5rem;
  border-radius: 6px;
  font-weight: 600;
  text-decoration: none;
  transition: transform 0.2s, opacity 0.2s;
}

.btn-primary {
  background-color: var(--primary-color);
  color: white;
}
.btn-primary:hover {
  opacity: 0.9;
  text-decoration: none;
  transform: translateY(-2px);
}

.btn-secondary {
  background-color: var(--surface-color);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
}
.btn-secondary:hover {
  border-color: var(--text-muted);
  text-decoration: none;
  transform: translateY(-2px);
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 2rem;
  margin: 4rem 0;
}

.feature-card {
  background: var(--surface-color);
  border: 1px solid var(--border-color);
  padding: 1.5rem;
  border-radius: 8px;
  text-align: center;
}

.feature-icon {
  font-size: 2rem;
  margin-bottom: 1rem;
  color: var(--secondary-color);
}

/* Responsive Design */
@media (max-width: 1200px) {
  .toc { display: none; }
  main { margin-right: 0; padding: 2rem; }
}

@media (max-width: 768px) {
  .sidebar {
      transform: translateX(-100%);
      box-shadow: 5px 0 15px rgba(0,0,0,0.5);
  }
  .sidebar.open { transform: translateX(0); }
  main { margin-left: 0; padding: 1.5rem; }
  .hamburger { display: block; }
  .logo span { display: none; } /* Hide text on very small screens if needed */
  .hero h1 { font-size: 2.5rem; }
  .page-nav { flex-direction: column; gap: 1rem; }
  .nav-btn { width: 100%; }
}

/* Print Styles */
@media print {
  .sidebar, .toc, header, .page-nav, .code-header { display: none !important; }
  main { margin: 0; padding: 0; width: 100%; }
  body { background: white; color: black; }
  pre { border: 1px solid #ccc; background: #f5f5f5; color: black; }
  code { color: black; }
  h1, h2, h3 { color: black; border-bottom: 1px solid #000; }
  a { text-decoration: underline; color: black; }
}