/* ─── Base ─────────────────────────────────────────────────────────────────── */

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Inter, sans-serif;
  color: var(--text);
  background: var(--bg-page);
  line-height: 1.5;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -4;
  background: linear-gradient(180deg, var(--bg-grad-start) 0%, var(--bg-grad-end) 100%);
}

/* ─── Header ────────────────────────────────────────────────────────────────── */

header {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid var(--border-soft);
  background: var(--surface-3);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.nav {
  height: 74px;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}

.brand img {
  width: 52px;
  height: 52px;
  border-radius: 10px;
  filter: var(--logo-filter);
  background: var(--logo-bg);
  border: 1px solid var(--logo-border);
  padding: 6px;
}

.brand-sep {
  width: 1px;
  height: 18px;
  background: var(--border-mid);
  margin: 0 2px;
}

.brand-section {
  font-weight: 500;
  color: var(--muted);
  font-size: 14px;
}

.nav-search {
  flex: 1;
  max-width: 380px;
  margin-left: 16px;
}

.search-box {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  background: var(--surface-1);
  padding: 6px 12px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  transition: border-color .2s ease;
}

.search-box:hover { border-color: var(--border-mid); }

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

.search-box input::placeholder { color: var(--muted); }

.search-kbd {
  font-size: 11px;
  color: var(--muted);
  border: 1px solid var(--border-mid);
  border-radius: 4px;
  padding: 1px 5px;
  font-family: inherit;
  background: var(--surface-2);
  margin-left: auto;
}

.search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  display: none;
  max-height: 420px;
  overflow: auto;
  border: 1px solid var(--border-mid);
  border-radius: 10px;
  background: var(--surface-2);
  opacity: 1;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.30);
  z-index: 200;
  padding: 6px;
}

.search-results.is-open {
  display: block;
}

.search-result-item {
  display: block;
  padding: 10px 10px;
  border-radius: 8px;
  color: inherit;
  text-decoration: none;
}

.search-result-item:hover {
  background: var(--surface-2);
}

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

.search-result-meta {
  margin-top: 2px;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.search-result-summary {
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}

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

.title-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.title-row h1 {
  margin-bottom: 0;
}

.llm-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  border: 1px solid var(--border-mid);
  background: var(--surface-1);
  color: var(--muted);
  text-decoration: none;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .03em;
}

.llm-link:hover {
  color: var(--text);
  border-color: var(--border-strong);
}

.llm-end-link {
  margin-top: 22px;
}

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

.nav-link {
  font-size: 13px;
  color: var(--nav-link);
  text-decoration: none;
  transition: color .2s ease;
}

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

.btn {
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 13px;
  line-height: 1;
  font-weight: 600;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: transform .2s ease;
}

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

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

.btn-ghost {
  border-color: var(--border-strong);
  color: var(--btn-secondary-text);
  background: var(--surface-1);
}

/* ─── Docs layout ───────────────────────────────────────────────────────────── */

.docs-wrap {
  display: grid;
  grid-template-columns: 256px 1fr;
  min-height: calc(100vh - 75px);
}

.docs-with-toc {
  grid-template-columns: 256px 1fr 220px;
}

/* ─── Left sidebar ──────────────────────────────────────────────────────────── */

.docs-sidebar {
  position: sticky;
  top: 75px;
  height: calc(100vh - 75px);
  overflow-y: auto;
  border-right: 1px solid var(--border-soft);
  padding: 24px 0 40px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-mid) transparent;
  flex-shrink: 0;
}

.docs-sidebar::-webkit-scrollbar { width: 4px; }
.docs-sidebar::-webkit-scrollbar-thumb { background: var(--border-mid); border-radius: 4px; }

.docs-nav-group {
  margin-bottom: 4px;
}

.docs-nav-group-label {
  display: block;
  padding: 14px 20px 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
  user-select: none;
}

.docs-nav-link {
  display: block;
  padding: 5px 20px;
  font-size: 13.5px;
  color: var(--nav-link);
  text-decoration: none;
  line-height: 1.45;
  position: relative;
  border-radius: 0;
  transition: color .15s ease, background .15s ease;
}

.docs-nav-link:hover {
  color: var(--nav-link-hover);
  background: var(--surface-1);
}

