:root{
  --lb-yellow: #f1b132;
  --lb-red: #ff5252;
}

#lbox{
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0,0,0,.88);
  display: none;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;

  /* dôležité pre mobily */
  padding:
    max(12px, env(safe-area-inset-top))
    max(12px, env(safe-area-inset-right))
    max(12px, env(safe-area-inset-bottom))
    max(12px, env(safe-area-inset-left));
}

#lbox.show{
  display: flex;
}

#lbox #lbimg{
  display: block;
  width: auto !important;
  height: auto !important;
  min-width: 0;
  min-height: 0;
  max-width: calc(100dvw - 24px) !important;
  max-height: calc(100dvh - 24px) !important;
  object-fit: contain !important;
  aspect-ratio: auto !important;

  border-radius: 10px;
  border: 1px solid var(--stroke, rgba(255,255,255,.15));
  box-shadow: 0 10px 40px rgba(0,0,0,.6);
}

/* fallback pre staršie prehliadače */
@supports not (height: 100dvh){
  #lbox #lbimg{
    max-width: calc(100vw - 24px) !important;
    max-height: calc(100vh - 24px) !important;
  }
}

#lbox .lb-btn{
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  width: 50px;
  height: 50px;
  border-radius: 50%;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  font-size: 26px;
  font-weight: 900;
  line-height: 1;
  box-shadow: 0 8px 24px rgba(0,0,0,.35);
  transition: transform .12s ease, filter .12s ease, opacity .12s ease;
  opacity: .98;
}

#lbox .lb-prev,
#lbox .lb-next{
  background: var(--lb-yellow);
  color: #111;
  border: 1px solid rgba(0,0,0,.1);
}

#lbox .lb-prev{ left: max(10px, env(safe-area-inset-left)); }
#lbox .lb-next{ right: max(10px, env(safe-area-inset-right)); }

#lbox .lb-close{
  top: max(10px, env(safe-area-inset-top));
  right: max(10px, env(safe-area-inset-right));
  transform: none;
  width: 44px;
  height: 44px;
  border-radius: 999px;
  background: var(--lb-red);
  color: #fff;
  font-size: 16px;
  font-weight: 800;
}

/* desktop hover */
#lbox .lb-btn:hover{
  transform: translateY(-50%) scale(1.06);
  filter: brightness(1.05);
}
#lbox .lb-btn:active{
  transform: translateY(-50%) scale(.96);
}
#lbox .lb-close:hover{
  transform: scale(1.06);
}
#lbox .lb-close:active{
  transform: scale(.95);
}

/* mobil */
@media (max-width: 640px){
  #lbox{
    padding:
      max(8px, env(safe-area-inset-top))
      max(8px, env(safe-area-inset-right))
      max(8px, env(safe-area-inset-bottom))
      max(8px, env(safe-area-inset-left));
  }

  #lbox #lbimg{
    max-width: calc(100dvw - 16px) !important;
    max-height: calc(100dvh - 16px) !important;
    border-radius: 8px;
  }

  #lbox .lb-btn{
    width: 42px;
    height: 42px;
    font-size: 22px;
  }

  #lbox .lb-prev{ left: max(6px, env(safe-area-inset-left)); }
  #lbox .lb-next{ right: max(6px, env(safe-area-inset-right)); }

  #lbox .lb-close{
    top: max(6px, env(safe-area-inset-top));
    right: max(6px, env(safe-area-inset-right));
    width: 40px;
    height: 40px;
    font-size: 15px;
  }
}