.toc-widget-wrapper {
	--toc-open: 1;
	--toc-rotate: 180deg;
	--toc-sub-indent: 20px;
	direction: rtl;
	text-align: right;
	box-sizing: border-box;
}

.toc-widget-wrapper *,
.toc-widget-wrapper *::before,
.toc-widget-wrapper *::after {
	box-sizing: border-box;
}

/* ---------- Header ---------- */
.toc-widget-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	margin-bottom: 12px;
}

.toc-widget-wrapper[data-header-toggle="1"] .toc-widget-header {
	cursor: pointer;
}

.toc-widget-wrapper .toc-widget-title {
	margin: 0;
	font-size: 18px;
	font-weight: 700;
}

/* ---------- Toggle button (reset theme button styles) ---------- */
.toc-widget-wrapper .toc-widget-toggle {
	display: inline-flex;
	flex: 0 0 auto;
	align-items: center;
	justify-content: center;
	min-width: 0;
	margin: 0;
	padding: 0;
	border: 0 solid transparent;
	border-radius: 0;
	background-color: transparent;
	box-shadow: none;
	color: inherit;
	font-size: 18px;
	line-height: 1;
	text-transform: none;
	cursor: pointer;
	-webkit-appearance: none;
	appearance: none;
	transition: background-color 0.25s ease, color 0.25s ease, border-color 0.25s ease;
}

.toc-widget-wrapper .toc-widget-toggle:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

.toc-widget-toggle__icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	line-height: 1;
	transition: transform 0.3s ease;
}

.toc-widget-toggle__icon i,
.toc-widget-toggle__icon svg {
	display: block;
	width: 1em;
	height: 1em;
	font-size: inherit;
	line-height: 1;
	fill: currentColor;
}

.toc-widget-wrapper.is-collapsed .toc-widget-toggle__icon {
	transform: rotate(var(--toc-rotate));
}

/* ---------- Collapsible body (no height measuring) ---------- */
.toc-widget-body {
	display: grid;
	grid-template-rows: 1fr;
	transition: grid-template-rows 0.3s ease;
}

.toc-widget-body__inner {
	min-height: 0;
	overflow: hidden;
}

.toc-widget-wrapper.is-collapsed .toc-widget-body {
	grid-template-rows: 0fr;
}

.toc-widget-wrapper.is-collapsed .toc-widget-body__inner {
	visibility: hidden;
	transition: visibility 0s linear 0.3s;
}

/* ---------- List ---------- */
.toc-list__items {
	margin: 0;
	padding: 0;
	list-style: none;
}

.toc-list__item {
	margin: 0 0 8px;
	padding: 0;
	list-style: none;
}

.toc-list__item--sub {
	padding-inline-start: var(--toc-sub-indent);
}

.toc-list__item a {
	display: flex;
	align-items: flex-start;
	padding: 6px 10px;
	border-radius: 4px;
	color: inherit;
	text-decoration: none;
	transition: background-color 0.2s ease, color 0.2s ease;
}

.toc-list__item a:hover {
	background-color: rgba(0, 0, 0, 0.05);
}

.toc-list__item a.is-active {
	font-weight: 700;
}

.toc-list__text {
	min-width: 0;
}

/* marker box = height of the first text line, so dots/icons align with line 1 */
.toc-list__marker-wrapper {
	display: inline-flex;
	flex-shrink: 0;
	align-items: center;
	height: 1lh;
}

.toc-list__marker {
	display: inline-flex;
	flex-shrink: 0;
	align-items: center;
	justify-content: center;
	width: 1em;
	height: 1em;
	margin-inline-end: 8px;
	font-size: 18px;
	line-height: 1;
	color: inherit;
	fill: currentColor;
}

.toc-list__marker--dot {
	border-radius: 50%;
	background-color: currentColor;
}

.toc-list__marker--number {
	width: auto;
	height: auto;
	line-height: inherit;
}

.toc-list__notice {
	margin: 0;
	padding: 8px 10px;
	border: 1px dashed currentColor;
	border-radius: 4px;
	font-size: 13px;
	opacity: 0.8;
}
