An analytical model is developed for the wind-driven circulation in a continuously stratified ocean overlying variable bottom topography. In the ocean interior we adopt a linear relation between potential vorticity, density and Montgomery potential, resulting in Welander's solution for an adiabatic internal thermocline. The horizontal structure of the circulation is described by a characteristic equation, obtained by imposing a boundary condition of no-normal flow at the sea floor and a prescribed vertical velocity through the base of the surface Ekman layer. The characteristics, which determine the extent to which bottom topography "steers" the circulation within the upper ocean, are dominated by latitude circles at low latitudes, but are increasingly influenced by the bottom topography at higher latitudes as the thermocline widens and intersects the sea floor. A solution is evaluated for the full three-dimensional circulation in the North Pacific. We find classical Sverdrup gyres within the thermocline, increasingly zonal flows at mid-depths, and weak topographically-bounded gyres within the abyssal ocean.