<!-- RUBY-BACKUP · part 313 -->
Update = true; } });
      },
      undo: function(){
        target.traverse(function(m){ if(m.isMesh && m.material){ m.material.map = null; m.material.needsUpdate = true; } });
      }
    });
    codeStatus('wrote "' + text.substring(0,20) + '"');
  }catch(e){ codeStatus('write failed'); }
}
/* CODE CONSOLE — paste area for Solid, for speed */
var _consoleOpen = false;
function toggleCodeConsole(){
  _consoleOpen = !_consoleOpen;
  var cc = document.getElementById('codeConsole');
  if(_consoleOpen){
    if(!cc){
      cc = document.createElement('div');
      cc.id = 'codeConsole';
      cc.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;';
      cc.innerHTML = '<div style="background:#0a0a0a;border:2px solid #ffd700;border-radius:12px;padding:16px;width:100%;max-width:500px;display:flex;flex-direction:column;gap:10px;">'
        + '<div style="color:#ffd700;font-family:monospace;font-size:14px;">SOLID CODE CONSOLE — paste & run</div>'
        + '<textarea id="codeInput" placeholder="// paste JavaScript here" style="width:100%;height:200px;background:#111;color:#0f0;border:1px solid #333;border-radius:8px;font-family:monospace;font-size:12px;padding:10px;box-sizing:border-box;resize:vertical;"></textarea>'
        + '<div style="display:flex;gap:10px;">'
        + '<button id="codeRun" style="flex:1;background:#ffd700;color:#111;border:none;border-radius:8px;padding:12px;font-size:16px;cursor:pointer;">▶ Run</button>'
        + '<button id="codeClear" style="background:#333;color:#fff;border:none;border-radius:8px;padding:12px 20px;font-size:16px;cursor:pointer;">Clear</button>'
        + '<button id="codeClose" style="background:#333;color:#fff;border:none;border-radius:8px;padding:12px 20px;font-size:16px;cursor:pointer;">X</button>'
        + '</div>'
        + '<div id="codeOutput" style="color:#888;font-family:monospace;font-size:11px;max-height:80px;overflow-y:auto;"></div>'
        + '</div>';
      document.body.appendChild(cc);
      document.getElementById('codeRun').onclick = function(){
        var code = document.getElementById('codeInput').value;
        var out = document.getElementById('codeOutput');
        try{
          var result = eval(code);
          out.innerHTML = '<span style="color:#0f0;">OK: ' + String(result).substring(0,200) + '</span>';
          try{ codeStatus('code ran'); }catch(e){}
        }catch(e){
          out.innerHTML = '<span style="color:#f44;">ERR: ' + e.message + '</span>';
        }
      };
      document.getElementById('codeClear').onclick = function(){
        document.getElementById('codeInput').value = '';
        document.getElementById('codeOutput').innerHTML = '';
      };
      document.getElementById('codeClose').onclick = function(){ toggleCodeConsole(); };
      cc.onclick = function(e){ if(e.target===cc) toggleCodeConsole(); };
    }else{
      cc.style.display = 'flex';
    }
  }else if(cc){
    cc.style.display = 'none';
  }
}
var _helpOpen = false;
function toggleHelp(){
  _helpOpen = !_helpOpen;
  var h = document.getElementById('helpOverlay');
  if(_helpOpen){
    if(!h){
      h = document.createElement('div');
      h.id = 'helpOverlay';
      h.style.cssText = 'position:fixed;top:0;left:0;width:100%;height:100%;background:rgba(0,0,0,0.9);z-index:20000;display:flex;align-items:center;justify-content:center;padding:20px;box-sizing:border-box;';
      h.innerHTML = '<div style="background:#111;border:2px solid #ffd700;border-radius:16px;padding:24px;max-width:400px;max-height:80vh;overflow-y:auto;color:#fff;font-family:sans-serif;">'
        + '<h2 style="color:#ffd700;margin-top:0;">How to Use the Creator</h2>'
        + '<p><b style="color:#ffd700;">Cheat Codes</b> — Type in the bar up top:<br>'
        + 'hourglass, pylon, hollowtetra, layeredpyramid — spawn shapes<br>'
        + 'body + paintbody — build and paint the body<br>'
        + 'solidhand — build the 3D hand<br>'
        + 'truelines — intaglio linework</p>'
        + '<p><b style="color:#ffd700;">Touch</b><br>'
        + 'Long-press a block (hold 1 sec) — swipe to spin, release for menu<br>'
        + 'Right edge — flick to spring the panel back<br>'
        + 'X button — collapse everything</p>'
        + '<p><b style="color:#ffd700;">Linework</b> — Pick grid density, background, presets, and colors from the chooser.</p>'
        + '<button onclick="toggleHelp()" style="background:#ffd700;color:#111;border:none;border-radius:8px;padding:12px 24px;font-size:16px;cursor:pointer;width:100%;">Got it</button>'
        + '</div>';
      document.body.appendChild(h);
      h.onclick = function(e){ if(e.target===h) toggleHelp(); };
    }else{
      h.style.display = 'flex';
    }
  }else if(h){
    h.style.display = 'none';
  }
}
function toggleButtonMenu(){
  _menuOpen = !_menuOpen;
  if(_menuPanel)