:root {
  --bg: #ffffff;
  --bg-subtle: #f8fafc;
  --surface: #f1f5f9;
  --border: #cbd5e1;
  --text: #0f172a;
  --text-muted: #475569;
  --accent: #3730a3;
  --accent-hover: #312e81;
  --accent-bg: #e0e7ff;
  --code-bg: #f1f5f9;
  --focus: #4338ca;
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #020617;
    --bg-subtle: #0f172a;
    --surface: #1e293b;
    --border: #334155;
    --text: #f8fafc;
    --text-muted: #cbd5e1;
    --accent: #a5b4fc;
    --accent-hover: #c7d2fe;
    --accent-bg: #1e1b4b;
    --code-bg: #0f172a;
    --focus: #818cf8;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { font-family: var(--font-sans); background: var(--bg); color: var(--text); line-height: 1.6; }
body { margin: 0; min-height: 100vh; display: flex; flex-direction: column; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}

a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: #ffffff;
  padding: 0.6rem 1rem;
  font-weight: 600;
  z-index: 100;
}
@media (prefers-color-scheme: dark) {
  .skip-link { color: #020617; }
}
.skip-link:focus { left: 0.75rem; top: 0.75rem; }

.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--bg-subtle);
  padding: 0.75rem 1rem;
}
.header-inner {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
  text-decoration: none;
}
.version-badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: var(--accent-bg);
  color: var(--accent);
}
.header-nav-desktop { display: flex; align-items: center; gap: 1rem; }
.header-nav-desktop a { text-decoration: none; font-weight: 500; color: var(--text); }
.header-nav-desktop a:hover { color: var(--accent); text-decoration: underline; }
.header-nav-desktop a.demo-cta {
  background: var(--accent);
  color: #ffffff;
  padding: 0.35rem 0.75rem;
  border-radius: 0.5rem;
  font-weight: 600;
}
@media (prefers-color-scheme: dark) {
  .header-nav-desktop a.demo-cta { color: #020617; }
}
.mobile-menu { display: none; }
.mobile-menu summary {
  cursor: pointer;
  list-style: none;
  padding: 0.35rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  font-weight: 600;
  color: var(--text);
}
.mobile-menu[open] .mobile-menu-panel {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.5rem;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: var(--bg);
}

.layout {
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr) 210px;
  gap: 2rem;
  flex: 1;
}
.layout.layout-landing {
  grid-template-columns: minmax(0, 1fr);
  max-width: 980px;
}

.sidebar { font-size: 0.9rem; }
.sidebar-group { margin-bottom: 1.25rem; }
.sidebar-group-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin: 0 0 0.4rem;
}
.sidebar ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.35rem; }
.sidebar a {
  display: block;
  padding: 0.35rem 0.5rem;
  min-height: 28px;
  border-radius: 0.375rem;
  text-decoration: none;
  color: var(--text);
}
.sidebar a:hover { background: var(--surface); }
.sidebar a[aria-current="page"] { background: var(--accent-bg); color: var(--accent); font-weight: 600; }

.toc { font-size: 0.85rem; }
.toc-title { font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); margin: 0 0 0.5rem; }
.toc ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.4rem; }
.toc a { display: inline-block; padding: 0.15rem 0; min-height: 24px; text-decoration: none; color: var(--text-muted); }
.toc a:hover { color: var(--accent); text-decoration: underline; }
.toc li.depth-3 { padding-left: 0.75rem; }

.breadcrumb { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 1rem; }
.breadcrumb ol { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 0.4rem; }
.breadcrumb li::after { content: "/"; margin-left: 0.4rem; color: var(--border); }
.breadcrumb li:last-child::after { content: ""; margin: 0; }

