Let $(X,\rho)$ be a metric space. Two sets $A,B\subseteq X$ are separated if $\overline{A}\cap B=\varnothing$ and $\overline{B}\cap A=\varnothing$. Show that $A$ and $B$ are separated if and only if there exist open sets $U$ and $V$ with $A\subseteq U, B\subseteq V$ such that $U\cap V=\varnothing$.
I think I have a solution but I have a couple of questions about it.
Assume $A$ and $B$ are separated. If $A$ and $B$ are open, then we can take $U=A$ and $V=B$ and we're done. If either of $A$ or $B$ are closed, then we get the stronger condition that $\overline{A}\cap\overline{B}=\varnothing$. Let $\text{diam}(A)=\alpha$ and $\text{diam}(B)=\beta$. Let $x\in A, y\in B$ be such that $\rho(x,y)$ is minimal over all $x\in A,y\in B$. Then $x\in\overline{A}, y\in\overline{B}\Rightarrow x\neq y \Rightarrow \rho(x,y)=\epsilon>0$. The let $U,V$ be open sets such that $ \text{diam}(U)=\alpha+\frac{\epsilon}{4} \qquad \text{diam}(V)=\beta+\frac{\epsilon}{4} $ and $A\subseteq U, B\subseteq V$. Then $U\cap V=\varnothing$ and we're done.
Assume we have $U$ and $V$ as above. Because $\text{diam}(X)=\text{diam}(\overline{X})$ for any set $X$ in a metric space, $ \text{diam}(\overline{A})\leq \text{diam}(U) \qquad \text{diam}(\overline{B})\leq \text{diam}(V) $ Let $x\in\overline{A}$ and consider $\min\{\rho(x,y)\;|\;x\in\overline{A}, y\in B\}=:\epsilon$. We want to show that $\epsilon>0$. First notice that $\min\{\rho(u,v)\;|\;u\in U, v\in V\}>0$. Since $B\subseteq V,\min\{\rho(u,y)\;|\;u\in U, y\in B\}>0 $. But we also have that $u$ is at least as close to $B$ as $x\Rightarrow \epsilon>0$. Thus, $\overline{A}\cap B=\varnothing$. By the same argument, $\overline{B}\cap A=\varnothing$. Thus $A$ and $B$ are separated.
What happens if $A$ or $B$ is neither open nor closed though? I always confuse myself with these types of arguments because I'm assuming that a set is always either open or closed, but that's clearly not true. Is there a way to justify only considering these cases?