      .modern-image-viewer {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        z-index: 10000;
        font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s ease;
      }

      .modern-image-viewer.active {
        opacity: 1;
        visibility: visible;
      }

      .miv-backdrop {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.9);
        backdrop-filter: blur(10px);
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 20px;
      }

      .miv-container {
        width: 100%;
        height: 100%;
        max-width: 1400px;
        display: flex;
        flex-direction: column;
        background: rgba(255, 255, 255, 0.05);
        border-radius: 12px;
        overflow: hidden;
        border: 1px solid rgba(255, 255, 255, 0.1);
      }

      .miv-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 16px 20px;
        background: rgba(0, 0, 0, 0.3);
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
      }

      .miv-counter {
        color: rgba(255, 255, 255, 0.8);
        font-size: 14px;
        font-weight: 500;
      }

      .miv-close {
        background: none;
        border: none;
        color: rgba(255, 255, 255, 0.8);
        cursor: pointer;
        padding: 8px;
        border-radius: 6px;
        transition: all 0.2s ease;
      }

      .miv-close:hover {
        background: rgba(255, 255, 255, 0.1);
        color: white;
      }

      .miv-content {
        flex: 1;
        display: flex;
        align-items: center;
        justify-content: center;
        position: relative;
        overflow: hidden;
      }

      .miv-nav {
        position: absolute;
        top: 50%;
        transform: translateY(-50%);
        background: rgba(0, 0, 0, 0.5);
        border: 1px solid rgba(255, 255, 255, 0.2);
        color: white;
        border-radius: 50%;
        width: 48px;
        height: 48px;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        transition: all 0.2s ease;
        z-index: 10;
      }

      .miv-nav:hover {
        background: rgba(0, 0, 0, 0.8);
        border-color: rgba(255, 255, 255, 0.4);
      }

      .miv-prev { left: 20px; }
      .miv-next { right: 20px; }

      .miv-canvas {
        position: relative;
        max-width: calc(100% - 120px);
        max-height: calc(100% - 120px);
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: grab;
        transition: cursor 0.2s ease;
        touch-action: none; /* Critical for mobile panning */
      }

      .miv-canvas.dragging {
        cursor: grabbing;
      }

      .miv-image {
        max-width: 100%;
        max-height: 100%;
        object-fit: contain;
        transition: transform 0.2s ease, opacity 0.3s ease;
        user-select: none;
        -webkit-user-drag: none;
        transform-origin: center center;
      }

      /* Wrapper used to animate slide-in/out without interfering with the image's transform
         (image transform is used for zoom/pan/rotate) */
      .miv-image-wrap {
        display: inline-block;
        will-change: transform, opacity;
      }

      .miv-image.switching {
        opacity: 0;
        transform: scale(0.95);
      }

      .miv-image.loaded {
        opacity: 1;
        transform: scale(1);
      }

      .miv-loading {
        color: rgba(255, 255, 255, 0.7);
        font-size: 16px;
        display: none;
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
      }

      .miv-loading.active {
        display: block;
      }

      .miv-footer {
        padding: 16px 20px;
        background: rgba(0, 0, 0, 0.3);
        border-top: 1px solid rgba(255, 255, 255, 0.1);
      }

      .miv-tools {
        display: flex;
        justify-content: center;
        align-items: center;
        gap: 8px;
      }

      .miv-tool {
        background: rgba(255, 255, 255, 0.1);
        border: 1px solid rgba(255, 255, 255, 0.2);
        color: white;
        padding: 8px 16px;
        border-radius: 6px;
        cursor: pointer;
        transition: all 0.2s ease;
        font-size: 14px;
        display: flex;
        align-items: center;
        gap: 6px;
      }

      .miv-tool:hover {
        background: rgba(255, 255, 255, 0.2);
        border-color: rgba(255, 255, 255, 0.3);
      }

      .miv-zoom-level {
        font-weight: 600;
      }

      @media (max-width: 768px) {
        .miv-backdrop {
          padding: 10px;
        }
        
        .miv-nav {
          width: 40px;
          height: 40px;
        }
        
        .miv-prev { left: 10px; }
        .miv-next { right: 10px; }
        
        .miv-canvas {
          max-width: calc(100% - 60px);
          max-height: calc(100% - 100px);
        }

        .miv-tools {
          gap: 4px;
        }

        .miv-tool {
          padding: 6px 12px;
          font-size: 12px;
        }
      }

      /* Improved slide animations applied to the wrapper to avoid transform conflicts */
      .miv-image-wrap.switch-animation {
        animation: miv-slide-in-right 0.32s cubic-bezier(.22,.9,.35,1) both;
      }
      .miv-image-wrap.switch-animation-prev {
        animation: miv-slide-in-left 0.32s cubic-bezier(.22,.9,.35,1) both;
      }

      @keyframes miv-slide-in-right {
        0% { transform: translateX(28%) scale(0.985); opacity: 0; }
        60% { transform: translateX(-6%) scale(1.01); opacity: 1; }
        100% { transform: translateX(0) scale(1); opacity: 1; }
      }

      @keyframes miv-slide-in-left {
        0% { transform: translateX(-28%) scale(0.985); opacity: 0; }
        60% { transform: translateX(6%) scale(1.01); opacity: 1; }
        100% { transform: translateX(0) scale(1); opacity: 1; }
      }
    