<!-- SOLID CITY · part 3063 -->
;
        for (var ci = 0; ci < curves.length; ci++) {
          var cv = curves[ci];
          if (s >= cv.sC - cv.L / 2 && s <= cv.sC + cv.L / 2) {
            var t = s - (cv.sC - cv.L / 2);
            y = (cv.yPVI - cv.gIn * cv.L / 2) + cv.gIn * t + (cv.gOut - cv.gIn) * t * t / (2 * cv.L);
            break;
          }
        }
        prof[vi2] = y;
      }
    })();
    for (i = 0; i < N; i++) if (prof[i] < cutY[i]) prof[i] = cutY[i];   // the design may cut; the demand may not
    envelope(); envelope();
    /* a guest at a node is given the host's PLANE for its first
     * stretch of arc: the host's grade along its own heading, the
     * host's bank across it, and the guest's profile held within a
     * hand's breadth of that plane for twelve metres — so two
     * roads leave a junction as ONE surface, and what seam remains
     * is the disc's to cover, never the traveller's to feel. Where
     * the floor and the plane quarrel, the floor wins: a road may
     * ride above its host's plane on honest fill, but it is never
     * buried to keep an appointment. */
    if (spec.pinHost) {
      var ph = spec.pinHost, tbH = Math.tan(ph.bank), arcH = 0;
      for (i = 0; i < N; i++) {
        if (i) arcH += st[i].ds || stepM;
        if (arcH > 12) break;
        var alH = (st[i].x - ph.x) * ph.fx + (st[i].z - ph.z) * ph.fz;
        var acH = (st[i].x - ph.x) * ph.rx + (st[i].z - ph.z) * ph.rz;
        var pyH = ph.y + ph.grade * alH + tbH * acH;
        if (prof[i] < pyH - 0.35) prof[i] = pyH - 0.35;
        if (prof[i] > pyH + 0.35) prof[i] = pyH + 0.35;
        if (prof[i] < cutY[i]) prof[i] = cutY[i];
      }
      envelope();
      if (spec.pinStartY != null) {
        prof[0] = spec.pinStartY;
        for (i = 1; i < N; i++) { var dpc = st[i].ds || stepM; var ndc = prof[i - 1] - gradeCap * dpc; if (prof[i] < ndc) prof[i] = ndc; }
      }
    }
    /* the pins are promises, and promises have feet: the cap-chains
     * that honour them meet the natural profile at a corner. A few
     * raise-only passes round those feet with honest fill, the
     * envelope re-proves every grade, and then the pins are set
     * exact once more — the promise stands, and the road walks up
     * to it like a road, not a step. */
    if (spec.pinStartY != null || spec.pinEndY != null) {
      for (var rp = 0; rp < 3; rp++) {
        var rsm = prof.slice();
        for (i = 1; i < N - 1; i++) { var rcand = prof[i - 1] * 0.3 + prof[i] * 0.4 + prof[i + 1] * 0.3; if (rcand > prof[i]) rsm[i] = rcand; }
        prof = rsm;
      }
      envelope();
      if (spec.pinStartY != null) prof[0] = spec.pinStartY;
      if (spec.pinEndY != null) prof[N - 1] = spec.pinEndY;
    }
    /* THE PIN APRON — the envelope's missing half, and the last
     * word on the profile. The cap chains limit how fast the
     * profile may FALL away from a station; nothing limited how
     * fast it may RISE away from a pin, and at the braid head the
     * host's banked plane lifted the second station 0.63 m over
     * the pin in a single step (45%, measured). The apron trims
     * any rise out of a pin to the cap across the first stations,
     * down to the floor and never below it; where the floor itself
     * forbids, the junction disc — which owns that ground — covers
     * what remains. It runs after the host-plane blend and the
     * pins-feet rounding, so nothing after it can reopen the seam. */
    (function pinApron() {
      var arcA = 0;
      for (var ai2 = 1; ai2 < N && ai2 <= 8; ai2++) {
        arcA += st[ai2].ds || stepM;
        var lim = prof[0] + gradeCap * arcA;
        if (prof[ai2] > lim) prof[ai2] = Math.max(cutY[ai2], lim);
      }
      var arcB = 0;
      for (ai2 = N - 2; ai2 >= 0 && ai2 >= N - 9; ai2--) {
        arcB += st[ai2 + 1].ds || stepM;
        var limB = prof[N - 1] + gradeCap * arcB;
        if (prof[ai2] > limB) prof[ai2] = Math.max(cutY[ai2], limB);
      }
    })();
    /* THE SHOULDER PASS (the hardening night, 2026-10-14): the
     * last shaping of the profile, and the answer to the knees
     * the census convicted. A crest eased at its floor still met
     * its descent in a single segment (−1% into −38% at Road C's
     * apex brow), because the descent is drawn by the envelope
     * at the grade cap while the crest rests at its eased
     * height, and nothing until now owned the JOIN. The pass
     * diffuses any station break sharper than 20 points: the
     * station walks halfway toward the chord of its neighbours,
     * again and again, a move accepted only when the three
     * breaks it touches lose more sharpness than they gain, and
     * never outside the sworn bounds — never below the cut
     * floor, never above the higher of its present height and
     * its demand floor. The pin aprons' ground — the first and
     * last nine stations — is not the pass's to touch: the
     * junction discs own it, as the apron's epistle swore. */
    (fu