Automatic theme change corrupts theme selected by the user

When I added automation for theme change based on sunsets the theme selected by a user is corrupting. On some devices, the theme is different than used by automation so the whole frontend has theme selected by user but Lovelace cards have a theme selected by a backend.
Take a look: