/* Docs layout: sidebar + main — centered as one block on wide viewports */
.docs-layout{
  display: flex;
  min-height: calc(100vh - 120px);
  width: 100%;
  max-width: 1560px;
  margin-left: auto;
  margin-right: auto;
  padding-left: 24px;
  padding-right: 24px;
  box-sizing: border-box;
  background: var(--bg);
}
.docs-footer{
  margin-top: 0;
}

/* Mobile-only: toggle button (hidden on desktop) */
.docs-nav-toggle{
  display: none;
}
.docs-sidebar-overlay{
  display: none;
  pointer-events: none;
}

/* Sidebar */
.docs-sidebar{
  width: 260px;
  flex-shrink: 0;
  background: var(--bg);
  border-right: 1px solid var(--line);
  padding: 24px 20px;
  position: sticky;
  top: 0;
  max-height: calc(100vh - 60px);
  overflow-y: auto;
}
.docs-nav{
  padding: 0;
}
.docs-nav__item{
  display: block;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--text);
  font-weight: 500;
  text-decoration: none;
}
.docs-nav__item:hover{
  background: rgba(17,24,39,0.06);
  text-decoration: none;
}
.docs-nav__item--active{
  background: rgba(17,24,39,0.08);
  color: var(--text);
}
.docs-nav__group{
  margin-top: 4px;
}
.docs-nav__group-title{
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border: 0;
  background: transparent;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}
.docs-nav__group-title:hover{
  background: rgba(17,24,39,0.06);
}
.docs-nav__chev{
  display: inline-block;
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid currentColor;
  opacity: 0.7;
  transition: transform 0.2s ease;
}
.docs-nav__group-title--open .docs-nav__chev{
  transform: rotate(180deg);
}
.docs-nav__children{
  padding: 4px 0 4px 8px;
  border-left: 1px solid var(--line);
  margin-left: 16px;
  display: none;
}
.docs-nav__group-title--open + .docs-nav__children{
  display: block;
}
.docs-nav__group-row{
  display: flex;
  align-items: center;
  width: 100%;
  gap: 4px;
}
.docs-nav__group-row .docs-nav__item{
  flex: 1;
  min-width: 0;
}
.docs-nav__group-toggle{
  flex-shrink: 0;
  padding: 6px;
  border: 0;
  background: transparent;
  border-radius: 8px;
  color: inherit;
  cursor: pointer;
}
.docs-nav__group-toggle:hover{
  background: rgba(17,24,39,0.06);
}
.docs-nav__group--open .docs-nav__children{
  display: block;
}
.docs-nav__group--open .docs-nav__group-toggle .docs-nav__chev{
  transform: rotate(180deg);
}
.docs-nav__child{
  display: block;
  padding: 8px 12px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 14px;
  text-decoration: none;
}
.docs-nav__child:hover{
  color: var(--text);
  background: rgba(17,24,39,0.04);
  text-decoration: none;
}
.docs-nav__child--active{
  color: var(--text);
  font-weight: 500;
  background: rgba(17,24,39,0.06);
}

/* Main + in-page TOC column */
.docs-stage{
  display: flex;
  flex: 1;
  min-width: 0;
  align-items: flex-start;
  gap: 36px;
}
.docs-toc{
  width: 232px;
  flex-shrink: 0;
  position: sticky;
  top: 72px;
  align-self: flex-start;
  max-height: calc(100vh - 88px);
  overflow-y: auto;
  padding: 8px 0 24px 20px;
  border-left: 1px solid var(--line);
  -webkit-overflow-scrolling: touch;
}
.docs-toc[hidden]{
  display: none !important;
}
.docs-toc__title{
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 12px;
}
.docs-toc__nav{
  margin: 0;
  padding: 0;
}
.docs-toc__list{
  list-style: none;
  margin: 0;
  padding: 0;
}
.docs-toc__list--nested{
  margin-top: 4px;
  margin-bottom: 2px;
  padding-left: 12px;
  border-left: 1px solid rgba(17,24,39,0.1);
}
.docs-toc__item{
  margin: 2px 0;
}
.docs-toc__link{
  display: block;
  font-size: 13px;
  line-height: 1.45;
  color: var(--muted);
  text-decoration: none;
  border-radius: 6px;
  padding: 4px 8px;
  margin-left: -6px;
  border: 0;
  background: transparent;
  width: 100%;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
}
.docs-toc__link:hover{
  color: var(--text);
  background: rgba(17,24,39,0.05);
}
.docs-toc__link--active{
  color: var(--text);
  font-weight: 500;
  background: rgba(17,24,39,0.07);
}

