.loyseo-single__toc-sidebar {
	min-width: 0;
	align-self: start;
}

.loyseo-single-toc {
	display: flex;
	flex-direction: column;
	box-sizing: border-box;
	max-height: 320px;
	padding: var(--wp--preset--spacing--40);
	border: 1px solid var(--wp--preset--color--border-subtle);
	border-radius: var(--wp--custom--radius--panel);
	background: var(--wp--preset--color--surface-white);
	box-shadow: none;
	overflow: hidden;
}

.loyseo-single-toc--max-height-240 { max-height: 240px; }
.loyseo-single-toc--max-height-320 { max-height: 320px; }
.loyseo-single-toc--max-height-400 { max-height: 400px; }
.loyseo-single-toc--max-height-480 { max-height: 480px; }
.loyseo-single-toc--max-height-560 { max-height: 560px; }
.loyseo-single-toc--max-height-640 { max-height: 640px; }
.loyseo-single-toc--max-height-unlimited { max-height: none; overflow: visible; }
.loyseo-single-toc--max-height-unlimited .loyseo-single-toc__scroll { overflow-y: visible; }

.loyseo-single-toc__title {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--wp--preset--spacing--20);
	flex: 0 0 auto;
	padding: var(--wp--preset--spacing--20) var(--wp--preset--spacing--30);
	border-radius: var(--wp--custom--radius--compact);
	background: var(--wp--preset--color--surface-soft);
	color: var(--wp--preset--color--text-heading);
	font-size: var(--wp--preset--font-size--body);
	font-weight: var(--wp--custom--typography--weight--semibold);
	line-height: var(--wp--custom--typography--line-height--title);
}

.loyseo-single-toc__scroll {
	flex: 1 1 auto;
	min-height: 0;
	margin-top: var(--wp--preset--spacing--30);
	overflow-y: auto;
	scrollbar-color: var(--wp--preset--color--border-default) var(--wp--preset--color--surface-soft);
	scrollbar-width: thin;
}

.loyseo-single-toc__list {
	margin: 0;
	padding: 0;
	list-style: none;
}

.loyseo-single-toc__children {
	margin-left: var(--wp--preset--spacing--30);
}

.loyseo-single-toc__item {
	position: relative;
	display: flex;
	flex-wrap: wrap;
	align-items: flex-start;
	margin: 0 !important;
	padding: 0;
	list-style: none !important;
}

.loyseo-single-toc__item > a {
	flex: 1;
	min-width: 0;
	/*
	 * Keep every item label aligned. The expander itself is positioned in this
	 * reserved gutter, so leaf items need no presentational spacer element.
	 */
	padding: var(--wp--preset--spacing--10) 0 var(--wp--preset--spacing--10) calc(18px + var(--wp--preset--spacing--10));
	color: var(--wp--preset--color--text-body) !important;
	font-size: var(--wp--preset--font-size--small, 14px) !important;
	line-height: 1.4;
	text-decoration: none;
	overflow-wrap: anywhere;
}

.loyseo-single-toc__item > a:hover,
.loyseo-single-toc__item > a:focus-visible {
	color: var(--wp--preset--color--brand-primary) !important;
	text-decoration: underline;
}

/*
 * `all: unset` deliberately isolates this disclosure control from Elementor's
 * generic button rules. Every interactive state below remains visually still;
 * only the expanded state rotates the glyph.
 */
.loyseo-single-toc button.loyseo-single-toc__toggle,
.loyseo-single-toc button.loyseo-single-toc__toggle:hover,
.loyseo-single-toc button.loyseo-single-toc__toggle:active,
.loyseo-single-toc button.loyseo-single-toc__toggle:focus-visible {
	all: unset !important;
	position: absolute !important;
	top: 0 !important;
	left: 0 !important;
	display: grid !important;
	box-sizing: border-box !important;
	width: 18px !important;
	height: 28px !important;
	place-items: center !important;
	margin: 0 !important;
	padding: 0 !important;
	border: 0 !important;
	border-radius: 0 !important;
	background: transparent !important;
	background-image: none !important;
	box-shadow: none !important;
	color: var(--wp--preset--color--text-body) !important;
	font-family: inherit !important;
	font-size: var(--wp--preset--font-size--small) !important;
	font-weight: var(--wp--custom--typography--weight--regular) !important;
	line-height: 1 !important;
	text-align: center !important;
	text-decoration: none !important;
	filter: none !important;
	cursor: pointer !important;
	transition: transform 160ms ease !important;
	transform: rotate(0deg) !important;
	transform-origin: center !important;
}

