/* API Docs — markdown reader styling.
 * Layout:topbar(global)+ left TOC rail(260px,sticky)+ scrollable article。
 * Visual:跟 manage / marketplace 一致的 quiet aesthetic;
 * 代码块单 mono 字体 + 深背景,不上 syntax highlighter(less freight)。
 */

.app.api-docs-app {
  display: flex; flex-direction: column; height: 100vh;
}
.app.api-docs-app .topbar { flex-shrink: 0; }

/* ---- API document selector ---- */
.api-docs-nav-menu {
  position: relative;
  display: inline-flex;
  align-items: center;
  height: 100%;
}
.api-docs-nav-menu > button {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 0;
  cursor: pointer;
}
.api-docs-nav-caret {
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1;
}
.api-docs-nav-dropdown {
  position: absolute;
  z-index: 20;
  top: calc(100% + 6px);
  right: 0;
  min-width: 142px;
  padding: 5px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.10);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: opacity 120ms ease, transform 120ms ease, visibility 120ms ease;
}
.api-docs-nav-menu:hover .api-docs-nav-dropdown,
.api-docs-nav-menu:focus-within .api-docs-nav-dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.api-docs-nav-dropdown a {
  display: block;
  padding: 7px 9px;
  border-radius: 5px;
  color: var(--text-muted);
  font-size: 13px;
  text-decoration: none;
  white-space: nowrap;
}
.api-docs-nav-dropdown a:hover,
.api-docs-nav-dropdown a:focus-visible,
.api-docs-nav-dropdown a.selected {
  background: var(--bg-subtle);
  color: var(--text);
}

.api-docs-shell {
  flex: 1; min-height: 0;
  display: grid;
  grid-template-columns: 260px 1fr;
}

/* ---- TOC rail (left) ---- */
.api-docs-toc {
  border-right: 1px solid var(--border);
  background: var(--bg-subtle);
  overflow-y: auto;
  padding: 18px 14px 24px;
  font-size: 13px;
}
.api-docs-toc h3 {
  margin: 0 0 10px;
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-muted); font-weight: 600;
}
.api-docs-toc ul {
  list-style: none; margin: 0; padding: 0;
}
.api-docs-toc li { margin: 0; }
.api-docs-toc a {
  display: block;
  padding: 5px 10px; border-radius: 6px;
  color: var(--text-muted); text-decoration: none;
  line-height: 1.4;
  border-left: 2px solid transparent;
}
.api-docs-toc a:hover { background: var(--row-hover); color: var(--text); }
.api-docs-toc a.active {
  background: var(--bg);
  color: var(--text); font-weight: 500;
  border-left-color: #0d0d0d;
}
.api-docs-toc a.lvl-3 {
  padding-left: 22px; font-size: 12.5px;
}

/* ---- Article (right) ---- */
.api-docs-article {
  overflow-y: auto;
  min-height: 0;
}
.api-docs-content {
  max-width: 880px;
  margin: 0 auto;
  padding: 32px 48px 80px;
  font-size: 14px; line-height: 1.65;
  color: var(--text);
}

/* ---- Markdown elements (scoped to .api-docs-content) ---- */
.api-docs-content h1 {
  font-size: 28px; font-weight: 700;
  margin: 0 0 8px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.api-docs-content h2 {
  font-size: 20px; font-weight: 700;
  margin: 40px 0 12px;
  padding-top: 12px;
  scroll-margin-top: 24px;
}
.api-docs-content h3 {
  font-size: 16px; font-weight: 600;
  margin: 28px 0 8px;
  scroll-margin-top: 24px;
}
.api-docs-content p { margin: 8px 0 12px; }
.api-docs-content hr {
  border: 0; border-top: 1px solid var(--border);
  margin: 32px 0;
}
.api-docs-content a {
  color: #0d0d0d; text-decoration: underline;
  text-decoration-color: var(--border-strong);
}
.api-docs-content a:hover { text-decoration-color: var(--text); }
.api-docs-content strong { font-weight: 600; }

/* Inline code */
.api-docs-content :not(pre) > code {
  font-family: var(--font-mono);
  font-size: 12.5px;
  padding: 1.5px 6px;
  background: var(--bg-subtle);
  border-radius: 4px;
  border: 1px solid var(--border);
  color: #0d0d0d;
}

/* Fenced code blocks */
.api-docs-content pre {
  margin: 12px 0 18px;
  background: #0d0d0d;
  color: #e5e5e5;
  border-radius: 8px;
  padding: 14px 16px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.55;
}
.api-docs-content pre code {
  background: transparent;
  color: inherit;
  padding: 0;
  border: 0;
  font-family: inherit;
  font-size: inherit;
}

/* Tables */
.api-docs-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 14px 0 22px;
  font-size: 13px;
}
.api-docs-content th, .api-docs-content td {
  text-align: left;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.api-docs-content th {
  background: var(--bg-subtle);
  font-weight: 600;
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.api-docs-content td code {
  white-space: nowrap;
}

/* Lists */
.api-docs-content ul, .api-docs-content ol {
  margin: 8px 0 14px;
  padding-left: 22px;
}
.api-docs-content li { margin: 4px 0; }
.api-docs-content li > p { margin: 2px 0; }

/* Block quotes */
.api-docs-content blockquote {
  border-left: 3px solid var(--border-strong);
  margin: 14px 0;
  padding: 6px 16px;
  background: var(--bg-subtle);
  color: var(--text-muted);
}

/* Header anchor — hover-shown § sign */
.api-docs-content h2 .anchor,
.api-docs-content h3 .anchor {
  opacity: 0; margin-left: 8px;
  color: var(--text-muted); text-decoration: none;
  font-weight: 400;
  transition: opacity 80ms ease;
}
.api-docs-content h2:hover .anchor,
.api-docs-content h3:hover .anchor { opacity: 1; }

/* Loading + error states */
.api-docs-status {
  padding: 60px 32px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}
.api-docs-status.error {
  color: #b91c1c;
}
.api-docs-status pre {
  display: inline-block;
  text-align: left;
  background: var(--bg-subtle);
  color: #0d0d0d;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  margin-top: 12px;
  font-size: 12px;
}

/* Mobile fallback — TOC drops below at narrow widths. */
@media (max-width: 960px) {
  .api-docs-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }
  .api-docs-toc {
    border-right: 0;
    border-bottom: 1px solid var(--border);
    max-height: 220px;
  }
  .api-docs-content {
    padding: 24px 24px 60px;
  }
}
