<!-- RUBY-BACKUP · part 531 -->
cute: function(){
        // re-apply is complex; store the result
        snapshots.forEach(function(s){
          var pos = s.mesh.geometry.attributes.position;
          // this is a simplified redo — full redo would need the delta
          pos.needsUpdate = true;
        });
      },
      undo: function(){
        snapshots.forEach(function(s){
          var pos = s.mesh.geometry.attributes.position;
          pos.array.set(s.orig);
          pos.needsUpdate = true;
          s.mesh.geometry.computeVertexNormals();
        });
      }
    });
    codeStatus('sculpted: ' + brush);
  }catch(e){ codeStatus('sculpt failed'); }
}
/* TRIM & CALIBRATE MODE — Playa 2.0 spec, 0.13 precision */
var _trimOpen = false;
var TRIM_STEP = 0.13;
function toggleTrimMode(){
  _trimOpen = !_trimOpen;
  var tm = document.getElementById('trimPanel');
  if(_trimOpen){
    var target = window._highlighted || window._selectedBlock;
    if(!target){ codeStatus('tap a block first, then trim'); _trimOpen = false; return; }
    if(!tm){
      tm = document.createElement('div');
      tm.id = 'trimPanel';
      tm.style.cssText = 'position:fixed;bottom:80px;left:50%;transform:translateX(-50%);z-index:15000;background:rgba(10,8,4,0.92);border:2px solid #ffd700;border-radius:16px;padding:12px;display:flex;flex-direction:column;gap:8px;max-width:94vw;';
      tm.innerHTML = '<div style="color:#ffd700;font-family:monospace;font-size:13px;text-align:center;">TRIM — 0.13 steps</div>'
        + '<div style="display:flex;gap:6px;justify-content:center;align-items:center;">'
        + '<span style="color:#888;font-size:11px;">MOVE</span>'
        + '<button data-trim="mx-" style="trimbtn">X-</button>'
        + '<button data-trim="mx+" style="trimbtn">X+</button>'
        + '<button data-trim="my-" style="trimbtn">Y-</button>'
        + '<button data-trim="my+" style="trimbtn">Y+</button>'
        + '<button data-trim="mz-" style="trimbtn">Z-</button>'
        + '<button data-trim="mz+" style="trimbtn">Z+</button>'
        + '</div>'
        + '<div style="display:flex;gap:6px;justify-content:center;align-items:center;">'
        + '<span style="color:#888;font-size:11px;">SPIN</span>'
        + '<button data-trim="rx-" style="trimbtn">◀</button>'
        + '<button data-trim="rx+" style="trimbtn">▶</button>'
        + '<button data-trim="ry-" style="trimbtn">◀</button>'
        + '<button data-trim="ry+" style="trimbtn">▶</button>'
        + '</div>'
        + '<div style="display:flex;gap:6px;justify-content:center;align-items:center;">'
        + '<span style="color:#888;font-size:11px;">SIZE</span>'
        + '<button data-trim="s-" style="trimbtn">−</button>'
        + '<button data-trim="s+" style="trimbtn">＋</button>'
        + '<button id="trimClose" style="background:#333;color:#fff;border:none;border-radius:8px;padding:10px 16px;font-size:14px;">X</button>'
        + '</div>';
      // style the trim buttons
      var st = document.createElement('style');
      st.textContent = '[data-trim]{background:#1a1a1a;color:#ffd700;border:1px solid #ffd700;border-radius:8px;min-width:44px;min-height:44px;font-size:16px;cursor:pointer;} [data-trim]:active{background:#ffd700;color:#111;}';
      document.head.appendChild(st);
      document.body.appendChild(tm);
      tm.querySelectorAll('[data-trim]').forEach(function(b){
        b.onclick = function(){ doTrim(b.getAttribute('data-trim')); };
      });
      document.getElementById('trimClose').onclick = function(){ toggleTrimMode(); };
    }else{
      tm.style.display = 'flex';
    }
    codeStatus('trim mode — 0.13');
  }else if(tm){
    tm.style.display = 'none';
    codeStatus('trim closed');
  }
}
function doTrim(action){
  var target = window._highlighted || window._selectedBlock;
  if(!target) return;
  var before = { p: target.position.clone(), r: target.rotation.clone(), s: target.scale.clone() };
  var s = TRIM_STEP;
  if(action==='mx+') target.position.x += s;
  else if(action==='mx-') target.position.x -= s;
  else if(action==='my+') target.position.y += s;
  else if(action==='my-') target.position.y -= s;
  else if(action==='mz+') target.position.z += s;
  else if(action==='mz-') target.position.z -= s;
  else if(action==='rx+') target.rotation.x += Math.PI/12;
  else if(action==='rx-') target.rotation.x -= Math.PI/12;
  else if(action==='ry+') target.rotation.y += Math.PI/12;
  else if(action==='ry-') target.rotation.y -= Math.PI/12;
  else if(action==='s+') target.scale.multiplyScalar(1.1);
  else if(action==='s-') target.scale.multiplyScalar(0.9);
  var after = { p: target.position.clone(), r: target.rotation.clone(), s: target.scale.clone() };
  pushCommand({
    name: 'trim ' + action,
    execute: function(){ target.position.copy(after.p); target.rotation.copy(after.r); target.scale.copy(after.s); },
    undo: function(){ target.position.copy(before.p); target.rotation.copy(before.r); target.scale.copy(before.s); }
  });
}
/* EPISTLE ED