sh-code-block {
	/* Token palette — darker variants for contrast on the light surface below. */
	--token-comment: var(--sh-color-neutral-40);
	--token-string: var(--sh-color-success-20);
	--token-keyword: var(--sh-color-info-50);
	--token-number: var(--sh-color-warning-20);
	--token-boolean: var(--sh-color-warning-20);
	--token-function: var(--sh-color-info-20);
	--token-operator: var(--sh-color-neutral-30);
	--token-punctuation: var(--sh-color-neutral-30);
	--token-tag: var(--sh-color-danger-20);
	--token-attr-name: var(--sh-color-warning-20);
	--token-attr-value: var(--sh-color-success-20);
	--token-property: var(--sh-color-info-50);
	--token-selector: var(--sh-color-danger-20);
	--token-at-rule: var(--sh-color-info-50);
	/* No hue is left for types, and the darkest tones read as plain text: mix two hues into a violet. */
	--token-type: color-mix(in oklch, var(--sh-color-info-50) 55%, var(--sh-color-danger-50));
	--token-regexp: var(--sh-color-danger-20);
	--token-variable: var(--sh-color-warning-20);
	--token-inserted: var(--sh-color-success-20);
	--token-deleted: var(--sh-color-danger-20);

	color: var(--sh-color-neutral-0);
	background-color: var(--sh-color-neutral-90);
	border: 2px solid var(--sh-color-neutral-0);

	&::part(pre) {
		padding: 1rem;
		line-height: 1.5;

		/* The <pre> is the focusable, scrollable box; inset the outline so it stays inside the border. */
	}

	&::part(pre):focus-visible {
		outline: var(--sh-focus-outline);
		outline-offset: calc(var(--sh-focus-outline-offset) * -1);
	}

	/* Toolbar — holds the label and the copy button. The sh-copy lives in the shadow DOM, so the global `sh-copy`
	   theme can't reach it: it is styled through the forwarded parts (the icon still swaps to convey
	   success/error). */

	&::part(toolbar) {
		gap: var(--sh-space-xs);
		padding: var(--sh-space-xs);
		background-color: var(--sh-color-neutral-100);
		border-block-end: 2px solid var(--sh-color-neutral-0);
	}

	&::part(label) {
		padding-inline: var(--sh-space-xs);
		font-family: monospace;
		font-size: calc(0.8125em / 0.875);
		font-weight: 700;
		color: var(--sh-color-neutral-20);
	}

	&::part(copy-button) {
		min-inline-size: 2rem;
		min-block-size: 2rem;
		padding: var(--sh-space-xs);
		color: var(--sh-color-neutral-0);
		background-color: transparent;
		border-radius: var(--sh-border-radius-xs);
	}

	&::part(copy-button):hover {
		background-color: var(--sh-color-neutral-80);
	}

	&::part(copy-button):focus-visible {
		outline: var(--sh-focus-outline);
		outline-offset: calc(var(--sh-focus-outline-offset) * -1);
	}

	&::part(copy-icon) {
		--icon-size: 1.125rem;
	}
}

/* Motion */

@media (prefers-reduced-motion: no-preference) {
	sh-code-block::part(copy-button) {
		transition: background-color 100ms ease;
	}
}
