- In the Shortcuts app, tap Automation, and create a new one.
- Select 'App' as the trigger.
- Select Mail and Safari for the apps; also select 'Is Opened' and 'Run Immediately'. (Leave 'Notify When Run' off.)
- Tap Next.
- Select 'New Blank Automation'.
- Search for the 'Set Appearance' action and add it.
- Set the action to 'Turn appearance Light'.
- Tap 'Done.
For the second automation, repeat the above steps, but use 'Is Closed' for step 3 and 'Turn appearance Dark' for step 7.