You can't stay airside. When you arrive, you'll be in the international arrivals area before clearing Canadian immigration. From here it is not possible to access any departure gates and there is nowhere to sleep. It is a segregated area that serves no purpose except to contain travellers who have not yet cleared immigration and customs. You will have to go through immigration and you will not be able to go to the US departures area until the day of your flight (because US CBP will not let you through). US preclearance opens at 04:30 each morning.
You can sleep landside. There should be no trouble with airport security as long as you can show an onward ticket the next day.