document.addEventListener('DOMContentLoaded', () => {
  const openBtn = document.getElementById('led-tool-btn');
  const modal = document.getElementById('led-tool-modal');
  const closeBtn = document.getElementById('led-tool-close-btn');
  const iframe = document.getElementById('led-tool-iframe');

  if (!openBtn || !modal || !iframe) {
    return;
  }

  openBtn.addEventListener('click', () => {
    iframe.src = '/led-tool/editor';
    modal.classList.add('active');
  });

  if (closeBtn) {
    closeBtn.addEventListener('click', () => {
      modal.classList.remove('active');
      iframe.src = 'about:blank';
    });
  }
});
