:root {
  --bg: #f6f2e9;
  --bg-elevated: #fffdf8;
  --bg-subtle: #ede6d6;
  --bg-code: #232d4b;
  --bg-code-inline: rgba(52, 74, 126, 0.09);
  --border: rgba(52, 74, 126, 0.14);
  --border-strong: rgba(52, 74, 126, 0.26);
  --text: #223052;
  --text-strong: #172340;
  --text-muted: #56668c;
  --brand: #344a7e;
  --accent: #b842be;
  --accent-bright: #de78e2;
  --accent-soft: rgba(222, 120, 226, 0.14);
  --shadow: 0 1px 2px rgba(23, 35, 64, 0.05), 0 8px 24px rgba(23, 35, 64, 0.06);
  --radius: 12px;
  --radius-sm: 8px;
  --header-h: 64px;
  --sidebar-w: 272px;
  --toc-w: 236px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

:root[data-theme="dark"] {
  --bg: #131b2e;
  --bg-elevated: #1a243d;
  --bg-subtle: #202c49;
  --bg-code: #0e1424;
  --bg-code-inline: rgba(246, 242, 233, 0.1);
  --border: rgba(246, 242, 233, 0.11);
  --border-strong: rgba(246, 242, 233, 0.22);
  --text: #e6e0d3;
  --text-strong: #f6f2e9;
  --text-muted: #9aa7c7;
  --brand: #f6f2e9;
  --accent: #e699ea;
  --accent-bright: #de78e2;
  --accent-soft: rgba(222, 120, 226, 0.18);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.25), 0 10px 28px rgba(0, 0, 0, 0.3);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 24px);
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.68;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

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

a:hover {
  text-decoration: underline;
}

/* Theme-switched brand assets */
.only-dark {
  display: none;
}
:root[data-theme="dark"] .only-light {
  display: none;
}
:root[data-theme="dark"] .only-dark {
  display: inline-block;
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 24px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text-strong);
  font-weight: 700;
  text-decoration: none;
}

.brand-link:hover {
  text-decoration: none;
}

.brand-link img {
  height: 30px;
  width: auto;
  display: block;
}

.brand-badge {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.search-trigger {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
  min-width: 200px;
  justify-content: space-between;
  transition: border-color 0.15s ease;
}

.search-trigger:hover {
  border-color: var(--border-strong);
  color: var(--text);
}

.search-trigger kbd {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 5px;
  background: var(--bg-subtle);
  color: var(--text-muted);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.icon-btn:hover {
  border-color: var(--border-strong);
  background: var(--bg-subtle);
}

.menu-btn {
  display: none;
}

/* Docs shell */
.docs-layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--toc-w);
  max-width: 1440px;
  margin: 0 auto;
  min-height: calc(100vh - var(--header-h));
}

.sidebar {
  position: sticky;
  top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
  padding: 24px 16px 40px 24px;
  border-right: 1px solid var(--border);
}

.nav-group {
  margin-bottom: 22px;
}

.nav-group-title {
  margin: 0 0 8px 10px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-link {
  display: block;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 14.5px;
  color: var(--text);
  transition: background 0.12s ease, color 0.12s ease;
}

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

.nav-link.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

/* Main content */
.doc-main {
  min-width: 0;
  padding: 36px 48px 72px;
  max-width: 860px;
  width: 100%;
  margin: 0 auto;
}

.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.breadcrumbs a {
  color: var(--text-muted);
}

.breadcrumbs a:hover {
  color: var(--accent);
}

.prose h1 {
  font-size: clamp(1.9rem, 3vw, 2.4rem);
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin: 0 0 14px;
  color: var(--text-strong);
}

.prose .lead {
  font-size: 1.08rem;
  color: var(--text-muted);
  margin: 0 0 28px;
}

.prose h2 {
  font-size: 1.45rem;
  line-height: 1.3;
  letter-spacing: -0.015em;
  margin: 40px 0 14px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  color: var(--text-strong);
}

.prose h3 {
  font-size: 1.15rem;
  line-height: 1.35;
  margin: 28px 0 10px;
  color: var(--text-strong);
}

.prose p {
  margin: 0 0 16px;
}

.prose ul,
.prose ol {
  margin: 0 0 18px;
  padding-left: 24px;
}

.prose li {
  margin-bottom: 6px;
}

.prose li strong {
  color: var(--text-strong);
}

.prose blockquote {
  margin: 20px 0;
  padding: 12px 18px;
  border-left: 3px solid var(--accent-bright);
  background: var(--bg-elevated);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-muted);
}

