Draw an ASCII oak tree (or a woman with curly hair?) Task

Your task is to draw these beautiful oak trees:

1 -&gt;
 @@@
@@@@@
@|.|@
_|_|_

2 -&gt;
   @@
 @@@@@@
@@@@@@@@
@@| .|@@
  |  |
__|__|__

3 -&gt;
   @@@@@
 @@@@@@@@@
@@@@@@@@@@@
@@@|   |@@@
  @|  .|@
   |   |
___|___|___

4 -&gt;
      @@
   @@@@@@@@
 @@@@@@@@@@@@
@@@@@@@@@@@@@@
@@@@|    |@@@@
  @@|   .|@@
    |    |
    |    |
____|____|____

5 -&gt;
      @@@@@
   @@@@@@@@@@@
 @@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@
@@@@@|     |@@@@@
  @@@|    .|@@@
     |     |
     |     |
     |     |
_____|_____|_____

6 -&gt;
      @@@@@@@@
   @@@@@@@@@@@@@@
 @@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@
@@@@@@|      |@@@@@@
  @@@@|      |@@@@
     @|     .|@
      |      |
      |      |
      |      |
______|______|______


(that one sandbox commenter felt were similar to women with curly hair!)

The trees are allowed to be surrounded by any extra whitespace your solution creates as long as that doesn't break the tree, of course.

Algorithm

As per the examples above, we take n to represent the width of the trunk and the specs of the tree will be given in terms of that.

Given n:


the height of the trunk is n + 1;
the width of the trunk in space characters is n;
the top row of the trunk is n times the character @, followed by |, n times the space character , another vertical pipe | and then n times @.
from the reference row up to the top of the crown, we only use @ as follows:


there is one row with the same width as the reference row and each subsequent row above is shortened by one @ than the previous shortening;

from the reference row downwards, we chop 2 @ from each side and then each row we go down, we chop one more @ than the previous row;
the last trunk row that is surrounded by a @ has a . immediately to the left of the right vertical pipe |;
the bottom most row has the underscore _ in all the tree width, except where the trunk vertical pipes | are.
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