:root {
  /* Dark theme (default) */
  --bg: #0c1014;
  --panel: #121820;
  --text: #e6edf3;
  --text-secondary: #b4bcc6;
  --muted: #9fb0c2;
  --accent: #4fd1c5;
  --accent-2: #f6ad55;
  --border: #1f2a36;
  --code-bg: #0f141b;
  --hero-grad: radial-gradient(1200px circle at 20% 20%, rgba(79, 209, 197, 0.2), transparent 55%),
               radial-gradient(900px circle at 80% 10%, rgba(246, 173, 85, 0.18), transparent 60%);
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #ffffff;
    --panel: #f8f9fa;
    --text: #1a1a1a;
    --text-secondary: #4a4a4a;
    --muted: #6b7280;
    --accent: #0891b2;
    --accent-2: #d97706;
    --border: #e5e7eb;
    --code-bg: #f3f4f6;
  }
}

[data-theme="light"] {
  --bg: #ffffff;
  --panel: #f8f9fa;
  --text: #1a1a1a;
  --text-secondary: #4a4a4a;
  --muted: #6b7280;
  --accent: #0891b2;
  --accent-2: #d97706;
  --border: #e5e7eb;
  --code-bg: #f3f4f6;
}

[data-theme="dark"] {
  --bg: #0c1014;
  --panel: #121820;
  --text: #e6edf3;
  --text-secondary: #b4bcc6;
  --muted: #9fb0c2;
  --accent: #4fd1c5;
  --accent-2: #f6ad55;
  --border: #1f2a36;
  --code-bg: #0f141b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Inter", "Segoe UI", "Helvetica Neue", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-weight: 400;
  letter-spacing: -0.3px;
  line-height: 1.6;
  transition: background-color 0.3s ease, color 0.3s ease;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

.site-header {
  position: sticky;
  top: 0;
  background: rgba(var(--header-rgb, 12, 16, 20), 0.95);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  z-index: 10;
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

.site-header .container {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 20px;
}

.brand {
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  font-size: 20px;
}

.subtitle {
  color: var(--muted);
  font-size: 13px;
}

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

.theme-toggle {
  background: transparent;
  border: none;
  font-size: 18px;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 6px;
  transition: background-color 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.theme-toggle:hover {
  background: var(--border);
}

.top-nav a {
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
}

.top-search {
  position: relative;
}

.top-search input {
  width: 200px;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--code-bg);
  color: var(--text);
  font-size: 13px;
}

.top-results {
  position: absolute;
  right: 0;
  top: 36px;
  width: 320px;
  max-height: 360px;
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px;
  z-index: 20;
}

.version-switcher {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: 12px;
}

.version-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.version-switcher select {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
}

.layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 24px;
  padding: 24px 20px 40px;
}

.sidebar {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  height: fit-content;
  top: 80px;
  position: sticky;
}

.search {
  margin-bottom: 16px;
}

.search input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--code-bg);
  color: var(--text);
}

.search-results {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.search-item {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  text-decoration: none;
  color: var(--text);
  background: rgba(15, 20, 27, 0.6);
}

.search-title {
  font-size: 13px;
  font-weight: 600;
}

.search-snippet {
  font-size: 12px;
  color: var(--muted);
}

.search-empty {
  font-size: 12px;
  color: var(--muted);
}

.side-nav ul {
  list-style: none;
  padding: 0;
  margin: 16px 0 24px;
}

.side-nav li {
  margin: 0;
}

.side-nav a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  padding: 8px 12px;
  display: block;
  border-radius: 6px;
  transition: background-color 0.2s ease, color 0.2s ease;
  line-height: 1.5;
}

.side-nav a:hover {
  color: #ffffff;
  background: var(--code-bg);
}

.nav-section {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent-2);
  margin: 20px 0 12px 0;
  padding: 0 12px;
  font-weight: 600;
}

.content {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 40px 48px;
  line-height: 1.8;
}