.loyseo-single-toc__toggle[aria-expanded="true"] {
	transform: rotate(90deg) !important;
}

.loyseo-single-toc__toggle:focus-visible {
	outline: 2px solid var(--wp--preset--color--brand-primary);
	outline-offset: 1px;
}

.loyseo-single-toc__children {
	flex-basis: 100%;
}

.loyseo-single-toc__inline-shell {
	float: right;
	width: 25%;
	min-width: 280px;
	max-width: 320px;
	margin: 0 0 var(--wp--preset--spacing--40) 20px;
}

.loyseo-single-toc__inline-shell .loyseo-single-toc {
	border: 1px solid var(--wp--preset--color--border-subtle);
	box-shadow: none;
}

.loyseo-single-toc__fixed-marker {
	display: block;
	height: 0;
}

.loyseo-single-toc__minimize,
.loyseo-single-toc__maximize,
.loyseo-single-toc__mobile-trigger,
.loyseo-single-toc__mobile-overlay {
	display: none;
}

/* Inline TOCs leave normal document flow only after their start marker passes the fixed top. */
.loyseo-single-toc__inline-shell.is-fixed {
	position: fixed;
	/* Keep the sticky promotion bar visually and interactively above the TOC. */
	z-index: 15;
	top: 98px;
	right: 10px;
	width: clamp(280px, 25vw, 320px);
	float: none;
	margin: 0;
}

.loyseo-single-toc__inline-shell.is-fixed .loyseo-single-toc {
	max-height: calc(100dvh - 114px);
}

.loyseo-single-toc__inline-shell.is-fixed .loyseo-single-toc__minimize {
	display: grid;
	flex: 0 0 24px;
	width: 24px;
	height: 24px;
	place-items: center;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: var(--wp--custom--radius--compact);
	background: transparent;
	color: var(--wp--preset--color--text-body);
	font: inherit;
	font-size: var(--wp--preset--font-size--title);
	line-height: 1;
	cursor: pointer;
}

.loyseo-single-toc__inline-shell.is-fixed.is-minimized {
	position: fixed;
	width: 42px !important;
	min-width: 42px;
	max-width: 42px;
	height: 42px;
	top: auto;
	right: 10px !important;
	bottom: 132px;
	left: auto !important;
}

.loyseo-single-toc__inline-shell.is-fixed.is-minimized .loyseo-single-toc {
	display: none;
}

.loyseo-single-toc__inline-shell.is-fixed.is-minimized .loyseo-single-toc__maximize {
	display: grid;
	width: 42px;
	height: 42px;
	place-items: center;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: var(--wp--preset--color--brand-primary);
	box-shadow: var(--wp--custom--shadow--soft-compact);
	color: var(--wp--preset--color--surface-white);
	font-family: var(--wp--preset--font-family--site-sans);
	font-size: var(--wp--preset--font-size--small);
	font-weight: var(--wp--custom--typography--weight--semibold);
	line-height: 1;
	cursor: pointer;
}

.loyseo-single-toc__inline-shell.is-fixed button.loyseo-single-toc__minimize:hover,
.loyseo-single-toc__inline-shell.is-fixed button.loyseo-single-toc__minimize:active,
.loyseo-single-toc__inline-shell.is-fixed button.loyseo-single-toc__minimize:focus-visible,
.loyseo-single-toc__inline-shell.is-fixed button.loyseo-single-toc__maximize:hover,
.loyseo-single-toc__inline-shell.is-fixed button.loyseo-single-toc__maximize:active,
.loyseo-single-toc__inline-shell.is-fixed button.loyseo-single-toc__maximize:focus-visible {
	box-shadow: var(--wp--custom--shadow--soft-compact) !important;
	filter: none !important;
	transform: none !important;
}

.loyseo-single-toc__inline-shell.is-fixed button.loyseo-single-toc__minimize:focus-visible,
.loyseo-single-toc__inline-shell.is-fixed button.loyseo-single-toc__maximize:focus-visible {
	outline: 2px solid var(--wp--preset--color--brand-primary);
	outline-offset: 2px;
}

