/* Escape the shared .site-main 760px shell so docs can use their own width. */
.site-main:has(.docs-layout) {
  width: 100%;
  margin: 0;
  padding: 0;
}

.docs-layout {
  --docs-sidebar: 288px;
  --docs-max: 1120px;
  min-height: 100vh;
}

.docs-header {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px);
}

.docs-header-inner {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  width: min(100%, var(--docs-max));
  margin: 0 auto;
  padding: 16px;
  box-sizing: border-box;
}

.docs-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-self: start;
}

.docs-back {
  color: var(--muted);
  font-size: 0.95rem;
}

.docs-back:hover {
  color: var(--text);
}

.docs-header-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  justify-self: center;
}

.docs-header-switch {
  justify-self: end;
  color: var(--muted);
  font-size: 0.95rem;
}

.docs-header-switch:hover {
  color: var(--text);
  text-decoration: none;
}

.docs-menu-btn {
  display: none;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

.docs-shell {
  display: grid;
  grid-template-columns: var(--docs-sidebar) minmax(0, 1fr);
  gap: 32px;
  width: min(100%, var(--docs-max));
  margin: 0 auto;
  padding: 32px 16px 64px;
  box-sizing: border-box;
}

.docs-sidebar {
  position: sticky;
  top: 72px;
  align-self: start;
  max-height: calc(100vh - 88px);
  overflow-y: auto;
}

.docs-sidebar-brand {
  display: flex;
  justify-content: flex-start;
  padding: 0 12px 20px;
}

.docs-sidebar-icon {
  display: block;
  width: 80px;
  height: 80px;
  border: 0;
  border-radius: 0;
  object-fit: contain;
  background: transparent;
}

.docs-sidebar nav {
  display: grid;
  gap: 4px;
}

.docs-nav-group {
  display: grid;
  gap: 4px;
  margin-top: 8px;
}

.docs-nav-group-title {
  display: block;
  padding: 8px 12px 4px;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 600;
}

.docs-nav-group-title:hover {
  color: var(--text);
  text-decoration: none;
}

.docs-nav-group-title.is-active {
  color: var(--text);
}

.docs-sidebar a {
  display: block;
  padding: 8px 12px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.95rem;
}

.docs-sidebar a.is-child {
  margin-left: 12px;
}

.docs-sidebar a:hover {
  color: var(--text);
  background: var(--card);
  text-decoration: none;
}

.docs-sidebar a.is-active {
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--border);
  font-weight: 500;
}

.docs-main {
  min-width: 0;
  max-width: 48rem;
  transition: opacity 0.18s ease;
}

.docs-main.is-page-loading {
  opacity: 0.35;
  pointer-events: none;
}

/* Wider viewports: expand the shell; sidebar stays fixed, article takes the rest. */
@media (min-width: 1200px) {
  .docs-layout {
    --docs-max: 1280px;
  }

  .docs-main {
    max-width: none;
  }
}

@media (min-width: 1440px) {
  .docs-layout {
    --docs-max: 1400px;
  }
}

.docs-section-intro {
  margin-bottom: 32px;
}

.docs-section-intro h1 {
  margin: 0 0 12px;
  font-size: clamp(1.5rem, 3vw, 2rem);
}

.docs-section-intro p {
  margin: 0;
  color: var(--muted);
}

.docs-guide-list {
  display: grid;
  gap: 12px;
  list-style: none;
  padding: 0;
  margin: 0;
}

.docs-guide-list a {
  display: block;
  padding: 18px 20px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
}

.docs-guide-list a:hover {
  border-color: var(--link);
  text-decoration: none;
}

.docs-guide-list strong {
  display: block;
  margin-bottom: 4px;
}

.docs-guide-list span {
  color: var(--muted);
  font-size: 0.95rem;
}

.docs-overlay {
  display: none;
}

@media (max-width: 900px) {
  .docs-menu-btn {
    display: inline-block;
  }

  .docs-header-inner {
    grid-template-columns: auto 1fr auto;
  }

  /* Article-only: match homepage side gutters (16px each side). */
  .docs-shell {
    grid-template-columns: 1fr;
    width: min(100%, 760px);
    padding: 32px 16px 64px;
  }

  .docs-main {
    max-width: none;
  }

  .docs-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 30;
    width: min(288px, 85vw);
    height: 100vh;
    max-height: none;
    padding: 72px 16px 24px;
    background: var(--bg);
    border-right: 1px solid var(--border);
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }

  .docs-sidebar.is-open {
    transform: translateX(0);
  }

  .docs-overlay.is-visible {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 25;
    background: rgba(0, 0, 0, 0.4);
  }
}
