  We calculate shifts and width of 1s and 2p states of pions bound to heavy
nuclei, using an optical potential with its s-wave interaction part based on
chiral symmetry. This potential is constructed systematically in two-loop
approximation of chiral perturbation theory. A proper treatment of the explicit
energy dependence of this potential in conjunction with gauge invariance turns
out to be very important. Results are reported for deeply bound pionic states
in Pb and Sn isotopes in comparison with the GSI data
