% =============================================================================
% dag-basic.tex — Three-node causal DAG with a confounder
%
% Shows: X → Y with confounder U affecting both X and Y.
% Compiles standalone via: xelatex dag-basic.tex
% =============================================================================

\documentclass[border=4pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta, positioning}

\definecolor{node-fill}{HTML}{E8EDF5}
\definecolor{node-border}{HTML}{012169}
\definecolor{arrow}{HTML}{1A1A1A}
\definecolor{confound}{HTML}{B23A48}

\tikzset{
  dag-node/.style={
    draw=node-border, fill=node-fill, rounded corners=2pt,
    minimum width=1.2cm, minimum height=0.9cm, align=center, font=\small
  },
  dag-edge/.style={-{Latex[length=2.5mm]}, thick, draw=arrow},
  confound-edge/.style={-{Latex[length=2.5mm]}, thick, draw=confound, dashed}
}

% -----------------------------------------------------------------------------
% Diagram: Confounded X → Y. U is observed/unobserved confounder above.
% Coordinates:
%   U at (3, 2.2)  -- confounder, top center
%   X at (0, 0)    -- treatment, lower left
%   Y at (6, 0)    -- outcome, lower right
% All nodes 1.2 x 0.9cm; chord X-Y = 6cm straight edge, no Bézier.
% Confound edges U→X and U→Y are diagonal with label on the outside.
% -----------------------------------------------------------------------------

\begin{document}
\begin{tikzpicture}
  \node[dag-node] (U) at (3, 2.2) {$U$};
  \node[dag-node] (X) at (0, 0)   {$X$};
  \node[dag-node] (Y) at (6, 0)   {$Y$};

  \draw[dag-edge]      (X) -- (Y) node[midway, above] {\small effect};
  \draw[confound-edge] (U) -- (X) node[midway, left]  {\small confound};
  \draw[confound-edge] (U) -- (Y) node[midway, right] {\small confound};
\end{tikzpicture}
\end{document}
