On iOS 26, `UIWindowScene.keyWindow` can be nil during scene connection until the scene becomes active. The implicitly-unwrapped `mainWindow` then crashes on the next line. Fall back to `scene.windows.first`, which is the SwiftUI WindowGroup's window and is already attached to the scene at this point.