/* Main content */
.docs-main{
  flex: 1;
  min-width: 0;
  padding: 32px 40px 64px;
  max-width: 900px;
  background: var(--bg);
}
.docs-search{
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
  margin-bottom: 28px;
  padding: 10px 14px;
  background: rgba(17,24,39,0.04);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.docs-search__icon{
  font-size: 16px;
  opacity: 0.6;
}
.docs-search__input{
  flex: 1;
  border: 0;
  background: transparent;
  font-size: 15px;
  outline: none;
}
.docs-search__input::placeholder{
  color: var(--muted);
}
.docs-search__results{
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 8px);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(17,24,39,0.08);
  z-index: 50;
  max-height: 360px;
  overflow-y: auto;
}
.docs-search__item{
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  text-align: left;
  padding: 10px 14px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.docs-search__item:last-child{
  border-bottom: 0;
}
.docs-search__item:hover{
  background: rgba(17,24,39,0.04);
}
.docs-search__item--active{
  background: rgba(17,24,39,0.08);
}
.docs-search__item-title{
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
}
.docs-search__item-snippet{
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}
.docs-search__empty{
  padding: 12px 14px;
  color: var(--muted);
  font-size: 14px;
}
.docs-search__hl{
  background: rgba(245, 158, 11, 0.28);
  color: inherit;
  padding: 0 2px;
  border-radius: 4px;
}

@media (max-width: 1100px){
  .docs-stage{
    gap: 0;
  }
  .docs-toc{
    display: none !important;
  }
}
.docs-content__title{
  font-size: 32px;
  font-weight: 700;
  margin: 0 0 8px;
  letter-spacing: -0.02em;
  scroll-margin-top: 80px;
}
.docs-content__desc{
  font-size: 16px;
  color: var(--muted);
  margin: 0 0 24px;
  line-height: 1.6;
}
.docs-content__body{
  font-size: 15px;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
}

/* Markdown body (marked.js output) */
.markdown-body img{
  max-width: 100%;
  height: auto;
  display: block;
  margin: 14px 0;
}
.markdown-body h1{ font-size: 28px; margin: 32px 0 14px; font-weight: 600; scroll-margin-top: 80px; }
.markdown-body h2{ font-size: 22px; margin: 28px 0 12px; font-weight: 600; scroll-margin-top: 80px; }
.markdown-body h3{ font-size: 18px; margin: 22px 0 10px; font-weight: 600; scroll-margin-top: 80px; }
.markdown-body h4{ font-size: 16px; margin: 18px 0 8px; font-weight: 600; scroll-margin-top: 80px; }
.markdown-body h5, .markdown-body h6{ font-size: 15px; margin: 16px 0 6px; font-weight: 600; scroll-margin-top: 80px; }
.markdown-body p{ margin: 0 0 14px; }
.markdown-body ul, .markdown-body ol{ margin: 0 0 14px; padding-left: 24px; }
.markdown-body li{ margin: 4px 0; }
.markdown-body code{ background: rgba(17,24,39,0.06); padding: 2px 6px; border-radius: 6px; font-size: 14px; }
.markdown-body pre{ background: rgba(17,24,39,0.04); border: 1px solid var(--line); border-radius: 10px; padding: 16px; overflow-x: auto; margin: 14px 0; }
.markdown-body pre code{ background: none; padding: 0; }
.markdown-body code, .markdown-body pre, .markdown-body pre code{
  font-family: var(--font-mono);
  font-variant-ligatures: none;
}
.markdown-body a{ color: #2563eb; text-decoration: none; }
.markdown-body a:hover{ text-decoration: underline; }
.markdown-body blockquote{ border-left: 4px solid var(--line); margin: 14px 0; padding-left: 16px; color: var(--muted); }

@media (max-width: 768px){
  .docs-layout{
    flex-direction: column;
    min-height: auto;
    position: relative;
    padding-left: 16px;
    padding-right: 16px;
  }
  .docs-nav-toggle{
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
    padding: 10px 16px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
  }
  .docs-nav-toggle:hover{ background: rgba(17,24,39,0.04); }
  .docs-nav-toggle::before{ content: "☰ "; font-size: 18px; }
  .docs-sidebar-overlay{
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.35);
    z-index: 25;
    top: 60px;
  }
  .docs-layout.docs-nav-open .docs-sidebar-overlay{
    display: block;
    pointer-events: auto;
  }
  .docs-sidebar{
    position: fixed;
    left: 0;
    top: 60px;
    bottom: 0;
    z-index: 30;
    width: 280px;
    max-width: 85vw;
    max-height: none;
    border-right: 1px solid var(--line);
    padding: 16px;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: 4px 0 20px rgba(0,0,0,0.08);
    overflow-y: auto;
  }
  .docs-layout.docs-nav-open .docs-sidebar{
    transform: translateX(0);
  }
  .docs-main{
    padding: 20px 16px 48px;
    max-width: none;
    position: relative;
    z-index: 35;
  }
  .docs-layout.docs-nav-open .docs-main{
    z-index: 10;
  }
  .docs-nav-toggle{
    min-height: 44px;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
  }
  .docs-content__title{ font-size: 26px; }
  .docs-content__desc{ font-size: 15px; }
  .docs-search{ margin-bottom: 20px; padding: 10px 12px; }
  .markdown-body pre{ padding: 12px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .markdown-body code{ font-size: 13px; }
}
@media (max-width: 520px){
  .docs-sidebar{ padding: 12px; }
  .docs-main{ padding: 16px 12px 40px; }
  .docs-content__title{ font-size: 22px; }
}
