Edge and divertor plasma: detachment, stability, and plasma-wall interactions