They can detain you and take your device, but they cannot compel you to give up your password, to be clear. As a US Citizen you have a right to re-enter the country.
The letter of the law says you are correct. Reality however disagrees. People who are most definitely US citizens have in fact been put in jail for the simple not-crime of refusing to provide passwords to their devices to law enforcement.