.docs-nav-link.is-active {
  color: var(--accent);
  font-weight: 500;
}

.docs-nav-link.is-active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 2px;
  bottom: 2px;
  width: 2px;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
}

.docs-nav-sub {
  margin-left: 16px;
  padding-left: 12px;
  border-left: 1px solid var(--border-soft);
}

.docs-nav-sub .docs-nav-link {
  padding: 4px 12px;
  font-size: 13px;
}

/* ─── Content area ──────────────────────────────────────────────────────────── */

.docs-content {
  min-width: 0;
  padding: 40px 48px 80px;
}

.docs-breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 28px;
  font-size: 12px;
  color: var(--muted);
}

.docs-breadcrumb a {
  color: var(--muted);
  text-decoration: none;
  transition: color .15s ease;
}

.docs-breadcrumb a:hover { color: var(--nav-link-hover); }

.docs-breadcrumb-sep {
  opacity: 0.4;
}

/* ─── Prose (markdown content) ──────────────────────────────────────────────── */

.prose {
  max-width: 720px;
}

.prose h1 {
  font-size: clamp(26px, 3.5vw, 38px);
  margin: 0 0 12px;
  letter-spacing: -0.025em;
  line-height: 1.1;
  font-weight: 800;
}

.prose .page-meta {
  display: flex;
  gap: 14px;
  margin-bottom: 32px;
  font-size: 12px;
  color: var(--muted);
}

.prose h2 {
  font-size: 20px;
  font-weight: 700;
  margin: 44px 0 12px;
  letter-spacing: -0.015em;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-soft);
  scroll-margin-top: 80px;
}

.prose h3 {
  font-size: 16px;
  font-weight: 600;
  margin: 28px 0 8px;
  letter-spacing: -0.01em;
  scroll-margin-top: 80px;
}

.prose h4 {
  font-size: 14px;
  font-weight: 600;
  margin: 20px 0 6px;
  scroll-margin-top: 80px;
}

.prose p {
  margin: 0 0 16px;
  line-height: 1.75;
  color: var(--text);
  opacity: .88;
}

.prose a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: var(--accent-soft);
  text-underline-offset: 3px;
  transition: text-decoration-color .15s ease;
}

.prose a:hover { text-decoration-color: var(--accent); }

.prose ul, .prose ol {
  margin: 0 0 16px;
  padding-left: 22px;
}

.prose li {
  margin: 6px 0;
  line-height: 1.7;
  color: var(--text);
  opacity: .88;
}

.prose li p { margin: 0; }

.prose strong { font-weight: 600; color: var(--text); }

.prose blockquote {
  margin: 20px 0;
  padding: 12px 16px;
  border-left: 3px solid var(--accent);
  background: var(--surface-1);
  border-radius: 0 8px 8px 0;
  font-size: 14px;
  color: var(--muted);
}

.prose blockquote p { margin: 0; opacity: 1; }

.prose hr {
  border: 0;
  border-top: 1px solid var(--border-soft);
  margin: 36px 0;
}

/* ─── Code ──────────────────────────────────────────────────────────────────── */

.prose code {
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .85em;
  background: var(--surface-1);
  border: 1px solid var(--border-soft);
  color: var(--code-text);
  border-radius: 5px;
  padding: 1px 5px;
}

.prose pre {
  border: 1px solid var(--border-mid);
  background: var(--code-bg);
  border-radius: 12px;
  padding: 18px 20px;
  overflow-x: auto;
  margin: 20px 0;
  position: relative;
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13.5px;
  line-height: 1.65;
}

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

.prose .code-block {
  position: relative;
  margin: 20px 0;
}

.prose .code-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  border: 1px solid var(--border-mid);
  border-bottom: 0;
  border-radius: 12px 12px 0 0;
  background: var(--surface-2);
  font-size: 12px;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  color: var(--muted);
}

.prose .code-block-header + pre {
  margin-top: 0;
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

.copy-btn {
  border: 1px solid var(--border-soft);
  background: var(--surface-1);
  color: var(--muted);
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 11px;
  font-family: inherit;
  cursor: pointer;
  transition: color .15s ease, border-color .15s ease;
}

.copy-btn:hover {
  color: var(--nav-link-hover);
  border-color: var(--border-strong);
}

/* ─── Tables ────────────────────────────────────────────────────────────────── */

.prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 20px 0;
  font-size: 14px;
  display: block;
  overflow-x: auto;
}

