/* Container (unchanged basics) */
.common-toc {
  display: block;
  width: 100%;
  padding: 1rem 1.25rem;
  margin: 0 0 1.5rem;
  border: 1px solid #e5e5e5;
  border-radius: 8px;
  background-color: #fafafa;
  position: relative; /* for toggle button positioning */
}

/* Body: leave space for the top-right toggle */
.common-toc .ct-body {
  font-size: 0.95rem;
  line-height: 1.6;
  padding-top: 2.0rem; /* space for the button */
}

/* List/link styles (unchanged) */
.common-toc ul,
.common-toc ol { margin: 0; padding-left: 1.25rem; }
.common-toc a { text-decoration: none; border-bottom: 1px dashed transparent; }
.common-toc a:hover, .common-toc a:focus { border-bottom-color: currentColor; outline: none; }
.common-toc a[aria-current="true"] { font-weight: 700; border-bottom-color: currentColor; }

/* Toggle button: move to top-right and float above content */
.common-toc .ct-toggle {
  position: absolute;
  right: 8px;      /* moved to right */
  left: auto;      /* cancel left */
  top: 8px;
  padding: 0.25rem 0.6rem;
  font-size: 0.85rem;
  line-height: 1;
  border: 1px solid #ddd;
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  z-index: 3;      /* ensure above TOC items */
}

/* Collapsed state */
.common-toc.is-collapsed {
  padding: 0.5rem 0.75rem 0.6rem 0.75rem;
  max-height: none;
  overflow: visible;
}
.common-toc.is-collapsed .ct-body { display: none; }

/* Sticky on wider screens */
@media (min-width: 980px) {
  .common-toc {
    position: sticky;
    top: var(--header-offset, 84px);
    max-height: calc(100vh - var(--header-offset, 84px) - 1rem);
    overflow: auto;
  }
}

/* Mobile tweaks */
@media (max-width: 979.98px) {
  .common-toc { padding: 0.85rem 1rem; }
  .common-toc .ct-body { font-size: 0.9rem; }
}
