:root {
  --font-sans: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --radius: 10px;
  --transition: 0.2s ease;
}

html[data-theme="light"] {
  --bg: #ffffff;
  --bg-muted: #f5f7fa;
  --text: #0f172a;
  --text-muted: #475569;
  --primary: #2563eb;
  --border: #e2e8f0;
  --code-bg: #f1f5f9;
}

html[data-theme="dark"] {
  --bg: #0b0f19;
  --bg-muted: #111827;
  --text: #e5e7eb;
  --text-muted: #9ca3af;
  --primary: #3b82f6;
  --border: #1f2933;
  --code-bg: #1e293b;
}

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

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  transition: background-color var(--transition), color var(--transition);
}

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

a:hover {
  text-decoration: underline;
}

.container {
  max-width: 1100px;
  padding: 0 1.5rem;
  margin: 0 auto;
}

/* Header */
.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 100;
  transition: border-color var(--transition);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 72px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 700;
  font-size: 1.1rem;
}

.brand svg { 
  color: var(--primary); 
  width: 40px;
  height: 32px;
}

.nav { 
  display: flex; 
  gap: 1.5rem; 
  align-items: center;
}

.nav a { 
  color: var(--text-muted); 
  font-weight: 500;
  text-decoration: none;
}

.nav a:hover { 
  color: var(--text); 
}

.nav a.active {
  color: var(--primary);
}

/* Hero Section */
.hero {
  padding: 5rem 0 4rem;
  text-align: center;
}

.hero h1 {
  font-size: 3rem;
  line-height: 1.1;
  margin-bottom: 1rem;
  font-weight: 800;
}

.hero p {
  font-size: 1.2rem;
  color: var(--text-muted);
  max-width: 700px;
  margin: 0 auto 2rem;
}

.hero-actions {
  display: flex;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.btn {
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius);
  font-weight: 600;
  transition: var(--transition);
  border: 1px solid transparent;
  display: inline-block;
  cursor: pointer;
}

.btn.primary {
  background: var(--primary);
  color: white;
}

.btn.primary:hover { 
  filter: brightness(1.1); 
  text-decoration: none;
}

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

.btn.secondary:hover { 
  background: var(--bg-muted); 
  text-decoration: none;
}

/* Cards */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.5rem;
  padding-bottom: 4rem;
}

.card {
  background: var(--bg-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  transition: background-color var(--transition), border-color var(--transition);
}

.card h3 {
  margin-bottom: 0.5rem;
  font-size: 1.25rem;
}

.card p {
  color: var(--text-muted);
  margin: 0;
}

/* Content */
.content {
  padding: 2rem 0 4rem;
  max-width: 800px;
  margin: 0 auto;
}

.content h1 {
  font-size: 2.5rem;
  margin-bottom: 1rem;
  font-weight: 700;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.5rem;
  position: relative;
}

.content h2 {
  font-size: 2rem;
  margin-top: 2rem;
  margin-bottom: 1rem;
  font-weight: 700;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.5rem;
  position: relative;
}

.content h3 {
  font-size: 1.5rem;
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
  font-weight: 600;
  position: relative;
}

.content h4 {
  font-size: 1.25rem;
  margin-top: 1.25rem;
  margin-bottom: 0.5rem;
  font-weight: 600;
  position: relative;
}

/* Permalink anchors (¶) */
.content h1 .headerlink,
.content h2 .headerlink,
.content h3 .headerlink,
.content h4 .headerlink,
.content h5 .headerlink,
.content h6 .headerlink {
  opacity: 0;
  font-size: 0.7em;
  margin-left: 0.5rem;
  color: var(--text-muted);
  transition: opacity var(--transition), color var(--transition);
  text-decoration: none;
}

.content h1:hover .headerlink,
.content h2:hover .headerlink,
.content h3:hover .headerlink,
.content h4:hover .headerlink,
.content h5:hover .headerlink,
.content h6:hover .headerlink {
  opacity: 1;
}

.content h1 .headerlink:hover,
.content h2 .headerlink:hover,
.content h3 .headerlink:hover,
.content h4 .headerlink:hover,
.content h5 .headerlink:hover,
.content h6 .headerlink:hover {
  color: var(--primary);
  text-decoration: none;
}

.content p {
  margin-bottom: 1rem;
}

.content ul, .content ol {
  margin-bottom: 1rem;
  padding-left: 2rem;
}

.content li {
  margin-bottom: 0.5rem;
}

.content pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  overflow-x: auto;
  margin-bottom: 1rem;
  font-family: ui-monospace, SFMono-Regular, Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 0.9rem;
  line-height: 1.5;
}

