<script>
(function () {
  const IMG_URL = 'https://gwinfoto.xyz/bgr/background.png';

  // ===== 1. BERSIHKAN PERUBAHAN DARI PERCOBAAN SEBELUMNYA =====
  const app = document.getElementById('app');
  const index = document.getElementById('index');

  if (app) {
    app.style.removeProperty('margin-left');
    app.style.removeProperty('margin-right');
    app.style.removeProperty('width');
    app.style.removeProperty('max-width');
  }

  if (index) {
    index.style.removeProperty('background-image');
    index.style.removeProperty('background-size');
    index.style.removeProperty('background-position');
    index.style.removeProperty('background-repeat');
    index.style.removeProperty('background-attachment');
    index.style.removeProperty('width');
    index.style.removeProperty('min-height');
    index.style.removeProperty('flex');
    index.style.removeProperty('left');
    index.style.removeProperty('right');
  }

  document.documentElement.style.removeProperty('background-image');
  document.body.style.removeProperty('background-image');

  // Hapus layer lama kalau sebelumnya sudah pernah dipasang
  const oldLayer = document.getElementById('custom-bg-layer');
  if (oldLayer) oldLayer.remove();

  // ===== 2. PASANG BACKGROUND LAYER BARU (AMAN, TIDAK GANGGU LAYOUT) =====
  const bgLayer = document.createElement('div');
  bgLayer.id = 'custom-bg-layer';
  bgLayer.style.cssText = `
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-image: url('${IMG_URL}');
    background-size: cover;
    background-position: center top;
    background-repeat: no-repeat;
    z-index: -1;
    pointer-events: none;
  `;
  document.body.insertBefore(bgLayer, document.body.firstChild);

  console.log('Background layer berhasil dipasang. Navbar & layout asli tidak diubah.');
})();
</script>