<?php
$accent = ugly_get( 'accent' );
if ( preg_match( '/^#[0-9a-fA-F]{6}$/', (string) $accent ) ) {
echo '<style>:root { --accent: ' . esc_html( $accent ) . '; }</style>';
}Check it before you put it in a <style> tag. The field cleans it when saving, but a style tag is a place to be careful.