.content code {
  background: var(--code-bg);
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 0.9em;
}

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

.content blockquote {
  border-left: 4px solid var(--primary);
  padding-left: 1rem;
  margin: 1rem 0;
  color: var(--text-muted);
  font-style: italic;
}

.content table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1rem;
}

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

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

.content img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
}

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

/* Admonitions */
.content .admonition {
  padding: 1rem;
  margin-bottom: 1rem;
  border-radius: var(--radius);
  border-left: 4px solid var(--primary);
  background: var(--bg-muted);
}

.content .admonition-title {
  font-weight: 600;
  margin-bottom: 0.5rem;
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 1.5rem 0;
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-top: auto;
}

.footer-inner {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

/* Theme Toggle */
.theme-toggle {
  position: fixed;
  top: 1rem;
  right: 1rem;
  background: var(--bg-muted);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  font-size: 0.9rem;
  z-index: 1000;
  transition: background-color var(--transition);
}

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

/* Docs Layout with Sidebar */
.docs-layout {
  display: grid;
  grid-template-columns: 250px 1fr;
  gap: 3rem;
  padding: 2rem 0 4rem;
}

.sidebar {
  position: sticky;
  top: 88px;
  height: fit-content;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
}

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

.nav-section {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.nav-section-title {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text);
  margin-bottom: 0.25rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.nav-subsection {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-left: 0.75rem;
  padding-left: 0.75rem;
  border-left: 1px solid var(--border);
}

.nav-subsection-title {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0.5rem 0 0.25rem;
}

.nav-link {
  padding: 0.4rem 0.75rem;
  font-size: 0.9rem;
  color: var(--text-muted);
  border-radius: 6px;
  transition: background-color var(--transition), color var(--transition);
  text-decoration: none;
}

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

.nav-link.active {
  background: var(--bg-muted);
  color: var(--primary);
  font-weight: 600;
}

/* Responsive */
@media (max-width: 768px) {
  .hero h1 {
    font-size: 2rem;
  }

  .hero p {
    font-size: 1rem;
  }

  .nav {
    flex-direction: column;
    gap: 0.75rem;
    align-items: flex-end;
  }

  .header-inner {
    height: auto;
    padding: 1rem 0;
  }

  .content h1 {
    font-size: 2rem;
  }

  .content h2 {
    font-size: 1.5rem;
  }

  .docs-layout {
    grid-template-columns: 1fr;
    gap: 2rem;
  }

  .sidebar {
    position: static;
    max-height: none;
  }
}

/* ============================================
   Syntax Highlighting for Code Blocks
   ============================================ */

/* Light Theme Syntax Highlighting */
html[data-theme="light"] .codehilite .hll { background-color: #ffffcc }
html[data-theme="light"] .codehilite .c { color: #60a0b0; font-style: italic } /* Comment */
html[data-theme="light"] .codehilite .err { border: 1px solid #FF0000 } /* Error */
html[data-theme="light"] .codehilite .k { color: #007020; font-weight: bold } /* Keyword */
html[data-theme="light"] .codehilite .o { color: #666666 } /* Operator */
html[data-theme="light"] .codehilite .ch { color: #60a0b0; font-style: italic } /* Comment.Hashbang */
html[data-theme="light"] .codehilite .cm { color: #60a0b0; font-style: italic } /* Comment.Multiline */
html[data-theme="light"] .codehilite .cp { color: #007020 } /* Comment.Preproc */
html[data-theme="light"] .codehilite .cpf { color: #60a0b0; font-style: italic } /* Comment.PreprocFile */
html[data-theme="light"] .codehilite .c1 { color: #60a0b0; font-style: italic } /* Comment.Single */
html[data-theme="light"] .codehilite .cs { color: #60a0b0; background-color: #fff0f0 } /* Comment.Special */
html[data-theme="light"] .codehilite .gd { color: #A00000 } /* Generic.Deleted */
html[data-theme="light"] .codehilite .ge { font-style: italic } /* Generic.Emph */
html[data-theme="light"] .codehilite .gr { color: #FF0000 } /* Generic.Error */
html[data-theme="light"] .codehilite .gh { color: #000080; font-weight: bold } /* Generic.Heading */
html[data-theme="light"] .codehilite .gi { color: #00A000 } /* Generic.Inserted */
html[data-theme="light"] .codehilite .go { color: #888888 } /* Generic.Output */
html[data-theme="light"] .codehilite .gp { color: #c65d09; font-weight: bold } /* Generic.Prompt */
html[data-theme="light"] .codehilite .gs { font-weight: bold } /* Generic.Strong */
html[data-theme="light"] .codehilite .gu { color: #800080; font-weight: bold } /* Generic.Subheading */
html[data-theme="light"] .codehilite .gt { color: #0044DD } /* Generic.Traceback */
html[data-theme="light"] .codehilite .kc { color: #007020; font-weight: bold } /* Keyword.Constant */
html[data-theme="light"] .codehilite .kd { color: #007020; font-weight: bold } /* Keyword.Declaration */
html[data-theme="light"] .codehilite .kn { color: #007020; font-weight: bold } /* Keyword.Namespace */
html[data-theme="light"] .codehilite .kp { color: #007020 } /* Keyword.Pseudo */
html[data-theme="light"] .codehilite .kr { color: #007020; font-weight: bold } /* Keyword.Reserved */
html[data-theme="light"] .codehilite .kt { color: #902000 } /* Keyword.Type */
html[data-theme="light"] .codehilite .m { color: #40a070 } /* Literal.Number */
html[data-theme="light"] .codehilite .s { color: #4070a0 } /* Literal.String */
html[data-theme="light"] .codehilite .na { color: #4070a0 } /* Name.Attribute */
html[data-theme="light"] .codehilite .nb { color: #007020 } /* Name.Builtin */
html[data-theme="light"] .codehilite .nc { color: #0e84b5; font-weight: bold } /* Name.Class */
html[data-theme="light"] .codehilite .no { color: #60add5 } /* Name.Constant */
html[data-theme="light"] .codehilite .nd { color: #555555; font-weight: bold } /* Name.Decorator */
html[data-theme="light"] .codehilite .ni { color: #d55537; font-weight: bold } /* Name.Entity */
html[data-theme="light"] .codehilite .ne { color: #007020 } /* Name.Exception */
html[data-theme="light"] .codehilite .nf { color: #06287e } /* Name.Function */
html[data-theme="light"] .codehilite .nl { color: #002070; font-weight: bold } /* Name.Label */
html[data-theme="light"] .codehilite .nn { color: #0e84b5; font-weight: bold } /* Name.Namespace */
html[data-theme="light"] .codehilite .nt { color: #062873; font-weight: bold } /* Name.Tag */
html[data-theme="light"] .codehilite .nv { color: #bb60d5 } /* Name.Variable */
html[data-theme="light"] .codehilite .ow { color: #007020; font-weight: bold } /* Operator.Word */
html[data-theme="light"] .codehilite .w { color: #bbbbbb } /* Text.Whitespace */
html[data-theme="light"] .codehilite .mb { color: #40a070 } /* Literal.Number.Bin */
html[data-theme="light"] .codehilite .mf { color: #40a070 } /* Literal.Number.Float */
html[data-theme="light"] .codehilite .mh { color: #40a070 } /* Literal.Number.Hex */
html[data-theme="light"] .codehilite .mi { color: #40a070 } /* Literal.Number.Integer */
html[data-theme="light"] .codehilite .mo { color: #40a070 } /* Literal.Number.Oct */
html[data-theme="light"] .codehilite .sa { color: #4070a0 } /* Literal.String.Affix */
html[data-theme="light"] .codehilite .sb { color: #4070a0 } /* Literal.String.Backtick */
html[data-theme="light"] .codehilite .sc { color: #4070a0 } /* Literal.String.Char */
html[data-theme="light"] .codehilite .dl { color: #4070a0 } /* Literal.String.Delimiter */
html[data-theme="light"] .codehilite .sd { color: #4070a0; font-style: italic } /* Literal.String.Doc */
html[data-theme="light"] .codehilite .s2 { color: #4070a0 } /* Literal.String.Double */
html[data-theme="light"] .codehilite .se { color: #4070a0; font-weight: bold } /* Literal.String.Escape */
html[data-theme="light"] .codehilite .sh { color: #4070a0 } /* Literal.String.Heredoc */
html[data-theme="light"] .codehilite .si { color: #70a0d0; font-style: italic } /* Literal.String.Interpol */
html[data-theme="light"] .codehilite .sx { color: #c65d09 } /* Literal.String.Other */
html[data-theme="light"] .codehilite .sr { color: #235388 } /* Literal.String.Regex */
html[data-theme="light"] .codehilite .s1 { color: #4070a0 } /* Literal.String.Single */
html[data-theme="light"] .codehilite .ss { color: #517918 } /* Literal.String.Symbol */
html[data-theme="light"] .codehilite .bp { color: #007020 } /* Name.Builtin.Pseudo */
html[data-theme="light"] .codehilite .fm { color: #06287e } /* Name.Function.Magic */
html[data-theme="light"] .codehilite .vc { color: #bb60d5 } /* Name.Variable.Class */
html[data-theme="light"] .codehilite .vg { color: #bb60d5 } /* Name.Variable.Global */
html[data-theme="light"] .codehilite .vi { color: #bb60d5 } /* Name.Variable.Instance */
html[data-theme="light"] .codehilite .vm { color: #bb60d5 } /* Name.Variable.Magic */
html[data-theme="light"] .codehilite .il { color: #40a070 } /* Literal.Number.Integer.Long */

/* Dark Theme Syntax Highlighting */
html[data-theme="dark"] .codehilite .hll { background-color: #49483e }
html[data-theme="dark"] .codehilite .c { color: #959077 } /* Comment */
html[data-theme="dark"] .codehilite .err { color: #ed007e; background-color: #1e0010 } /* Error */
html[data-theme="dark"] .codehilite .k { color: #66d9ef } /* Keyword */
html[data-theme="dark"] .codehilite .l { color: #ae81ff } /* Literal */
html[data-theme="dark"] .codehilite .n { color: #f8f8f2 } /* Name */
html[data-theme="dark"] .codehilite .o { color: #ff4689 } /* Operator */
html[data-theme="dark"] .codehilite .p { color: #f8f8f2 } /* Punctuation */
html[data-theme="dark"] .codehilite .ch { color: #959077 } /* Comment.Hashbang */
html[data-theme="dark"] .codehilite .cm { color: #959077 } /* Comment.Multiline */
html[data-theme="dark"] .codehilite .cp { color: #959077 } /* Comment.Preproc */
html[data-theme="dark"] .codehilite .cpf { color: #959077 } /* Comment.PreprocFile */
html[data-theme="dark"] .codehilite .c1 { color: #959077 } /* Comment.Single */
html[data-theme="dark"] .codehilite .cs { color: #959077 } /* Comment.Special */
html[data-theme="dark"] .codehilite .gd { color: #ff4689 } /* Generic.Deleted */
html[data-theme="dark"] .codehilite .ge { font-style: italic } /* Generic.Emph */
html[data-theme="dark"] .codehilite .gr { color: #f8f8f2 } /* Generic.Error */
html[data-theme="dark"] .codehilite .gh { color: #f8f8f2 } /* Generic.Heading */
html[data-theme="dark"] .codehilite .gi { color: #a6e22e } /* Generic.Inserted */
html[data-theme="dark"] .codehilite .go { color: #66d9ef } /* Generic.Output */
html[data-theme="dark"] .codehilite .gp { color: #ff4689; font-weight: bold } /* Generic.Prompt */
html[data-theme="dark"] .codehilite .gs { font-weight: bold } /* Generic.Strong */
html[data-theme="dark"] .codehilite .gu { color: #959077 } /* Generic.Subheading */
html[data-theme="dark"] .codehilite .gt { color: #f8f8f2 } /* Generic.Traceback */
html[data-theme="dark"] .codehilite .kc { color: #66d9ef } /* Keyword.Constant */
html[data-theme="dark"] .codehilite .kd { color: #66d9ef } /* Keyword.Declaration */
html[data-theme="dark"] .codehilite .kn { color: #ff4689 } /* Keyword.Namespace */
html[data-theme="dark"] .codehilite .kp { color: #66d9ef } /* Keyword.Pseudo */
html[data-theme="dark"] .codehilite .kr { color: #66d9ef } /* Keyword.Reserved */
html[data-theme="dark"] .codehilite .kt { color: #66d9ef } /* Keyword.Type */
html[data-theme="dark"] .codehilite .ld { color: #e6db74 } /* Literal.Date */
html[data-theme="dark"] .codehilite .m { color: #ae81ff } /* Literal.Number */
html[data-theme="dark"] .codehilite .s { color: #e6db74 } /* Literal.String */
html[data-theme="dark"] .codehilite .na { color: #a6e22e } /* Name.Attribute */
html[data-theme="dark"] .codehilite .nb { color: #f8f8f2 } /* Name.Builtin */
html[data-theme="dark"] .codehilite .nc { color: #a6e22e } /* Name.Class */
html[data-theme="dark"] .codehilite .no { color: #66d9ef } /* Name.Constant */
html[data-theme="dark"] .codehilite .nd { color: #a6e22e } /* Name.Decorator */
html[data-theme="dark"] .codehilite .ni { color: #f8f8f2 } /* Name.Entity */
html[data-theme="dark"] .codehilite .ne { color: #a6e22e } /* Name.Exception */
html[data-theme="dark"] .codehilite .nf { color: #a6e22e } /* Name.Function */
html[data-theme="dark"] .codehilite .nl { color: #f8f8f2 } /* Name.Label */
html[data-theme="dark"] .codehilite .nn { color: #f8f8f2 } /* Name.Namespace */
html[data-theme="dark"] .codehilite .nx { color: #a6e22e } /* Name.Other */
html[data-theme="dark"] .codehilite .py { color: #f8f8f2 } /* Name.Property */
html[data-theme="dark"] .codehilite .nt { color: #ff4689 } /* Name.Tag */
html[data-theme="dark"] .codehilite .nv { color: #f8f8f2 } /* Name.Variable */
html[data-theme="dark"] .codehilite .ow { color: #ff4689 } /* Operator.Word */
html[data-theme="dark"] .codehilite .w { color: #f8f8f2 } /* Text.Whitespace */
html[data-theme="dark"] .codehilite .mb { color: #ae81ff } /* Literal.Number.Bin */
html[data-theme="dark"] .codehilite .mf { color: #ae81ff } /* Literal.Number.Float */
html[data-theme="dark"] .codehilite .mh { color: #ae81ff } /* Literal.Number.Hex */
html[data-theme="dark"] .codehilite .mi { color: #ae81ff } /* Literal.Number.Integer */
html[data-theme="dark"] .codehilite .mo { color: #ae81ff } /* Literal.Number.Oct */
html[data-theme="dark"] .codehilite .sa { color: #e6db74 } /* Literal.String.Affix */
html[data-theme="dark"] .codehilite .sb { color: #e6db74 } /* Literal.String.Backtick */
html[data-theme="dark"] .codehilite .sc { color: #e6db74 } /* Literal.String.Char */
html[data-theme="dark"] .codehilite .dl { color: #e6db74 } /* Literal.String.Delimiter */
html[data-theme="dark"] .codehilite .sd { color: #e6db74 } /* Literal.String.Doc */
html[data-theme="dark"] .codehilite .s2 { color: #e6db74 } /* Literal.String.Double */
html[data-theme="dark"] .codehilite .se { color: #ae81ff } /* Literal.String.Escape */
html[data-theme="dark"] .codehilite .sh { color: #e6db74 } /* Literal.String.Heredoc */
html[data-theme="dark"] .codehilite .si { color: #e6db74 } /* Literal.String.Interpol */
html[data-theme="dark"] .codehilite .sx { color: #e6db74 } /* Literal.String.Other */
html[data-theme="dark"] .codehilite .sr { color: #e6db74 } /* Literal.String.Regex */
html[data-theme="dark"] .codehilite .s1 { color: #e6db74 } /* Literal.String.Single */
html[data-theme="dark"] .codehilite .ss { color: #e6db74 } /* Literal.String.Symbol */
html[data-theme="dark"] .codehilite .bp { color: #f8f8f2 } /* Name.Builtin.Pseudo */
html[data-theme="dark"] .codehilite .fm { color: #a6e22e } /* Name.Function.Magic */
html[data-theme="dark"] .codehilite .vc { color: #f8f8f2 } /* Name.Variable.Class */
html[data-theme="dark"] .codehilite .vg { color: #f8f8f2 } /* Name.Variable.Global */
html[data-theme="dark"] .codehilite .vi { color: #f8f8f2 } /* Name.Variable.Instance */
html[data-theme="dark"] .codehilite .vm { color: #f8f8f2 } /* Name.Variable.Magic */
html[data-theme="dark"] .codehilite .il { color: #ae81ff } /* Literal.Number.Integer.Long */