.content p {
  margin: 1.2em 0;
  color: var(--text-secondary);
  font-size: 15px;
}

h1, h2, h3, h4, h5, h6 {
  font-family: "Outfit", "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin: 1.5em 0 0.5em 0;
  line-height: 1.3;
  color: var(--text);
}

h1 {
  font-size: 2.5em;
  margin-top: 0;
}

h2 {
  font-size: 1.75em;
  margin-top: 1.8em;
  padding-top: 0.5em;
  border-top: 2px solid var(--border);
}

h3 {
  font-size: 1.3em;
}

h4 {
  font-size: 1.1em;
}

.chapter-meta {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

pre, code {
  font-family: "JetBrains Mono", "Fira Code", monospace;
  font-size: 14px;
}

pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  padding: 16px 20px;
  border-radius: 8px;
  overflow: auto;
  line-height: 1.5;
  margin: 1.5em 0;
}

code {
  background: rgba(79, 209, 197, 0.08);
  padding: 3px 6px;
  border-radius: 4px;
  font-size: 0.9em;
}

pre code {
  background: none;
  padding: 0;
  color: inherit;
}

/* Blockquotes */
blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 1.5em;
  margin: 1.5em 0;
  color: var(--text-secondary);
  font-style: italic;
}

/* Lists */
ul, ol {
  margin: 1.2em 0;
  padding-left: 2em;
  line-height: 1.8;
}

li {
  margin: 0.6em 0;
}

/* Tables */
table {
  border-collapse: collapse;
  width: 100%;
  margin: 1.5em 0;
}

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

table th {
  background: var(--code-bg);
  font-weight: 600;
}

.chapter-nav {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 24px;
}

.chapter-nav a {
  color: #ffffff;
  text-decoration: none;
}

.site-footer {
  border-top: 1px solid var(--border);
  padding: 20px 0;
  color: var(--muted);
}

@media (max-width: 960px) {
  .layout {
    grid-template-columns: 1fr;
  }
  .sidebar {
    order: 2;
  }
  .content {
    order: 1;
  }
  .top-search {
    display: none;
  }
}

/* Home */
.home {
  background: var(--bg);
}

.home-hero {
  padding: 56px 28px 28px;
  background: var(--hero-grad);
}

.home-grid {
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 28px;
}

.home-title h1 {
  font-size: 42px;
  margin: 8px 0 12px;
}

.home-title p {
  color: var(--muted);
  font-size: 16px;
  line-height: 1.6;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: 11px;
  color: var(--accent-2);
}

.home-cta {
  display: flex;
  gap: 12px;
  margin: 18px 0;
}

.btn {
  padding: 10px 16px;
  border-radius: 999px;
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
}

.btn.primary {
  background: var(--accent);
  color: #0b1217;
}

.btn.ghost {
  border: 1px solid var(--border);
  color: var(--text);
}

.home-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.home-meta div {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  font-size: 12px;
  color: var(--muted);
}

.home-meta span {
  display: block;
  color: var(--text);
  font-weight: 600;
}

.home-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
}

.card-head {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--accent-2);
  margin-bottom: 8px;
}

