<!-- RUBY-BACKUP · part 286 -->
h(function(st){
      var u = st.userData;
      if(u.shape==='cube' && u.rubies===15 && !u.filler){
        var d = Math.hypot(st.position.x-sx, st.position.z-sz);
        if(d < bd){ bd = d; bs = st; }
      }
    });
    if(bs){
      var sh = spawnShoe(bs.position.x, bs.position.z, -camYaw);
      sh.position.y = bs.position.y + 15*window.MINIMUM;
      persistShoes();
      codeStatus('shoe — enthroned atop the babystep');
    }else{
      spawnShoe(sx, sz, -camYaw);
      codeStatus('shoe — the monument, precise to your picture');
    }
    return; }
  if(tl==='king'){
    var ksp = freeSpawn(cursor.x, cursor.z);
    spawnKingNPC(ksp.x, ksp.z);
    codeStatus('a king stands in the world — not you');
    return; }
  if(tl==='nokings'){
    npcKings.forEach(function(k){ scene.remove(k); });
    npcKings = [];
    persistKings();
    codeStatus('the kings are gone');
    return; }
  if(tl==='newmap'||tl==='selfdestruct'||tl==='soliditronium1snap'){
    var n = selfDestruct();
    codeStatus(n ? (tl==='soliditronium1snap' ? 'snap — all gone. `oops` brings them back' : tl==='selfdestruct' ? 'self-destruct — `oops` brings them back' : 'new map — `oops` brings the old field back') : 'new map');
    return; }
  var trimmed0 = line.trim();
  if(trimmed0.toLowerCase().indexOf('take')===0){
    var tk = trimmed0.slice(4).trim(), p0 = shareDecode(tk);
    if(!p0){ codeStatus('refused \u00b7 bad code'); return; }
    var nm0=p0.n, kk0=2;
    while(SAVES[nm0]) nm0 = p0.n+(kk0++);
    SAVES[nm0]={stones:p0.s}; persistSaves();
    codeStatus(nm0+' received ('+p0.s.length+' stones) \u2014 punch '+nm0+' to build it');
    return; }
  if(tl.indexOf('send')===0){
    var sd0 = tl.split(/\s+/);
    if(sd0[1] && SAVES[sd0[1]]){
      var code0 = shareEncode(sd0[1]);
      try{ if(navigator.clipboard && navigator.clipboard.writeText) navigator.clipboard.writeText(code0); }catch(e){}
      codeInput.value = code0; codeInput.focus(); codeInput.select();
      codeStatus('code ready \u2014 copy it and send it to your friend');
    } else codeStatus(sd0[1] ? 'no save named '+sd0[1] : 'send <name>');
    return; }
  var spotM = tl.match(/^(save|go)(\d+)$/);
  if(spotM){
    /* save1, save2... — save a spot; go1, go2... — go to it. spots persist. */
    var sk = 'ruby-spots-v1', spots = {};
    try{ spots = JSON.parse(localStorage.getItem(sk)||'{}'); }catch(e){ spots = {}; }
    var sn = spotM[2];
    if(spotM[1]==='save'){
      if(spots[sn]){ codeStatus('spot '+sn+' is taken'); return; }
      var px = (WALK ? mePos.x : cursor.x), pz = (WALK ? mePos.z : cursor.z);
      spots[sn] = {x:px, z:pz};
      try{ localStorage.setItem(sk, JSON.stringify(spots)); }catch(e){}
      undoStack.push({victim:'spot', spot:sn});
      if(undoStack.length>10) undoStack.shift();
      saveUndo();
      codeStatus('spot '+sn+' saved');
    }else{
      if(!spots[sn]){ codeStatus('no spot '+sn+' — stand somewhere and punch save'+sn); return; }
      if(!WALK) setWalk(true);
      var gp = freeSpawn(spots[sn].x, spots[sn].z);
      mePos.set(gp.x, 0, gp.z); meVel.set(0,0,0);
      codeStatus('spot '+sn);
    }
    return; }
  if(tl.indexOf('save')===0){ var sv=tl.split(/\s+/);
    if(sv[1] && /^[a-z][a-z0-9]*$/.test(sv[1]) && !SAVE_RESERVED[sv[1]]) saveSelection(sv[1]);
    else codeStatus('save <name> — a fresh word');
    return; }
  if(tl.indexOf('swap')===0){ var sp = tl.split(/\s+/); if(sp[1]){ swapSelection(sp[1]); } else { codeStatus('swap <code> — e.g. swap s'); } return; }
  if(selection.length) clearSelection();
  var p = parseLine(line, ec);
  if(!p.ok){ codeStatus('refused · '+p.error); return; }
  var v = validateOps(p.ops);
  if(v){ codeStatus('refused · '+v); return; }
  if(!p.ops.length){ codeStatus('nothing to build'); return; }
  var r = runOps(p.ops, procMassOf(p.ops));
  cursor.x = ec.x; cursor.z = ec.z; saveCursor(); paintCursor();
  codeStatus(r.raised+' raised'+(r.stepped?' · '+r.stepped+' stepped over':'')+(r.cleared?' · '+r.cleared+' cleared':''));
}
window.runLine = runLine; /* exposed for hook chain */

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   MARK: COMMAND BAR — wired. The > button, the input, the voice.
   (Look lives in MARK: COMMAND BAR in index.html.)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
var codeBtn = document.getElementById('codebtn'),
    codeInput = document.getElementById('codeinput') || document.getElementById('solidinput'),
    codeT = null;
function codeStatus(msg, sticky){
  if(pendingDid){ didLog.push({line:pendingDid, res:msg}); if(didLog.length>8) didLog.shift(); persistDid(); pendingDid=null; }
  var st = document.getElementById('codetext-status');
  if(!st) return;
  st.textContent = msg; st.style.whiteSpace = 'pre-line'; st.style.opacity = '1'; st.style.pointerEvents = 'none';
  if(codeT) clearTimeout(codeT);
  if(!sticky) codeT = setTimeout(function(){ st.style.opacity = '0'; }, 2600);
}
if(codeBtn) codeBtn.addEvent