I am told that, in the US, people sentenced to death by a state can apply to that state's court for habeas corpus and then, if that fails, apply to a federal court for habeas corpus again.
I thought habeas corpus is habeas corpus. You are either lawfully imprisoned or you aren't. Even if the writ is being considered by a federal court, they are still judging your imprisonment against state law (or so I presume, since there wouldn't be any federal law relevant to your imprisonment for a state offence).
What is the difference between state and federal habeas corpus?