.home-strip {
  max-width: 1200px;
  margin: 24px auto;
  padding: 0 28px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.strip-item {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  background: rgba(18, 24, 32, 0.7);
}

.strip-title {
  font-weight: 700;
  margin-bottom: 6px;
}

.strip-text {
  color: var(--muted);
  font-size: 13px;
}

.home-grid-2 {
  max-width: 1200px;
  margin: 24px auto 40px;
  padding: 0 28px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.panel {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  background: var(--panel);
}

.panel-links a {
  display: inline-block;
  margin: 6px 10px 0 0;
  color: #ffffff;
  text-decoration: none;
}

.plain {
  list-style: none;
  padding: 0;
  margin: 0;
}

.plain li {
  margin: 6px 0;
  color: var(--muted);
}

.home-footer {
  border-top: 1px solid var(--border);
  padding: 20px 28px;
  display: flex;
  justify-content: space-between;
  color: var(--muted);
}

.home-footer a {
  color: #ffffff;
  text-decoration: none;
}

/* Syntax highlighting for Vitte code blocks - Dark theme */
[data-theme="dark"] .highlight .k { color: #ff7b72; font-weight: 600; }
[data-theme="dark"] .highlight .kd { color: #ff7b72; font-weight: 600; }
[data-theme="dark"] .highlight .nb { color: #79c0ff; }
[data-theme="dark"] .highlight .s { color: #a5d6ff; }
[data-theme="dark"] .highlight .s2 { color: #a5d6ff; }
[data-theme="dark"] .highlight .sc { color: #a5d6ff; }
[data-theme="dark"] .highlight .sb { color: #a5d6ff; }
[data-theme="dark"] .highlight .c1 { color: #8b949e; font-style: italic; }
[data-theme="dark"] .highlight .cm { color: #8b949e; font-style: italic; }
[data-theme="dark"] .highlight .n { color: #e6edf3; }
[data-theme="dark"] .highlight .no { color: #79c0ff; }
[data-theme="dark"] .highlight .mi { color: #79d836; }
[data-theme="dark"] .highlight .mf { color: #79d836; }
[data-theme="dark"] .highlight .mh { color: #79d836; }
[data-theme="dark"] .highlight .mb { color: #79d836; }
[data-theme="dark"] .highlight .o { color: #ff7b72; }
[data-theme="dark"] .highlight .p { color: #e6edf3; }

/* Syntax highlighting for Vitte code blocks - Light theme */
[data-theme="light"] .highlight .k { color: #d73a49; font-weight: 600; }
[data-theme="light"] .highlight .kd { color: #d73a49; font-weight: 600; }
[data-theme="light"] .highlight .nb { color: #0550ae; }
[data-theme="light"] .highlight .s { color: #0a3069; }
[data-theme="light"] .highlight .s2 { color: #0a3069; }
[data-theme="light"] .highlight .sc { color: #0a3069; }
[data-theme="light"] .highlight .sb { color: #0a3069; }
[data-theme="light"] .highlight .c1 { color: #8590a2; font-style: italic; }
[data-theme="light"] .highlight .cm { color: #8590a2; font-style: italic; }
[data-theme="light"] .highlight .n { color: #24292f; }
[data-theme="light"] .highlight .no { color: #0550ae; }
[data-theme="light"] .highlight .mi { color: #0550ae; }
[data-theme="light"] .highlight .mf { color: #0550ae; }
[data-theme="light"] .highlight .mh { color: #0550ae; }
[data-theme="light"] .highlight .mb { color: #0550ae; }
[data-theme="light"] .highlight .o { color: #d73a49; }
[data-theme="light"] .highlight .p { color: #24292f; }

/* Default (dark) theme fallback */
.highlight .k { color: #ff7b72; font-weight: 600; }
.highlight .kd { color: #ff7b72; font-weight: 600; }
.highlight .nb { color: #79c0ff; }
.highlight .s { color: #a5d6ff; }
.highlight .s2 { color: #a5d6ff; }
.highlight .sc { color: #a5d6ff; }
.highlight .sb { color: #a5d6ff; }
.highlight .c1 { color: #8b949e; font-style: italic; }
.highlight .cm { color: #8b949e; font-style: italic; }
.highlight .n { color: #e6edf3; }
.highlight .no { color: #79c0ff; }
.highlight .mi { color: #79d836; }
.highlight .mf { color: #79d836; }
.highlight .mh { color: #79d836; }
.highlight .mb { color: #79d836; }
.highlight .o { color: #ff7b72; }
.highlight .p { color: #e6edf3; }

@media (max-width: 960px) {
  .home-grid {
    grid-template-columns: 1fr;
  }
  .home-strip,
  .home-grid-2 {
    grid-template-columns: 1fr;
  }
  .home-meta {
    grid-template-columns: 1fr;
  }
}