.prose th {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-mid);
}

.prose td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: top;
  line-height: 1.5;
}

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

/* ─── Callout / admonition ──────────────────────────────────────────────────── */

.callout {
  display: flex;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 10px;
  margin: 20px 0;
  font-size: 14px;
  border: 1px solid;
}

.callout-note {
  background: rgba(59, 130, 246, 0.08);
  border-color: rgba(59, 130, 246, 0.3);
  color: var(--text);
}

.callout-warning {
  background: var(--eyebrow-bg);
  border-color: var(--accent-soft);
  color: var(--eyebrow-text);
}

.callout-danger {
  background: rgba(239, 68, 68, 0.08);
  border-color: rgba(239, 68, 68, 0.3);
  color: var(--text);
}

.callout-icon { font-size: 16px; flex-shrink: 0; }

.callout p { margin: 0; opacity: 1; }

/* ─── Right TOC ─────────────────────────────────────────────────────────────── */

.docs-toc {
  position: sticky;
  top: 75px;
  height: calc(100vh - 75px);
  overflow-y: auto;
  padding: 40px 20px 40px 16px;
  font-size: 12.5px;
  scrollbar-width: none;
}

.docs-toc::-webkit-scrollbar { display: none; }

.docs-toc-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 10px;
}

.docs-toc nav ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.docs-toc nav li { margin: 0; }

.docs-toc nav a {
  display: block;
  padding: 3px 0;
  color: var(--muted);
  text-decoration: none;
  line-height: 1.4;
  transition: color .15s ease;
  font-size: 12.5px;
}

.docs-toc nav a:hover { color: var(--nav-link-hover); }

.docs-toc nav a.toc-active { color: var(--accent); }

.docs-toc nav ul ul {
  margin-left: 12px;
  padding-left: 8px;
  border-left: 1px solid var(--border-soft);
}

/* Hugo auto-generates #TableOfContents */
#TableOfContents { margin: 0; }
#TableOfContents ul { list-style: none; padding: 0; margin: 0; }
#TableOfContents > ul > li { margin-bottom: 2px; }
#TableOfContents a {
  display: block;
  padding: 3px 0;
  color: var(--muted);
  text-decoration: none;
  font-size: 12.5px;
  line-height: 1.4;
  transition: color .15s ease;
}
#TableOfContents a:hover { color: var(--nav-link-hover); }
#TableOfContents ul ul {
  margin-left: 12px;
  padding-left: 8px;
  border-left: 1px solid var(--border-soft);
  margin-top: 2px;
}

/* ─── Pager (prev/next) ─────────────────────────────────────────────────────── */

.docs-pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 56px;
  padding-top: 28px;
  border-top: 1px solid var(--border-soft);
}

.pager-link {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px;
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  background: var(--surface-1);
  text-decoration: none;
  transition: border-color .2s ease, background .2s ease;
}

.pager-link:hover {
  border-color: var(--border-strong);
  background: var(--surface-2);
}

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

.pager-dir {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .08em;
}

.pager-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

/* ─── Docs home / index page ────────────────────────────────────────────────── */

.docs-home {
  max-width: 860px;
}

.docs-home h1 {
  font-size: clamp(32px, 5vw, 52px);
  margin: 0 0 16px;
  letter-spacing: -0.03em;
  line-height: 1.05;
  font-weight: 800;
}

.docs-home-sub {
  font-size: 18px;
  color: var(--muted);
  margin: 0 0 40px;
  max-width: 600px;
  line-height: 1.6;
}

.docs-card-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 48px;
}

.docs-card {
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  background: linear-gradient(180deg, var(--panel-top), var(--panel-bottom));
  padding: 20px;
  text-decoration: none;
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color .2s ease;
  position: relative;
  overflow: hidden;
}

.docs-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, transparent 36%, rgba(59, 130, 246, 0.05) 56%, transparent 66%);
  transform: translateX(-45%);
  transition: transform .65s ease;
  pointer-events: none;
}

