Draw an ASCII oak tree (or a woman with curly hair?)
JavaScript (ES8),  215 ... 199  197 bytes
f=(n,k=(W=3*n+2)**.5-.5|0,x=.5-k-(W-n)**.5,R=(n,k)=&gt;S=''.padEnd(n,'.@_'[k]))=&gt;k+n+2?(w=k*-~k/2,k&lt;0?(x&gt;0?s=R(n,k+n+3):R(w+=~k,s=R(n-1)+R(1,~~x))+R(n-w,1))+`|${s}|`+S:R(w)+R(W-w*2,1))+`
`+f(n,k-1):''

Try it online!
or Test it online! against an ungolfed, straightforward implementation
How?
We define \$H\$ as the height of the upper part of the crown (where the width is increasing) and \$h\$ as the height of the lower part (where the width is decreasing).
Example for \$n=6\$:

We have:
$$H_n=\left\lfloor\sqrt{3n+2}+\frac{1}{2}\right\rfloor$$
and:
$$h_n=\left\lfloor\sqrt{2n+2}-\frac{1}{2}\right\rfloor$$
By computing these values beforehand, we can draw the tree from top to bottom with a single loop, which is implemented here as a recursive function.
The total height of the tree is \$H_n+n+1\$. We use a counter \$k\$ going from \$H_n-1\$ to \$-n-1\$.
 3 | ......@@@@@@@@       | upper crown
 2 | ...@@@@@@@@@@@@@@    |
 1 | .@@@@@@@@@@@@@@@@@@  |
 0 | @@@@@@@@@@@@@@@@@@@@ |
---+----------------------+-------------
-1 | @@@@@@|      |@@@@@@ | lower crown
-2 | ..@@@@|      |@@@@   |
-3 | .....@|     .|@      |
---+----------------------+-------------
-4 |       |      |       | trunk only
-5 |       |      |       |
-6 |       |      |       |
---+----------------------+-------------
-7 | ______|______|______ | roots

The number of leading spaces for the upper part of the crown is the \$k\$-th triangular number:
$$T_k=\frac{k\times(k+1)}{2}$$
The number of leading spaces for the lower part of the crown is given by:
$$\frac{(k+1)\times(k-2)}{2}=T_k-k-1$$
Commented
f = (                         // f is a recursive function taking:
  n,                          //   n = input
  k = (W = 3 * n + 2)         //   W = 3n + 2 = total width of the tree
      ** .5 - .5 | 0,         //   k = counter, initialized to floor(sqrt(W) - 1/2)
  x = .5 - k - (W - n) ** .5, //   x = 1/2 - k - sqrt(W - n)
  R = (n, k) =&gt;               //   R is a helper function returning and saving in S:
    S =                       //     a character identified with k ('.', '@', '_' or
      ''.padEnd(n, '.@_'[k])  //     a space) repeated n times
) =&gt;                          //
  k + n + 2 ?                 // if k is not equal to -n - 2:
    ( w = k * -~k / 2,        //   initialize w to the k-th triangular number
      k &lt; 0 ?                 //   if k is negative:
        ( x &gt; 0 ?             //     if x is positive (trunk only or roots):
            s =               //       set s to:
              R(n, k + n + 3) //         '_' * n if k = -n - 1, or space * n otherwise
          :                   //     else (lower crown):
            R(                //       append ...
              w += ~k,        //         ... w - k - 1 spaces
              s = R(n - 1) +  //         and set s to n - 1 spaces followed by
                  R(1, ~~x)   //         '.' if floor(x) = 0, or another space otherwise
            ) +               //
            R(n - w, 1)       //       append '@' * (n - w)
        ) +                   //
        `|${s}|` +            //     append s surrounded by '|' characters
        S                     //     append S
      :                       //   else (upper crown):
        R(w) +                //     append w spaces
        R(W - w * 2, 1)       //     append '@' * (W - 2w)
    ) +                       //
    `\n` +                    //   append a line-feed
    f(n, k - 1)               //   append the result of a recursive call with k - 1
  :                           // else:
    ''                        //   stop recursion