Coupled-cluster method with optimized reference state