<!-- RUBY-BACKUP · part 311 -->
on: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 EDITOR — compose letters, engrave them on stone tablets */
var _epistleOpen = false;
function toggleEpistleEditor(){
  _epistleOpen = !_epistleOpen;
  var ee = document.getElementById('epistleEditor');
  if(_epistleOpen){
    if(!ee){
      ee = document.createElement('div');
      ee.id = 'epistleEditor';
      ee.style.cssText = 'position:fixed;top:0;left:0;width:100%;height:100%;background:rgba(0,0,0,0.92);z-index:20000;display:flex;align-items:center;justify-content:center;padding:16px;box-sizing:border-box;';
      ee.innerHTML = '<div style="background:#0d0a06;border:2px solid #ffd700;border-radius:12px;padding:20px;width:100%;max-width:480px;display:flex;flex-direction:column;gap:12px;max-height:90vh;overflow-y:auto;">'
        + '<div style="color:#ffd700;font-family:serif;font-size:20px;text-align:center;">✒️ Epistle Editor</div>'
        + '<div style="color:#888;font-size:12px;text-align:center;">Write for the ancestors. Engrave it in stone.</div>'
        + '<input id="epistleTitle" placeholder="Title..." style="background:#111;color:#ffd700;border:1px solid #8a6a1c;border-radius:8px;padding:12px;font-family:serif;font-size:16px;">'
        + '<textarea id="epistleBody" placeholder="Write your epistle here..." style="width:100%;height:220px;background:#111;color:#fff;border:1px soli