This is a rough of my concept;
The AC is rectified by the diode bridge, with current limiting via the two 470K resistor, so only around 250uA drawn from the mains and fed through the optocoupler LED.
The transistor is turned on for part of each half cycle, when the LED is drawing current, and repeatedly discharged C1, so the MOSFET gate never gets any appreciable voltage on it and the MOSFET is held off.
If the AC fails, the optocoupler transistor does not turn on so the capacitor charges and the MOSFET switches on, over a few seconds. That sounds the alarm or turns on a relay to switch eg. an AC operated alarm.
View attachment 144718