<!-- SOLID CITY · part 3026 -->
smooth crests, but the road was
     * riding its cut floor (floor − 2.2) through the ridges, and
     * the floor, sampled from the land, crests as sharply as the
     * land does. So floor and want are eased where they reverse:
     * at a station whose grade enters above +15% and leaves
     * below −15%, the point is lowered toward the chord of its
     * neighbours — at most 1.2 m, never below the lower
     * neighbour's line — which is to say the cut deepens exactly
     * at sharp crests, the topography sliced where slicing buys
     * smoothness. Sags are untouched: a dipped floor never binds
     * a profile that bridges it on fill. A road whose grades
     * never reach 15% holds no reversal the rule can see, and is
     * left exactly as it lies. */
    (function easeCrests() {
      function ease(arr, cap) {
        var orig = arr.slice();
        for (var pass = 0; pass < 2; pass++) {
          var src = arr.slice();
          for (var j = 2; j < N - 2; j++) {
            /* the reversal is read over TWO stations each way:
             * a ridge crest in the land is as often a two-station
             * plateau as a point (Road C's apex: the floor stands
             * level across sts 281–282 with the fall beyond), and
             * a one-station stencil reads level-in, level-out and
             * sees no crest at all. */
            var dA = (st[j].ds || stepM) + (st[j - 1].ds || stepM), dB = (st[j + 1].ds || stepM) + (st[j + 2].ds || stepM);
            var gIn = (src[j] - src[j - 2]) / dA, gOut = (src[j + 2] - src[j]) / dB;
            if (gIn > 0.15 && gOut < -0.15) {
              var kern = src[j - 2] * 0.15 + src[j - 1] * 0.2 + src[j] * 0.3 + src[j + 1] * 0.2 + src[j + 2] * 0.15;
              var low = Math.min(src[j - 2], src[j + 2]) - 0.5;
              arr[j] = Math.max(kern, orig[j] - cap, low);
              if (arr[j] > src[j]) arr[j] = src[j];
            }
          }
        }
      }
      ease(floorY, 1.2);
      ease(prof, 1.2);
    })();
    /* The envelope survives as the profile's SAFETY NET (it is
     * called again below and inside the host-plane blend): the
     * profile never sinks under its floor and never grades beyond
     * the cap; its passes only ever RAISE — a limiter that could
     * also lower would drag the surface under the floor it was
     * sworn to keep (the first build's burial was that crime). */
    for (i = 0; i < N; i++) if (prof[i] < floorY[i]) prof[i] = floorY[i];
    /* THE CUT (the King's word, 2026-10-13 ~23:56): "some of these
     * ups and downs could be cut in to the topography to make the
     * drive smoother." The demand keeps its honest floor above;
     * the DESIGN is granted a cut allowance — a second floor 2.2 m
     * lower, used by every clamp after the alignment is drawn.
     * The road may slice that deep through a hump instead of
     * riding over it; the drape and the new cliff walls dress the
     * cut, and the smoothing passes in the alignment spend the
     * allowance where the land rolls hardest. */
    var CUT = 2.2;
    var cutY = floorY.map(function (v) { return v - CUT; });
    function envelope() {
      var i2;
      for (i2 = 1; i2 < N; i2++) { var d = st[i2].ds || stepM; var need = prof[i2 - 1] - gradeCap * d; if (prof[i2] < need) prof[i2] = need; }
      for (i2 = N - 2; i2 >= 0; i2--) { var d2 = st[i2 + 1].ds || stepM; var need2 = prof[i2 + 1] - gradeCap * d2; if (prof[i2] < need2) prof[i2] = need2; }
    }
    /* THE VERTICAL ALIGNMENT — the corridor's second element
     * chain, in the vertical plane (the curriculum's discipline
     * 2). The design profile is a chain of GRADE SEGMENTS through
     * PVIs — points of vertical intersection — joined by PARABOLIC
     * vertical curves: y = yPVC + gIn·t + (gOut−gIn)·t²/(2L), the
     * curve's length from its rate L = K·A (K = 6 m per percent of
     * grade change, A the grades' difference). PVIs stand about
     * twelve metres apart on the terrain's demand (the floored
     * want computed above); the pins are the chain's two ends,
     * exact by construction; the chain is grade-limited by raising
     * the low end of any over-cap segment, the envelope's own
     * discipline, before a single parabola is drawn. What the
     * parabolas cannot honour — a floor that fights back — the
     * envelope below re-proves, as it always has. */
    (function verticalAlign() {
      var arcS = [0];
      for (var vi2 = 1; vi2 < N; vi2++) arcS.push(arcS[vi2 - 1] + (st[vi2].ds || stepM));
      var pIdx = [0];
      for (vi2 = 1; vi2 < N - 1; vi2++) if (arcS[vi2] - arcS[pIdx[pIdx.length - 1]] >= 12) pIdx.push(vi2);
      pIdx.push(N - 1);
      var m = pIdx.length, H = pIdx.map(function (ix) { return prof[ix]; });
      if (spec.pinStartY != null) H[0] = spec.pinStartY;
      if (spec.pinEndY != null) H[m - 1] = spec.pinEndY;
      for (var lp = 0; lp < 3; lp++) {
        for (var j = 0; j < m - 1; j++) {
          var dS = 