.prose blockquote p:last-child {
  margin-bottom: 0;
}

.prose code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  padding: 0.15em 0.4em;
  border-radius: 5px;
  background: var(--bg-code-inline);
  color: var(--text-strong);
}

.code-block {
  position: relative;
  margin: 20px 0;
  border-radius: var(--radius);
  background: var(--bg-code);
  border: 1px solid rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.code-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: #9aa7c7;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.copy-btn {
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: transparent;
  color: #cbd5f0;
  font-family: var(--font-sans);
  font-size: 12px;
  padding: 3px 9px;
  border-radius: 6px;
  cursor: pointer;
}

.copy-btn:hover {
  background: rgba(255, 255, 255, 0.08);
}

.code-block pre {
  margin: 0;
  padding: 16px 18px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 13.5px;
  line-height: 1.6;
  color: #eef1f8;
}

.code-block pre code {
  background: transparent;
  padding: 0;
  color: inherit;
  font-size: inherit;
}

/* Syntax highlight tokens */
.tok-kw { color: #e699ea; }
.tok-str { color: #9ee0b8; }
.tok-com { color: #7e8db3; font-style: italic; }
.tok-num { color: #f6c177; }
.tok-type { color: #8ecae6; }

/* Tables */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  margin: 20px 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elevated);
}

.prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14.5px;
}

.prose th,
.prose td {
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.prose th {
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: color-mix(in srgb, var(--bg-subtle) 55%, transparent);
}

.prose tr:last-child td {
  border-bottom: none;
}

/* Prev / Next */
.doc-pager {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 52px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.pager-link {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  color: var(--text-strong);
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.pager-link:hover {
  border-color: var(--accent-bright);
  text-decoration: none;
  transform: translateY(-1px);
}

.pager-link.next {
  text-align: right;
}

.pager-label {
  font-size: 12px;
  color: var(--text-muted);
}

.pager-title {
  font-weight: 600;
  color: var(--accent);
}

/* Right TOC */
.toc {
  position: sticky;
  top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
  padding: 36px 20px 40px 16px;
}

.toc-title {
  margin: 0 0 12px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

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

.toc-item a {
  display: block;
  padding: 4px 0 4px 12px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--text-muted);
  border-left: 2px solid transparent;
  margin-left: -1px;
}

.toc-item.depth-3 a {
  padding-left: 22px;
}

.toc-item a:hover,
.toc-item a.active {
  color: var(--accent);
  border-left-color: var(--accent-bright);
  text-decoration: none;
}

/* Home Landing Page */
.home-container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 56px 24px 80px;
}

.hero {
  display: grid;
  grid-template-columns: 1.25fr 0.75fr;
  gap: 36px;
  align-items: center;
  padding: 44px;
  border-radius: 20px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  margin-bottom: 44px;
}

.hero-eyebrow {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 12px;
}

.hero h1 {
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 1.12;
  letter-spacing: -0.025em;
  margin: 0 0 16px;
  color: var(--text-strong);
}

.hero p {
  font-size: 1.08rem;
  color: var(--text-muted);
  margin: 0 0 26px;
  max-width: 56ch;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 18px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 15px;
  text-decoration: none;
  transition: transform 0.12s ease, opacity 0.12s ease;
}

.btn:hover {
  text-decoration: none;
  transform: translateY(-1px);
}

.btn-primary {
  background: #344a7e;
  color: #f6f2e9;
}

:root[data-theme="dark"] .btn-primary {
  background: #de78e2;
  color: #131b2e;
}

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

.hero-art {
  display: flex;
  justify-content: center;
  align-items: center;
}

.hero-art img {
  width: 210px;
  height: auto;
}

.hero-meta {
  margin: 20px 0 0 !important;
  font-size: 13.5px !important;
  color: var(--text-muted);
}

.landing-nav {
  display: flex;
  align-items: center;
  gap: 22px;
  font-size: 14.5px;
  font-weight: 500;
}

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

.landing-nav a:hover {
  color: var(--accent);
  text-decoration: none;
}

.landing-section {
  margin-top: 64px;
}

.section-heading {
  margin-bottom: 24px;
}

.section-heading h2 {
  font-size: clamp(1.5rem, 2.8vw, 2rem);
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin: 0 0 10px;
  color: var(--text-strong);
}

.section-heading p {
  margin: 0;
  color: var(--text-muted);
  max-width: 60ch;
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.feature-card {
  padding: 26px;
  border-radius: var(--radius);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.feature-card h3 {
  margin: 0;
  font-size: 1.15rem;
  color: var(--text-strong);
}

.feature-card p {
  margin: 0;
  font-size: 15px;
  color: var(--text-muted);
  flex: 1;
}

.feature-card a {
  font-size: 14.5px;
  font-weight: 600;
}

.layer-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.layer-card {
  padding: 22px;
  border-radius: var(--radius);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.layer-tag {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
}

.crate-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  flex: 1;
  align-content: flex-start;
}

.crate-pills code {
  font-family: var(--font-mono);
  font-size: 12.5px;
  padding: 4px 8px;
  border-radius: 6px;
  background: var(--bg-subtle);
  color: var(--text-strong);
}

.layer-card a {
  font-size: 14px;
  font-weight: 600;
}

.quickstart-box {
  display: grid;
  grid-template-columns: 1fr 1.1fr;
  gap: 28px;
  align-items: center;
  padding: 36px;
  border-radius: 18px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.quickstart-box h2 {
  font-size: clamp(1.4rem, 2.5vw, 1.85rem);
  line-height: 1.22;
  margin: 0 0 12px;
  color: var(--text-strong);
}

.quickstart-box p {
  margin: 0 0 22px;
  color: var(--text-muted);
}

@media (max-width: 860px) {
  .landing-nav {
    display: none;
  }
  .feature-grid,
  .layer-grid,
  .quickstart-box {
    grid-template-columns: 1fr;
  }
  .quickstart-box {
    padding: 24px;
  }
}

.section-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 18px;
  margin-bottom: 48px;
}

.section-card {
  padding: 22px;
  border-radius: var(--radius);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.section-card h2 {
  margin: 0;
  font-size: 1.1rem;
  color: var(--text-strong);
}

.section-card ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.section-card li a {
  display: block;
  font-weight: 500;
  color: var(--accent);
}

.section-card li span {
  display: block;
  font-size: 13.5px;
  color: var(--text-muted);
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 28px 24px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 1440px;
  margin: 0 auto;
  font-size: 13.5px;
  color: var(--text-muted);
}

.site-footer img {
  height: 26px;
}

/* 404 */
.not-found {
  max-width: 560px;
  margin: 80px auto;
  padding: 0 24px;
  text-align: center;
}

.not-found img {
  width: 140px;
  margin-bottom: 16px;
}

/* Search Modal */
.search-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 10vh 16px 24px;
  background: rgba(14, 20, 36, 0.55);
  backdrop-filter: blur(4px);
}

.search-modal.open {
  display: flex;
}

.search-dialog {
  width: 100%;
  max-width: 600px;
  border-radius: 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.35);
  overflow: hidden;
}

.search-input-wrap {
  display: flex;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  gap: 10px;
}

.search-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text-strong);
  font-family: inherit;
  font-size: 16px;
}

.search-results {
  max-height: 60vh;
  overflow-y: auto;
  padding: 8px;
}

.search-result {
  display: block;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text);
}

.search-result:hover,
.search-result.selected {
  background: var(--accent-soft);
  text-decoration: none;
}

.search-result-title {
  font-weight: 600;
  color: var(--text-strong);
}

.search-result-meta {
  font-size: 12px;
  color: var(--accent);
}

.search-result-snippet {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}

.search-empty {
  padding: 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}

/* Responsive */
@media (max-width: 1180px) {
  .docs-layout {
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  }
  .toc {
    display: none;
  }
}

@media (max-width: 860px) {
  .docs-layout {
    grid-template-columns: minmax(0, 1fr);
  }
  .menu-btn {
    display: inline-flex;
  }
  .sidebar {
    position: fixed;
    top: var(--header-h);
    left: 0;
    bottom: 0;
    width: min(300px, 86vw);
    z-index: 50;
    background: var(--bg);
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: var(--shadow);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .doc-main {
    padding: 24px 20px 56px;
  }
  .hero {
    grid-template-columns: 1fr;
    padding: 28px;
  }
  .hero-art {
    order: -1;
  }
  .search-trigger {
    min-width: auto;
  }
  .search-trigger .search-label,
  .search-trigger kbd {
    display: none;
  }
  .doc-pager {
    grid-template-columns: 1fr;
  }
}
