:root {
  --docs-bg: #0a0e14;
  --docs-panel: rgba(18, 23, 31, 0.92);
  --docs-card: rgba(18, 23, 31, 0.85);
  --docs-border: rgba(0, 170, 255, 0.15);
  --docs-text: #e6edf3;
  --docs-muted: #8b949e;
  --docs-accent: #0af;
  --docs-tag-bg: rgba(0, 170, 255, 0.12);
  --docs-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

html[data-theme='light'] {
  --docs-bg: #f8fafc;
  --docs-panel: rgba(255, 255, 255, 0.95);
  --docs-card: rgba(255, 255, 255, 0.9);
  --docs-border: rgba(8, 145, 178, 0.15);
  --docs-text: #0f172a;
  --docs-muted: #64748b;
  --docs-accent: #0891b2;
  --docs-tag-bg: rgba(8, 145, 178, 0.1);
  --docs-shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
}

.docs-hero .docs-shell {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
}

.docs-shell-hero {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
}

.docs-shell {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
}

.docs-hero {
  padding: 28px 0 16px;
}

body.docs-layout-body {
  background: var(--docs-bg);
}

body.docs-layout-body .site-main {
  padding: 16px 0 36px;
}

body.docs-layout-body .ap-footer {
  margin-top: 24px;
}

.docs-hero__tag {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--docs-accent);
  background: var(--docs-tag-bg);
  border: 1px solid var(--docs-border);
  padding: 6px 14px;
  border-radius: 999px;
  margin-bottom: 14px;
}

.docs-hero__title {
  font-family: var(--font-mono);
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  font-weight: 700;
  margin: 0 0 16px;
  color: var(--docs-text);
}

.docs-hero__crumb {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--docs-muted);
}

.docs-hero__crumb a {
  color: var(--docs-text);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s ease;
}

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

.docs-layout {
  padding: 0 0 30px;
}

.docs-grid {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 24px;
}

.docs-sidebar {
  position: sticky;
  top: 100px;
  height: fit-content;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
  padding: 24px;
  border-radius: 16px;
  border: 1px solid var(--docs-border);
  background: var(--docs-card);
  box-shadow: var(--docs-shadow);
  backdrop-filter: blur(20px);
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.docs-search {
  margin-bottom: 24px;
}

.docs-toc-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.docs-toc-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.docs-toc-link {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--docs-muted);
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 8px;
  transition: all 0.2s ease;
}

.docs-toc-link:hover {
  color: var(--docs-accent);
  background: rgba(0, 170, 255, 0.08);
}

.docs-toc-item.is-active > .docs-toc-link {
  color: var(--docs-accent);
  background: rgba(0, 170, 255, 0.12);
  border-left: 2px solid var(--docs-accent);
}

.docs-toc-child {
  margin-left: 12px;
  padding-left: 12px;
  border-left: 1px solid var(--docs-border);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.docs-article {
  border-radius: 16px;
  padding: clamp(24px, 4vw, 40px);
  background: var(--docs-card);
  border: 1px solid var(--docs-border);
  box-shadow: var(--docs-shadow);
}

.docs-article__abstract {
  color: var(--docs-muted);
  font-size: 1.05rem;
  line-height: 1.7;
  margin-bottom: 24px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--docs-border);
}

.docs-article__abstract img {
  display: block;
  width: min(100%, 960px) !important;
  max-width: 100% !important;
  height: auto !important;
  box-sizing: border-box;
  border-radius: 12px;
  margin: 16px auto 0;
  object-fit: contain !important;
}

.docs-article__body h2,
.docs-article__body h3,
.docs-article__body h4 {
  font-family: var(--font-mono);
  color: var(--docs-text);
  margin: 2rem 0 1rem;
}

.docs-article__body h2 {
  font-size: 1.5rem;
}

.docs-article__body h3 {
  font-size: 1.25rem;
}

.docs-article__body p {
  color: var(--docs-text);
  line-height: 1.8;
  margin: 0 0 1rem;
}

