4. As shown in Figure 1, in the cube $A B C D-A_{1} B_{1} C_{1} D_{1}$, $P$ is a point on edge $A B$. A line $l$ is drawn through point $P$ in space such that $l$ makes a $30^{\circ}$ angle with both plane $A B C D$ and plane $A B C_{1} D_{1}$. The number of such lines is ( ).
(A) 1
(B) 2
(C) 3
(D) 4
4. B.

Since the dihedral angle $C_{1}-A B-D$ has a plane angle of $45^{\circ}$, therefore, within this dihedral angle and its "opposite" dihedral angle, there does not exist a line passing through point $P$ that forms a $30^{\circ}$ angle with both plane $A B C D$ and plane $A B C_{1} D_{1}$. Instead, consider its supplementary dihedral angle. It is easy to know that there are exactly 2 lines passing through point $P$ that form a $30^{\circ}$ angle with both plane $A B C D$ and plane $A B C_{1} D_{1}$. Therefore, there are 2 lines $l$ that satisfy the conditions.