main h1 { font-size: 2rem; line-height: 1.2; margin: 0 0 0.75rem; }
main h2 { font-size: 1.35rem; margin: 2rem 0 0.6rem; border-bottom: 1px solid var(--border); padding-bottom: 0.25rem; }
main h3 { font-size: 1.1rem; margin: 1.4rem 0 0.4rem; }
main p { margin: 0.75rem 0; }
main img { max-width: 100%; height: auto; border-radius: 0.5rem; border: 1px solid var(--border); display: block; margin: 1rem 0; }
main code { font-family: var(--font-mono); font-size: 0.88em; background: var(--code-bg); padding: 0.1rem 0.3rem; border-radius: 0.25rem; overflow-wrap: anywhere; }
main a { overflow-wrap: anywhere; }
main pre { background: var(--code-bg); border: 1px solid var(--border); padding: 0.9rem 1rem; border-radius: 0.5rem; overflow-x: auto; }
main pre code { background: none; padding: 0; font-size: 0.85rem; }
.table-wrap { overflow-x: auto; margin: 1rem 0; }
table { border-collapse: collapse; width: 100%; font-size: 0.9rem; }
th, td { border: 1px solid var(--border); padding: 0.5rem 0.65rem; text-align: left; vertical-align: top; }
th { background: var(--surface); font-weight: 600; }

.lead { font-size: 1.05rem; color: var(--text-muted); margin-top: 0; }

.search-box { margin: 1.25rem 0 1.75rem; }
.search-box label { display: block; font-weight: 600; margin-bottom: 0.35rem; }
.search-box input {
  width: 100%;
  max-width: 560px;
  padding: 0.6rem 0.85rem;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: var(--bg);
  color: var(--text);
}
.search-status { font-size: 0.85rem; color: var(--text-muted); margin-top: 0.4rem; min-height: 1.25rem; }
.search-results { list-style: none; padding: 0; margin: 0.5rem 0 0; max-width: 640px; display: flex; flex-direction: column; gap: 0.5rem; }
.search-results a {
  display: block;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: var(--bg-subtle);
  text-decoration: none;
  color: var(--text);
}
.search-results a:hover { border-color: var(--accent); }
.search-results .res-title { font-weight: 600; color: var(--accent); display: block; }
.search-results .res-snippet { font-size: 0.85rem; color: var(--text-muted); display: block; margin-top: 0.15rem; }

.entry-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
}
.entry-card {
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 1rem 1.1rem;
  background: var(--bg-subtle);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.entry-card h2 { margin: 0; border: none; padding: 0; font-size: 1.15rem; }
.entry-card p { margin: 0; font-size: 0.9rem; color: var(--text-muted); }
.entry-card ul { margin: 0.25rem 0 0.5rem; padding-left: 1.1rem; font-size: 0.9rem; display: flex; flex-direction: column; gap: 0.35rem; }
.entry-card ul a { display: inline-block; padding: 0.15rem 0; min-height: 24px; }
.entry-card .all-pages { margin-top: auto; font-size: 0.88rem; font-weight: 600; display: inline-block; padding: 0.2rem 0; min-height: 24px; }

.section-list { list-style: none; padding: 0; margin: 1.25rem 0; display: flex; flex-direction: column; gap: 0.85rem; }
.section-list li { border: 1px solid var(--border); border-radius: 0.5rem; padding: 0.85rem 1rem; background: var(--bg-subtle); }
.section-list a { font-weight: 600; font-size: 1.02rem; }
.section-list p { margin: 0.25rem 0 0; font-size: 0.9rem; color: var(--text-muted); }

.page-meta {
  margin-top: 2.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.site-footer {
  border-top: 1px solid var(--border);
  background: var(--bg-subtle);
  padding: 1.25rem 1rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}
.footer-inner {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}
.footer-links { display: flex; gap: 1rem; flex-wrap: wrap; }

@media (max-width: 1024px) {
  .layout { grid-template-columns: 220px minmax(0, 1fr); }
  .toc { display: none; }
}
@media (max-width: 760px) {
  .header-nav-desktop { display: none; }
  .mobile-menu { display: block; }
  .layout { grid-template-columns: minmax(0, 1fr); gap: 1.25rem; }
  .sidebar { order: 2; border-top: 1px solid var(--border); padding-top: 1rem; }
}
