/* Docs Render Agent panel sizing + FAB toggle affordance */

.render-agent-panel--docs.render-agent-panel--popup,
.render-agent-panel--docs.render-agent-panel--sticky {
  position: fixed !important;
  z-index: 12050 !important;
  right: 16px;
  top: auto;
  bottom: 24px;
  left: auto;
  width: min(320px, calc(100vw - 24px));
  height: min(460px, calc(100vh - 120px));
  max-height: none !important;
  border-radius: 16px;
  box-shadow:
    0 22px 56px rgba(0, 0, 0, 0.5),
    0 0 0 1px rgba(210, 168, 255, 0.18);
}

.render-agent-fab {
  z-index: 12060;
}

.render-agent-fab.is-open {
  border-color: rgba(88, 166, 255, 0.55);
  background: rgba(22, 27, 34, 0.98);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(88, 166, 255, 0.2);
}

.render-agent-fab.hidden {
  display: none !important;
}

/*
 * Left topic legend (Getting Started TOC + Complete docs catalog nav).
 * Parent #app / .info-main use overflow:auto which breaks position:sticky —
 * restore viewport sticky so the legend scrolls with you.
 */
body.docs-body #app.app-info,
body.gs-body #app.app-info {
  overflow: visible;
}

body.docs-body .info-main,
body.gs-body .info-main {
  overflow: visible;
}

body.docs-body,
body.gs-body {
  overflow-x: hidden;
}

.docs-catalog-nav,
.gs-toc {
  position: sticky !important;
  top: 68px !important;
  align-self: start;
  z-index: 5;
  max-height: calc(100vh - 88px);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}

@media (max-width: 980px) {
  .docs-catalog-nav,
  .gs-toc {
    position: static !important;
    top: auto !important;
    max-height: none;
    overflow: visible;
  }
}

/* Mobile docs: keep content readable; agent opens as a bottom sheet overlay. */
@media (max-width: 820px), (pointer: coarse) and (max-width: 1024px) {
  body.gs-body .gs-page,
  body.docs-body .docs-content,
  body.docs-body .updates-page,
  body.docs-body .info-main {
    padding-bottom: calc(76px + env(safe-area-inset-bottom, 0px));
  }

  .render-agent-fab {
    right: max(14px, env(safe-area-inset-right, 0px));
    bottom: max(14px, env(safe-area-inset-bottom, 0px));
    padding: 9px 12px;
    font-size: 0.92rem;
  }

  .render-agent-fab img {
    width: 38px;
    height: 24px;
  }

  .render-agent-backdrop {
    position: fixed;
    inset: 0;
    z-index: 12040;
    border: 0;
    background: rgba(1, 4, 9, 0.66);
    backdrop-filter: blur(2px);
  }

  .render-agent-backdrop.hidden {
    display: none !important;
  }

  body.gs-agent-sheet-open .render-agent-panel--docs.render-agent-panel--mobile-sheet {
    inset: auto 0 0 0 !important;
    left: 0 !important;
    right: 0 !important;
    top: auto !important;
    bottom: 0 !important;
    width: 100% !important;
    max-width: none !important;
    height: min(92dvh, calc(100dvh - env(safe-area-inset-top, 0px) - 8px)) !important;
    max-height: none !important;
    border-radius: 18px 18px 0 0;
    border-bottom: none;
    box-shadow:
      0 -18px 48px rgba(0, 0, 0, 0.42),
      0 0 0 1px rgba(210, 168, 255, 0.16);
  }

  body.gs-agent-sheet-open .render-agent-panel--docs .render-agent-head {
    position: relative;
    cursor: default;
    padding-top: 16px;
  }

  body.gs-agent-sheet-open .render-agent-panel--docs .render-agent-head::before {
    content: "";
    position: absolute;
    top: 8px;
    left: 50%;
    width: 42px;
    height: 4px;
    margin-left: -21px;
    border-radius: 999px;
    background: rgba(139, 148, 158, 0.45);
  }

  body.gs-agent-sheet-open .render-agent-panel--docs .render-agent-resize,
  body.gs-agent-sheet-open .render-agent-panel--docs .render-agent-drag-hint {
    display: none !important;
  }

  body.gs-agent-sheet-open .render-agent-panel--docs .render-agent-messages {
    flex: 1 1 auto;
    min-height: 0;
  }

  body.gs-agent-sheet-open .render-agent-panel--docs .render-agent-form {
    padding-bottom: max(10px, env(safe-area-inset-bottom, 0px));
  }

  body.gs-agent-open .gs-page,
  body.gs-agent-open .docs-content,
  body.gs-agent-open .updates-page {
    max-width: 100% !important;
    width: 100% !important;
    margin-left: auto !important;
    margin-right: auto !important;
  }
}
