[part="swatch-wrapper"] {
	display: inline-flex;
	align-items: baseline;
	gap: 0.2em;
	margin-inline: 0.1em;
}

#swatch {
	--_transparency-cell-size: var(--transparency-cell-size, clamp(6px, 0.5em, 30px));
	--_transparency-background: var(--transparency-background, transparent);
	--_transparency-darkness: var(--transparency-darkness, 5%);
	--_transparency-grid: var(
		--transparency-grid,
		repeating-conic-gradient(
				transparent 0 25%,
				rgb(0 0 0 / var(--_transparency-darkness)) 0 50%
			)
			0 0 / calc(2 * var(--_transparency-cell-size)) calc(2 * var(--_transparency-cell-size))
			content-box border-box var(--_transparency-background)
	);

	--color-image: linear-gradient(var(--color), var(--color));
	--border-width: clamp(2px, 0.15em, 16px);
	--box-shadow-blur: clamp(2px, 0.1em, 5px);
	--box-shadow-color: rgb(0 0 0 / 0.3);

	position: relative;
	bottom: calc(-1 * var(--border-width) - 0.1em);
	width: 1.2em;
	height: 1.2em;
	border: var(--border-width) solid white;
	box-sizing: border-box;
	background: var(--color-image, 0), var(--_transparency-grid, canvas);
	box-shadow: calc(var(--box-shadow-blur) * 0.2) calc(var(--box-shadow-blur) * 0.2)
		var(--box-shadow-blur) var(--box-shadow-color);
	border-radius: clamp(1px, 0.1em, 10px);
}

#swatch:hover {
	transform: scale(1.5);
	transition: 0.4s;
}

#swatch.invalid {
	--color-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><text y=".9em" font-size="90">⚠️</text></svg>');
	--_transparency-grid: initial;
}

@media (prefers-color-scheme: dark) {
	#swatch {
		--box-shadow-color: rgb(0 0 0 / 0.8);
	}
}
