The South was in a quasi-legal state that the government treated as a rebellion. A rebellion was a recognized possibility, as given in Article 1, Section 9 of the Constitution.
The Privilege of the Writ of Habeas Corpus shall not be suspended, unless when in Cases of Rebellion or Invasion the public Safety may require it.
Treason was also defined in the Constitution, most relevantly in Article 3, Section 3.
Section 3
Treason against the United States, shall consist only in levying War against them, or in adhering to their Enemies, giving them Aid and Comfort.
Secession is not mentioned at all.
What the government could do in cases of rebellion or treason or secession was not as explicitly written out. Treason by an individual was punishable, but treason by a state was not. Clearly the government had some powers to act, but in practical reality Lincoln had to make them all up on the fly.
Those choices rode a fine line. Lincoln acted as if the government was fighting another sovereign entity while maintaining the pretense that it was putting down a local rebellion. People who make comments on the legality of so doing are pulling opinions out of their … hat. The courts in the North mostly accepted all the decisions made - they would have been crazy not to, but they looked away the majority of the time. After the war, a famous decision called Ex parte Milligan established that the government could not use extraordinary powers in areas that were not in active rebellion.
Military commissions organized during the late civil war, in a State not invaded and not engaged in rebellion, in which the Federal courts were open, and in the proper and unobstructed exercise of their judicial functions, had no jurisdiction to try, convict, or sentence for any criminal offense, a citizen who was neither a resident of a rebellious State nor a prisoner of war, nor a person in the military or naval service. And Congress could not invest them with any such power.
This may look as if it can be retroactively applied to the EP. But the text adroitly sidesteps that.
"That on the first day of January, in the year of our Lord one thousand eight hundred and sixty-three, all persons held as slaves within any State or designated part of a State, the people whereof shall then be in rebellion against the United States, shall be then, thenceforward, and forever free; and the Executive Government of the United States, including the military and naval authority thereof, will recognize and maintain the freedom of such persons, and will do no act or acts to repress such persons, or any of them, in any efforts they may make for their actual freedom.
“That the Executive will, on the first day of January aforesaid, by proclamation, designate the States and parts of States, if any, in which the people thereof, respectively, shall then be in rebellion against the United States; and the fact that any State, or the people thereof, shall on that day be, in good faith, represented in the Congress of the United States by members chosen thereto at elections wherein a majority of the qualified voters of such State shall have participated, shall, in the absence of strong countervailing testimony, be deemed conclusive evidence that such State, and the people thereof, are not then in rebellion against the United States.”
The EP is a military declaration rather than a civic one and it limits itself to areas in a state of rebellion, a distinction also made by Ex parte Milligan.
The status of the CSA has never been legally clarified, to my knowledge. Everybody then and later just agreed to let the past be past, settled, as the adage has it, by Grant v. Lee. You are therefore free to take any legal position on the theoretical fine points and nobody can definitely refute them. However, that means that you can’t defend them either. The only correct answer is, nobody knows and nobody ever will.