Arm SHM when door closes in night mode?

I would like to have SHM automatically arm to stay mode when my bedroom door is closed at night, and disarm when it’s opened. I created a routine to arm SHM when the system is in night mode and the door closes. Plus another routine to do the opposite. But this misses the case where I close the door before the system goes into night mode at 11:00 PM. Is there a clean way to handle this, preferably using the stock SmartThings apps?

Can you trigger the Routine to fire on the door close action itself?

“Automatically perform X when bedroom door closes between these hours and these hours.”

Yes, I have a routine that triggers based on the door close action when the system is in night mode (2300 hours to 0700 hours). That works well. But it doesn’t solve the problem of arming the system when the door has been closed for the night before the system enters night mode at 2300. I need something that will arm SHM when the system enters night mode and the door contact is already closed. Preferably something that is a native SmartThings tool so that it runs locally.

If you don’t mind getting into coding, there’s always the route of CoRE… I myself have beehive a regular user of that app…