@media (min-width: 961px) {
	.loyseo-single__toc-sidebar {
		position: sticky;
		top: var(--wp--custom--header--promotion-sticky-height);
		z-index: 10;
	}

	body.admin-bar .loyseo-single__toc-sidebar {
		top: calc(var(--wp--custom--header--promotion-sticky-height) + 32px);
	}

	.loyseo-single__content :is(h2, h3, h4, h5, h6)[id] {
		scroll-margin-top: calc(var(--wp--custom--header--promotion-sticky-height) + var(--wp--preset--spacing--30));
	}

	body.admin-bar .loyseo-single__content :is(h2, h3, h4, h5, h6)[id] {
		scroll-margin-top: calc(var(--wp--custom--header--promotion-sticky-height) + var(--wp--preset--spacing--30) + 32px);
	}

	body.admin-bar .loyseo-single-toc__inline-shell.is-fixed {
		top: 130px;
	}

	body.admin-bar .loyseo-single-toc__inline-shell.is-fixed .loyseo-single-toc {
		max-height: calc(100dvh - 146px);
	}

	body.admin-bar .loyseo-single-toc__inline-shell.is-fixed.is-minimized {
		top: auto;
	}
}

@media (min-width: 901px) and (max-width: 960px) {
	.loyseo-single__toc-sidebar {
		position: sticky;
		top: 0;
		z-index: 10;
	}

	body.admin-bar .loyseo-single__toc-sidebar {
		top: 32px;
	}
}

@media (max-width: 900px) {
	.loyseo-single__toc-sidebar {
		grid-column: 1;
		order: -1;
	}

	.loyseo-single-toc__inline-shell {
		float: none;
		width: auto;
		min-width: 0;
		max-width: none;
		margin: 0 0 var(--wp--preset--spacing--40);
	}

	.loyseo-single-toc__inline-shell[data-mobile-mode="drawer"],
	.loyseo-single__toc-sidebar[data-mobile-mode="drawer"] {
		position: fixed;
		top: 0;
		right: 0;
		bottom: 0;
		z-index: 60;
		width: min(88vw, 360px);
		height: 100dvh;
		margin: 0;
		padding: var(--wp--preset--spacing--50);
		grid-column: auto;
		order: initial;
		background: var(--wp--preset--color--surface-soft);
		overflow-y: auto;
		transform: translateX(100%);
		transition: transform 180ms ease;
	}

	.loyseo-single-toc__inline-shell[data-mobile-mode="drawer"] .loyseo-single-toc,
	.loyseo-single__toc-sidebar[data-mobile-mode="drawer"] .loyseo-single-toc {
		max-height: none;
	}

	.loyseo-single-toc__inline-shell[data-mobile-mode="drawer"] .loyseo-single-toc__minimize,
	.loyseo-single__toc-sidebar[data-mobile-mode="drawer"] .loyseo-single-toc__minimize {
		display: grid;
		flex: 0 0 24px;
		width: 24px;
		height: 24px;
		place-items: center;
		margin: 0;
		padding: 0;
		border: 0;
		border-radius: var(--wp--custom--radius--compact);
		background: transparent;
		color: var(--wp--preset--color--text-body);
		font: inherit;
		font-size: var(--wp--preset--font-size--title);
		line-height: 1;
		cursor: pointer;
	}

	.loyseo-single-toc__mobile-trigger[data-mobile-mode="drawer"] {
		position: fixed;
		bottom: 132px;
		right: 10px;
		z-index: 40;
		display: grid;
		width: 42px;
		height: 42px;
		place-items: center;
		margin: 0;
		padding: 0;
		border: 0;
		border-radius: 50%;
		background: var(--wp--preset--color--brand-primary);
		box-shadow: var(--wp--custom--shadow--soft-compact);
		color: var(--wp--preset--color--surface-white);
		font-family: var(--wp--preset--font-family--site-sans);
		font-size: var(--wp--preset--font-size--small);
		font-weight: var(--wp--custom--typography--weight--semibold);
		cursor: pointer;
	}

	.loyseo-single-toc__mobile-overlay[data-mobile-mode="drawer"] {
		position: fixed;
		z-index: 50;
		display: block;
		inset: 0;
		width: 100%;
		height: 100%;
		margin: 0;
		padding: 0;
		border: 0;
		background: color-mix(in srgb, var(--wp--preset--color--text-heading) 35%, transparent);
		opacity: 0;
		visibility: hidden;
		transition: opacity 180ms ease, visibility 180ms ease;
	}

	body.loyseo-toc-drawer-open {
		overflow: hidden;
	}

	body.loyseo-toc-drawer-open .loyseo-single-toc__inline-shell[data-mobile-mode="drawer"],
	body.loyseo-toc-drawer-open .loyseo-single__toc-sidebar[data-mobile-mode="drawer"] {
		transform: translateX(0);
	}

	body.loyseo-toc-drawer-open .loyseo-single-toc__mobile-overlay {
		opacity: 1;
		visibility: visible;
	}
}
