.theme-switch {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	margin: 0;
	padding: 0;
	border: 0;
	color: var(--subtle, var(--text));
	font: 600 12px "DM Sans", "Trebuchet MS", sans-serif;
}
.theme-switch legend {
	float: left;
	margin: 0 8px 0 0;
	padding: 0;
	line-height: 34px;
}
.theme-options {
	display: inline-flex;
	padding: 3px;
	border: 1px solid var(--outline, var(--border-strong));
	border-radius: 999px;
	background: var(--surface-soft, var(--panel));
}
.theme-options label { position: relative; display: block; cursor: pointer; }
.theme-options input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.theme-options span {
	position: relative;
	display: block;
	width: 34px;
	height: 30px;
	border-radius: 999px;
	color: var(--subtle, var(--text));
	font-size: 0;
	transition: background 160ms ease, color 160ms ease;
}
.theme-options span::before {
	position: absolute;
	top: 50%;
	left: 50%;
	display: block;
	width: 17px;
	height: 17px;
	background: currentColor;
	content: "";
	transform: translate(-50%, -50%);
	mask-repeat: no-repeat;
	mask-position: center;
	mask-size: contain;
}
.theme-options input[value="system"] + span::before {
	mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M4 3h16a2 2 0 0 1 2 2v11a2 2 0 0 1-2 2h-7v2h4v2H7v-2h4v-2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2zm0 2v11h16V5z'/%3E%3C/svg%3E");
}
.theme-options input[value="dark"] + span::before {
	mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M20.9 13.1A8.5 8.5 0 0 1 10.9 3.1a9 9 0 1 0 10 10z'/%3E%3C/svg%3E");
}
.theme-options input[value="light"] + span::before {
	mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M11 1h2v3h-2zm0 19h2v3h-2zM1 11h3v2H1zm19 0h3v2h-3zM4.2 5.6l1.4-1.4 2.1 2.1-1.4 1.4zm12.1 12.1 1.4-1.4 2.1 2.1-1.4 1.4zM16.3 6.3l2.1-2.1 1.4 1.4-2.1 2.1zM4.2 18.4l2.1-2.1 1.4 1.4-2.1 2.1zM12 6a6 6 0 1 1 0 12 6 6 0 0 1 0-12z'/%3E%3C/svg%3E");
}
.theme-options input:checked + span {
	background: var(--surface, var(--black));
	color: var(--text);
	box-shadow: 0 1px 5px rgba(0, 0, 0, .18);
}
.theme-options input:focus-visible + span { outline: 2px solid var(--accent-strong, var(--gold)); outline-offset: 2px; }
@supports selector(:has(*)) {
	.theme-options { position: relative; display: grid; grid-template-columns: repeat(3, 1fr); }
	.theme-options::before {
		position: absolute;
		top: 3px;
		bottom: 3px;
		left: 3px;
		width: calc((100% - 6px) / 3);
		border-radius: 999px;
		background: var(--surface, var(--black));
		box-shadow: 0 1px 5px rgba(0, 0, 0, .18);
		content: "";
		transition: transform 160ms ease;
	}
	.theme-options:has(input[value="dark"]:checked)::before { transform: translateX(100%); }
	.theme-options:has(input[value="light"]:checked)::before { transform: translateX(200%); }
	.theme-options label { z-index: 1; text-align: center; }
	.theme-options input:checked + span { background: transparent; box-shadow: none; }
}
@media (prefers-reduced-motion: reduce) { .theme-options::before, .theme-options span { transition: none; } }
