.ct-toc {
	padding: 20px 24px;
	border: 1px solid var(--ct-gb-border);
	border-radius: var(--ct-gb-radius);
	background-color: var(--ct-gb-surface-alt);
	font-size: .95rem;
}
.ct-toc.is-sticky {
	position: sticky;
	top: calc(var(--ct-toc-offset, 80px) - 40px);
	max-height: calc(100vh - var(--ct-toc-offset, 80px));
	overflow-y: auto;
}
.ct-toc__title {
	margin: 0 0 10px;
	font-family: var(--ct-gb-font-heading, inherit);
	font-weight: 700;
	font-size: 1.05rem;
}
.ct-toc__details > summary {
	display: flex;
	align-items: center;
	justify-content: space-between;
	cursor: pointer;
	list-style: none;
}
.ct-toc__details > summary::-webkit-details-marker {
	display: none;
}
.ct-toc__details > summary::after {
	content: "";
	width: 8px;
	height: 8px;
	margin-left: 12px;
	border-right: 2px solid currentColor;
	border-bottom: 2px solid currentColor;
	transform: rotate(45deg);
	transition: transform .2s ease;
}
.ct-toc__details[open] > summary::after {
	transform: rotate(-135deg);
}
.ct-toc__details:not([open]) > summary {
	margin-bottom: 0;
}

.ct-toc__list,
.ct-toc__sublist {
	margin: 0;
	padding: 0;
	list-style: none;
}
.ct-toc__sublist {
	margin-top: 4px;
	padding-left: 18px;
}
.ct-toc__item {
	margin: 4px 0;
	line-height: 1.45;
}
.ct-toc__link {
	color: inherit;
	text-decoration: none;
	opacity: .85;
}
.ct-toc__link:hover {
	opacity: 1;
	text-decoration: underline;
}
.ct-toc__link.is-active {
	opacity: 1;
	font-weight: 600;
	color: var(--ct-gb-primary);
}

/* Numbering 1, 1.1, 1.1.1 */
.ct-toc.is-numbered .ct-toc__list,
.ct-toc.is-numbered .ct-toc__sublist {
	counter-reset: ct-toc;
}
.ct-toc.is-numbered .ct-toc__item {
	counter-increment: ct-toc;
}
.ct-toc.is-numbered .ct-toc__link::before {
	content: counters(ct-toc, ".") ". ";
	font-variant-numeric: tabular-nums;
	opacity: .7;
}
/* Wrapper <li> created only to hold a deeper list (heading levels skipped) is not counted. */
.ct-toc.is-numbered .ct-toc__item:not(:has(> .ct-toc__link)) {
	counter-increment: none;
}

/* Jump targets clear sticky headers. */
:where(h2, h3, h4, h5, h6)[id] {
	scroll-margin-top: var(--ct-toc-offset, 80px);
}
@media (prefers-reduced-motion: no-preference) {
	html:has(.ct-toc) {
		scroll-behavior: smooth;
	}
}

/* Layout "Sidebar + content": .toc-wrapper > .left (TOC) + .right (page content). */
.ct-toc-layout {
	--ct-toc-gap: 40px;
	display: grid;
	grid-template-columns: var(--ct-toc-sidebar-width, 280px) minmax(0, 1fr);
	gap: var(--ct-toc-gap);
	align-items: stretch;
}
/* Sticky: the .left column sticks, so it still works if a theme repositions the nav itself. */
.ct-toc-layout.is-sticky > .ct-toc-layout__sidebar {
	position: sticky;
	top: calc(var(--ct-toc-offset, 80px) - 40px);
	align-self: start;
}
.ct-toc-layout > * {
	box-sizing: border-box;
	min-width: 0;
}
.ct-toc-layout__content > :first-child {
	margin-top: 0;
}
.ct-toc-layout__content > :last-child {
	margin-bottom: 0;
}
/* Phones/tablets: stack, TOC first. */
@media (max-width: 781px) {
	.ct-toc-layout {
		grid-template-columns: minmax(0, 1fr);
		gap: 24px;
	}
	.ct-toc-layout.is-sticky > .ct-toc-layout__sidebar,
	.ct-toc-layout .ct-toc.is-sticky {
		position: static;
		max-height: none;
	}
}