.docs-article__body ul,
.docs-article__body ol {
  padding-left: 1.5rem;
  margin: 1rem 0;
  color: var(--docs-text);
}

.docs-article__body li {
  margin-bottom: 0.5rem;
  line-height: 1.7;
}

.docs-article__body a {
  color: var(--docs-accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.docs-article__body a:hover {
  text-decoration: none;
}

.docs-article__body code {
  font-family: var(--font-mono);
  background: rgba(0, 170, 255, 0.1);
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  font-size: 0.9rem;
  color: var(--docs-accent);
}

.docs-article__body pre {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--docs-border);
  border-radius: 12px;
  padding: 1rem;
  overflow-x: auto;
}

.docs-article__body pre code {
  background: none;
  padding: 0;
  color: var(--docs-text);
}

.docs-article__promo {
  margin-bottom: 24px;
}

.docs-article__body img {
  width: min(100%, 960px) !important;
  max-width: 100% !important;
  height: auto !important;
  box-sizing: border-box;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.2);
  padding: 8px;
  display: block;
  margin: 24px auto;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
  border: 1px solid var(--docs-border);
  object-fit: contain !important;
}

.docs-article__body table {
  width: 100%;
  border-collapse: collapse;
  margin: 24px 0;
  font-size: 0.95rem;
}

.docs-article__body th,
.docs-article__body td {
  border: 1px solid var(--docs-border);
  padding: 12px 14px;
  text-align: left;
}

.docs-article__body th {
  background: rgba(0, 170, 255, 0.08);
  font-weight: 600;
}

.docs-next {
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--docs-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.docs-next__label {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--docs-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.docs-next__link {
  font-family: var(--font-mono);
  color: var(--docs-accent);
  text-decoration: none;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: gap 0.2s ease;
}

.docs-next__link:hover {
  gap: 12px;
}

.docs-sidebar-toggle {
  display: none;
  width: 100%;
  margin: 0 auto 20px;
  border: 1px solid var(--docs-border);
  background: var(--docs-panel);
  color: var(--docs-text);
  border-radius: 12px;
  padding: 14px 16px;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--docs-shadow);
  transition: all 0.2s ease;
}

.docs-sidebar-toggle:hover {
  border-color: var(--docs-accent);
}

.docs-sidebar-overlay {
  display: none;
}

/* Floating TOC FAB */
.docs-toc-fab {
  display: none;
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: var(--docs-accent);
  color: #fff;
  border: none;
  cursor: pointer;
  z-index: 100;
  box-shadow: 0 8px 24px rgba(0, 170, 255, 0.4);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  align-items: center;
  justify-content: center;
}

.docs-toc-fab:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 32px rgba(0, 170, 255, 0.5);
}

.docs-toc-fab:active {
  transform: scale(0.95);
}

/* TOC Panel */
.docs-toc-panel {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-height: 60vh;
  background: var(--docs-card);
  border-top: 1px solid var(--docs-border);
  border-radius: 24px 24px 0 0;
  z-index: 200;
  transform: translateY(100%);
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  backdrop-filter: blur(20px);
  box-shadow: 0 -20px 60px rgba(0, 0, 0, 0.4);
}

.docs-toc-panel.is-open {
  transform: translateY(0);
}

.docs-toc-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--docs-border);
}

.docs-toc-panel__title {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--docs-text);
  letter-spacing: 0.02em;
}

.docs-toc-panel__close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  background: rgba(0, 170, 255, 0.1);
  border-radius: 10px;
  color: var(--docs-text);
  cursor: pointer;
  transition: all 0.2s ease;
}

.docs-toc-panel__close:hover {
  background: rgba(0, 170, 255, 0.2);
}

.docs-toc-panel__nav {
  padding: 16px 20px 32px;
  overflow-y: auto;
  max-height: calc(60vh - 70px);
}

.docs-toc-panel__nav .docs-toc-link {
  padding: 12px 16px;
  font-size: 0.95rem;
}

/* TOC Overlay */
.docs-toc-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 150;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.docs-toc-overlay.is-visible {
  opacity: 1;
}

