Here’s how you can fix it

Change it back to C# code: in VS2019 click Tools>Options>Environment>Fonts and Colors>HTML Razor Code Background.

On the right side, you can select another Item background. You can select another background that uses your default color and save it as a custom color then go back to select it.

Use code-behind!

You can add a standard C# class as a partial class in the same parent as the Blazor Page and name it PageName.Razor.cs where it will layer appropriately. You can then use this code-behind as the page logic instead of it being embedded to the view code.