Demixing properties of major planetary constituents influence the interior structure and evolution of planets. Comparing experimental and computational data on the miscibility of hydrogen and water to adiabatic profiles suggests that phase separation between these two components occurs in the ice giants Uranus and Neptune. We aim to predict the atmospheric water abundance and transition pressure between the water-poor outer envelope and the water-rich deep interior in Uranus and Neptune. We constructed seven H$_ $-H$_ $O phase diagrams from the available experimental and computational data. We computed interior adiabatic structure models and compared these to the phase diagrams to infer whether demixing occurred. We obtain a strong water depletion in the top layer due to the rain-out of water and find upper limits on the atmospheric water-mass fraction Zatm of 0.21 for Uranus and 0.16 for Neptune. The transition from the water-poor to the water-rich layer is sharp and occurs at pressures $P_Z$ between 4 and 11 GPa. Using these constraints on Zatm and $P_Z$, we find that the observed gravitational harmonics $J_2$ and $J_4$ can be reproduced if $P_Z 10$ GPa in Uranus and $ 5$ GPa in Neptune, and if the deep interior has a high primordial water-mass fraction of 0.8, unless rocks are also present. The agreement with $J_4$ is improved if rocks are confined deeper than $P_Z$, for instance, below a rock cloud level at 2000 K (20--30 GPa). These findings confirm classical few-layer models and suggest that a layered structure may result from a combination of primordial mass accretion and subsequent phase separation. Reduced observational uncertainty in $J_4$ and its dynamic contribution, atmospheric water abundance measurements from the Uranus Orbiter and Probe (UOP) or a Neptune mission, and better understanding of the mixing behaviour of constituents are needed to constrain the interiors of ice giants.