.docs-card:hover { border-color: var(--accent-soft); }
.docs-card:hover::after { transform: translateX(25%); }

.docs-card-icon {
  font-size: 20px;
  margin-bottom: 4px;
}

.docs-card-title {
  font-size: 15px;
  font-weight: 600;
}

.docs-card-desc {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
}

/* ─── Footer ────────────────────────────────────────────────────────────────── */

footer {
  border-top: 1px solid var(--border-soft);
  padding: 20px 24px;
  color: var(--footer-text);
  font-size: 13px;
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.footer-meta {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  align-items: center;
}

.footer-meta a {
  color: var(--footer-text);
  text-decoration: none;
}

.footer-meta a:hover { color: var(--nav-link-hover); }

/* ─── Responsive ─────────────────────────────────────────────────────────────── */

@media (max-width: 1100px) {
  .docs-with-toc {
    grid-template-columns: 256px 1fr;
  }
  .docs-toc { display: none; }
}

@media (max-width: 768px) {
  .docs-wrap,
  .docs-with-toc {
    grid-template-columns: 1fr;
  }

  .docs-sidebar {
    position: fixed;
    top: 60px;
    left: -256px;
    width: 256px;
    z-index: 30;
    background: var(--bg-page);
    transition: left .25s ease;
  }

  .docs-sidebar.is-open {
    left: 0;
    box-shadow: 8px 0 32px rgba(0,0,0,0.3);
  }

  .docs-content {
    padding: 24px 20px 60px;
  }

  .docs-pager {
    grid-template-columns: 1fr;
  }

  .pager-link.pager-next { text-align: left; margin-left: 0; }

  .docs-card-grid {
    grid-template-columns: 1fr;
  }

  .nav-search { display: none; }

  .sidebar-toggle {
    display: flex !important;
  }
}

/* Mobile sidebar toggle */
.sidebar-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  background: var(--surface-1);
  color: var(--text);
  cursor: pointer;
  margin-right: 4px;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 60px 0 0 0;
  background: rgba(0,0,0,0.4);
  z-index: 29;
}

.sidebar-overlay.is-open { display: block; }

/* ─── Cookie consent ───────────────────────────────────────────────────────── */

.cookie-banner {
  position: fixed;
  left: 20px;
  right: 20px;
  bottom: 20px;
  z-index: 80;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: linear-gradient(180deg, var(--surface-2), var(--surface-1));
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.28);
}

.cookie-banner[hidden] {
  display: none !important;
}

.cookie-banner__content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
}

.cookie-banner__text {
  margin: 0;
  font-size: 13px;
  color: var(--text);
}

.cookie-banner__actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.cookie-btn {
  min-width: 120px;
  justify-content: center;
}

/* ─── 404 ─────────────────────────────────────────────────────────────────── */

.not-found-page {
  min-height: calc(100vh - 180px);
  display: grid;
  place-items: center;
  padding: 28px 20px 60px;
}

.not-found-card {
  width: min(760px, 100%);
  padding: 30px;
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  background: linear-gradient(180deg, var(--panel-top), var(--panel-bottom));
  box-shadow: 0 20px 46px rgba(0, 0, 0, 0.22);
}

.not-found-code {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 700;
}

.not-found-title {
  margin: 0 0 10px;
  font-size: clamp(32px, 6vw, 48px);
  line-height: 1.05;
  letter-spacing: -0.02em;
}

.not-found-text {
  margin: 0;
  max-width: 56ch;
  color: var(--muted);
  font-size: 16px;
}

.not-found-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 22px;
  flex-wrap: wrap;
}

.not-found-links {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border-soft);
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
}

.not-found-links a {
  color: var(--nav-link);
  text-decoration: none;
  font-size: 13px;
}

.not-found-links a:hover {
  color: var(--nav-link-hover);
}

@media (max-width: 768px) {
  .cookie-banner {
    left: 12px;
    right: 12px;
    bottom: 12px;
  }

  .cookie-banner__content {
    flex-direction: column;
    align-items: stretch;
  }

  .cookie-banner__actions {
    width: 100%;
  }

  .cookie-btn {
    width: 100%;
  }

  .not-found-card {
    padding: 22px 18px;
  }

  .not-found-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .not-found-actions .btn {
    justify-content: center;
  }
}
