<!-- SOLID CITY · part 3028 -->
 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. */
    (function shoulderPass() {
      function grades() { var g = [0]; for (var gi = 1; gi < N; gi++) g.push((prof[gi] - prof[gi - 1]) / (st[gi].ds || stepM)); return g; }
      for (var sw2 = 0; sw2 < 6; sw2++) {
        var moved = 0;
        for (var j = 9; j < N - 9; j++) {
          var g = grades();
          if (Math.abs(g[j + 1] - g[j]) <= 0.20) continue;
          var before = Math.abs(g[j] - g[j - 1]) + Math.abs(g[j + 1] - g[j]) + Math.abs(g[j + 2] - g[j + 1]);
          var chord = (prof[j - 1] + prof[j + 1]) / 2;
          var cand = prof[j] + (chord - prof[j]) * 0.5;
          var hi = Math.max(prof[j], floorY[j]);
          if (cand < cutY[j]) cand = cutY[j];
          if (cand > hi) cand = hi;
          if (cand === prof[j]) continue;
          var keep = prof[j]; prof[j] = cand;
          var g2 = grades();
          var after = Math.abs(g2[j] - g2[j - 1]) + Math.abs(g2[j + 1] - g2[j]) + Math.abs(g2[j + 2] - g2[j + 1]);
          if (after < before - 1e-9) moved++; else prof[j] = keep;
        }
        if (!moved) break;
      }
      for (i = 0; i < N; i++) if (prof[i] < cutY[i]) prof[i] = cutY[i];
      envelope();
    })();
    for (i = 0; i < N; i++) { st[i].y = prof[i]; st[i].grade = i ? (prof[i] - prof[i - 1]) / (st[i].ds || stepM) : 0; }

    /* SUPERELEVATION — the curriculum's third discipline, and the
     * corridor's quiet triumph: banking is the balance law read
     * straight off the alignment's analytic curvature, bank =
     * atan(e), e ∝ κ. It needs no smoothing passes: on a clothoid
     * the curvature ramps linearly, so the tilt develops along the
     * transition exactly as the runoff law prescribes — the spiral
     * IS the runoff. The constant carries Solid City's own design
     * speed (the principles are the profession's; the dimensions
     * are ours), and the cap remains the spec's law. */
    for (i = 0; i < N; i++) st[i].bank = Math.max(-bankCap, Math.min(bankCap, -Math.atan(st[i].kappa * 1.31)));

    /* THE JUNCTION THROAT: a road that must braid past its
     * neighbour in the first metres from a node may be built
     * narrower there, widening smoothly as the lines part —
     * spec.taperStart / taperEnd {width, over}. Only the SURFACE
     * narrows; the profile above was computed for the full
     * breadth, and the height law does not 