<!-- SOLID CITY · part 3061 -->
(sU.x - sU.rx * (hw + 1.2), sU.z - sU.rz * (hw + 1.2));
      upScore += (uRg - uLg);
    }
    var upSide = upScore >= 0 ? 1 : -1;

    /* the profile: keyed to the uphill edge, floored by the surface.
     * desired: the uphill edge sits a hair under its own ground (the
     * dirt meets the road), and the surface rises from that edge
     * toward the centre at a civil cross slope. The floor's law is
     * stated where it is computed (v3, below). */
    /* the cross-section is read through a median first: a rib that
     * crosses the line for ONE station is a feature of the land, not
     * an order to the road — the road answers the land's grain, and
     * the rib's corner is dressed by the cut bank where it stands.
     * The floor (v3) swears two things only: the centre is never
     * buried, and no edge may drag the whole surface more than
     * 1.35 m above the centre for its own sake. */
    var rawC = [], rawL = [], rawR = [];
    for (i = 0; i < N; i++) {
      var s0 = st[i];
      rawC.push(groundAt(s0.x, s0.z));
      rawL.push(groundAt(s0.x - s0.rx * hw, s0.z - s0.rz * hw));
      rawR.push(groundAt(s0.x + s0.rx * hw, s0.z + s0.rz * hw));
      s0.gC = rawC[i];
    }
    function med3(arr, j) {
      var a = arr[Math.max(0, j - 1)], b = arr[j], c = arr[Math.min(N - 1, j + 1)];
      return a + b + c - Math.min(a, b, c) - Math.max(a, b, c);
    }
    var prof = [], floorY = [];
    for (i = 0; i < N; i++) {
      var s = st[i];
      var gC = med3(rawC, i);
      var gL = med3(rawL, i), gR = med3(rawR, i);
      var crossMax = Math.max(gL, gC, gR);
      var gUp = upSide > 0 ? gR : gL;
      var sCross = Math.max(-0.04, Math.min(0.10, (gC - gUp) / hw));
      var want = gUp - 0.06 + hw * sCross;
      if (want > gC + 1.05) want = gC + 1.05;        // never fill the centre higher
      prof.push(want);
      floorY.push(Math.max(gC + 0.06, Math.min(crossMax - 0.30, gC + 1.35)));
      s.crossMax = crossMax; s.gUp = gUp;
    }
    /* THE CREST EASING (the hardening night, 2026-10-14 — the
     * King's "run it hard," and his own Cut doctrine carried one
     * step further): the measured knife-edges in the finished
     * profile — +38% into one flat segment into −38% at Road C's
     * ridge crossings — were traced to the FLOOR itself. The
     * design's parabolas drew 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