body {
  overflow-x: visible;
}

.terms-header p {
  max-width: 640px;
}

.terms-layout {
  width: 100%;
  max-width: none;
  margin: 0 auto;
  padding: 8px var(--page-pad) 96px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 264px;
  gap: clamp(40px, 5vw, 84px);
  align-items: start;
}

.terms-doc {
  grid-column: 1;
  grid-row: 1;
  min-width: 0;
  max-width: 1080px;
}

.terms-toc {
  grid-column: 2;
  grid-row: 1;
  position: sticky;
  top: var(--nav-height);
}

.terms-toc-title {
  margin: 0 0 12px;
  padding-right: 8px;
  color: var(--muted-strong);
  font-family: 'Space Grotesk', Arial, sans-serif;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.terms-toc-scroll {
  max-height: calc(100vh - var(--nav-height) - 56px);
  overflow-y: auto;
  padding: 2px 8px 2px 0;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: #000 transparent;
}

.terms-toc-scroll::-webkit-scrollbar {
  width: 8px;
}

.terms-toc-scroll::-webkit-scrollbar-track {
  background: transparent;
}

.terms-toc-scroll::-webkit-scrollbar-thumb {
  background: #000;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
}

.terms-toc-scroll::-webkit-scrollbar-thumb:hover {
  background: #1a1a1a;
}

.terms-toc-scroll::-webkit-scrollbar-corner {
  background: transparent;
}

.terms-toc::after {
  content: "";
  position: absolute;
  left: 0;
  right: 14px;
  bottom: 0;
  height: 64px;
  pointer-events: none;
  opacity: 0;
  background: linear-gradient(to top, var(--bg), transparent);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  -webkit-mask-image: linear-gradient(to top, #000 0%, #000 30%, transparent 100%);
  mask-image: linear-gradient(to top, #000 0%, #000 30%, transparent 100%);
  transition: opacity 0.45s ease;
}

.terms-toc.has-more::after {
  opacity: 1;
}

.terms-chapters {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.terms-chapters a {
  display: block;
  padding: 7px 10px;
  color: var(--muted);
  opacity: 1;
  font-size: 13px;
  line-height: 1.4;
  text-decoration: none;
  border-left: 2px solid transparent;
  border-radius: 0 6px 6px 0;
  transition: color 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
}

.terms-chapters a:hover {
  color: var(--text);
  background: var(--panel-soft);
}

.terms-chapters a:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: -2px;
}

.terms-chapters a.active,
.terms-chapters a[aria-current="true"] {
  color: var(--text);
  background: var(--panel);
  border-left-color: #ff007f;
}

.terms-doc section {
  scroll-margin-top: calc(var(--nav-height) + 16px);
  margin-top: 20px;
}

.terms-doc section h2 {
  margin-top: 0;
}

.terms-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 28px;
  padding: 14px 18px;
  margin-bottom: 26px;
  background: var(--panel);
  border: 1px solid var(--card-border);
  border-radius: 10px;
}

.terms-meta p {
  margin: 0;
  color: var(--muted);
}

.terms-meta strong {
  color: var(--text);
}

.terms-toc-mobile {
  display: none;
}

@media (max-width: 960px) {
  .terms-layout {
    grid-template-columns: 1fr;
    padding-bottom: 84px;
  }

  .terms-doc {
    grid-column: 1;
    max-width: none;
  }

  .terms-toc {
    display: none;
  }

  .terms-intro-sep {
    display: none;
  }

  .terms-toc-mobile {
    display: block;
    margin: 12px 0 0;
    padding: 14px 16px 16px;
    border: 1px solid var(--card-border);
    border-radius: 12px;
    background: var(--panel-soft);
  }

  .terms-toc-mobile .terms-toc-title {
    margin-bottom: 10px;
  }

  .terms-toc-mobile .terms-toc-scroll-wrap {
    position: relative;
  }

  .terms-toc-mobile .terms-toc-scroll {
    max-height: 170px;
    overflow-y: auto;
    padding: 2px 14px 2px 0;
    overscroll-behavior: contain;
    scrollbar-width: none;
  }

  .terms-toc-mobile .terms-toc-scroll::-webkit-scrollbar {
    display: none;
  }

  .terms-toc-mobile .terms-toc-scroll-wrap::after {
    content: "";
    position: absolute;
    left: 0;
    right: 12px;
    bottom: 0;
    height: 36px;
    pointer-events: none;
    opacity: 0;
    background: linear-gradient(to top, var(--panel-soft), transparent);
    transition: opacity 0.35s ease;
  }

  .terms-toc-mobile.has-more .terms-toc-scroll-wrap::after {
    opacity: 1;
  }

  .terms-toc-mobile .terms-toc-scrollbar {
    position: absolute;
    top: 2px;
    right: 0;
    bottom: 2px;
    width: 6px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.25s ease;
  }

  .terms-toc-mobile .terms-toc-scrollbar.visible {
    opacity: 1;
  }

  .terms-toc-mobile .terms-toc-thumb {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    height: 0;
    border-radius: 999px;
    background: #000;
    border: 1px solid rgba(255, 255, 255, 0.18);
  }
}