@media (max-width: 1024px) {
  .docs-grid {
    grid-template-columns: 1fr;
  }

  .docs-hero {
    padding-top: 24px;
  }

  .docs-sidebar-toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  .docs-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(360px, 85vw);
    max-width: 100%;
    max-height: 100%;
    height: 100%;
    overflow-y: auto;
    transform: translateX(-105%);
    opacity: 0;
    border-radius: 0;
    border-right: 1px solid var(--docs-border);
    top: 0;
  }

  .docs-sidebar.is-open {
    transform: translateX(0);
    opacity: 1;
    z-index: 30;
  }

  .docs-sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: none;
    z-index: 20;
  }

  .docs-sidebar-overlay.is-visible {
    display: block;
  }

  /* Show TOC FAB on mobile */
  .docs-toc-fab {
    display: flex;
  }

  .docs-toc-panel {
    display: block;
  }

  .docs-toc-overlay {
    display: block;
    pointer-events: none;
  }

  .docs-toc-overlay.is-visible {
    pointer-events: auto;
  }
}

@media (max-width: 767px) {
  .docs-hero__title {
    font-size: clamp(1.5rem, 6vw, 2rem);
  }

  .docs-article {
    padding: 20px;
    border-radius: 12px;
  }

  .docs-toc-fab {
    bottom: 20px;
    right: 20px;
    width: 52px;
    height: 52px;
  }
}

/* Light mode overrides */
html[data-theme='light'] .docs-toc-fab {
  box-shadow: 0 8px 24px rgba(8, 145, 178, 0.3);
}

html[data-theme='light'] .docs-toc-fab:hover {
  box-shadow: 0 12px 32px rgba(8, 145, 178, 0.4);
}

html[data-theme='light'] .docs-article__body code {
  background: rgba(8, 145, 178, 0.1);
}

html[data-theme='light'] .docs-article__body pre {
  background: rgba(0, 0, 0, 0.03);
}

/* PageFind Search Styles */
#pagefind-search {
  position: relative;
}

.pagefind-input {
  width: 100%;
  padding: 12px 16px;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: var(--docs-text);
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--docs-border);
  border-radius: 10px;
  outline: none;
  transition: all 0.2s ease;
}

.pagefind-input::placeholder {
  color: var(--docs-muted);
}

.pagefind-input:focus {
  border-color: var(--docs-accent);
  box-shadow: 0 0 0 3px rgba(0, 170, 255, 0.15);
}

.pagefind-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  max-height: 400px;
  overflow-y: auto;
  background: var(--docs-card);
  border: 1px solid var(--docs-border);
  border-radius: 12px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(20px);
  z-index: 100;
  display: none;
}

.pagefind-results.is-visible {
  display: block;
}

.pagefind-result {
  display: block;
  padding: 14px 16px;
  text-decoration: none;
  border-bottom: 1px solid var(--docs-border);
  transition: background 0.2s ease;
}

.pagefind-result:last-child {
  border-bottom: none;
}

.pagefind-result:hover {
  background: rgba(0, 170, 255, 0.08);
}

.pagefind-result__title {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--docs-accent);
  margin-bottom: 6px;
}

.pagefind-result__excerpt {
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--docs-muted);
}

.pagefind-result__excerpt mark {
  background: rgba(0, 170, 255, 0.25);
  color: var(--docs-text);
  padding: 1px 3px;
  border-radius: 3px;
}

.pagefind-no-results {
  padding: 20px 16px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--docs-muted);
}

/* Light mode PageFind overrides */
html[data-theme='light'] .pagefind-input {
  background: rgba(0, 0, 0, 0.04);
}

html[data-theme='light'] .pagefind-input:focus {
  box-shadow: 0 0 0 3px rgba(8, 145, 178, 0.15);
}

html[data-theme='light'] .pagefind-results {
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.12);
}

html[data-theme='light'] .pagefind-result:hover {
  background: rgba(8, 145, 178, 0.06);
}

html[data-theme='light'] .pagefind-result__excerpt mark {
  background: rgba(8, 145, 178, 0.2);
}
