Style the parent <form> based on invalid <input required>
<form>
<input required>
form:has(input:focus:invalid) { border-color: red; }